aboutsummaryrefslogtreecommitdiff
path: root/xorg-server
diff options
context:
space:
mode:
authormarha <marha@users.sourceforge.net>2010-12-23 07:51:31 +0000
committermarha <marha@users.sourceforge.net>2010-12-23 07:51:31 +0000
commit71e1361d0fd4c2d1c6c31f9a28d474fceee7e12e (patch)
tree4e5cebc3ac6d1c0f5dd765697a7c2ad7be796136 /xorg-server
parent374f6889ce26ba0a914d07f4946cd113263a6e18 (diff)
parent8fd06c45853cb2300105db84e4b722f0e2dad8d2 (diff)
downloadvcxsrv-71e1361d0fd4c2d1c6c31f9a28d474fceee7e12e.tar.gz
vcxsrv-71e1361d0fd4c2d1c6c31f9a28d474fceee7e12e.tar.bz2
vcxsrv-71e1361d0fd4c2d1c6c31f9a28d474fceee7e12e.zip
svn merge ^/branches/released .
Diffstat (limited to 'xorg-server')
-rw-r--r--xorg-server/Xext/sync.c5768
-rw-r--r--xorg-server/Xext/xf86bigfont.c1502
-rw-r--r--xorg-server/configure.ac1
-rw-r--r--xorg-server/dix/dixfonts.c4172
-rw-r--r--xorg-server/hw/xfree86/common/Makefile.am185
-rw-r--r--xorg-server/hw/xfree86/common/compiler.h3559
-rw-r--r--xorg-server/hw/xfree86/common/scoasm.h142
-rw-r--r--xorg-server/hw/xfree86/common/xf86.h708
-rw-r--r--xorg-server/hw/xfree86/common/xf86Bus.c1307
-rw-r--r--xorg-server/hw/xfree86/common/xf86Configure.c1549
-rw-r--r--xorg-server/hw/xfree86/common/xf86Cursor.c1720
-rw-r--r--xorg-server/hw/xfree86/common/xf86Events.c1511
-rw-r--r--xorg-server/hw/xfree86/common/xf86Globals.c395
-rw-r--r--xorg-server/hw/xfree86/common/xf86Init.c3007
-rw-r--r--xorg-server/hw/xfree86/common/xf86PM.c23
-rw-r--r--xorg-server/hw/xfree86/common/xf86Priv.h315
-rw-r--r--xorg-server/hw/xfree86/common/xf86str.h1819
-rw-r--r--xorg-server/hw/xfree86/ddc/ddc.c1009
-rw-r--r--xorg-server/hw/xfree86/int10/helper_exec.c1465
-rw-r--r--xorg-server/hw/xfree86/loader/loader.c436
-rw-r--r--xorg-server/hw/xfree86/loader/os.c2
-rw-r--r--xorg-server/hw/xfree86/loader/sdksyms.sh844
-rw-r--r--xorg-server/hw/xfree86/modes/xf86EdidModes.c2427
-rw-r--r--xorg-server/hw/xfree86/os-support/Makefile.am52
-rw-r--r--xorg-server/hw/xfree86/os-support/sco/Makefile.am5
-rw-r--r--xorg-server/hw/xfree86/os-support/sco/VTsw_sco.c127
-rw-r--r--xorg-server/hw/xfree86/os-support/sco/sco_init.c294
-rw-r--r--xorg-server/hw/xfree86/os-support/sco/sco_iop.c90
-rw-r--r--xorg-server/hw/xfree86/os-support/sco/sco_video.c290
-rw-r--r--xorg-server/hw/xfree86/os-support/xf86_OSlib.h31
-rw-r--r--xorg-server/hw/xfree86/parser/Makefile.am102
-rw-r--r--xorg-server/os/access.c4200
-rw-r--r--xorg-server/os/osinit.c639
-rw-r--r--xorg-server/os/xprintf.c466
-rw-r--r--xorg-server/randr/rrscreen.c2072
-rw-r--r--xorg-server/xkeyboard-config/rules/base.xml.in11462
-rw-r--r--xorg-server/xkeyboard-config/symbols/fi415
-rw-r--r--xorg-server/xkeyboard-config/symbols/ru1041
-rw-r--r--xorg-server/xkeyboard-config/symbols/us2390
39 files changed, 28258 insertions, 29284 deletions
diff --git a/xorg-server/Xext/sync.c b/xorg-server/Xext/sync.c
index d1948d3ed..5af055a7d 100644
--- a/xorg-server/Xext/sync.c
+++ b/xorg-server/Xext/sync.c
@@ -1,2869 +1,2899 @@
-/*
-
-Copyright 1991, 1993, 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 1991, 1993 by Digital Equipment Corporation, Maynard, Massachusetts,
-and Olivetti Research Limited, Cambridge, England.
-
- 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 names of Digital or Olivetti
-not be used in advertising or publicity pertaining to distribution of the
-software without specific, written prior permission. Digital and Olivetti
-make no representations about the suitability of this software
-for any purpose. It is provided "as is" without express or implied warranty.
-
-DIGITAL AND OLIVETTI DISCLAIM ALL WARRANTIES WITH REGARD TO THIS
-SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND
-FITNESS, IN NO EVENT SHALL THEY 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_DIX_CONFIG_H
-#include <dix-config.h>
-#endif
-
-#include <string.h>
-
-#include <X11/X.h>
-#include <X11/Xproto.h>
-#include <X11/Xmd.h>
-#include "scrnintstr.h"
-#include "os.h"
-#include "extnsionst.h"
-#include "dixstruct.h"
-#include "pixmapstr.h"
-#include "resource.h"
-#include "opaque.h"
-#include <X11/extensions/syncproto.h>
-#include "syncsrv.h"
-#include "syncsdk.h"
-#include "protocol-versions.h"
-
-#include <stdio.h>
-#if !defined(WIN32)
-#include <sys/time.h>
-#endif
-
-#include "modinit.h"
-
-/*
- * Local Global Variables
- */
-static int SyncEventBase;
-static int SyncErrorBase;
-static RESTYPE RTCounter = 0;
-static RESTYPE RTAwait;
-static RESTYPE RTAlarm;
-static RESTYPE RTAlarmClient;
-static RESTYPE RTFence;
-static int SyncNumSystemCounters = 0;
-static SyncCounter **SysCounterList = NULL;
-
-#define IsSystemCounter(pCounter) \
- (pCounter && (pCounter->sync.client == NULL))
-
-/* these are all the alarm attributes that pertain to the alarm's trigger */
-#define XSyncCAAllTrigger \
- (XSyncCACounter | XSyncCAValueType | XSyncCAValue | XSyncCATestType)
-
-static void SyncComputeBracketValues(SyncCounter *);
-
-static void SyncInitServerTime(void);
-
-static void SyncInitIdleTime(void);
-
-
-/* Each counter maintains a simple linked list of triggers that are
- * interested in the counter. The two functions below are used to
- * delete and add triggers on this list.
- */
-static void
-SyncDeleteTriggerFromSyncObject(SyncTrigger *pTrigger)
-{
- SyncTriggerList *pCur;
- SyncTriggerList *pPrev;
- SyncCounter *pCounter;
-
- /* pSync needs to be stored in pTrigger before calling here. */
-
- if (!pTrigger->pSync)
- return;
-
- pPrev = NULL;
- pCur = pTrigger->pSync->pTriglist;
-
- while (pCur)
- {
- if (pCur->pTrigger == pTrigger)
- {
- if (pPrev)
- pPrev->next = pCur->next;
- else
- pTrigger->pSync->pTriglist = pCur->next;
-
- free(pCur);
- break;
- }
-
- pPrev = pCur;
- pCur = pCur->next;
- }
-
- if (SYNC_COUNTER == pTrigger->pSync->type)
- {
- pCounter = (SyncCounter *)pTrigger->pSync;
-
- if (IsSystemCounter(pCounter))
- SyncComputeBracketValues(pCounter);
- } else if (SYNC_FENCE == pTrigger->pSync->type) {
- SyncFence* pFence = (SyncFence*) pTrigger->pSync;
- pFence->funcs.DeleteTrigger(pTrigger);
- }
-}
-
-
-static int
-SyncAddTriggerToSyncObject(SyncTrigger *pTrigger)
-{
- SyncTriggerList *pCur;
- SyncCounter *pCounter;
-
- if (!pTrigger->pSync)
- return Success;
-
- /* don't do anything if it's already there */
- for (pCur = pTrigger->pSync->pTriglist; pCur; pCur = pCur->next)
- {
- if (pCur->pTrigger == pTrigger)
- return Success;
- }
-
- if (!(pCur = malloc(sizeof(SyncTriggerList))))
- return BadAlloc;
-
- pCur->pTrigger = pTrigger;
- pCur->next = pTrigger->pSync->pTriglist;
- pTrigger->pSync->pTriglist = pCur;
-
- if (SYNC_COUNTER == pTrigger->pSync->type)
- {
- pCounter = (SyncCounter *)pTrigger->pSync;
-
- if (IsSystemCounter(pCounter))
- SyncComputeBracketValues(pCounter);
- } else if (SYNC_FENCE == pTrigger->pSync->type) {
- SyncFence* pFence = (SyncFence*) pTrigger->pSync;
- pFence->funcs.AddTrigger(pTrigger);
- }
-
- return Success;
-}
-
-
-/* Below are five possible functions that can be plugged into
- * pTrigger->CheckTrigger for counter sync objects, corresponding to
- * the four possible test-types, and the one possible function that
- * can be plugged into pTrigger->CheckTrigger for fence sync objects.
- * These functions are called after the sync object's state changes
- * but are also passed the old state so they can inspect both the old
- * and new values. (PositiveTransition and NegativeTransition need to
- * see both pieces of information.) These functions return the truth
- * value of the trigger.
- *
- * All of them include the condition pTrigger->pSync == NULL.
- * This is because the spec says that a trigger with a sync value
- * of None is always TRUE.
- */
-
-static Bool
-SyncCheckTriggerPositiveComparison(SyncTrigger *pTrigger, CARD64 oldval)
-{
- SyncCounter *pCounter;
-
- assert(!pTrigger->pSync || (SYNC_COUNTER == pTrigger->pSync->type));
- pCounter = (SyncCounter *)pTrigger->pSync;
-
- return (pCounter == NULL ||
- XSyncValueGreaterOrEqual(pCounter->value, pTrigger->test_value));
-}
-
-static Bool
-SyncCheckTriggerNegativeComparison(SyncTrigger *pTrigger, CARD64 oldval)
-{
- SyncCounter *pCounter;
-
- assert(!pTrigger->pSync || (SYNC_COUNTER == pTrigger->pSync->type));
- pCounter = (SyncCounter *)pTrigger->pSync;
-
- return (pCounter == NULL ||
- XSyncValueLessOrEqual(pCounter->value, pTrigger->test_value));
-}
-
-static Bool
-SyncCheckTriggerPositiveTransition(SyncTrigger *pTrigger, CARD64 oldval)
-{
- SyncCounter *pCounter;
-
- assert(!pTrigger->pSync || (SYNC_COUNTER == pTrigger->pSync->type));
- pCounter = (SyncCounter *)pTrigger->pSync;
-
- return (pCounter == NULL ||
- (XSyncValueLessThan(oldval, pTrigger->test_value) &&
- XSyncValueGreaterOrEqual(pCounter->value, pTrigger->test_value)));
-}
-
-static Bool
-SyncCheckTriggerNegativeTransition(SyncTrigger *pTrigger, CARD64 oldval)
-{
- SyncCounter *pCounter;
-
- assert(!pTrigger->pSync || (SYNC_COUNTER == pTrigger->pSync->type));
- pCounter = (SyncCounter *)pTrigger->pSync;
-
- return (pCounter == NULL ||
- (XSyncValueGreaterThan(oldval, pTrigger->test_value) &&
- XSyncValueLessOrEqual(pCounter->value, pTrigger->test_value)));
-}
-
-static Bool
-SyncCheckTriggerFence(SyncTrigger *pTrigger, CARD64 unused)
-{
- SyncFence* pFence = (SyncFence*) pTrigger->pSync;
- (void)unused;
-
- return (pFence == NULL ||
- pFence->funcs.CheckTriggered(pFence));
-}
-
-static int
-SyncInitTrigger(ClientPtr client, SyncTrigger *pTrigger, XID syncObject,
- RESTYPE resType, Mask changes)
-{
- SyncObject *pSync = pTrigger->pSync;
- SyncCounter *pCounter = NULL;
- int rc;
- Bool newSyncObject = FALSE;
-
- if (changes & XSyncCACounter)
- {
- if (syncObject == None)
- pSync = NULL;
- else if (Success != (rc = dixLookupResourceByType ((pointer *)&pSync,
- syncObject, resType, client, DixReadAccess)))
- {
- client->errorValue = syncObject;
- return rc;
- }
- if (pSync != pTrigger->pSync)
- { /* new counter for trigger */
- SyncDeleteTriggerFromSyncObject(pTrigger);
- pTrigger->pSync = pSync;
- newSyncObject = TRUE;
- }
- }
-
- /* if system counter, ask it what the current value is */
-
- if (pSync && SYNC_COUNTER == pSync->type)
- {
- pCounter = (SyncCounter *)pSync;
-
- if (IsSystemCounter(pCounter))
- {
- (*pCounter->pSysCounterInfo->QueryValue) ((pointer) pCounter,
- &pCounter->value);
- }
- }
-
- if (changes & XSyncCAValueType)
- {
- if (pTrigger->value_type != XSyncRelative &&
- pTrigger->value_type != XSyncAbsolute)
- {
- client->errorValue = pTrigger->value_type;
- return BadValue;
- }
- }
-
- if (changes & XSyncCATestType)
- {
-
- if (pSync && SYNC_FENCE == pSync->type)
- {
- pTrigger->CheckTrigger = SyncCheckTriggerFence;
- }
- else
- {
- if (pTrigger->test_type != XSyncPositiveTransition &&
- pTrigger->test_type != XSyncNegativeTransition &&
- pTrigger->test_type != XSyncPositiveComparison &&
- pTrigger->test_type != XSyncNegativeComparison)
- {
- client->errorValue = pTrigger->test_type;
- return BadValue;
- }
- /* select appropriate CheckTrigger function */
-
- switch (pTrigger->test_type)
- {
- case XSyncPositiveTransition:
- pTrigger->CheckTrigger = SyncCheckTriggerPositiveTransition;
- break;
- case XSyncNegativeTransition:
- pTrigger->CheckTrigger = SyncCheckTriggerNegativeTransition;
- break;
- case XSyncPositiveComparison:
- pTrigger->CheckTrigger = SyncCheckTriggerPositiveComparison;
- break;
- case XSyncNegativeComparison:
- pTrigger->CheckTrigger = SyncCheckTriggerNegativeComparison;
- break;
- }
- }
- }
-
- if (changes & (XSyncCAValueType | XSyncCAValue))
- {
- if (pTrigger->value_type == XSyncAbsolute)
- pTrigger->test_value = pTrigger->wait_value;
- else /* relative */
- {
- Bool overflow;
- if (pCounter == NULL)
- return BadMatch;
-
- XSyncValueAdd(&pTrigger->test_value, pCounter->value,
- pTrigger->wait_value, &overflow);
- if (overflow)
- {
- client->errorValue = XSyncValueHigh32(pTrigger->wait_value);
- return BadValue;
- }
- }
- }
-
- /* we wait until we're sure there are no errors before registering
- * a new counter on a trigger
- */
- if (newSyncObject)
- {
- if ((rc = SyncAddTriggerToSyncObject(pTrigger)) != Success)
- return rc;
- }
- else if (pCounter && IsSystemCounter(pCounter))
- {
- SyncComputeBracketValues(pCounter);
- }
-
- return Success;
-}
-
-/* AlarmNotify events happen in response to actions taken on an Alarm or
- * the counter used by the alarm. AlarmNotify may be sent to multiple
- * clients. The alarm maintains a list of clients interested in events.
- */
-static void
-SyncSendAlarmNotifyEvents(SyncAlarm *pAlarm)
-{
- SyncAlarmClientList *pcl;
- xSyncAlarmNotifyEvent ane;
- SyncTrigger *pTrigger = &pAlarm->trigger;
- SyncCounter *pCounter;
-
- assert(!pTrigger->pSync || (SYNC_COUNTER == pTrigger->pSync->type));
-
- pCounter = (SyncCounter *)pTrigger->pSync;
-
- UpdateCurrentTime();
-
- ane.type = SyncEventBase + XSyncAlarmNotify;
- ane.kind = XSyncAlarmNotify;
- ane.alarm = pAlarm->alarm_id;
- if (pTrigger->pSync && SYNC_COUNTER == pTrigger->pSync->type)
- {
- ane.counter_value_hi = XSyncValueHigh32(pCounter->value);
- ane.counter_value_lo = XSyncValueLow32(pCounter->value);
- }
- else
- { /* XXX what else can we do if there's no counter? */
- ane.counter_value_hi = ane.counter_value_lo = 0;
- }
-
- ane.alarm_value_hi = XSyncValueHigh32(pTrigger->test_value);
- ane.alarm_value_lo = XSyncValueLow32(pTrigger->test_value);
- ane.time = currentTime.milliseconds;
- ane.state = pAlarm->state;
-
- /* send to owner */
- if (pAlarm->events)
- WriteEventsToClient(pAlarm->client, 1, (xEvent *) &ane);
-
- /* send to other interested clients */
- for (pcl = pAlarm->pEventClients; pcl; pcl = pcl->next)
- WriteEventsToClient(pcl->client, 1, (xEvent *) &ane);
-}
-
-
-/* CounterNotify events only occur in response to an Await. The events
- * go only to the Awaiting client.
- */
-static void
-SyncSendCounterNotifyEvents(ClientPtr client, SyncAwait **ppAwait,
- int num_events)
-{
- xSyncCounterNotifyEvent *pEvents, *pev;
- int i;
-
- if (client->clientGone)
- return;
- pev = pEvents = malloc(num_events * sizeof(xSyncCounterNotifyEvent));
- if (!pEvents)
- return;
- UpdateCurrentTime();
- for (i = 0; i < num_events; i++, ppAwait++, pev++)
- {
- SyncTrigger *pTrigger = &(*ppAwait)->trigger;
- pev->type = SyncEventBase + XSyncCounterNotify;
- pev->kind = XSyncCounterNotify;
- pev->counter = pTrigger->pSync->id;
- pev->wait_value_lo = XSyncValueLow32(pTrigger->test_value);
- pev->wait_value_hi = XSyncValueHigh32(pTrigger->test_value);
- if (SYNC_COUNTER == pTrigger->pSync->type)
- {
- SyncCounter *pCounter = (SyncCounter *)pTrigger->pSync;
-
- pev->counter_value_lo = XSyncValueLow32(pCounter->value);
- pev->counter_value_hi = XSyncValueHigh32(pCounter->value);
- }
- else
- {
- pev->counter_value_lo = 0;
- pev->counter_value_hi = 0;
- }
-
- pev->time = currentTime.milliseconds;
- pev->count = num_events - i - 1; /* events remaining */
- pev->destroyed = pTrigger->pSync->beingDestroyed;
- }
- /* swapping will be taken care of by this */
- WriteEventsToClient(client, num_events, (xEvent *)pEvents);
- free(pEvents);
-}
-
-
-/* This function is called when an alarm's counter is destroyed.
- * It is plugged into pTrigger->CounterDestroyed (for alarm triggers).
- */
-static void
-SyncAlarmCounterDestroyed(SyncTrigger *pTrigger)
-{
- SyncAlarm *pAlarm = (SyncAlarm *)pTrigger;
-
- pAlarm->state = XSyncAlarmInactive;
- SyncSendAlarmNotifyEvents(pAlarm);
- pTrigger->pSync = NULL;
-}
-
-
-/* This function is called when an alarm "goes off."
- * It is plugged into pTrigger->TriggerFired (for alarm triggers).
- */
-static void
-SyncAlarmTriggerFired(SyncTrigger *pTrigger)
-{
- SyncAlarm *pAlarm = (SyncAlarm *)pTrigger;
- SyncCounter *pCounter;
- CARD64 new_test_value;
-
- assert(!pTrigger->pSync || (SYNC_COUNTER == pTrigger->pSync->type));
- pCounter = (SyncCounter *)pTrigger->pSync;
-
- /* no need to check alarm unless it's active */
- if (pAlarm->state != XSyncAlarmActive)
- return;
-
- /* " if the counter value is None, or if the delta is 0 and
- * the test-type is PositiveComparison or NegativeComparison,
- * no change is made to value (test-value) and the alarm
- * state is changed to Inactive before the event is generated."
- */
- if (pCounter == NULL
- || (XSyncValueIsZero(pAlarm->delta)
- && (pAlarm->trigger.test_type == XSyncPositiveComparison
- || pAlarm->trigger.test_type == XSyncNegativeComparison)))
- pAlarm->state = XSyncAlarmInactive;
-
- new_test_value = pAlarm->trigger.test_value;
-
- if (pAlarm->state == XSyncAlarmActive)
- {
- Bool overflow;
- CARD64 oldvalue;
- SyncTrigger *paTrigger = &pAlarm->trigger;
- SyncCounter *paCounter;
-
- assert(!paTrigger->pSync || (SYNC_COUNTER == paTrigger->pSync->type));
- paCounter = (SyncCounter *)pTrigger->pSync;
-
- /* "The alarm is updated by repeatedly adding delta to the
- * value of the trigger and re-initializing it until it
- * becomes FALSE."
- */
- oldvalue = paTrigger->test_value;
-
- /* XXX really should do something smarter here */
-
- do
- {
- XSyncValueAdd(&paTrigger->test_value, paTrigger->test_value,
- pAlarm->delta, &overflow);
- } while (!overflow &&
- (*paTrigger->CheckTrigger)(paTrigger,
- paCounter->value));
-
- new_test_value = paTrigger->test_value;
- paTrigger->test_value = oldvalue;
-
- /* "If this update would cause value to fall outside the range
- * for an INT64...no change is made to value (test-value) and
- * the alarm state is changed to Inactive before the event is
- * generated."
- */
- if (overflow)
- {
- new_test_value = oldvalue;
- pAlarm->state = XSyncAlarmInactive;
- }
- }
- /* The AlarmNotify event has to have the "new state of the alarm"
- * which we can't be sure of until this point. However, it has
- * to have the "old" trigger test value. That's the reason for
- * all the newvalue/oldvalue shuffling above. After we send the
- * events, give the trigger its new test value.
- */
- SyncSendAlarmNotifyEvents(pAlarm);
- pTrigger->test_value = new_test_value;
-}
-
-
-/* This function is called when an Await unblocks, either as a result
- * of the trigger firing OR the counter being destroyed.
- * It goes into pTrigger->TriggerFired AND pTrigger->CounterDestroyed
- * (for Await triggers).
- */
-static void
-SyncAwaitTriggerFired(SyncTrigger *pTrigger)
-{
- SyncAwait *pAwait = (SyncAwait *)pTrigger;
- int numwaits;
- SyncAwaitUnion *pAwaitUnion;
- SyncAwait **ppAwait;
- int num_events = 0;
-
- pAwaitUnion = (SyncAwaitUnion *)pAwait->pHeader;
- numwaits = pAwaitUnion->header.num_waitconditions;
- ppAwait = malloc(numwaits * sizeof(SyncAwait *));
- if (!ppAwait)
- goto bail;
-
- pAwait = &(pAwaitUnion+1)->await;
-
- /* "When a client is unblocked, all the CounterNotify events for
- * the Await request are generated contiguously. If count is 0
- * there are no more events to follow for this request. If
- * count is n, there are at least n more events to follow."
- *
- * Thus, it is best to find all the counters for which events
- * need to be sent first, so that an accurate count field can
- * be stored in the events.
- */
- for ( ; numwaits; numwaits--, pAwait++)
- {
- CARD64 diff;
- Bool overflow, diffgreater, diffequal;
-
- /* "A CounterNotify event with the destroyed flag set to TRUE is
- * always generated if the counter for one of the triggers is
- * destroyed."
- */
- if (pAwait->trigger.pSync->beingDestroyed)
- {
- ppAwait[num_events++] = pAwait;
- continue;
- }
-
- if (SYNC_COUNTER == pAwait->trigger.pSync->type)
- {
- SyncCounter *pCounter = (SyncCounter *) pAwait->trigger.pSync;
-
- /* "The difference between the counter and the test value is
- * calculated by subtracting the test value from the value of
- * the counter."
- */
- XSyncValueSubtract(&diff, pCounter->value,
- pAwait->trigger.test_value, &overflow);
-
- /* "If the difference lies outside the range for an INT64, an
- * event is not generated."
- */
- if (overflow)
- continue;
- diffgreater = XSyncValueGreaterThan(diff, pAwait->event_threshold);
- diffequal = XSyncValueEqual(diff, pAwait->event_threshold);
-
- /* "If the test-type is PositiveTransition or
- * PositiveComparison, a CounterNotify event is generated if
- * the difference is at least event-threshold. If the test-type
- * is NegativeTransition or NegativeComparison, a CounterNotify
- * event is generated if the difference is at most
- * event-threshold."
- */
-
- if ( ((pAwait->trigger.test_type == XSyncPositiveComparison ||
- pAwait->trigger.test_type == XSyncPositiveTransition)
- && (diffgreater || diffequal))
- ||
- ((pAwait->trigger.test_type == XSyncNegativeComparison ||
- pAwait->trigger.test_type == XSyncNegativeTransition)
- && (!diffgreater) /* less or equal */
- )
- )
- {
- ppAwait[num_events++] = pAwait;
- }
- }
- }
- if (num_events)
- SyncSendCounterNotifyEvents(pAwaitUnion->header.client, ppAwait,
- num_events);
- free(ppAwait);
-
-bail:
- /* unblock the client */
- AttendClient(pAwaitUnion->header.client);
- /* delete the await */
- FreeResource(pAwaitUnion->header.delete_id, RT_NONE);
-}
-
-
-/* This function should always be used to change a counter's value so that
- * any triggers depending on the counter will be checked.
- */
-void
-SyncChangeCounter(SyncCounter *pCounter, CARD64 newval)
-{
- SyncTriggerList *ptl, *pnext;
- CARD64 oldval;
-
- oldval = pCounter->value;
- pCounter->value = newval;
-
- /* run through triggers to see if any become true */
- for (ptl = pCounter->sync.pTriglist; ptl; ptl = pnext)
- {
- pnext = ptl->next;
- if ((*ptl->pTrigger->CheckTrigger)(ptl->pTrigger, oldval))
- (*ptl->pTrigger->TriggerFired)(ptl->pTrigger);
- }
-
- if (IsSystemCounter(pCounter))
- {
- SyncComputeBracketValues(pCounter);
- }
-}
-
-
-/* loosely based on dix/events.c/EventSelectForWindow */
-static Bool
-SyncEventSelectForAlarm(SyncAlarm *pAlarm, ClientPtr client, Bool wantevents)
-{
- SyncAlarmClientList *pClients;
-
- if (client == pAlarm->client) /* alarm owner */
- {
- pAlarm->events = wantevents;
- return Success;
- }
-
- /* see if the client is already on the list (has events selected) */
-
- for (pClients = pAlarm->pEventClients; pClients;
- pClients = pClients->next)
- {
- if (pClients->client == client)
- {
- /* client's presence on the list indicates desire for
- * events. If the client doesn't want events, remove it
- * from the list. If the client does want events, do
- * nothing, since it's already got them.
- */
- if (!wantevents)
- {
- FreeResource(pClients->delete_id, RT_NONE);
- }
- return Success;
- }
- }
-
- /* if we get here, this client does not currently have
- * events selected on the alarm
- */
-
- if (!wantevents)
- /* client doesn't want events, and we just discovered that it
- * doesn't have them, so there's nothing to do.
- */
- return Success;
-
- /* add new client to pAlarm->pEventClients */
-
- pClients = malloc(sizeof(SyncAlarmClientList));
- if (!pClients)
- return BadAlloc;
-
- /* register it as a resource so it will be cleaned up
- * if the client dies
- */
-
- pClients->delete_id = FakeClientID(client->index);
- if (!AddResource(pClients->delete_id, RTAlarmClient, pAlarm))
- {
- free(pClients);
- return BadAlloc;
- }
-
- /* link it into list after we know all the allocations succeed */
-
- pClients->next = pAlarm->pEventClients;
- pAlarm->pEventClients = pClients;
- pClients->client = client;
- return Success;
-}
-
-/*
- * ** SyncChangeAlarmAttributes ** This is used by CreateAlarm and ChangeAlarm
- */
-static int
-SyncChangeAlarmAttributes(ClientPtr client, SyncAlarm *pAlarm, Mask mask,
- CARD32 *values)
-{
- int status;
- XSyncCounter counter;
- Mask origmask = mask;
-
- counter =
- pAlarm->trigger.pSync ? pAlarm->trigger.pSync->id : None;
-
- while (mask)
- {
- int index2 = lowbit(mask);
- mask &= ~index2;
- switch (index2)
- {
- case XSyncCACounter:
- mask &= ~XSyncCACounter;
- /* sanity check in SyncInitTrigger */
- counter = *values++;
- break;
-
- case XSyncCAValueType:
- mask &= ~XSyncCAValueType;
- /* sanity check in SyncInitTrigger */
- pAlarm->trigger.value_type = *values++;
- break;
-
- case XSyncCAValue:
- mask &= ~XSyncCAValue;
- XSyncIntsToValue(&pAlarm->trigger.wait_value, values[1], values[0]);
- values += 2;
- break;
-
- case XSyncCATestType:
- mask &= ~XSyncCATestType;
- /* sanity check in SyncInitTrigger */
- pAlarm->trigger.test_type = *values++;
- break;
-
- case XSyncCADelta:
- mask &= ~XSyncCADelta;
- XSyncIntsToValue(&pAlarm->delta, values[1], values[0]);
- values += 2;
- break;
-
- case XSyncCAEvents:
- mask &= ~XSyncCAEvents;
- if ((*values != xTrue) && (*values != xFalse))
- {
- client->errorValue = *values;
- return BadValue;
- }
- status = SyncEventSelectForAlarm(pAlarm, client,
- (Bool)(*values++));
- if (status != Success)
- return status;
- break;
-
- default:
- client->errorValue = mask;
- return BadValue;
- }
- }
-
- /* "If the test-type is PositiveComparison or PositiveTransition
- * and delta is less than zero, or if the test-type is
- * NegativeComparison or NegativeTransition and delta is
- * greater than zero, a Match error is generated."
- */
- if (origmask & (XSyncCADelta|XSyncCATestType))
- {
- CARD64 zero;
- XSyncIntToValue(&zero, 0);
- if ((((pAlarm->trigger.test_type == XSyncPositiveComparison) ||
- (pAlarm->trigger.test_type == XSyncPositiveTransition))
- && XSyncValueLessThan(pAlarm->delta, zero))
- ||
- (((pAlarm->trigger.test_type == XSyncNegativeComparison) ||
- (pAlarm->trigger.test_type == XSyncNegativeTransition))
- && XSyncValueGreaterThan(pAlarm->delta, zero))
- )
- {
- return BadMatch;
- }
- }
-
- /* postpone this until now, when we're sure nothing else can go wrong */
- if ((status = SyncInitTrigger(client, &pAlarm->trigger, counter, RTCounter,
- origmask & XSyncCAAllTrigger)) != Success)
- return status;
-
- /* XXX spec does not really say to do this - needs clarification */
- pAlarm->state = XSyncAlarmActive;
- return Success;
-}
-
-static SyncObject *
-SyncCreate(ClientPtr client, XID id, unsigned char type)
-{
- SyncObject *pSync;
- RESTYPE resType;
-
- switch (type) {
- case SYNC_COUNTER:
- resType = RTCounter;
- pSync = malloc(sizeof(SyncCounter));
- break;
- case SYNC_FENCE:
- resType = RTFence;
- pSync = dixAllocateObjectWithPrivates(SyncFence,
- PRIVATE_SYNC_FENCE);
- break;
- default:
- return NULL;
- }
-
- if (!pSync)
- return NULL;
-
- if (!AddResource(id, resType, (pointer) pSync))
- {
- switch (type) {
- case SYNC_FENCE:
- dixFreeObjectWithPrivates((SyncFence *)pSync, PRIVATE_SYNC_FENCE);
- break;
- default:
- free(pSync);
- }
-
- return NULL;
- }
-
- pSync->client = client;
- pSync->id = id;
- pSync->pTriglist = NULL;
- pSync->beingDestroyed = FALSE;
- pSync->type = type;
-
- return pSync;
-}
-
-
-static SyncCounter *
-SyncCreateCounter(ClientPtr client, XSyncCounter id, CARD64 initialvalue)
-{
- SyncCounter *pCounter;
-
- if (!(pCounter = (SyncCounter *)SyncCreate(client,
- id,
- SYNC_COUNTER)))
- return NULL;
-
- pCounter->value = initialvalue;
- pCounter->pSysCounterInfo = NULL;
- return pCounter;
-}
-
-static int FreeCounter(void *, XID);
-
-/*
- * ***** System Counter utilities
- */
-
-pointer
-SyncCreateSystemCounter(
- char *name,
- CARD64 initial,
- CARD64 resolution,
- SyncCounterType counterType,
- void (*QueryValue)(pointer /* pCounter */,
- CARD64 * /* pValue_return */),
- void (*BracketValues)(pointer /* pCounter */,
- CARD64 * /* pbracket_less */,
- CARD64 * /* pbracket_greater */)
- )
-{
- SyncCounter *pCounter;
-
- SysCounterList = realloc(SysCounterList,
- (SyncNumSystemCounters+1)*sizeof(SyncCounter *));
- if (!SysCounterList)
- return NULL;
-
- /* this function may be called before SYNC has been initialized, so we
- * have to make sure RTCounter is created.
- */
- if (RTCounter == 0)
- {
- RTCounter = CreateNewResourceType(FreeCounter, "SyncCounter");
- if (RTCounter == 0)
- {
- return NULL;
- }
- }
-
- pCounter = SyncCreateCounter(NULL, FakeClientID(0), initial);
-
- if (pCounter)
- {
- SysCounterInfo *psci;
-
- psci = malloc(sizeof(SysCounterInfo));
- if (!psci)
- {
- FreeResource(pCounter->sync.id, RT_NONE);
- return pCounter;
- }
- pCounter->pSysCounterInfo = psci;
- psci->name = name;
- psci->resolution = resolution;
- psci->counterType = counterType;
- psci->QueryValue = QueryValue;
- psci->BracketValues = BracketValues;
- XSyncMaxValue(&psci->bracket_greater);
- XSyncMinValue(&psci->bracket_less);
- SysCounterList[SyncNumSystemCounters++] = pCounter;
- }
- return pCounter;
-}
-
-void
-SyncDestroySystemCounter(pointer pSysCounter)
-{
- SyncCounter *pCounter = (SyncCounter *)pSysCounter;
- FreeResource(pCounter->sync.id, RT_NONE);
-}
-
-static void
-SyncComputeBracketValues(SyncCounter *pCounter)
-{
- SyncTriggerList *pCur;
- SyncTrigger *pTrigger;
- SysCounterInfo *psci;
- CARD64 *pnewgtval = NULL;
- CARD64 *pnewltval = NULL;
- SyncCounterType ct;
-
- if (!pCounter)
- return;
-
- psci = pCounter->pSysCounterInfo;
- ct = pCounter->pSysCounterInfo->counterType;
- if (ct == XSyncCounterNeverChanges)
- return;
-
- XSyncMaxValue(&psci->bracket_greater);
- XSyncMinValue(&psci->bracket_less);
-
- for (pCur = pCounter->sync.pTriglist; pCur; pCur = pCur->next)
- {
- pTrigger = pCur->pTrigger;
-
- if (pTrigger->test_type == XSyncPositiveComparison &&
- ct != XSyncCounterNeverIncreases)
- {
- if (XSyncValueLessThan(pCounter->value, pTrigger->test_value) &&
- XSyncValueLessThan(pTrigger->test_value,
- psci->bracket_greater))
- {
- psci->bracket_greater = pTrigger->test_value;
- pnewgtval = &psci->bracket_greater;
- }
- }
- else if (pTrigger->test_type == XSyncNegativeComparison &&
- ct != XSyncCounterNeverDecreases)
- {
- if (XSyncValueGreaterThan(pCounter->value, pTrigger->test_value) &&
- XSyncValueGreaterThan(pTrigger->test_value,
- psci->bracket_less))
- {
- psci->bracket_less = pTrigger->test_value;
- pnewltval = &psci->bracket_less;
- }
- }
- else if (pTrigger->test_type == XSyncNegativeTransition &&
- ct != XSyncCounterNeverIncreases)
- {
- if (XSyncValueGreaterThan(pCounter->value, pTrigger->test_value) &&
- XSyncValueGreaterThan(pTrigger->test_value, psci->bracket_less))
- {
- psci->bracket_less = pTrigger->test_value;
- pnewltval = &psci->bracket_less;
- }
- }
- else if (pTrigger->test_type == XSyncPositiveTransition &&
- ct != XSyncCounterNeverDecreases)
- {
- if (XSyncValueLessThan(pCounter->value, pTrigger->test_value) &&
- XSyncValueLessThan(pTrigger->test_value, psci->bracket_greater))
- {
- psci->bracket_greater = pTrigger->test_value;
- pnewgtval = &psci->bracket_greater;
- }
- }
- } /* end for each trigger */
-
- if (pnewgtval || pnewltval)
- {
- (*psci->BracketValues)((pointer)pCounter, pnewltval, pnewgtval);
- }
-}
-
-/*
- * ***** Resource delete functions
- */
-
-/* ARGSUSED */
-static int
-FreeAlarm(void *addr, XID id)
-{
- SyncAlarm *pAlarm = (SyncAlarm *) addr;
-
- pAlarm->state = XSyncAlarmDestroyed;
-
- SyncSendAlarmNotifyEvents(pAlarm);
-
- /* delete event selections */
-
- while (pAlarm->pEventClients)
- FreeResource(pAlarm->pEventClients->delete_id, RT_NONE);
-
- SyncDeleteTriggerFromSyncObject(&pAlarm->trigger);
-
- free(pAlarm);
- return Success;
-}
-
-
-/*
- * ** Cleanup after the destruction of a Counter
- */
-/* ARGSUSED */
-static int
-FreeCounter(void *env, XID id)
-{
- SyncCounter *pCounter = (SyncCounter *) env;
- SyncTriggerList *ptl, *pnext;
-
- pCounter->sync.beingDestroyed = TRUE;
- /* tell all the counter's triggers that the counter has been destroyed */
- for (ptl = pCounter->sync.pTriglist; ptl; ptl = pnext)
- {
- (*ptl->pTrigger->CounterDestroyed)(ptl->pTrigger);
- pnext = ptl->next;
- free(ptl); /* destroy the trigger list as we go */
- }
- if (IsSystemCounter(pCounter))
- {
- int i, found = 0;
-
- free(pCounter->pSysCounterInfo);
-
- /* find the counter in the list of system counters and remove it */
-
- if (SysCounterList)
- {
- for (i = 0; i < SyncNumSystemCounters; i++)
- {
- if (SysCounterList[i] == pCounter)
- {
- found = i;
- break;
- }
- }
- if (found < (SyncNumSystemCounters-1))
- {
- for (i = found; i < SyncNumSystemCounters-1; i++)
- {
- SysCounterList[i] = SysCounterList[i+1];
- }
- }
- }
- SyncNumSystemCounters--;
- }
- free(pCounter);
- return Success;
-}
-
-/*
- * ** Cleanup after Await
- */
-/* ARGSUSED */
-static int
-FreeAwait(void *addr, XID id)
-{
- SyncAwaitUnion *pAwaitUnion = (SyncAwaitUnion *) addr;
- SyncAwait *pAwait;
- int numwaits;
-
- pAwait = &(pAwaitUnion+1)->await; /* first await on list */
-
- /* remove triggers from counters */
-
- for (numwaits = pAwaitUnion->header.num_waitconditions; numwaits;
- numwaits--, pAwait++)
- {
- /* If the counter is being destroyed, FreeCounter will delete
- * the trigger list itself, so don't do it here.
- */
- SyncObject *pSync = pAwait->trigger.pSync;
- if (pSync && !pSync->beingDestroyed)
- SyncDeleteTriggerFromSyncObject(&pAwait->trigger);
- }
- free(pAwaitUnion);
- return Success;
-}
-
-#ifdef _MSC_VER
-#pragma warning(disable:4715) /* Not all control paths return a value */
-#endif
-
-/* loosely based on dix/events.c/OtherClientGone */
-static int
-FreeAlarmClient(void *value, XID id)
-{
- SyncAlarm *pAlarm = (SyncAlarm *)value;
- SyncAlarmClientList *pCur, *pPrev;
-
- for (pPrev = NULL, pCur = pAlarm->pEventClients;
- pCur;
- pPrev = pCur, pCur = pCur->next)
- {
- if (pCur->delete_id == id)
- {
- if (pPrev)
- pPrev->next = pCur->next;
- else
- pAlarm->pEventClients = pCur->next;
- free(pCur);
- return Success;
- }
- }
- FatalError("alarm client not on event list");
- /*NOTREACHED*/
-}
-
-
-/*
- * ***** Proc functions
- */
-
-
-/*
- * ** Initialize the extension
- */
-static int
-ProcSyncInitialize(ClientPtr client)
-{
- xSyncInitializeReply rep;
- int n;
-
- REQUEST_SIZE_MATCH(xSyncInitializeReq);
-
- memset(&rep, 0, sizeof(xSyncInitializeReply));
- rep.type = X_Reply;
- rep.sequenceNumber = client->sequence;
- rep.majorVersion = SERVER_SYNC_MAJOR_VERSION;
- rep.minorVersion = SERVER_SYNC_MINOR_VERSION;
- rep.length = 0;
-
- if (client->swapped)
- {
- swaps(&rep.sequenceNumber, n);
- }
- WriteToClient(client, sizeof(rep), (char *) &rep);
- return Success;
-}
-
-/*
- * ** Get list of system counters available through the extension
- */
-static int
-ProcSyncListSystemCounters(ClientPtr client)
-{
- xSyncListSystemCountersReply rep;
- int i, len;
- xSyncSystemCounter *list = NULL, *walklist = NULL;
-
- REQUEST_SIZE_MATCH(xSyncListSystemCountersReq);
-
- rep.type = X_Reply;
- rep.sequenceNumber = client->sequence;
- rep.nCounters = SyncNumSystemCounters;
-
- for (i = len = 0; i < SyncNumSystemCounters; i++)
- {
- char *name = SysCounterList[i]->pSysCounterInfo->name;
- /* pad to 4 byte boundary */
- len += pad_to_int32(sz_xSyncSystemCounter + strlen(name));
- }
-
- if (len)
- {
- walklist = list = malloc(len);
- if (!list)
- return BadAlloc;
- }
-
- rep.length = bytes_to_int32(len);
-
- if (client->swapped)
- {
- char n;
- swaps(&rep.sequenceNumber, n);
- swapl(&rep.length, n);
- swapl(&rep.nCounters, n);
- }
-
- for (i = 0; i < SyncNumSystemCounters; i++)
- {
- int namelen;
- char *pname_in_reply;
- SysCounterInfo *psci = SysCounterList[i]->pSysCounterInfo;
-
- walklist->counter = SysCounterList[i]->sync.id;
- walklist->resolution_hi = XSyncValueHigh32(psci->resolution);
- walklist->resolution_lo = XSyncValueLow32(psci->resolution);
- namelen = strlen(psci->name);
- walklist->name_length = namelen;
-
- if (client->swapped)
- {
- char n;
- swapl(&walklist->counter, n);
- swapl(&walklist->resolution_hi, n);
- swapl(&walklist->resolution_lo, n);
- swaps(&walklist->name_length, n);
- }
-
- pname_in_reply = ((char *)walklist) + sz_xSyncSystemCounter;
- strncpy(pname_in_reply, psci->name, namelen);
- walklist = (xSyncSystemCounter *) (((char *)walklist) +
- pad_to_int32(sz_xSyncSystemCounter + namelen));
- }
-
- WriteToClient(client, sizeof(rep), (char *) &rep);
- if (len)
- {
- WriteToClient(client, len, (char *) list);
- free(list);
- }
-
- return Success;
-}
-
-/*
- * ** Set client Priority
- */
-static int
-ProcSyncSetPriority(ClientPtr client)
-{
- REQUEST(xSyncSetPriorityReq);
- ClientPtr priorityclient;
- int rc;
-
- REQUEST_SIZE_MATCH(xSyncSetPriorityReq);
-
- if (stuff->id == None)
- priorityclient = client;
- else {
- rc = dixLookupClient(&priorityclient, stuff->id, client,
- DixSetAttrAccess);
- if (rc != Success)
- return rc;
- }
-
- if (priorityclient->priority != stuff->priority)
- {
- priorityclient->priority = stuff->priority;
-
- /* The following will force the server back into WaitForSomething
- * so that the change in this client's priority is immediately
- * reflected.
- */
- isItTimeToYield = TRUE;
- dispatchException |= DE_PRIORITYCHANGE;
- }
- return Success;
-}
-
-/*
- * ** Get client Priority
- */
-static int
-ProcSyncGetPriority(ClientPtr client)
-{
- REQUEST(xSyncGetPriorityReq);
- xSyncGetPriorityReply rep;
- ClientPtr priorityclient;
- int rc;
-
- REQUEST_SIZE_MATCH(xSyncGetPriorityReq);
-
- if (stuff->id == None)
- priorityclient = client;
- else {
- rc = dixLookupClient(&priorityclient, stuff->id, client,
- DixGetAttrAccess);
- if (rc != Success)
- return rc;
- }
-
- rep.type = X_Reply;
- rep.length = 0;
- rep.sequenceNumber = client->sequence;
- rep.priority = priorityclient->priority;
-
- if (client->swapped)
- {
- char n;
- swaps(&rep.sequenceNumber, n);
- swapl(&rep.priority, n);
- }
-
- WriteToClient(client, sizeof(xSyncGetPriorityReply), (char *) &rep);
-
- return Success;
-}
-
-/*
- * ** Create a new counter
- */
-static int
-ProcSyncCreateCounter(ClientPtr client)
-{
- REQUEST(xSyncCreateCounterReq);
- CARD64 initial;
-
- REQUEST_SIZE_MATCH(xSyncCreateCounterReq);
-
- LEGAL_NEW_RESOURCE(stuff->cid, client);
-
- XSyncIntsToValue(&initial, stuff->initial_value_lo, stuff->initial_value_hi);
- if (!SyncCreateCounter(client, stuff->cid, initial))
- return BadAlloc;
-
- return Success;
-}
-
-/*
- * ** Set Counter value
- */
-static int
-ProcSyncSetCounter(ClientPtr client)
-{
- REQUEST(xSyncSetCounterReq);
- SyncCounter *pCounter;
- CARD64 newvalue;
- int rc;
-
- REQUEST_SIZE_MATCH(xSyncSetCounterReq);
-
- rc = dixLookupResourceByType((pointer *)&pCounter, stuff->cid, RTCounter,
- client, DixWriteAccess);
- if (rc != Success)
- return rc;
-
- if (IsSystemCounter(pCounter))
- {
- client->errorValue = stuff->cid;
- return BadAccess;
- }
-
- XSyncIntsToValue(&newvalue, stuff->value_lo, stuff->value_hi);
- SyncChangeCounter(pCounter, newvalue);
- return Success;
-}
-
-/*
- * ** Change Counter value
- */
-static int
-ProcSyncChangeCounter(ClientPtr client)
-{
- REQUEST(xSyncChangeCounterReq);
- SyncCounter *pCounter;
- CARD64 newvalue;
- Bool overflow;
- int rc;
-
- REQUEST_SIZE_MATCH(xSyncChangeCounterReq);
-
- rc = dixLookupResourceByType((pointer *)&pCounter, stuff->cid, RTCounter,
- client, DixWriteAccess);
- if (rc != Success)
- return rc;
-
- if (IsSystemCounter(pCounter))
- {
- client->errorValue = stuff->cid;
- return BadAccess;
- }
-
- XSyncIntsToValue(&newvalue, stuff->value_lo, stuff->value_hi);
- XSyncValueAdd(&newvalue, pCounter->value, newvalue, &overflow);
- if (overflow)
- {
- /* XXX 64 bit value can't fit in 32 bits; do the best we can */
- client->errorValue = stuff->value_hi;
- return BadValue;
- }
- SyncChangeCounter(pCounter, newvalue);
- return Success;
-}
-
-/*
- * ** Destroy a counter
- */
-static int
-ProcSyncDestroyCounter(ClientPtr client)
-{
- REQUEST(xSyncDestroyCounterReq);
- SyncCounter *pCounter;
- int rc;
-
- REQUEST_SIZE_MATCH(xSyncDestroyCounterReq);
-
- rc = dixLookupResourceByType((pointer *)&pCounter, stuff->counter, RTCounter,
- client, DixDestroyAccess);
- if (rc != Success)
- return rc;
-
- if (IsSystemCounter(pCounter))
- {
- client->errorValue = stuff->counter;
- return BadAccess;
- }
- FreeResource(pCounter->sync.id, RT_NONE);
- return Success;
-}
-
-static SyncAwaitUnion*
-SyncAwaitPrologue(ClientPtr client, int items)
-{
- SyncAwaitUnion *pAwaitUnion;
-
- /* all the memory for the entire await list is allocated
- * here in one chunk
- */
- pAwaitUnion = malloc((items+1) * sizeof(SyncAwaitUnion));
- if (!pAwaitUnion)
- return NULL;
-
- /* first item is the header, remainder are real wait conditions */
-
- pAwaitUnion->header.delete_id = FakeClientID(client->index);
- if (!AddResource(pAwaitUnion->header.delete_id, RTAwait, pAwaitUnion))
- {
- free(pAwaitUnion);
- return NULL;
- }
-
- pAwaitUnion->header.client = client;
- pAwaitUnion->header.num_waitconditions = 0;
-
- return pAwaitUnion;
-}
-
-static void
-SyncAwaitEpilogue(ClientPtr client, int items, SyncAwaitUnion *pAwaitUnion)
-{
- SyncAwait *pAwait;
- int i;
-
- IgnoreClient(client);
-
- /* see if any of the triggers are already true */
-
- pAwait = &(pAwaitUnion+1)->await; /* skip over header */
- for (i = 0; i < items; i++, pAwait++)
- {
- CARD64 value;
-
- /* don't have to worry about NULL counters because the request
- * errors before we get here out if they occur
- */
- switch (pAwait->trigger.pSync->type) {
- case SYNC_COUNTER:
- value = ((SyncCounter *)pAwait->trigger.pSync)->value;
- break;
- default:
- XSyncIntToValue(&value, 0);
- }
-
- if ((*pAwait->trigger.CheckTrigger)(&pAwait->trigger, value))
- {
- (*pAwait->trigger.TriggerFired)(&pAwait->trigger);
- break; /* once is enough */
- }
- }
-}
-
-/*
- * ** Await
- */
-static int
-ProcSyncAwait(ClientPtr client)
-{
- REQUEST(xSyncAwaitReq);
- int len, items;
- int i;
- xSyncWaitCondition *pProtocolWaitConds;
- SyncAwaitUnion *pAwaitUnion;
- SyncAwait *pAwait;
- int status;
-
- REQUEST_AT_LEAST_SIZE(xSyncAwaitReq);
-
- len = client->req_len << 2;
- len -= sz_xSyncAwaitReq;
- items = len / sz_xSyncWaitCondition;
-
- if (items * sz_xSyncWaitCondition != len)
- {
- return BadLength;
- }
- if (items == 0)
- {
- client->errorValue = items; /* XXX protocol change */
- return BadValue;
- }
-
- if (!(pAwaitUnion = SyncAwaitPrologue(client, items)))
- return BadAlloc;
-
- /* don't need to do any more memory allocation for this request! */
-
- pProtocolWaitConds = (xSyncWaitCondition *) & stuff[1];
-
- pAwait = &(pAwaitUnion+1)->await; /* skip over header */
- for (i = 0; i < items; i++, pProtocolWaitConds++, pAwait++)
- {
- if (pProtocolWaitConds->counter == None) /* XXX protocol change */
- {
- /* this should take care of removing any triggers created by
- * this request that have already been registered on sync objects
- */
- FreeResource(pAwaitUnion->header.delete_id, RT_NONE);
- client->errorValue = pProtocolWaitConds->counter;
- return SyncErrorBase + XSyncBadCounter;
- }
-
- /* sanity checks are in SyncInitTrigger */
- pAwait->trigger.pSync = NULL;
- pAwait->trigger.value_type = pProtocolWaitConds->value_type;
- XSyncIntsToValue(&pAwait->trigger.wait_value,
- pProtocolWaitConds->wait_value_lo,
- pProtocolWaitConds->wait_value_hi);
- pAwait->trigger.test_type = pProtocolWaitConds->test_type;
-
- status = SyncInitTrigger(client, &pAwait->trigger,
- pProtocolWaitConds->counter, RTCounter,
- XSyncCAAllTrigger);
- if (status != Success)
- {
- /* this should take care of removing any triggers created by
- * this request that have already been registered on sync objects
- */
- FreeResource(pAwaitUnion->header.delete_id, RT_NONE);
- return status;
- }
- /* this is not a mistake -- same function works for both cases */
- pAwait->trigger.TriggerFired = SyncAwaitTriggerFired;
- pAwait->trigger.CounterDestroyed = SyncAwaitTriggerFired;
- XSyncIntsToValue(&pAwait->event_threshold,
- pProtocolWaitConds->event_threshold_lo,
- pProtocolWaitConds->event_threshold_hi);
- pAwait->pHeader = &pAwaitUnion->header;
- pAwaitUnion->header.num_waitconditions++;
- }
-
- SyncAwaitEpilogue(client, items, pAwaitUnion);
-
- return Success;
-}
-
-
-/*
- * ** Query a counter
- */
-static int
-ProcSyncQueryCounter(ClientPtr client)
-{
- REQUEST(xSyncQueryCounterReq);
- xSyncQueryCounterReply rep;
- SyncCounter *pCounter;
- int rc;
-
- REQUEST_SIZE_MATCH(xSyncQueryCounterReq);
-
- rc = dixLookupResourceByType((pointer *)&pCounter, stuff->counter,
- RTCounter, client, DixReadAccess);
- if (rc != Success)
- return rc;
-
- rep.type = X_Reply;
- rep.length = 0;
- rep.sequenceNumber = client->sequence;
-
- /* if system counter, ask it what the current value is */
-
- if (IsSystemCounter(pCounter))
- {
- (*pCounter->pSysCounterInfo->QueryValue) ((pointer) pCounter,
- &pCounter->value);
- }
-
- rep.value_hi = XSyncValueHigh32(pCounter->value);
- rep.value_lo = XSyncValueLow32(pCounter->value);
- if (client->swapped)
- {
- char n;
- swaps(&rep.sequenceNumber, n);
- swapl(&rep.length, n);
- swapl(&rep.value_hi, n);
- swapl(&rep.value_lo, n);
- }
- WriteToClient(client, sizeof(xSyncQueryCounterReply), (char *) &rep);
- return Success;
-}
-
-
-/*
- * ** Create Alarm
- */
-static int
-ProcSyncCreateAlarm(ClientPtr client)
-{
- REQUEST(xSyncCreateAlarmReq);
- SyncAlarm *pAlarm;
- int status;
- unsigned long len, vmask;
- SyncTrigger *pTrigger;
-
- REQUEST_AT_LEAST_SIZE(xSyncCreateAlarmReq);
-
- LEGAL_NEW_RESOURCE(stuff->id, client);
-
- vmask = stuff->valueMask;
- len = client->req_len - bytes_to_int32(sizeof(xSyncCreateAlarmReq));
- /* the "extra" call to Ones accounts for the presence of 64 bit values */
- if (len != (Ones(vmask) + Ones(vmask & (XSyncCAValue|XSyncCADelta))))
- return BadLength;
-
- if (!(pAlarm = malloc(sizeof(SyncAlarm))))
- {
- return BadAlloc;
- }
-
- /* set up defaults */
-
- pTrigger = &pAlarm->trigger;
- pTrigger->pSync = NULL;
- pTrigger->value_type = XSyncAbsolute;
- XSyncIntToValue(&pTrigger->wait_value, 0L);
- pTrigger->test_type = XSyncPositiveComparison;
- pTrigger->TriggerFired = SyncAlarmTriggerFired;
- pTrigger->CounterDestroyed = SyncAlarmCounterDestroyed;
- status = SyncInitTrigger(client, pTrigger, None, RTCounter,
- XSyncCAAllTrigger);
- if (status != Success)
- {
- free(pAlarm);
- return status;
- }
-
- pAlarm->client = client;
- pAlarm->alarm_id = stuff->id;
- XSyncIntToValue(&pAlarm->delta, 1L);
- pAlarm->events = TRUE;
- pAlarm->state = XSyncAlarmInactive;
- pAlarm->pEventClients = NULL;
- status = SyncChangeAlarmAttributes(client, pAlarm, vmask,
- (CARD32 *)&stuff[1]);
- if (status != Success)
- {
- free(pAlarm);
- return status;
- }
-
- if (!AddResource(stuff->id, RTAlarm, pAlarm))
- {
- free(pAlarm);
- return BadAlloc;
- }
-
- /* see if alarm already triggered. NULL counter will not trigger
- * in CreateAlarm and sets alarm state to Inactive.
- */
-
- if (!pTrigger->pSync)
- {
- pAlarm->state = XSyncAlarmInactive; /* XXX protocol change */
- }
- else
- {
- SyncCounter *pCounter;
-
- assert(SYNC_COUNTER == pTrigger->pSync->type);
- pCounter = (SyncCounter *)pTrigger->pSync;
-
- if ((*pTrigger->CheckTrigger)(pTrigger, pCounter->value))
- (*pTrigger->TriggerFired)(pTrigger);
- }
-
- return Success;
-}
-
-/*
- * ** Change Alarm
- */
-static int
-ProcSyncChangeAlarm(ClientPtr client)
-{
- REQUEST(xSyncChangeAlarmReq);
- SyncAlarm *pAlarm;
- SyncCounter *pCounter = NULL;
- long vmask;
- int len, status;
-
- REQUEST_AT_LEAST_SIZE(xSyncChangeAlarmReq);
-
- status = dixLookupResourceByType((pointer *)&pAlarm, stuff->alarm, RTAlarm,
- client, DixWriteAccess);
- if (status != Success)
- return status;
-
- vmask = stuff->valueMask;
- len = client->req_len - bytes_to_int32(sizeof(xSyncChangeAlarmReq));
- /* the "extra" call to Ones accounts for the presence of 64 bit values */
- if (len != (Ones(vmask) + Ones(vmask & (XSyncCAValue|XSyncCADelta))))
- return BadLength;
-
- if ((status = SyncChangeAlarmAttributes(client, pAlarm, vmask,
- (CARD32 *)&stuff[1])) != Success)
- return status;
-
- if (pAlarm->trigger.pSync)
- {
- assert(SYNC_COUNTER == pAlarm->trigger.pSync->type);
- pCounter = (SyncCounter *)pAlarm->trigger.pSync;
- }
-
- /* see if alarm already triggered. NULL counter WILL trigger
- * in ChangeAlarm.
- */
-
- if (!pCounter ||
- (*pAlarm->trigger.CheckTrigger)(&pAlarm->trigger, pCounter->value))
- {
- (*pAlarm->trigger.TriggerFired)(&pAlarm->trigger);
- }
- return Success;
-}
-
-static int
-ProcSyncQueryAlarm(ClientPtr client)
-{
- REQUEST(xSyncQueryAlarmReq);
- SyncAlarm *pAlarm;
- xSyncQueryAlarmReply rep;
- SyncTrigger *pTrigger;
- int rc;
-
- REQUEST_SIZE_MATCH(xSyncQueryAlarmReq);
-
- rc = dixLookupResourceByType((pointer *)&pAlarm, stuff->alarm, RTAlarm,
- client, DixReadAccess);
- if (rc != Success)
- return rc;
-
- rep.type = X_Reply;
- rep.length = bytes_to_int32(sizeof(xSyncQueryAlarmReply) - sizeof(xGenericReply));
- rep.sequenceNumber = client->sequence;
-
- pTrigger = &pAlarm->trigger;
- rep.counter = (pTrigger->pSync) ? pTrigger->pSync->id : None;
-
-#if 0 /* XXX unclear what to do, depends on whether relative value-types
- * are "consumed" immediately and are considered absolute from then
- * on.
- */
- rep.value_type = pTrigger->value_type;
- rep.wait_value_hi = XSyncValueHigh32(pTrigger->wait_value);
- rep.wait_value_lo = XSyncValueLow32(pTrigger->wait_value);
-#else
- rep.value_type = XSyncAbsolute;
- rep.wait_value_hi = XSyncValueHigh32(pTrigger->test_value);
- rep.wait_value_lo = XSyncValueLow32(pTrigger->test_value);
-#endif
-
- rep.test_type = pTrigger->test_type;
- rep.delta_hi = XSyncValueHigh32(pAlarm->delta);
- rep.delta_lo = XSyncValueLow32(pAlarm->delta);
- rep.events = pAlarm->events;
- rep.state = pAlarm->state;
-
- if (client->swapped)
- {
- char n;
- swaps(&rep.sequenceNumber, n);
- swapl(&rep.length, n);
- swapl(&rep.counter, n);
- swapl(&rep.wait_value_hi, n);
- swapl(&rep.wait_value_lo, n);
- swapl(&rep.test_type, n);
- swapl(&rep.delta_hi, n);
- swapl(&rep.delta_lo, n);
- }
-
- WriteToClient(client, sizeof(xSyncQueryAlarmReply), (char *) &rep);
- return Success;
-}
-
-static int
-ProcSyncDestroyAlarm(ClientPtr client)
-{
- SyncAlarm *pAlarm;
- int rc;
- REQUEST(xSyncDestroyAlarmReq);
-
- REQUEST_SIZE_MATCH(xSyncDestroyAlarmReq);
-
- rc = dixLookupResourceByType((pointer *)&pAlarm, stuff->alarm, RTAlarm,
- client, DixDestroyAccess);
- if (rc != Success)
- return rc;
-
- FreeResource(stuff->alarm, RT_NONE);
- return Success;
-}
-
-static int
-ProcSyncCreateFence(ClientPtr client)
-{
- REQUEST(xSyncCreateFenceReq);
- DrawablePtr pDraw;
- SyncFence *pFence;
- int rc;
-
- REQUEST_SIZE_MATCH(xSyncCreateFenceReq);
-
- rc = dixLookupDrawable(&pDraw, stuff->d, client, M_ANY, DixGetAttrAccess);
- if (rc != Success)
- return rc;
-
- LEGAL_NEW_RESOURCE(stuff->fid, client);
-
- if (!(pFence = (SyncFence *)SyncCreate(client,
- stuff->fid,
- SYNC_FENCE)))
- return BadAlloc;
-
- miSyncInitFence(pDraw->pScreen, pFence, stuff->initially_triggered);
-
- return client->noClientException;
-}
-
-static int
-FreeFence(void *obj, XID id)
-{
- SyncFence *pFence = (SyncFence *) obj;
-
- miSyncDestroyFence(pFence);
-
- return Success;
-}
-
-int SyncVerifyFence(SyncFence **ppSyncFence, XID fid,
- ClientPtr client, Mask mode)
-{
- int rc = dixLookupResourceByType((pointer *)ppSyncFence, fid, RTFence,
- client, mode);
-
- if (rc != Success)
- client->errorValue = fid;
-
- return rc;
-}
-
-static int
-ProcSyncTriggerFence(ClientPtr client)
-{
- REQUEST(xSyncTriggerFenceReq);
- SyncFence *pFence;
- int rc;
-
- REQUEST_SIZE_MATCH(xSyncTriggerFenceReq);
-
- rc = dixLookupResourceByType((pointer *)&pFence, stuff->fid, RTFence,
- client, DixWriteAccess);
- if (rc != Success)
- return rc;
-
- miSyncTriggerFence(pFence);
-
- return client->noClientException;
-}
-
-static int
-ProcSyncResetFence(ClientPtr client)
-{
- REQUEST(xSyncResetFenceReq);
- SyncFence *pFence;
- int rc;
-
- REQUEST_SIZE_MATCH(xSyncResetFenceReq);
-
- rc = dixLookupResourceByType((pointer *)&pFence, stuff->fid, RTFence,
- client, DixWriteAccess);
- if (rc != Success)
- return rc;
-
- if (pFence->funcs.CheckTriggered(pFence) != TRUE)
- return BadMatch;
-
- pFence->funcs.Reset(pFence);
-
- return client->noClientException;
-}
-
-static int
-ProcSyncDestroyFence(ClientPtr client)
-{
- REQUEST(xSyncDestroyFenceReq);
- SyncFence *pFence;
- int rc;
-
- REQUEST_SIZE_MATCH(xSyncDestroyFenceReq);
-
- rc = dixLookupResourceByType((pointer *)&pFence, stuff->fid, RTFence,
- client, DixDestroyAccess);
- if (rc != Success)
- return rc;
-
- FreeResource(stuff->fid, RT_NONE);
- return client->noClientException;
-}
-
-static int
-ProcSyncQueryFence(ClientPtr client)
-{
- REQUEST(xSyncQueryFenceReq);
- xSyncQueryFenceReply rep;
- SyncFence *pFence;
- int rc;
-
- REQUEST_SIZE_MATCH(xSyncQueryFenceReq);
-
- rc = dixLookupResourceByType((pointer *)&pFence, stuff->fid,
- RTFence, client, DixReadAccess);
- if (rc != Success)
- return rc;
-
- rep.type = X_Reply;
- rep.length = 0;
- rep.sequenceNumber = client->sequence;
-
- rep.triggered = pFence->funcs.CheckTriggered(pFence);
-
- if (client->swapped)
- {
- char n;
- swaps(&rep.sequenceNumber, n);
- swapl(&rep.length, n);
- }
-
- WriteToClient(client, sizeof(xSyncQueryFenceReply), (char *) &rep);
- return client->noClientException;
-}
-
-static int
-ProcSyncAwaitFence(ClientPtr client)
-{
- REQUEST(xSyncAwaitFenceReq);
- SyncAwaitUnion *pAwaitUnion;
- SyncAwait *pAwait;
- /* Use CARD32 rather than XSyncFence because XIDs are hard-coded to
- * CARD32 in protocol definitions */
- CARD32 *pProtocolFences;
- int status;
- int len;
- int items;
- int i;
-
- REQUEST_AT_LEAST_SIZE(xSyncAwaitFenceReq);
-
- len = client->req_len << 2;
- len -= sz_xSyncAwaitFenceReq;
- items = len / sizeof(CARD32);
-
- if (items * sizeof(CARD32) != len)
- {
- return BadLength;
- }
- if (items == 0)
- {
- client->errorValue = items; /* XXX protocol change */
- return BadValue;
- }
-
- if (!(pAwaitUnion = SyncAwaitPrologue(client, items)))
- return BadAlloc;
-
- /* don't need to do any more memory allocation for this request! */
-
- pProtocolFences = (CARD32 *) & stuff[1];
-
- pAwait = &(pAwaitUnion+1)->await; /* skip over header */
- for (i = 0; i < items; i++, pProtocolFences++, pAwait++)
- {
- if (*pProtocolFences == None) /* XXX protocol change */
- {
- /* this should take care of removing any triggers created by
- * this request that have already been registered on sync objects
- */
- FreeResource(pAwaitUnion->header.delete_id, RT_NONE);
- client->errorValue = *pProtocolFences;
- return SyncErrorBase + XSyncBadCounter;
- }
-
- pAwait->trigger.pSync = NULL;
- /* Provide acceptable values for these unused fields to
- * satisfy SyncInitTrigger's validation logic
- */
- pAwait->trigger.value_type = XSyncAbsolute;
- XSyncIntToValue(&pAwait->trigger.wait_value, 0);
- pAwait->trigger.test_type = 0;
-
- status = SyncInitTrigger(client, &pAwait->trigger,
- *pProtocolFences, RTFence,
- XSyncCAAllTrigger);
- if (status != Success)
- {
- /* this should take care of removing any triggers created by
- * this request that have already been registered on sync objects
- */
- FreeResource(pAwaitUnion->header.delete_id, RT_NONE);
- return status;
- }
- /* this is not a mistake -- same function works for both cases */
- pAwait->trigger.TriggerFired = SyncAwaitTriggerFired;
- pAwait->trigger.CounterDestroyed = SyncAwaitTriggerFired;
- /* event_threshold is unused for fence syncs */
- XSyncIntToValue(&pAwait->event_threshold, 0);
- pAwait->pHeader = &pAwaitUnion->header;
- pAwaitUnion->header.num_waitconditions++;
- }
-
- SyncAwaitEpilogue(client, items, pAwaitUnion);
-
- return client->noClientException;
-}
-
-/*
- * ** Given an extension request, call the appropriate request procedure
- */
-static int
-ProcSyncDispatch(ClientPtr client)
-{
- REQUEST(xReq);
-
- switch (stuff->data)
- {
- case X_SyncInitialize:
- return ProcSyncInitialize(client);
- case X_SyncListSystemCounters:
- return ProcSyncListSystemCounters(client);
- case X_SyncCreateCounter:
- return ProcSyncCreateCounter(client);
- case X_SyncSetCounter:
- return ProcSyncSetCounter(client);
- case X_SyncChangeCounter:
- return ProcSyncChangeCounter(client);
- case X_SyncQueryCounter:
- return ProcSyncQueryCounter(client);
- case X_SyncDestroyCounter:
- return ProcSyncDestroyCounter(client);
- case X_SyncAwait:
- return ProcSyncAwait(client);
- case X_SyncCreateAlarm:
- return ProcSyncCreateAlarm(client);
- case X_SyncChangeAlarm:
- return ProcSyncChangeAlarm(client);
- case X_SyncQueryAlarm:
- return ProcSyncQueryAlarm(client);
- case X_SyncDestroyAlarm:
- return ProcSyncDestroyAlarm(client);
- case X_SyncSetPriority:
- return ProcSyncSetPriority(client);
- case X_SyncGetPriority:
- return ProcSyncGetPriority(client);
- case X_SyncCreateFence:
- return ProcSyncCreateFence(client);
- case X_SyncTriggerFence:
- return ProcSyncTriggerFence(client);
- case X_SyncResetFence:
- return ProcSyncResetFence(client);
- case X_SyncDestroyFence:
- return ProcSyncDestroyFence(client);
- case X_SyncQueryFence:
- return ProcSyncQueryFence(client);
- case X_SyncAwaitFence:
- return ProcSyncAwaitFence(client);
- default:
- return BadRequest;
- }
-}
-
-/*
- * Boring Swapping stuff ...
- */
-
-static int
-SProcSyncInitialize(ClientPtr client)
-{
- REQUEST(xSyncInitializeReq);
- char n;
-
- swaps(&stuff->length, n);
- REQUEST_SIZE_MATCH (xSyncInitializeReq);
-
- return ProcSyncInitialize(client);
-}
-
-static int
-SProcSyncListSystemCounters(ClientPtr client)
-{
- REQUEST(xSyncListSystemCountersReq);
- char n;
-
- swaps(&stuff->length, n);
- REQUEST_SIZE_MATCH (xSyncListSystemCountersReq);
-
- return ProcSyncListSystemCounters(client);
-}
-
-static int
-SProcSyncCreateCounter(ClientPtr client)
-{
- REQUEST(xSyncCreateCounterReq);
- char n;
-
- swaps(&stuff->length, n);
- REQUEST_SIZE_MATCH (xSyncCreateCounterReq);
- swapl(&stuff->cid, n);
- swapl(&stuff->initial_value_lo, n);
- swapl(&stuff->initial_value_hi, n);
-
- return ProcSyncCreateCounter(client);
-}
-
-static int
-SProcSyncSetCounter(ClientPtr client)
-{
- REQUEST(xSyncSetCounterReq);
- char n;
-
- swaps(&stuff->length, n);
- REQUEST_SIZE_MATCH (xSyncSetCounterReq);
- swapl(&stuff->cid, n);
- swapl(&stuff->value_lo, n);
- swapl(&stuff->value_hi, n);
-
- return ProcSyncSetCounter(client);
-}
-
-static int
-SProcSyncChangeCounter(ClientPtr client)
-{
- REQUEST(xSyncChangeCounterReq);
- char n;
-
- swaps(&stuff->length, n);
- REQUEST_SIZE_MATCH (xSyncChangeCounterReq);
- swapl(&stuff->cid, n);
- swapl(&stuff->value_lo, n);
- swapl(&stuff->value_hi, n);
-
- return ProcSyncChangeCounter(client);
-}
-
-static int
-SProcSyncQueryCounter(ClientPtr client)
-{
- REQUEST(xSyncQueryCounterReq);
- char n;
-
- swaps(&stuff->length, n);
- REQUEST_SIZE_MATCH (xSyncQueryCounterReq);
- swapl(&stuff->counter, n);
-
- return ProcSyncQueryCounter(client);
-}
-
-static int
-SProcSyncDestroyCounter(ClientPtr client)
-{
- REQUEST(xSyncDestroyCounterReq);
- char n;
-
- swaps(&stuff->length, n);
- REQUEST_SIZE_MATCH (xSyncDestroyCounterReq);
- swapl(&stuff->counter, n);
-
- return ProcSyncDestroyCounter(client);
-}
-
-static int
-SProcSyncAwait(ClientPtr client)
-{
- REQUEST(xSyncAwaitReq);
- char n;
-
- swaps(&stuff->length, n);
- REQUEST_AT_LEAST_SIZE(xSyncAwaitReq);
- SwapRestL(stuff);
-
- return ProcSyncAwait(client);
-}
-
-static int
-SProcSyncCreateAlarm(ClientPtr client)
-{
- REQUEST(xSyncCreateAlarmReq);
- char n;
-
- swaps(&stuff->length, n);
- REQUEST_AT_LEAST_SIZE(xSyncCreateAlarmReq);
- swapl(&stuff->id, n);
- swapl(&stuff->valueMask, n);
- SwapRestL(stuff);
-
- return ProcSyncCreateAlarm(client);
-}
-
-static int
-SProcSyncChangeAlarm(ClientPtr client)
-{
- REQUEST(xSyncChangeAlarmReq);
- char n;
-
- swaps(&stuff->length, n);
- REQUEST_AT_LEAST_SIZE(xSyncChangeAlarmReq);
- swapl(&stuff->alarm, n);
- swapl(&stuff->valueMask, n);
- SwapRestL(stuff);
- return ProcSyncChangeAlarm(client);
-}
-
-static int
-SProcSyncQueryAlarm(ClientPtr client)
-{
- REQUEST(xSyncQueryAlarmReq);
- char n;
-
- swaps(&stuff->length, n);
- REQUEST_SIZE_MATCH (xSyncQueryAlarmReq);
- swapl(&stuff->alarm, n);
-
- return ProcSyncQueryAlarm(client);
-}
-
-static int
-SProcSyncDestroyAlarm(ClientPtr client)
-{
- REQUEST(xSyncDestroyAlarmReq);
- char n;
-
- swaps(&stuff->length, n);
- REQUEST_SIZE_MATCH (xSyncDestroyAlarmReq);
- swapl(&stuff->alarm, n);
-
- return ProcSyncDestroyAlarm(client);
-}
-
-static int
-SProcSyncSetPriority(ClientPtr client)
-{
- REQUEST(xSyncSetPriorityReq);
- char n;
-
- swaps(&stuff->length, n);
- REQUEST_SIZE_MATCH (xSyncSetPriorityReq);
- swapl(&stuff->id, n);
- swapl(&stuff->priority, n);
-
- return ProcSyncSetPriority(client);
-}
-
-static int
-SProcSyncGetPriority(ClientPtr client)
-{
- REQUEST(xSyncGetPriorityReq);
- char n;
-
- swaps(&stuff->length, n);
- REQUEST_SIZE_MATCH (xSyncGetPriorityReq);
- swapl(&stuff->id, n);
-
- return ProcSyncGetPriority(client);
-}
-
-static int
-SProcSyncCreateFence(ClientPtr client)
-{
- REQUEST(xSyncCreateFenceReq);
- char n;
-
- swaps(&stuff->length, n);
- REQUEST_SIZE_MATCH (xSyncCreateFenceReq);
- swapl(&stuff->fid, n);
-
- return ProcSyncCreateFence(client);
-}
-
-static int
-SProcSyncTriggerFence(ClientPtr client)
-{
- REQUEST(xSyncTriggerFenceReq);
- char n;
-
- swaps(&stuff->length, n);
- REQUEST_SIZE_MATCH (xSyncTriggerFenceReq);
- swapl(&stuff->fid, n);
-
- return ProcSyncTriggerFence(client);
-}
-
-static int
-SProcSyncResetFence(ClientPtr client)
-{
- REQUEST(xSyncResetFenceReq);
- char n;
-
- swaps(&stuff->length, n);
- REQUEST_SIZE_MATCH (xSyncResetFenceReq);
- swapl(&stuff->fid, n);
-
- return ProcSyncResetFence(client);
-}
-
-static int
-SProcSyncDestroyFence(ClientPtr client)
-{
- REQUEST(xSyncDestroyFenceReq);
- char n;
-
- swaps(&stuff->length, n);
- REQUEST_SIZE_MATCH (xSyncDestroyFenceReq);
- swapl(&stuff->fid, n);
-
- return ProcSyncDestroyFence(client);
-}
-
-static int
-SProcSyncQueryFence(ClientPtr client)
-{
- REQUEST(xSyncQueryFenceReq);
- char n;
-
- swaps(&stuff->length, n);
- REQUEST_SIZE_MATCH (xSyncQueryFenceReq);
- swapl(&stuff->fid, n);
-
- return ProcSyncQueryFence(client);
-}
-
-static int
-SProcSyncAwaitFence(ClientPtr client)
-{
- REQUEST(xSyncAwaitFenceReq);
- char n;
-
- swaps(&stuff->length, n);
- REQUEST_AT_LEAST_SIZE(xSyncAwaitFenceReq);
- SwapRestL(stuff);
-
- return ProcSyncAwaitFence(client);
-}
-
-static int
-SProcSyncDispatch(ClientPtr client)
-{
- REQUEST(xReq);
-
- switch (stuff->data)
- {
- case X_SyncInitialize:
- return SProcSyncInitialize(client);
- case X_SyncListSystemCounters:
- return SProcSyncListSystemCounters(client);
- case X_SyncCreateCounter:
- return SProcSyncCreateCounter(client);
- case X_SyncSetCounter:
- return SProcSyncSetCounter(client);
- case X_SyncChangeCounter:
- return SProcSyncChangeCounter(client);
- case X_SyncQueryCounter:
- return SProcSyncQueryCounter(client);
- case X_SyncDestroyCounter:
- return SProcSyncDestroyCounter(client);
- case X_SyncAwait:
- return SProcSyncAwait(client);
- case X_SyncCreateAlarm:
- return SProcSyncCreateAlarm(client);
- case X_SyncChangeAlarm:
- return SProcSyncChangeAlarm(client);
- case X_SyncQueryAlarm:
- return SProcSyncQueryAlarm(client);
- case X_SyncDestroyAlarm:
- return SProcSyncDestroyAlarm(client);
- case X_SyncSetPriority:
- return SProcSyncSetPriority(client);
- case X_SyncGetPriority:
- return SProcSyncGetPriority(client);
- case X_SyncCreateFence:
- return SProcSyncCreateFence(client);
- case X_SyncTriggerFence:
- return SProcSyncTriggerFence(client);
- case X_SyncResetFence:
- return SProcSyncResetFence(client);
- case X_SyncDestroyFence:
- return SProcSyncDestroyFence(client);
- case X_SyncQueryFence:
- return SProcSyncQueryFence(client);
- case X_SyncAwaitFence:
- return SProcSyncAwaitFence(client);
- default:
- return BadRequest;
- }
-}
-
-/*
- * Event Swapping
- */
-
-static void
-SCounterNotifyEvent(xSyncCounterNotifyEvent *from, xSyncCounterNotifyEvent *to)
-{
- to->type = from->type;
- to->kind = from->kind;
- cpswaps(from->sequenceNumber, to->sequenceNumber);
- cpswapl(from->counter, to->counter);
- cpswapl(from->wait_value_lo, to->wait_value_lo);
- cpswapl(from->wait_value_hi, to->wait_value_hi);
- cpswapl(from->counter_value_lo, to->counter_value_lo);
- cpswapl(from->counter_value_hi, to->counter_value_hi);
- cpswapl(from->time, to->time);
- cpswaps(from->count, to->count);
- to->destroyed = from->destroyed;
-}
-
-
-static void
-SAlarmNotifyEvent(xSyncAlarmNotifyEvent *from, xSyncAlarmNotifyEvent *to)
-{
- to->type = from->type;
- to->kind = from->kind;
- cpswaps(from->sequenceNumber, to->sequenceNumber);
- cpswapl(from->alarm, to->alarm);
- cpswapl(from->counter_value_lo, to->counter_value_lo);
- cpswapl(from->counter_value_hi, to->counter_value_hi);
- cpswapl(from->alarm_value_lo, to->alarm_value_lo);
- cpswapl(from->alarm_value_hi, to->alarm_value_hi);
- cpswapl(from->time, to->time);
- to->state = from->state;
-}
-
-/*
- * ** Close everything down. ** This is fairly simple for now.
- */
-/* ARGSUSED */
-static void
-SyncResetProc(ExtensionEntry *extEntry)
-{
- free(SysCounterList);
- SysCounterList = NULL;
- RTCounter = 0;
-}
-
-/*
- * ** Initialise the extension.
- */
-void
-SyncExtensionInit(void)
-{
- ExtensionEntry *extEntry;
- int s;
-
- for (s = 0; s < screenInfo.numScreens; s++)
- miSyncSetup(screenInfo.screens[s]);
-
- if (RTCounter == 0)
- {
- RTCounter = CreateNewResourceType(FreeCounter, "SyncCounter");
- }
- RTAlarm = CreateNewResourceType(FreeAlarm, "SyncAlarm");
- RTAwait = CreateNewResourceType(FreeAwait, "SyncAwait");
- RTFence = CreateNewResourceType(FreeFence, "SyncFence");
- if (RTAwait)
- RTAwait |= RC_NEVERRETAIN;
- RTAlarmClient = CreateNewResourceType(FreeAlarmClient, "SyncAlarmClient");
- if (RTAlarmClient)
- RTAlarmClient |= RC_NEVERRETAIN;
-
- if (RTCounter == 0 || RTAwait == 0 || RTAlarm == 0 ||
- RTAlarmClient == 0 ||
- (extEntry = AddExtension(SYNC_NAME,
- XSyncNumberEvents, XSyncNumberErrors,
- ProcSyncDispatch, SProcSyncDispatch,
- SyncResetProc,
- StandardMinorOpcode)) == NULL)
- {
- ErrorF("Sync Extension %d.%d failed to Initialise\n",
- SYNC_MAJOR_VERSION, SYNC_MINOR_VERSION);
- return;
- }
-
- SyncEventBase = extEntry->eventBase;
- SyncErrorBase = extEntry->errorBase;
- EventSwapVector[SyncEventBase + XSyncCounterNotify] = (EventSwapPtr) SCounterNotifyEvent;
- EventSwapVector[SyncEventBase + XSyncAlarmNotify] = (EventSwapPtr) SAlarmNotifyEvent;
-
- SetResourceTypeErrorValue(RTCounter, SyncErrorBase + XSyncBadCounter);
- SetResourceTypeErrorValue(RTAlarm, SyncErrorBase + XSyncBadAlarm);
- SetResourceTypeErrorValue(RTFence, SyncErrorBase + XSyncBadFence);
-
- /*
- * Although SERVERTIME is implemented by the OS layer, we initialise it
- * here because doing it in OsInit() is too early. The resource database
- * is not initialised when OsInit() is called. This is just about OK
- * because there is always a servertime counter.
- */
- SyncInitServerTime();
- SyncInitIdleTime();
-
-#ifdef DEBUG
- fprintf(stderr, "Sync Extension %d.%d\n",
- SYNC_MAJOR_VERSION, SYNC_MINOR_VERSION);
-#endif
-}
-
-
-/*
- * ***** SERVERTIME implementation - should go in its own file in OS directory?
- */
-
-
-
-static pointer ServertimeCounter;
-static XSyncValue Now;
-static XSyncValue *pnext_time;
-
-#define GetTime()\
-{\
- unsigned long millis = GetTimeInMillis();\
- unsigned long maxis = XSyncValueHigh32(Now);\
- if (millis < XSyncValueLow32(Now)) maxis++;\
- XSyncIntsToValue(&Now, millis, maxis);\
-}
-
-/*
-*** Server Block Handler
-*** code inspired by multibuffer extension (now deprecated)
- */
-/*ARGSUSED*/
-static void
-ServertimeBlockHandler(void *env, struct timeval **wt, void *LastSelectMask)
-{
- XSyncValue delay;
- unsigned long timeout;
-
- if (pnext_time)
- {
- GetTime();
-
- if (XSyncValueGreaterOrEqual(Now, *pnext_time))
- {
- timeout = 0;
- }
- else
- {
- Bool overflow;
- XSyncValueSubtract(&delay, *pnext_time, Now, &overflow);
- (void)overflow;
- timeout = XSyncValueLow32(delay);
- }
- AdjustWaitForDelay(wt, timeout); /* os/utils.c */
- }
-}
-
-/*
-*** Wakeup Handler
- */
-/*ARGSUSED*/
-static void
-ServertimeWakeupHandler(void *env, int rc, void *LastSelectMask)
-{
- if (pnext_time)
- {
- GetTime();
-
- if (XSyncValueGreaterOrEqual(Now, *pnext_time))
- {
- SyncChangeCounter(ServertimeCounter, Now);
- }
- }
-}
-
-static void
-ServertimeQueryValue(void *pCounter, CARD64 *pValue_return)
-{
- GetTime();
- *pValue_return = Now;
-}
-
-static void
-ServertimeBracketValues(void *pCounter, CARD64 *pbracket_less,
- CARD64 *pbracket_greater)
-{
- if (!pnext_time && pbracket_greater)
- {
- RegisterBlockAndWakeupHandlers(ServertimeBlockHandler,
- ServertimeWakeupHandler,
- NULL);
- }
- else if (pnext_time && !pbracket_greater)
- {
- RemoveBlockAndWakeupHandlers(ServertimeBlockHandler,
- ServertimeWakeupHandler,
- NULL);
- }
- pnext_time = pbracket_greater;
-}
-
-static void
-SyncInitServerTime(void)
-{
- CARD64 resolution;
-
- XSyncIntsToValue(&Now, GetTimeInMillis(), 0);
- XSyncIntToValue(&resolution, 4);
- ServertimeCounter = SyncCreateSystemCounter("SERVERTIME", Now, resolution,
- XSyncCounterNeverDecreases,
- ServertimeQueryValue, ServertimeBracketValues);
- pnext_time = NULL;
-}
-
-
-
-/*
- * IDLETIME implementation
- */
-
-static SyncCounter *IdleTimeCounter;
-static XSyncValue *pIdleTimeValueLess;
-static XSyncValue *pIdleTimeValueGreater;
-
-static void
-IdleTimeQueryValue (pointer pCounter, CARD64 *pValue_return)
-{
- CARD32 idle = GetTimeInMillis() - lastDeviceEventTime.milliseconds;
- XSyncIntsToValue (pValue_return, idle, 0);
-}
-
-static void
-IdleTimeBlockHandler(pointer env, struct timeval **wt, pointer LastSelectMask)
-{
- XSyncValue idle, old_idle;
- SyncTriggerList *list = IdleTimeCounter->sync.pTriglist;
- SyncTrigger *trig;
-
- if (!pIdleTimeValueLess && !pIdleTimeValueGreater)
- return;
-
- old_idle = IdleTimeCounter->value;
- IdleTimeQueryValue (NULL, &idle);
- IdleTimeCounter->value = idle; /* push, so CheckTrigger works */
-
- if (pIdleTimeValueLess &&
- XSyncValueLessOrEqual (idle, *pIdleTimeValueLess))
- {
- /*
- * We've been idle for less than the threshold value, and someone
- * wants to know about that, but now we need to know whether they
- * want level or edge trigger. Check the trigger list against the
- * current idle time, and if any succeed, bomb out of select()
- * immediately so we can reschedule.
- */
-
- for (list = IdleTimeCounter->sync.pTriglist; list; list = list->next) {
- trig = list->pTrigger;
- if (trig->CheckTrigger(trig, old_idle)) {
- AdjustWaitForDelay(wt, 0);
- break;
- }
- }
- }
- else if (pIdleTimeValueGreater)
- {
- /*
- * There's a threshold in the positive direction. If we've been
- * idle less than it, schedule a wakeup for sometime in the future.
- * If we've been idle more than it, and someone wants to know about
- * that level-triggered, schedule an immediate wakeup.
- */
- unsigned long timeout = -1;
-
- if (XSyncValueLessThan (idle, *pIdleTimeValueGreater)) {
- XSyncValue value;
- Bool overflow;
-
- XSyncValueSubtract (&value, *pIdleTimeValueGreater,
- idle, &overflow);
- timeout = min(timeout, XSyncValueLow32 (value));
- } else {
- for (list = IdleTimeCounter->sync.pTriglist; list; list = list->next) {
- trig = list->pTrigger;
- if (trig->CheckTrigger(trig, old_idle)) {
- timeout = min(timeout, 0);
- break;
- }
- }
- }
-
- AdjustWaitForDelay (wt, timeout);
- }
-
- IdleTimeCounter->value = old_idle; /* pop */
-}
-
-static void
-IdleTimeWakeupHandler (pointer env, int rc, pointer LastSelectMask)
-{
- XSyncValue idle;
-
- if (!pIdleTimeValueLess && !pIdleTimeValueGreater)
- return;
-
- IdleTimeQueryValue (NULL, &idle);
-
- if ((pIdleTimeValueGreater &&
- XSyncValueGreaterOrEqual (idle, *pIdleTimeValueGreater)) ||
- (pIdleTimeValueLess &&
- XSyncValueLessOrEqual (idle, *pIdleTimeValueLess)))
- {
- SyncChangeCounter (IdleTimeCounter, idle);
- }
-}
-
-static void
-IdleTimeBracketValues (pointer pCounter, CARD64 *pbracket_less,
- CARD64 *pbracket_greater)
-{
- Bool registered = (pIdleTimeValueLess || pIdleTimeValueGreater);
-
- if (registered && !pbracket_less && !pbracket_greater)
- {
- RemoveBlockAndWakeupHandlers(IdleTimeBlockHandler,
- IdleTimeWakeupHandler,
- NULL);
- }
- else if (!registered && (pbracket_less || pbracket_greater))
- {
- RegisterBlockAndWakeupHandlers(IdleTimeBlockHandler,
- IdleTimeWakeupHandler,
- NULL);
- }
-
- pIdleTimeValueGreater = pbracket_greater;
- pIdleTimeValueLess = pbracket_less;
-}
-
-static void
-SyncInitIdleTime (void)
-{
- CARD64 resolution;
- XSyncValue idle;
-
- IdleTimeQueryValue (NULL, &idle);
- XSyncIntToValue (&resolution, 4);
-
- IdleTimeCounter = SyncCreateSystemCounter ("IDLETIME", idle, resolution,
- XSyncCounterUnrestricted,
- IdleTimeQueryValue,
- IdleTimeBracketValues);
-
- pIdleTimeValueLess = pIdleTimeValueGreater = NULL;
-}
+/*
+
+Copyright 1991, 1993, 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 1991, 1993 by Digital Equipment Corporation, Maynard, Massachusetts,
+and Olivetti Research Limited, Cambridge, England.
+
+ 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 names of Digital or Olivetti
+not be used in advertising or publicity pertaining to distribution of the
+software without specific, written prior permission. Digital and Olivetti
+make no representations about the suitability of this software
+for any purpose. It is provided "as is" without express or implied warranty.
+
+DIGITAL AND OLIVETTI DISCLAIM ALL WARRANTIES WITH REGARD TO THIS
+SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND
+FITNESS, IN NO EVENT SHALL THEY 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_DIX_CONFIG_H
+#include <dix-config.h>
+#endif
+
+#include <string.h>
+
+#include <X11/X.h>
+#include <X11/Xproto.h>
+#include <X11/Xmd.h>
+#include "scrnintstr.h"
+#include "os.h"
+#include "extnsionst.h"
+#include "dixstruct.h"
+#include "pixmapstr.h"
+#include "resource.h"
+#include "opaque.h"
+#include <X11/extensions/syncproto.h>
+#include "syncsrv.h"
+#include "syncsdk.h"
+#include "protocol-versions.h"
+
+#include <stdio.h>
+#if !defined(WIN32)
+#include <sys/time.h>
+#endif
+
+#include "modinit.h"
+
+/*
+ * Local Global Variables
+ */
+static int SyncEventBase;
+static int SyncErrorBase;
+static RESTYPE RTCounter = 0;
+static RESTYPE RTAwait;
+static RESTYPE RTAlarm;
+static RESTYPE RTAlarmClient;
+static RESTYPE RTFence;
+static int SyncNumSystemCounters = 0;
+static SyncCounter **SysCounterList = NULL;
+
+#define IsSystemCounter(pCounter) \
+ (pCounter && (pCounter->sync.client == NULL))
+
+/* these are all the alarm attributes that pertain to the alarm's trigger */
+#define XSyncCAAllTrigger \
+ (XSyncCACounter | XSyncCAValueType | XSyncCAValue | XSyncCATestType)
+
+static void SyncComputeBracketValues(SyncCounter *);
+
+static void SyncInitServerTime(void);
+
+static void SyncInitIdleTime(void);
+
+
+/* Each counter maintains a simple linked list of triggers that are
+ * interested in the counter. The two functions below are used to
+ * delete and add triggers on this list.
+ */
+static void
+SyncDeleteTriggerFromSyncObject(SyncTrigger *pTrigger)
+{
+ SyncTriggerList *pCur;
+ SyncTriggerList *pPrev;
+ SyncCounter *pCounter;
+
+ /* pSync needs to be stored in pTrigger before calling here. */
+
+ if (!pTrigger->pSync)
+ return;
+
+ pPrev = NULL;
+ pCur = pTrigger->pSync->pTriglist;
+
+ while (pCur)
+ {
+ if (pCur->pTrigger == pTrigger)
+ {
+ if (pPrev)
+ pPrev->next = pCur->next;
+ else
+ pTrigger->pSync->pTriglist = pCur->next;
+
+ free(pCur);
+ break;
+ }
+
+ pPrev = pCur;
+ pCur = pCur->next;
+ }
+
+ if (SYNC_COUNTER == pTrigger->pSync->type)
+ {
+ pCounter = (SyncCounter *)pTrigger->pSync;
+
+ if (IsSystemCounter(pCounter))
+ SyncComputeBracketValues(pCounter);
+ } else if (SYNC_FENCE == pTrigger->pSync->type) {
+ SyncFence* pFence = (SyncFence*) pTrigger->pSync;
+ pFence->funcs.DeleteTrigger(pTrigger);
+ }
+}
+
+
+static int
+SyncAddTriggerToSyncObject(SyncTrigger *pTrigger)
+{
+ SyncTriggerList *pCur;
+ SyncCounter *pCounter;
+
+ if (!pTrigger->pSync)
+ return Success;
+
+ /* don't do anything if it's already there */
+ for (pCur = pTrigger->pSync->pTriglist; pCur; pCur = pCur->next)
+ {
+ if (pCur->pTrigger == pTrigger)
+ return Success;
+ }
+
+ if (!(pCur = malloc(sizeof(SyncTriggerList))))
+ return BadAlloc;
+
+ pCur->pTrigger = pTrigger;
+ pCur->next = pTrigger->pSync->pTriglist;
+ pTrigger->pSync->pTriglist = pCur;
+
+ if (SYNC_COUNTER == pTrigger->pSync->type)
+ {
+ pCounter = (SyncCounter *)pTrigger->pSync;
+
+ if (IsSystemCounter(pCounter))
+ SyncComputeBracketValues(pCounter);
+ } else if (SYNC_FENCE == pTrigger->pSync->type) {
+ SyncFence* pFence = (SyncFence*) pTrigger->pSync;
+ pFence->funcs.AddTrigger(pTrigger);
+ }
+
+ return Success;
+}
+
+
+/* Below are five possible functions that can be plugged into
+ * pTrigger->CheckTrigger for counter sync objects, corresponding to
+ * the four possible test-types, and the one possible function that
+ * can be plugged into pTrigger->CheckTrigger for fence sync objects.
+ * These functions are called after the sync object's state changes
+ * but are also passed the old state so they can inspect both the old
+ * and new values. (PositiveTransition and NegativeTransition need to
+ * see both pieces of information.) These functions return the truth
+ * value of the trigger.
+ *
+ * All of them include the condition pTrigger->pSync == NULL.
+ * This is because the spec says that a trigger with a sync value
+ * of None is always TRUE.
+ */
+
+static Bool
+SyncCheckTriggerPositiveComparison(SyncTrigger *pTrigger, CARD64 oldval)
+{
+ SyncCounter *pCounter;
+
+ assert(!pTrigger->pSync || (SYNC_COUNTER == pTrigger->pSync->type));
+ pCounter = (SyncCounter *)pTrigger->pSync;
+
+ return (pCounter == NULL ||
+ XSyncValueGreaterOrEqual(pCounter->value, pTrigger->test_value));
+}
+
+static Bool
+SyncCheckTriggerNegativeComparison(SyncTrigger *pTrigger, CARD64 oldval)
+{
+ SyncCounter *pCounter;
+
+ assert(!pTrigger->pSync || (SYNC_COUNTER == pTrigger->pSync->type));
+ pCounter = (SyncCounter *)pTrigger->pSync;
+
+ return (pCounter == NULL ||
+ XSyncValueLessOrEqual(pCounter->value, pTrigger->test_value));
+}
+
+static Bool
+SyncCheckTriggerPositiveTransition(SyncTrigger *pTrigger, CARD64 oldval)
+{
+ SyncCounter *pCounter;
+
+ assert(!pTrigger->pSync || (SYNC_COUNTER == pTrigger->pSync->type));
+ pCounter = (SyncCounter *)pTrigger->pSync;
+
+ return (pCounter == NULL ||
+ (XSyncValueLessThan(oldval, pTrigger->test_value) &&
+ XSyncValueGreaterOrEqual(pCounter->value, pTrigger->test_value)));
+}
+
+static Bool
+SyncCheckTriggerNegativeTransition(SyncTrigger *pTrigger, CARD64 oldval)
+{
+ SyncCounter *pCounter;
+
+ assert(!pTrigger->pSync || (SYNC_COUNTER == pTrigger->pSync->type));
+ pCounter = (SyncCounter *)pTrigger->pSync;
+
+ return (pCounter == NULL ||
+ (XSyncValueGreaterThan(oldval, pTrigger->test_value) &&
+ XSyncValueLessOrEqual(pCounter->value, pTrigger->test_value)));
+}
+
+static Bool
+SyncCheckTriggerFence(SyncTrigger *pTrigger, CARD64 unused)
+{
+ SyncFence* pFence = (SyncFence*) pTrigger->pSync;
+ (void)unused;
+
+ return (pFence == NULL ||
+ pFence->funcs.CheckTriggered(pFence));
+}
+
+static int
+SyncInitTrigger(ClientPtr client, SyncTrigger *pTrigger, XID syncObject,
+ RESTYPE resType, Mask changes)
+{
+ SyncObject *pSync = pTrigger->pSync;
+ SyncCounter *pCounter = NULL;
+ int rc;
+ Bool newSyncObject = FALSE;
+
+ if (changes & XSyncCACounter)
+ {
+ if (syncObject == None)
+ pSync = NULL;
+ else if (Success != (rc = dixLookupResourceByType ((pointer *)&pSync,
+ syncObject, resType, client, DixReadAccess)))
+ {
+ client->errorValue = syncObject;
+ return rc;
+ }
+ if (pSync != pTrigger->pSync)
+ { /* new counter for trigger */
+ SyncDeleteTriggerFromSyncObject(pTrigger);
+ pTrigger->pSync = pSync;
+ newSyncObject = TRUE;
+ }
+ }
+
+ /* if system counter, ask it what the current value is */
+
+ if (pSync && SYNC_COUNTER == pSync->type)
+ {
+ pCounter = (SyncCounter *)pSync;
+
+ if (IsSystemCounter(pCounter))
+ {
+ (*pCounter->pSysCounterInfo->QueryValue) ((pointer) pCounter,
+ &pCounter->value);
+ }
+ }
+
+ if (changes & XSyncCAValueType)
+ {
+ if (pTrigger->value_type != XSyncRelative &&
+ pTrigger->value_type != XSyncAbsolute)
+ {
+ client->errorValue = pTrigger->value_type;
+ return BadValue;
+ }
+ }
+
+ if (changes & XSyncCATestType)
+ {
+
+ if (pSync && SYNC_FENCE == pSync->type)
+ {
+ pTrigger->CheckTrigger = SyncCheckTriggerFence;
+ }
+ else
+ {
+ if (pTrigger->test_type != XSyncPositiveTransition &&
+ pTrigger->test_type != XSyncNegativeTransition &&
+ pTrigger->test_type != XSyncPositiveComparison &&
+ pTrigger->test_type != XSyncNegativeComparison)
+ {
+ client->errorValue = pTrigger->test_type;
+ return BadValue;
+ }
+ /* select appropriate CheckTrigger function */
+
+ switch (pTrigger->test_type)
+ {
+ case XSyncPositiveTransition:
+ pTrigger->CheckTrigger = SyncCheckTriggerPositiveTransition;
+ break;
+ case XSyncNegativeTransition:
+ pTrigger->CheckTrigger = SyncCheckTriggerNegativeTransition;
+ break;
+ case XSyncPositiveComparison:
+ pTrigger->CheckTrigger = SyncCheckTriggerPositiveComparison;
+ break;
+ case XSyncNegativeComparison:
+ pTrigger->CheckTrigger = SyncCheckTriggerNegativeComparison;
+ break;
+ }
+ }
+ }
+
+ if (changes & (XSyncCAValueType | XSyncCAValue))
+ {
+ if (pTrigger->value_type == XSyncAbsolute)
+ pTrigger->test_value = pTrigger->wait_value;
+ else /* relative */
+ {
+ Bool overflow;
+ if (pCounter == NULL)
+ return BadMatch;
+
+ XSyncValueAdd(&pTrigger->test_value, pCounter->value,
+ pTrigger->wait_value, &overflow);
+ if (overflow)
+ {
+ client->errorValue = XSyncValueHigh32(pTrigger->wait_value);
+ return BadValue;
+ }
+ }
+ }
+
+ /* we wait until we're sure there are no errors before registering
+ * a new counter on a trigger
+ */
+ if (newSyncObject)
+ {
+ if ((rc = SyncAddTriggerToSyncObject(pTrigger)) != Success)
+ return rc;
+ }
+ else if (pCounter && IsSystemCounter(pCounter))
+ {
+ SyncComputeBracketValues(pCounter);
+ }
+
+ return Success;
+}
+
+/* AlarmNotify events happen in response to actions taken on an Alarm or
+ * the counter used by the alarm. AlarmNotify may be sent to multiple
+ * clients. The alarm maintains a list of clients interested in events.
+ */
+static void
+SyncSendAlarmNotifyEvents(SyncAlarm *pAlarm)
+{
+ SyncAlarmClientList *pcl;
+ xSyncAlarmNotifyEvent ane;
+ SyncTrigger *pTrigger = &pAlarm->trigger;
+ SyncCounter *pCounter;
+
+ assert(!pTrigger->pSync || (SYNC_COUNTER == pTrigger->pSync->type));
+
+ pCounter = (SyncCounter *)pTrigger->pSync;
+
+ UpdateCurrentTime();
+
+ ane.type = SyncEventBase + XSyncAlarmNotify;
+ ane.kind = XSyncAlarmNotify;
+ ane.alarm = pAlarm->alarm_id;
+ if (pTrigger->pSync && SYNC_COUNTER == pTrigger->pSync->type)
+ {
+ ane.counter_value_hi = XSyncValueHigh32(pCounter->value);
+ ane.counter_value_lo = XSyncValueLow32(pCounter->value);
+ }
+ else
+ { /* XXX what else can we do if there's no counter? */
+ ane.counter_value_hi = ane.counter_value_lo = 0;
+ }
+
+ ane.alarm_value_hi = XSyncValueHigh32(pTrigger->test_value);
+ ane.alarm_value_lo = XSyncValueLow32(pTrigger->test_value);
+ ane.time = currentTime.milliseconds;
+ ane.state = pAlarm->state;
+
+ /* send to owner */
+ if (pAlarm->events)
+ WriteEventsToClient(pAlarm->client, 1, (xEvent *) &ane);
+
+ /* send to other interested clients */
+ for (pcl = pAlarm->pEventClients; pcl; pcl = pcl->next)
+ WriteEventsToClient(pcl->client, 1, (xEvent *) &ane);
+}
+
+
+/* CounterNotify events only occur in response to an Await. The events
+ * go only to the Awaiting client.
+ */
+static void
+SyncSendCounterNotifyEvents(ClientPtr client, SyncAwait **ppAwait,
+ int num_events)
+{
+ xSyncCounterNotifyEvent *pEvents, *pev;
+ int i;
+
+ if (client->clientGone)
+ return;
+ pev = pEvents = malloc(num_events * sizeof(xSyncCounterNotifyEvent));
+ if (!pEvents)
+ return;
+ UpdateCurrentTime();
+ for (i = 0; i < num_events; i++, ppAwait++, pev++)
+ {
+ SyncTrigger *pTrigger = &(*ppAwait)->trigger;
+ pev->type = SyncEventBase + XSyncCounterNotify;
+ pev->kind = XSyncCounterNotify;
+ pev->counter = pTrigger->pSync->id;
+ pev->wait_value_lo = XSyncValueLow32(pTrigger->test_value);
+ pev->wait_value_hi = XSyncValueHigh32(pTrigger->test_value);
+ if (SYNC_COUNTER == pTrigger->pSync->type)
+ {
+ SyncCounter *pCounter = (SyncCounter *)pTrigger->pSync;
+
+ pev->counter_value_lo = XSyncValueLow32(pCounter->value);
+ pev->counter_value_hi = XSyncValueHigh32(pCounter->value);
+ }
+ else
+ {
+ pev->counter_value_lo = 0;
+ pev->counter_value_hi = 0;
+ }
+
+ pev->time = currentTime.milliseconds;
+ pev->count = num_events - i - 1; /* events remaining */
+ pev->destroyed = pTrigger->pSync->beingDestroyed;
+ }
+ /* swapping will be taken care of by this */
+ WriteEventsToClient(client, num_events, (xEvent *)pEvents);
+ free(pEvents);
+}
+
+
+/* This function is called when an alarm's counter is destroyed.
+ * It is plugged into pTrigger->CounterDestroyed (for alarm triggers).
+ */
+static void
+SyncAlarmCounterDestroyed(SyncTrigger *pTrigger)
+{
+ SyncAlarm *pAlarm = (SyncAlarm *)pTrigger;
+
+ pAlarm->state = XSyncAlarmInactive;
+ SyncSendAlarmNotifyEvents(pAlarm);
+ pTrigger->pSync = NULL;
+}
+
+
+/* This function is called when an alarm "goes off."
+ * It is plugged into pTrigger->TriggerFired (for alarm triggers).
+ */
+static void
+SyncAlarmTriggerFired(SyncTrigger *pTrigger)
+{
+ SyncAlarm *pAlarm = (SyncAlarm *)pTrigger;
+ SyncCounter *pCounter;
+ CARD64 new_test_value;
+
+ assert(!pTrigger->pSync || (SYNC_COUNTER == pTrigger->pSync->type));
+ pCounter = (SyncCounter *)pTrigger->pSync;
+
+ /* no need to check alarm unless it's active */
+ if (pAlarm->state != XSyncAlarmActive)
+ return;
+
+ /* " if the counter value is None, or if the delta is 0 and
+ * the test-type is PositiveComparison or NegativeComparison,
+ * no change is made to value (test-value) and the alarm
+ * state is changed to Inactive before the event is generated."
+ */
+ if (pCounter == NULL
+ || (XSyncValueIsZero(pAlarm->delta)
+ && (pAlarm->trigger.test_type == XSyncPositiveComparison
+ || pAlarm->trigger.test_type == XSyncNegativeComparison)))
+ pAlarm->state = XSyncAlarmInactive;
+
+ new_test_value = pAlarm->trigger.test_value;
+
+ if (pAlarm->state == XSyncAlarmActive)
+ {
+ Bool overflow;
+ CARD64 oldvalue;
+ SyncTrigger *paTrigger = &pAlarm->trigger;
+ SyncCounter *paCounter;
+
+ assert(!paTrigger->pSync || (SYNC_COUNTER == paTrigger->pSync->type));
+ paCounter = (SyncCounter *)pTrigger->pSync;
+
+ /* "The alarm is updated by repeatedly adding delta to the
+ * value of the trigger and re-initializing it until it
+ * becomes FALSE."
+ */
+ oldvalue = paTrigger->test_value;
+
+ /* XXX really should do something smarter here */
+
+ do
+ {
+ XSyncValueAdd(&paTrigger->test_value, paTrigger->test_value,
+ pAlarm->delta, &overflow);
+ } while (!overflow &&
+ (*paTrigger->CheckTrigger)(paTrigger,
+ paCounter->value));
+
+ new_test_value = paTrigger->test_value;
+ paTrigger->test_value = oldvalue;
+
+ /* "If this update would cause value to fall outside the range
+ * for an INT64...no change is made to value (test-value) and
+ * the alarm state is changed to Inactive before the event is
+ * generated."
+ */
+ if (overflow)
+ {
+ new_test_value = oldvalue;
+ pAlarm->state = XSyncAlarmInactive;
+ }
+ }
+ /* The AlarmNotify event has to have the "new state of the alarm"
+ * which we can't be sure of until this point. However, it has
+ * to have the "old" trigger test value. That's the reason for
+ * all the newvalue/oldvalue shuffling above. After we send the
+ * events, give the trigger its new test value.
+ */
+ SyncSendAlarmNotifyEvents(pAlarm);
+ pTrigger->test_value = new_test_value;
+}
+
+
+/* This function is called when an Await unblocks, either as a result
+ * of the trigger firing OR the counter being destroyed.
+ * It goes into pTrigger->TriggerFired AND pTrigger->CounterDestroyed
+ * (for Await triggers).
+ */
+static void
+SyncAwaitTriggerFired(SyncTrigger *pTrigger)
+{
+ SyncAwait *pAwait = (SyncAwait *)pTrigger;
+ int numwaits;
+ SyncAwaitUnion *pAwaitUnion;
+ SyncAwait **ppAwait;
+ int num_events = 0;
+
+ pAwaitUnion = (SyncAwaitUnion *)pAwait->pHeader;
+ numwaits = pAwaitUnion->header.num_waitconditions;
+ ppAwait = malloc(numwaits * sizeof(SyncAwait *));
+ if (!ppAwait)
+ goto bail;
+
+ pAwait = &(pAwaitUnion+1)->await;
+
+ /* "When a client is unblocked, all the CounterNotify events for
+ * the Await request are generated contiguously. If count is 0
+ * there are no more events to follow for this request. If
+ * count is n, there are at least n more events to follow."
+ *
+ * Thus, it is best to find all the counters for which events
+ * need to be sent first, so that an accurate count field can
+ * be stored in the events.
+ */
+ for ( ; numwaits; numwaits--, pAwait++)
+ {
+ CARD64 diff;
+ Bool overflow, diffgreater, diffequal;
+
+ /* "A CounterNotify event with the destroyed flag set to TRUE is
+ * always generated if the counter for one of the triggers is
+ * destroyed."
+ */
+ if (pAwait->trigger.pSync->beingDestroyed)
+ {
+ ppAwait[num_events++] = pAwait;
+ continue;
+ }
+
+ if (SYNC_COUNTER == pAwait->trigger.pSync->type)
+ {
+ SyncCounter *pCounter = (SyncCounter *) pAwait->trigger.pSync;
+
+ /* "The difference between the counter and the test value is
+ * calculated by subtracting the test value from the value of
+ * the counter."
+ */
+ XSyncValueSubtract(&diff, pCounter->value,
+ pAwait->trigger.test_value, &overflow);
+
+ /* "If the difference lies outside the range for an INT64, an
+ * event is not generated."
+ */
+ if (overflow)
+ continue;
+ diffgreater = XSyncValueGreaterThan(diff, pAwait->event_threshold);
+ diffequal = XSyncValueEqual(diff, pAwait->event_threshold);
+
+ /* "If the test-type is PositiveTransition or
+ * PositiveComparison, a CounterNotify event is generated if
+ * the difference is at least event-threshold. If the test-type
+ * is NegativeTransition or NegativeComparison, a CounterNotify
+ * event is generated if the difference is at most
+ * event-threshold."
+ */
+
+ if ( ((pAwait->trigger.test_type == XSyncPositiveComparison ||
+ pAwait->trigger.test_type == XSyncPositiveTransition)
+ && (diffgreater || diffequal))
+ ||
+ ((pAwait->trigger.test_type == XSyncNegativeComparison ||
+ pAwait->trigger.test_type == XSyncNegativeTransition)
+ && (!diffgreater) /* less or equal */
+ )
+ )
+ {
+ ppAwait[num_events++] = pAwait;
+ }
+ }
+ }
+ if (num_events)
+ SyncSendCounterNotifyEvents(pAwaitUnion->header.client, ppAwait,
+ num_events);
+ free(ppAwait);
+
+bail:
+ /* unblock the client */
+ AttendClient(pAwaitUnion->header.client);
+ /* delete the await */
+ FreeResource(pAwaitUnion->header.delete_id, RT_NONE);
+}
+
+
+/* This function should always be used to change a counter's value so that
+ * any triggers depending on the counter will be checked.
+ */
+void
+SyncChangeCounter(SyncCounter *pCounter, CARD64 newval)
+{
+ SyncTriggerList *ptl, *pnext;
+ CARD64 oldval;
+
+ oldval = pCounter->value;
+ pCounter->value = newval;
+
+ /* run through triggers to see if any become true */
+ for (ptl = pCounter->sync.pTriglist; ptl; ptl = pnext)
+ {
+ pnext = ptl->next;
+ if ((*ptl->pTrigger->CheckTrigger)(ptl->pTrigger, oldval))
+ (*ptl->pTrigger->TriggerFired)(ptl->pTrigger);
+ }
+
+ if (IsSystemCounter(pCounter))
+ {
+ SyncComputeBracketValues(pCounter);
+ }
+}
+
+
+/* loosely based on dix/events.c/EventSelectForWindow */
+static Bool
+SyncEventSelectForAlarm(SyncAlarm *pAlarm, ClientPtr client, Bool wantevents)
+{
+ SyncAlarmClientList *pClients;
+
+ if (client == pAlarm->client) /* alarm owner */
+ {
+ pAlarm->events = wantevents;
+ return Success;
+ }
+
+ /* see if the client is already on the list (has events selected) */
+
+ for (pClients = pAlarm->pEventClients; pClients;
+ pClients = pClients->next)
+ {
+ if (pClients->client == client)
+ {
+ /* client's presence on the list indicates desire for
+ * events. If the client doesn't want events, remove it
+ * from the list. If the client does want events, do
+ * nothing, since it's already got them.
+ */
+ if (!wantevents)
+ {
+ FreeResource(pClients->delete_id, RT_NONE);
+ }
+ return Success;
+ }
+ }
+
+ /* if we get here, this client does not currently have
+ * events selected on the alarm
+ */
+
+ if (!wantevents)
+ /* client doesn't want events, and we just discovered that it
+ * doesn't have them, so there's nothing to do.
+ */
+ return Success;
+
+ /* add new client to pAlarm->pEventClients */
+
+ pClients = malloc(sizeof(SyncAlarmClientList));
+ if (!pClients)
+ return BadAlloc;
+
+ /* register it as a resource so it will be cleaned up
+ * if the client dies
+ */
+
+ pClients->delete_id = FakeClientID(client->index);
+ if (!AddResource(pClients->delete_id, RTAlarmClient, pAlarm))
+ {
+ free(pClients);
+ return BadAlloc;
+ }
+
+ /* link it into list after we know all the allocations succeed */
+
+ pClients->next = pAlarm->pEventClients;
+ pAlarm->pEventClients = pClients;
+ pClients->client = client;
+ return Success;
+}
+
+/*
+ * ** SyncChangeAlarmAttributes ** This is used by CreateAlarm and ChangeAlarm
+ */
+static int
+SyncChangeAlarmAttributes(ClientPtr client, SyncAlarm *pAlarm, Mask mask,
+ CARD32 *values)
+{
+ int status;
+ XSyncCounter counter;
+ Mask origmask = mask;
+
+ counter =
+ pAlarm->trigger.pSync ? pAlarm->trigger.pSync->id : None;
+
+ while (mask)
+ {
+ int index2 = lowbit(mask);
+ mask &= ~index2;
+ switch (index2)
+ {
+ case XSyncCACounter:
+ mask &= ~XSyncCACounter;
+ /* sanity check in SyncInitTrigger */
+ counter = *values++;
+ break;
+
+ case XSyncCAValueType:
+ mask &= ~XSyncCAValueType;
+ /* sanity check in SyncInitTrigger */
+ pAlarm->trigger.value_type = *values++;
+ break;
+
+ case XSyncCAValue:
+ mask &= ~XSyncCAValue;
+ XSyncIntsToValue(&pAlarm->trigger.wait_value, values[1], values[0]);
+ values += 2;
+ break;
+
+ case XSyncCATestType:
+ mask &= ~XSyncCATestType;
+ /* sanity check in SyncInitTrigger */
+ pAlarm->trigger.test_type = *values++;
+ break;
+
+ case XSyncCADelta:
+ mask &= ~XSyncCADelta;
+ XSyncIntsToValue(&pAlarm->delta, values[1], values[0]);
+ values += 2;
+ break;
+
+ case XSyncCAEvents:
+ mask &= ~XSyncCAEvents;
+ if ((*values != xTrue) && (*values != xFalse))
+ {
+ client->errorValue = *values;
+ return BadValue;
+ }
+ status = SyncEventSelectForAlarm(pAlarm, client,
+ (Bool)(*values++));
+ if (status != Success)
+ return status;
+ break;
+
+ default:
+ client->errorValue = mask;
+ return BadValue;
+ }
+ }
+
+ /* "If the test-type is PositiveComparison or PositiveTransition
+ * and delta is less than zero, or if the test-type is
+ * NegativeComparison or NegativeTransition and delta is
+ * greater than zero, a Match error is generated."
+ */
+ if (origmask & (XSyncCADelta|XSyncCATestType))
+ {
+ CARD64 zero;
+ XSyncIntToValue(&zero, 0);
+ if ((((pAlarm->trigger.test_type == XSyncPositiveComparison) ||
+ (pAlarm->trigger.test_type == XSyncPositiveTransition))
+ && XSyncValueLessThan(pAlarm->delta, zero))
+ ||
+ (((pAlarm->trigger.test_type == XSyncNegativeComparison) ||
+ (pAlarm->trigger.test_type == XSyncNegativeTransition))
+ && XSyncValueGreaterThan(pAlarm->delta, zero))
+ )
+ {
+ return BadMatch;
+ }
+ }
+
+ /* postpone this until now, when we're sure nothing else can go wrong */
+ if ((status = SyncInitTrigger(client, &pAlarm->trigger, counter, RTCounter,
+ origmask & XSyncCAAllTrigger)) != Success)
+ return status;
+
+ /* XXX spec does not really say to do this - needs clarification */
+ pAlarm->state = XSyncAlarmActive;
+ return Success;
+}
+
+static SyncObject *
+SyncCreate(ClientPtr client, XID id, unsigned char type)
+{
+ SyncObject *pSync;
+ RESTYPE resType;
+
+ switch (type) {
+ case SYNC_COUNTER:
+ resType = RTCounter;
+ pSync = malloc(sizeof(SyncCounter));
+ break;
+ case SYNC_FENCE:
+ resType = RTFence;
+ pSync = dixAllocateObjectWithPrivates(SyncFence,
+ PRIVATE_SYNC_FENCE);
+ break;
+ default:
+ return NULL;
+ }
+
+ if (!pSync)
+ return NULL;
+
+ if (!AddResource(id, resType, (pointer) pSync))
+ {
+ switch (type) {
+ case SYNC_FENCE:
+ dixFreeObjectWithPrivates((SyncFence *)pSync, PRIVATE_SYNC_FENCE);
+ break;
+ default:
+ free(pSync);
+ }
+
+ return NULL;
+ }
+
+ pSync->client = client;
+ pSync->id = id;
+ pSync->pTriglist = NULL;
+ pSync->beingDestroyed = FALSE;
+ pSync->type = type;
+
+ return pSync;
+}
+
+
+static SyncCounter *
+SyncCreateCounter(ClientPtr client, XSyncCounter id, CARD64 initialvalue)
+{
+ SyncCounter *pCounter;
+
+ if (!(pCounter = (SyncCounter *)SyncCreate(client,
+ id,
+ SYNC_COUNTER)))
+ return NULL;
+
+ pCounter->value = initialvalue;
+ pCounter->pSysCounterInfo = NULL;
+ return pCounter;
+}
+
+static int FreeCounter(void *, XID);
+
+/*
+ * ***** System Counter utilities
+ */
+
+pointer
+SyncCreateSystemCounter(
+ char *name,
+ CARD64 initial,
+ CARD64 resolution,
+ SyncCounterType counterType,
+ void (*QueryValue)(pointer /* pCounter */,
+ CARD64 * /* pValue_return */),
+ void (*BracketValues)(pointer /* pCounter */,
+ CARD64 * /* pbracket_less */,
+ CARD64 * /* pbracket_greater */)
+ )
+{
+ SyncCounter *pCounter;
+
+ SysCounterList = realloc(SysCounterList,
+ (SyncNumSystemCounters+1)*sizeof(SyncCounter *));
+ if (!SysCounterList)
+ return NULL;
+
+ /* this function may be called before SYNC has been initialized, so we
+ * have to make sure RTCounter is created.
+ */
+ if (RTCounter == 0)
+ {
+ RTCounter = CreateNewResourceType(FreeCounter, "SyncCounter");
+ if (RTCounter == 0)
+ {
+ return NULL;
+ }
+ }
+
+ pCounter = SyncCreateCounter(NULL, FakeClientID(0), initial);
+
+ if (pCounter)
+ {
+ SysCounterInfo *psci;
+
+ psci = malloc(sizeof(SysCounterInfo));
+ if (!psci)
+ {
+ FreeResource(pCounter->sync.id, RT_NONE);
+ return pCounter;
+ }
+ pCounter->pSysCounterInfo = psci;
+ psci->name = name;
+ psci->resolution = resolution;
+ psci->counterType = counterType;
+ psci->QueryValue = QueryValue;
+ psci->BracketValues = BracketValues;
+ XSyncMaxValue(&psci->bracket_greater);
+ XSyncMinValue(&psci->bracket_less);
+ SysCounterList[SyncNumSystemCounters++] = pCounter;
+ }
+ return pCounter;
+}
+
+void
+SyncDestroySystemCounter(pointer pSysCounter)
+{
+ SyncCounter *pCounter = (SyncCounter *)pSysCounter;
+ FreeResource(pCounter->sync.id, RT_NONE);
+}
+
+static void
+SyncComputeBracketValues(SyncCounter *pCounter)
+{
+ SyncTriggerList *pCur;
+ SyncTrigger *pTrigger;
+ SysCounterInfo *psci;
+ CARD64 *pnewgtval = NULL;
+ CARD64 *pnewltval = NULL;
+ SyncCounterType ct;
+
+ if (!pCounter)
+ return;
+
+ psci = pCounter->pSysCounterInfo;
+ ct = pCounter->pSysCounterInfo->counterType;
+ if (ct == XSyncCounterNeverChanges)
+ return;
+
+ XSyncMaxValue(&psci->bracket_greater);
+ XSyncMinValue(&psci->bracket_less);
+
+ for (pCur = pCounter->sync.pTriglist; pCur; pCur = pCur->next)
+ {
+ pTrigger = pCur->pTrigger;
+
+ if (pTrigger->test_type == XSyncPositiveComparison &&
+ ct != XSyncCounterNeverIncreases)
+ {
+ if (XSyncValueLessThan(pCounter->value, pTrigger->test_value) &&
+ XSyncValueLessThan(pTrigger->test_value,
+ psci->bracket_greater))
+ {
+ psci->bracket_greater = pTrigger->test_value;
+ pnewgtval = &psci->bracket_greater;
+ }
+ }
+ else if (pTrigger->test_type == XSyncNegativeComparison &&
+ ct != XSyncCounterNeverDecreases)
+ {
+ if (XSyncValueGreaterThan(pCounter->value, pTrigger->test_value) &&
+ XSyncValueGreaterThan(pTrigger->test_value,
+ psci->bracket_less))
+ {
+ psci->bracket_less = pTrigger->test_value;
+ pnewltval = &psci->bracket_less;
+ }
+ }
+ else if (pTrigger->test_type == XSyncNegativeTransition &&
+ ct != XSyncCounterNeverIncreases)
+ {
+ if (XSyncValueGreaterThan(pCounter->value, pTrigger->test_value) &&
+ XSyncValueGreaterThan(pTrigger->test_value, psci->bracket_less))
+ {
+ psci->bracket_less = pTrigger->test_value;
+ pnewltval = &psci->bracket_less;
+ } else if (XSyncValueEqual(pCounter->value, pTrigger->test_value) &&
+ XSyncValueLessThan(pTrigger->test_value,
+ psci->bracket_greater))
+ {
+ /*
+ * The value is exactly equal to our threshold. We want one
+ * more event in the positive direction to ensure we pick up
+ * when the value *exceeds* this threshold.
+ */
+ psci->bracket_greater = pTrigger->test_value;
+ pnewgtval = &psci->bracket_greater;
+ }
+ }
+ else if (pTrigger->test_type == XSyncPositiveTransition &&
+ ct != XSyncCounterNeverDecreases)
+ {
+ if (XSyncValueLessThan(pCounter->value, pTrigger->test_value) &&
+ XSyncValueLessThan(pTrigger->test_value, psci->bracket_greater))
+ {
+ psci->bracket_greater = pTrigger->test_value;
+ pnewgtval = &psci->bracket_greater;
+ } else if (XSyncValueEqual(pCounter->value, pTrigger->test_value) &&
+ XSyncValueGreaterThan(pTrigger->test_value,
+ psci->bracket_less))
+ {
+ /*
+ * The value is exactly equal to our threshold. We want one
+ * more event in the negative direction to ensure we pick up
+ * when the value is less than this threshold.
+ */
+ psci->bracket_less = pTrigger->test_value;
+ pnewltval = &psci->bracket_less;
+ }
+ }
+ } /* end for each trigger */
+
+ if (pnewgtval || pnewltval)
+ {
+ (*psci->BracketValues)((pointer)pCounter, pnewltval, pnewgtval);
+ }
+}
+
+/*
+ * ***** Resource delete functions
+ */
+
+/* ARGSUSED */
+static int
+FreeAlarm(void *addr, XID id)
+{
+ SyncAlarm *pAlarm = (SyncAlarm *) addr;
+
+ pAlarm->state = XSyncAlarmDestroyed;
+
+ SyncSendAlarmNotifyEvents(pAlarm);
+
+ /* delete event selections */
+
+ while (pAlarm->pEventClients)
+ FreeResource(pAlarm->pEventClients->delete_id, RT_NONE);
+
+ SyncDeleteTriggerFromSyncObject(&pAlarm->trigger);
+
+ free(pAlarm);
+ return Success;
+}
+
+
+/*
+ * ** Cleanup after the destruction of a Counter
+ */
+/* ARGSUSED */
+static int
+FreeCounter(void *env, XID id)
+{
+ SyncCounter *pCounter = (SyncCounter *) env;
+ SyncTriggerList *ptl, *pnext;
+
+ pCounter->sync.beingDestroyed = TRUE;
+ /* tell all the counter's triggers that the counter has been destroyed */
+ for (ptl = pCounter->sync.pTriglist; ptl; ptl = pnext)
+ {
+ (*ptl->pTrigger->CounterDestroyed)(ptl->pTrigger);
+ pnext = ptl->next;
+ free(ptl); /* destroy the trigger list as we go */
+ }
+ if (IsSystemCounter(pCounter))
+ {
+ int i, found = 0;
+
+ free(pCounter->pSysCounterInfo);
+
+ /* find the counter in the list of system counters and remove it */
+
+ if (SysCounterList)
+ {
+ for (i = 0; i < SyncNumSystemCounters; i++)
+ {
+ if (SysCounterList[i] == pCounter)
+ {
+ found = i;
+ break;
+ }
+ }
+ if (found < (SyncNumSystemCounters-1))
+ {
+ for (i = found; i < SyncNumSystemCounters-1; i++)
+ {
+ SysCounterList[i] = SysCounterList[i+1];
+ }
+ }
+ }
+ SyncNumSystemCounters--;
+ }
+ free(pCounter);
+ return Success;
+}
+
+/*
+ * ** Cleanup after Await
+ */
+/* ARGSUSED */
+static int
+FreeAwait(void *addr, XID id)
+{
+ SyncAwaitUnion *pAwaitUnion = (SyncAwaitUnion *) addr;
+ SyncAwait *pAwait;
+ int numwaits;
+
+ pAwait = &(pAwaitUnion+1)->await; /* first await on list */
+
+ /* remove triggers from counters */
+
+ for (numwaits = pAwaitUnion->header.num_waitconditions; numwaits;
+ numwaits--, pAwait++)
+ {
+ /* If the counter is being destroyed, FreeCounter will delete
+ * the trigger list itself, so don't do it here.
+ */
+ SyncObject *pSync = pAwait->trigger.pSync;
+ if (pSync && !pSync->beingDestroyed)
+ SyncDeleteTriggerFromSyncObject(&pAwait->trigger);
+ }
+ free(pAwaitUnion);
+ return Success;
+}
+
+#ifdef _MSC_VER
+#pragma warning(disable:4715) /* Not all control paths return a value */
+#endif
+
+/* loosely based on dix/events.c/OtherClientGone */
+static int
+FreeAlarmClient(void *value, XID id)
+{
+ SyncAlarm *pAlarm = (SyncAlarm *)value;
+ SyncAlarmClientList *pCur, *pPrev;
+
+ for (pPrev = NULL, pCur = pAlarm->pEventClients;
+ pCur;
+ pPrev = pCur, pCur = pCur->next)
+ {
+ if (pCur->delete_id == id)
+ {
+ if (pPrev)
+ pPrev->next = pCur->next;
+ else
+ pAlarm->pEventClients = pCur->next;
+ free(pCur);
+ return Success;
+ }
+ }
+ FatalError("alarm client not on event list");
+ /*NOTREACHED*/
+}
+
+
+/*
+ * ***** Proc functions
+ */
+
+
+/*
+ * ** Initialize the extension
+ */
+static int
+ProcSyncInitialize(ClientPtr client)
+{
+ xSyncInitializeReply rep;
+ int n;
+
+ REQUEST_SIZE_MATCH(xSyncInitializeReq);
+
+ memset(&rep, 0, sizeof(xSyncInitializeReply));
+ rep.type = X_Reply;
+ rep.sequenceNumber = client->sequence;
+ rep.majorVersion = SERVER_SYNC_MAJOR_VERSION;
+ rep.minorVersion = SERVER_SYNC_MINOR_VERSION;
+ rep.length = 0;
+
+ if (client->swapped)
+ {
+ swaps(&rep.sequenceNumber, n);
+ }
+ WriteToClient(client, sizeof(rep), (char *) &rep);
+ return Success;
+}
+
+/*
+ * ** Get list of system counters available through the extension
+ */
+static int
+ProcSyncListSystemCounters(ClientPtr client)
+{
+ xSyncListSystemCountersReply rep;
+ int i, len;
+ xSyncSystemCounter *list = NULL, *walklist = NULL;
+
+ REQUEST_SIZE_MATCH(xSyncListSystemCountersReq);
+
+ rep.type = X_Reply;
+ rep.sequenceNumber = client->sequence;
+ rep.nCounters = SyncNumSystemCounters;
+
+ for (i = len = 0; i < SyncNumSystemCounters; i++)
+ {
+ char *name = SysCounterList[i]->pSysCounterInfo->name;
+ /* pad to 4 byte boundary */
+ len += pad_to_int32(sz_xSyncSystemCounter + strlen(name));
+ }
+
+ if (len)
+ {
+ walklist = list = malloc(len);
+ if (!list)
+ return BadAlloc;
+ }
+
+ rep.length = bytes_to_int32(len);
+
+ if (client->swapped)
+ {
+ char n;
+ swaps(&rep.sequenceNumber, n);
+ swapl(&rep.length, n);
+ swapl(&rep.nCounters, n);
+ }
+
+ for (i = 0; i < SyncNumSystemCounters; i++)
+ {
+ int namelen;
+ char *pname_in_reply;
+ SysCounterInfo *psci = SysCounterList[i]->pSysCounterInfo;
+
+ walklist->counter = SysCounterList[i]->sync.id;
+ walklist->resolution_hi = XSyncValueHigh32(psci->resolution);
+ walklist->resolution_lo = XSyncValueLow32(psci->resolution);
+ namelen = strlen(psci->name);
+ walklist->name_length = namelen;
+
+ if (client->swapped)
+ {
+ char n;
+ swapl(&walklist->counter, n);
+ swapl(&walklist->resolution_hi, n);
+ swapl(&walklist->resolution_lo, n);
+ swaps(&walklist->name_length, n);
+ }
+
+ pname_in_reply = ((char *)walklist) + sz_xSyncSystemCounter;
+ strncpy(pname_in_reply, psci->name, namelen);
+ walklist = (xSyncSystemCounter *) (((char *)walklist) +
+ pad_to_int32(sz_xSyncSystemCounter + namelen));
+ }
+
+ WriteToClient(client, sizeof(rep), (char *) &rep);
+ if (len)
+ {
+ WriteToClient(client, len, (char *) list);
+ free(list);
+ }
+
+ return Success;
+}
+
+/*
+ * ** Set client Priority
+ */
+static int
+ProcSyncSetPriority(ClientPtr client)
+{
+ REQUEST(xSyncSetPriorityReq);
+ ClientPtr priorityclient;
+ int rc;
+
+ REQUEST_SIZE_MATCH(xSyncSetPriorityReq);
+
+ if (stuff->id == None)
+ priorityclient = client;
+ else {
+ rc = dixLookupClient(&priorityclient, stuff->id, client,
+ DixSetAttrAccess);
+ if (rc != Success)
+ return rc;
+ }
+
+ if (priorityclient->priority != stuff->priority)
+ {
+ priorityclient->priority = stuff->priority;
+
+ /* The following will force the server back into WaitForSomething
+ * so that the change in this client's priority is immediately
+ * reflected.
+ */
+ isItTimeToYield = TRUE;
+ dispatchException |= DE_PRIORITYCHANGE;
+ }
+ return Success;
+}
+
+/*
+ * ** Get client Priority
+ */
+static int
+ProcSyncGetPriority(ClientPtr client)
+{
+ REQUEST(xSyncGetPriorityReq);
+ xSyncGetPriorityReply rep;
+ ClientPtr priorityclient;
+ int rc;
+
+ REQUEST_SIZE_MATCH(xSyncGetPriorityReq);
+
+ if (stuff->id == None)
+ priorityclient = client;
+ else {
+ rc = dixLookupClient(&priorityclient, stuff->id, client,
+ DixGetAttrAccess);
+ if (rc != Success)
+ return rc;
+ }
+
+ rep.type = X_Reply;
+ rep.length = 0;
+ rep.sequenceNumber = client->sequence;
+ rep.priority = priorityclient->priority;
+
+ if (client->swapped)
+ {
+ char n;
+ swaps(&rep.sequenceNumber, n);
+ swapl(&rep.priority, n);
+ }
+
+ WriteToClient(client, sizeof(xSyncGetPriorityReply), (char *) &rep);
+
+ return Success;
+}
+
+/*
+ * ** Create a new counter
+ */
+static int
+ProcSyncCreateCounter(ClientPtr client)
+{
+ REQUEST(xSyncCreateCounterReq);
+ CARD64 initial;
+
+ REQUEST_SIZE_MATCH(xSyncCreateCounterReq);
+
+ LEGAL_NEW_RESOURCE(stuff->cid, client);
+
+ XSyncIntsToValue(&initial, stuff->initial_value_lo, stuff->initial_value_hi);
+ if (!SyncCreateCounter(client, stuff->cid, initial))
+ return BadAlloc;
+
+ return Success;
+}
+
+/*
+ * ** Set Counter value
+ */
+static int
+ProcSyncSetCounter(ClientPtr client)
+{
+ REQUEST(xSyncSetCounterReq);
+ SyncCounter *pCounter;
+ CARD64 newvalue;
+ int rc;
+
+ REQUEST_SIZE_MATCH(xSyncSetCounterReq);
+
+ rc = dixLookupResourceByType((pointer *)&pCounter, stuff->cid, RTCounter,
+ client, DixWriteAccess);
+ if (rc != Success)
+ return rc;
+
+ if (IsSystemCounter(pCounter))
+ {
+ client->errorValue = stuff->cid;
+ return BadAccess;
+ }
+
+ XSyncIntsToValue(&newvalue, stuff->value_lo, stuff->value_hi);
+ SyncChangeCounter(pCounter, newvalue);
+ return Success;
+}
+
+/*
+ * ** Change Counter value
+ */
+static int
+ProcSyncChangeCounter(ClientPtr client)
+{
+ REQUEST(xSyncChangeCounterReq);
+ SyncCounter *pCounter;
+ CARD64 newvalue;
+ Bool overflow;
+ int rc;
+
+ REQUEST_SIZE_MATCH(xSyncChangeCounterReq);
+
+ rc = dixLookupResourceByType((pointer *)&pCounter, stuff->cid, RTCounter,
+ client, DixWriteAccess);
+ if (rc != Success)
+ return rc;
+
+ if (IsSystemCounter(pCounter))
+ {
+ client->errorValue = stuff->cid;
+ return BadAccess;
+ }
+
+ XSyncIntsToValue(&newvalue, stuff->value_lo, stuff->value_hi);
+ XSyncValueAdd(&newvalue, pCounter->value, newvalue, &overflow);
+ if (overflow)
+ {
+ /* XXX 64 bit value can't fit in 32 bits; do the best we can */
+ client->errorValue = stuff->value_hi;
+ return BadValue;
+ }
+ SyncChangeCounter(pCounter, newvalue);
+ return Success;
+}
+
+/*
+ * ** Destroy a counter
+ */
+static int
+ProcSyncDestroyCounter(ClientPtr client)
+{
+ REQUEST(xSyncDestroyCounterReq);
+ SyncCounter *pCounter;
+ int rc;
+
+ REQUEST_SIZE_MATCH(xSyncDestroyCounterReq);
+
+ rc = dixLookupResourceByType((pointer *)&pCounter, stuff->counter, RTCounter,
+ client, DixDestroyAccess);
+ if (rc != Success)
+ return rc;
+
+ if (IsSystemCounter(pCounter))
+ {
+ client->errorValue = stuff->counter;
+ return BadAccess;
+ }
+ FreeResource(pCounter->sync.id, RT_NONE);
+ return Success;
+}
+
+static SyncAwaitUnion*
+SyncAwaitPrologue(ClientPtr client, int items)
+{
+ SyncAwaitUnion *pAwaitUnion;
+
+ /* all the memory for the entire await list is allocated
+ * here in one chunk
+ */
+ pAwaitUnion = malloc((items+1) * sizeof(SyncAwaitUnion));
+ if (!pAwaitUnion)
+ return NULL;
+
+ /* first item is the header, remainder are real wait conditions */
+
+ pAwaitUnion->header.delete_id = FakeClientID(client->index);
+ if (!AddResource(pAwaitUnion->header.delete_id, RTAwait, pAwaitUnion))
+ {
+ free(pAwaitUnion);
+ return NULL;
+ }
+
+ pAwaitUnion->header.client = client;
+ pAwaitUnion->header.num_waitconditions = 0;
+
+ return pAwaitUnion;
+}
+
+static void
+SyncAwaitEpilogue(ClientPtr client, int items, SyncAwaitUnion *pAwaitUnion)
+{
+ SyncAwait *pAwait;
+ int i;
+
+ IgnoreClient(client);
+
+ /* see if any of the triggers are already true */
+
+ pAwait = &(pAwaitUnion+1)->await; /* skip over header */
+ for (i = 0; i < items; i++, pAwait++)
+ {
+ CARD64 value;
+
+ /* don't have to worry about NULL counters because the request
+ * errors before we get here out if they occur
+ */
+ switch (pAwait->trigger.pSync->type) {
+ case SYNC_COUNTER:
+ value = ((SyncCounter *)pAwait->trigger.pSync)->value;
+ break;
+ default:
+ XSyncIntToValue(&value, 0);
+ }
+
+ if ((*pAwait->trigger.CheckTrigger)(&pAwait->trigger, value))
+ {
+ (*pAwait->trigger.TriggerFired)(&pAwait->trigger);
+ break; /* once is enough */
+ }
+ }
+}
+
+/*
+ * ** Await
+ */
+static int
+ProcSyncAwait(ClientPtr client)
+{
+ REQUEST(xSyncAwaitReq);
+ int len, items;
+ int i;
+ xSyncWaitCondition *pProtocolWaitConds;
+ SyncAwaitUnion *pAwaitUnion;
+ SyncAwait *pAwait;
+ int status;
+
+ REQUEST_AT_LEAST_SIZE(xSyncAwaitReq);
+
+ len = client->req_len << 2;
+ len -= sz_xSyncAwaitReq;
+ items = len / sz_xSyncWaitCondition;
+
+ if (items * sz_xSyncWaitCondition != len)
+ {
+ return BadLength;
+ }
+ if (items == 0)
+ {
+ client->errorValue = items; /* XXX protocol change */
+ return BadValue;
+ }
+
+ if (!(pAwaitUnion = SyncAwaitPrologue(client, items)))
+ return BadAlloc;
+
+ /* don't need to do any more memory allocation for this request! */
+
+ pProtocolWaitConds = (xSyncWaitCondition *) & stuff[1];
+
+ pAwait = &(pAwaitUnion+1)->await; /* skip over header */
+ for (i = 0; i < items; i++, pProtocolWaitConds++, pAwait++)
+ {
+ if (pProtocolWaitConds->counter == None) /* XXX protocol change */
+ {
+ /* this should take care of removing any triggers created by
+ * this request that have already been registered on sync objects
+ */
+ FreeResource(pAwaitUnion->header.delete_id, RT_NONE);
+ client->errorValue = pProtocolWaitConds->counter;
+ return SyncErrorBase + XSyncBadCounter;
+ }
+
+ /* sanity checks are in SyncInitTrigger */
+ pAwait->trigger.pSync = NULL;
+ pAwait->trigger.value_type = pProtocolWaitConds->value_type;
+ XSyncIntsToValue(&pAwait->trigger.wait_value,
+ pProtocolWaitConds->wait_value_lo,
+ pProtocolWaitConds->wait_value_hi);
+ pAwait->trigger.test_type = pProtocolWaitConds->test_type;
+
+ status = SyncInitTrigger(client, &pAwait->trigger,
+ pProtocolWaitConds->counter, RTCounter,
+ XSyncCAAllTrigger);
+ if (status != Success)
+ {
+ /* this should take care of removing any triggers created by
+ * this request that have already been registered on sync objects
+ */
+ FreeResource(pAwaitUnion->header.delete_id, RT_NONE);
+ return status;
+ }
+ /* this is not a mistake -- same function works for both cases */
+ pAwait->trigger.TriggerFired = SyncAwaitTriggerFired;
+ pAwait->trigger.CounterDestroyed = SyncAwaitTriggerFired;
+ XSyncIntsToValue(&pAwait->event_threshold,
+ pProtocolWaitConds->event_threshold_lo,
+ pProtocolWaitConds->event_threshold_hi);
+ pAwait->pHeader = &pAwaitUnion->header;
+ pAwaitUnion->header.num_waitconditions++;
+ }
+
+ SyncAwaitEpilogue(client, items, pAwaitUnion);
+
+ return Success;
+}
+
+
+/*
+ * ** Query a counter
+ */
+static int
+ProcSyncQueryCounter(ClientPtr client)
+{
+ REQUEST(xSyncQueryCounterReq);
+ xSyncQueryCounterReply rep;
+ SyncCounter *pCounter;
+ int rc;
+
+ REQUEST_SIZE_MATCH(xSyncQueryCounterReq);
+
+ rc = dixLookupResourceByType((pointer *)&pCounter, stuff->counter,
+ RTCounter, client, DixReadAccess);
+ if (rc != Success)
+ return rc;
+
+ rep.type = X_Reply;
+ rep.length = 0;
+ rep.sequenceNumber = client->sequence;
+
+ /* if system counter, ask it what the current value is */
+
+ if (IsSystemCounter(pCounter))
+ {
+ (*pCounter->pSysCounterInfo->QueryValue) ((pointer) pCounter,
+ &pCounter->value);
+ }
+
+ rep.value_hi = XSyncValueHigh32(pCounter->value);
+ rep.value_lo = XSyncValueLow32(pCounter->value);
+ if (client->swapped)
+ {
+ char n;
+ swaps(&rep.sequenceNumber, n);
+ swapl(&rep.length, n);
+ swapl(&rep.value_hi, n);
+ swapl(&rep.value_lo, n);
+ }
+ WriteToClient(client, sizeof(xSyncQueryCounterReply), (char *) &rep);
+ return Success;
+}
+
+
+/*
+ * ** Create Alarm
+ */
+static int
+ProcSyncCreateAlarm(ClientPtr client)
+{
+ REQUEST(xSyncCreateAlarmReq);
+ SyncAlarm *pAlarm;
+ int status;
+ unsigned long len, vmask;
+ SyncTrigger *pTrigger;
+
+ REQUEST_AT_LEAST_SIZE(xSyncCreateAlarmReq);
+
+ LEGAL_NEW_RESOURCE(stuff->id, client);
+
+ vmask = stuff->valueMask;
+ len = client->req_len - bytes_to_int32(sizeof(xSyncCreateAlarmReq));
+ /* the "extra" call to Ones accounts for the presence of 64 bit values */
+ if (len != (Ones(vmask) + Ones(vmask & (XSyncCAValue|XSyncCADelta))))
+ return BadLength;
+
+ if (!(pAlarm = malloc(sizeof(SyncAlarm))))
+ {
+ return BadAlloc;
+ }
+
+ /* set up defaults */
+
+ pTrigger = &pAlarm->trigger;
+ pTrigger->pSync = NULL;
+ pTrigger->value_type = XSyncAbsolute;
+ XSyncIntToValue(&pTrigger->wait_value, 0L);
+ pTrigger->test_type = XSyncPositiveComparison;
+ pTrigger->TriggerFired = SyncAlarmTriggerFired;
+ pTrigger->CounterDestroyed = SyncAlarmCounterDestroyed;
+ status = SyncInitTrigger(client, pTrigger, None, RTCounter,
+ XSyncCAAllTrigger);
+ if (status != Success)
+ {
+ free(pAlarm);
+ return status;
+ }
+
+ pAlarm->client = client;
+ pAlarm->alarm_id = stuff->id;
+ XSyncIntToValue(&pAlarm->delta, 1L);
+ pAlarm->events = TRUE;
+ pAlarm->state = XSyncAlarmInactive;
+ pAlarm->pEventClients = NULL;
+ status = SyncChangeAlarmAttributes(client, pAlarm, vmask,
+ (CARD32 *)&stuff[1]);
+ if (status != Success)
+ {
+ free(pAlarm);
+ return status;
+ }
+
+ if (!AddResource(stuff->id, RTAlarm, pAlarm))
+ {
+ free(pAlarm);
+ return BadAlloc;
+ }
+
+ /* see if alarm already triggered. NULL counter will not trigger
+ * in CreateAlarm and sets alarm state to Inactive.
+ */
+
+ if (!pTrigger->pSync)
+ {
+ pAlarm->state = XSyncAlarmInactive; /* XXX protocol change */
+ }
+ else
+ {
+ SyncCounter *pCounter;
+
+ assert(SYNC_COUNTER == pTrigger->pSync->type);
+ pCounter = (SyncCounter *)pTrigger->pSync;
+
+ if ((*pTrigger->CheckTrigger)(pTrigger, pCounter->value))
+ (*pTrigger->TriggerFired)(pTrigger);
+ }
+
+ return Success;
+}
+
+/*
+ * ** Change Alarm
+ */
+static int
+ProcSyncChangeAlarm(ClientPtr client)
+{
+ REQUEST(xSyncChangeAlarmReq);
+ SyncAlarm *pAlarm;
+ SyncCounter *pCounter = NULL;
+ long vmask;
+ int len, status;
+
+ REQUEST_AT_LEAST_SIZE(xSyncChangeAlarmReq);
+
+ status = dixLookupResourceByType((pointer *)&pAlarm, stuff->alarm, RTAlarm,
+ client, DixWriteAccess);
+ if (status != Success)
+ return status;
+
+ vmask = stuff->valueMask;
+ len = client->req_len - bytes_to_int32(sizeof(xSyncChangeAlarmReq));
+ /* the "extra" call to Ones accounts for the presence of 64 bit values */
+ if (len != (Ones(vmask) + Ones(vmask & (XSyncCAValue|XSyncCADelta))))
+ return BadLength;
+
+ if ((status = SyncChangeAlarmAttributes(client, pAlarm, vmask,
+ (CARD32 *)&stuff[1])) != Success)
+ return status;
+
+ if (pAlarm->trigger.pSync)
+ {
+ assert(SYNC_COUNTER == pAlarm->trigger.pSync->type);
+ pCounter = (SyncCounter *)pAlarm->trigger.pSync;
+ }
+
+ /* see if alarm already triggered. NULL counter WILL trigger
+ * in ChangeAlarm.
+ */
+
+ if (!pCounter ||
+ (*pAlarm->trigger.CheckTrigger)(&pAlarm->trigger, pCounter->value))
+ {
+ (*pAlarm->trigger.TriggerFired)(&pAlarm->trigger);
+ }
+ return Success;
+}
+
+static int
+ProcSyncQueryAlarm(ClientPtr client)
+{
+ REQUEST(xSyncQueryAlarmReq);
+ SyncAlarm *pAlarm;
+ xSyncQueryAlarmReply rep;
+ SyncTrigger *pTrigger;
+ int rc;
+
+ REQUEST_SIZE_MATCH(xSyncQueryAlarmReq);
+
+ rc = dixLookupResourceByType((pointer *)&pAlarm, stuff->alarm, RTAlarm,
+ client, DixReadAccess);
+ if (rc != Success)
+ return rc;
+
+ rep.type = X_Reply;
+ rep.length = bytes_to_int32(sizeof(xSyncQueryAlarmReply) - sizeof(xGenericReply));
+ rep.sequenceNumber = client->sequence;
+
+ pTrigger = &pAlarm->trigger;
+ rep.counter = (pTrigger->pSync) ? pTrigger->pSync->id : None;
+
+#if 0 /* XXX unclear what to do, depends on whether relative value-types
+ * are "consumed" immediately and are considered absolute from then
+ * on.
+ */
+ rep.value_type = pTrigger->value_type;
+ rep.wait_value_hi = XSyncValueHigh32(pTrigger->wait_value);
+ rep.wait_value_lo = XSyncValueLow32(pTrigger->wait_value);
+#else
+ rep.value_type = XSyncAbsolute;
+ rep.wait_value_hi = XSyncValueHigh32(pTrigger->test_value);
+ rep.wait_value_lo = XSyncValueLow32(pTrigger->test_value);
+#endif
+
+ rep.test_type = pTrigger->test_type;
+ rep.delta_hi = XSyncValueHigh32(pAlarm->delta);
+ rep.delta_lo = XSyncValueLow32(pAlarm->delta);
+ rep.events = pAlarm->events;
+ rep.state = pAlarm->state;
+
+ if (client->swapped)
+ {
+ char n;
+ swaps(&rep.sequenceNumber, n);
+ swapl(&rep.length, n);
+ swapl(&rep.counter, n);
+ swapl(&rep.wait_value_hi, n);
+ swapl(&rep.wait_value_lo, n);
+ swapl(&rep.test_type, n);
+ swapl(&rep.delta_hi, n);
+ swapl(&rep.delta_lo, n);
+ }
+
+ WriteToClient(client, sizeof(xSyncQueryAlarmReply), (char *) &rep);
+ return Success;
+}
+
+static int
+ProcSyncDestroyAlarm(ClientPtr client)
+{
+ SyncAlarm *pAlarm;
+ int rc;
+ REQUEST(xSyncDestroyAlarmReq);
+
+ REQUEST_SIZE_MATCH(xSyncDestroyAlarmReq);
+
+ rc = dixLookupResourceByType((pointer *)&pAlarm, stuff->alarm, RTAlarm,
+ client, DixDestroyAccess);
+ if (rc != Success)
+ return rc;
+
+ FreeResource(stuff->alarm, RT_NONE);
+ return Success;
+}
+
+static int
+ProcSyncCreateFence(ClientPtr client)
+{
+ REQUEST(xSyncCreateFenceReq);
+ DrawablePtr pDraw;
+ SyncFence *pFence;
+ int rc;
+
+ REQUEST_SIZE_MATCH(xSyncCreateFenceReq);
+
+ rc = dixLookupDrawable(&pDraw, stuff->d, client, M_ANY, DixGetAttrAccess);
+ if (rc != Success)
+ return rc;
+
+ LEGAL_NEW_RESOURCE(stuff->fid, client);
+
+ if (!(pFence = (SyncFence *)SyncCreate(client,
+ stuff->fid,
+ SYNC_FENCE)))
+ return BadAlloc;
+
+ miSyncInitFence(pDraw->pScreen, pFence, stuff->initially_triggered);
+
+ return client->noClientException;
+}
+
+static int
+FreeFence(void *obj, XID id)
+{
+ SyncFence *pFence = (SyncFence *) obj;
+
+ miSyncDestroyFence(pFence);
+
+ return Success;
+}
+
+int SyncVerifyFence(SyncFence **ppSyncFence, XID fid,
+ ClientPtr client, Mask mode)
+{
+ int rc = dixLookupResourceByType((pointer *)ppSyncFence, fid, RTFence,
+ client, mode);
+
+ if (rc != Success)
+ client->errorValue = fid;
+
+ return rc;
+}
+
+static int
+ProcSyncTriggerFence(ClientPtr client)
+{
+ REQUEST(xSyncTriggerFenceReq);
+ SyncFence *pFence;
+ int rc;
+
+ REQUEST_SIZE_MATCH(xSyncTriggerFenceReq);
+
+ rc = dixLookupResourceByType((pointer *)&pFence, stuff->fid, RTFence,
+ client, DixWriteAccess);
+ if (rc != Success)
+ return rc;
+
+ miSyncTriggerFence(pFence);
+
+ return client->noClientException;
+}
+
+static int
+ProcSyncResetFence(ClientPtr client)
+{
+ REQUEST(xSyncResetFenceReq);
+ SyncFence *pFence;
+ int rc;
+
+ REQUEST_SIZE_MATCH(xSyncResetFenceReq);
+
+ rc = dixLookupResourceByType((pointer *)&pFence, stuff->fid, RTFence,
+ client, DixWriteAccess);
+ if (rc != Success)
+ return rc;
+
+ if (pFence->funcs.CheckTriggered(pFence) != TRUE)
+ return BadMatch;
+
+ pFence->funcs.Reset(pFence);
+
+ return client->noClientException;
+}
+
+static int
+ProcSyncDestroyFence(ClientPtr client)
+{
+ REQUEST(xSyncDestroyFenceReq);
+ SyncFence *pFence;
+ int rc;
+
+ REQUEST_SIZE_MATCH(xSyncDestroyFenceReq);
+
+ rc = dixLookupResourceByType((pointer *)&pFence, stuff->fid, RTFence,
+ client, DixDestroyAccess);
+ if (rc != Success)
+ return rc;
+
+ FreeResource(stuff->fid, RT_NONE);
+ return client->noClientException;
+}
+
+static int
+ProcSyncQueryFence(ClientPtr client)
+{
+ REQUEST(xSyncQueryFenceReq);
+ xSyncQueryFenceReply rep;
+ SyncFence *pFence;
+ int rc;
+
+ REQUEST_SIZE_MATCH(xSyncQueryFenceReq);
+
+ rc = dixLookupResourceByType((pointer *)&pFence, stuff->fid,
+ RTFence, client, DixReadAccess);
+ if (rc != Success)
+ return rc;
+
+ rep.type = X_Reply;
+ rep.length = 0;
+ rep.sequenceNumber = client->sequence;
+
+ rep.triggered = pFence->funcs.CheckTriggered(pFence);
+
+ if (client->swapped)
+ {
+ char n;
+ swaps(&rep.sequenceNumber, n);
+ swapl(&rep.length, n);
+ }
+
+ WriteToClient(client, sizeof(xSyncQueryFenceReply), (char *) &rep);
+ return client->noClientException;
+}
+
+static int
+ProcSyncAwaitFence(ClientPtr client)
+{
+ REQUEST(xSyncAwaitFenceReq);
+ SyncAwaitUnion *pAwaitUnion;
+ SyncAwait *pAwait;
+ /* Use CARD32 rather than XSyncFence because XIDs are hard-coded to
+ * CARD32 in protocol definitions */
+ CARD32 *pProtocolFences;
+ int status;
+ int len;
+ int items;
+ int i;
+
+ REQUEST_AT_LEAST_SIZE(xSyncAwaitFenceReq);
+
+ len = client->req_len << 2;
+ len -= sz_xSyncAwaitFenceReq;
+ items = len / sizeof(CARD32);
+
+ if (items * sizeof(CARD32) != len)
+ {
+ return BadLength;
+ }
+ if (items == 0)
+ {
+ client->errorValue = items; /* XXX protocol change */
+ return BadValue;
+ }
+
+ if (!(pAwaitUnion = SyncAwaitPrologue(client, items)))
+ return BadAlloc;
+
+ /* don't need to do any more memory allocation for this request! */
+
+ pProtocolFences = (CARD32 *) & stuff[1];
+
+ pAwait = &(pAwaitUnion+1)->await; /* skip over header */
+ for (i = 0; i < items; i++, pProtocolFences++, pAwait++)
+ {
+ if (*pProtocolFences == None) /* XXX protocol change */
+ {
+ /* this should take care of removing any triggers created by
+ * this request that have already been registered on sync objects
+ */
+ FreeResource(pAwaitUnion->header.delete_id, RT_NONE);
+ client->errorValue = *pProtocolFences;
+ return SyncErrorBase + XSyncBadCounter;
+ }
+
+ pAwait->trigger.pSync = NULL;
+ /* Provide acceptable values for these unused fields to
+ * satisfy SyncInitTrigger's validation logic
+ */
+ pAwait->trigger.value_type = XSyncAbsolute;
+ XSyncIntToValue(&pAwait->trigger.wait_value, 0);
+ pAwait->trigger.test_type = 0;
+
+ status = SyncInitTrigger(client, &pAwait->trigger,
+ *pProtocolFences, RTFence,
+ XSyncCAAllTrigger);
+ if (status != Success)
+ {
+ /* this should take care of removing any triggers created by
+ * this request that have already been registered on sync objects
+ */
+ FreeResource(pAwaitUnion->header.delete_id, RT_NONE);
+ return status;
+ }
+ /* this is not a mistake -- same function works for both cases */
+ pAwait->trigger.TriggerFired = SyncAwaitTriggerFired;
+ pAwait->trigger.CounterDestroyed = SyncAwaitTriggerFired;
+ /* event_threshold is unused for fence syncs */
+ XSyncIntToValue(&pAwait->event_threshold, 0);
+ pAwait->pHeader = &pAwaitUnion->header;
+ pAwaitUnion->header.num_waitconditions++;
+ }
+
+ SyncAwaitEpilogue(client, items, pAwaitUnion);
+
+ return client->noClientException;
+}
+
+/*
+ * ** Given an extension request, call the appropriate request procedure
+ */
+static int
+ProcSyncDispatch(ClientPtr client)
+{
+ REQUEST(xReq);
+
+ switch (stuff->data)
+ {
+ case X_SyncInitialize:
+ return ProcSyncInitialize(client);
+ case X_SyncListSystemCounters:
+ return ProcSyncListSystemCounters(client);
+ case X_SyncCreateCounter:
+ return ProcSyncCreateCounter(client);
+ case X_SyncSetCounter:
+ return ProcSyncSetCounter(client);
+ case X_SyncChangeCounter:
+ return ProcSyncChangeCounter(client);
+ case X_SyncQueryCounter:
+ return ProcSyncQueryCounter(client);
+ case X_SyncDestroyCounter:
+ return ProcSyncDestroyCounter(client);
+ case X_SyncAwait:
+ return ProcSyncAwait(client);
+ case X_SyncCreateAlarm:
+ return ProcSyncCreateAlarm(client);
+ case X_SyncChangeAlarm:
+ return ProcSyncChangeAlarm(client);
+ case X_SyncQueryAlarm:
+ return ProcSyncQueryAlarm(client);
+ case X_SyncDestroyAlarm:
+ return ProcSyncDestroyAlarm(client);
+ case X_SyncSetPriority:
+ return ProcSyncSetPriority(client);
+ case X_SyncGetPriority:
+ return ProcSyncGetPriority(client);
+ case X_SyncCreateFence:
+ return ProcSyncCreateFence(client);
+ case X_SyncTriggerFence:
+ return ProcSyncTriggerFence(client);
+ case X_SyncResetFence:
+ return ProcSyncResetFence(client);
+ case X_SyncDestroyFence:
+ return ProcSyncDestroyFence(client);
+ case X_SyncQueryFence:
+ return ProcSyncQueryFence(client);
+ case X_SyncAwaitFence:
+ return ProcSyncAwaitFence(client);
+ default:
+ return BadRequest;
+ }
+}
+
+/*
+ * Boring Swapping stuff ...
+ */
+
+static int
+SProcSyncInitialize(ClientPtr client)
+{
+ REQUEST(xSyncInitializeReq);
+ char n;
+
+ swaps(&stuff->length, n);
+ REQUEST_SIZE_MATCH (xSyncInitializeReq);
+
+ return ProcSyncInitialize(client);
+}
+
+static int
+SProcSyncListSystemCounters(ClientPtr client)
+{
+ REQUEST(xSyncListSystemCountersReq);
+ char n;
+
+ swaps(&stuff->length, n);
+ REQUEST_SIZE_MATCH (xSyncListSystemCountersReq);
+
+ return ProcSyncListSystemCounters(client);
+}
+
+static int
+SProcSyncCreateCounter(ClientPtr client)
+{
+ REQUEST(xSyncCreateCounterReq);
+ char n;
+
+ swaps(&stuff->length, n);
+ REQUEST_SIZE_MATCH (xSyncCreateCounterReq);
+ swapl(&stuff->cid, n);
+ swapl(&stuff->initial_value_lo, n);
+ swapl(&stuff->initial_value_hi, n);
+
+ return ProcSyncCreateCounter(client);
+}
+
+static int
+SProcSyncSetCounter(ClientPtr client)
+{
+ REQUEST(xSyncSetCounterReq);
+ char n;
+
+ swaps(&stuff->length, n);
+ REQUEST_SIZE_MATCH (xSyncSetCounterReq);
+ swapl(&stuff->cid, n);
+ swapl(&stuff->value_lo, n);
+ swapl(&stuff->value_hi, n);
+
+ return ProcSyncSetCounter(client);
+}
+
+static int
+SProcSyncChangeCounter(ClientPtr client)
+{
+ REQUEST(xSyncChangeCounterReq);
+ char n;
+
+ swaps(&stuff->length, n);
+ REQUEST_SIZE_MATCH (xSyncChangeCounterReq);
+ swapl(&stuff->cid, n);
+ swapl(&stuff->value_lo, n);
+ swapl(&stuff->value_hi, n);
+
+ return ProcSyncChangeCounter(client);
+}
+
+static int
+SProcSyncQueryCounter(ClientPtr client)
+{
+ REQUEST(xSyncQueryCounterReq);
+ char n;
+
+ swaps(&stuff->length, n);
+ REQUEST_SIZE_MATCH (xSyncQueryCounterReq);
+ swapl(&stuff->counter, n);
+
+ return ProcSyncQueryCounter(client);
+}
+
+static int
+SProcSyncDestroyCounter(ClientPtr client)
+{
+ REQUEST(xSyncDestroyCounterReq);
+ char n;
+
+ swaps(&stuff->length, n);
+ REQUEST_SIZE_MATCH (xSyncDestroyCounterReq);
+ swapl(&stuff->counter, n);
+
+ return ProcSyncDestroyCounter(client);
+}
+
+static int
+SProcSyncAwait(ClientPtr client)
+{
+ REQUEST(xSyncAwaitReq);
+ char n;
+
+ swaps(&stuff->length, n);
+ REQUEST_AT_LEAST_SIZE(xSyncAwaitReq);
+ SwapRestL(stuff);
+
+ return ProcSyncAwait(client);
+}
+
+static int
+SProcSyncCreateAlarm(ClientPtr client)
+{
+ REQUEST(xSyncCreateAlarmReq);
+ char n;
+
+ swaps(&stuff->length, n);
+ REQUEST_AT_LEAST_SIZE(xSyncCreateAlarmReq);
+ swapl(&stuff->id, n);
+ swapl(&stuff->valueMask, n);
+ SwapRestL(stuff);
+
+ return ProcSyncCreateAlarm(client);
+}
+
+static int
+SProcSyncChangeAlarm(ClientPtr client)
+{
+ REQUEST(xSyncChangeAlarmReq);
+ char n;
+
+ swaps(&stuff->length, n);
+ REQUEST_AT_LEAST_SIZE(xSyncChangeAlarmReq);
+ swapl(&stuff->alarm, n);
+ swapl(&stuff->valueMask, n);
+ SwapRestL(stuff);
+ return ProcSyncChangeAlarm(client);
+}
+
+static int
+SProcSyncQueryAlarm(ClientPtr client)
+{
+ REQUEST(xSyncQueryAlarmReq);
+ char n;
+
+ swaps(&stuff->length, n);
+ REQUEST_SIZE_MATCH (xSyncQueryAlarmReq);
+ swapl(&stuff->alarm, n);
+
+ return ProcSyncQueryAlarm(client);
+}
+
+static int
+SProcSyncDestroyAlarm(ClientPtr client)
+{
+ REQUEST(xSyncDestroyAlarmReq);
+ char n;
+
+ swaps(&stuff->length, n);
+ REQUEST_SIZE_MATCH (xSyncDestroyAlarmReq);
+ swapl(&stuff->alarm, n);
+
+ return ProcSyncDestroyAlarm(client);
+}
+
+static int
+SProcSyncSetPriority(ClientPtr client)
+{
+ REQUEST(xSyncSetPriorityReq);
+ char n;
+
+ swaps(&stuff->length, n);
+ REQUEST_SIZE_MATCH (xSyncSetPriorityReq);
+ swapl(&stuff->id, n);
+ swapl(&stuff->priority, n);
+
+ return ProcSyncSetPriority(client);
+}
+
+static int
+SProcSyncGetPriority(ClientPtr client)
+{
+ REQUEST(xSyncGetPriorityReq);
+ char n;
+
+ swaps(&stuff->length, n);
+ REQUEST_SIZE_MATCH (xSyncGetPriorityReq);
+ swapl(&stuff->id, n);
+
+ return ProcSyncGetPriority(client);
+}
+
+static int
+SProcSyncCreateFence(ClientPtr client)
+{
+ REQUEST(xSyncCreateFenceReq);
+ char n;
+
+ swaps(&stuff->length, n);
+ REQUEST_SIZE_MATCH (xSyncCreateFenceReq);
+ swapl(&stuff->fid, n);
+
+ return ProcSyncCreateFence(client);
+}
+
+static int
+SProcSyncTriggerFence(ClientPtr client)
+{
+ REQUEST(xSyncTriggerFenceReq);
+ char n;
+
+ swaps(&stuff->length, n);
+ REQUEST_SIZE_MATCH (xSyncTriggerFenceReq);
+ swapl(&stuff->fid, n);
+
+ return ProcSyncTriggerFence(client);
+}
+
+static int
+SProcSyncResetFence(ClientPtr client)
+{
+ REQUEST(xSyncResetFenceReq);
+ char n;
+
+ swaps(&stuff->length, n);
+ REQUEST_SIZE_MATCH (xSyncResetFenceReq);
+ swapl(&stuff->fid, n);
+
+ return ProcSyncResetFence(client);
+}
+
+static int
+SProcSyncDestroyFence(ClientPtr client)
+{
+ REQUEST(xSyncDestroyFenceReq);
+ char n;
+
+ swaps(&stuff->length, n);
+ REQUEST_SIZE_MATCH (xSyncDestroyFenceReq);
+ swapl(&stuff->fid, n);
+
+ return ProcSyncDestroyFence(client);
+}
+
+static int
+SProcSyncQueryFence(ClientPtr client)
+{
+ REQUEST(xSyncQueryFenceReq);
+ char n;
+
+ swaps(&stuff->length, n);
+ REQUEST_SIZE_MATCH (xSyncQueryFenceReq);
+ swapl(&stuff->fid, n);
+
+ return ProcSyncQueryFence(client);
+}
+
+static int
+SProcSyncAwaitFence(ClientPtr client)
+{
+ REQUEST(xSyncAwaitFenceReq);
+ char n;
+
+ swaps(&stuff->length, n);
+ REQUEST_AT_LEAST_SIZE(xSyncAwaitFenceReq);
+ SwapRestL(stuff);
+
+ return ProcSyncAwaitFence(client);
+}
+
+static int
+SProcSyncDispatch(ClientPtr client)
+{
+ REQUEST(xReq);
+
+ switch (stuff->data)
+ {
+ case X_SyncInitialize:
+ return SProcSyncInitialize(client);
+ case X_SyncListSystemCounters:
+ return SProcSyncListSystemCounters(client);
+ case X_SyncCreateCounter:
+ return SProcSyncCreateCounter(client);
+ case X_SyncSetCounter:
+ return SProcSyncSetCounter(client);
+ case X_SyncChangeCounter:
+ return SProcSyncChangeCounter(client);
+ case X_SyncQueryCounter:
+ return SProcSyncQueryCounter(client);
+ case X_SyncDestroyCounter:
+ return SProcSyncDestroyCounter(client);
+ case X_SyncAwait:
+ return SProcSyncAwait(client);
+ case X_SyncCreateAlarm:
+ return SProcSyncCreateAlarm(client);
+ case X_SyncChangeAlarm:
+ return SProcSyncChangeAlarm(client);
+ case X_SyncQueryAlarm:
+ return SProcSyncQueryAlarm(client);
+ case X_SyncDestroyAlarm:
+ return SProcSyncDestroyAlarm(client);
+ case X_SyncSetPriority:
+ return SProcSyncSetPriority(client);
+ case X_SyncGetPriority:
+ return SProcSyncGetPriority(client);
+ case X_SyncCreateFence:
+ return SProcSyncCreateFence(client);
+ case X_SyncTriggerFence:
+ return SProcSyncTriggerFence(client);
+ case X_SyncResetFence:
+ return SProcSyncResetFence(client);
+ case X_SyncDestroyFence:
+ return SProcSyncDestroyFence(client);
+ case X_SyncQueryFence:
+ return SProcSyncQueryFence(client);
+ case X_SyncAwaitFence:
+ return SProcSyncAwaitFence(client);
+ default:
+ return BadRequest;
+ }
+}
+
+/*
+ * Event Swapping
+ */
+
+static void
+SCounterNotifyEvent(xSyncCounterNotifyEvent *from, xSyncCounterNotifyEvent *to)
+{
+ to->type = from->type;
+ to->kind = from->kind;
+ cpswaps(from->sequenceNumber, to->sequenceNumber);
+ cpswapl(from->counter, to->counter);
+ cpswapl(from->wait_value_lo, to->wait_value_lo);
+ cpswapl(from->wait_value_hi, to->wait_value_hi);
+ cpswapl(from->counter_value_lo, to->counter_value_lo);
+ cpswapl(from->counter_value_hi, to->counter_value_hi);
+ cpswapl(from->time, to->time);
+ cpswaps(from->count, to->count);
+ to->destroyed = from->destroyed;
+}
+
+
+static void
+SAlarmNotifyEvent(xSyncAlarmNotifyEvent *from, xSyncAlarmNotifyEvent *to)
+{
+ to->type = from->type;
+ to->kind = from->kind;
+ cpswaps(from->sequenceNumber, to->sequenceNumber);
+ cpswapl(from->alarm, to->alarm);
+ cpswapl(from->counter_value_lo, to->counter_value_lo);
+ cpswapl(from->counter_value_hi, to->counter_value_hi);
+ cpswapl(from->alarm_value_lo, to->alarm_value_lo);
+ cpswapl(from->alarm_value_hi, to->alarm_value_hi);
+ cpswapl(from->time, to->time);
+ to->state = from->state;
+}
+
+/*
+ * ** Close everything down. ** This is fairly simple for now.
+ */
+/* ARGSUSED */
+static void
+SyncResetProc(ExtensionEntry *extEntry)
+{
+ free(SysCounterList);
+ SysCounterList = NULL;
+ RTCounter = 0;
+}
+
+/*
+ * ** Initialise the extension.
+ */
+void
+SyncExtensionInit(void)
+{
+ ExtensionEntry *extEntry;
+ int s;
+
+ for (s = 0; s < screenInfo.numScreens; s++)
+ miSyncSetup(screenInfo.screens[s]);
+
+ if (RTCounter == 0)
+ {
+ RTCounter = CreateNewResourceType(FreeCounter, "SyncCounter");
+ }
+ RTAlarm = CreateNewResourceType(FreeAlarm, "SyncAlarm");
+ RTAwait = CreateNewResourceType(FreeAwait, "SyncAwait");
+ RTFence = CreateNewResourceType(FreeFence, "SyncFence");
+ if (RTAwait)
+ RTAwait |= RC_NEVERRETAIN;
+ RTAlarmClient = CreateNewResourceType(FreeAlarmClient, "SyncAlarmClient");
+ if (RTAlarmClient)
+ RTAlarmClient |= RC_NEVERRETAIN;
+
+ if (RTCounter == 0 || RTAwait == 0 || RTAlarm == 0 ||
+ RTAlarmClient == 0 ||
+ (extEntry = AddExtension(SYNC_NAME,
+ XSyncNumberEvents, XSyncNumberErrors,
+ ProcSyncDispatch, SProcSyncDispatch,
+ SyncResetProc,
+ StandardMinorOpcode)) == NULL)
+ {
+ ErrorF("Sync Extension %d.%d failed to Initialise\n",
+ SYNC_MAJOR_VERSION, SYNC_MINOR_VERSION);
+ return;
+ }
+
+ SyncEventBase = extEntry->eventBase;
+ SyncErrorBase = extEntry->errorBase;
+ EventSwapVector[SyncEventBase + XSyncCounterNotify] = (EventSwapPtr) SCounterNotifyEvent;
+ EventSwapVector[SyncEventBase + XSyncAlarmNotify] = (EventSwapPtr) SAlarmNotifyEvent;
+
+ SetResourceTypeErrorValue(RTCounter, SyncErrorBase + XSyncBadCounter);
+ SetResourceTypeErrorValue(RTAlarm, SyncErrorBase + XSyncBadAlarm);
+ SetResourceTypeErrorValue(RTFence, SyncErrorBase + XSyncBadFence);
+
+ /*
+ * Although SERVERTIME is implemented by the OS layer, we initialise it
+ * here because doing it in OsInit() is too early. The resource database
+ * is not initialised when OsInit() is called. This is just about OK
+ * because there is always a servertime counter.
+ */
+ SyncInitServerTime();
+ SyncInitIdleTime();
+
+#ifdef DEBUG
+ fprintf(stderr, "Sync Extension %d.%d\n",
+ SYNC_MAJOR_VERSION, SYNC_MINOR_VERSION);
+#endif
+}
+
+
+/*
+ * ***** SERVERTIME implementation - should go in its own file in OS directory?
+ */
+
+
+
+static pointer ServertimeCounter;
+static XSyncValue Now;
+static XSyncValue *pnext_time;
+
+#define GetTime()\
+{\
+ unsigned long millis = GetTimeInMillis();\
+ unsigned long maxis = XSyncValueHigh32(Now);\
+ if (millis < XSyncValueLow32(Now)) maxis++;\
+ XSyncIntsToValue(&Now, millis, maxis);\
+}
+
+/*
+*** Server Block Handler
+*** code inspired by multibuffer extension (now deprecated)
+ */
+/*ARGSUSED*/
+static void
+ServertimeBlockHandler(void *env, struct timeval **wt, void *LastSelectMask)
+{
+ XSyncValue delay;
+ unsigned long timeout;
+
+ if (pnext_time)
+ {
+ GetTime();
+
+ if (XSyncValueGreaterOrEqual(Now, *pnext_time))
+ {
+ timeout = 0;
+ }
+ else
+ {
+ Bool overflow;
+ XSyncValueSubtract(&delay, *pnext_time, Now, &overflow);
+ (void)overflow;
+ timeout = XSyncValueLow32(delay);
+ }
+ AdjustWaitForDelay(wt, timeout); /* os/utils.c */
+ }
+}
+
+/*
+*** Wakeup Handler
+ */
+/*ARGSUSED*/
+static void
+ServertimeWakeupHandler(void *env, int rc, void *LastSelectMask)
+{
+ if (pnext_time)
+ {
+ GetTime();
+
+ if (XSyncValueGreaterOrEqual(Now, *pnext_time))
+ {
+ SyncChangeCounter(ServertimeCounter, Now);
+ }
+ }
+}
+
+static void
+ServertimeQueryValue(void *pCounter, CARD64 *pValue_return)
+{
+ GetTime();
+ *pValue_return = Now;
+}
+
+static void
+ServertimeBracketValues(void *pCounter, CARD64 *pbracket_less,
+ CARD64 *pbracket_greater)
+{
+ if (!pnext_time && pbracket_greater)
+ {
+ RegisterBlockAndWakeupHandlers(ServertimeBlockHandler,
+ ServertimeWakeupHandler,
+ NULL);
+ }
+ else if (pnext_time && !pbracket_greater)
+ {
+ RemoveBlockAndWakeupHandlers(ServertimeBlockHandler,
+ ServertimeWakeupHandler,
+ NULL);
+ }
+ pnext_time = pbracket_greater;
+}
+
+static void
+SyncInitServerTime(void)
+{
+ CARD64 resolution;
+
+ XSyncIntsToValue(&Now, GetTimeInMillis(), 0);
+ XSyncIntToValue(&resolution, 4);
+ ServertimeCounter = SyncCreateSystemCounter("SERVERTIME", Now, resolution,
+ XSyncCounterNeverDecreases,
+ ServertimeQueryValue, ServertimeBracketValues);
+ pnext_time = NULL;
+}
+
+
+
+/*
+ * IDLETIME implementation
+ */
+
+static SyncCounter *IdleTimeCounter;
+static XSyncValue *pIdleTimeValueLess;
+static XSyncValue *pIdleTimeValueGreater;
+
+static void
+IdleTimeQueryValue (pointer pCounter, CARD64 *pValue_return)
+{
+ CARD32 idle = GetTimeInMillis() - lastDeviceEventTime.milliseconds;
+ XSyncIntsToValue (pValue_return, idle, 0);
+}
+
+static void
+IdleTimeBlockHandler(pointer env, struct timeval **wt, pointer LastSelectMask)
+{
+ XSyncValue idle, old_idle;
+ SyncTriggerList *list = IdleTimeCounter->sync.pTriglist;
+ SyncTrigger *trig;
+
+ if (!pIdleTimeValueLess && !pIdleTimeValueGreater)
+ return;
+
+ old_idle = IdleTimeCounter->value;
+ IdleTimeQueryValue (NULL, &idle);
+ IdleTimeCounter->value = idle; /* push, so CheckTrigger works */
+
+ if (pIdleTimeValueLess &&
+ XSyncValueLessOrEqual (idle, *pIdleTimeValueLess))
+ {
+ /*
+ * We've been idle for less than the threshold value, and someone
+ * wants to know about that, but now we need to know whether they
+ * want level or edge trigger. Check the trigger list against the
+ * current idle time, and if any succeed, bomb out of select()
+ * immediately so we can reschedule.
+ */
+
+ for (list = IdleTimeCounter->sync.pTriglist; list; list = list->next) {
+ trig = list->pTrigger;
+ if (trig->CheckTrigger(trig, old_idle)) {
+ AdjustWaitForDelay(wt, 0);
+ break;
+ }
+ }
+ /*
+ * We've been called exactly on the idle time, but we have a
+ * NegativeTransition trigger which requires a transition from an
+ * idle time greater than this. Schedule a wakeup for the next
+ * millisecond so we won't miss a transition.
+ */
+ if (XSyncValueEqual (idle, *pIdleTimeValueLess))
+ AdjustWaitForDelay(wt, 1);
+ }
+ else if (pIdleTimeValueGreater)
+ {
+ /*
+ * There's a threshold in the positive direction. If we've been
+ * idle less than it, schedule a wakeup for sometime in the future.
+ * If we've been idle more than it, and someone wants to know about
+ * that level-triggered, schedule an immediate wakeup.
+ */
+ unsigned long timeout = -1;
+
+ if (XSyncValueLessThan (idle, *pIdleTimeValueGreater)) {
+ XSyncValue value;
+ Bool overflow;
+
+ XSyncValueSubtract (&value, *pIdleTimeValueGreater,
+ idle, &overflow);
+ timeout = min(timeout, XSyncValueLow32 (value));
+ } else {
+ for (list = IdleTimeCounter->sync.pTriglist; list; list = list->next) {
+ trig = list->pTrigger;
+ if (trig->CheckTrigger(trig, old_idle)) {
+ timeout = min(timeout, 0);
+ break;
+ }
+ }
+ }
+
+ AdjustWaitForDelay (wt, timeout);
+ }
+
+ IdleTimeCounter->value = old_idle; /* pop */
+}
+
+static void
+IdleTimeWakeupHandler (pointer env, int rc, pointer LastSelectMask)
+{
+ XSyncValue idle;
+
+ if (!pIdleTimeValueLess && !pIdleTimeValueGreater)
+ return;
+
+ IdleTimeQueryValue (NULL, &idle);
+
+ if ((pIdleTimeValueGreater &&
+ XSyncValueGreaterOrEqual (idle, *pIdleTimeValueGreater)) ||
+ (pIdleTimeValueLess &&
+ XSyncValueLessOrEqual (idle, *pIdleTimeValueLess)))
+ {
+ SyncChangeCounter (IdleTimeCounter, idle);
+ }
+}
+
+static void
+IdleTimeBracketValues (pointer pCounter, CARD64 *pbracket_less,
+ CARD64 *pbracket_greater)
+{
+ Bool registered = (pIdleTimeValueLess || pIdleTimeValueGreater);
+
+ if (registered && !pbracket_less && !pbracket_greater)
+ {
+ RemoveBlockAndWakeupHandlers(IdleTimeBlockHandler,
+ IdleTimeWakeupHandler,
+ NULL);
+ }
+ else if (!registered && (pbracket_less || pbracket_greater))
+ {
+ RegisterBlockAndWakeupHandlers(IdleTimeBlockHandler,
+ IdleTimeWakeupHandler,
+ NULL);
+ }
+
+ pIdleTimeValueGreater = pbracket_greater;
+ pIdleTimeValueLess = pbracket_less;
+}
+
+static void
+SyncInitIdleTime (void)
+{
+ CARD64 resolution;
+ XSyncValue idle;
+
+ IdleTimeQueryValue (NULL, &idle);
+ XSyncIntToValue (&resolution, 4);
+
+ IdleTimeCounter = SyncCreateSystemCounter ("IDLETIME", idle, resolution,
+ XSyncCounterUnrestricted,
+ IdleTimeQueryValue,
+ IdleTimeBracketValues);
+
+ pIdleTimeValueLess = pIdleTimeValueGreater = NULL;
+}
diff --git a/xorg-server/Xext/xf86bigfont.c b/xorg-server/Xext/xf86bigfont.c
index 356a6152b..da3528783 100644
--- a/xorg-server/Xext/xf86bigfont.c
+++ b/xorg-server/Xext/xf86bigfont.c
@@ -1,751 +1,751 @@
-/*
- * BIGFONT extension for sharing font metrics between clients (if possible)
- * and for transmitting font metrics to clients in a compressed form.
- *
- * Copyright (c) 1999-2000 Bruno Haible
- * Copyright (c) 1999-2000 The XFree86 Project, Inc.
- */
-
-/* THIS IS NOT AN X CONSORTIUM STANDARD */
-
-/*
- * Big fonts suffer from the following: All clients that have opened a
- * font can access the complete glyph metrics array (the XFontStruct member
- * `per_char') directly, without going through a macro. Moreover these
- * glyph metrics are ink metrics, i.e. are not redundant even for a
- * fixed-width font. For a Unicode font, the size of this array is 768 KB.
- *
- * Problems: 1. It eats a lot of memory in each client. 2. All this glyph
- * metrics data is piped through the socket when the font is opened.
- *
- * This extension addresses these two problems for local clients, by using
- * shared memory. It also addresses the second problem for non-local clients,
- * by compressing the data before transmit by a factor of nearly 6.
- *
- * If you use this extension, your OS ought to nicely support shared memory.
- * This means: Shared memory should be swappable to the swap, and the limits
- * should be high enough (SHMMNI at least 64, SHMMAX at least 768 KB,
- * SHMALL at least 48 MB). It is a plus if your OS allows shmat() calls
- * on segments that have already been marked "removed", because it permits
- * these segments to be cleaned up by the OS if the X server is killed with
- * signal SIGKILL.
- *
- * This extension is transparently exploited by Xlib (functions XQueryFont,
- * XLoadQueryFont).
- */
-
-#ifdef HAVE_DIX_CONFIG_H
-#include <dix-config.h>
-#endif
-
-#include <sys/types.h>
-#ifdef HAS_SHM
-#if defined(linux) && (!defined(__GNU_LIBRARY__) || __GNU_LIBRARY__ < 2)
-/* libc4 does not define __GNU_LIBRARY__, libc5 defines __GNU_LIBRARY__ as 1 */
-/* Linux libc4 and libc5 only (because glibc doesn't include kernel headers):
- Linux 2.0.x and 2.2.x define SHMLBA as PAGE_SIZE, but forget to define
- PAGE_SIZE. It is defined in <asm/page.h>. */
-#include <asm/page.h>
-#endif
-#ifdef SVR4
-#include <sys/sysmacros.h>
-#endif
-#if defined(__CYGWIN__) || defined(__SCO__)
-#include <sys/param.h>
-#include <sys/sysmacros.h>
-#endif
-#include <sys/ipc.h>
-#include <sys/shm.h>
-#include <sys/stat.h>
-#include <stdlib.h>
-#include <unistd.h>
-#include <time.h>
-#include <errno.h>
-#endif
-
-#include <X11/X.h>
-#include <X11/Xproto.h>
-#include "misc.h"
-#include "os.h"
-#include "dixstruct.h"
-#include "gcstruct.h"
-#include "dixfontstr.h"
-#include "extnsionst.h"
-#include "protocol-versions.h"
-
-#include <X11/extensions/xf86bigfproto.h>
-#include "xf86bigfontsrv.h"
-
-static void XF86BigfontResetProc(
- ExtensionEntry * /* extEntry */
- );
-
-
-#ifdef HAS_SHM
-
-/* A random signature, transmitted to the clients so they can verify that the
- shared memory segment they are attaching to was really established by the
- X server they are talking to. */
-static CARD32 signature;
-
-/* Index for additional information stored in a FontRec's devPrivates array. */
-static int FontShmdescIndex;
-
-static unsigned int pagesize;
-
-static Bool badSysCall = FALSE;
-
-#if defined(__FreeBSD__) || defined(__NetBSD__) || defined(__OpenBSD__) || defined(__CYGWIN__) || defined(__DragonFly__)
-
-#include <sys/signal.h>
-
-static void
-SigSysHandler(
- int signo)
-{
- badSysCall = TRUE;
-}
-
-static Bool
-CheckForShmSyscall(void)
-{
- void (*oldHandler)(int);
- int shmid = -1;
-
- /* If no SHM support in the kernel, the bad syscall will generate SIGSYS */
- oldHandler = signal(SIGSYS, SigSysHandler);
-
- badSysCall = FALSE;
- shmid = shmget(IPC_PRIVATE, 4096, IPC_CREAT);
- if (shmid != -1)
- {
- /* Successful allocation - clean up */
- shmctl(shmid, IPC_RMID, NULL);
- }
- else
- {
- /* Allocation failed */
- badSysCall = TRUE;
- }
- signal(SIGSYS, oldHandler);
- return !badSysCall;
-}
-
-#define MUST_CHECK_FOR_SHM_SYSCALL
-
-#endif
-
-#endif
-
-void
-XFree86BigfontExtensionInit(void)
-{
- if (AddExtension(XF86BIGFONTNAME,
- XF86BigfontNumberEvents,
- XF86BigfontNumberErrors,
- ProcXF86BigfontDispatch,
- SProcXF86BigfontDispatch,
- XF86BigfontResetProc,
- StandardMinorOpcode)) {
-#ifdef HAS_SHM
-#ifdef MUST_CHECK_FOR_SHM_SYSCALL
- /*
- * Note: Local-clients will not be optimized without shared memory
- * support. Remote-client optimization does not depend on shared
- * memory support. Thus, the extension is still registered even
- * when shared memory support is not functional.
- */
- if (!CheckForShmSyscall()) {
- ErrorF(XF86BIGFONTNAME " extension local-client optimization disabled due to lack of shared memory support in the kernel\n");
- return;
- }
-#endif
-
- srand((unsigned int) time(NULL));
- signature = ((unsigned int) (65536.0/(RAND_MAX+1.0) * rand()) << 16)
- + (unsigned int) (65536.0/(RAND_MAX+1.0) * rand());
- /* fprintf(stderr, "signature = 0x%08X\n", signature); */
-
- FontShmdescIndex = AllocateFontPrivateIndex();
-
-#if !defined(CSRG_BASED) && !defined(__CYGWIN__)
- pagesize = SHMLBA;
-#else
-# ifdef _SC_PAGESIZE
- pagesize = sysconf(_SC_PAGESIZE);
-# else
- pagesize = getpagesize();
-# endif
-#endif
-#endif
- }
-}
-
-
-/* ========== Management of shared memory segments ========== */
-
-#ifdef HAS_SHM
-
-#ifdef __linux__
-/* On Linux, shared memory marked as "removed" can still be attached.
- Nice feature, because the kernel will automatically free the associated
- storage when the server and all clients are gone. */
-#define EARLY_REMOVE
-#endif
-
-typedef struct _ShmDesc {
- struct _ShmDesc *next;
- struct _ShmDesc **prev;
- int shmid;
- char *attach_addr;
-} ShmDescRec, *ShmDescPtr;
-
-static ShmDescPtr ShmList = (ShmDescPtr) NULL;
-
-static ShmDescPtr
-shmalloc(
- unsigned int size)
-{
- ShmDescPtr pDesc;
- int shmid;
- char *addr;
-
-#ifdef MUST_CHECK_FOR_SHM_SYSCALL
- if (pagesize == 0)
- return (ShmDescPtr) NULL;
-#endif
-
- /* On some older Linux systems, the number of shared memory segments
- system-wide is 127. In Linux 2.4, it is 4095.
- Therefore there is a tradeoff to be made between allocating a
- shared memory segment on one hand, and allocating memory and piping
- the glyph metrics on the other hand. If the glyph metrics size is
- small, we prefer the traditional way. */
- if (size < 3500)
- return (ShmDescPtr) NULL;
-
- pDesc = malloc(sizeof(ShmDescRec));
- if (!pDesc)
- return (ShmDescPtr) NULL;
-
- size = (size + pagesize-1) & -pagesize;
- shmid = shmget(IPC_PRIVATE, size, S_IWUSR | S_IRUSR | S_IRGRP | S_IROTH);
- if (shmid == -1) {
- ErrorF(XF86BIGFONTNAME " extension: shmget() failed, size = %u, %s\n",
- size, strerror(errno));
- free(pDesc);
- return (ShmDescPtr) NULL;
- }
-
- if ((addr = shmat(shmid, 0, 0)) == (char *)-1) {
- ErrorF(XF86BIGFONTNAME " extension: shmat() failed, size = %u, %s\n",
- size, strerror(errno));
- shmctl(shmid, IPC_RMID, (void *) 0);
- free(pDesc);
- return (ShmDescPtr) NULL;
- }
-
-#ifdef EARLY_REMOVE
- shmctl(shmid, IPC_RMID, (void *) 0);
-#endif
-
- pDesc->shmid = shmid;
- pDesc->attach_addr = addr;
- if (ShmList) ShmList->prev = &pDesc->next;
- pDesc->next = ShmList;
- pDesc->prev = &ShmList;
- ShmList = pDesc;
-
- return pDesc;
-}
-
-static void
-shmdealloc(
- ShmDescPtr pDesc)
-{
-#ifndef EARLY_REMOVE
- shmctl(pDesc->shmid, IPC_RMID, (void *) 0);
-#endif
- shmdt(pDesc->attach_addr);
-
- if (pDesc->next) pDesc->next->prev = pDesc->prev;
- *pDesc->prev = pDesc->next;
- free(pDesc);
-}
-
-#endif
-
-/* Called when a font is closed. */
-void
-XF86BigfontFreeFontShm(
- FontPtr pFont)
-{
-#ifdef HAS_SHM
- ShmDescPtr pDesc;
-
- /* If during shutdown of the server, XF86BigfontCleanup() has already
- * called shmdealloc() for all segments, we don't need to do it here.
- */
- if (!ShmList)
- return;
-
- pDesc = (ShmDescPtr) FontGetPrivate(pFont, FontShmdescIndex);
- if (pDesc)
- shmdealloc(pDesc);
-#endif
-}
-
-/* Called upon fatal signal. */
-void
-XF86BigfontCleanup(void)
-{
-#ifdef HAS_SHM
- while (ShmList)
- shmdealloc(ShmList);
-#endif
-}
-
-/* Called when a server generation dies. */
-static void
-XF86BigfontResetProc(
- ExtensionEntry* extEntry)
-{
- /* This function is normally called from CloseDownExtensions(), called
- * from main(). It will be followed by a call to FreeAllResources(),
- * which will call XF86BigfontFreeFontShm() for each font. Thus it
- * appears that we do not need to do anything in this function. --
- * But I prefer to write robust code, and not keep shared memory lying
- * around when it's not needed any more. (Someone might close down the
- * extension without calling FreeAllResources()...)
- */
- XF86BigfontCleanup();
-}
-
-
-/* ========== Handling of extension specific requests ========== */
-
-static int
-ProcXF86BigfontQueryVersion(
- ClientPtr client)
-{
- xXF86BigfontQueryVersionReply reply;
-
- REQUEST_SIZE_MATCH(xXF86BigfontQueryVersionReq);
- reply.type = X_Reply;
- reply.length = 0;
- reply.sequenceNumber = client->sequence;
- reply.majorVersion = SERVER_XF86BIGFONT_MAJOR_VERSION;
- reply.minorVersion = SERVER_XF86BIGFONT_MINOR_VERSION;
- reply.uid = geteuid();
- reply.gid = getegid();
-#ifdef HAS_SHM
- reply.signature = signature;
-#else
- reply.signature = 0; /* This is redundant. Avoids uninitialized memory. */
-#endif
- reply.capabilities =
-#ifdef HAS_SHM
- (LocalClient(client) && !client->swapped ? XF86Bigfont_CAP_LocalShm : 0)
-#else
- 0
-#endif
- ; /* may add more bits here in future versions */
- if (client->swapped) {
- char tmp;
- swaps(&reply.sequenceNumber, tmp);
- swapl(&reply.length, tmp);
- swaps(&reply.majorVersion, tmp);
- swaps(&reply.minorVersion, tmp);
- swapl(&reply.uid, tmp);
- swapl(&reply.gid, tmp);
- swapl(&reply.signature, tmp);
- }
- WriteToClient(client,
- sizeof(xXF86BigfontQueryVersionReply), (char *)&reply);
- return Success;
-}
-
-static void
-swapCharInfo(
- xCharInfo *pCI)
-{
- char tmp;
-
- swaps(&pCI->leftSideBearing, tmp);
- swaps(&pCI->rightSideBearing, tmp);
- swaps(&pCI->characterWidth, tmp);
- swaps(&pCI->ascent, tmp);
- swaps(&pCI->descent, tmp);
- swaps(&pCI->attributes, tmp);
-}
-
-/* static CARD32 hashCI (xCharInfo *p); */
-#define hashCI(p) \
- (CARD32)(((p->leftSideBearing << 27) + (p->leftSideBearing >> 5) + \
- (p->rightSideBearing << 23) + (p->rightSideBearing >> 9) + \
- (p->characterWidth << 16) + \
- (p->ascent << 11) + (p->descent << 6)) ^ p->attributes)
-
-static int
-ProcXF86BigfontQueryFont(
- ClientPtr client)
-{
- FontPtr pFont;
- REQUEST(xXF86BigfontQueryFontReq);
- CARD32 stuff_flags;
- xCharInfo* pmax;
- xCharInfo* pmin;
- int nCharInfos;
- int shmid;
-#ifdef HAS_SHM
- ShmDescPtr pDesc = NULL;
-#else
-#define pDesc 0
-#endif
- xCharInfo* pCI;
- CARD16* pIndex2UniqIndex;
- CARD16* pUniqIndex2Index;
- CARD32 nUniqCharInfos;
-
-#if 0
- REQUEST_SIZE_MATCH(xXF86BigfontQueryFontReq);
-#else
- switch (client->req_len) {
- case 2: /* client with version 1.0 libX11 */
- stuff_flags = (LocalClient(client) && !client->swapped ? XF86Bigfont_FLAGS_Shm : 0);
- break;
- case 3: /* client with version 1.1 libX11 */
- stuff_flags = stuff->flags;
- break;
- default:
- return BadLength;
- }
-#endif
- if (dixLookupFontable(&pFont, stuff->id, client, DixGetAttrAccess) != Success)
- return BadFont; /* procotol spec says only error is BadFont */
-
- pmax = FONTINKMAX(pFont);
- pmin = FONTINKMIN(pFont);
- nCharInfos =
- (pmax->rightSideBearing == pmin->rightSideBearing
- && pmax->leftSideBearing == pmin->leftSideBearing
- && pmax->descent == pmin->descent
- && pmax->ascent == pmin->ascent
- && pmax->characterWidth == pmin->characterWidth)
- ? 0 : N2dChars(pFont);
- shmid = -1;
- pCI = NULL;
- pIndex2UniqIndex = NULL;
- pUniqIndex2Index = NULL;
- nUniqCharInfos = 0;
-
- if (nCharInfos > 0) {
-#ifdef HAS_SHM
- if (!badSysCall)
- pDesc = (ShmDescPtr) FontGetPrivate(pFont, FontShmdescIndex);
- if (pDesc) {
- pCI = (xCharInfo *) pDesc->attach_addr;
- if (stuff_flags & XF86Bigfont_FLAGS_Shm)
- shmid = pDesc->shmid;
- } else {
- if (stuff_flags & XF86Bigfont_FLAGS_Shm && !badSysCall)
- pDesc = shmalloc(nCharInfos * sizeof(xCharInfo)
- + sizeof(CARD32));
- if (pDesc) {
- pCI = (xCharInfo *) pDesc->attach_addr;
- shmid = pDesc->shmid;
- } else {
-#endif
- pCI = malloc(nCharInfos * sizeof(xCharInfo));
- if (!pCI)
- return BadAlloc;
-#ifdef HAS_SHM
- }
-#endif
- /* Fill nCharInfos starting at pCI. */
- {
- xCharInfo* prCI = pCI;
- int ninfos = 0;
- int ncols = pFont->info.lastCol - pFont->info.firstCol + 1;
- int row;
- for (row = pFont->info.firstRow;
- row <= pFont->info.lastRow && ninfos < nCharInfos;
- row++) {
- unsigned char chars[512];
- xCharInfo* tmpCharInfos[256];
- unsigned long count;
- int col;
- unsigned long i;
- i = 0;
- for (col = pFont->info.firstCol;
- col <= pFont->info.lastCol;
- col++) {
- chars[i++] = row;
- chars[i++] = col;
- }
- (*pFont->get_metrics) (pFont, ncols, chars, TwoD16Bit,
- &count, tmpCharInfos);
- for (i = 0; i < count && ninfos < nCharInfos; i++) {
- *prCI++ = *tmpCharInfos[i];
- ninfos++;
- }
- }
- }
-#ifdef HAS_SHM
- if (pDesc && !badSysCall) {
- *(CARD32 *)(pCI + nCharInfos) = signature;
- if (!FontSetPrivate(pFont, FontShmdescIndex, pDesc)) {
- shmdealloc(pDesc);
- return BadAlloc;
- }
- }
- }
-#endif
- if (shmid == -1) {
- /* Cannot use shared memory, so remove-duplicates the xCharInfos
- using a temporary hash table. */
- /* Note that CARD16 is suitable as index type, because
- nCharInfos <= 0x10000. */
- CARD32 hashModulus;
- CARD16* pHash2UniqIndex;
- CARD16* pUniqIndex2NextUniqIndex;
- CARD32 NextIndex;
- CARD32 NextUniqIndex;
- CARD16* tmp;
- CARD32 i, j;
-
- hashModulus = 67;
- if (hashModulus > nCharInfos+1)
- hashModulus = nCharInfos+1;
-
- tmp = malloc((4*nCharInfos+1) * sizeof(CARD16));
- if (!tmp) {
- if (!pDesc) free(pCI);
- return BadAlloc;
- }
- pIndex2UniqIndex = tmp;
- /* nCharInfos elements */
- pUniqIndex2Index = tmp + nCharInfos;
- /* max. nCharInfos elements */
- pUniqIndex2NextUniqIndex = tmp + 2*nCharInfos;
- /* max. nCharInfos elements */
- pHash2UniqIndex = tmp + 3*nCharInfos;
- /* hashModulus (<= nCharInfos+1) elements */
-
- /* Note that we can use 0xffff as end-of-list indicator, because
- even if nCharInfos = 0x10000, 0xffff can not occur as valid
- entry before the last element has been inserted. And once the
- last element has been inserted, we don't need the hash table
- any more. */
- for (j = 0; j < hashModulus; j++)
- pHash2UniqIndex[j] = (CARD16)(-1);
-
- NextUniqIndex = 0;
- for (NextIndex = 0; NextIndex < nCharInfos; NextIndex++) {
- xCharInfo* p = &pCI[NextIndex];
- CARD32 hashCode = hashCI(p) % hashModulus;
- for (i = pHash2UniqIndex[hashCode];
- i != (CARD16)(-1);
- i = pUniqIndex2NextUniqIndex[i]) {
- j = pUniqIndex2Index[i];
- if (pCI[j].leftSideBearing == p->leftSideBearing
- && pCI[j].rightSideBearing == p->rightSideBearing
- && pCI[j].characterWidth == p->characterWidth
- && pCI[j].ascent == p->ascent
- && pCI[j].descent == p->descent
- && pCI[j].attributes == p->attributes)
- break;
- }
- if (i != (CARD16)(-1)) {
- /* Found *p at Index j, UniqIndex i */
- pIndex2UniqIndex[NextIndex] = i;
- } else {
- /* Allocate a new entry in the Uniq table */
- if (hashModulus <= 2*NextUniqIndex
- && hashModulus < nCharInfos+1) {
- /* Time to increate hash table size */
- hashModulus = 2*hashModulus+1;
- if (hashModulus > nCharInfos+1)
- hashModulus = nCharInfos+1;
- for (j = 0; j < hashModulus; j++)
- pHash2UniqIndex[j] = (CARD16)(-1);
- for (i = 0; i < NextUniqIndex; i++)
- pUniqIndex2NextUniqIndex[i] = (CARD16)(-1);
- for (i = 0; i < NextUniqIndex; i++) {
- j = pUniqIndex2Index[i];
- p = &pCI[j];
- hashCode = hashCI(p) % hashModulus;
- pUniqIndex2NextUniqIndex[i] = pHash2UniqIndex[hashCode];
- pHash2UniqIndex[hashCode] = i;
- }
- p = &pCI[NextIndex];
- hashCode = hashCI(p) % hashModulus;
- }
- i = NextUniqIndex++;
- pUniqIndex2NextUniqIndex[i] = pHash2UniqIndex[hashCode];
- pHash2UniqIndex[hashCode] = i;
- pUniqIndex2Index[i] = NextIndex;
- pIndex2UniqIndex[NextIndex] = i;
- }
- }
- nUniqCharInfos = NextUniqIndex;
- /* fprintf(stderr, "font metrics: nCharInfos = %d, nUniqCharInfos = %d, hashModulus = %d\n", nCharInfos, nUniqCharInfos, hashModulus); */
- }
- }
-
- {
- int nfontprops = pFont->info.nprops;
- int rlength =
- sizeof(xXF86BigfontQueryFontReply)
- + nfontprops * sizeof(xFontProp)
- + (nCharInfos > 0 && shmid == -1
- ? nUniqCharInfos * sizeof(xCharInfo)
- + (nCharInfos+1)/2 * 2 * sizeof(CARD16)
- : 0);
- xXF86BigfontQueryFontReply* reply = malloc(rlength);
- char* p;
- if (!reply) {
- if (nCharInfos > 0) {
- if (shmid == -1) free(pIndex2UniqIndex);
- if (!pDesc) free(pCI);
- }
- return BadAlloc;
- }
- reply->type = X_Reply;
- reply->length = bytes_to_int32(rlength - sizeof(xGenericReply));
- reply->sequenceNumber = client->sequence;
- reply->minBounds = pFont->info.ink_minbounds;
- reply->maxBounds = pFont->info.ink_maxbounds;
- reply->minCharOrByte2 = pFont->info.firstCol;
- reply->maxCharOrByte2 = pFont->info.lastCol;
- reply->defaultChar = pFont->info.defaultCh;
- reply->nFontProps = pFont->info.nprops;
- reply->drawDirection = pFont->info.drawDirection;
- reply->minByte1 = pFont->info.firstRow;
- reply->maxByte1 = pFont->info.lastRow;
- reply->allCharsExist = pFont->info.allExist;
- reply->fontAscent = pFont->info.fontAscent;
- reply->fontDescent = pFont->info.fontDescent;
- reply->nCharInfos = nCharInfos;
- reply->nUniqCharInfos = nUniqCharInfos;
- reply->shmid = shmid;
- reply->shmsegoffset = 0;
- if (client->swapped) {
- char tmp;
- swaps(&reply->sequenceNumber, tmp);
- swapl(&reply->length, tmp);
- swapCharInfo(&reply->minBounds);
- swapCharInfo(&reply->maxBounds);
- swaps(&reply->minCharOrByte2, tmp);
- swaps(&reply->maxCharOrByte2, tmp);
- swaps(&reply->defaultChar, tmp);
- swaps(&reply->nFontProps, tmp);
- swaps(&reply->fontAscent, tmp);
- swaps(&reply->fontDescent, tmp);
- swapl(&reply->nCharInfos, tmp);
- swapl(&reply->nUniqCharInfos, tmp);
- swapl(&reply->shmid, tmp);
- swapl(&reply->shmsegoffset, tmp);
- }
- p = (char*) &reply[1];
- {
- FontPropPtr pFP;
- xFontProp* prFP;
- int i;
- for (i = 0, pFP = pFont->info.props, prFP = (xFontProp *) p;
- i < nfontprops;
- i++, pFP++, prFP++) {
- prFP->name = pFP->name;
- prFP->value = pFP->value;
- if (client->swapped) {
- char tmp;
- swapl(&prFP->name, tmp);
- swapl(&prFP->value, tmp);
- }
- }
- p = (char*) prFP;
- }
- if (nCharInfos > 0 && shmid == -1) {
- xCharInfo* pci;
- CARD16* ps;
- int i, j;
- pci = (xCharInfo*) p;
- for (i = 0; i < nUniqCharInfos; i++, pci++) {
- *pci = pCI[pUniqIndex2Index[i]];
- if (client->swapped)
- swapCharInfo(pci);
- }
- ps = (CARD16*) pci;
- for (j = 0; j < nCharInfos; j++, ps++) {
- *ps = pIndex2UniqIndex[j];
- if (client->swapped) {
- char tmp;
- swaps(ps, tmp);
- }
- }
- }
- WriteToClient(client, rlength, (char *)reply);
- free(reply);
- if (nCharInfos > 0) {
- if (shmid == -1) free(pIndex2UniqIndex);
- if (!pDesc) free(pCI);
- }
- return Success;
- }
-}
-
-static int
-ProcXF86BigfontDispatch(
- ClientPtr client)
-{
- REQUEST(xReq);
-
- switch (stuff->data) {
- case X_XF86BigfontQueryVersion:
- return ProcXF86BigfontQueryVersion(client);
- case X_XF86BigfontQueryFont:
- return ProcXF86BigfontQueryFont(client);
- default:
- return BadRequest;
- }
-}
-
-static int
-SProcXF86BigfontQueryVersion(
- ClientPtr client)
-{
- REQUEST(xXF86BigfontQueryVersionReq);
- char tmp;
-
- swaps(&stuff->length, tmp);
- return ProcXF86BigfontQueryVersion(client);
-}
-
-static int
-SProcXF86BigfontQueryFont(
- ClientPtr client)
-{
- REQUEST(xXF86BigfontQueryFontReq);
- char tmp;
-
- swaps(&stuff->length, tmp);
- REQUEST_SIZE_MATCH(xXF86BigfontQueryFontReq);
- swapl(&stuff->id, tmp);
- return ProcXF86BigfontQueryFont(client);
-}
-
-static int
-SProcXF86BigfontDispatch(
- ClientPtr client)
-{
- REQUEST(xReq);
-
- switch (stuff->data) {
- case X_XF86BigfontQueryVersion:
- return SProcXF86BigfontQueryVersion(client);
- case X_XF86BigfontQueryFont:
- return SProcXF86BigfontQueryFont(client);
- default:
- return BadRequest;
- }
-}
+/*
+ * BIGFONT extension for sharing font metrics between clients (if possible)
+ * and for transmitting font metrics to clients in a compressed form.
+ *
+ * Copyright (c) 1999-2000 Bruno Haible
+ * Copyright (c) 1999-2000 The XFree86 Project, Inc.
+ */
+
+/* THIS IS NOT AN X CONSORTIUM STANDARD */
+
+/*
+ * Big fonts suffer from the following: All clients that have opened a
+ * font can access the complete glyph metrics array (the XFontStruct member
+ * `per_char') directly, without going through a macro. Moreover these
+ * glyph metrics are ink metrics, i.e. are not redundant even for a
+ * fixed-width font. For a Unicode font, the size of this array is 768 KB.
+ *
+ * Problems: 1. It eats a lot of memory in each client. 2. All this glyph
+ * metrics data is piped through the socket when the font is opened.
+ *
+ * This extension addresses these two problems for local clients, by using
+ * shared memory. It also addresses the second problem for non-local clients,
+ * by compressing the data before transmit by a factor of nearly 6.
+ *
+ * If you use this extension, your OS ought to nicely support shared memory.
+ * This means: Shared memory should be swappable to the swap, and the limits
+ * should be high enough (SHMMNI at least 64, SHMMAX at least 768 KB,
+ * SHMALL at least 48 MB). It is a plus if your OS allows shmat() calls
+ * on segments that have already been marked "removed", because it permits
+ * these segments to be cleaned up by the OS if the X server is killed with
+ * signal SIGKILL.
+ *
+ * This extension is transparently exploited by Xlib (functions XQueryFont,
+ * XLoadQueryFont).
+ */
+
+#ifdef HAVE_DIX_CONFIG_H
+#include <dix-config.h>
+#endif
+
+#include <sys/types.h>
+#ifdef HAS_SHM
+#if defined(linux) && (!defined(__GNU_LIBRARY__) || __GNU_LIBRARY__ < 2)
+/* libc4 does not define __GNU_LIBRARY__, libc5 defines __GNU_LIBRARY__ as 1 */
+/* Linux libc4 and libc5 only (because glibc doesn't include kernel headers):
+ Linux 2.0.x and 2.2.x define SHMLBA as PAGE_SIZE, but forget to define
+ PAGE_SIZE. It is defined in <asm/page.h>. */
+#include <asm/page.h>
+#endif
+#ifdef SVR4
+#include <sys/sysmacros.h>
+#endif
+#if defined(__CYGWIN__)
+#include <sys/param.h>
+#include <sys/sysmacros.h>
+#endif
+#include <sys/ipc.h>
+#include <sys/shm.h>
+#include <sys/stat.h>
+#include <stdlib.h>
+#include <unistd.h>
+#include <time.h>
+#include <errno.h>
+#endif
+
+#include <X11/X.h>
+#include <X11/Xproto.h>
+#include "misc.h"
+#include "os.h"
+#include "dixstruct.h"
+#include "gcstruct.h"
+#include "dixfontstr.h"
+#include "extnsionst.h"
+#include "protocol-versions.h"
+
+#include <X11/extensions/xf86bigfproto.h>
+#include "xf86bigfontsrv.h"
+
+static void XF86BigfontResetProc(
+ ExtensionEntry * /* extEntry */
+ );
+
+
+#ifdef HAS_SHM
+
+/* A random signature, transmitted to the clients so they can verify that the
+ shared memory segment they are attaching to was really established by the
+ X server they are talking to. */
+static CARD32 signature;
+
+/* Index for additional information stored in a FontRec's devPrivates array. */
+static int FontShmdescIndex;
+
+static unsigned int pagesize;
+
+static Bool badSysCall = FALSE;
+
+#if defined(__FreeBSD__) || defined(__NetBSD__) || defined(__OpenBSD__) || defined(__CYGWIN__) || defined(__DragonFly__)
+
+#include <sys/signal.h>
+
+static void
+SigSysHandler(
+ int signo)
+{
+ badSysCall = TRUE;
+}
+
+static Bool
+CheckForShmSyscall(void)
+{
+ void (*oldHandler)(int);
+ int shmid = -1;
+
+ /* If no SHM support in the kernel, the bad syscall will generate SIGSYS */
+ oldHandler = signal(SIGSYS, SigSysHandler);
+
+ badSysCall = FALSE;
+ shmid = shmget(IPC_PRIVATE, 4096, IPC_CREAT);
+ if (shmid != -1)
+ {
+ /* Successful allocation - clean up */
+ shmctl(shmid, IPC_RMID, NULL);
+ }
+ else
+ {
+ /* Allocation failed */
+ badSysCall = TRUE;
+ }
+ signal(SIGSYS, oldHandler);
+ return !badSysCall;
+}
+
+#define MUST_CHECK_FOR_SHM_SYSCALL
+
+#endif
+
+#endif
+
+void
+XFree86BigfontExtensionInit(void)
+{
+ if (AddExtension(XF86BIGFONTNAME,
+ XF86BigfontNumberEvents,
+ XF86BigfontNumberErrors,
+ ProcXF86BigfontDispatch,
+ SProcXF86BigfontDispatch,
+ XF86BigfontResetProc,
+ StandardMinorOpcode)) {
+#ifdef HAS_SHM
+#ifdef MUST_CHECK_FOR_SHM_SYSCALL
+ /*
+ * Note: Local-clients will not be optimized without shared memory
+ * support. Remote-client optimization does not depend on shared
+ * memory support. Thus, the extension is still registered even
+ * when shared memory support is not functional.
+ */
+ if (!CheckForShmSyscall()) {
+ ErrorF(XF86BIGFONTNAME " extension local-client optimization disabled due to lack of shared memory support in the kernel\n");
+ return;
+ }
+#endif
+
+ srand((unsigned int) time(NULL));
+ signature = ((unsigned int) (65536.0/(RAND_MAX+1.0) * rand()) << 16)
+ + (unsigned int) (65536.0/(RAND_MAX+1.0) * rand());
+ /* fprintf(stderr, "signature = 0x%08X\n", signature); */
+
+ FontShmdescIndex = AllocateFontPrivateIndex();
+
+#if !defined(CSRG_BASED) && !defined(__CYGWIN__)
+ pagesize = SHMLBA;
+#else
+# ifdef _SC_PAGESIZE
+ pagesize = sysconf(_SC_PAGESIZE);
+# else
+ pagesize = getpagesize();
+# endif
+#endif
+#endif
+ }
+}
+
+
+/* ========== Management of shared memory segments ========== */
+
+#ifdef HAS_SHM
+
+#ifdef __linux__
+/* On Linux, shared memory marked as "removed" can still be attached.
+ Nice feature, because the kernel will automatically free the associated
+ storage when the server and all clients are gone. */
+#define EARLY_REMOVE
+#endif
+
+typedef struct _ShmDesc {
+ struct _ShmDesc *next;
+ struct _ShmDesc **prev;
+ int shmid;
+ char *attach_addr;
+} ShmDescRec, *ShmDescPtr;
+
+static ShmDescPtr ShmList = (ShmDescPtr) NULL;
+
+static ShmDescPtr
+shmalloc(
+ unsigned int size)
+{
+ ShmDescPtr pDesc;
+ int shmid;
+ char *addr;
+
+#ifdef MUST_CHECK_FOR_SHM_SYSCALL
+ if (pagesize == 0)
+ return (ShmDescPtr) NULL;
+#endif
+
+ /* On some older Linux systems, the number of shared memory segments
+ system-wide is 127. In Linux 2.4, it is 4095.
+ Therefore there is a tradeoff to be made between allocating a
+ shared memory segment on one hand, and allocating memory and piping
+ the glyph metrics on the other hand. If the glyph metrics size is
+ small, we prefer the traditional way. */
+ if (size < 3500)
+ return (ShmDescPtr) NULL;
+
+ pDesc = malloc(sizeof(ShmDescRec));
+ if (!pDesc)
+ return (ShmDescPtr) NULL;
+
+ size = (size + pagesize-1) & -pagesize;
+ shmid = shmget(IPC_PRIVATE, size, S_IWUSR | S_IRUSR | S_IRGRP | S_IROTH);
+ if (shmid == -1) {
+ ErrorF(XF86BIGFONTNAME " extension: shmget() failed, size = %u, %s\n",
+ size, strerror(errno));
+ free(pDesc);
+ return (ShmDescPtr) NULL;
+ }
+
+ if ((addr = shmat(shmid, 0, 0)) == (char *)-1) {
+ ErrorF(XF86BIGFONTNAME " extension: shmat() failed, size = %u, %s\n",
+ size, strerror(errno));
+ shmctl(shmid, IPC_RMID, (void *) 0);
+ free(pDesc);
+ return (ShmDescPtr) NULL;
+ }
+
+#ifdef EARLY_REMOVE
+ shmctl(shmid, IPC_RMID, (void *) 0);
+#endif
+
+ pDesc->shmid = shmid;
+ pDesc->attach_addr = addr;
+ if (ShmList) ShmList->prev = &pDesc->next;
+ pDesc->next = ShmList;
+ pDesc->prev = &ShmList;
+ ShmList = pDesc;
+
+ return pDesc;
+}
+
+static void
+shmdealloc(
+ ShmDescPtr pDesc)
+{
+#ifndef EARLY_REMOVE
+ shmctl(pDesc->shmid, IPC_RMID, (void *) 0);
+#endif
+ shmdt(pDesc->attach_addr);
+
+ if (pDesc->next) pDesc->next->prev = pDesc->prev;
+ *pDesc->prev = pDesc->next;
+ free(pDesc);
+}
+
+#endif
+
+/* Called when a font is closed. */
+void
+XF86BigfontFreeFontShm(
+ FontPtr pFont)
+{
+#ifdef HAS_SHM
+ ShmDescPtr pDesc;
+
+ /* If during shutdown of the server, XF86BigfontCleanup() has already
+ * called shmdealloc() for all segments, we don't need to do it here.
+ */
+ if (!ShmList)
+ return;
+
+ pDesc = (ShmDescPtr) FontGetPrivate(pFont, FontShmdescIndex);
+ if (pDesc)
+ shmdealloc(pDesc);
+#endif
+}
+
+/* Called upon fatal signal. */
+void
+XF86BigfontCleanup(void)
+{
+#ifdef HAS_SHM
+ while (ShmList)
+ shmdealloc(ShmList);
+#endif
+}
+
+/* Called when a server generation dies. */
+static void
+XF86BigfontResetProc(
+ ExtensionEntry* extEntry)
+{
+ /* This function is normally called from CloseDownExtensions(), called
+ * from main(). It will be followed by a call to FreeAllResources(),
+ * which will call XF86BigfontFreeFontShm() for each font. Thus it
+ * appears that we do not need to do anything in this function. --
+ * But I prefer to write robust code, and not keep shared memory lying
+ * around when it's not needed any more. (Someone might close down the
+ * extension without calling FreeAllResources()...)
+ */
+ XF86BigfontCleanup();
+}
+
+
+/* ========== Handling of extension specific requests ========== */
+
+static int
+ProcXF86BigfontQueryVersion(
+ ClientPtr client)
+{
+ xXF86BigfontQueryVersionReply reply;
+
+ REQUEST_SIZE_MATCH(xXF86BigfontQueryVersionReq);
+ reply.type = X_Reply;
+ reply.length = 0;
+ reply.sequenceNumber = client->sequence;
+ reply.majorVersion = SERVER_XF86BIGFONT_MAJOR_VERSION;
+ reply.minorVersion = SERVER_XF86BIGFONT_MINOR_VERSION;
+ reply.uid = geteuid();
+ reply.gid = getegid();
+#ifdef HAS_SHM
+ reply.signature = signature;
+#else
+ reply.signature = 0; /* This is redundant. Avoids uninitialized memory. */
+#endif
+ reply.capabilities =
+#ifdef HAS_SHM
+ (LocalClient(client) && !client->swapped ? XF86Bigfont_CAP_LocalShm : 0)
+#else
+ 0
+#endif
+ ; /* may add more bits here in future versions */
+ if (client->swapped) {
+ char tmp;
+ swaps(&reply.sequenceNumber, tmp);
+ swapl(&reply.length, tmp);
+ swaps(&reply.majorVersion, tmp);
+ swaps(&reply.minorVersion, tmp);
+ swapl(&reply.uid, tmp);
+ swapl(&reply.gid, tmp);
+ swapl(&reply.signature, tmp);
+ }
+ WriteToClient(client,
+ sizeof(xXF86BigfontQueryVersionReply), (char *)&reply);
+ return Success;
+}
+
+static void
+swapCharInfo(
+ xCharInfo *pCI)
+{
+ char tmp;
+
+ swaps(&pCI->leftSideBearing, tmp);
+ swaps(&pCI->rightSideBearing, tmp);
+ swaps(&pCI->characterWidth, tmp);
+ swaps(&pCI->ascent, tmp);
+ swaps(&pCI->descent, tmp);
+ swaps(&pCI->attributes, tmp);
+}
+
+/* static CARD32 hashCI (xCharInfo *p); */
+#define hashCI(p) \
+ (CARD32)(((p->leftSideBearing << 27) + (p->leftSideBearing >> 5) + \
+ (p->rightSideBearing << 23) + (p->rightSideBearing >> 9) + \
+ (p->characterWidth << 16) + \
+ (p->ascent << 11) + (p->descent << 6)) ^ p->attributes)
+
+static int
+ProcXF86BigfontQueryFont(
+ ClientPtr client)
+{
+ FontPtr pFont;
+ REQUEST(xXF86BigfontQueryFontReq);
+ CARD32 stuff_flags;
+ xCharInfo* pmax;
+ xCharInfo* pmin;
+ int nCharInfos;
+ int shmid;
+#ifdef HAS_SHM
+ ShmDescPtr pDesc = NULL;
+#else
+#define pDesc 0
+#endif
+ xCharInfo* pCI;
+ CARD16* pIndex2UniqIndex;
+ CARD16* pUniqIndex2Index;
+ CARD32 nUniqCharInfos;
+
+#if 0
+ REQUEST_SIZE_MATCH(xXF86BigfontQueryFontReq);
+#else
+ switch (client->req_len) {
+ case 2: /* client with version 1.0 libX11 */
+ stuff_flags = (LocalClient(client) && !client->swapped ? XF86Bigfont_FLAGS_Shm : 0);
+ break;
+ case 3: /* client with version 1.1 libX11 */
+ stuff_flags = stuff->flags;
+ break;
+ default:
+ return BadLength;
+ }
+#endif
+ if (dixLookupFontable(&pFont, stuff->id, client, DixGetAttrAccess) != Success)
+ return BadFont; /* procotol spec says only error is BadFont */
+
+ pmax = FONTINKMAX(pFont);
+ pmin = FONTINKMIN(pFont);
+ nCharInfos =
+ (pmax->rightSideBearing == pmin->rightSideBearing
+ && pmax->leftSideBearing == pmin->leftSideBearing
+ && pmax->descent == pmin->descent
+ && pmax->ascent == pmin->ascent
+ && pmax->characterWidth == pmin->characterWidth)
+ ? 0 : N2dChars(pFont);
+ shmid = -1;
+ pCI = NULL;
+ pIndex2UniqIndex = NULL;
+ pUniqIndex2Index = NULL;
+ nUniqCharInfos = 0;
+
+ if (nCharInfos > 0) {
+#ifdef HAS_SHM
+ if (!badSysCall)
+ pDesc = (ShmDescPtr) FontGetPrivate(pFont, FontShmdescIndex);
+ if (pDesc) {
+ pCI = (xCharInfo *) pDesc->attach_addr;
+ if (stuff_flags & XF86Bigfont_FLAGS_Shm)
+ shmid = pDesc->shmid;
+ } else {
+ if (stuff_flags & XF86Bigfont_FLAGS_Shm && !badSysCall)
+ pDesc = shmalloc(nCharInfos * sizeof(xCharInfo)
+ + sizeof(CARD32));
+ if (pDesc) {
+ pCI = (xCharInfo *) pDesc->attach_addr;
+ shmid = pDesc->shmid;
+ } else {
+#endif
+ pCI = malloc(nCharInfos * sizeof(xCharInfo));
+ if (!pCI)
+ return BadAlloc;
+#ifdef HAS_SHM
+ }
+#endif
+ /* Fill nCharInfos starting at pCI. */
+ {
+ xCharInfo* prCI = pCI;
+ int ninfos = 0;
+ int ncols = pFont->info.lastCol - pFont->info.firstCol + 1;
+ int row;
+ for (row = pFont->info.firstRow;
+ row <= pFont->info.lastRow && ninfos < nCharInfos;
+ row++) {
+ unsigned char chars[512];
+ xCharInfo* tmpCharInfos[256];
+ unsigned long count;
+ int col;
+ unsigned long i;
+ i = 0;
+ for (col = pFont->info.firstCol;
+ col <= pFont->info.lastCol;
+ col++) {
+ chars[i++] = row;
+ chars[i++] = col;
+ }
+ (*pFont->get_metrics) (pFont, ncols, chars, TwoD16Bit,
+ &count, tmpCharInfos);
+ for (i = 0; i < count && ninfos < nCharInfos; i++) {
+ *prCI++ = *tmpCharInfos[i];
+ ninfos++;
+ }
+ }
+ }
+#ifdef HAS_SHM
+ if (pDesc && !badSysCall) {
+ *(CARD32 *)(pCI + nCharInfos) = signature;
+ if (!FontSetPrivate(pFont, FontShmdescIndex, pDesc)) {
+ shmdealloc(pDesc);
+ return BadAlloc;
+ }
+ }
+ }
+#endif
+ if (shmid == -1) {
+ /* Cannot use shared memory, so remove-duplicates the xCharInfos
+ using a temporary hash table. */
+ /* Note that CARD16 is suitable as index type, because
+ nCharInfos <= 0x10000. */
+ CARD32 hashModulus;
+ CARD16* pHash2UniqIndex;
+ CARD16* pUniqIndex2NextUniqIndex;
+ CARD32 NextIndex;
+ CARD32 NextUniqIndex;
+ CARD16* tmp;
+ CARD32 i, j;
+
+ hashModulus = 67;
+ if (hashModulus > nCharInfos+1)
+ hashModulus = nCharInfos+1;
+
+ tmp = malloc((4*nCharInfos+1) * sizeof(CARD16));
+ if (!tmp) {
+ if (!pDesc) free(pCI);
+ return BadAlloc;
+ }
+ pIndex2UniqIndex = tmp;
+ /* nCharInfos elements */
+ pUniqIndex2Index = tmp + nCharInfos;
+ /* max. nCharInfos elements */
+ pUniqIndex2NextUniqIndex = tmp + 2*nCharInfos;
+ /* max. nCharInfos elements */
+ pHash2UniqIndex = tmp + 3*nCharInfos;
+ /* hashModulus (<= nCharInfos+1) elements */
+
+ /* Note that we can use 0xffff as end-of-list indicator, because
+ even if nCharInfos = 0x10000, 0xffff can not occur as valid
+ entry before the last element has been inserted. And once the
+ last element has been inserted, we don't need the hash table
+ any more. */
+ for (j = 0; j < hashModulus; j++)
+ pHash2UniqIndex[j] = (CARD16)(-1);
+
+ NextUniqIndex = 0;
+ for (NextIndex = 0; NextIndex < nCharInfos; NextIndex++) {
+ xCharInfo* p = &pCI[NextIndex];
+ CARD32 hashCode = hashCI(p) % hashModulus;
+ for (i = pHash2UniqIndex[hashCode];
+ i != (CARD16)(-1);
+ i = pUniqIndex2NextUniqIndex[i]) {
+ j = pUniqIndex2Index[i];
+ if (pCI[j].leftSideBearing == p->leftSideBearing
+ && pCI[j].rightSideBearing == p->rightSideBearing
+ && pCI[j].characterWidth == p->characterWidth
+ && pCI[j].ascent == p->ascent
+ && pCI[j].descent == p->descent
+ && pCI[j].attributes == p->attributes)
+ break;
+ }
+ if (i != (CARD16)(-1)) {
+ /* Found *p at Index j, UniqIndex i */
+ pIndex2UniqIndex[NextIndex] = i;
+ } else {
+ /* Allocate a new entry in the Uniq table */
+ if (hashModulus <= 2*NextUniqIndex
+ && hashModulus < nCharInfos+1) {
+ /* Time to increate hash table size */
+ hashModulus = 2*hashModulus+1;
+ if (hashModulus > nCharInfos+1)
+ hashModulus = nCharInfos+1;
+ for (j = 0; j < hashModulus; j++)
+ pHash2UniqIndex[j] = (CARD16)(-1);
+ for (i = 0; i < NextUniqIndex; i++)
+ pUniqIndex2NextUniqIndex[i] = (CARD16)(-1);
+ for (i = 0; i < NextUniqIndex; i++) {
+ j = pUniqIndex2Index[i];
+ p = &pCI[j];
+ hashCode = hashCI(p) % hashModulus;
+ pUniqIndex2NextUniqIndex[i] = pHash2UniqIndex[hashCode];
+ pHash2UniqIndex[hashCode] = i;
+ }
+ p = &pCI[NextIndex];
+ hashCode = hashCI(p) % hashModulus;
+ }
+ i = NextUniqIndex++;
+ pUniqIndex2NextUniqIndex[i] = pHash2UniqIndex[hashCode];
+ pHash2UniqIndex[hashCode] = i;
+ pUniqIndex2Index[i] = NextIndex;
+ pIndex2UniqIndex[NextIndex] = i;
+ }
+ }
+ nUniqCharInfos = NextUniqIndex;
+ /* fprintf(stderr, "font metrics: nCharInfos = %d, nUniqCharInfos = %d, hashModulus = %d\n", nCharInfos, nUniqCharInfos, hashModulus); */
+ }
+ }
+
+ {
+ int nfontprops = pFont->info.nprops;
+ int rlength =
+ sizeof(xXF86BigfontQueryFontReply)
+ + nfontprops * sizeof(xFontProp)
+ + (nCharInfos > 0 && shmid == -1
+ ? nUniqCharInfos * sizeof(xCharInfo)
+ + (nCharInfos+1)/2 * 2 * sizeof(CARD16)
+ : 0);
+ xXF86BigfontQueryFontReply* reply = malloc(rlength);
+ char* p;
+ if (!reply) {
+ if (nCharInfos > 0) {
+ if (shmid == -1) free(pIndex2UniqIndex);
+ if (!pDesc) free(pCI);
+ }
+ return BadAlloc;
+ }
+ reply->type = X_Reply;
+ reply->length = bytes_to_int32(rlength - sizeof(xGenericReply));
+ reply->sequenceNumber = client->sequence;
+ reply->minBounds = pFont->info.ink_minbounds;
+ reply->maxBounds = pFont->info.ink_maxbounds;
+ reply->minCharOrByte2 = pFont->info.firstCol;
+ reply->maxCharOrByte2 = pFont->info.lastCol;
+ reply->defaultChar = pFont->info.defaultCh;
+ reply->nFontProps = pFont->info.nprops;
+ reply->drawDirection = pFont->info.drawDirection;
+ reply->minByte1 = pFont->info.firstRow;
+ reply->maxByte1 = pFont->info.lastRow;
+ reply->allCharsExist = pFont->info.allExist;
+ reply->fontAscent = pFont->info.fontAscent;
+ reply->fontDescent = pFont->info.fontDescent;
+ reply->nCharInfos = nCharInfos;
+ reply->nUniqCharInfos = nUniqCharInfos;
+ reply->shmid = shmid;
+ reply->shmsegoffset = 0;
+ if (client->swapped) {
+ char tmp;
+ swaps(&reply->sequenceNumber, tmp);
+ swapl(&reply->length, tmp);
+ swapCharInfo(&reply->minBounds);
+ swapCharInfo(&reply->maxBounds);
+ swaps(&reply->minCharOrByte2, tmp);
+ swaps(&reply->maxCharOrByte2, tmp);
+ swaps(&reply->defaultChar, tmp);
+ swaps(&reply->nFontProps, tmp);
+ swaps(&reply->fontAscent, tmp);
+ swaps(&reply->fontDescent, tmp);
+ swapl(&reply->nCharInfos, tmp);
+ swapl(&reply->nUniqCharInfos, tmp);
+ swapl(&reply->shmid, tmp);
+ swapl(&reply->shmsegoffset, tmp);
+ }
+ p = (char*) &reply[1];
+ {
+ FontPropPtr pFP;
+ xFontProp* prFP;
+ int i;
+ for (i = 0, pFP = pFont->info.props, prFP = (xFontProp *) p;
+ i < nfontprops;
+ i++, pFP++, prFP++) {
+ prFP->name = pFP->name;
+ prFP->value = pFP->value;
+ if (client->swapped) {
+ char tmp;
+ swapl(&prFP->name, tmp);
+ swapl(&prFP->value, tmp);
+ }
+ }
+ p = (char*) prFP;
+ }
+ if (nCharInfos > 0 && shmid == -1) {
+ xCharInfo* pci;
+ CARD16* ps;
+ int i, j;
+ pci = (xCharInfo*) p;
+ for (i = 0; i < nUniqCharInfos; i++, pci++) {
+ *pci = pCI[pUniqIndex2Index[i]];
+ if (client->swapped)
+ swapCharInfo(pci);
+ }
+ ps = (CARD16*) pci;
+ for (j = 0; j < nCharInfos; j++, ps++) {
+ *ps = pIndex2UniqIndex[j];
+ if (client->swapped) {
+ char tmp;
+ swaps(ps, tmp);
+ }
+ }
+ }
+ WriteToClient(client, rlength, (char *)reply);
+ free(reply);
+ if (nCharInfos > 0) {
+ if (shmid == -1) free(pIndex2UniqIndex);
+ if (!pDesc) free(pCI);
+ }
+ return Success;
+ }
+}
+
+static int
+ProcXF86BigfontDispatch(
+ ClientPtr client)
+{
+ REQUEST(xReq);
+
+ switch (stuff->data) {
+ case X_XF86BigfontQueryVersion:
+ return ProcXF86BigfontQueryVersion(client);
+ case X_XF86BigfontQueryFont:
+ return ProcXF86BigfontQueryFont(client);
+ default:
+ return BadRequest;
+ }
+}
+
+static int
+SProcXF86BigfontQueryVersion(
+ ClientPtr client)
+{
+ REQUEST(xXF86BigfontQueryVersionReq);
+ char tmp;
+
+ swaps(&stuff->length, tmp);
+ return ProcXF86BigfontQueryVersion(client);
+}
+
+static int
+SProcXF86BigfontQueryFont(
+ ClientPtr client)
+{
+ REQUEST(xXF86BigfontQueryFontReq);
+ char tmp;
+
+ swaps(&stuff->length, tmp);
+ REQUEST_SIZE_MATCH(xXF86BigfontQueryFontReq);
+ swapl(&stuff->id, tmp);
+ return ProcXF86BigfontQueryFont(client);
+}
+
+static int
+SProcXF86BigfontDispatch(
+ ClientPtr client)
+{
+ REQUEST(xReq);
+
+ switch (stuff->data) {
+ case X_XF86BigfontQueryVersion:
+ return SProcXF86BigfontQueryVersion(client);
+ case X_XF86BigfontQueryFont:
+ return SProcXF86BigfontQueryFont(client);
+ default:
+ return BadRequest;
+ }
+}
diff --git a/xorg-server/configure.ac b/xorg-server/configure.ac
index a5967ad03..1ceffe7cb 100644
--- a/xorg-server/configure.ac
+++ b/xorg-server/configure.ac
@@ -2224,7 +2224,6 @@ hw/xfree86/os-support/bus/Makefile
hw/xfree86/os-support/hurd/Makefile
hw/xfree86/os-support/misc/Makefile
hw/xfree86/os-support/linux/Makefile
-hw/xfree86/os-support/sco/Makefile
hw/xfree86/os-support/solaris/Makefile
hw/xfree86/parser/Makefile
hw/xfree86/ramdac/Makefile
diff --git a/xorg-server/dix/dixfonts.c b/xorg-server/dix/dixfonts.c
index ce9309f40..9cd8e3bbd 100644
--- a/xorg-server/dix/dixfonts.c
+++ b/xorg-server/dix/dixfonts.c
@@ -1,2086 +1,2086 @@
-/************************************************************************
-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.
-
-************************************************************************/
-/* The panoramix components contained the following notice */
-/*
-Copyright (c) 1991, 1997 Digital Equipment Corporation, Maynard, Massachusetts.
-
-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.
-
-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
-DIGITAL EQUIPMENT CORPORATION BE LIABLE FOR ANY CLAIM, DAMAGES, INCLUDING,
-BUT NOT LIMITED TO CONSEQUENTIAL OR INCIDENTAL 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 Digital Equipment Corporation
-shall not be used in advertising or otherwise to promote the sale, use or other
-dealings in this Software without prior written authorization from Digital
-Equipment Corporation.
-
-******************************************************************/
-
-#ifdef HAVE_DIX_CONFIG_H
-#include <dix-config.h>
-#endif
-
-#include <X11/X.h>
-#include <X11/Xmd.h>
-#include <X11/Xproto.h>
-#include "scrnintstr.h"
-#include "resource.h"
-#include "dixstruct.h"
-#include "cursorstr.h"
-#include "misc.h"
-#include "opaque.h"
-#include "dixfontstr.h"
-#include "closestr.h"
-#include "dixfont.h"
-#include "xace.h"
-
-#ifdef DEBUG
-#include <stdio.h>
-#endif
-
-#ifdef XF86BIGFONT
-#include "xf86bigfontsrv.h"
-#endif
-
-#define QUERYCHARINFO(pci, pr) *(pr) = (pci)->metrics
-
-extern pointer fosNaturalParams;
-extern FontPtr defaultFont;
-
-static FontPathElementPtr *font_path_elements = (FontPathElementPtr *) 0;
-static int num_fpes = 0;
-static FPEFunctions *fpe_functions = (FPEFunctions *) 0;
-static int num_fpe_types = 0;
-
-static unsigned char *font_path_string;
-
-static int num_slept_fpes = 0;
-static int size_slept_fpes = 0;
-static FontPathElementPtr *slept_fpes = (FontPathElementPtr *) 0;
-static FontPatternCachePtr patternCache;
-
-static int
-FontToXError(int err)
-{
- switch (err) {
- case Successful:
- return Success;
- case AllocError:
- return BadAlloc;
- case BadFontName:
- return BadName;
- case BadFontPath:
- case BadFontFormat: /* is there something better? */
- case BadCharRange:
- return BadValue;
- default:
- return err;
- }
-}
-
-static int
-LoadGlyphs(ClientPtr client, FontPtr pfont, unsigned nchars, int item_size,
- unsigned char *data)
-{
- if (fpe_functions[pfont->fpe->type].load_glyphs)
- return (*fpe_functions[pfont->fpe->type].load_glyphs)
- (client, pfont, 0, nchars, item_size, data);
- else
- return Successful;
-}
-
-/*
- * adding RT_FONT prevents conflict with default cursor font
- */
-Bool
-SetDefaultFont(char *defaultfontname)
-{
- int err;
- FontPtr pf;
- XID fid;
- static FontPtr last_pf;
-
- fid = FakeClientID(0);
- err = OpenFont(serverClient, fid, FontLoadAll | FontOpenSync,
- (unsigned) strlen(defaultfontname), defaultfontname);
- if (err != Success)
- return FALSE;
- err = dixLookupResourceByType((pointer *)&pf, fid, RT_FONT, serverClient,
- DixReadAccess);
- if (err == Success) last_pf = pf;
- if (last_pf == (FontPtr) NULL)
- return FALSE;
- defaultFont = last_pf;
- return TRUE;
-}
-
-/*
- * note that the font wakeup queue is not refcounted. this is because
- * an fpe needs to be added when it's inited, and removed when it's finally
- * freed, in order to handle any data that isn't requested, like FS events.
- *
- * since the only thing that should call these routines is the renderer's
- * init_fpe() and free_fpe(), there shouldn't be any problem in using
- * freed data.
- */
-void
-QueueFontWakeup(FontPathElementPtr fpe)
-{
- int i;
- FontPathElementPtr *new;
-
- for (i = 0; i < num_slept_fpes; i++) {
- if (slept_fpes[i] == fpe) {
- return;
- }
- }
- if (num_slept_fpes == size_slept_fpes) {
- new = (FontPathElementPtr *)
- realloc(slept_fpes,
- sizeof(FontPathElementPtr) * (size_slept_fpes + 4));
- if (!new)
- return;
- slept_fpes = new;
- size_slept_fpes += 4;
- }
- slept_fpes[num_slept_fpes] = fpe;
- num_slept_fpes++;
-}
-
-void
-RemoveFontWakeup(FontPathElementPtr fpe)
-{
- int i,
- j;
-
- for (i = 0; i < num_slept_fpes; i++) {
- if (slept_fpes[i] == fpe) {
- for (j = i; j < num_slept_fpes; j++) {
- slept_fpes[j] = slept_fpes[j + 1];
- }
- num_slept_fpes--;
- return;
- }
- }
-}
-
-void
-FontWakeup(pointer data, int count, pointer LastSelectMask)
-{
- int i;
- FontPathElementPtr fpe;
-
- if (count < 0)
- return;
- /* wake up any fpe's that may be waiting for information */
- for (i = 0; i < num_slept_fpes; i++) {
- fpe = slept_fpes[i];
- (void) (*fpe_functions[fpe->type].wakeup_fpe) (fpe, LastSelectMask);
- }
-}
-
-/* XXX -- these two funcs may want to be broken into macros */
-static void
-UseFPE(FontPathElementPtr fpe)
-{
- fpe->refcount++;
-}
-
-static void
-FreeFPE (FontPathElementPtr fpe)
-{
- fpe->refcount--;
- if (fpe->refcount == 0) {
- (*fpe_functions[fpe->type].free_fpe) (fpe);
- free(fpe->name);
- free(fpe);
- }
-}
-
-static Bool
-doOpenFont(ClientPtr client, OFclosurePtr c)
-{
- FontPtr pfont = NullFont;
- FontPathElementPtr fpe = NULL;
- ScreenPtr pScr;
- int err = Successful;
- int i;
- char *alias,
- *newname;
- int newlen;
- int aliascount = 20;
- /*
- * Decide at runtime what FontFormat to use.
- */
- Mask FontFormat =
-
- ((screenInfo.imageByteOrder == LSBFirst) ?
- BitmapFormatByteOrderLSB : BitmapFormatByteOrderMSB) |
-
- ((screenInfo.bitmapBitOrder == LSBFirst) ?
- BitmapFormatBitOrderLSB : BitmapFormatBitOrderMSB) |
-
- BitmapFormatImageRectMin |
-
-#if GLYPHPADBYTES == 1
- BitmapFormatScanlinePad8 |
-#endif
-
-#if GLYPHPADBYTES == 2
- BitmapFormatScanlinePad16 |
-#endif
-
-#if GLYPHPADBYTES == 4
- BitmapFormatScanlinePad32 |
-#endif
-
-#if GLYPHPADBYTES == 8
- BitmapFormatScanlinePad64 |
-#endif
-
- BitmapFormatScanlineUnit8;
-
- if (client->clientGone)
- {
- if (c->current_fpe < c->num_fpes)
- {
- fpe = c->fpe_list[c->current_fpe];
- (*fpe_functions[fpe->type].client_died) ((pointer) client, fpe);
- }
- err = Successful;
- goto bail;
- }
- while (c->current_fpe < c->num_fpes) {
- fpe = c->fpe_list[c->current_fpe];
- err = (*fpe_functions[fpe->type].open_font)
- ((pointer) client, fpe, c->flags,
- c->fontname, c->fnamelen, FontFormat,
- BitmapFormatMaskByte |
- BitmapFormatMaskBit |
- BitmapFormatMaskImageRectangle |
- BitmapFormatMaskScanLinePad |
- BitmapFormatMaskScanLineUnit,
- c->fontid, &pfont, &alias,
- c->non_cachable_font && c->non_cachable_font->fpe == fpe ?
- c->non_cachable_font :
- (FontPtr)0);
-
- if (err == FontNameAlias && alias) {
- newlen = strlen(alias);
- newname = (char *) realloc(c->fontname, newlen);
- if (!newname) {
- err = AllocError;
- break;
- }
- memmove(newname, alias, newlen);
- c->fontname = newname;
- c->fnamelen = newlen;
- c->current_fpe = 0;
- if (--aliascount <= 0) {
- /* We've tried resolving this alias 20 times, we're
- * probably stuck in an infinite loop of aliases pointing
- * to each other - time to take emergency exit!
- */
- err = BadImplementation;
- break;
- }
- continue;
- }
- if (err == BadFontName) {
- c->current_fpe++;
- continue;
- }
- if (err == Suspended) {
- if (!ClientIsAsleep(client))
- ClientSleep(client, (ClientSleepProcPtr)doOpenFont, c);
- else
- goto xinerama_sleep;
- return TRUE;
- }
- break;
- }
-
- if (err != Successful)
- goto bail;
- if (!pfont) {
- err = BadFontName;
- goto bail;
- }
- /* check values for firstCol, lastCol, firstRow, and lastRow */
- if (pfont->info.firstCol > pfont->info.lastCol ||
- pfont->info.firstRow > pfont->info.lastRow ||
- pfont->info.lastCol - pfont->info.firstCol > 255) {
- err = AllocError;
- goto bail;
- }
- if (!pfont->fpe)
- pfont->fpe = fpe;
- pfont->refcnt++;
- if (pfont->refcnt == 1) {
- UseFPE(pfont->fpe);
- for (i = 0; i < screenInfo.numScreens; i++) {
- pScr = screenInfo.screens[i];
- if (pScr->RealizeFont)
- {
- if (!(*pScr->RealizeFont) (pScr, pfont))
- {
- CloseFont (pfont, (Font) 0);
- err = AllocError;
- goto bail;
- }
- }
- }
- }
- if (!AddResource(c->fontid, RT_FONT, (pointer) pfont)) {
- err = AllocError;
- goto bail;
- }
- if (patternCache && pfont != c->non_cachable_font)
- CacheFontPattern(patternCache, c->origFontName, c->origFontNameLen,
- pfont);
-bail:
- if (err != Successful && c->client != serverClient) {
- SendErrorToClient(c->client, X_OpenFont, 0,
- c->fontid, FontToXError(err));
- }
- ClientWakeup(c->client);
-xinerama_sleep:
- for (i = 0; i < c->num_fpes; i++) {
- FreeFPE(c->fpe_list[i]);
- }
- free(c->fpe_list);
- free(c->fontname);
- free(c);
- return TRUE;
-}
-
-int
-OpenFont(ClientPtr client, XID fid, Mask flags, unsigned lenfname, char *pfontname)
-{
- OFclosurePtr c;
- int i;
- FontPtr cached = (FontPtr)0;
-
-#ifdef FONTDEBUG
- char *f;
- f = malloc(lenfname + 1);
- memmove(f, pfontname, lenfname);
- f[lenfname] = '\0';
- ErrorF("[dix] OpenFont: fontname is \"%s\"\n", f);
- free(f);
-#endif
- if (!lenfname || lenfname > XLFDMAXFONTNAMELEN)
- return BadName;
- if (patternCache)
- {
-
- /*
- ** Check name cache. If we find a cached version of this font that
- ** is cachable, immediately satisfy the request with it. If we find
- ** a cached version of this font that is non-cachable, we do not
- ** satisfy the request with it. Instead, we pass the FontPtr to the
- ** FPE's open_font code (the fontfile FPE in turn passes the
- ** information to the rasterizer; the fserve FPE ignores it).
- **
- ** Presumably, the font is marked non-cachable because the FPE has
- ** put some licensing restrictions on it. If the FPE, using
- ** whatever logic it relies on, determines that it is willing to
- ** share this existing font with the client, then it has the option
- ** to return the FontPtr we passed it as the newly-opened font.
- ** This allows the FPE to exercise its licensing logic without
- ** having to create another instance of a font that already exists.
- */
-
- cached = FindCachedFontPattern(patternCache, pfontname, lenfname);
- if (cached && cached->info.cachable)
- {
- if (!AddResource(fid, RT_FONT, (pointer) cached))
- return BadAlloc;
- cached->refcnt++;
- return Success;
- }
- }
- c = malloc(sizeof(OFclosureRec));
- if (!c)
- return BadAlloc;
- c->fontname = malloc(lenfname);
- c->origFontName = pfontname;
- c->origFontNameLen = lenfname;
- if (!c->fontname) {
- free(c);
- return BadAlloc;
- }
- /*
- * copy the current FPE list, so that if it gets changed by another client
- * while we're blocking, the request still appears atomic
- */
- c->fpe_list = malloc(sizeof(FontPathElementPtr) * num_fpes);
- if (!c->fpe_list) {
- free(c->fontname);
- free(c);
- return BadAlloc;
- }
- memmove(c->fontname, pfontname, lenfname);
- for (i = 0; i < num_fpes; i++) {
- c->fpe_list[i] = font_path_elements[i];
- UseFPE(c->fpe_list[i]);
- }
- c->client = client;
- c->fontid = fid;
- c->current_fpe = 0;
- c->num_fpes = num_fpes;
- c->fnamelen = lenfname;
- c->flags = flags;
- c->non_cachable_font = cached;
-
- (void) doOpenFont(client, c);
- return Success;
-}
-
-/**
- * Decrement font's ref count, and free storage if ref count equals zero
- *
- * \param value must conform to DeleteType
- */
-int
-CloseFont(pointer value, XID fid)
-{
- int nscr;
- ScreenPtr pscr;
- FontPathElementPtr fpe;
- FontPtr pfont = (FontPtr)value;
-
- if (pfont == NullFont)
- return Success;
- if (--pfont->refcnt == 0) {
- if (patternCache)
- RemoveCachedFontPattern (patternCache, pfont);
- /*
- * since the last reference is gone, ask each screen to free any
- * storage it may have allocated locally for it.
- */
- for (nscr = 0; nscr < screenInfo.numScreens; nscr++) {
- pscr = screenInfo.screens[nscr];
- if (pscr->UnrealizeFont)
- (*pscr->UnrealizeFont) (pscr, pfont);
- }
- if (pfont == defaultFont)
- defaultFont = NULL;
-#ifdef XF86BIGFONT
- XF86BigfontFreeFontShm(pfont);
-#endif
- fpe = pfont->fpe;
- (*fpe_functions[fpe->type].close_font) (fpe, pfont);
- FreeFPE(fpe);
- }
- return Success;
-}
-
-
-/***====================================================================***/
-
-/**
- * Sets up pReply as the correct QueryFontReply for pFont with the first
- * nProtoCCIStructs char infos.
- *
- * \param pReply caller must allocate this storage
- */
-void
-QueryFont(FontPtr pFont, xQueryFontReply *pReply, int nProtoCCIStructs)
-{
- FontPropPtr pFP;
- int r,
- c,
- i;
- xFontProp *prFP;
- xCharInfo *prCI;
- xCharInfo *charInfos[256];
- unsigned char chars[512];
- int ninfos;
- unsigned long ncols;
- unsigned long count;
-
- /* pr->length set in dispatch */
- pReply->minCharOrByte2 = pFont->info.firstCol;
- pReply->defaultChar = pFont->info.defaultCh;
- pReply->maxCharOrByte2 = pFont->info.lastCol;
- pReply->drawDirection = pFont->info.drawDirection;
- pReply->allCharsExist = pFont->info.allExist;
- pReply->minByte1 = pFont->info.firstRow;
- pReply->maxByte1 = pFont->info.lastRow;
- pReply->fontAscent = pFont->info.fontAscent;
- pReply->fontDescent = pFont->info.fontDescent;
-
- pReply->minBounds = pFont->info.ink_minbounds;
- pReply->maxBounds = pFont->info.ink_maxbounds;
-
- pReply->nFontProps = pFont->info.nprops;
- pReply->nCharInfos = nProtoCCIStructs;
-
- for (i = 0, pFP = pFont->info.props, prFP = (xFontProp *) (&pReply[1]);
- i < pFont->info.nprops;
- i++, pFP++, prFP++) {
- prFP->name = pFP->name;
- prFP->value = pFP->value;
- }
-
- ninfos = 0;
- ncols = (unsigned long) (pFont->info.lastCol - pFont->info.firstCol + 1);
- prCI = (xCharInfo *) (prFP);
- for (r = pFont->info.firstRow;
- ninfos < nProtoCCIStructs && r <= (int)pFont->info.lastRow;
- r++) {
- i = 0;
- for (c = pFont->info.firstCol; c <= (int)pFont->info.lastCol; c++) {
- chars[i++] = r;
- chars[i++] = c;
- }
- (*pFont->get_metrics) (pFont, ncols, chars,
- TwoD16Bit, &count, charInfos);
- i = 0;
- for (i = 0; i < (int) count && ninfos < nProtoCCIStructs; i++) {
- *prCI = *charInfos[i];
- prCI++;
- ninfos++;
- }
- }
- return;
-}
-
-static Bool
-doListFontsAndAliases(ClientPtr client, LFclosurePtr c)
-{
- FontPathElementPtr fpe;
- int err = Successful;
- FontNamesPtr names = NULL;
- char *name, *resolved=NULL;
- int namelen, resolvedlen;
- int nnames;
- int stringLens;
- int i;
- xListFontsReply reply;
- char *bufptr;
- char *bufferStart;
- int aliascount = 0;
-
- if (client->clientGone)
- {
- if (c->current.current_fpe < c->num_fpes)
- {
- fpe = c->fpe_list[c->current.current_fpe];
- (*fpe_functions[fpe->type].client_died) ((pointer) client, fpe);
- }
- err = Successful;
- goto bail;
- }
-
- if (!c->current.patlen)
- goto finish;
-
- while (c->current.current_fpe < c->num_fpes) {
- fpe = c->fpe_list[c->current.current_fpe];
- err = Successful;
-
- if (!fpe_functions[fpe->type].start_list_fonts_and_aliases)
- {
- /* This FPE doesn't support/require list_fonts_and_aliases */
-
- err = (*fpe_functions[fpe->type].list_fonts)
- ((pointer) c->client, fpe, c->current.pattern,
- c->current.patlen, c->current.max_names - c->names->nnames,
- c->names);
-
- if (err == Suspended) {
- if (!ClientIsAsleep(client))
- ClientSleep(client,
- (ClientSleepProcPtr)doListFontsAndAliases,
- c);
- else
- goto xinerama_sleep;
- return TRUE;
- }
-
- err = BadFontName;
- }
- else
- {
- /* Start of list_fonts_and_aliases functionality. Modeled
- after list_fonts_with_info in that it resolves aliases,
- except that the information collected from FPEs is just
- names, not font info. Each list_next_font_or_alias()
- returns either a name into name/namelen or an alias into
- name/namelen and its target name into resolved/resolvedlen.
- The code at this level then resolves the alias by polling
- the FPEs. */
-
- if (!c->current.list_started) {
- err = (*fpe_functions[fpe->type].start_list_fonts_and_aliases)
- ((pointer) c->client, fpe, c->current.pattern,
- c->current.patlen, c->current.max_names - c->names->nnames,
- &c->current.private);
- if (err == Suspended) {
- if (!ClientIsAsleep(client))
- ClientSleep(client,
- (ClientSleepProcPtr)doListFontsAndAliases,
- c);
- else
- goto xinerama_sleep;
- return TRUE;
- }
- if (err == Successful)
- c->current.list_started = TRUE;
- }
- if (err == Successful) {
- char *tmpname;
- name = 0;
- err = (*fpe_functions[fpe->type].list_next_font_or_alias)
- ((pointer) c->client, fpe, &name, &namelen, &tmpname,
- &resolvedlen, c->current.private);
- if (err == Suspended) {
- if (ClientIsAsleep(client))
- ClientSleep(client,
- (ClientSleepProcPtr)doListFontsAndAliases,
- c);
- else
- goto xinerama_sleep;
- return TRUE;
- }
- if (err == FontNameAlias) {
- free(resolved);
- resolved = malloc(resolvedlen + 1);
- if (resolved)
- memmove(resolved, tmpname, resolvedlen + 1);
- }
- }
-
- if (err == Successful)
- {
- if (c->haveSaved)
- {
- if (c->savedName)
- (void)AddFontNamesName(c->names, c->savedName,
- c->savedNameLen);
- }
- else
- (void)AddFontNamesName(c->names, name, namelen);
- }
-
- /*
- * When we get an alias back, save our state and reset back to
- * the start of the FPE looking for the specified name. As
- * soon as a real font is found for the alias, pop back to the
- * old state
- */
- else if (err == FontNameAlias) {
- char tmp_pattern[XLFDMAXFONTNAMELEN];
- /*
- * when an alias recurses, we need to give
- * the last FPE a chance to clean up; so we call
- * it again, and assume that the error returned
- * is BadFontName, indicating the alias resolution
- * is complete.
- */
- memmove(tmp_pattern, resolved, resolvedlen);
- if (c->haveSaved)
- {
- char *tmpname;
- int tmpnamelen;
-
- tmpname = 0;
- (void) (*fpe_functions[fpe->type].list_next_font_or_alias)
- ((pointer) c->client, fpe, &tmpname, &tmpnamelen,
- &tmpname, &tmpnamelen, c->current.private);
- if (--aliascount <= 0)
- {
- err = BadFontName;
- goto ContBadFontName;
- }
- }
- else
- {
- c->saved = c->current;
- c->haveSaved = TRUE;
- free(c->savedName);
- c->savedName = malloc(namelen + 1);
- if (c->savedName)
- memmove(c->savedName, name, namelen + 1);
- c->savedNameLen = namelen;
- aliascount = 20;
- }
- memmove(c->current.pattern, tmp_pattern, resolvedlen);
- c->current.patlen = resolvedlen;
- c->current.max_names = c->names->nnames + 1;
- c->current.current_fpe = -1;
- c->current.private = 0;
- err = BadFontName;
- }
- }
- /*
- * At the end of this FPE, step to the next. If we've finished
- * processing an alias, pop state back. If we've collected enough
- * font names, quit.
- */
- if (err == BadFontName) {
- ContBadFontName: ;
- c->current.list_started = FALSE;
- c->current.current_fpe++;
- err = Successful;
- if (c->haveSaved)
- {
- if (c->names->nnames == c->current.max_names ||
- c->current.current_fpe == c->num_fpes) {
- c->haveSaved = FALSE;
- c->current = c->saved;
- /* Give the saved namelist a chance to clean itself up */
- continue;
- }
- }
- if (c->names->nnames == c->current.max_names)
- break;
- }
- }
-
- /*
- * send the reply
- */
- if (err != Successful) {
- SendErrorToClient(client, X_ListFonts, 0, 0, FontToXError(err));
- goto bail;
- }
-
-finish:
-
- names = c->names;
- nnames = names->nnames;
- client = c->client;
- stringLens = 0;
- for (i = 0; i < nnames; i++)
- stringLens += (names->length[i] <= 255) ? names->length[i] : 0;
-
- memset(&reply, 0, sizeof(xListFontsReply));
- reply.type = X_Reply;
- reply.length = bytes_to_int32(stringLens + nnames);
- reply.nFonts = nnames;
- reply.sequenceNumber = client->sequence;
-
- bufptr = bufferStart = malloc(reply.length << 2);
-
- if (!bufptr && reply.length) {
- SendErrorToClient(client, X_ListFonts, 0, 0, BadAlloc);
- goto bail;
- }
- /*
- * since WriteToClient long word aligns things, copy to temp buffer and
- * write all at once
- */
- for (i = 0; i < nnames; i++) {
- if (names->length[i] > 255)
- reply.nFonts--;
- else
- {
- *bufptr++ = names->length[i];
- memmove( bufptr, names->names[i], names->length[i]);
- bufptr += names->length[i];
- }
- }
- nnames = reply.nFonts;
- reply.length = bytes_to_int32(stringLens + nnames);
- client->pSwapReplyFunc = ReplySwapVector[X_ListFonts];
- WriteSwappedDataToClient(client, sizeof(xListFontsReply), &reply);
- (void) WriteToClient(client, stringLens + nnames, bufferStart);
- free(bufferStart);
-
-bail:
- ClientWakeup(client);
-xinerama_sleep:
- for (i = 0; i < c->num_fpes; i++)
- FreeFPE(c->fpe_list[i]);
- free(c->fpe_list);
- free(c->savedName);
- FreeFontNames(names);
- free(c);
- free(resolved);
- return TRUE;
-}
-
-int
-ListFonts(ClientPtr client, unsigned char *pattern, unsigned length,
- unsigned max_names)
-{
- int i;
- LFclosurePtr c;
-
- /*
- * The right error to return here would be BadName, however the
- * specification does not allow for a Name error on this request.
- * Perhaps a better solution would be to return a nil list, i.e.
- * a list containing zero fontnames.
- */
- if (length > XLFDMAXFONTNAMELEN)
- return BadAlloc;
-
- i = XaceHook(XACE_SERVER_ACCESS, client, DixGetAttrAccess);
- if (i != Success)
- return i;
-
- if (!(c = malloc(sizeof *c)))
- return BadAlloc;
- c->fpe_list = malloc(sizeof(FontPathElementPtr) * num_fpes);
- if (!c->fpe_list) {
- free(c);
- return BadAlloc;
- }
- c->names = MakeFontNamesRecord(max_names < 100 ? max_names : 100);
- if (!c->names)
- {
- free(c->fpe_list);
- free(c);
- return BadAlloc;
- }
- memmove( c->current.pattern, pattern, length);
- for (i = 0; i < num_fpes; i++) {
- c->fpe_list[i] = font_path_elements[i];
- UseFPE(c->fpe_list[i]);
- }
- c->client = client;
- c->num_fpes = num_fpes;
- c->current.patlen = length;
- c->current.current_fpe = 0;
- c->current.max_names = max_names;
- c->current.list_started = FALSE;
- c->current.private = 0;
- c->haveSaved = FALSE;
- c->savedName = 0;
- doListFontsAndAliases(client, c);
- return Success;
-}
-
-int
-doListFontsWithInfo(ClientPtr client, LFWIclosurePtr c)
-{
- FontPathElementPtr fpe;
- int err = Successful;
- char *name;
- int namelen;
- int numFonts;
- FontInfoRec fontInfo,
- *pFontInfo;
- xListFontsWithInfoReply *reply;
- int length;
- xFontProp *pFP;
- int i;
- int aliascount = 0;
- xListFontsWithInfoReply finalReply;
-
- if (client->clientGone)
- {
- if (c->current.current_fpe < c->num_fpes)
- {
- fpe = c->fpe_list[c->current.current_fpe];
- (*fpe_functions[fpe->type].client_died) ((pointer) client, fpe);
- }
- err = Successful;
- goto bail;
- }
- client->pSwapReplyFunc = ReplySwapVector[X_ListFontsWithInfo];
- if (!c->current.patlen)
- goto finish;
- while (c->current.current_fpe < c->num_fpes)
- {
- fpe = c->fpe_list[c->current.current_fpe];
- err = Successful;
- if (!c->current.list_started)
- {
- err = (*fpe_functions[fpe->type].start_list_fonts_with_info)
- (client, fpe, c->current.pattern, c->current.patlen,
- c->current.max_names, &c->current.private);
- if (err == Suspended)
- {
- if (!ClientIsAsleep(client))
- ClientSleep(client,
- (ClientSleepProcPtr)doListFontsWithInfo, c);
- else
- goto xinerama_sleep;
- return TRUE;
- }
- if (err == Successful)
- c->current.list_started = TRUE;
- }
- if (err == Successful)
- {
- name = 0;
- pFontInfo = &fontInfo;
- err = (*fpe_functions[fpe->type].list_next_font_with_info)
- (client, fpe, &name, &namelen, &pFontInfo,
- &numFonts, c->current.private);
- if (err == Suspended)
- {
- if (!ClientIsAsleep(client))
- ClientSleep(client,
- (ClientSleepProcPtr)doListFontsWithInfo, c);
- else
- goto xinerama_sleep;
- return TRUE;
- }
- }
- /*
- * When we get an alias back, save our state and reset back to the
- * start of the FPE looking for the specified name. As soon as a real
- * font is found for the alias, pop back to the old state
- */
- if (err == FontNameAlias)
- {
- /*
- * when an alias recurses, we need to give
- * the last FPE a chance to clean up; so we call
- * it again, and assume that the error returned
- * is BadFontName, indicating the alias resolution
- * is complete.
- */
- if (c->haveSaved)
- {
- char *tmpname;
- int tmpnamelen;
- FontInfoPtr tmpFontInfo;
-
- tmpname = 0;
- tmpFontInfo = &fontInfo;
- (void) (*fpe_functions[fpe->type].list_next_font_with_info)
- (client, fpe, &tmpname, &tmpnamelen, &tmpFontInfo,
- &numFonts, c->current.private);
- if (--aliascount <= 0)
- {
- err = BadFontName;
- goto ContBadFontName;
- }
- }
- else
- {
- c->saved = c->current;
- c->haveSaved = TRUE;
- c->savedNumFonts = numFonts;
- free(c->savedName);
- c->savedName = malloc(namelen + 1);
- if (c->savedName)
- memmove(c->savedName, name, namelen + 1);
- aliascount = 20;
- }
- memmove(c->current.pattern, name, namelen);
- c->current.patlen = namelen;
- c->current.max_names = 1;
- c->current.current_fpe = 0;
- c->current.private = 0;
- c->current.list_started = FALSE;
- }
- /*
- * At the end of this FPE, step to the next. If we've finished
- * processing an alias, pop state back. If we've sent enough font
- * names, quit. Always wait for BadFontName to let the FPE
- * have a chance to clean up.
- */
- else if (err == BadFontName)
- {
- ContBadFontName: ;
- c->current.list_started = FALSE;
- c->current.current_fpe++;
- err = Successful;
- if (c->haveSaved)
- {
- if (c->current.max_names == 0 ||
- c->current.current_fpe == c->num_fpes)
- {
- c->haveSaved = FALSE;
- c->saved.max_names -= (1 - c->current.max_names);
- c->current = c->saved;
- }
- }
- else if (c->current.max_names == 0)
- break;
- }
- else if (err == Successful)
- {
- length = sizeof(*reply) + pFontInfo->nprops * sizeof(xFontProp);
- reply = c->reply;
- if (c->length < length)
- {
- reply = (xListFontsWithInfoReply *) realloc(c->reply, length);
- if (!reply)
- {
- err = AllocError;
- break;
- }
- memset((char*)reply + c->length, 0, length - c->length);
- c->reply = reply;
- c->length = length;
- }
- if (c->haveSaved)
- {
- numFonts = c->savedNumFonts;
- name = c->savedName;
- namelen = strlen(name);
- }
- reply->type = X_Reply;
- reply->length = bytes_to_int32(sizeof *reply - sizeof(xGenericReply) +
- pFontInfo->nprops * sizeof(xFontProp) +
- namelen);
- reply->sequenceNumber = client->sequence;
- reply->nameLength = namelen;
- reply->minBounds = pFontInfo->ink_minbounds;
- reply->maxBounds = pFontInfo->ink_maxbounds;
- reply->minCharOrByte2 = pFontInfo->firstCol;
- reply->maxCharOrByte2 = pFontInfo->lastCol;
- reply->defaultChar = pFontInfo->defaultCh;
- reply->nFontProps = pFontInfo->nprops;
- reply->drawDirection = pFontInfo->drawDirection;
- reply->minByte1 = pFontInfo->firstRow;
- reply->maxByte1 = pFontInfo->lastRow;
- reply->allCharsExist = pFontInfo->allExist;
- reply->fontAscent = pFontInfo->fontAscent;
- reply->fontDescent = pFontInfo->fontDescent;
- reply->nReplies = numFonts;
- pFP = (xFontProp *) (reply + 1);
- for (i = 0; i < pFontInfo->nprops; i++)
- {
- pFP->name = pFontInfo->props[i].name;
- pFP->value = pFontInfo->props[i].value;
- pFP++;
- }
- WriteSwappedDataToClient(client, length, reply);
- (void) WriteToClient(client, namelen, name);
- if (pFontInfo == &fontInfo)
- {
- free(fontInfo.props);
- free(fontInfo.isStringProp);
- }
- --c->current.max_names;
- }
- }
-finish:
- length = sizeof(xListFontsWithInfoReply);
- memset((char *) &finalReply, 0, sizeof(xListFontsWithInfoReply));
- finalReply.type = X_Reply;
- finalReply.sequenceNumber = client->sequence;
- finalReply.length = bytes_to_int32(sizeof(xListFontsWithInfoReply)
- - sizeof(xGenericReply));
- WriteSwappedDataToClient(client, length, &finalReply);
-bail:
- ClientWakeup(client);
-xinerama_sleep:
- for (i = 0; i < c->num_fpes; i++)
- FreeFPE(c->fpe_list[i]);
- free(c->reply);
- free(c->fpe_list);
- free(c->savedName);
- free(c);
- return TRUE;
-}
-
-int
-StartListFontsWithInfo(ClientPtr client, int length, unsigned char *pattern,
- int max_names)
-{
- int i;
- LFWIclosurePtr c;
-
- /*
- * The right error to return here would be BadName, however the
- * specification does not allow for a Name error on this request.
- * Perhaps a better solution would be to return a nil list, i.e.
- * a list containing zero fontnames.
- */
- if (length > XLFDMAXFONTNAMELEN)
- return BadAlloc;
-
- i = XaceHook(XACE_SERVER_ACCESS, client, DixGetAttrAccess);
- if (i != Success)
- return i;
-
- if (!(c = malloc(sizeof *c)))
- goto badAlloc;
- c->fpe_list = malloc(sizeof(FontPathElementPtr) * num_fpes);
- if (!c->fpe_list)
- {
- free(c);
- goto badAlloc;
- }
- memmove(c->current.pattern, pattern, length);
- for (i = 0; i < num_fpes; i++)
- {
- c->fpe_list[i] = font_path_elements[i];
- UseFPE(c->fpe_list[i]);
- }
- c->client = client;
- c->num_fpes = num_fpes;
- c->reply = 0;
- c->length = 0;
- c->current.patlen = length;
- c->current.current_fpe = 0;
- c->current.max_names = max_names;
- c->current.list_started = FALSE;
- c->current.private = 0;
- c->savedNumFonts = 0;
- c->haveSaved = FALSE;
- c->savedName = 0;
- doListFontsWithInfo(client, c);
- return Success;
-badAlloc:
- return BadAlloc;
-}
-
-#define TextEltHeader 2
-#define FontShiftSize 5
-static ChangeGCVal clearGC[] = { NullPixmap };
-#define clearGCmask (GCClipMask)
-
-int
-doPolyText(ClientPtr client, PTclosurePtr c)
-{
- FontPtr pFont = c->pGC->font, oldpFont;
- int err = Success, lgerr; /* err is in X error, not font error, space */
- enum { NEVER_SLEPT, START_SLEEP, SLEEPING } client_state = NEVER_SLEPT;
- FontPathElementPtr fpe;
- GC *origGC = NULL;
- int itemSize = c->reqType == X_PolyText8 ? 1 : 2;
-
- if (client->clientGone)
- {
- fpe = c->pGC->font->fpe;
- (*fpe_functions[fpe->type].client_died) ((pointer) client, fpe);
-
- if (ClientIsAsleep(client))
- {
- /* Client has died, but we cannot bail out right now. We
- need to clean up after the work we did when going to
- sleep. Setting the drawable pointer to 0 makes this
- happen without any attempts to render or perform other
- unnecessary activities. */
- c->pDraw = (DrawablePtr)0;
- }
- else
- {
- err = Success;
- goto bail;
- }
- }
-
- /* Make sure our drawable hasn't disappeared while we slept. */
- if (ClientIsAsleep(client) && c->pDraw)
- {
- DrawablePtr pDraw;
- dixLookupDrawable(&pDraw, c->did, client, 0, DixWriteAccess);
- if (c->pDraw != pDraw) {
- /* Our drawable has disappeared. Treat like client died... ask
- the FPE code to clean up after client and avoid further
- rendering while we clean up after ourself. */
- fpe = c->pGC->font->fpe;
- (*fpe_functions[fpe->type].client_died) ((pointer) client, fpe);
- c->pDraw = (DrawablePtr)0;
- }
- }
-
- client_state = ClientIsAsleep(client) ? SLEEPING : NEVER_SLEPT;
-
- while (c->endReq - c->pElt > TextEltHeader)
- {
- if (*c->pElt == FontChange)
- {
- Font fid;
- if (c->endReq - c->pElt < FontShiftSize)
- {
- err = BadLength;
- goto bail;
- }
-
- oldpFont = pFont;
-
- fid = ((Font)*(c->pElt+4)) /* big-endian */
- | ((Font)*(c->pElt+3)) << 8
- | ((Font)*(c->pElt+2)) << 16
- | ((Font)*(c->pElt+1)) << 24;
- err = dixLookupResourceByType((pointer *)&pFont, fid, RT_FONT,
- client, DixUseAccess);
- if (err != Success)
- {
- /* restore pFont for step 4 (described below) */
- pFont = oldpFont;
-
- /* If we're in START_SLEEP mode, the following step
- shortens the request... in the unlikely event that
- the fid somehow becomes valid before we come through
- again to actually execute the polytext, which would
- then mess up our refcounting scheme badly. */
- c->err = err;
- c->endReq = c->pElt;
-
- goto bail;
- }
-
- /* Step 3 (described below) on our new font */
- if (client_state == START_SLEEP)
- pFont->refcnt++;
- else
- {
- if (pFont != c->pGC->font && c->pDraw)
- {
- ChangeGCVal val;
- val.ptr = pFont;
- ChangeGC(NullClient, c->pGC, GCFont, &val);
- ValidateGC(c->pDraw, c->pGC);
- }
-
- /* Undo the refcnt++ we performed when going to sleep */
- if (client_state == SLEEPING)
- (void)CloseFont(c->pGC->font, (Font)0);
- }
- c->pElt += FontShiftSize;
- }
- else /* print a string */
- {
- unsigned char *pNextElt;
- pNextElt = c->pElt + TextEltHeader + (*c->pElt) * itemSize;
- if ( pNextElt > c->endReq)
- {
- err = BadLength;
- goto bail;
- }
- if (client_state == START_SLEEP)
- {
- c->pElt = pNextElt;
- continue;
- }
- if (c->pDraw)
- {
- lgerr = LoadGlyphs(client, c->pGC->font, *c->pElt, itemSize,
- c->pElt + TextEltHeader);
- }
- else lgerr = Successful;
-
- if (lgerr == Suspended)
- {
- if (!ClientIsAsleep(client)) {
- int len;
- GC *pGC;
- PTclosurePtr new_closure;
-
- /* We're putting the client to sleep. We need to do a few things
- to ensure successful and atomic-appearing execution of the
- remainder of the request. First, copy the remainder of the
- request into a safe malloc'd area. Second, create a scratch GC
- to use for the remainder of the request. Third, mark all fonts
- referenced in the remainder of the request to prevent their
- deallocation. Fourth, make the original GC look like the
- request has completed... set its font to the final font value
- from this request. These GC manipulations are for the unlikely
- (but possible) event that some other client is using the GC.
- Steps 3 and 4 are performed by running this procedure through
- the remainder of the request in a special no-render mode
- indicated by client_state = START_SLEEP. */
-
- /* Step 1 */
- /* Allocate a malloc'd closure structure to replace
- the local one we were passed */
- new_closure = malloc(sizeof(PTclosureRec));
- if (!new_closure)
- {
- err = BadAlloc;
- goto bail;
- }
- *new_closure = *c;
- c = new_closure;
-
- len = c->endReq - c->pElt;
- c->data = malloc(len);
- if (!c->data)
- {
- free(c);
- err = BadAlloc;
- goto bail;
- }
- memmove(c->data, c->pElt, len);
- c->pElt = c->data;
- c->endReq = c->pElt + len;
-
- /* Step 2 */
-
- pGC = GetScratchGC(c->pGC->depth, c->pGC->pScreen);
- if (!pGC)
- {
- free(c->data);
- free(c);
- err = BadAlloc;
- goto bail;
- }
- if ((err = CopyGC(c->pGC, pGC, GCFunction |
- GCPlaneMask | GCForeground |
- GCBackground | GCFillStyle |
- GCTile | GCStipple |
- GCTileStipXOrigin |
- GCTileStipYOrigin | GCFont |
- GCSubwindowMode | GCClipXOrigin |
- GCClipYOrigin | GCClipMask)) !=
- Success)
- {
- FreeScratchGC(pGC);
- free(c->data);
- free(c);
- err = BadAlloc;
- goto bail;
- }
- origGC = c->pGC;
- c->pGC = pGC;
- ValidateGC(c->pDraw, c->pGC);
-
- ClientSleep(client, (ClientSleepProcPtr)doPolyText, c);
-
- /* Set up to perform steps 3 and 4 */
- client_state = START_SLEEP;
- continue; /* on to steps 3 and 4 */
- }
- else
- goto xinerama_sleep;
- return TRUE;
- }
- else if (lgerr != Successful)
- {
- err = FontToXError(lgerr);
- goto bail;
- }
- if (c->pDraw)
- {
- c->xorg += *((INT8 *)(c->pElt + 1)); /* must be signed */
- if (c->reqType == X_PolyText8)
- c->xorg = (* c->pGC->ops->PolyText8)(c->pDraw, c->pGC, c->xorg, c->yorg,
- *c->pElt, (char *) (c->pElt + TextEltHeader));
- else
- c->xorg = (* c->pGC->ops->PolyText16)(c->pDraw, c->pGC, c->xorg, c->yorg,
- *c->pElt, (unsigned short *) (c->pElt + TextEltHeader));
- }
- c->pElt = pNextElt;
- }
- }
-
-bail:
-
- if (client_state == START_SLEEP)
- {
- /* Step 4 */
- if (pFont != origGC->font)
- {
- ChangeGCVal val;
- val.ptr = pFont;
- ChangeGC(NullClient, origGC, GCFont, &val);
- ValidateGC(c->pDraw, origGC);
- }
-
- /* restore pElt pointer for execution of remainder of the request */
- c->pElt = c->data;
- return TRUE;
- }
-
- if (c->err != Success) err = c->err;
- if (err != Success && c->client != serverClient) {
-#ifdef PANORAMIX
- if (noPanoramiXExtension || !c->pGC->pScreen->myNum)
-#endif
- SendErrorToClient(c->client, c->reqType, 0, 0, err);
- }
- if (ClientIsAsleep(client))
- {
- ClientWakeup(c->client);
-xinerama_sleep:
- ChangeGC(NullClient, c->pGC, clearGCmask, clearGC);
-
- /* Unreference the font from the scratch GC */
- CloseFont(c->pGC->font, (Font)0);
- c->pGC->font = NullFont;
-
- FreeScratchGC(c->pGC);
- free(c->data);
- free(c);
- }
- return TRUE;
-}
-
-int
-PolyText(ClientPtr client, DrawablePtr pDraw, GC *pGC, unsigned char *pElt,
- unsigned char *endReq, int xorg, int yorg, int reqType, XID did)
-{
- PTclosureRec local_closure;
-
- local_closure.pElt = pElt;
- local_closure.endReq = endReq;
- local_closure.client = client;
- local_closure.pDraw = pDraw;
- local_closure.xorg = xorg;
- local_closure.yorg = yorg;
- local_closure.reqType = reqType;
- local_closure.pGC = pGC;
- local_closure.did = did;
- local_closure.err = Success;
-
- (void) doPolyText(client, &local_closure);
- return Success;
-}
-
-
-#undef TextEltHeader
-#undef FontShiftSize
-
-int
-doImageText(ClientPtr client, ITclosurePtr c)
-{
- int err = Success, lgerr; /* err is in X error, not font error, space */
- FontPathElementPtr fpe;
- int itemSize = c->reqType == X_ImageText8 ? 1 : 2;
-
- if (client->clientGone)
- {
- fpe = c->pGC->font->fpe;
- (*fpe_functions[fpe->type].client_died) ((pointer) client, fpe);
- err = Success;
- goto bail;
- }
-
- /* Make sure our drawable hasn't disappeared while we slept. */
- if (ClientIsAsleep(client) && c->pDraw)
- {
- DrawablePtr pDraw;
- dixLookupDrawable(&pDraw, c->did, client, 0, DixWriteAccess);
- if (c->pDraw != pDraw) {
- /* Our drawable has disappeared. Treat like client died... ask
- the FPE code to clean up after client. */
- fpe = c->pGC->font->fpe;
- (*fpe_functions[fpe->type].client_died) ((pointer) client, fpe);
- err = Success;
- goto bail;
- }
- }
-
- lgerr = LoadGlyphs(client, c->pGC->font, c->nChars, itemSize, c->data);
- if (lgerr == Suspended)
- {
- if (!ClientIsAsleep(client)) {
- GC *pGC;
- unsigned char *data;
- ITclosurePtr new_closure;
-
- /* We're putting the client to sleep. We need to
- save some state. Similar problem to that handled
- in doPolyText, but much simpler because the
- request structure is much simpler. */
-
- new_closure = malloc(sizeof(ITclosureRec));
- if (!new_closure)
- {
- err = BadAlloc;
- goto bail;
- }
- *new_closure = *c;
- c = new_closure;
-
- data = malloc(c->nChars * itemSize);
- if (!data)
- {
- free(c);
- err = BadAlloc;
- goto bail;
- }
- memmove(data, c->data, c->nChars * itemSize);
- c->data = data;
-
- pGC = GetScratchGC(c->pGC->depth, c->pGC->pScreen);
- if (!pGC)
- {
- free(c->data);
- free(c);
- err = BadAlloc;
- goto bail;
- }
- if ((err = CopyGC(c->pGC, pGC, GCFunction | GCPlaneMask |
- GCForeground | GCBackground | GCFillStyle |
- GCTile | GCStipple | GCTileStipXOrigin |
- GCTileStipYOrigin | GCFont |
- GCSubwindowMode | GCClipXOrigin |
- GCClipYOrigin | GCClipMask)) != Success)
- {
- FreeScratchGC(pGC);
- free(c->data);
- free(c);
- err = BadAlloc;
- goto bail;
- }
- c->pGC = pGC;
- ValidateGC(c->pDraw, c->pGC);
-
- ClientSleep(client, (ClientSleepProcPtr)doImageText, c);
- }
- else
- goto xinerama_sleep;
- return TRUE;
- }
- else if (lgerr != Successful)
- {
- err = FontToXError(lgerr);
- goto bail;
- }
- if (c->pDraw)
- {
- if (c->reqType == X_ImageText8)
- (* c->pGC->ops->ImageText8)(c->pDraw, c->pGC, c->xorg, c->yorg,
- c->nChars, (char *) c->data);
- else
- (* c->pGC->ops->ImageText16)(c->pDraw, c->pGC, c->xorg, c->yorg,
- c->nChars, (unsigned short *) c->data);
- }
-
-bail:
-
- if (err != Success && c->client != serverClient) {
- SendErrorToClient(c->client, c->reqType, 0, 0, err);
- }
- if (ClientIsAsleep(client))
- {
- ClientWakeup(c->client);
-xinerama_sleep:
- ChangeGC(NullClient, c->pGC, clearGCmask, clearGC);
-
- /* Unreference the font from the scratch GC */
- CloseFont(c->pGC->font, (Font)0);
- c->pGC->font = NullFont;
-
- FreeScratchGC(c->pGC);
- free(c->data);
- free(c);
- }
- return TRUE;
-}
-
-int
-ImageText(ClientPtr client, DrawablePtr pDraw, GC *pGC, int nChars,
- unsigned char *data, int xorg, int yorg, int reqType, XID did)
-{
- ITclosureRec local_closure;
-
- local_closure.client = client;
- local_closure.pDraw = pDraw;
- local_closure.pGC = pGC;
- local_closure.nChars = nChars;
- local_closure.data = data;
- local_closure.xorg = xorg;
- local_closure.yorg = yorg;
- local_closure.reqType = reqType;
- local_closure.did = did;
-
- (void) doImageText(client, &local_closure);
- return Success;
-}
-
-
-/* does the necessary magic to figure out the fpe type */
-static int
-DetermineFPEType(char *pathname)
-{
- int i;
-
- for (i = 0; i < num_fpe_types; i++) {
- if ((*fpe_functions[i].name_check) (pathname))
- return i;
- }
- return -1;
-}
-
-
-static void
-FreeFontPath(FontPathElementPtr *list, int n, Bool force)
-{
- int i;
-
- for (i = 0; i < n; i++) {
- if (force) {
- /* Sanity check that all refcounts will be 0 by the time
- we get to the end of the list. */
- int found = 1; /* the first reference is us */
- int j;
- for (j = i+1; j < n; j++) {
- if (list[j] == list[i])
- found++;
- }
- if (list[i]->refcount != found) {
- list[i]->refcount = found; /* ensure it will get freed */
- }
- }
- FreeFPE(list[i]);
- }
- free(list);
-}
-
-static FontPathElementPtr
-find_existing_fpe(FontPathElementPtr *list, int num, unsigned char *name, int len)
-{
- FontPathElementPtr fpe;
- int i;
-
- for (i = 0; i < num; i++) {
- fpe = list[i];
- if (fpe->name_length == len && memcmp(name, fpe->name, len) == 0)
- return fpe;
- }
- return (FontPathElementPtr) 0;
-}
-
-
-static int
-SetFontPathElements(int npaths, unsigned char *paths, int *bad, Bool persist)
-{
- int i, err = 0;
- int valid_paths = 0;
- unsigned int len;
- unsigned char *cp = paths;
- FontPathElementPtr fpe = NULL, *fplist;
-
- fplist = malloc(sizeof(FontPathElementPtr) * npaths);
- if (!fplist) {
- *bad = 0;
- return BadAlloc;
- }
- for (i = 0; i < num_fpe_types; i++) {
- if (fpe_functions[i].set_path_hook)
- (*fpe_functions[i].set_path_hook) ();
- }
- for (i = 0; i < npaths; i++)
- {
- len = (unsigned int) (*cp++);
-
- if (len == 0)
- {
- if (persist)
- ErrorF("[dix] Removing empty element from the valid list of fontpaths\n");
- err = BadValue;
- }
- else
- {
- /* if it's already in our active list, just reset it */
- /*
- * note that this can miss FPE's in limbo -- may be worth catching
- * them, though it'd muck up refcounting
- */
- fpe = find_existing_fpe(font_path_elements, num_fpes, cp, len);
- if (fpe)
- {
- err = (*fpe_functions[fpe->type].reset_fpe) (fpe);
- if (err == Successful)
- {
- UseFPE(fpe);/* since it'll be decref'd later when freed
- * from the old list */
- }
- else
- fpe = 0;
- }
- /* if error or can't do it, act like it's a new one */
- if (!fpe)
- {
- fpe = malloc(sizeof(FontPathElementRec));
- if (!fpe)
- {
- err = BadAlloc;
- goto bail;
- }
- fpe->name = malloc(len + 1);
- if (!fpe->name)
- {
- free(fpe);
- err = BadAlloc;
- goto bail;
- }
- fpe->refcount = 1;
-
- strncpy(fpe->name, (char *) cp, (int) len);
- fpe->name[len] = '\0';
- fpe->name_length = len;
- fpe->type = DetermineFPEType(fpe->name);
- if (fpe->type == -1)
- err = BadValue;
- else
- err = (*fpe_functions[fpe->type].init_fpe) (fpe);
- if (err != Successful)
- {
- if (persist)
- {
- ErrorF("[dix] Could not init font path element %s, removing from list!\n",
- fpe->name);
- }
- free(fpe->name);
- free(fpe);
- }
- }
- }
- if (err != Successful)
- {
- if (!persist)
- goto bail;
- }
- else
- {
- fplist[valid_paths++] = fpe;
- }
- cp += len;
- }
-
- FreeFontPath(font_path_elements, num_fpes, FALSE);
- font_path_elements = fplist;
- if (patternCache)
- EmptyFontPatternCache(patternCache);
- num_fpes = valid_paths;
-
- return Success;
-bail:
- *bad = i;
- while (--valid_paths >= 0)
- FreeFPE(fplist[valid_paths]);
- free(fplist);
- return FontToXError(err);
-}
-
-int
-SetFontPath(ClientPtr client, int npaths, unsigned char *paths)
-{
- int err = XaceHook(XACE_SERVER_ACCESS, client, DixManageAccess);
- if (err != Success)
- return err;
-
- if (npaths == 0) {
- if (SetDefaultFontPath(defaultFontPath) != Success)
- return BadValue;
- } else {
- int bad;
- err = SetFontPathElements(npaths, paths, &bad, FALSE);
- client->errorValue = bad;
- }
- return err;
-}
-
-int
-SetDefaultFontPath(char *path)
-{
- char *temp_path,
- *start,
- *end;
- unsigned char *cp,
- *pp,
- *nump,
- *newpath;
- int num = 1,
- len,
- err,
- size = 0,
- bad;
-
- /* ensure temp_path contains "built-ins" */
- start = path;
- while (1) {
- start = strstr(start, "built-ins");
- if (start == NULL)
- break;
- end = start + strlen("built-ins");
- if ((start == path || start[-1] == ',') && (!*end || *end == ','))
- break;
- start = end;
- }
- if (!start) {
- if (asprintf(&temp_path, "%s%sbuilt-ins", path, *path ? "," : "")
- == -1)
- temp_path = NULL;
- } else {
- temp_path = strdup(path);
- }
- if (!temp_path)
- return BadAlloc;
-
- /* get enough for string, plus values -- use up commas */
- len = strlen(temp_path) + 1;
- nump = cp = newpath = malloc(len);
- if (!newpath)
- return BadAlloc;
- pp = (unsigned char *) temp_path;
- cp++;
- while (*pp) {
- if (*pp == ',') {
- *nump = (unsigned char) size;
- nump = cp++;
- pp++;
- num++;
- size = 0;
- } else {
- *cp++ = *pp++;
- size++;
- }
- }
- *nump = (unsigned char) size;
-
- err = SetFontPathElements(num, newpath, &bad, TRUE);
-
- free(newpath);
- free(temp_path);
-
- return err;
-}
-
-int
-GetFontPath(ClientPtr client, int *count, int *length, unsigned char **result)
-{
- int i;
- unsigned char *c;
- int len;
- FontPathElementPtr fpe;
-
- i = XaceHook(XACE_SERVER_ACCESS, client, DixGetAttrAccess);
- if (i != Success)
- return i;
-
- len = 0;
- for (i = 0; i < num_fpes; i++) {
- fpe = font_path_elements[i];
- len += fpe->name_length + 1;
- }
- font_path_string = (unsigned char *) realloc(font_path_string, len);
- if (!font_path_string)
- return BadAlloc;
-
- c = font_path_string;
- *length = 0;
- for (i = 0; i < num_fpes; i++) {
- fpe = font_path_elements[i];
- *c = fpe->name_length;
- *length += *c++;
- memmove(c, fpe->name, fpe->name_length);
- c += fpe->name_length;
- }
- *count = num_fpes;
- *result = font_path_string;
- return Success;
-}
-
-void
-DeleteClientFontStuff(ClientPtr client)
-{
- int i;
- FontPathElementPtr fpe;
-
- for (i = 0; i < num_fpes; i++)
- {
- fpe = font_path_elements[i];
- if (fpe_functions[fpe->type].client_died)
- (*fpe_functions[fpe->type].client_died) ((pointer) client, fpe);
- }
-}
-
-void
-InitFonts (void)
-{
- patternCache = MakeFontPatternCache();
-
- register_fpe_functions();
-}
-
-int
-GetDefaultPointSize (void)
-{
- return 120;
-}
-
-
-FontResolutionPtr
-GetClientResolutions (int *num)
-{
- static struct _FontResolution res;
- ScreenPtr pScreen;
-
- pScreen = screenInfo.screens[0];
- res.x_resolution = (pScreen->width * 25.4) / pScreen->mmWidth;
- /*
- * XXX - we'll want this as long as bitmap instances are prevalent
- so that we can match them from scalable fonts
- */
- if (res.x_resolution < 88)
- res.x_resolution = 75;
- else
- res.x_resolution = 100;
- res.y_resolution = (pScreen->height * 25.4) / pScreen->mmHeight;
- if (res.y_resolution < 88)
- res.y_resolution = 75;
- else
- res.y_resolution = 100;
- res.point_size = 120;
- *num = 1;
- return &res;
-}
-
-/*
- * returns the type index of the new fpe
- *
- * should be called (only once!) by each type of fpe when initialized
- */
-
-int
-RegisterFPEFunctions(NameCheckFunc name_func,
- InitFpeFunc init_func,
- FreeFpeFunc free_func,
- ResetFpeFunc reset_func,
- OpenFontFunc open_func,
- CloseFontFunc close_func,
- ListFontsFunc list_func,
- StartLfwiFunc start_lfwi_func,
- NextLfwiFunc next_lfwi_func,
- WakeupFpeFunc wakeup_func,
- ClientDiedFunc client_died,
- LoadGlyphsFunc load_glyphs,
- StartLaFunc start_list_alias_func,
- NextLaFunc next_list_alias_func,
- SetPathFunc set_path_func)
-{
- FPEFunctions *new;
-
- /* grow the list */
- new = (FPEFunctions *) realloc(fpe_functions,
- (num_fpe_types + 1) * sizeof(FPEFunctions));
- if (!new)
- return -1;
- fpe_functions = new;
-
- fpe_functions[num_fpe_types].name_check = name_func;
- fpe_functions[num_fpe_types].open_font = open_func;
- fpe_functions[num_fpe_types].close_font = close_func;
- fpe_functions[num_fpe_types].wakeup_fpe = wakeup_func;
- fpe_functions[num_fpe_types].list_fonts = list_func;
- fpe_functions[num_fpe_types].start_list_fonts_with_info =
- start_lfwi_func;
- fpe_functions[num_fpe_types].list_next_font_with_info =
- next_lfwi_func;
- fpe_functions[num_fpe_types].init_fpe = init_func;
- fpe_functions[num_fpe_types].free_fpe = free_func;
- fpe_functions[num_fpe_types].reset_fpe = reset_func;
- fpe_functions[num_fpe_types].client_died = client_died;
- fpe_functions[num_fpe_types].load_glyphs = load_glyphs;
- fpe_functions[num_fpe_types].start_list_fonts_and_aliases =
- start_list_alias_func;
- fpe_functions[num_fpe_types].list_next_font_or_alias =
- next_list_alias_func;
- fpe_functions[num_fpe_types].set_path_hook = set_path_func;
-
- return num_fpe_types++;
-}
-
-void
-FreeFonts(void)
-{
- if (patternCache) {
- FreeFontPatternCache(patternCache);
- patternCache = 0;
- }
- FreeFontPath(font_path_elements, num_fpes, TRUE);
- font_path_elements = 0;
- num_fpes = 0;
- free(fpe_functions);
- num_fpe_types = 0;
- fpe_functions = (FPEFunctions *) 0;
-}
-
-/* convenience functions for FS interface */
-
-FontPtr
-find_old_font(XID id)
-{
- pointer pFont;
- dixLookupResourceByType(&pFont, id, RT_NONE, serverClient, DixReadAccess);
- return (FontPtr)pFont;
-}
-
-Font
-GetNewFontClientID(void)
-{
- return FakeClientID(0);
-}
-
-int
-StoreFontClientFont(FontPtr pfont, Font id)
-{
- return AddResource(id, RT_NONE, (pointer) pfont);
-}
-
-void
-DeleteFontClientID(Font id)
-{
- FreeResource(id, RT_NONE);
-}
-
-int
-client_auth_generation(ClientPtr client)
-{
- return 0;
-}
-
-static int fs_handlers_installed = 0;
-static unsigned int last_server_gen;
-
-int
-init_fs_handlers(FontPathElementPtr fpe, BlockHandlerProcPtr block_handler)
-{
- /* if server has reset, make sure the b&w handlers are reinstalled */
- if (last_server_gen < serverGeneration) {
- last_server_gen = serverGeneration;
- fs_handlers_installed = 0;
- }
- if (fs_handlers_installed == 0) {
- if (!RegisterBlockAndWakeupHandlers(block_handler,
- FontWakeup, (pointer) 0))
- return AllocError;
- fs_handlers_installed++;
- }
- QueueFontWakeup(fpe);
- return Successful;
-}
-
-void
-remove_fs_handlers(FontPathElementPtr fpe, BlockHandlerProcPtr block_handler, Bool all)
-{
- if (all) {
- /* remove the handlers if no one else is using them */
- if (--fs_handlers_installed == 0) {
- RemoveBlockAndWakeupHandlers(block_handler, FontWakeup,
- (pointer) 0);
- }
- }
- RemoveFontWakeup(fpe);
-}
+/************************************************************************
+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.
+
+************************************************************************/
+/* The panoramix components contained the following notice */
+/*
+Copyright (c) 1991, 1997 Digital Equipment Corporation, Maynard, Massachusetts.
+
+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.
+
+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
+DIGITAL EQUIPMENT CORPORATION BE LIABLE FOR ANY CLAIM, DAMAGES, INCLUDING,
+BUT NOT LIMITED TO CONSEQUENTIAL OR INCIDENTAL 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 Digital Equipment Corporation
+shall not be used in advertising or otherwise to promote the sale, use or other
+dealings in this Software without prior written authorization from Digital
+Equipment Corporation.
+
+******************************************************************/
+
+#ifdef HAVE_DIX_CONFIG_H
+#include <dix-config.h>
+#endif
+
+#include <X11/X.h>
+#include <X11/Xmd.h>
+#include <X11/Xproto.h>
+#include "scrnintstr.h"
+#include "resource.h"
+#include "dixstruct.h"
+#include "cursorstr.h"
+#include "misc.h"
+#include "opaque.h"
+#include "dixfontstr.h"
+#include "closestr.h"
+#include "dixfont.h"
+#include "xace.h"
+
+#ifdef DEBUG
+#include <stdio.h>
+#endif
+
+#ifdef XF86BIGFONT
+#include "xf86bigfontsrv.h"
+#endif
+
+#define QUERYCHARINFO(pci, pr) *(pr) = (pci)->metrics
+
+extern pointer fosNaturalParams;
+extern FontPtr defaultFont;
+
+static FontPathElementPtr *font_path_elements = (FontPathElementPtr *) 0;
+static int num_fpes = 0;
+static FPEFunctions *fpe_functions = (FPEFunctions *) 0;
+static int num_fpe_types = 0;
+
+static unsigned char *font_path_string;
+
+static int num_slept_fpes = 0;
+static int size_slept_fpes = 0;
+static FontPathElementPtr *slept_fpes = (FontPathElementPtr *) 0;
+static FontPatternCachePtr patternCache;
+
+static int
+FontToXError(int err)
+{
+ switch (err) {
+ case Successful:
+ return Success;
+ case AllocError:
+ return BadAlloc;
+ case BadFontName:
+ return BadName;
+ case BadFontPath:
+ case BadFontFormat: /* is there something better? */
+ case BadCharRange:
+ return BadValue;
+ default:
+ return err;
+ }
+}
+
+static int
+LoadGlyphs(ClientPtr client, FontPtr pfont, unsigned nchars, int item_size,
+ unsigned char *data)
+{
+ if (fpe_functions[pfont->fpe->type].load_glyphs)
+ return (*fpe_functions[pfont->fpe->type].load_glyphs)
+ (client, pfont, 0, nchars, item_size, data);
+ else
+ return Successful;
+}
+
+/*
+ * adding RT_FONT prevents conflict with default cursor font
+ */
+Bool
+SetDefaultFont(char *defaultfontname)
+{
+ int err;
+ FontPtr pf;
+ XID fid;
+ static FontPtr last_pf;
+
+ fid = FakeClientID(0);
+ err = OpenFont(serverClient, fid, FontLoadAll | FontOpenSync,
+ (unsigned) strlen(defaultfontname), defaultfontname);
+ if (err != Success)
+ return FALSE;
+ err = dixLookupResourceByType((pointer *)&pf, fid, RT_FONT, serverClient,
+ DixReadAccess);
+ if (err == Success) last_pf = pf;
+ if (last_pf == (FontPtr) NULL)
+ return FALSE;
+ defaultFont = last_pf;
+ return TRUE;
+}
+
+/*
+ * note that the font wakeup queue is not refcounted. this is because
+ * an fpe needs to be added when it's inited, and removed when it's finally
+ * freed, in order to handle any data that isn't requested, like FS events.
+ *
+ * since the only thing that should call these routines is the renderer's
+ * init_fpe() and free_fpe(), there shouldn't be any problem in using
+ * freed data.
+ */
+void
+QueueFontWakeup(FontPathElementPtr fpe)
+{
+ int i;
+ FontPathElementPtr *new;
+
+ for (i = 0; i < num_slept_fpes; i++) {
+ if (slept_fpes[i] == fpe) {
+ return;
+ }
+ }
+ if (num_slept_fpes == size_slept_fpes) {
+ new = (FontPathElementPtr *)
+ realloc(slept_fpes,
+ sizeof(FontPathElementPtr) * (size_slept_fpes + 4));
+ if (!new)
+ return;
+ slept_fpes = new;
+ size_slept_fpes += 4;
+ }
+ slept_fpes[num_slept_fpes] = fpe;
+ num_slept_fpes++;
+}
+
+void
+RemoveFontWakeup(FontPathElementPtr fpe)
+{
+ int i,
+ j;
+
+ for (i = 0; i < num_slept_fpes; i++) {
+ if (slept_fpes[i] == fpe) {
+ for (j = i; j < num_slept_fpes; j++) {
+ slept_fpes[j] = slept_fpes[j + 1];
+ }
+ num_slept_fpes--;
+ return;
+ }
+ }
+}
+
+void
+FontWakeup(pointer data, int count, pointer LastSelectMask)
+{
+ int i;
+ FontPathElementPtr fpe;
+
+ if (count < 0)
+ return;
+ /* wake up any fpe's that may be waiting for information */
+ for (i = 0; i < num_slept_fpes; i++) {
+ fpe = slept_fpes[i];
+ (void) (*fpe_functions[fpe->type].wakeup_fpe) (fpe, LastSelectMask);
+ }
+}
+
+/* XXX -- these two funcs may want to be broken into macros */
+static void
+UseFPE(FontPathElementPtr fpe)
+{
+ fpe->refcount++;
+}
+
+static void
+FreeFPE (FontPathElementPtr fpe)
+{
+ fpe->refcount--;
+ if (fpe->refcount == 0) {
+ (*fpe_functions[fpe->type].free_fpe) (fpe);
+ free(fpe->name);
+ free(fpe);
+ }
+}
+
+static Bool
+doOpenFont(ClientPtr client, OFclosurePtr c)
+{
+ FontPtr pfont = NullFont;
+ FontPathElementPtr fpe = NULL;
+ ScreenPtr pScr;
+ int err = Successful;
+ int i;
+ char *alias,
+ *newname;
+ int newlen;
+ int aliascount = 20;
+ /*
+ * Decide at runtime what FontFormat to use.
+ */
+ Mask FontFormat =
+
+ ((screenInfo.imageByteOrder == LSBFirst) ?
+ BitmapFormatByteOrderLSB : BitmapFormatByteOrderMSB) |
+
+ ((screenInfo.bitmapBitOrder == LSBFirst) ?
+ BitmapFormatBitOrderLSB : BitmapFormatBitOrderMSB) |
+
+ BitmapFormatImageRectMin |
+
+#if GLYPHPADBYTES == 1
+ BitmapFormatScanlinePad8 |
+#endif
+
+#if GLYPHPADBYTES == 2
+ BitmapFormatScanlinePad16 |
+#endif
+
+#if GLYPHPADBYTES == 4
+ BitmapFormatScanlinePad32 |
+#endif
+
+#if GLYPHPADBYTES == 8
+ BitmapFormatScanlinePad64 |
+#endif
+
+ BitmapFormatScanlineUnit8;
+
+ if (client->clientGone)
+ {
+ if (c->current_fpe < c->num_fpes)
+ {
+ fpe = c->fpe_list[c->current_fpe];
+ (*fpe_functions[fpe->type].client_died) ((pointer) client, fpe);
+ }
+ err = Successful;
+ goto bail;
+ }
+ while (c->current_fpe < c->num_fpes) {
+ fpe = c->fpe_list[c->current_fpe];
+ err = (*fpe_functions[fpe->type].open_font)
+ ((pointer) client, fpe, c->flags,
+ c->fontname, c->fnamelen, FontFormat,
+ BitmapFormatMaskByte |
+ BitmapFormatMaskBit |
+ BitmapFormatMaskImageRectangle |
+ BitmapFormatMaskScanLinePad |
+ BitmapFormatMaskScanLineUnit,
+ c->fontid, &pfont, &alias,
+ c->non_cachable_font && c->non_cachable_font->fpe == fpe ?
+ c->non_cachable_font :
+ (FontPtr)0);
+
+ if (err == FontNameAlias && alias) {
+ newlen = strlen(alias);
+ newname = (char *) realloc(c->fontname, newlen);
+ if (!newname) {
+ err = AllocError;
+ break;
+ }
+ memmove(newname, alias, newlen);
+ c->fontname = newname;
+ c->fnamelen = newlen;
+ c->current_fpe = 0;
+ if (--aliascount <= 0) {
+ /* We've tried resolving this alias 20 times, we're
+ * probably stuck in an infinite loop of aliases pointing
+ * to each other - time to take emergency exit!
+ */
+ err = BadImplementation;
+ break;
+ }
+ continue;
+ }
+ if (err == BadFontName) {
+ c->current_fpe++;
+ continue;
+ }
+ if (err == Suspended) {
+ if (!ClientIsAsleep(client))
+ ClientSleep(client, (ClientSleepProcPtr)doOpenFont, c);
+ else
+ goto xinerama_sleep;
+ return TRUE;
+ }
+ break;
+ }
+
+ if (err != Successful)
+ goto bail;
+ if (!pfont) {
+ err = BadFontName;
+ goto bail;
+ }
+ /* check values for firstCol, lastCol, firstRow, and lastRow */
+ if (pfont->info.firstCol > pfont->info.lastCol ||
+ pfont->info.firstRow > pfont->info.lastRow ||
+ pfont->info.lastCol - pfont->info.firstCol > 255) {
+ err = AllocError;
+ goto bail;
+ }
+ if (!pfont->fpe)
+ pfont->fpe = fpe;
+ pfont->refcnt++;
+ if (pfont->refcnt == 1) {
+ UseFPE(pfont->fpe);
+ for (i = 0; i < screenInfo.numScreens; i++) {
+ pScr = screenInfo.screens[i];
+ if (pScr->RealizeFont)
+ {
+ if (!(*pScr->RealizeFont) (pScr, pfont))
+ {
+ CloseFont (pfont, (Font) 0);
+ err = AllocError;
+ goto bail;
+ }
+ }
+ }
+ }
+ if (!AddResource(c->fontid, RT_FONT, (pointer) pfont)) {
+ err = AllocError;
+ goto bail;
+ }
+ if (patternCache && pfont != c->non_cachable_font)
+ CacheFontPattern(patternCache, c->origFontName, c->origFontNameLen,
+ pfont);
+bail:
+ if (err != Successful && c->client != serverClient) {
+ SendErrorToClient(c->client, X_OpenFont, 0,
+ c->fontid, FontToXError(err));
+ }
+ ClientWakeup(c->client);
+xinerama_sleep:
+ for (i = 0; i < c->num_fpes; i++) {
+ FreeFPE(c->fpe_list[i]);
+ }
+ free(c->fpe_list);
+ free(c->fontname);
+ free(c);
+ return TRUE;
+}
+
+int
+OpenFont(ClientPtr client, XID fid, Mask flags, unsigned lenfname, char *pfontname)
+{
+ OFclosurePtr c;
+ int i;
+ FontPtr cached = (FontPtr)0;
+
+#ifdef FONTDEBUG
+ char *f;
+ f = malloc(lenfname + 1);
+ memmove(f, pfontname, lenfname);
+ f[lenfname] = '\0';
+ ErrorF("[dix] OpenFont: fontname is \"%s\"\n", f);
+ free(f);
+#endif
+ if (!lenfname || lenfname > XLFDMAXFONTNAMELEN)
+ return BadName;
+ if (patternCache)
+ {
+
+ /*
+ ** Check name cache. If we find a cached version of this font that
+ ** is cachable, immediately satisfy the request with it. If we find
+ ** a cached version of this font that is non-cachable, we do not
+ ** satisfy the request with it. Instead, we pass the FontPtr to the
+ ** FPE's open_font code (the fontfile FPE in turn passes the
+ ** information to the rasterizer; the fserve FPE ignores it).
+ **
+ ** Presumably, the font is marked non-cachable because the FPE has
+ ** put some licensing restrictions on it. If the FPE, using
+ ** whatever logic it relies on, determines that it is willing to
+ ** share this existing font with the client, then it has the option
+ ** to return the FontPtr we passed it as the newly-opened font.
+ ** This allows the FPE to exercise its licensing logic without
+ ** having to create another instance of a font that already exists.
+ */
+
+ cached = FindCachedFontPattern(patternCache, pfontname, lenfname);
+ if (cached && cached->info.cachable)
+ {
+ if (!AddResource(fid, RT_FONT, (pointer) cached))
+ return BadAlloc;
+ cached->refcnt++;
+ return Success;
+ }
+ }
+ c = malloc(sizeof(OFclosureRec));
+ if (!c)
+ return BadAlloc;
+ c->fontname = malloc(lenfname);
+ c->origFontName = pfontname;
+ c->origFontNameLen = lenfname;
+ if (!c->fontname) {
+ free(c);
+ return BadAlloc;
+ }
+ /*
+ * copy the current FPE list, so that if it gets changed by another client
+ * while we're blocking, the request still appears atomic
+ */
+ c->fpe_list = malloc(sizeof(FontPathElementPtr) * num_fpes);
+ if (!c->fpe_list) {
+ free(c->fontname);
+ free(c);
+ return BadAlloc;
+ }
+ memmove(c->fontname, pfontname, lenfname);
+ for (i = 0; i < num_fpes; i++) {
+ c->fpe_list[i] = font_path_elements[i];
+ UseFPE(c->fpe_list[i]);
+ }
+ c->client = client;
+ c->fontid = fid;
+ c->current_fpe = 0;
+ c->num_fpes = num_fpes;
+ c->fnamelen = lenfname;
+ c->flags = flags;
+ c->non_cachable_font = cached;
+
+ (void) doOpenFont(client, c);
+ return Success;
+}
+
+/**
+ * Decrement font's ref count, and free storage if ref count equals zero
+ *
+ * \param value must conform to DeleteType
+ */
+int
+CloseFont(pointer value, XID fid)
+{
+ int nscr;
+ ScreenPtr pscr;
+ FontPathElementPtr fpe;
+ FontPtr pfont = (FontPtr)value;
+
+ if (pfont == NullFont)
+ return Success;
+ if (--pfont->refcnt == 0) {
+ if (patternCache)
+ RemoveCachedFontPattern (patternCache, pfont);
+ /*
+ * since the last reference is gone, ask each screen to free any
+ * storage it may have allocated locally for it.
+ */
+ for (nscr = 0; nscr < screenInfo.numScreens; nscr++) {
+ pscr = screenInfo.screens[nscr];
+ if (pscr->UnrealizeFont)
+ (*pscr->UnrealizeFont) (pscr, pfont);
+ }
+ if (pfont == defaultFont)
+ defaultFont = NULL;
+#ifdef XF86BIGFONT
+ XF86BigfontFreeFontShm(pfont);
+#endif
+ fpe = pfont->fpe;
+ (*fpe_functions[fpe->type].close_font) (fpe, pfont);
+ FreeFPE(fpe);
+ }
+ return Success;
+}
+
+
+/***====================================================================***/
+
+/**
+ * Sets up pReply as the correct QueryFontReply for pFont with the first
+ * nProtoCCIStructs char infos.
+ *
+ * \param pReply caller must allocate this storage
+ */
+void
+QueryFont(FontPtr pFont, xQueryFontReply *pReply, int nProtoCCIStructs)
+{
+ FontPropPtr pFP;
+ int r,
+ c,
+ i;
+ xFontProp *prFP;
+ xCharInfo *prCI;
+ xCharInfo *charInfos[256];
+ unsigned char chars[512];
+ int ninfos;
+ unsigned long ncols;
+ unsigned long count;
+
+ /* pr->length set in dispatch */
+ pReply->minCharOrByte2 = pFont->info.firstCol;
+ pReply->defaultChar = pFont->info.defaultCh;
+ pReply->maxCharOrByte2 = pFont->info.lastCol;
+ pReply->drawDirection = pFont->info.drawDirection;
+ pReply->allCharsExist = pFont->info.allExist;
+ pReply->minByte1 = pFont->info.firstRow;
+ pReply->maxByte1 = pFont->info.lastRow;
+ pReply->fontAscent = pFont->info.fontAscent;
+ pReply->fontDescent = pFont->info.fontDescent;
+
+ pReply->minBounds = pFont->info.ink_minbounds;
+ pReply->maxBounds = pFont->info.ink_maxbounds;
+
+ pReply->nFontProps = pFont->info.nprops;
+ pReply->nCharInfos = nProtoCCIStructs;
+
+ for (i = 0, pFP = pFont->info.props, prFP = (xFontProp *) (&pReply[1]);
+ i < pFont->info.nprops;
+ i++, pFP++, prFP++) {
+ prFP->name = pFP->name;
+ prFP->value = pFP->value;
+ }
+
+ ninfos = 0;
+ ncols = (unsigned long) (pFont->info.lastCol - pFont->info.firstCol + 1);
+ prCI = (xCharInfo *) (prFP);
+ for (r = pFont->info.firstRow;
+ ninfos < nProtoCCIStructs && r <= (int)pFont->info.lastRow;
+ r++) {
+ i = 0;
+ for (c = pFont->info.firstCol; c <= (int)pFont->info.lastCol; c++) {
+ chars[i++] = r;
+ chars[i++] = c;
+ }
+ (*pFont->get_metrics) (pFont, ncols, chars,
+ TwoD16Bit, &count, charInfos);
+ i = 0;
+ for (i = 0; i < (int) count && ninfos < nProtoCCIStructs; i++) {
+ *prCI = *charInfos[i];
+ prCI++;
+ ninfos++;
+ }
+ }
+ return;
+}
+
+static Bool
+doListFontsAndAliases(ClientPtr client, LFclosurePtr c)
+{
+ FontPathElementPtr fpe;
+ int err = Successful;
+ FontNamesPtr names = NULL;
+ char *name, *resolved=NULL;
+ int namelen, resolvedlen;
+ int nnames;
+ int stringLens;
+ int i;
+ xListFontsReply reply;
+ char *bufptr;
+ char *bufferStart;
+ int aliascount = 0;
+
+ if (client->clientGone)
+ {
+ if (c->current.current_fpe < c->num_fpes)
+ {
+ fpe = c->fpe_list[c->current.current_fpe];
+ (*fpe_functions[fpe->type].client_died) ((pointer) client, fpe);
+ }
+ err = Successful;
+ goto bail;
+ }
+
+ if (!c->current.patlen)
+ goto finish;
+
+ while (c->current.current_fpe < c->num_fpes) {
+ fpe = c->fpe_list[c->current.current_fpe];
+ err = Successful;
+
+ if (!fpe_functions[fpe->type].start_list_fonts_and_aliases)
+ {
+ /* This FPE doesn't support/require list_fonts_and_aliases */
+
+ err = (*fpe_functions[fpe->type].list_fonts)
+ ((pointer) c->client, fpe, c->current.pattern,
+ c->current.patlen, c->current.max_names - c->names->nnames,
+ c->names);
+
+ if (err == Suspended) {
+ if (!ClientIsAsleep(client))
+ ClientSleep(client,
+ (ClientSleepProcPtr)doListFontsAndAliases,
+ c);
+ else
+ goto xinerama_sleep;
+ return TRUE;
+ }
+
+ err = BadFontName;
+ }
+ else
+ {
+ /* Start of list_fonts_and_aliases functionality. Modeled
+ after list_fonts_with_info in that it resolves aliases,
+ except that the information collected from FPEs is just
+ names, not font info. Each list_next_font_or_alias()
+ returns either a name into name/namelen or an alias into
+ name/namelen and its target name into resolved/resolvedlen.
+ The code at this level then resolves the alias by polling
+ the FPEs. */
+
+ if (!c->current.list_started) {
+ err = (*fpe_functions[fpe->type].start_list_fonts_and_aliases)
+ ((pointer) c->client, fpe, c->current.pattern,
+ c->current.patlen, c->current.max_names - c->names->nnames,
+ &c->current.private);
+ if (err == Suspended) {
+ if (!ClientIsAsleep(client))
+ ClientSleep(client,
+ (ClientSleepProcPtr)doListFontsAndAliases,
+ c);
+ else
+ goto xinerama_sleep;
+ return TRUE;
+ }
+ if (err == Successful)
+ c->current.list_started = TRUE;
+ }
+ if (err == Successful) {
+ char *tmpname;
+ name = 0;
+ err = (*fpe_functions[fpe->type].list_next_font_or_alias)
+ ((pointer) c->client, fpe, &name, &namelen, &tmpname,
+ &resolvedlen, c->current.private);
+ if (err == Suspended) {
+ if (!ClientIsAsleep(client))
+ ClientSleep(client,
+ (ClientSleepProcPtr)doListFontsAndAliases,
+ c);
+ else
+ goto xinerama_sleep;
+ return TRUE;
+ }
+ if (err == FontNameAlias) {
+ free(resolved);
+ resolved = malloc(resolvedlen + 1);
+ if (resolved)
+ memmove(resolved, tmpname, resolvedlen + 1);
+ }
+ }
+
+ if (err == Successful)
+ {
+ if (c->haveSaved)
+ {
+ if (c->savedName)
+ (void)AddFontNamesName(c->names, c->savedName,
+ c->savedNameLen);
+ }
+ else
+ (void)AddFontNamesName(c->names, name, namelen);
+ }
+
+ /*
+ * When we get an alias back, save our state and reset back to
+ * the start of the FPE looking for the specified name. As
+ * soon as a real font is found for the alias, pop back to the
+ * old state
+ */
+ else if (err == FontNameAlias) {
+ char tmp_pattern[XLFDMAXFONTNAMELEN];
+ /*
+ * when an alias recurses, we need to give
+ * the last FPE a chance to clean up; so we call
+ * it again, and assume that the error returned
+ * is BadFontName, indicating the alias resolution
+ * is complete.
+ */
+ memmove(tmp_pattern, resolved, resolvedlen);
+ if (c->haveSaved)
+ {
+ char *tmpname;
+ int tmpnamelen;
+
+ tmpname = 0;
+ (void) (*fpe_functions[fpe->type].list_next_font_or_alias)
+ ((pointer) c->client, fpe, &tmpname, &tmpnamelen,
+ &tmpname, &tmpnamelen, c->current.private);
+ if (--aliascount <= 0)
+ {
+ err = BadFontName;
+ goto ContBadFontName;
+ }
+ }
+ else
+ {
+ c->saved = c->current;
+ c->haveSaved = TRUE;
+ free(c->savedName);
+ c->savedName = malloc(namelen + 1);
+ if (c->savedName)
+ memmove(c->savedName, name, namelen + 1);
+ c->savedNameLen = namelen;
+ aliascount = 20;
+ }
+ memmove(c->current.pattern, tmp_pattern, resolvedlen);
+ c->current.patlen = resolvedlen;
+ c->current.max_names = c->names->nnames + 1;
+ c->current.current_fpe = -1;
+ c->current.private = 0;
+ err = BadFontName;
+ }
+ }
+ /*
+ * At the end of this FPE, step to the next. If we've finished
+ * processing an alias, pop state back. If we've collected enough
+ * font names, quit.
+ */
+ if (err == BadFontName) {
+ ContBadFontName: ;
+ c->current.list_started = FALSE;
+ c->current.current_fpe++;
+ err = Successful;
+ if (c->haveSaved)
+ {
+ if (c->names->nnames == c->current.max_names ||
+ c->current.current_fpe == c->num_fpes) {
+ c->haveSaved = FALSE;
+ c->current = c->saved;
+ /* Give the saved namelist a chance to clean itself up */
+ continue;
+ }
+ }
+ if (c->names->nnames == c->current.max_names)
+ break;
+ }
+ }
+
+ /*
+ * send the reply
+ */
+ if (err != Successful) {
+ SendErrorToClient(client, X_ListFonts, 0, 0, FontToXError(err));
+ goto bail;
+ }
+
+finish:
+
+ names = c->names;
+ nnames = names->nnames;
+ client = c->client;
+ stringLens = 0;
+ for (i = 0; i < nnames; i++)
+ stringLens += (names->length[i] <= 255) ? names->length[i] : 0;
+
+ memset(&reply, 0, sizeof(xListFontsReply));
+ reply.type = X_Reply;
+ reply.length = bytes_to_int32(stringLens + nnames);
+ reply.nFonts = nnames;
+ reply.sequenceNumber = client->sequence;
+
+ bufptr = bufferStart = malloc(reply.length << 2);
+
+ if (!bufptr && reply.length) {
+ SendErrorToClient(client, X_ListFonts, 0, 0, BadAlloc);
+ goto bail;
+ }
+ /*
+ * since WriteToClient long word aligns things, copy to temp buffer and
+ * write all at once
+ */
+ for (i = 0; i < nnames; i++) {
+ if (names->length[i] > 255)
+ reply.nFonts--;
+ else
+ {
+ *bufptr++ = names->length[i];
+ memmove( bufptr, names->names[i], names->length[i]);
+ bufptr += names->length[i];
+ }
+ }
+ nnames = reply.nFonts;
+ reply.length = bytes_to_int32(stringLens + nnames);
+ client->pSwapReplyFunc = ReplySwapVector[X_ListFonts];
+ WriteSwappedDataToClient(client, sizeof(xListFontsReply), &reply);
+ (void) WriteToClient(client, stringLens + nnames, bufferStart);
+ free(bufferStart);
+
+bail:
+ ClientWakeup(client);
+xinerama_sleep:
+ for (i = 0; i < c->num_fpes; i++)
+ FreeFPE(c->fpe_list[i]);
+ free(c->fpe_list);
+ free(c->savedName);
+ FreeFontNames(names);
+ free(c);
+ free(resolved);
+ return TRUE;
+}
+
+int
+ListFonts(ClientPtr client, unsigned char *pattern, unsigned length,
+ unsigned max_names)
+{
+ int i;
+ LFclosurePtr c;
+
+ /*
+ * The right error to return here would be BadName, however the
+ * specification does not allow for a Name error on this request.
+ * Perhaps a better solution would be to return a nil list, i.e.
+ * a list containing zero fontnames.
+ */
+ if (length > XLFDMAXFONTNAMELEN)
+ return BadAlloc;
+
+ i = XaceHook(XACE_SERVER_ACCESS, client, DixGetAttrAccess);
+ if (i != Success)
+ return i;
+
+ if (!(c = malloc(sizeof *c)))
+ return BadAlloc;
+ c->fpe_list = malloc(sizeof(FontPathElementPtr) * num_fpes);
+ if (!c->fpe_list) {
+ free(c);
+ return BadAlloc;
+ }
+ c->names = MakeFontNamesRecord(max_names < 100 ? max_names : 100);
+ if (!c->names)
+ {
+ free(c->fpe_list);
+ free(c);
+ return BadAlloc;
+ }
+ memmove( c->current.pattern, pattern, length);
+ for (i = 0; i < num_fpes; i++) {
+ c->fpe_list[i] = font_path_elements[i];
+ UseFPE(c->fpe_list[i]);
+ }
+ c->client = client;
+ c->num_fpes = num_fpes;
+ c->current.patlen = length;
+ c->current.current_fpe = 0;
+ c->current.max_names = max_names;
+ c->current.list_started = FALSE;
+ c->current.private = 0;
+ c->haveSaved = FALSE;
+ c->savedName = 0;
+ doListFontsAndAliases(client, c);
+ return Success;
+}
+
+int
+doListFontsWithInfo(ClientPtr client, LFWIclosurePtr c)
+{
+ FontPathElementPtr fpe;
+ int err = Successful;
+ char *name;
+ int namelen;
+ int numFonts;
+ FontInfoRec fontInfo,
+ *pFontInfo;
+ xListFontsWithInfoReply *reply;
+ int length;
+ xFontProp *pFP;
+ int i;
+ int aliascount = 0;
+ xListFontsWithInfoReply finalReply;
+
+ if (client->clientGone)
+ {
+ if (c->current.current_fpe < c->num_fpes)
+ {
+ fpe = c->fpe_list[c->current.current_fpe];
+ (*fpe_functions[fpe->type].client_died) ((pointer) client, fpe);
+ }
+ err = Successful;
+ goto bail;
+ }
+ client->pSwapReplyFunc = ReplySwapVector[X_ListFontsWithInfo];
+ if (!c->current.patlen)
+ goto finish;
+ while (c->current.current_fpe < c->num_fpes)
+ {
+ fpe = c->fpe_list[c->current.current_fpe];
+ err = Successful;
+ if (!c->current.list_started)
+ {
+ err = (*fpe_functions[fpe->type].start_list_fonts_with_info)
+ (client, fpe, c->current.pattern, c->current.patlen,
+ c->current.max_names, &c->current.private);
+ if (err == Suspended)
+ {
+ if (!ClientIsAsleep(client))
+ ClientSleep(client,
+ (ClientSleepProcPtr)doListFontsWithInfo, c);
+ else
+ goto xinerama_sleep;
+ return TRUE;
+ }
+ if (err == Successful)
+ c->current.list_started = TRUE;
+ }
+ if (err == Successful)
+ {
+ name = 0;
+ pFontInfo = &fontInfo;
+ err = (*fpe_functions[fpe->type].list_next_font_with_info)
+ (client, fpe, &name, &namelen, &pFontInfo,
+ &numFonts, c->current.private);
+ if (err == Suspended)
+ {
+ if (!ClientIsAsleep(client))
+ ClientSleep(client,
+ (ClientSleepProcPtr)doListFontsWithInfo, c);
+ else
+ goto xinerama_sleep;
+ return TRUE;
+ }
+ }
+ /*
+ * When we get an alias back, save our state and reset back to the
+ * start of the FPE looking for the specified name. As soon as a real
+ * font is found for the alias, pop back to the old state
+ */
+ if (err == FontNameAlias)
+ {
+ /*
+ * when an alias recurses, we need to give
+ * the last FPE a chance to clean up; so we call
+ * it again, and assume that the error returned
+ * is BadFontName, indicating the alias resolution
+ * is complete.
+ */
+ if (c->haveSaved)
+ {
+ char *tmpname;
+ int tmpnamelen;
+ FontInfoPtr tmpFontInfo;
+
+ tmpname = 0;
+ tmpFontInfo = &fontInfo;
+ (void) (*fpe_functions[fpe->type].list_next_font_with_info)
+ (client, fpe, &tmpname, &tmpnamelen, &tmpFontInfo,
+ &numFonts, c->current.private);
+ if (--aliascount <= 0)
+ {
+ err = BadFontName;
+ goto ContBadFontName;
+ }
+ }
+ else
+ {
+ c->saved = c->current;
+ c->haveSaved = TRUE;
+ c->savedNumFonts = numFonts;
+ free(c->savedName);
+ c->savedName = malloc(namelen + 1);
+ if (c->savedName)
+ memmove(c->savedName, name, namelen + 1);
+ aliascount = 20;
+ }
+ memmove(c->current.pattern, name, namelen);
+ c->current.patlen = namelen;
+ c->current.max_names = 1;
+ c->current.current_fpe = 0;
+ c->current.private = 0;
+ c->current.list_started = FALSE;
+ }
+ /*
+ * At the end of this FPE, step to the next. If we've finished
+ * processing an alias, pop state back. If we've sent enough font
+ * names, quit. Always wait for BadFontName to let the FPE
+ * have a chance to clean up.
+ */
+ else if (err == BadFontName)
+ {
+ ContBadFontName: ;
+ c->current.list_started = FALSE;
+ c->current.current_fpe++;
+ err = Successful;
+ if (c->haveSaved)
+ {
+ if (c->current.max_names == 0 ||
+ c->current.current_fpe == c->num_fpes)
+ {
+ c->haveSaved = FALSE;
+ c->saved.max_names -= (1 - c->current.max_names);
+ c->current = c->saved;
+ }
+ }
+ else if (c->current.max_names == 0)
+ break;
+ }
+ else if (err == Successful)
+ {
+ length = sizeof(*reply) + pFontInfo->nprops * sizeof(xFontProp);
+ reply = c->reply;
+ if (c->length < length)
+ {
+ reply = (xListFontsWithInfoReply *) realloc(c->reply, length);
+ if (!reply)
+ {
+ err = AllocError;
+ break;
+ }
+ memset((char*)reply + c->length, 0, length - c->length);
+ c->reply = reply;
+ c->length = length;
+ }
+ if (c->haveSaved)
+ {
+ numFonts = c->savedNumFonts;
+ name = c->savedName;
+ namelen = strlen(name);
+ }
+ reply->type = X_Reply;
+ reply->length = bytes_to_int32(sizeof *reply - sizeof(xGenericReply) +
+ pFontInfo->nprops * sizeof(xFontProp) +
+ namelen);
+ reply->sequenceNumber = client->sequence;
+ reply->nameLength = namelen;
+ reply->minBounds = pFontInfo->ink_minbounds;
+ reply->maxBounds = pFontInfo->ink_maxbounds;
+ reply->minCharOrByte2 = pFontInfo->firstCol;
+ reply->maxCharOrByte2 = pFontInfo->lastCol;
+ reply->defaultChar = pFontInfo->defaultCh;
+ reply->nFontProps = pFontInfo->nprops;
+ reply->drawDirection = pFontInfo->drawDirection;
+ reply->minByte1 = pFontInfo->firstRow;
+ reply->maxByte1 = pFontInfo->lastRow;
+ reply->allCharsExist = pFontInfo->allExist;
+ reply->fontAscent = pFontInfo->fontAscent;
+ reply->fontDescent = pFontInfo->fontDescent;
+ reply->nReplies = numFonts;
+ pFP = (xFontProp *) (reply + 1);
+ for (i = 0; i < pFontInfo->nprops; i++)
+ {
+ pFP->name = pFontInfo->props[i].name;
+ pFP->value = pFontInfo->props[i].value;
+ pFP++;
+ }
+ WriteSwappedDataToClient(client, length, reply);
+ (void) WriteToClient(client, namelen, name);
+ if (pFontInfo == &fontInfo)
+ {
+ free(fontInfo.props);
+ free(fontInfo.isStringProp);
+ }
+ --c->current.max_names;
+ }
+ }
+finish:
+ length = sizeof(xListFontsWithInfoReply);
+ memset((char *) &finalReply, 0, sizeof(xListFontsWithInfoReply));
+ finalReply.type = X_Reply;
+ finalReply.sequenceNumber = client->sequence;
+ finalReply.length = bytes_to_int32(sizeof(xListFontsWithInfoReply)
+ - sizeof(xGenericReply));
+ WriteSwappedDataToClient(client, length, &finalReply);
+bail:
+ ClientWakeup(client);
+xinerama_sleep:
+ for (i = 0; i < c->num_fpes; i++)
+ FreeFPE(c->fpe_list[i]);
+ free(c->reply);
+ free(c->fpe_list);
+ free(c->savedName);
+ free(c);
+ return TRUE;
+}
+
+int
+StartListFontsWithInfo(ClientPtr client, int length, unsigned char *pattern,
+ int max_names)
+{
+ int i;
+ LFWIclosurePtr c;
+
+ /*
+ * The right error to return here would be BadName, however the
+ * specification does not allow for a Name error on this request.
+ * Perhaps a better solution would be to return a nil list, i.e.
+ * a list containing zero fontnames.
+ */
+ if (length > XLFDMAXFONTNAMELEN)
+ return BadAlloc;
+
+ i = XaceHook(XACE_SERVER_ACCESS, client, DixGetAttrAccess);
+ if (i != Success)
+ return i;
+
+ if (!(c = malloc(sizeof *c)))
+ goto badAlloc;
+ c->fpe_list = malloc(sizeof(FontPathElementPtr) * num_fpes);
+ if (!c->fpe_list)
+ {
+ free(c);
+ goto badAlloc;
+ }
+ memmove(c->current.pattern, pattern, length);
+ for (i = 0; i < num_fpes; i++)
+ {
+ c->fpe_list[i] = font_path_elements[i];
+ UseFPE(c->fpe_list[i]);
+ }
+ c->client = client;
+ c->num_fpes = num_fpes;
+ c->reply = 0;
+ c->length = 0;
+ c->current.patlen = length;
+ c->current.current_fpe = 0;
+ c->current.max_names = max_names;
+ c->current.list_started = FALSE;
+ c->current.private = 0;
+ c->savedNumFonts = 0;
+ c->haveSaved = FALSE;
+ c->savedName = 0;
+ doListFontsWithInfo(client, c);
+ return Success;
+badAlloc:
+ return BadAlloc;
+}
+
+#define TextEltHeader 2
+#define FontShiftSize 5
+static ChangeGCVal clearGC[] = { NullPixmap };
+#define clearGCmask (GCClipMask)
+
+int
+doPolyText(ClientPtr client, PTclosurePtr c)
+{
+ FontPtr pFont = c->pGC->font, oldpFont;
+ int err = Success, lgerr; /* err is in X error, not font error, space */
+ enum { NEVER_SLEPT, START_SLEEP, SLEEPING } client_state = NEVER_SLEPT;
+ FontPathElementPtr fpe;
+ GC *origGC = NULL;
+ int itemSize = c->reqType == X_PolyText8 ? 1 : 2;
+
+ if (client->clientGone)
+ {
+ fpe = c->pGC->font->fpe;
+ (*fpe_functions[fpe->type].client_died) ((pointer) client, fpe);
+
+ if (ClientIsAsleep(client))
+ {
+ /* Client has died, but we cannot bail out right now. We
+ need to clean up after the work we did when going to
+ sleep. Setting the drawable pointer to 0 makes this
+ happen without any attempts to render or perform other
+ unnecessary activities. */
+ c->pDraw = (DrawablePtr)0;
+ }
+ else
+ {
+ err = Success;
+ goto bail;
+ }
+ }
+
+ /* Make sure our drawable hasn't disappeared while we slept. */
+ if (ClientIsAsleep(client) && c->pDraw)
+ {
+ DrawablePtr pDraw;
+ dixLookupDrawable(&pDraw, c->did, client, 0, DixWriteAccess);
+ if (c->pDraw != pDraw) {
+ /* Our drawable has disappeared. Treat like client died... ask
+ the FPE code to clean up after client and avoid further
+ rendering while we clean up after ourself. */
+ fpe = c->pGC->font->fpe;
+ (*fpe_functions[fpe->type].client_died) ((pointer) client, fpe);
+ c->pDraw = (DrawablePtr)0;
+ }
+ }
+
+ client_state = ClientIsAsleep(client) ? SLEEPING : NEVER_SLEPT;
+
+ while (c->endReq - c->pElt > TextEltHeader)
+ {
+ if (*c->pElt == FontChange)
+ {
+ Font fid;
+ if (c->endReq - c->pElt < FontShiftSize)
+ {
+ err = BadLength;
+ goto bail;
+ }
+
+ oldpFont = pFont;
+
+ fid = ((Font)*(c->pElt+4)) /* big-endian */
+ | ((Font)*(c->pElt+3)) << 8
+ | ((Font)*(c->pElt+2)) << 16
+ | ((Font)*(c->pElt+1)) << 24;
+ err = dixLookupResourceByType((pointer *)&pFont, fid, RT_FONT,
+ client, DixUseAccess);
+ if (err != Success)
+ {
+ /* restore pFont for step 4 (described below) */
+ pFont = oldpFont;
+
+ /* If we're in START_SLEEP mode, the following step
+ shortens the request... in the unlikely event that
+ the fid somehow becomes valid before we come through
+ again to actually execute the polytext, which would
+ then mess up our refcounting scheme badly. */
+ c->err = err;
+ c->endReq = c->pElt;
+
+ goto bail;
+ }
+
+ /* Step 3 (described below) on our new font */
+ if (client_state == START_SLEEP)
+ pFont->refcnt++;
+ else
+ {
+ if (pFont != c->pGC->font && c->pDraw)
+ {
+ ChangeGCVal val;
+ val.ptr = pFont;
+ ChangeGC(NullClient, c->pGC, GCFont, &val);
+ ValidateGC(c->pDraw, c->pGC);
+ }
+
+ /* Undo the refcnt++ we performed when going to sleep */
+ if (client_state == SLEEPING)
+ (void)CloseFont(c->pGC->font, (Font)0);
+ }
+ c->pElt += FontShiftSize;
+ }
+ else /* print a string */
+ {
+ unsigned char *pNextElt;
+ pNextElt = c->pElt + TextEltHeader + (*c->pElt) * itemSize;
+ if ( pNextElt > c->endReq)
+ {
+ err = BadLength;
+ goto bail;
+ }
+ if (client_state == START_SLEEP)
+ {
+ c->pElt = pNextElt;
+ continue;
+ }
+ if (c->pDraw)
+ {
+ lgerr = LoadGlyphs(client, c->pGC->font, *c->pElt, itemSize,
+ c->pElt + TextEltHeader);
+ }
+ else lgerr = Successful;
+
+ if (lgerr == Suspended)
+ {
+ if (!ClientIsAsleep(client)) {
+ int len;
+ GC *pGC;
+ PTclosurePtr new_closure;
+
+ /* We're putting the client to sleep. We need to do a few things
+ to ensure successful and atomic-appearing execution of the
+ remainder of the request. First, copy the remainder of the
+ request into a safe malloc'd area. Second, create a scratch GC
+ to use for the remainder of the request. Third, mark all fonts
+ referenced in the remainder of the request to prevent their
+ deallocation. Fourth, make the original GC look like the
+ request has completed... set its font to the final font value
+ from this request. These GC manipulations are for the unlikely
+ (but possible) event that some other client is using the GC.
+ Steps 3 and 4 are performed by running this procedure through
+ the remainder of the request in a special no-render mode
+ indicated by client_state = START_SLEEP. */
+
+ /* Step 1 */
+ /* Allocate a malloc'd closure structure to replace
+ the local one we were passed */
+ new_closure = malloc(sizeof(PTclosureRec));
+ if (!new_closure)
+ {
+ err = BadAlloc;
+ goto bail;
+ }
+ *new_closure = *c;
+ c = new_closure;
+
+ len = c->endReq - c->pElt;
+ c->data = malloc(len);
+ if (!c->data)
+ {
+ free(c);
+ err = BadAlloc;
+ goto bail;
+ }
+ memmove(c->data, c->pElt, len);
+ c->pElt = c->data;
+ c->endReq = c->pElt + len;
+
+ /* Step 2 */
+
+ pGC = GetScratchGC(c->pGC->depth, c->pGC->pScreen);
+ if (!pGC)
+ {
+ free(c->data);
+ free(c);
+ err = BadAlloc;
+ goto bail;
+ }
+ if ((err = CopyGC(c->pGC, pGC, GCFunction |
+ GCPlaneMask | GCForeground |
+ GCBackground | GCFillStyle |
+ GCTile | GCStipple |
+ GCTileStipXOrigin |
+ GCTileStipYOrigin | GCFont |
+ GCSubwindowMode | GCClipXOrigin |
+ GCClipYOrigin | GCClipMask)) !=
+ Success)
+ {
+ FreeScratchGC(pGC);
+ free(c->data);
+ free(c);
+ err = BadAlloc;
+ goto bail;
+ }
+ origGC = c->pGC;
+ c->pGC = pGC;
+ ValidateGC(c->pDraw, c->pGC);
+
+ ClientSleep(client, (ClientSleepProcPtr)doPolyText, c);
+
+ /* Set up to perform steps 3 and 4 */
+ client_state = START_SLEEP;
+ continue; /* on to steps 3 and 4 */
+ }
+ else
+ goto xinerama_sleep;
+ return TRUE;
+ }
+ else if (lgerr != Successful)
+ {
+ err = FontToXError(lgerr);
+ goto bail;
+ }
+ if (c->pDraw)
+ {
+ c->xorg += *((INT8 *)(c->pElt + 1)); /* must be signed */
+ if (c->reqType == X_PolyText8)
+ c->xorg = (* c->pGC->ops->PolyText8)(c->pDraw, c->pGC, c->xorg, c->yorg,
+ *c->pElt, (char *) (c->pElt + TextEltHeader));
+ else
+ c->xorg = (* c->pGC->ops->PolyText16)(c->pDraw, c->pGC, c->xorg, c->yorg,
+ *c->pElt, (unsigned short *) (c->pElt + TextEltHeader));
+ }
+ c->pElt = pNextElt;
+ }
+ }
+
+bail:
+
+ if (client_state == START_SLEEP)
+ {
+ /* Step 4 */
+ if (pFont != origGC->font)
+ {
+ ChangeGCVal val;
+ val.ptr = pFont;
+ ChangeGC(NullClient, origGC, GCFont, &val);
+ ValidateGC(c->pDraw, origGC);
+ }
+
+ /* restore pElt pointer for execution of remainder of the request */
+ c->pElt = c->data;
+ return TRUE;
+ }
+
+ if (c->err != Success) err = c->err;
+ if (err != Success && c->client != serverClient) {
+#ifdef PANORAMIX
+ if (noPanoramiXExtension || !c->pGC->pScreen->myNum)
+#endif
+ SendErrorToClient(c->client, c->reqType, 0, 0, err);
+ }
+ if (ClientIsAsleep(client))
+ {
+ ClientWakeup(c->client);
+xinerama_sleep:
+ ChangeGC(NullClient, c->pGC, clearGCmask, clearGC);
+
+ /* Unreference the font from the scratch GC */
+ CloseFont(c->pGC->font, (Font)0);
+ c->pGC->font = NullFont;
+
+ FreeScratchGC(c->pGC);
+ free(c->data);
+ free(c);
+ }
+ return TRUE;
+}
+
+int
+PolyText(ClientPtr client, DrawablePtr pDraw, GC *pGC, unsigned char *pElt,
+ unsigned char *endReq, int xorg, int yorg, int reqType, XID did)
+{
+ PTclosureRec local_closure;
+
+ local_closure.pElt = pElt;
+ local_closure.endReq = endReq;
+ local_closure.client = client;
+ local_closure.pDraw = pDraw;
+ local_closure.xorg = xorg;
+ local_closure.yorg = yorg;
+ local_closure.reqType = reqType;
+ local_closure.pGC = pGC;
+ local_closure.did = did;
+ local_closure.err = Success;
+
+ (void) doPolyText(client, &local_closure);
+ return Success;
+}
+
+
+#undef TextEltHeader
+#undef FontShiftSize
+
+int
+doImageText(ClientPtr client, ITclosurePtr c)
+{
+ int err = Success, lgerr; /* err is in X error, not font error, space */
+ FontPathElementPtr fpe;
+ int itemSize = c->reqType == X_ImageText8 ? 1 : 2;
+
+ if (client->clientGone)
+ {
+ fpe = c->pGC->font->fpe;
+ (*fpe_functions[fpe->type].client_died) ((pointer) client, fpe);
+ err = Success;
+ goto bail;
+ }
+
+ /* Make sure our drawable hasn't disappeared while we slept. */
+ if (ClientIsAsleep(client) && c->pDraw)
+ {
+ DrawablePtr pDraw;
+ dixLookupDrawable(&pDraw, c->did, client, 0, DixWriteAccess);
+ if (c->pDraw != pDraw) {
+ /* Our drawable has disappeared. Treat like client died... ask
+ the FPE code to clean up after client. */
+ fpe = c->pGC->font->fpe;
+ (*fpe_functions[fpe->type].client_died) ((pointer) client, fpe);
+ err = Success;
+ goto bail;
+ }
+ }
+
+ lgerr = LoadGlyphs(client, c->pGC->font, c->nChars, itemSize, c->data);
+ if (lgerr == Suspended)
+ {
+ if (!ClientIsAsleep(client)) {
+ GC *pGC;
+ unsigned char *data;
+ ITclosurePtr new_closure;
+
+ /* We're putting the client to sleep. We need to
+ save some state. Similar problem to that handled
+ in doPolyText, but much simpler because the
+ request structure is much simpler. */
+
+ new_closure = malloc(sizeof(ITclosureRec));
+ if (!new_closure)
+ {
+ err = BadAlloc;
+ goto bail;
+ }
+ *new_closure = *c;
+ c = new_closure;
+
+ data = malloc(c->nChars * itemSize);
+ if (!data)
+ {
+ free(c);
+ err = BadAlloc;
+ goto bail;
+ }
+ memmove(data, c->data, c->nChars * itemSize);
+ c->data = data;
+
+ pGC = GetScratchGC(c->pGC->depth, c->pGC->pScreen);
+ if (!pGC)
+ {
+ free(c->data);
+ free(c);
+ err = BadAlloc;
+ goto bail;
+ }
+ if ((err = CopyGC(c->pGC, pGC, GCFunction | GCPlaneMask |
+ GCForeground | GCBackground | GCFillStyle |
+ GCTile | GCStipple | GCTileStipXOrigin |
+ GCTileStipYOrigin | GCFont |
+ GCSubwindowMode | GCClipXOrigin |
+ GCClipYOrigin | GCClipMask)) != Success)
+ {
+ FreeScratchGC(pGC);
+ free(c->data);
+ free(c);
+ err = BadAlloc;
+ goto bail;
+ }
+ c->pGC = pGC;
+ ValidateGC(c->pDraw, c->pGC);
+
+ ClientSleep(client, (ClientSleepProcPtr)doImageText, c);
+ }
+ else
+ goto xinerama_sleep;
+ return TRUE;
+ }
+ else if (lgerr != Successful)
+ {
+ err = FontToXError(lgerr);
+ goto bail;
+ }
+ if (c->pDraw)
+ {
+ if (c->reqType == X_ImageText8)
+ (* c->pGC->ops->ImageText8)(c->pDraw, c->pGC, c->xorg, c->yorg,
+ c->nChars, (char *) c->data);
+ else
+ (* c->pGC->ops->ImageText16)(c->pDraw, c->pGC, c->xorg, c->yorg,
+ c->nChars, (unsigned short *) c->data);
+ }
+
+bail:
+
+ if (err != Success && c->client != serverClient) {
+ SendErrorToClient(c->client, c->reqType, 0, 0, err);
+ }
+ if (ClientIsAsleep(client))
+ {
+ ClientWakeup(c->client);
+xinerama_sleep:
+ ChangeGC(NullClient, c->pGC, clearGCmask, clearGC);
+
+ /* Unreference the font from the scratch GC */
+ CloseFont(c->pGC->font, (Font)0);
+ c->pGC->font = NullFont;
+
+ FreeScratchGC(c->pGC);
+ free(c->data);
+ free(c);
+ }
+ return TRUE;
+}
+
+int
+ImageText(ClientPtr client, DrawablePtr pDraw, GC *pGC, int nChars,
+ unsigned char *data, int xorg, int yorg, int reqType, XID did)
+{
+ ITclosureRec local_closure;
+
+ local_closure.client = client;
+ local_closure.pDraw = pDraw;
+ local_closure.pGC = pGC;
+ local_closure.nChars = nChars;
+ local_closure.data = data;
+ local_closure.xorg = xorg;
+ local_closure.yorg = yorg;
+ local_closure.reqType = reqType;
+ local_closure.did = did;
+
+ (void) doImageText(client, &local_closure);
+ return Success;
+}
+
+
+/* does the necessary magic to figure out the fpe type */
+static int
+DetermineFPEType(char *pathname)
+{
+ int i;
+
+ for (i = 0; i < num_fpe_types; i++) {
+ if ((*fpe_functions[i].name_check) (pathname))
+ return i;
+ }
+ return -1;
+}
+
+
+static void
+FreeFontPath(FontPathElementPtr *list, int n, Bool force)
+{
+ int i;
+
+ for (i = 0; i < n; i++) {
+ if (force) {
+ /* Sanity check that all refcounts will be 0 by the time
+ we get to the end of the list. */
+ int found = 1; /* the first reference is us */
+ int j;
+ for (j = i+1; j < n; j++) {
+ if (list[j] == list[i])
+ found++;
+ }
+ if (list[i]->refcount != found) {
+ list[i]->refcount = found; /* ensure it will get freed */
+ }
+ }
+ FreeFPE(list[i]);
+ }
+ free(list);
+}
+
+static FontPathElementPtr
+find_existing_fpe(FontPathElementPtr *list, int num, unsigned char *name, int len)
+{
+ FontPathElementPtr fpe;
+ int i;
+
+ for (i = 0; i < num; i++) {
+ fpe = list[i];
+ if (fpe->name_length == len && memcmp(name, fpe->name, len) == 0)
+ return fpe;
+ }
+ return (FontPathElementPtr) 0;
+}
+
+
+static int
+SetFontPathElements(int npaths, unsigned char *paths, int *bad, Bool persist)
+{
+ int i, err = 0;
+ int valid_paths = 0;
+ unsigned int len;
+ unsigned char *cp = paths;
+ FontPathElementPtr fpe = NULL, *fplist;
+
+ fplist = malloc(sizeof(FontPathElementPtr) * npaths);
+ if (!fplist) {
+ *bad = 0;
+ return BadAlloc;
+ }
+ for (i = 0; i < num_fpe_types; i++) {
+ if (fpe_functions[i].set_path_hook)
+ (*fpe_functions[i].set_path_hook) ();
+ }
+ for (i = 0; i < npaths; i++)
+ {
+ len = (unsigned int) (*cp++);
+
+ if (len == 0)
+ {
+ if (persist)
+ ErrorF("[dix] Removing empty element from the valid list of fontpaths\n");
+ err = BadValue;
+ }
+ else
+ {
+ /* if it's already in our active list, just reset it */
+ /*
+ * note that this can miss FPE's in limbo -- may be worth catching
+ * them, though it'd muck up refcounting
+ */
+ fpe = find_existing_fpe(font_path_elements, num_fpes, cp, len);
+ if (fpe)
+ {
+ err = (*fpe_functions[fpe->type].reset_fpe) (fpe);
+ if (err == Successful)
+ {
+ UseFPE(fpe);/* since it'll be decref'd later when freed
+ * from the old list */
+ }
+ else
+ fpe = 0;
+ }
+ /* if error or can't do it, act like it's a new one */
+ if (!fpe)
+ {
+ fpe = malloc(sizeof(FontPathElementRec));
+ if (!fpe)
+ {
+ err = BadAlloc;
+ goto bail;
+ }
+ fpe->name = malloc(len + 1);
+ if (!fpe->name)
+ {
+ free(fpe);
+ err = BadAlloc;
+ goto bail;
+ }
+ fpe->refcount = 1;
+
+ strncpy(fpe->name, (char *) cp, (int) len);
+ fpe->name[len] = '\0';
+ fpe->name_length = len;
+ fpe->type = DetermineFPEType(fpe->name);
+ if (fpe->type == -1)
+ err = BadValue;
+ else
+ err = (*fpe_functions[fpe->type].init_fpe) (fpe);
+ if (err != Successful)
+ {
+ if (persist)
+ {
+ ErrorF("[dix] Could not init font path element %s, removing from list!\n",
+ fpe->name);
+ }
+ free(fpe->name);
+ free(fpe);
+ }
+ }
+ }
+ if (err != Successful)
+ {
+ if (!persist)
+ goto bail;
+ }
+ else
+ {
+ fplist[valid_paths++] = fpe;
+ }
+ cp += len;
+ }
+
+ FreeFontPath(font_path_elements, num_fpes, FALSE);
+ font_path_elements = fplist;
+ if (patternCache)
+ EmptyFontPatternCache(patternCache);
+ num_fpes = valid_paths;
+
+ return Success;
+bail:
+ *bad = i;
+ while (--valid_paths >= 0)
+ FreeFPE(fplist[valid_paths]);
+ free(fplist);
+ return FontToXError(err);
+}
+
+int
+SetFontPath(ClientPtr client, int npaths, unsigned char *paths)
+{
+ int err = XaceHook(XACE_SERVER_ACCESS, client, DixManageAccess);
+ if (err != Success)
+ return err;
+
+ if (npaths == 0) {
+ if (SetDefaultFontPath(defaultFontPath) != Success)
+ return BadValue;
+ } else {
+ int bad;
+ err = SetFontPathElements(npaths, paths, &bad, FALSE);
+ client->errorValue = bad;
+ }
+ return err;
+}
+
+int
+SetDefaultFontPath(char *path)
+{
+ char *temp_path,
+ *start,
+ *end;
+ unsigned char *cp,
+ *pp,
+ *nump,
+ *newpath;
+ int num = 1,
+ len,
+ err,
+ size = 0,
+ bad;
+
+ /* ensure temp_path contains "built-ins" */
+ start = path;
+ while (1) {
+ start = strstr(start, "built-ins");
+ if (start == NULL)
+ break;
+ end = start + strlen("built-ins");
+ if ((start == path || start[-1] == ',') && (!*end || *end == ','))
+ break;
+ start = end;
+ }
+ if (!start) {
+ if (asprintf(&temp_path, "%s%sbuilt-ins", path, *path ? "," : "")
+ == -1)
+ temp_path = NULL;
+ } else {
+ temp_path = strdup(path);
+ }
+ if (!temp_path)
+ return BadAlloc;
+
+ /* get enough for string, plus values -- use up commas */
+ len = strlen(temp_path) + 1;
+ nump = cp = newpath = malloc(len);
+ if (!newpath)
+ return BadAlloc;
+ pp = (unsigned char *) temp_path;
+ cp++;
+ while (*pp) {
+ if (*pp == ',') {
+ *nump = (unsigned char) size;
+ nump = cp++;
+ pp++;
+ num++;
+ size = 0;
+ } else {
+ *cp++ = *pp++;
+ size++;
+ }
+ }
+ *nump = (unsigned char) size;
+
+ err = SetFontPathElements(num, newpath, &bad, TRUE);
+
+ free(newpath);
+ free(temp_path);
+
+ return err;
+}
+
+int
+GetFontPath(ClientPtr client, int *count, int *length, unsigned char **result)
+{
+ int i;
+ unsigned char *c;
+ int len;
+ FontPathElementPtr fpe;
+
+ i = XaceHook(XACE_SERVER_ACCESS, client, DixGetAttrAccess);
+ if (i != Success)
+ return i;
+
+ len = 0;
+ for (i = 0; i < num_fpes; i++) {
+ fpe = font_path_elements[i];
+ len += fpe->name_length + 1;
+ }
+ font_path_string = (unsigned char *) realloc(font_path_string, len);
+ if (!font_path_string)
+ return BadAlloc;
+
+ c = font_path_string;
+ *length = 0;
+ for (i = 0; i < num_fpes; i++) {
+ fpe = font_path_elements[i];
+ *c = fpe->name_length;
+ *length += *c++;
+ memmove(c, fpe->name, fpe->name_length);
+ c += fpe->name_length;
+ }
+ *count = num_fpes;
+ *result = font_path_string;
+ return Success;
+}
+
+void
+DeleteClientFontStuff(ClientPtr client)
+{
+ int i;
+ FontPathElementPtr fpe;
+
+ for (i = 0; i < num_fpes; i++)
+ {
+ fpe = font_path_elements[i];
+ if (fpe_functions[fpe->type].client_died)
+ (*fpe_functions[fpe->type].client_died) ((pointer) client, fpe);
+ }
+}
+
+void
+InitFonts (void)
+{
+ patternCache = MakeFontPatternCache();
+
+ register_fpe_functions();
+}
+
+int
+GetDefaultPointSize (void)
+{
+ return 120;
+}
+
+
+FontResolutionPtr
+GetClientResolutions (int *num)
+{
+ static struct _FontResolution res;
+ ScreenPtr pScreen;
+
+ pScreen = screenInfo.screens[0];
+ res.x_resolution = (pScreen->width * 25.4) / pScreen->mmWidth;
+ /*
+ * XXX - we'll want this as long as bitmap instances are prevalent
+ so that we can match them from scalable fonts
+ */
+ if (res.x_resolution < 88)
+ res.x_resolution = 75;
+ else
+ res.x_resolution = 100;
+ res.y_resolution = (pScreen->height * 25.4) / pScreen->mmHeight;
+ if (res.y_resolution < 88)
+ res.y_resolution = 75;
+ else
+ res.y_resolution = 100;
+ res.point_size = 120;
+ *num = 1;
+ return &res;
+}
+
+/*
+ * returns the type index of the new fpe
+ *
+ * should be called (only once!) by each type of fpe when initialized
+ */
+
+int
+RegisterFPEFunctions(NameCheckFunc name_func,
+ InitFpeFunc init_func,
+ FreeFpeFunc free_func,
+ ResetFpeFunc reset_func,
+ OpenFontFunc open_func,
+ CloseFontFunc close_func,
+ ListFontsFunc list_func,
+ StartLfwiFunc start_lfwi_func,
+ NextLfwiFunc next_lfwi_func,
+ WakeupFpeFunc wakeup_func,
+ ClientDiedFunc client_died,
+ LoadGlyphsFunc load_glyphs,
+ StartLaFunc start_list_alias_func,
+ NextLaFunc next_list_alias_func,
+ SetPathFunc set_path_func)
+{
+ FPEFunctions *new;
+
+ /* grow the list */
+ new = (FPEFunctions *) realloc(fpe_functions,
+ (num_fpe_types + 1) * sizeof(FPEFunctions));
+ if (!new)
+ return -1;
+ fpe_functions = new;
+
+ fpe_functions[num_fpe_types].name_check = name_func;
+ fpe_functions[num_fpe_types].open_font = open_func;
+ fpe_functions[num_fpe_types].close_font = close_func;
+ fpe_functions[num_fpe_types].wakeup_fpe = wakeup_func;
+ fpe_functions[num_fpe_types].list_fonts = list_func;
+ fpe_functions[num_fpe_types].start_list_fonts_with_info =
+ start_lfwi_func;
+ fpe_functions[num_fpe_types].list_next_font_with_info =
+ next_lfwi_func;
+ fpe_functions[num_fpe_types].init_fpe = init_func;
+ fpe_functions[num_fpe_types].free_fpe = free_func;
+ fpe_functions[num_fpe_types].reset_fpe = reset_func;
+ fpe_functions[num_fpe_types].client_died = client_died;
+ fpe_functions[num_fpe_types].load_glyphs = load_glyphs;
+ fpe_functions[num_fpe_types].start_list_fonts_and_aliases =
+ start_list_alias_func;
+ fpe_functions[num_fpe_types].list_next_font_or_alias =
+ next_list_alias_func;
+ fpe_functions[num_fpe_types].set_path_hook = set_path_func;
+
+ return num_fpe_types++;
+}
+
+void
+FreeFonts(void)
+{
+ if (patternCache) {
+ FreeFontPatternCache(patternCache);
+ patternCache = 0;
+ }
+ FreeFontPath(font_path_elements, num_fpes, TRUE);
+ font_path_elements = 0;
+ num_fpes = 0;
+ free(fpe_functions);
+ num_fpe_types = 0;
+ fpe_functions = (FPEFunctions *) 0;
+}
+
+/* convenience functions for FS interface */
+
+FontPtr
+find_old_font(XID id)
+{
+ pointer pFont;
+ dixLookupResourceByType(&pFont, id, RT_NONE, serverClient, DixReadAccess);
+ return (FontPtr)pFont;
+}
+
+Font
+GetNewFontClientID(void)
+{
+ return FakeClientID(0);
+}
+
+int
+StoreFontClientFont(FontPtr pfont, Font id)
+{
+ return AddResource(id, RT_NONE, (pointer) pfont);
+}
+
+void
+DeleteFontClientID(Font id)
+{
+ FreeResource(id, RT_NONE);
+}
+
+int
+client_auth_generation(ClientPtr client)
+{
+ return 0;
+}
+
+static int fs_handlers_installed = 0;
+static unsigned int last_server_gen;
+
+int
+init_fs_handlers(FontPathElementPtr fpe, BlockHandlerProcPtr block_handler)
+{
+ /* if server has reset, make sure the b&w handlers are reinstalled */
+ if (last_server_gen < serverGeneration) {
+ last_server_gen = serverGeneration;
+ fs_handlers_installed = 0;
+ }
+ if (fs_handlers_installed == 0) {
+ if (!RegisterBlockAndWakeupHandlers(block_handler,
+ FontWakeup, (pointer) 0))
+ return AllocError;
+ fs_handlers_installed++;
+ }
+ QueueFontWakeup(fpe);
+ return Successful;
+}
+
+void
+remove_fs_handlers(FontPathElementPtr fpe, BlockHandlerProcPtr block_handler, Bool all)
+{
+ if (all) {
+ /* remove the handlers if no one else is using them */
+ if (--fs_handlers_installed == 0) {
+ RemoveBlockAndWakeupHandlers(block_handler, FontWakeup,
+ (pointer) 0);
+ }
+ }
+ RemoveFontWakeup(fpe);
+}
diff --git a/xorg-server/hw/xfree86/common/Makefile.am b/xorg-server/hw/xfree86/common/Makefile.am
index 56caaa5ab..c031d4be3 100644
--- a/xorg-server/hw/xfree86/common/Makefile.am
+++ b/xorg-server/hw/xfree86/common/Makefile.am
@@ -1,93 +1,92 @@
-noinst_LTLIBRARIES = libcommon.la
-
-if XORG_BUS_SPARC
-SBUS_SOURCES = xf86sbusBus.c
-endif
-
-if XV
-XVSOURCES = xf86xv.c xf86xvmc.c
-XVSDKINCS = xf86xv.h xf86xvmc.h xf86xvpriv.h
-endif
-
-if XF86VIDMODE
-XF86VMODE_SDK = vidmodeproc.h
-endif
-
-if DGA
-DGASOURCES = xf86DGA.c
-endif
-
-RANDRSOURCES = xf86RandR.c
-
-BUSSOURCES = xf86pciBus.c xf86fbBus.c xf86noBus.c $(SBUS_SOURCES)
-
-MODEDEFSOURCES = $(srcdir)/vesamodes $(srcdir)/extramodes
-
-xf86DefModeSet.c: $(srcdir)/modeline2c.awk $(MODEDEFSOURCES)
- $(AM_V_GEN)cat $(MODEDEFSOURCES) | LC_ALL=C $(AWK) -f $(srcdir)/modeline2c.awk > $@
- $(AM_V_GEN)echo >> $@
-
-BUILT_SOURCES = xf86DefModeSet.c
-
-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 \
- xf86VidMode.c xf86fbman.c xf86cmap.c \
- xf86Helper.c xf86PM.c xf86Xinput.c xisb.c \
- xf86Mode.c xorgHelper.c \
- $(XVSOURCES) $(BUSSOURCES) $(RANDRSOURCES)
-nodist_libcommon_la_SOURCES = xf86DefModeSet.c xf86Build.h
-libcommon_la_LIBADD = $(top_builddir)/config/libconfig.la
-
-INCLUDES = $(XORG_INCS) -I$(srcdir)/../ddc -I$(srcdir)/../i2c \
- -I$(srcdir)/../loader -I$(srcdir)/../parser \
- -I$(srcdir)/../vbe -I$(srcdir)/../int10 \
- -I$(srcdir)/../vgahw -I$(srcdir)/../dixmods/extmod \
- -I$(srcdir)/../modes -I$(srcdir)/../ramdac
-
-sdk_HEADERS = compiler.h fourcc.h xf86.h xf86Module.h xf86Opt.h \
- xf86PciInfo.h xf86Priv.h xf86Privstr.h \
- xf86cmap.h xf86fbman.h xf86str.h xf86Xinput.h xisb.h \
- $(XVSDKINCS) $(XF86VMODE_SDK) xorgVersion.h \
- xf86sbusBus.h xf86VGAarbiter.h
-
-DISTCLEANFILES = xf86Build.h
-CLEANFILES = $(BUILT_SOURCES)
-
-EXTRA_DIST = \
- compiler.h \
- fourcc.h \
- scoasm.h \
- vidmodeproc.h \
- xf86.h \
- xf86Bus.h \
- xf86Config.h \
- xf86InPriv.h \
- xf86Module.h \
- xf86Opt.h \
- xf86PciInfo.h \
- xf86Priv.h \
- xf86Privstr.h \
- xf86Xinput.h \
- xf86cmap.h \
- xf86fbman.h \
- xf86pciBus.h \
- xf86str.h \
- xf86xv.h \
- xf86xvmc.h \
- xf86xvpriv.h \
- xisb.h \
- xorgVersion.h \
- $(MODEDEFSOURCES) \
- modeline2c.awk \
- xf86VGAarbiter.h \
- xf86VGAarbiterPriv.h \
- $(DISTKBDSOURCES)
-
-if LNXACPI
-XORG_CFLAGS += -DHAVE_ACPI
-endif
-
-AM_CFLAGS = $(DIX_CFLAGS) $(XORG_CFLAGS)
+noinst_LTLIBRARIES = libcommon.la
+
+if XORG_BUS_SPARC
+SBUS_SOURCES = xf86sbusBus.c
+endif
+
+if XV
+XVSOURCES = xf86xv.c xf86xvmc.c
+XVSDKINCS = xf86xv.h xf86xvmc.h xf86xvpriv.h
+endif
+
+if XF86VIDMODE
+XF86VMODE_SDK = vidmodeproc.h
+endif
+
+if DGA
+DGASOURCES = xf86DGA.c
+endif
+
+RANDRSOURCES = xf86RandR.c
+
+BUSSOURCES = xf86pciBus.c xf86fbBus.c xf86noBus.c $(SBUS_SOURCES)
+
+MODEDEFSOURCES = $(srcdir)/vesamodes $(srcdir)/extramodes
+
+xf86DefModeSet.c: $(srcdir)/modeline2c.awk $(MODEDEFSOURCES)
+ $(AM_V_GEN)cat $(MODEDEFSOURCES) | LC_ALL=C $(AWK) -f $(srcdir)/modeline2c.awk > $@
+ $(AM_V_GEN)echo >> $@
+
+BUILT_SOURCES = xf86DefModeSet.c
+
+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 \
+ xf86VidMode.c xf86fbman.c xf86cmap.c \
+ xf86Helper.c xf86PM.c xf86Xinput.c xisb.c \
+ xf86Mode.c xorgHelper.c \
+ $(XVSOURCES) $(BUSSOURCES) $(RANDRSOURCES)
+nodist_libcommon_la_SOURCES = xf86DefModeSet.c xf86Build.h
+libcommon_la_LIBADD = $(top_builddir)/config/libconfig.la
+
+INCLUDES = $(XORG_INCS) -I$(srcdir)/../ddc -I$(srcdir)/../i2c \
+ -I$(srcdir)/../loader -I$(srcdir)/../parser \
+ -I$(srcdir)/../vbe -I$(srcdir)/../int10 \
+ -I$(srcdir)/../vgahw -I$(srcdir)/../dixmods/extmod \
+ -I$(srcdir)/../modes -I$(srcdir)/../ramdac
+
+sdk_HEADERS = compiler.h fourcc.h xf86.h xf86Module.h xf86Opt.h \
+ xf86PciInfo.h xf86Priv.h xf86Privstr.h \
+ xf86cmap.h xf86fbman.h xf86str.h xf86Xinput.h xisb.h \
+ $(XVSDKINCS) $(XF86VMODE_SDK) xorgVersion.h \
+ xf86sbusBus.h xf86VGAarbiter.h
+
+DISTCLEANFILES = xf86Build.h
+CLEANFILES = $(BUILT_SOURCES)
+
+EXTRA_DIST = \
+ compiler.h \
+ fourcc.h \
+ vidmodeproc.h \
+ xf86.h \
+ xf86Bus.h \
+ xf86Config.h \
+ xf86InPriv.h \
+ xf86Module.h \
+ xf86Opt.h \
+ xf86PciInfo.h \
+ xf86Priv.h \
+ xf86Privstr.h \
+ xf86Xinput.h \
+ xf86cmap.h \
+ xf86fbman.h \
+ xf86pciBus.h \
+ xf86str.h \
+ xf86xv.h \
+ xf86xvmc.h \
+ xf86xvpriv.h \
+ xisb.h \
+ xorgVersion.h \
+ $(MODEDEFSOURCES) \
+ modeline2c.awk \
+ xf86VGAarbiter.h \
+ xf86VGAarbiterPriv.h \
+ $(DISTKBDSOURCES)
+
+if LNXACPI
+XORG_CFLAGS += -DHAVE_ACPI
+endif
+
+AM_CFLAGS = $(DIX_CFLAGS) $(XORG_CFLAGS)
diff --git a/xorg-server/hw/xfree86/common/compiler.h b/xorg-server/hw/xfree86/common/compiler.h
index 617f6b788..9c9bac6ba 100644
--- a/xorg-server/hw/xfree86/common/compiler.h
+++ b/xorg-server/hw/xfree86/common/compiler.h
@@ -1,1786 +1,1773 @@
-/*
- * Copyright 1990,91 by Thomas Roell, Dinkelscherben, Germany.
- *
- * 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 Thomas Roell not be used in
- * advertising or publicity pertaining to distribution of the software without
- * specific, written prior permission. Thomas Roell makes no representations
- * about the suitability of this software for any purpose. It is provided
- * "as is" without express or implied warranty.
- *
- * THOMAS ROELL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
- * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
- * EVENT SHALL THOMAS ROELL 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) 1994-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).
- */
-
-#ifndef _COMPILER_H
-
-# define _COMPILER_H
-
-#if defined(__SUNPRO_C)
-# define DO_PROTOTYPES
-#endif
-
-/* Map Sun compiler platform defines to gcc-style used in the code */
-#if defined(__amd64) && !defined(__amd64__)
-# define __amd64__
-#endif
-#if defined(__i386) && !defined(__i386__)
-# define __i386__
-#endif
-#if defined(__sparc) && !defined(__sparc__)
-# define __sparc__
-#endif
-#if defined(__sparcv9) && !defined(__sparc64__)
-# define __sparc64__
-#endif
-
-#ifndef _X_EXPORT
-# include <X11/Xfuncproto.h>
-#endif
-
-# include <pixman.h> /* for uint*_t types */
-
-/* Allow drivers to use the GCC-supported __inline__ and/or __inline. */
-# ifndef __inline__
-# if defined(__GNUC__)
- /* gcc has __inline__ */
-# elif defined(__HIGHC__)
-# define __inline__ _Inline
-# else
-# define __inline__ /**/
-# endif
-# endif /* __inline__ */
-# ifndef __inline
-# if defined(__GNUC__) || defined(_MSC_VER)
- /* gcc has __inline */
-# elif defined(__HIGHC__)
-# define __inline _Inline
-# else
-# define __inline /**/
-# endif
-# endif /* __inline */
-
-/* Support gcc's __FUNCTION__ for people using other compilers */
-#if !defined(__GNUC__) && !defined(__FUNCTION__)
-# define __FUNCTION__ __func__ /* C99 */
-#endif
-
-# if defined(NO_INLINE) || defined(DO_PROTOTYPES)
-
-# if !defined(__arm__)
-# if !defined(__sparc__) && !defined(__sparc) && !defined(__arm32__) && !defined(__nds32__) \
- && !(defined(__alpha__) && defined(linux)) \
- && !(defined(__ia64__) && defined(linux)) \
-
-extern _X_EXPORT void outb(unsigned short, unsigned char);
-extern _X_EXPORT void outw(unsigned short, unsigned short);
-extern _X_EXPORT void outl(unsigned short, unsigned int);
-extern _X_EXPORT unsigned int inb(unsigned short);
-extern _X_EXPORT unsigned int inw(unsigned short);
-extern _X_EXPORT unsigned int inl(unsigned short);
-
-# else /* __sparc__, __arm32__, __alpha__, __nds32__ */
-
-extern _X_EXPORT void outb(unsigned long, unsigned char);
-extern _X_EXPORT void outw(unsigned long, unsigned short);
-extern _X_EXPORT void outl(unsigned long, unsigned int);
-extern _X_EXPORT unsigned int inb(unsigned long);
-extern _X_EXPORT unsigned int inw(unsigned long);
-extern _X_EXPORT unsigned int inl(unsigned long);
-
-# endif /* __sparc__, __arm32__, __alpha__, __nds32__ */
-# endif /* __arm__ */
-
-# if defined(__powerpc__) && !defined(__OpenBSD__)
-extern unsigned long ldq_u(unsigned long *);
-extern unsigned long ldl_u(unsigned int *);
-extern unsigned long ldw_u(unsigned short *);
-extern void stq_u(unsigned long, unsigned long *);
-extern void stl_u(unsigned long, unsigned int *);
-extern void stw_u(unsigned long, unsigned short *);
-extern void mem_barrier(void);
-extern void write_mem_barrier(void);
-extern void stl_brx(unsigned long, volatile unsigned char *, int);
-extern void stw_brx(unsigned short, volatile unsigned char *, int);
-extern unsigned long ldl_brx(volatile unsigned char *, int);
-extern unsigned short ldw_brx(volatile unsigned char *, int);
-# endif /* __powerpc__ && !__OpenBSD */
-
-# endif /* NO_INLINE || DO_PROTOTYPES */
-
-# ifndef NO_INLINE
-# ifdef __GNUC__
-# ifdef __i386__
-
-# ifdef __SSE__
-# define write_mem_barrier() __asm__ __volatile__ ("sfence" : : : "memory")
-# else
-# define write_mem_barrier() __asm__ __volatile__ ("lock; addl $0,0(%%esp)" : : : "memory")
-# endif
-
-# ifdef __SSE2__
-# define mem_barrier() __asm__ __volatile__ ("mfence" : : : "memory")
-# else
-# define mem_barrier() __asm__ __volatile__ ("lock; addl $0,0(%%esp)" : : : "memory")
-# endif
-
-# elif defined __alpha__
-
-# define mem_barrier() __asm__ __volatile__ ("mb" : : : "memory")
-# define write_mem_barrier() __asm__ __volatile__ ("wmb" : : : "memory")
-
-# elif defined __amd64__
-
-# define mem_barrier() __asm__ __volatile__ ("mfence" : : : "memory")
-# define write_mem_barrier() __asm__ __volatile__ ("sfence" : : : "memory")
-
-# elif defined __ia64__
-
-# ifndef __INTEL_COMPILER
-# define mem_barrier() __asm__ __volatile__ ("mf" : : : "memory")
-# define write_mem_barrier() __asm__ __volatile__ ("mf" : : : "memory")
-# else
-# include "ia64intrin.h"
-# define mem_barrier() __mf()
-# define write_mem_barrier() __mf()
-# endif
-
-# elif defined __mips__
- /* Note: sync instruction requires MIPS II instruction set */
-# define mem_barrier() \
- __asm__ __volatile__( \
- ".set push\n\t" \
- ".set noreorder\n\t" \
- ".set mips2\n\t" \
- "sync\n\t" \
- ".set pop" \
- : /* no output */ \
- : /* no input */ \
- : "memory")
-# define write_mem_barrier() mem_barrier()
-
-# elif defined __powerpc__
-
-# if defined(linux) && defined(__powerpc64__)
-# include <linux/version.h>
-# if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 0)
-# include <asm/memory.h>
-# endif
-# endif /* defined(linux) && defined(__powerpc64__) */
-
-# ifndef eieio /* We deal with arch-specific eieio() routines above... */
-# define eieio() __asm__ __volatile__ ("eieio" ::: "memory")
-# endif /* eieio */
-# define mem_barrier() eieio()
-# define write_mem_barrier() eieio()
-
-# elif defined __sparc__
-
-# define barrier() __asm__ __volatile__ (".word 0x8143e00a" : : : "memory")
-# define mem_barrier() /* XXX: nop for now */
-# define write_mem_barrier() /* XXX: nop for now */
-# endif
-# endif /* __GNUC__ */
-# endif /* NO_INLINE */
-
-# ifndef mem_barrier
-# define mem_barrier() /* NOP */
-# endif
-
-# ifndef write_mem_barrier
-# define write_mem_barrier() /* NOP */
-# endif
-
-
-# ifndef NO_INLINE
-# ifdef __GNUC__
-
-/* Define some packed structures to use with unaligned accesses */
-
-struct __una_u64 { uint64_t x __attribute__((packed)); };
-struct __una_u32 { uint32_t x __attribute__((packed)); };
-struct __una_u16 { uint16_t x __attribute__((packed)); };
-
-/* Elemental unaligned loads */
-
-static __inline__ uint64_t ldq_u(uint64_t *p)
-{
- const struct __una_u64 *ptr = (const struct __una_u64 *) p;
- return ptr->x;
-}
-
-static __inline__ uint32_t ldl_u(uint32_t *p)
-{
- const struct __una_u32 *ptr = (const struct __una_u32 *) p;
- return ptr->x;
-}
-
-static __inline__ uint16_t ldw_u(uint16_t *p)
-{
- const struct __una_u16 *ptr = (const struct __una_u16 *) p;
- return ptr->x;
-}
-
-/* Elemental unaligned stores */
-
-static __inline__ void stq_u(uint64_t val, uint64_t *p)
-{
- struct __una_u64 *ptr = (struct __una_u64 *) p;
- ptr->x = val;
-}
-
-static __inline__ void stl_u(uint32_t val, uint32_t *p)
-{
- struct __una_u32 *ptr = (struct __una_u32 *) p;
- ptr->x = val;
-}
-
-static __inline__ void stw_u(uint16_t val, uint16_t *p)
-{
- struct __una_u16 *ptr = (struct __una_u16 *) p;
- ptr->x = val;
-}
-# else /* !__GNUC__ */
-
-#include <string.h> /* needed for memmove */
-
-static __inline__ uint64_t ldq_u(uint64_t *p)
-{
- uint64_t ret;
- memmove(&ret, p, sizeof(*p));
- return ret;
-}
-
-static __inline__ uint32_t ldl_u(uint32_t *p)
-{
- uint32_t ret;
- memmove(&ret, p, sizeof(*p));
- return ret;
-}
-
-static __inline__ uint16_t ldw_u(uint16_t *p)
-{
- uint16_t ret;
- memmove(&ret, p, sizeof(*p));
- return ret;
-}
-
-static __inline__ void stq_u(uint64_t val, uint64_t *p)
-{
- uint64_t tmp = val;
- memmove(p, &tmp, sizeof(*p));
-}
-
-static __inline__ void stl_u(uint32_t val, uint32_t *p)
-{
- uint32_t tmp = val;
- memmove(p, &tmp, sizeof(*p));
-}
-
-static __inline__ void stw_u(uint16_t val, uint16_t *p)
-{
- uint16_t tmp = val;
- memmove(p, &tmp, sizeof(*p));
-}
-
-# endif /* __GNUC__ */
-# endif /* NO_INLINE */
-
-# ifndef NO_INLINE
-# ifdef __GNUC__
-# if (defined(linux) || defined(__FreeBSD__) || defined(__NetBSD__) || defined(__OpenBSD__)) && (defined(__alpha__))
-
-# ifdef linux
-/* for Linux on Alpha, we use the LIBC _inx/_outx routines */
-/* note that the appropriate setup via "ioperm" needs to be done */
-/* *before* any inx/outx is done. */
-
-extern _X_EXPORT void _outb(unsigned char val, unsigned long port);
-extern _X_EXPORT void _outw(unsigned short val, unsigned long port);
-extern _X_EXPORT void _outl(unsigned int val, unsigned long port);
-extern _X_EXPORT unsigned int _inb(unsigned long port);
-extern _X_EXPORT unsigned int _inw(unsigned long port);
-extern _X_EXPORT unsigned int _inl(unsigned long port);
-
-static __inline__ void
-outb(unsigned long port, unsigned char val)
-{
- _outb(val, port);
-}
-
-static __inline__ void
-outw(unsigned long port, unsigned short val)
-{
- _outw(val, port);
-}
-
-static __inline__ void
-outl(unsigned long port, unsigned int val)
-{
- _outl(val, port);
-}
-
-static __inline__ unsigned int
-inb(unsigned long port)
-{
- return _inb(port);
-}
-
-static __inline__ unsigned int
-inw(unsigned long port)
-{
- return _inw(port);
-}
-
-static __inline__ unsigned int
-inl(unsigned long port)
-{
- return _inl(port);
-}
-
-# endif /* linux */
-
-# if (defined(__FreeBSD__) || defined(__OpenBSD__)) \
- && !defined(DO_PROTOTYPES)
-
-/* for FreeBSD and OpenBSD on Alpha, we use the libio (resp. libalpha) */
-/* inx/outx routines */
-/* note that the appropriate setup via "ioperm" needs to be done */
-/* *before* any inx/outx is done. */
-
-extern _X_EXPORT void outb(unsigned int port, unsigned char val);
-extern _X_EXPORT void outw(unsigned int port, unsigned short val);
-extern _X_EXPORT void outl(unsigned int port, unsigned int val);
-extern _X_EXPORT unsigned char inb(unsigned int port);
-extern _X_EXPORT unsigned short inw(unsigned int port);
-extern _X_EXPORT unsigned int inl(unsigned int port);
-
-# endif /* (__FreeBSD__ || __OpenBSD__ ) && !DO_PROTOTYPES */
-
-
-#if defined(__NetBSD__)
-#include <machine/pio.h>
-#endif /* __NetBSD__ */
-
-# elif defined(linux) && defined(__ia64__)
-
-# include <inttypes.h>
-
-# include <sys/io.h>
-
-# undef outb
-# undef outw
-# undef outl
-# undef inb
-# undef inw
-# undef inl
-extern _X_EXPORT void outb(unsigned long port, unsigned char val);
-extern _X_EXPORT void outw(unsigned long port, unsigned short val);
-extern _X_EXPORT void outl(unsigned long port, unsigned int val);
-extern _X_EXPORT unsigned int inb(unsigned long port);
-extern _X_EXPORT unsigned int inw(unsigned long port);
-extern _X_EXPORT unsigned int inl(unsigned long port);
-
-# elif (defined(linux) || defined(__FreeBSD__)) && defined(__amd64__)
-
-# include <inttypes.h>
-
-static __inline__ void
-outb(unsigned short port, unsigned char val)
-{
- __asm__ __volatile__("outb %0,%1" : :"a" (val), "d" (port));
-}
-
-
-static __inline__ void
-outw(unsigned short port, unsigned short val)
-{
- __asm__ __volatile__("outw %0,%1" : :"a" (val), "d" (port));
-}
-
-static __inline__ void
-outl(unsigned short port, unsigned int val)
-{
- __asm__ __volatile__("outl %0,%1" : :"a" (val), "d" (port));
-}
-
-static __inline__ unsigned int
-inb(unsigned short port)
-{
- unsigned char ret;
- __asm__ __volatile__("inb %1,%0" :
- "=a" (ret) :
- "d" (port));
- return ret;
-}
-
-static __inline__ unsigned int
-inw(unsigned short port)
-{
- unsigned short ret;
- __asm__ __volatile__("inw %1,%0" :
- "=a" (ret) :
- "d" (port));
- return ret;
-}
-
-static __inline__ unsigned int
-inl(unsigned short port)
-{
- unsigned int ret;
- __asm__ __volatile__("inl %1,%0" :
- "=a" (ret) :
- "d" (port));
- return ret;
-}
-
-# elif (defined(linux) || defined(sun) || defined(__OpenBSD__) || defined(__FreeBSD__)) && defined(__sparc__)
-
-# ifndef ASI_PL
-# define ASI_PL 0x88
-# endif
-
-static __inline__ void
-outb(unsigned long port, unsigned char val)
-{
- __asm__ __volatile__("stba %0, [%1] %2"
- : /* No outputs */
- : "r" (val), "r" (port), "i" (ASI_PL));
- barrier();
-}
-
-static __inline__ void
-outw(unsigned long port, unsigned short val)
-{
- __asm__ __volatile__("stha %0, [%1] %2"
- : /* No outputs */
- : "r" (val), "r" (port), "i" (ASI_PL));
- barrier();
-}
-
-static __inline__ void
-outl(unsigned long port, unsigned int val)
-{
- __asm__ __volatile__("sta %0, [%1] %2"
- : /* No outputs */
- : "r" (val), "r" (port), "i" (ASI_PL));
- barrier();
-}
-
-static __inline__ unsigned int
-inb(unsigned long port)
-{
- unsigned int ret;
- __asm__ __volatile__("lduba [%1] %2, %0"
- : "=r" (ret)
- : "r" (port), "i" (ASI_PL));
- return ret;
-}
-
-static __inline__ unsigned int
-inw(unsigned long port)
-{
- unsigned int ret;
- __asm__ __volatile__("lduha [%1] %2, %0"
- : "=r" (ret)
- : "r" (port), "i" (ASI_PL));
- return ret;
-}
-
-static __inline__ unsigned int
-inl(unsigned long port)
-{
- unsigned int ret;
- __asm__ __volatile__("lda [%1] %2, %0"
- : "=r" (ret)
- : "r" (port), "i" (ASI_PL));
- return ret;
-}
-
-static __inline__ unsigned char
-xf86ReadMmio8(__volatile__ void *base, const unsigned long offset)
-{
- unsigned long addr = ((unsigned long)base) + offset;
- unsigned char ret;
-
- __asm__ __volatile__("lduba [%1] %2, %0"
- : "=r" (ret)
- : "r" (addr), "i" (ASI_PL));
- return ret;
-}
-
-static __inline__ unsigned short
-xf86ReadMmio16Be(__volatile__ void *base, const unsigned long offset)
-{
- unsigned long addr = ((unsigned long)base) + offset;
- unsigned short ret;
-
- __asm__ __volatile__("lduh [%1], %0"
- : "=r" (ret)
- : "r" (addr));
- return ret;
-}
-
-static __inline__ unsigned short
-xf86ReadMmio16Le(__volatile__ void *base, const unsigned long offset)
-{
- unsigned long addr = ((unsigned long)base) + offset;
- unsigned short ret;
-
- __asm__ __volatile__("lduha [%1] %2, %0"
- : "=r" (ret)
- : "r" (addr), "i" (ASI_PL));
- return ret;
-}
-
-static __inline__ unsigned int
-xf86ReadMmio32Be(__volatile__ void *base, const unsigned long offset)
-{
- unsigned long addr = ((unsigned long)base) + offset;
- unsigned int ret;
-
- __asm__ __volatile__("ld [%1], %0"
- : "=r" (ret)
- : "r" (addr));
- return ret;
-}
-
-static __inline__ unsigned int
-xf86ReadMmio32Le(__volatile__ void *base, const unsigned long offset)
-{
- unsigned long addr = ((unsigned long)base) + offset;
- unsigned int ret;
-
- __asm__ __volatile__("lda [%1] %2, %0"
- : "=r" (ret)
- : "r" (addr), "i" (ASI_PL));
- return ret;
-}
-
-static __inline__ void
-xf86WriteMmio8(__volatile__ void *base, const unsigned long offset,
- const unsigned int val)
-{
- unsigned long addr = ((unsigned long)base) + offset;
-
- __asm__ __volatile__("stba %0, [%1] %2"
- : /* No outputs */
- : "r" (val), "r" (addr), "i" (ASI_PL));
- barrier();
-}
-
-static __inline__ void
-xf86WriteMmio16Be(__volatile__ void *base, const unsigned long offset,
- const unsigned int val)
-{
- unsigned long addr = ((unsigned long)base) + offset;
-
- __asm__ __volatile__("sth %0, [%1]"
- : /* No outputs */
- : "r" (val), "r" (addr));
- barrier();
-}
-
-static __inline__ void
-xf86WriteMmio16Le(__volatile__ void *base, const unsigned long offset,
- const unsigned int val)
-{
- unsigned long addr = ((unsigned long)base) + offset;
-
- __asm__ __volatile__("stha %0, [%1] %2"
- : /* No outputs */
- : "r" (val), "r" (addr), "i" (ASI_PL));
- barrier();
-}
-
-static __inline__ void
-xf86WriteMmio32Be(__volatile__ void *base, const unsigned long offset,
- const unsigned int val)
-{
- unsigned long addr = ((unsigned long)base) + offset;
-
- __asm__ __volatile__("st %0, [%1]"
- : /* No outputs */
- : "r" (val), "r" (addr));
- barrier();
-}
-
-static __inline__ void
-xf86WriteMmio32Le(__volatile__ void *base, const unsigned long offset,
- const unsigned int val)
-{
- unsigned long addr = ((unsigned long)base) + offset;
-
- __asm__ __volatile__("sta %0, [%1] %2"
- : /* No outputs */
- : "r" (val), "r" (addr), "i" (ASI_PL));
- barrier();
-}
-
-static __inline__ void
-xf86WriteMmio8NB(__volatile__ void *base, const unsigned long offset,
- const unsigned int val)
-{
- unsigned long addr = ((unsigned long)base) + offset;
-
- __asm__ __volatile__("stba %0, [%1] %2"
- : /* No outputs */
- : "r" (val), "r" (addr), "i" (ASI_PL));
-}
-
-static __inline__ void
-xf86WriteMmio16BeNB(__volatile__ void *base, const unsigned long offset,
- const unsigned int val)
-{
- unsigned long addr = ((unsigned long)base) + offset;
-
- __asm__ __volatile__("sth %0, [%1]"
- : /* No outputs */
- : "r" (val), "r" (addr));
-}
-
-static __inline__ void
-xf86WriteMmio16LeNB(__volatile__ void *base, const unsigned long offset,
- const unsigned int val)
-{
- unsigned long addr = ((unsigned long)base) + offset;
-
- __asm__ __volatile__("stha %0, [%1] %2"
- : /* No outputs */
- : "r" (val), "r" (addr), "i" (ASI_PL));
-}
-
-static __inline__ void
-xf86WriteMmio32BeNB(__volatile__ void *base, const unsigned long offset,
- const unsigned int val)
-{
- unsigned long addr = ((unsigned long)base) + offset;
-
- __asm__ __volatile__("st %0, [%1]"
- : /* No outputs */
- : "r" (val), "r" (addr));
-}
-
-static __inline__ void
-xf86WriteMmio32LeNB(__volatile__ void *base, const unsigned long offset,
- const unsigned int val)
-{
- unsigned long addr = ((unsigned long)base) + offset;
-
- __asm__ __volatile__("sta %0, [%1] %2"
- : /* No outputs */
- : "r" (val), "r" (addr), "i" (ASI_PL));
-}
-
-# elif defined(__mips__) || (defined(__arm32__) && !defined(__linux__))
-# ifdef __arm32__
-# define PORT_SIZE long
-# else
-# define PORT_SIZE short
-# endif
-
-_X_EXPORT unsigned int IOPortBase; /* Memory mapped I/O port area */
-
-static __inline__ void
-outb(unsigned PORT_SIZE port, unsigned char val)
-{
- *(volatile unsigned char*)(((unsigned PORT_SIZE)(port))+IOPortBase) = val;
-}
-
-static __inline__ void
-outw(unsigned PORT_SIZE port, unsigned short val)
-{
- *(volatile unsigned short*)(((unsigned PORT_SIZE)(port))+IOPortBase) = val;
-}
-
-static __inline__ void
-outl(unsigned PORT_SIZE port, unsigned int val)
-{
- *(volatile unsigned int*)(((unsigned PORT_SIZE)(port))+IOPortBase) = val;
-}
-
-static __inline__ unsigned int
-inb(unsigned PORT_SIZE port)
-{
- return *(volatile unsigned char*)(((unsigned PORT_SIZE)(port))+IOPortBase);
-}
-
-static __inline__ unsigned int
-inw(unsigned PORT_SIZE port)
-{
- return *(volatile unsigned short*)(((unsigned PORT_SIZE)(port))+IOPortBase);
-}
-
-static __inline__ unsigned int
-inl(unsigned PORT_SIZE port)
-{
- return *(volatile unsigned int*)(((unsigned PORT_SIZE)(port))+IOPortBase);
-}
-
-
-# if defined(__mips__)
-# ifdef linux /* don't mess with other OSs */
-# if X_BYTE_ORDER == X_BIG_ENDIAN
-static __inline__ unsigned int
-xf86ReadMmio32Be(__volatile__ void *base, const unsigned long offset)
-{
- unsigned long addr = ((unsigned long)base) + offset;
- unsigned int ret;
-
- __asm__ __volatile__("lw %0, 0(%1)"
- : "=r" (ret)
- : "r" (addr));
- return ret;
-}
-
-static __inline__ void
-xf86WriteMmio32Be(__volatile__ void *base, const unsigned long offset,
- const unsigned int val)
-{
- unsigned long addr = ((unsigned long)base) + offset;
-
- __asm__ __volatile__("sw %0, 0(%1)"
- : /* No outputs */
- : "r" (val), "r" (addr));
-}
-# endif
-# endif /* !linux */
-# endif /* __mips__ */
-
-# elif (defined(linux) || defined(__OpenBSD__) || defined(__NetBSD__) || defined(__FreeBSD__)) && defined(__powerpc__)
-
-# ifndef MAP_FAILED
-# define MAP_FAILED ((void *)-1)
-# endif
-
-extern _X_EXPORT volatile unsigned char *ioBase;
-
-static __inline__ unsigned char
-xf86ReadMmio8(__volatile__ void *base, const unsigned long offset)
-{
- register unsigned char val;
- __asm__ __volatile__(
- "lbzx %0,%1,%2\n\t"
- "eieio"
- : "=r" (val)
- : "b" (base), "r" (offset),
- "m" (*((volatile unsigned char *)base+offset)));
- return val;
-}
-
-static __inline__ unsigned short
-xf86ReadMmio16Be(__volatile__ void *base, const unsigned long offset)
-{
- register unsigned short val;
- __asm__ __volatile__(
- "lhzx %0,%1,%2\n\t"
- "eieio"
- : "=r" (val)
- : "b" (base), "r" (offset),
- "m" (*((volatile unsigned char *)base+offset)));
- return val;
-}
-
-static __inline__ unsigned short
-xf86ReadMmio16Le(__volatile__ void *base, const unsigned long offset)
-{
- register unsigned short val;
- __asm__ __volatile__(
- "lhbrx %0,%1,%2\n\t"
- "eieio"
- : "=r" (val)
- : "b" (base), "r" (offset),
- "m" (*((volatile unsigned char *)base+offset)));
- return val;
-}
-
-static __inline__ unsigned int
-xf86ReadMmio32Be(__volatile__ void *base, const unsigned long offset)
-{
- register unsigned int val;
- __asm__ __volatile__(
- "lwzx %0,%1,%2\n\t"
- "eieio"
- : "=r" (val)
- : "b" (base), "r" (offset),
- "m" (*((volatile unsigned char *)base+offset)));
- return val;
-}
-
-static __inline__ unsigned int
-xf86ReadMmio32Le(__volatile__ void *base, const unsigned long offset)
-{
- register unsigned int val;
- __asm__ __volatile__(
- "lwbrx %0,%1,%2\n\t"
- "eieio"
- : "=r" (val)
- : "b" (base), "r" (offset),
- "m" (*((volatile unsigned char *)base+offset)));
- return val;
-}
-
-static __inline__ void
-xf86WriteMmioNB8(__volatile__ void *base, const unsigned long offset,
- const unsigned char val)
-{
- __asm__ __volatile__(
- "stbx %1,%2,%3\n\t"
- : "=m" (*((volatile unsigned char *)base+offset))
- : "r" (val), "b" (base), "r" (offset));
-}
-
-static __inline__ void
-xf86WriteMmioNB16Le(__volatile__ void *base, const unsigned long offset,
- const unsigned short val)
-{
- __asm__ __volatile__(
- "sthbrx %1,%2,%3\n\t"
- : "=m" (*((volatile unsigned char *)base+offset))
- : "r" (val), "b" (base), "r" (offset));
-}
-
-static __inline__ void
-xf86WriteMmioNB16Be(__volatile__ void *base, const unsigned long offset,
- const unsigned short val)
-{
- __asm__ __volatile__(
- "sthx %1,%2,%3\n\t"
- : "=m" (*((volatile unsigned char *)base+offset))
- : "r" (val), "b" (base), "r" (offset));
-}
-
-static __inline__ void
-xf86WriteMmioNB32Le(__volatile__ void *base, const unsigned long offset,
- const unsigned int val)
-{
- __asm__ __volatile__(
- "stwbrx %1,%2,%3\n\t"
- : "=m" (*((volatile unsigned char *)base+offset))
- : "r" (val), "b" (base), "r" (offset));
-}
-
-static __inline__ void
-xf86WriteMmioNB32Be(__volatile__ void *base, const unsigned long offset,
- const unsigned int val)
-{
- __asm__ __volatile__(
- "stwx %1,%2,%3\n\t"
- : "=m" (*((volatile unsigned char *)base+offset))
- : "r" (val), "b" (base), "r" (offset));
-}
-
-static __inline__ void
-xf86WriteMmio8(__volatile__ void *base, const unsigned long offset,
- const unsigned char val)
-{
- xf86WriteMmioNB8(base, offset, val);
- eieio();
-}
-
-static __inline__ void
-xf86WriteMmio16Le(__volatile__ void *base, const unsigned long offset,
- const unsigned short val)
-{
- xf86WriteMmioNB16Le(base, offset, val);
- eieio();
-}
-
-static __inline__ void
-xf86WriteMmio16Be(__volatile__ void *base, const unsigned long offset,
- const unsigned short val)
-{
- xf86WriteMmioNB16Be(base, offset, val);
- eieio();
-}
-
-static __inline__ void
-xf86WriteMmio32Le(__volatile__ void *base, const unsigned long offset,
- const unsigned int val)
-{
- xf86WriteMmioNB32Le(base, offset, val);
- eieio();
-}
-
-static __inline__ void
-xf86WriteMmio32Be(__volatile__ void *base, const unsigned long offset,
- const unsigned int val)
-{
- xf86WriteMmioNB32Be(base, offset, val);
- eieio();
-}
-
-
-static __inline__ void
-outb(unsigned short port, unsigned char value)
-{
- if(ioBase == MAP_FAILED) return;
- xf86WriteMmio8((void *)ioBase, port, value);
-}
-
-static __inline__ void
-outw(unsigned short port, unsigned short value)
-{
- if(ioBase == MAP_FAILED) return;
- xf86WriteMmio16Le((void *)ioBase, port, value);
-}
-
-static __inline__ void
-outl(unsigned short port, unsigned int value)
-{
- if(ioBase == MAP_FAILED) return;
- xf86WriteMmio32Le((void *)ioBase, port, value);
-}
-
-static __inline__ unsigned int
-inb(unsigned short port)
-{
- if(ioBase == MAP_FAILED) return 0;
- return xf86ReadMmio8((void *)ioBase, port);
-}
-
-static __inline__ unsigned int
-inw(unsigned short port)
-{
- if(ioBase == MAP_FAILED) return 0;
- return xf86ReadMmio16Le((void *)ioBase, port);
-}
-
-static __inline__ unsigned int
-inl(unsigned short port)
-{
- if(ioBase == MAP_FAILED) return 0;
- return xf86ReadMmio32Le((void *)ioBase, port);
-}
-
-#elif defined(__arm__) && defined(__linux__)
-
-/* for Linux on ARM, we use the LIBC inx/outx routines */
-/* note that the appropriate setup via "ioperm" needs to be done */
-/* *before* any inx/outx is done. */
-
-#include <sys/io.h>
-
-static __inline__ void
-xf_outb(unsigned short port, unsigned char val)
-{
- outb(val, port);
-}
-
-static __inline__ void
-xf_outw(unsigned short port, unsigned short val)
-{
- outw(val, port);
-}
-
-static __inline__ void
-xf_outl(unsigned short port, unsigned int val)
-{
- outl(val, port);
-}
-
-#define outb xf_outb
-#define outw xf_outw
-#define outl xf_outl
-
-# elif defined(__nds32__)
-
-/*
- * Assume all port access are aligned. We need to revise this implementation
- * if there is unaligned port access. For ldq_u, ldl_u, ldw_u, stq_u, stl_u and
- * stw_u, they are assumed unaligned.
- */
-
-#define barrier() /* no barrier */
-
-#define PORT_SIZE long
-
-static __inline__ unsigned char
-xf86ReadMmio8(__volatile__ void *base, const unsigned long offset)
-{
- return *(volatile unsigned char *)((unsigned char *)base + offset) ;
-}
-
-static __inline__ void
-xf86WriteMmio8(__volatile__ void *base, const unsigned long offset,
- const unsigned int val)
-{
- *(volatile unsigned char *)((unsigned char *)base + offset) = val ;
- barrier();
-}
-
-static __inline__ void
-xf86WriteMmio8NB(__volatile__ void *base, const unsigned long offset,
- const unsigned int val)
-{
- *(volatile unsigned char *)((unsigned char *)base + offset) = val ;
-}
-
-static __inline__ unsigned short
-xf86ReadMmio16Swap(__volatile__ void *base, const unsigned long offset)
-{
- unsigned long addr = ((unsigned long)base) + offset;
- unsigned short ret;
-
- __asm__ __volatile__(
- "lhi %0, [%1];\n\t"
- "wsbh %0, %0;\n\t"
- : "=r" (ret)
- : "r" (addr));
- return ret;
-}
-
-static __inline__ unsigned short
-xf86ReadMmio16(__volatile__ void *base, const unsigned long offset)
-{
- return *(volatile unsigned short *)((char *)base + offset) ;
-}
-
-static __inline__ void
-xf86WriteMmio16Swap(__volatile__ void *base, const unsigned long offset,
- const unsigned int val)
-{
- unsigned long addr = ((unsigned long)base) + offset;
-
- __asm__ __volatile__(
- "wsbh %0, %0;\n\t"
- "shi %0, [%1];\n\t"
- : /* No outputs */
- : "r" (val), "r" (addr));
- barrier();
-}
-
-static __inline__ void
-xf86WriteMmio16(__volatile__ void *base, const unsigned long offset,
- const unsigned int val)
-{
- *(volatile unsigned short *)((unsigned char *)base + offset) = val ;
- barrier();
-}
-
-static __inline__ void
-xf86WriteMmio16SwapNB(__volatile__ void *base, const unsigned long offset,
- const unsigned int val)
-{
- unsigned long addr = ((unsigned long)base) + offset;
-
- __asm__ __volatile__(
- "wsbh %0, %0;\n\t"
- "shi %0, [%1];\n\t"
- : /* No outputs */
- : "r" (val), "r" (addr));
-}
-
-static __inline__ void
-xf86WriteMmio16NB(__volatile__ void *base, const unsigned long offset,
- const unsigned int val)
-{
- *(volatile unsigned short *)((unsigned char *)base + offset) = val ;
-}
-
-static __inline__ unsigned int
-xf86ReadMmio32Swap(__volatile__ void *base, const unsigned long offset)
-{
- unsigned long addr = ((unsigned long)base) + offset;
- unsigned int ret;
-
- __asm__ __volatile__(
- "lwi %0, [%1];\n\t"
- "wsbh %0, %0;\n\t"
- "rotri %0, %0, 16;\n\t"
- : "=r" (ret)
- : "r" (addr));
- return ret;
-}
-
-static __inline__ unsigned int
-xf86ReadMmio32(__volatile__ void *base, const unsigned long offset)
-{
- return *(volatile unsigned int *)((unsigned char *)base + offset) ;
-}
-
-static __inline__ void
-xf86WriteMmio32Swap(__volatile__ void *base, const unsigned long offset,
- const unsigned int val)
-{
- unsigned long addr = ((unsigned long)base) + offset;
-
- __asm__ __volatile__(
- "wsbh %0, %0;\n\t"
- "rotri %0, %0, 16;\n\t"
- "swi %0, [%1];\n\t"
- : /* No outputs */
- : "r" (val), "r" (addr));
- barrier();
-}
-
-static __inline__ void
-xf86WriteMmio32(__volatile__ void *base, const unsigned long offset,
- const unsigned int val)
-{
- *(volatile unsigned int *)((unsigned char *)base + offset) = val ;
- barrier();
-}
-
-static __inline__ void
-xf86WriteMmio32SwapNB(__volatile__ void *base, const unsigned long offset,
- const unsigned int val)
-{
- unsigned long addr = ((unsigned long)base) + offset;
-
- __asm__ __volatile__(
- "wsbh %0, %0;\n\t"
- "rotri %0, %0, 16;\n\t"
- "swi %0, [%1];\n\t"
- : /* No outputs */
- : "r" (val), "r" (addr));
-}
-
-static __inline__ void
-xf86WriteMmio32NB(__volatile__ void *base, const unsigned long offset,
- const unsigned int val)
-{
- *(volatile unsigned int *)((unsigned char *)base + offset) = val ;
-}
-
-# if defined(NDS32_MMIO_SWAP)
-static __inline__ void
-outb(unsigned PORT_SIZE port, unsigned char val)
-{
- xf86WriteMmio8(IOPortBase, port, val);
-}
-
-static __inline__ void
-outw(unsigned PORT_SIZE port, unsigned short val)
-{
- xf86WriteMmio16Swap(IOPortBase, port, val);
-}
-
-static __inline__ void
-outl(unsigned PORT_SIZE port, unsigned int val)
-{
- xf86WriteMmio32Swap(IOPortBase, port, val);
-}
-
-static __inline__ unsigned int
-inb(unsigned PORT_SIZE port)
-{
- return xf86ReadMmio8(IOPortBase, port);
-}
-
-static __inline__ unsigned int
-inw(unsigned PORT_SIZE port)
-{
- return xf86ReadMmio16Swap(IOPortBase, port);
-}
-
-static __inline__ unsigned int
-inl(unsigned PORT_SIZE port)
-{
- return xf86ReadMmio32Swap(IOPortBase, port);
-}
-
-static __inline__ unsigned long ldq_u(unsigned long *p)
-{
- unsigned long addr = (unsigned long)p;
- unsigned int ret;
-
- __asm__ __volatile__(
- "lmw.bi %0, [%1], %0, 0;\n\t"
- "wsbh %0, %0;\n\t"
- "rotri %0, %0, 16;\n\t"
- : "=r" (ret)
- : "r" (addr));
- return ret;
-}
-
-static __inline__ unsigned long ldl_u(unsigned int *p)
-{
- unsigned long addr = (unsigned long)p;
- unsigned int ret;
-
- __asm__ __volatile__(
- "lmw.bi %0, [%1], %0, 0;\n\t"
- "wsbh %0, %0;\n\t"
- "rotri %0, %0, 16;\n\t"
- : "=r" (ret)
- : "r" (addr));
- return ret;
-}
-
-static __inline__ void stq_u(unsigned long val, unsigned long *p)
-{
- unsigned long addr = (unsigned long)p;
-
- __asm__ __volatile__(
- "wsbh %0, %0;\n\t"
- "rotri %0, %0, 16;\n\t"
- "smw.bi %0, [%1], %0, 0;\n\t"
- : /* No outputs */
- : "r" (val), "r" (addr));
-}
-
-static __inline__ void stl_u(unsigned long val, unsigned int *p)
-{
- unsigned long addr = (unsigned long)p;
-
- __asm__ __volatile__(
- "wsbh %0, %0;\n\t"
- "rotri %0, %0, 16;\n\t"
- "smw.bi %0, [%1], %0, 0;\n\t"
- : /* No outputs */
- : "r" (val), "r" (addr));
-}
-
-# else /* !NDS32_MMIO_SWAP */
-static __inline__ void
-outb(unsigned PORT_SIZE port, unsigned char val)
-{
- *(volatile unsigned char*)(((unsigned PORT_SIZE)(port))) = val;
- barrier();
-}
-
-static __inline__ void
-outw(unsigned PORT_SIZE port, unsigned short val)
-{
- *(volatile unsigned short*)(((unsigned PORT_SIZE)(port))) = val;
- barrier();
-}
-
-static __inline__ void
-outl(unsigned PORT_SIZE port, unsigned int val)
-{
- *(volatile unsigned int*)(((unsigned PORT_SIZE)(port))) = val;
- barrier();
-}
-static __inline__ unsigned int
-inb(unsigned PORT_SIZE port)
-{
- return *(volatile unsigned char*)(((unsigned PORT_SIZE)(port)));
-}
-
-static __inline__ unsigned int
-inw(unsigned PORT_SIZE port)
-{
- return *(volatile unsigned short*)(((unsigned PORT_SIZE)(port)));
-}
-
-static __inline__ unsigned int
-inl(unsigned PORT_SIZE port)
-{
- return *(volatile unsigned int*)(((unsigned PORT_SIZE)(port)));
-}
-
-static __inline__ unsigned long ldq_u(unsigned long *p)
-{
- unsigned long addr = (unsigned long)p;
- unsigned int ret;
-
- __asm__ __volatile__(
- "lmw.bi %0, [%1], %0, 0;\n\t"
- : "=r" (ret)
- : "r" (addr));
- return ret;
-}
-
-static __inline__ unsigned long ldl_u(unsigned int *p)
-{
- unsigned long addr = (unsigned long)p;
- unsigned int ret;
-
- __asm__ __volatile__(
- "lmw.bi %0, [%1], %0, 0;\n\t"
- : "=r" (ret)
- : "r" (addr));
- return ret;
-}
-
-
-static __inline__ void stq_u(unsigned long val, unsigned long *p)
-{
- unsigned long addr = (unsigned long)p;
-
- __asm__ __volatile__(
- "smw.bi %0, [%1], %0, 0;\n\t"
- : /* No outputs */
- : "r" (val), "r" (addr));
-}
-
-static __inline__ void stl_u(unsigned long val, unsigned int *p)
-{
- unsigned long addr = (unsigned long)p;
-
- __asm__ __volatile__(
- "smw.bi %0, [%1], %0, 0;\n\t"
- : /* No outputs */
- : "r" (val), "r" (addr));
-}
-# endif /* NDS32_MMIO_SWAP */
-
-# if (((X_BYTE_ORDER == X_BIG_ENDIAN) && !defined(NDS32_MMIO_SWAP)) || ((X_BYTE_ORDER != X_BIG_ENDIAN) && defined(NDS32_MMIO_SWAP)))
-# define ldw_u(p) ((*(unsigned char *)(p)) << 8 | \
- (*((unsigned char *)(p)+1)))
-# define stw_u(v,p) (*(unsigned char *)(p)) = ((v) >> 8); \
- (*((unsigned char *)(p)+1)) = (v)
-# else
-# define ldw_u(p) ((*(unsigned char *)(p)) | \
- (*((unsigned char *)(p)+1)<<8))
-# define stw_u(v,p) (*(unsigned char *)(p)) = (v); \
- (*((unsigned char *)(p)+1)) = ((v) >> 8)
-# endif
-
-# define mem_barrier() /* XXX: nop for now */
-# define write_mem_barrier() /* XXX: nop for now */
-
-# else /* ix86 */
-
-# if !defined(__SUNPRO_C)
-# if !defined(FAKEIT) && !defined(__mc68000__) && !defined(__arm__) && !defined(__sh__) && !defined(__hppa__) && !defined(__s390__) && !defined(__m32r__)
-# ifdef GCCUSESGAS
-
-/*
- * If gcc uses gas rather than the native assembler, the syntax of these
- * inlines has to be different. DHD
- */
-
-static __inline__ void
-outb(unsigned short port, unsigned char val)
-{
- __asm__ __volatile__("outb %0,%1" : :"a" (val), "d" (port));
-}
-
-
-static __inline__ void
-outw(unsigned short port, unsigned short val)
-{
- __asm__ __volatile__("outw %0,%1" : :"a" (val), "d" (port));
-}
-
-static __inline__ void
-outl(unsigned short port, unsigned int val)
-{
- __asm__ __volatile__("outl %0,%1" : :"a" (val), "d" (port));
-}
-
-static __inline__ unsigned int
-inb(unsigned short port)
-{
- unsigned char ret;
- __asm__ __volatile__("inb %1,%0" :
- "=a" (ret) :
- "d" (port));
- return ret;
-}
-
-static __inline__ unsigned int
-inw(unsigned short port)
-{
- unsigned short ret;
- __asm__ __volatile__("inw %1,%0" :
- "=a" (ret) :
- "d" (port));
- return ret;
-}
-
-static __inline__ unsigned int
-inl(unsigned short port)
-{
- unsigned int ret;
- __asm__ __volatile__("inl %1,%0" :
- "=a" (ret) :
- "d" (port));
- return ret;
-}
-
-# else /* GCCUSESGAS */
-
-static __inline__ void
-outb(unsigned short port, unsigned char val)
-{
- __asm__ __volatile__("out%B0 (%1)" : :"a" (val), "d" (port));
-}
-
-static __inline__ void
-outw(unsigned short port, unsigned short val)
-{
- __asm__ __volatile__("out%W0 (%1)" : :"a" (val), "d" (port));
-}
-
-static __inline__ void
-outl(unsigned short port, unsigned int val)
-{
- __asm__ __volatile__("out%L0 (%1)" : :"a" (val), "d" (port));
-}
-
-static __inline__ unsigned int
-inb(unsigned short port)
-{
- unsigned char ret;
- __asm__ __volatile__("in%B0 (%1)" :
- "=a" (ret) :
- "d" (port));
- return ret;
-}
-
-static __inline__ unsigned int
-inw(unsigned short port)
-{
- unsigned short ret;
- __asm__ __volatile__("in%W0 (%1)" :
- "=a" (ret) :
- "d" (port));
- return ret;
-}
-
-static __inline__ unsigned int
-inl(unsigned short port)
-{
- unsigned int ret;
- __asm__ __volatile__("in%L0 (%1)" :
- "=a" (ret) :
- "d" (port));
- return ret;
-}
-
-# endif /* GCCUSESGAS */
-
-# else /* !defined(FAKEIT) && !defined(__mc68000__) && !defined(__arm__) && !defined(__sh__) && !defined(__hppa__) && !defined(__m32r__) */
-
-static __inline__ void
-outb(unsigned short port, unsigned char val)
-{
-}
-
-static __inline__ void
-outw(unsigned short port, unsigned short val)
-{
-}
-
-static __inline__ void
-outl(unsigned short port, unsigned int val)
-{
-}
-
-static __inline__ unsigned int
-inb(unsigned short port)
-{
- return 0;
-}
-
-static __inline__ unsigned int
-inw(unsigned short port)
-{
- return 0;
-}
-
-static __inline__ unsigned int
-inl(unsigned short port)
-{
- return 0;
-}
-
-# endif /* FAKEIT */
-# endif /* __SUNPRO_C */
-
-# endif /* ix86 */
-
-# else /* !GNUC */
-# if defined(__STDC__) && (__STDC__ == 1)
-# ifndef asm
-# define asm __asm
-# endif
-# endif
-# ifndef SCO325
-# if defined(__UNIXWARE__)
-# /* avoid including <sys/types.h> for <sys/inline.h> on UnixWare */
-# define ushort unsigned short
-# define ushort_t unsigned short
-# define ulong unsigned long
-# define ulong_t unsigned long
-# define uint_t unsigned int
-# define uchar_t unsigned char
-# endif /* __UNIXWARE__ */
-# if !defined(__SUNPRO_C) && !defined(_MSC_VER)
-# include <sys/inline.h>
-# endif
-# else
-# include "scoasm.h"
-# endif
-# if (!defined(__HIGHC__) && !defined(__SUNPRO_C) && !defined(_MSC_VER)) || \
- defined(__USLC__)
-# pragma asm partial_optimization outl
-# pragma asm partial_optimization outw
-# pragma asm partial_optimization outb
-# pragma asm partial_optimization inl
-# pragma asm partial_optimization inw
-# pragma asm partial_optimization inb
-# endif
-# endif /* __GNUC__ */
-
-# endif /* NO_INLINE */
-
-# ifdef __alpha__
-/* entry points for Mmio memory access routines */
-extern _X_EXPORT int (*xf86ReadMmio8)(void *, unsigned long);
-extern _X_EXPORT int (*xf86ReadMmio16)(void *, unsigned long);
-# ifndef STANDALONE_MMIO
-extern _X_EXPORT int (*xf86ReadMmio32)(void *, unsigned long);
-# else
-/* Some DRI 3D drivers need MMIO_IN32. */
-static __inline__ int
-xf86ReadMmio32(void *Base, unsigned long Offset)
-{
- mem_barrier();
- return *(volatile unsigned int*)((unsigned long)Base+(Offset));
-}
-# endif
-extern _X_EXPORT void (*xf86WriteMmio8)(int, void *, unsigned long);
-extern _X_EXPORT void (*xf86WriteMmio16)(int, void *, unsigned long);
-extern _X_EXPORT void (*xf86WriteMmio32)(int, void *, unsigned long);
-extern _X_EXPORT void (*xf86WriteMmioNB8)(int, void *, unsigned long);
-extern _X_EXPORT void (*xf86WriteMmioNB16)(int, void *, unsigned long);
-extern _X_EXPORT void (*xf86WriteMmioNB32)(int, void *, unsigned long);
-extern _X_EXPORT void xf86SlowBCopyFromBus(unsigned char *, unsigned char *, int);
-extern _X_EXPORT void xf86SlowBCopyToBus(unsigned char *, unsigned char *, int);
-
-/* Some macros to hide the system dependencies for MMIO accesses */
-/* Changed to kill noise generated by gcc's -Wcast-align */
-# define MMIO_IN8(base, offset) (*xf86ReadMmio8)(base, offset)
-# define MMIO_IN16(base, offset) (*xf86ReadMmio16)(base, offset)
-# ifndef STANDALONE_MMIO
-# define MMIO_IN32(base, offset) (*xf86ReadMmio32)(base, offset)
-# else
-# define MMIO_IN32(base, offset) xf86ReadMmio32(base, offset)
-# endif
-
-# define MMIO_OUT32(base, offset, val) \
- do { \
- write_mem_barrier(); \
- *(volatile CARD32 *)(void *)(((CARD8*)(base)) + (offset)) = (val); \
- } while (0)
-# define MMIO_ONB32(base, offset, val) \
- *(volatile CARD32 *)(void *)(((CARD8*)(base)) + (offset)) = (val)
-
-# define MMIO_OUT8(base, offset, val) \
- (*xf86WriteMmio8)((CARD8)(val), base, offset)
-# define MMIO_OUT16(base, offset, val) \
- (*xf86WriteMmio16)((CARD16)(val), base, offset)
-# define MMIO_ONB8(base, offset, val) \
- (*xf86WriteMmioNB8)((CARD8)(val), base, offset)
-# define MMIO_ONB16(base, offset, val) \
- (*xf86WriteMmioNB16)((CARD16)(val), base, offset)
-# define MMIO_MOVE32(base, offset, val) \
- MMIO_OUT32(base, offset, val)
-
-# elif defined(__powerpc__)
- /*
- * we provide byteswapping and no byteswapping functions here
- * with byteswapping as default,
- * drivers that don't need byteswapping should define PPC_MMIO_IS_BE
- */
-# define MMIO_IN8(base, offset) xf86ReadMmio8(base, offset)
-# define MMIO_OUT8(base, offset, val) \
- xf86WriteMmio8(base, offset, (CARD8)(val))
-# define MMIO_ONB8(base, offset, val) \
- xf86WriteMmioNB8(base, offset, (CARD8)(val))
-
-# if defined(PPC_MMIO_IS_BE) /* No byteswapping */
-# define MMIO_IN16(base, offset) xf86ReadMmio16Be(base, offset)
-# define MMIO_IN32(base, offset) xf86ReadMmio32Be(base, offset)
-# define MMIO_OUT16(base, offset, val) \
- xf86WriteMmio16Be(base, offset, (CARD16)(val))
-# define MMIO_OUT32(base, offset, val) \
- xf86WriteMmio32Be(base, offset, (CARD32)(val))
-# define MMIO_ONB16(base, offset, val) \
- xf86WriteMmioNB16Be(base, offset, (CARD16)(val))
-# define MMIO_ONB32(base, offset, val) \
- xf86WriteMmioNB32Be(base, offset, (CARD32)(val))
-# else /* byteswapping is the default */
-# define MMIO_IN16(base, offset) xf86ReadMmio16Le(base, offset)
-# define MMIO_IN32(base, offset) xf86ReadMmio32Le(base, offset)
-# define MMIO_OUT16(base, offset, val) \
- xf86WriteMmio16Le(base, offset, (CARD16)(val))
-# define MMIO_OUT32(base, offset, val) \
- xf86WriteMmio32Le(base, offset, (CARD32)(val))
-# define MMIO_ONB16(base, offset, val) \
- xf86WriteMmioNB16Le(base, offset, (CARD16)(val))
-# define MMIO_ONB32(base, offset, val) \
- xf86WriteMmioNB32Le(base, offset, (CARD32)(val))
-# endif
-
-# define MMIO_MOVE32(base, offset, val) \
- xf86WriteMmio32Be(base, offset, (CARD32)(val))
-
-# elif defined(__sparc__) || defined(sparc) || defined(__sparc)
- /*
- * Like powerpc, we provide byteswapping and no byteswapping functions
- * here with byteswapping as default, drivers that don't need byteswapping
- * should define SPARC_MMIO_IS_BE (perhaps create a generic macro so that we
- * do not need to use PPC_MMIO_IS_BE and the sparc one in all the same places
- * of drivers?).
- */
-# define MMIO_IN8(base, offset) xf86ReadMmio8(base, offset)
-# define MMIO_OUT8(base, offset, val) \
- xf86WriteMmio8(base, offset, (CARD8)(val))
-# define MMIO_ONB8(base, offset, val) \
- xf86WriteMmio8NB(base, offset, (CARD8)(val))
-
-# if defined(SPARC_MMIO_IS_BE) /* No byteswapping */
-# define MMIO_IN16(base, offset) xf86ReadMmio16Be(base, offset)
-# define MMIO_IN32(base, offset) xf86ReadMmio32Be(base, offset)
-# define MMIO_OUT16(base, offset, val) \
- xf86WriteMmio16Be(base, offset, (CARD16)(val))
-# define MMIO_OUT32(base, offset, val) \
- xf86WriteMmio32Be(base, offset, (CARD32)(val))
-# define MMIO_ONB16(base, offset, val) \
- xf86WriteMmio16BeNB(base, offset, (CARD16)(val))
-# define MMIO_ONB32(base, offset, val) \
- xf86WriteMmio32BeNB(base, offset, (CARD32)(val))
-# else /* byteswapping is the default */
-# define MMIO_IN16(base, offset) xf86ReadMmio16Le(base, offset)
-# define MMIO_IN32(base, offset) xf86ReadMmio32Le(base, offset)
-# define MMIO_OUT16(base, offset, val) \
- xf86WriteMmio16Le(base, offset, (CARD16)(val))
-# define MMIO_OUT32(base, offset, val) \
- xf86WriteMmio32Le(base, offset, (CARD32)(val))
-# define MMIO_ONB16(base, offset, val) \
- xf86WriteMmio16LeNB(base, offset, (CARD16)(val))
-# define MMIO_ONB32(base, offset, val) \
- xf86WriteMmio32LeNB(base, offset, (CARD32)(val))
-# endif
-
-# define MMIO_MOVE32(base, offset, val) \
- xf86WriteMmio32Be(base, offset, (CARD32)(val))
-
-# elif defined(__nds32__)
- /*
- * we provide byteswapping and no byteswapping functions here
- * with no byteswapping as default; when endianness of CPU core
- * and I/O devices don't match, byte swapping is necessary
- * drivers that need byteswapping should define NDS32_MMIO_SWAP
- */
-# define MMIO_IN8(base, offset) xf86ReadMmio8(base, offset)
-# define MMIO_OUT8(base, offset, val) \
- xf86WriteMmio8(base, offset, (CARD8)(val))
-# define MMIO_ONB8(base, offset, val) \
- xf86WriteMmioNB8(base, offset, (CARD8)(val))
-
-# if defined(NDS32_MMIO_SWAP) /* byteswapping */
-# define MMIO_IN16(base, offset) xf86ReadMmio16Swap(base, offset)
-# define MMIO_IN32(base, offset) xf86ReadMmio32Swap(base, offset)
-# define MMIO_OUT16(base, offset, val) \
- xf86WriteMmio16Swap(base, offset, (CARD16)(val))
-# define MMIO_OUT32(base, offset, val) \
- xf86WriteMmio32Swap(base, offset, (CARD32)(val))
-# define MMIO_ONB16(base, offset, val) \
- xf86WriteMmioNB16Swap(base, offset, (CARD16)(val))
-# define MMIO_ONB32(base, offset, val) \
- xf86WriteMmioNB32Swap(base, offset, (CARD32)(val))
-# else /* no byteswapping is the default */
-# define MMIO_IN16(base, offset) xf86ReadMmio16(base, offset)
-# define MMIO_IN32(base, offset) xf86ReadMmio32(base, offset)
-# define MMIO_OUT16(base, offset, val) \
- xf86WriteMmio16(base, offset, (CARD16)(val))
-# define MMIO_OUT32(base, offset, val) \
- xf86WriteMmio32(base, offset, (CARD32)(val))
-# define MMIO_ONB16(base, offset, val) \
- xf86WriteMmioNB16(base, offset, (CARD16)(val))
-# define MMIO_ONB32(base, offset, val) \
- xf86WriteMmioNB32(base, offset, (CARD32)(val))
-# endif
-
-# define MMIO_MOVE32(base, offset, val) \
- xf86WriteMmio32(base, offset, (CARD32)(val))
-
-#ifdef N1213_HC /* for NDS32 N1213 hardcore */
-static __inline__ void nds32_flush_icache(char *addr)
-{
- __asm__ volatile (
- "isync %0;"
- "msync;"
- "isb;"
- "cctl %0,L1I_VA_INVAL;"
- "isb;"
- : : "r"(addr) : "memory");
-}
-#else
-static __inline__ void nds32_flush_icache(char *addr)
-{
- __asm__ volatile (
- "isync %0;"
- "isb;"
- : : "r"(addr) : "memory");
-}
-#endif
-
-# else /* !__alpha__ && !__powerpc__ && !__sparc__ */
-
-# define MMIO_IN8(base, offset) \
- *(volatile CARD8 *)(((CARD8*)(base)) + (offset))
-# define MMIO_IN16(base, offset) \
- *(volatile CARD16 *)(void *)(((CARD8*)(base)) + (offset))
-# define MMIO_IN32(base, offset) \
- *(volatile CARD32 *)(void *)(((CARD8*)(base)) + (offset))
-# define MMIO_OUT8(base, offset, val) \
- *(volatile CARD8 *)(((CARD8*)(base)) + (offset)) = (val)
-# define MMIO_OUT16(base, offset, val) \
- *(volatile CARD16 *)(void *)(((CARD8*)(base)) + (offset)) = (val)
-# define MMIO_OUT32(base, offset, val) \
- *(volatile CARD32 *)(void *)(((CARD8*)(base)) + (offset)) = (val)
-# define MMIO_ONB8(base, offset, val) MMIO_OUT8(base, offset, val)
-# define MMIO_ONB16(base, offset, val) MMIO_OUT16(base, offset, val)
-# define MMIO_ONB32(base, offset, val) MMIO_OUT32(base, offset, val)
-
-# define MMIO_MOVE32(base, offset, val) MMIO_OUT32(base, offset, val)
-
-# endif /* __alpha__ */
-
-/*
- * With Intel, the version in os-support/misc/SlowBcopy.s is used.
- * This avoids port I/O during the copy (which causes problems with
- * some hardware).
- */
-# ifdef __alpha__
-# define slowbcopy_tobus(src,dst,count) xf86SlowBCopyToBus(src,dst,count)
-# define slowbcopy_frombus(src,dst,count) xf86SlowBCopyFromBus(src,dst,count)
-# else /* __alpha__ */
-# define slowbcopy_tobus(src,dst,count) xf86SlowBcopy(src,dst,count)
-# define slowbcopy_frombus(src,dst,count) xf86SlowBcopy(src,dst,count)
-# endif /* __alpha__ */
-
-#endif /* _COMPILER_H */
+/*
+ * Copyright 1990,91 by Thomas Roell, Dinkelscherben, Germany.
+ *
+ * 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 Thomas Roell not be used in
+ * advertising or publicity pertaining to distribution of the software without
+ * specific, written prior permission. Thomas Roell makes no representations
+ * about the suitability of this software for any purpose. It is provided
+ * "as is" without express or implied warranty.
+ *
+ * THOMAS ROELL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
+ * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
+ * EVENT SHALL THOMAS ROELL 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) 1994-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).
+ */
+
+#ifndef _COMPILER_H
+
+# define _COMPILER_H
+
+#if defined(__SUNPRO_C)
+# define DO_PROTOTYPES
+#endif
+
+/* Map Sun compiler platform defines to gcc-style used in the code */
+#if defined(__amd64) && !defined(__amd64__)
+# define __amd64__
+#endif
+#if defined(__i386) && !defined(__i386__)
+# define __i386__
+#endif
+#if defined(__sparc) && !defined(__sparc__)
+# define __sparc__
+#endif
+#if defined(__sparcv9) && !defined(__sparc64__)
+# define __sparc64__
+#endif
+
+#ifndef _X_EXPORT
+# include <X11/Xfuncproto.h>
+#endif
+
+# include <pixman.h> /* for uint*_t types */
+
+/* Allow drivers to use the GCC-supported __inline__ and/or __inline. */
+# ifndef __inline__
+# if defined(__GNUC__)
+ /* gcc has __inline__ */
+# elif defined(__HIGHC__)
+# define __inline__ _Inline
+# else
+# define __inline__ /**/
+# endif
+# endif /* __inline__ */
+# ifndef __inline
+# if defined(__GNUC__) || defined(_MSC_VER)
+ /* gcc has __inline */
+# elif defined(__HIGHC__)
+# define __inline _Inline
+# else
+# define __inline /**/
+# endif
+# endif /* __inline */
+
+/* Support gcc's __FUNCTION__ for people using other compilers */
+#if !defined(__GNUC__) && !defined(__FUNCTION__)
+# define __FUNCTION__ __func__ /* C99 */
+#endif
+
+# if defined(NO_INLINE) || defined(DO_PROTOTYPES)
+
+# if !defined(__arm__)
+# if !defined(__sparc__) && !defined(__sparc) && !defined(__arm32__) && !defined(__nds32__) \
+ && !(defined(__alpha__) && defined(linux)) \
+ && !(defined(__ia64__) && defined(linux)) \
+
+extern _X_EXPORT void outb(unsigned short, unsigned char);
+extern _X_EXPORT void outw(unsigned short, unsigned short);
+extern _X_EXPORT void outl(unsigned short, unsigned int);
+extern _X_EXPORT unsigned int inb(unsigned short);
+extern _X_EXPORT unsigned int inw(unsigned short);
+extern _X_EXPORT unsigned int inl(unsigned short);
+
+# else /* __sparc__, __arm32__, __alpha__, __nds32__ */
+
+extern _X_EXPORT void outb(unsigned long, unsigned char);
+extern _X_EXPORT void outw(unsigned long, unsigned short);
+extern _X_EXPORT void outl(unsigned long, unsigned int);
+extern _X_EXPORT unsigned int inb(unsigned long);
+extern _X_EXPORT unsigned int inw(unsigned long);
+extern _X_EXPORT unsigned int inl(unsigned long);
+
+# endif /* __sparc__, __arm32__, __alpha__, __nds32__ */
+# endif /* __arm__ */
+
+# if defined(__powerpc__) && !defined(__OpenBSD__)
+extern unsigned long ldq_u(unsigned long *);
+extern unsigned long ldl_u(unsigned int *);
+extern unsigned long ldw_u(unsigned short *);
+extern void stq_u(unsigned long, unsigned long *);
+extern void stl_u(unsigned long, unsigned int *);
+extern void stw_u(unsigned long, unsigned short *);
+extern void mem_barrier(void);
+extern void write_mem_barrier(void);
+extern void stl_brx(unsigned long, volatile unsigned char *, int);
+extern void stw_brx(unsigned short, volatile unsigned char *, int);
+extern unsigned long ldl_brx(volatile unsigned char *, int);
+extern unsigned short ldw_brx(volatile unsigned char *, int);
+# endif /* __powerpc__ && !__OpenBSD */
+
+# endif /* NO_INLINE || DO_PROTOTYPES */
+
+# ifndef NO_INLINE
+# ifdef __GNUC__
+# ifdef __i386__
+
+# ifdef __SSE__
+# define write_mem_barrier() __asm__ __volatile__ ("sfence" : : : "memory")
+# else
+# define write_mem_barrier() __asm__ __volatile__ ("lock; addl $0,0(%%esp)" : : : "memory")
+# endif
+
+# ifdef __SSE2__
+# define mem_barrier() __asm__ __volatile__ ("mfence" : : : "memory")
+# else
+# define mem_barrier() __asm__ __volatile__ ("lock; addl $0,0(%%esp)" : : : "memory")
+# endif
+
+# elif defined __alpha__
+
+# define mem_barrier() __asm__ __volatile__ ("mb" : : : "memory")
+# define write_mem_barrier() __asm__ __volatile__ ("wmb" : : : "memory")
+
+# elif defined __amd64__
+
+# define mem_barrier() __asm__ __volatile__ ("mfence" : : : "memory")
+# define write_mem_barrier() __asm__ __volatile__ ("sfence" : : : "memory")
+
+# elif defined __ia64__
+
+# ifndef __INTEL_COMPILER
+# define mem_barrier() __asm__ __volatile__ ("mf" : : : "memory")
+# define write_mem_barrier() __asm__ __volatile__ ("mf" : : : "memory")
+# else
+# include "ia64intrin.h"
+# define mem_barrier() __mf()
+# define write_mem_barrier() __mf()
+# endif
+
+# elif defined __mips__
+ /* Note: sync instruction requires MIPS II instruction set */
+# define mem_barrier() \
+ __asm__ __volatile__( \
+ ".set push\n\t" \
+ ".set noreorder\n\t" \
+ ".set mips2\n\t" \
+ "sync\n\t" \
+ ".set pop" \
+ : /* no output */ \
+ : /* no input */ \
+ : "memory")
+# define write_mem_barrier() mem_barrier()
+
+# elif defined __powerpc__
+
+# if defined(linux) && defined(__powerpc64__)
+# include <linux/version.h>
+# if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 0)
+# include <asm/memory.h>
+# endif
+# endif /* defined(linux) && defined(__powerpc64__) */
+
+# ifndef eieio /* We deal with arch-specific eieio() routines above... */
+# define eieio() __asm__ __volatile__ ("eieio" ::: "memory")
+# endif /* eieio */
+# define mem_barrier() eieio()
+# define write_mem_barrier() eieio()
+
+# elif defined __sparc__
+
+# define barrier() __asm__ __volatile__ (".word 0x8143e00a" : : : "memory")
+# define mem_barrier() /* XXX: nop for now */
+# define write_mem_barrier() /* XXX: nop for now */
+# endif
+# endif /* __GNUC__ */
+# endif /* NO_INLINE */
+
+# ifndef mem_barrier
+# define mem_barrier() /* NOP */
+# endif
+
+# ifndef write_mem_barrier
+# define write_mem_barrier() /* NOP */
+# endif
+
+
+# ifndef NO_INLINE
+# ifdef __GNUC__
+
+/* Define some packed structures to use with unaligned accesses */
+
+struct __una_u64 { uint64_t x __attribute__((packed)); };
+struct __una_u32 { uint32_t x __attribute__((packed)); };
+struct __una_u16 { uint16_t x __attribute__((packed)); };
+
+/* Elemental unaligned loads */
+
+static __inline__ uint64_t ldq_u(uint64_t *p)
+{
+ const struct __una_u64 *ptr = (const struct __una_u64 *) p;
+ return ptr->x;
+}
+
+static __inline__ uint32_t ldl_u(uint32_t *p)
+{
+ const struct __una_u32 *ptr = (const struct __una_u32 *) p;
+ return ptr->x;
+}
+
+static __inline__ uint16_t ldw_u(uint16_t *p)
+{
+ const struct __una_u16 *ptr = (const struct __una_u16 *) p;
+ return ptr->x;
+}
+
+/* Elemental unaligned stores */
+
+static __inline__ void stq_u(uint64_t val, uint64_t *p)
+{
+ struct __una_u64 *ptr = (struct __una_u64 *) p;
+ ptr->x = val;
+}
+
+static __inline__ void stl_u(uint32_t val, uint32_t *p)
+{
+ struct __una_u32 *ptr = (struct __una_u32 *) p;
+ ptr->x = val;
+}
+
+static __inline__ void stw_u(uint16_t val, uint16_t *p)
+{
+ struct __una_u16 *ptr = (struct __una_u16 *) p;
+ ptr->x = val;
+}
+# else /* !__GNUC__ */
+
+#include <string.h> /* needed for memmove */
+
+static __inline__ uint64_t ldq_u(uint64_t *p)
+{
+ uint64_t ret;
+ memmove(&ret, p, sizeof(*p));
+ return ret;
+}
+
+static __inline__ uint32_t ldl_u(uint32_t *p)
+{
+ uint32_t ret;
+ memmove(&ret, p, sizeof(*p));
+ return ret;
+}
+
+static __inline__ uint16_t ldw_u(uint16_t *p)
+{
+ uint16_t ret;
+ memmove(&ret, p, sizeof(*p));
+ return ret;
+}
+
+static __inline__ void stq_u(uint64_t val, uint64_t *p)
+{
+ uint64_t tmp = val;
+ memmove(p, &tmp, sizeof(*p));
+}
+
+static __inline__ void stl_u(uint32_t val, uint32_t *p)
+{
+ uint32_t tmp = val;
+ memmove(p, &tmp, sizeof(*p));
+}
+
+static __inline__ void stw_u(uint16_t val, uint16_t *p)
+{
+ uint16_t tmp = val;
+ memmove(p, &tmp, sizeof(*p));
+}
+
+# endif /* __GNUC__ */
+# endif /* NO_INLINE */
+
+# ifndef NO_INLINE
+# ifdef __GNUC__
+# if (defined(linux) || defined(__FreeBSD__) || defined(__NetBSD__) || defined(__OpenBSD__)) && (defined(__alpha__))
+
+# ifdef linux
+/* for Linux on Alpha, we use the LIBC _inx/_outx routines */
+/* note that the appropriate setup via "ioperm" needs to be done */
+/* *before* any inx/outx is done. */
+
+extern _X_EXPORT void _outb(unsigned char val, unsigned long port);
+extern _X_EXPORT void _outw(unsigned short val, unsigned long port);
+extern _X_EXPORT void _outl(unsigned int val, unsigned long port);
+extern _X_EXPORT unsigned int _inb(unsigned long port);
+extern _X_EXPORT unsigned int _inw(unsigned long port);
+extern _X_EXPORT unsigned int _inl(unsigned long port);
+
+static __inline__ void
+outb(unsigned long port, unsigned char val)
+{
+ _outb(val, port);
+}
+
+static __inline__ void
+outw(unsigned long port, unsigned short val)
+{
+ _outw(val, port);
+}
+
+static __inline__ void
+outl(unsigned long port, unsigned int val)
+{
+ _outl(val, port);
+}
+
+static __inline__ unsigned int
+inb(unsigned long port)
+{
+ return _inb(port);
+}
+
+static __inline__ unsigned int
+inw(unsigned long port)
+{
+ return _inw(port);
+}
+
+static __inline__ unsigned int
+inl(unsigned long port)
+{
+ return _inl(port);
+}
+
+# endif /* linux */
+
+# if (defined(__FreeBSD__) || defined(__OpenBSD__)) \
+ && !defined(DO_PROTOTYPES)
+
+/* for FreeBSD and OpenBSD on Alpha, we use the libio (resp. libalpha) */
+/* inx/outx routines */
+/* note that the appropriate setup via "ioperm" needs to be done */
+/* *before* any inx/outx is done. */
+
+extern _X_EXPORT void outb(unsigned int port, unsigned char val);
+extern _X_EXPORT void outw(unsigned int port, unsigned short val);
+extern _X_EXPORT void outl(unsigned int port, unsigned int val);
+extern _X_EXPORT unsigned char inb(unsigned int port);
+extern _X_EXPORT unsigned short inw(unsigned int port);
+extern _X_EXPORT unsigned int inl(unsigned int port);
+
+# endif /* (__FreeBSD__ || __OpenBSD__ ) && !DO_PROTOTYPES */
+
+
+#if defined(__NetBSD__)
+#include <machine/pio.h>
+#endif /* __NetBSD__ */
+
+# elif defined(linux) && defined(__ia64__)
+
+# include <inttypes.h>
+
+# include <sys/io.h>
+
+# undef outb
+# undef outw
+# undef outl
+# undef inb
+# undef inw
+# undef inl
+extern _X_EXPORT void outb(unsigned long port, unsigned char val);
+extern _X_EXPORT void outw(unsigned long port, unsigned short val);
+extern _X_EXPORT void outl(unsigned long port, unsigned int val);
+extern _X_EXPORT unsigned int inb(unsigned long port);
+extern _X_EXPORT unsigned int inw(unsigned long port);
+extern _X_EXPORT unsigned int inl(unsigned long port);
+
+# elif (defined(linux) || defined(__FreeBSD__)) && defined(__amd64__)
+
+# include <inttypes.h>
+
+static __inline__ void
+outb(unsigned short port, unsigned char val)
+{
+ __asm__ __volatile__("outb %0,%1" : :"a" (val), "d" (port));
+}
+
+
+static __inline__ void
+outw(unsigned short port, unsigned short val)
+{
+ __asm__ __volatile__("outw %0,%1" : :"a" (val), "d" (port));
+}
+
+static __inline__ void
+outl(unsigned short port, unsigned int val)
+{
+ __asm__ __volatile__("outl %0,%1" : :"a" (val), "d" (port));
+}
+
+static __inline__ unsigned int
+inb(unsigned short port)
+{
+ unsigned char ret;
+ __asm__ __volatile__("inb %1,%0" :
+ "=a" (ret) :
+ "d" (port));
+ return ret;
+}
+
+static __inline__ unsigned int
+inw(unsigned short port)
+{
+ unsigned short ret;
+ __asm__ __volatile__("inw %1,%0" :
+ "=a" (ret) :
+ "d" (port));
+ return ret;
+}
+
+static __inline__ unsigned int
+inl(unsigned short port)
+{
+ unsigned int ret;
+ __asm__ __volatile__("inl %1,%0" :
+ "=a" (ret) :
+ "d" (port));
+ return ret;
+}
+
+# elif (defined(linux) || defined(sun) || defined(__OpenBSD__) || defined(__FreeBSD__)) && defined(__sparc__)
+
+# ifndef ASI_PL
+# define ASI_PL 0x88
+# endif
+
+static __inline__ void
+outb(unsigned long port, unsigned char val)
+{
+ __asm__ __volatile__("stba %0, [%1] %2"
+ : /* No outputs */
+ : "r" (val), "r" (port), "i" (ASI_PL));
+ barrier();
+}
+
+static __inline__ void
+outw(unsigned long port, unsigned short val)
+{
+ __asm__ __volatile__("stha %0, [%1] %2"
+ : /* No outputs */
+ : "r" (val), "r" (port), "i" (ASI_PL));
+ barrier();
+}
+
+static __inline__ void
+outl(unsigned long port, unsigned int val)
+{
+ __asm__ __volatile__("sta %0, [%1] %2"
+ : /* No outputs */
+ : "r" (val), "r" (port), "i" (ASI_PL));
+ barrier();
+}
+
+static __inline__ unsigned int
+inb(unsigned long port)
+{
+ unsigned int ret;
+ __asm__ __volatile__("lduba [%1] %2, %0"
+ : "=r" (ret)
+ : "r" (port), "i" (ASI_PL));
+ return ret;
+}
+
+static __inline__ unsigned int
+inw(unsigned long port)
+{
+ unsigned int ret;
+ __asm__ __volatile__("lduha [%1] %2, %0"
+ : "=r" (ret)
+ : "r" (port), "i" (ASI_PL));
+ return ret;
+}
+
+static __inline__ unsigned int
+inl(unsigned long port)
+{
+ unsigned int ret;
+ __asm__ __volatile__("lda [%1] %2, %0"
+ : "=r" (ret)
+ : "r" (port), "i" (ASI_PL));
+ return ret;
+}
+
+static __inline__ unsigned char
+xf86ReadMmio8(__volatile__ void *base, const unsigned long offset)
+{
+ unsigned long addr = ((unsigned long)base) + offset;
+ unsigned char ret;
+
+ __asm__ __volatile__("lduba [%1] %2, %0"
+ : "=r" (ret)
+ : "r" (addr), "i" (ASI_PL));
+ return ret;
+}
+
+static __inline__ unsigned short
+xf86ReadMmio16Be(__volatile__ void *base, const unsigned long offset)
+{
+ unsigned long addr = ((unsigned long)base) + offset;
+ unsigned short ret;
+
+ __asm__ __volatile__("lduh [%1], %0"
+ : "=r" (ret)
+ : "r" (addr));
+ return ret;
+}
+
+static __inline__ unsigned short
+xf86ReadMmio16Le(__volatile__ void *base, const unsigned long offset)
+{
+ unsigned long addr = ((unsigned long)base) + offset;
+ unsigned short ret;
+
+ __asm__ __volatile__("lduha [%1] %2, %0"
+ : "=r" (ret)
+ : "r" (addr), "i" (ASI_PL));
+ return ret;
+}
+
+static __inline__ unsigned int
+xf86ReadMmio32Be(__volatile__ void *base, const unsigned long offset)
+{
+ unsigned long addr = ((unsigned long)base) + offset;
+ unsigned int ret;
+
+ __asm__ __volatile__("ld [%1], %0"
+ : "=r" (ret)
+ : "r" (addr));
+ return ret;
+}
+
+static __inline__ unsigned int
+xf86ReadMmio32Le(__volatile__ void *base, const unsigned long offset)
+{
+ unsigned long addr = ((unsigned long)base) + offset;
+ unsigned int ret;
+
+ __asm__ __volatile__("lda [%1] %2, %0"
+ : "=r" (ret)
+ : "r" (addr), "i" (ASI_PL));
+ return ret;
+}
+
+static __inline__ void
+xf86WriteMmio8(__volatile__ void *base, const unsigned long offset,
+ const unsigned int val)
+{
+ unsigned long addr = ((unsigned long)base) + offset;
+
+ __asm__ __volatile__("stba %0, [%1] %2"
+ : /* No outputs */
+ : "r" (val), "r" (addr), "i" (ASI_PL));
+ barrier();
+}
+
+static __inline__ void
+xf86WriteMmio16Be(__volatile__ void *base, const unsigned long offset,
+ const unsigned int val)
+{
+ unsigned long addr = ((unsigned long)base) + offset;
+
+ __asm__ __volatile__("sth %0, [%1]"
+ : /* No outputs */
+ : "r" (val), "r" (addr));
+ barrier();
+}
+
+static __inline__ void
+xf86WriteMmio16Le(__volatile__ void *base, const unsigned long offset,
+ const unsigned int val)
+{
+ unsigned long addr = ((unsigned long)base) + offset;
+
+ __asm__ __volatile__("stha %0, [%1] %2"
+ : /* No outputs */
+ : "r" (val), "r" (addr), "i" (ASI_PL));
+ barrier();
+}
+
+static __inline__ void
+xf86WriteMmio32Be(__volatile__ void *base, const unsigned long offset,
+ const unsigned int val)
+{
+ unsigned long addr = ((unsigned long)base) + offset;
+
+ __asm__ __volatile__("st %0, [%1]"
+ : /* No outputs */
+ : "r" (val), "r" (addr));
+ barrier();
+}
+
+static __inline__ void
+xf86WriteMmio32Le(__volatile__ void *base, const unsigned long offset,
+ const unsigned int val)
+{
+ unsigned long addr = ((unsigned long)base) + offset;
+
+ __asm__ __volatile__("sta %0, [%1] %2"
+ : /* No outputs */
+ : "r" (val), "r" (addr), "i" (ASI_PL));
+ barrier();
+}
+
+static __inline__ void
+xf86WriteMmio8NB(__volatile__ void *base, const unsigned long offset,
+ const unsigned int val)
+{
+ unsigned long addr = ((unsigned long)base) + offset;
+
+ __asm__ __volatile__("stba %0, [%1] %2"
+ : /* No outputs */
+ : "r" (val), "r" (addr), "i" (ASI_PL));
+}
+
+static __inline__ void
+xf86WriteMmio16BeNB(__volatile__ void *base, const unsigned long offset,
+ const unsigned int val)
+{
+ unsigned long addr = ((unsigned long)base) + offset;
+
+ __asm__ __volatile__("sth %0, [%1]"
+ : /* No outputs */
+ : "r" (val), "r" (addr));
+}
+
+static __inline__ void
+xf86WriteMmio16LeNB(__volatile__ void *base, const unsigned long offset,
+ const unsigned int val)
+{
+ unsigned long addr = ((unsigned long)base) + offset;
+
+ __asm__ __volatile__("stha %0, [%1] %2"
+ : /* No outputs */
+ : "r" (val), "r" (addr), "i" (ASI_PL));
+}
+
+static __inline__ void
+xf86WriteMmio32BeNB(__volatile__ void *base, const unsigned long offset,
+ const unsigned int val)
+{
+ unsigned long addr = ((unsigned long)base) + offset;
+
+ __asm__ __volatile__("st %0, [%1]"
+ : /* No outputs */
+ : "r" (val), "r" (addr));
+}
+
+static __inline__ void
+xf86WriteMmio32LeNB(__volatile__ void *base, const unsigned long offset,
+ const unsigned int val)
+{
+ unsigned long addr = ((unsigned long)base) + offset;
+
+ __asm__ __volatile__("sta %0, [%1] %2"
+ : /* No outputs */
+ : "r" (val), "r" (addr), "i" (ASI_PL));
+}
+
+# elif defined(__mips__) || (defined(__arm32__) && !defined(__linux__))
+# ifdef __arm32__
+# define PORT_SIZE long
+# else
+# define PORT_SIZE short
+# endif
+
+_X_EXPORT unsigned int IOPortBase; /* Memory mapped I/O port area */
+
+static __inline__ void
+outb(unsigned PORT_SIZE port, unsigned char val)
+{
+ *(volatile unsigned char*)(((unsigned PORT_SIZE)(port))+IOPortBase) = val;
+}
+
+static __inline__ void
+outw(unsigned PORT_SIZE port, unsigned short val)
+{
+ *(volatile unsigned short*)(((unsigned PORT_SIZE)(port))+IOPortBase) = val;
+}
+
+static __inline__ void
+outl(unsigned PORT_SIZE port, unsigned int val)
+{
+ *(volatile unsigned int*)(((unsigned PORT_SIZE)(port))+IOPortBase) = val;
+}
+
+static __inline__ unsigned int
+inb(unsigned PORT_SIZE port)
+{
+ return *(volatile unsigned char*)(((unsigned PORT_SIZE)(port))+IOPortBase);
+}
+
+static __inline__ unsigned int
+inw(unsigned PORT_SIZE port)
+{
+ return *(volatile unsigned short*)(((unsigned PORT_SIZE)(port))+IOPortBase);
+}
+
+static __inline__ unsigned int
+inl(unsigned PORT_SIZE port)
+{
+ return *(volatile unsigned int*)(((unsigned PORT_SIZE)(port))+IOPortBase);
+}
+
+
+# if defined(__mips__)
+# ifdef linux /* don't mess with other OSs */
+# if X_BYTE_ORDER == X_BIG_ENDIAN
+static __inline__ unsigned int
+xf86ReadMmio32Be(__volatile__ void *base, const unsigned long offset)
+{
+ unsigned long addr = ((unsigned long)base) + offset;
+ unsigned int ret;
+
+ __asm__ __volatile__("lw %0, 0(%1)"
+ : "=r" (ret)
+ : "r" (addr));
+ return ret;
+}
+
+static __inline__ void
+xf86WriteMmio32Be(__volatile__ void *base, const unsigned long offset,
+ const unsigned int val)
+{
+ unsigned long addr = ((unsigned long)base) + offset;
+
+ __asm__ __volatile__("sw %0, 0(%1)"
+ : /* No outputs */
+ : "r" (val), "r" (addr));
+}
+# endif
+# endif /* !linux */
+# endif /* __mips__ */
+
+# elif (defined(linux) || defined(__OpenBSD__) || defined(__NetBSD__) || defined(__FreeBSD__)) && defined(__powerpc__)
+
+# ifndef MAP_FAILED
+# define MAP_FAILED ((void *)-1)
+# endif
+
+extern _X_EXPORT volatile unsigned char *ioBase;
+
+static __inline__ unsigned char
+xf86ReadMmio8(__volatile__ void *base, const unsigned long offset)
+{
+ register unsigned char val;
+ __asm__ __volatile__(
+ "lbzx %0,%1,%2\n\t"
+ "eieio"
+ : "=r" (val)
+ : "b" (base), "r" (offset),
+ "m" (*((volatile unsigned char *)base+offset)));
+ return val;
+}
+
+static __inline__ unsigned short
+xf86ReadMmio16Be(__volatile__ void *base, const unsigned long offset)
+{
+ register unsigned short val;
+ __asm__ __volatile__(
+ "lhzx %0,%1,%2\n\t"
+ "eieio"
+ : "=r" (val)
+ : "b" (base), "r" (offset),
+ "m" (*((volatile unsigned char *)base+offset)));
+ return val;
+}
+
+static __inline__ unsigned short
+xf86ReadMmio16Le(__volatile__ void *base, const unsigned long offset)
+{
+ register unsigned short val;
+ __asm__ __volatile__(
+ "lhbrx %0,%1,%2\n\t"
+ "eieio"
+ : "=r" (val)
+ : "b" (base), "r" (offset),
+ "m" (*((volatile unsigned char *)base+offset)));
+ return val;
+}
+
+static __inline__ unsigned int
+xf86ReadMmio32Be(__volatile__ void *base, const unsigned long offset)
+{
+ register unsigned int val;
+ __asm__ __volatile__(
+ "lwzx %0,%1,%2\n\t"
+ "eieio"
+ : "=r" (val)
+ : "b" (base), "r" (offset),
+ "m" (*((volatile unsigned char *)base+offset)));
+ return val;
+}
+
+static __inline__ unsigned int
+xf86ReadMmio32Le(__volatile__ void *base, const unsigned long offset)
+{
+ register unsigned int val;
+ __asm__ __volatile__(
+ "lwbrx %0,%1,%2\n\t"
+ "eieio"
+ : "=r" (val)
+ : "b" (base), "r" (offset),
+ "m" (*((volatile unsigned char *)base+offset)));
+ return val;
+}
+
+static __inline__ void
+xf86WriteMmioNB8(__volatile__ void *base, const unsigned long offset,
+ const unsigned char val)
+{
+ __asm__ __volatile__(
+ "stbx %1,%2,%3\n\t"
+ : "=m" (*((volatile unsigned char *)base+offset))
+ : "r" (val), "b" (base), "r" (offset));
+}
+
+static __inline__ void
+xf86WriteMmioNB16Le(__volatile__ void *base, const unsigned long offset,
+ const unsigned short val)
+{
+ __asm__ __volatile__(
+ "sthbrx %1,%2,%3\n\t"
+ : "=m" (*((volatile unsigned char *)base+offset))
+ : "r" (val), "b" (base), "r" (offset));
+}
+
+static __inline__ void
+xf86WriteMmioNB16Be(__volatile__ void *base, const unsigned long offset,
+ const unsigned short val)
+{
+ __asm__ __volatile__(
+ "sthx %1,%2,%3\n\t"
+ : "=m" (*((volatile unsigned char *)base+offset))
+ : "r" (val), "b" (base), "r" (offset));
+}
+
+static __inline__ void
+xf86WriteMmioNB32Le(__volatile__ void *base, const unsigned long offset,
+ const unsigned int val)
+{
+ __asm__ __volatile__(
+ "stwbrx %1,%2,%3\n\t"
+ : "=m" (*((volatile unsigned char *)base+offset))
+ : "r" (val), "b" (base), "r" (offset));
+}
+
+static __inline__ void
+xf86WriteMmioNB32Be(__volatile__ void *base, const unsigned long offset,
+ const unsigned int val)
+{
+ __asm__ __volatile__(
+ "stwx %1,%2,%3\n\t"
+ : "=m" (*((volatile unsigned char *)base+offset))
+ : "r" (val), "b" (base), "r" (offset));
+}
+
+static __inline__ void
+xf86WriteMmio8(__volatile__ void *base, const unsigned long offset,
+ const unsigned char val)
+{
+ xf86WriteMmioNB8(base, offset, val);
+ eieio();
+}
+
+static __inline__ void
+xf86WriteMmio16Le(__volatile__ void *base, const unsigned long offset,
+ const unsigned short val)
+{
+ xf86WriteMmioNB16Le(base, offset, val);
+ eieio();
+}
+
+static __inline__ void
+xf86WriteMmio16Be(__volatile__ void *base, const unsigned long offset,
+ const unsigned short val)
+{
+ xf86WriteMmioNB16Be(base, offset, val);
+ eieio();
+}
+
+static __inline__ void
+xf86WriteMmio32Le(__volatile__ void *base, const unsigned long offset,
+ const unsigned int val)
+{
+ xf86WriteMmioNB32Le(base, offset, val);
+ eieio();
+}
+
+static __inline__ void
+xf86WriteMmio32Be(__volatile__ void *base, const unsigned long offset,
+ const unsigned int val)
+{
+ xf86WriteMmioNB32Be(base, offset, val);
+ eieio();
+}
+
+
+static __inline__ void
+outb(unsigned short port, unsigned char value)
+{
+ if(ioBase == MAP_FAILED) return;
+ xf86WriteMmio8((void *)ioBase, port, value);
+}
+
+static __inline__ void
+outw(unsigned short port, unsigned short value)
+{
+ if(ioBase == MAP_FAILED) return;
+ xf86WriteMmio16Le((void *)ioBase, port, value);
+}
+
+static __inline__ void
+outl(unsigned short port, unsigned int value)
+{
+ if(ioBase == MAP_FAILED) return;
+ xf86WriteMmio32Le((void *)ioBase, port, value);
+}
+
+static __inline__ unsigned int
+inb(unsigned short port)
+{
+ if(ioBase == MAP_FAILED) return 0;
+ return xf86ReadMmio8((void *)ioBase, port);
+}
+
+static __inline__ unsigned int
+inw(unsigned short port)
+{
+ if(ioBase == MAP_FAILED) return 0;
+ return xf86ReadMmio16Le((void *)ioBase, port);
+}
+
+static __inline__ unsigned int
+inl(unsigned short port)
+{
+ if(ioBase == MAP_FAILED) return 0;
+ return xf86ReadMmio32Le((void *)ioBase, port);
+}
+
+#elif defined(__arm__) && defined(__linux__)
+
+/* for Linux on ARM, we use the LIBC inx/outx routines */
+/* note that the appropriate setup via "ioperm" needs to be done */
+/* *before* any inx/outx is done. */
+
+#include <sys/io.h>
+
+static __inline__ void
+xf_outb(unsigned short port, unsigned char val)
+{
+ outb(val, port);
+}
+
+static __inline__ void
+xf_outw(unsigned short port, unsigned short val)
+{
+ outw(val, port);
+}
+
+static __inline__ void
+xf_outl(unsigned short port, unsigned int val)
+{
+ outl(val, port);
+}
+
+#define outb xf_outb
+#define outw xf_outw
+#define outl xf_outl
+
+# elif defined(__nds32__)
+
+/*
+ * Assume all port access are aligned. We need to revise this implementation
+ * if there is unaligned port access. For ldq_u, ldl_u, ldw_u, stq_u, stl_u and
+ * stw_u, they are assumed unaligned.
+ */
+
+#define barrier() /* no barrier */
+
+#define PORT_SIZE long
+
+static __inline__ unsigned char
+xf86ReadMmio8(__volatile__ void *base, const unsigned long offset)
+{
+ return *(volatile unsigned char *)((unsigned char *)base + offset) ;
+}
+
+static __inline__ void
+xf86WriteMmio8(__volatile__ void *base, const unsigned long offset,
+ const unsigned int val)
+{
+ *(volatile unsigned char *)((unsigned char *)base + offset) = val ;
+ barrier();
+}
+
+static __inline__ void
+xf86WriteMmio8NB(__volatile__ void *base, const unsigned long offset,
+ const unsigned int val)
+{
+ *(volatile unsigned char *)((unsigned char *)base + offset) = val ;
+}
+
+static __inline__ unsigned short
+xf86ReadMmio16Swap(__volatile__ void *base, const unsigned long offset)
+{
+ unsigned long addr = ((unsigned long)base) + offset;
+ unsigned short ret;
+
+ __asm__ __volatile__(
+ "lhi %0, [%1];\n\t"
+ "wsbh %0, %0;\n\t"
+ : "=r" (ret)
+ : "r" (addr));
+ return ret;
+}
+
+static __inline__ unsigned short
+xf86ReadMmio16(__volatile__ void *base, const unsigned long offset)
+{
+ return *(volatile unsigned short *)((char *)base + offset) ;
+}
+
+static __inline__ void
+xf86WriteMmio16Swap(__volatile__ void *base, const unsigned long offset,
+ const unsigned int val)
+{
+ unsigned long addr = ((unsigned long)base) + offset;
+
+ __asm__ __volatile__(
+ "wsbh %0, %0;\n\t"
+ "shi %0, [%1];\n\t"
+ : /* No outputs */
+ : "r" (val), "r" (addr));
+ barrier();
+}
+
+static __inline__ void
+xf86WriteMmio16(__volatile__ void *base, const unsigned long offset,
+ const unsigned int val)
+{
+ *(volatile unsigned short *)((unsigned char *)base + offset) = val ;
+ barrier();
+}
+
+static __inline__ void
+xf86WriteMmio16SwapNB(__volatile__ void *base, const unsigned long offset,
+ const unsigned int val)
+{
+ unsigned long addr = ((unsigned long)base) + offset;
+
+ __asm__ __volatile__(
+ "wsbh %0, %0;\n\t"
+ "shi %0, [%1];\n\t"
+ : /* No outputs */
+ : "r" (val), "r" (addr));
+}
+
+static __inline__ void
+xf86WriteMmio16NB(__volatile__ void *base, const unsigned long offset,
+ const unsigned int val)
+{
+ *(volatile unsigned short *)((unsigned char *)base + offset) = val ;
+}
+
+static __inline__ unsigned int
+xf86ReadMmio32Swap(__volatile__ void *base, const unsigned long offset)
+{
+ unsigned long addr = ((unsigned long)base) + offset;
+ unsigned int ret;
+
+ __asm__ __volatile__(
+ "lwi %0, [%1];\n\t"
+ "wsbh %0, %0;\n\t"
+ "rotri %0, %0, 16;\n\t"
+ : "=r" (ret)
+ : "r" (addr));
+ return ret;
+}
+
+static __inline__ unsigned int
+xf86ReadMmio32(__volatile__ void *base, const unsigned long offset)
+{
+ return *(volatile unsigned int *)((unsigned char *)base + offset) ;
+}
+
+static __inline__ void
+xf86WriteMmio32Swap(__volatile__ void *base, const unsigned long offset,
+ const unsigned int val)
+{
+ unsigned long addr = ((unsigned long)base) + offset;
+
+ __asm__ __volatile__(
+ "wsbh %0, %0;\n\t"
+ "rotri %0, %0, 16;\n\t"
+ "swi %0, [%1];\n\t"
+ : /* No outputs */
+ : "r" (val), "r" (addr));
+ barrier();
+}
+
+static __inline__ void
+xf86WriteMmio32(__volatile__ void *base, const unsigned long offset,
+ const unsigned int val)
+{
+ *(volatile unsigned int *)((unsigned char *)base + offset) = val ;
+ barrier();
+}
+
+static __inline__ void
+xf86WriteMmio32SwapNB(__volatile__ void *base, const unsigned long offset,
+ const unsigned int val)
+{
+ unsigned long addr = ((unsigned long)base) + offset;
+
+ __asm__ __volatile__(
+ "wsbh %0, %0;\n\t"
+ "rotri %0, %0, 16;\n\t"
+ "swi %0, [%1];\n\t"
+ : /* No outputs */
+ : "r" (val), "r" (addr));
+}
+
+static __inline__ void
+xf86WriteMmio32NB(__volatile__ void *base, const unsigned long offset,
+ const unsigned int val)
+{
+ *(volatile unsigned int *)((unsigned char *)base + offset) = val ;
+}
+
+# if defined(NDS32_MMIO_SWAP)
+static __inline__ void
+outb(unsigned PORT_SIZE port, unsigned char val)
+{
+ xf86WriteMmio8(IOPortBase, port, val);
+}
+
+static __inline__ void
+outw(unsigned PORT_SIZE port, unsigned short val)
+{
+ xf86WriteMmio16Swap(IOPortBase, port, val);
+}
+
+static __inline__ void
+outl(unsigned PORT_SIZE port, unsigned int val)
+{
+ xf86WriteMmio32Swap(IOPortBase, port, val);
+}
+
+static __inline__ unsigned int
+inb(unsigned PORT_SIZE port)
+{
+ return xf86ReadMmio8(IOPortBase, port);
+}
+
+static __inline__ unsigned int
+inw(unsigned PORT_SIZE port)
+{
+ return xf86ReadMmio16Swap(IOPortBase, port);
+}
+
+static __inline__ unsigned int
+inl(unsigned PORT_SIZE port)
+{
+ return xf86ReadMmio32Swap(IOPortBase, port);
+}
+
+static __inline__ unsigned long ldq_u(unsigned long *p)
+{
+ unsigned long addr = (unsigned long)p;
+ unsigned int ret;
+
+ __asm__ __volatile__(
+ "lmw.bi %0, [%1], %0, 0;\n\t"
+ "wsbh %0, %0;\n\t"
+ "rotri %0, %0, 16;\n\t"
+ : "=r" (ret)
+ : "r" (addr));
+ return ret;
+}
+
+static __inline__ unsigned long ldl_u(unsigned int *p)
+{
+ unsigned long addr = (unsigned long)p;
+ unsigned int ret;
+
+ __asm__ __volatile__(
+ "lmw.bi %0, [%1], %0, 0;\n\t"
+ "wsbh %0, %0;\n\t"
+ "rotri %0, %0, 16;\n\t"
+ : "=r" (ret)
+ : "r" (addr));
+ return ret;
+}
+
+static __inline__ void stq_u(unsigned long val, unsigned long *p)
+{
+ unsigned long addr = (unsigned long)p;
+
+ __asm__ __volatile__(
+ "wsbh %0, %0;\n\t"
+ "rotri %0, %0, 16;\n\t"
+ "smw.bi %0, [%1], %0, 0;\n\t"
+ : /* No outputs */
+ : "r" (val), "r" (addr));
+}
+
+static __inline__ void stl_u(unsigned long val, unsigned int *p)
+{
+ unsigned long addr = (unsigned long)p;
+
+ __asm__ __volatile__(
+ "wsbh %0, %0;\n\t"
+ "rotri %0, %0, 16;\n\t"
+ "smw.bi %0, [%1], %0, 0;\n\t"
+ : /* No outputs */
+ : "r" (val), "r" (addr));
+}
+
+# else /* !NDS32_MMIO_SWAP */
+static __inline__ void
+outb(unsigned PORT_SIZE port, unsigned char val)
+{
+ *(volatile unsigned char*)(((unsigned PORT_SIZE)(port))) = val;
+ barrier();
+}
+
+static __inline__ void
+outw(unsigned PORT_SIZE port, unsigned short val)
+{
+ *(volatile unsigned short*)(((unsigned PORT_SIZE)(port))) = val;
+ barrier();
+}
+
+static __inline__ void
+outl(unsigned PORT_SIZE port, unsigned int val)
+{
+ *(volatile unsigned int*)(((unsigned PORT_SIZE)(port))) = val;
+ barrier();
+}
+static __inline__ unsigned int
+inb(unsigned PORT_SIZE port)
+{
+ return *(volatile unsigned char*)(((unsigned PORT_SIZE)(port)));
+}
+
+static __inline__ unsigned int
+inw(unsigned PORT_SIZE port)
+{
+ return *(volatile unsigned short*)(((unsigned PORT_SIZE)(port)));
+}
+
+static __inline__ unsigned int
+inl(unsigned PORT_SIZE port)
+{
+ return *(volatile unsigned int*)(((unsigned PORT_SIZE)(port)));
+}
+
+static __inline__ unsigned long ldq_u(unsigned long *p)
+{
+ unsigned long addr = (unsigned long)p;
+ unsigned int ret;
+
+ __asm__ __volatile__(
+ "lmw.bi %0, [%1], %0, 0;\n\t"
+ : "=r" (ret)
+ : "r" (addr));
+ return ret;
+}
+
+static __inline__ unsigned long ldl_u(unsigned int *p)
+{
+ unsigned long addr = (unsigned long)p;
+ unsigned int ret;
+
+ __asm__ __volatile__(
+ "lmw.bi %0, [%1], %0, 0;\n\t"
+ : "=r" (ret)
+ : "r" (addr));
+ return ret;
+}
+
+
+static __inline__ void stq_u(unsigned long val, unsigned long *p)
+{
+ unsigned long addr = (unsigned long)p;
+
+ __asm__ __volatile__(
+ "smw.bi %0, [%1], %0, 0;\n\t"
+ : /* No outputs */
+ : "r" (val), "r" (addr));
+}
+
+static __inline__ void stl_u(unsigned long val, unsigned int *p)
+{
+ unsigned long addr = (unsigned long)p;
+
+ __asm__ __volatile__(
+ "smw.bi %0, [%1], %0, 0;\n\t"
+ : /* No outputs */
+ : "r" (val), "r" (addr));
+}
+# endif /* NDS32_MMIO_SWAP */
+
+# if (((X_BYTE_ORDER == X_BIG_ENDIAN) && !defined(NDS32_MMIO_SWAP)) || ((X_BYTE_ORDER != X_BIG_ENDIAN) && defined(NDS32_MMIO_SWAP)))
+# define ldw_u(p) ((*(unsigned char *)(p)) << 8 | \
+ (*((unsigned char *)(p)+1)))
+# define stw_u(v,p) (*(unsigned char *)(p)) = ((v) >> 8); \
+ (*((unsigned char *)(p)+1)) = (v)
+# else
+# define ldw_u(p) ((*(unsigned char *)(p)) | \
+ (*((unsigned char *)(p)+1)<<8))
+# define stw_u(v,p) (*(unsigned char *)(p)) = (v); \
+ (*((unsigned char *)(p)+1)) = ((v) >> 8)
+# endif
+
+# define mem_barrier() /* XXX: nop for now */
+# define write_mem_barrier() /* XXX: nop for now */
+
+# else /* ix86 */
+
+# if !defined(__SUNPRO_C)
+# if !defined(FAKEIT) && !defined(__mc68000__) && !defined(__arm__) && !defined(__sh__) && !defined(__hppa__) && !defined(__s390__) && !defined(__m32r__)
+# ifdef GCCUSESGAS
+
+/*
+ * If gcc uses gas rather than the native assembler, the syntax of these
+ * inlines has to be different. DHD
+ */
+
+static __inline__ void
+outb(unsigned short port, unsigned char val)
+{
+ __asm__ __volatile__("outb %0,%1" : :"a" (val), "d" (port));
+}
+
+
+static __inline__ void
+outw(unsigned short port, unsigned short val)
+{
+ __asm__ __volatile__("outw %0,%1" : :"a" (val), "d" (port));
+}
+
+static __inline__ void
+outl(unsigned short port, unsigned int val)
+{
+ __asm__ __volatile__("outl %0,%1" : :"a" (val), "d" (port));
+}
+
+static __inline__ unsigned int
+inb(unsigned short port)
+{
+ unsigned char ret;
+ __asm__ __volatile__("inb %1,%0" :
+ "=a" (ret) :
+ "d" (port));
+ return ret;
+}
+
+static __inline__ unsigned int
+inw(unsigned short port)
+{
+ unsigned short ret;
+ __asm__ __volatile__("inw %1,%0" :
+ "=a" (ret) :
+ "d" (port));
+ return ret;
+}
+
+static __inline__ unsigned int
+inl(unsigned short port)
+{
+ unsigned int ret;
+ __asm__ __volatile__("inl %1,%0" :
+ "=a" (ret) :
+ "d" (port));
+ return ret;
+}
+
+# else /* GCCUSESGAS */
+
+static __inline__ void
+outb(unsigned short port, unsigned char val)
+{
+ __asm__ __volatile__("out%B0 (%1)" : :"a" (val), "d" (port));
+}
+
+static __inline__ void
+outw(unsigned short port, unsigned short val)
+{
+ __asm__ __volatile__("out%W0 (%1)" : :"a" (val), "d" (port));
+}
+
+static __inline__ void
+outl(unsigned short port, unsigned int val)
+{
+ __asm__ __volatile__("out%L0 (%1)" : :"a" (val), "d" (port));
+}
+
+static __inline__ unsigned int
+inb(unsigned short port)
+{
+ unsigned char ret;
+ __asm__ __volatile__("in%B0 (%1)" :
+ "=a" (ret) :
+ "d" (port));
+ return ret;
+}
+
+static __inline__ unsigned int
+inw(unsigned short port)
+{
+ unsigned short ret;
+ __asm__ __volatile__("in%W0 (%1)" :
+ "=a" (ret) :
+ "d" (port));
+ return ret;
+}
+
+static __inline__ unsigned int
+inl(unsigned short port)
+{
+ unsigned int ret;
+ __asm__ __volatile__("in%L0 (%1)" :
+ "=a" (ret) :
+ "d" (port));
+ return ret;
+}
+
+# endif /* GCCUSESGAS */
+
+# else /* !defined(FAKEIT) && !defined(__mc68000__) && !defined(__arm__) && !defined(__sh__) && !defined(__hppa__) && !defined(__m32r__) */
+
+static __inline__ void
+outb(unsigned short port, unsigned char val)
+{
+}
+
+static __inline__ void
+outw(unsigned short port, unsigned short val)
+{
+}
+
+static __inline__ void
+outl(unsigned short port, unsigned int val)
+{
+}
+
+static __inline__ unsigned int
+inb(unsigned short port)
+{
+ return 0;
+}
+
+static __inline__ unsigned int
+inw(unsigned short port)
+{
+ return 0;
+}
+
+static __inline__ unsigned int
+inl(unsigned short port)
+{
+ return 0;
+}
+
+# endif /* FAKEIT */
+# endif /* __SUNPRO_C */
+
+# endif /* ix86 */
+
+# else /* !GNUC */
+# if defined(__STDC__) && (__STDC__ == 1)
+# ifndef asm
+# define asm __asm
+# endif
+# endif
+# if !defined(__SUNPRO_C) && !defined(_MSC_VER)
+# include <sys/inline.h>
+# endif
+# if (!defined(__HIGHC__) && !defined(__SUNPRO_C) && !defined(_MSC_VER)) || \
+ defined(__USLC__)
+# pragma asm partial_optimization outl
+# pragma asm partial_optimization outw
+# pragma asm partial_optimization outb
+# pragma asm partial_optimization inl
+# pragma asm partial_optimization inw
+# pragma asm partial_optimization inb
+# endif
+# endif /* __GNUC__ */
+
+# endif /* NO_INLINE */
+
+# ifdef __alpha__
+/* entry points for Mmio memory access routines */
+extern _X_EXPORT int (*xf86ReadMmio8)(void *, unsigned long);
+extern _X_EXPORT int (*xf86ReadMmio16)(void *, unsigned long);
+# ifndef STANDALONE_MMIO
+extern _X_EXPORT int (*xf86ReadMmio32)(void *, unsigned long);
+# else
+/* Some DRI 3D drivers need MMIO_IN32. */
+static __inline__ int
+xf86ReadMmio32(void *Base, unsigned long Offset)
+{
+ mem_barrier();
+ return *(volatile unsigned int*)((unsigned long)Base+(Offset));
+}
+# endif
+extern _X_EXPORT void (*xf86WriteMmio8)(int, void *, unsigned long);
+extern _X_EXPORT void (*xf86WriteMmio16)(int, void *, unsigned long);
+extern _X_EXPORT void (*xf86WriteMmio32)(int, void *, unsigned long);
+extern _X_EXPORT void (*xf86WriteMmioNB8)(int, void *, unsigned long);
+extern _X_EXPORT void (*xf86WriteMmioNB16)(int, void *, unsigned long);
+extern _X_EXPORT void (*xf86WriteMmioNB32)(int, void *, unsigned long);
+extern _X_EXPORT void xf86SlowBCopyFromBus(unsigned char *, unsigned char *, int);
+extern _X_EXPORT void xf86SlowBCopyToBus(unsigned char *, unsigned char *, int);
+
+/* Some macros to hide the system dependencies for MMIO accesses */
+/* Changed to kill noise generated by gcc's -Wcast-align */
+# define MMIO_IN8(base, offset) (*xf86ReadMmio8)(base, offset)
+# define MMIO_IN16(base, offset) (*xf86ReadMmio16)(base, offset)
+# ifndef STANDALONE_MMIO
+# define MMIO_IN32(base, offset) (*xf86ReadMmio32)(base, offset)
+# else
+# define MMIO_IN32(base, offset) xf86ReadMmio32(base, offset)
+# endif
+
+# define MMIO_OUT32(base, offset, val) \
+ do { \
+ write_mem_barrier(); \
+ *(volatile CARD32 *)(void *)(((CARD8*)(base)) + (offset)) = (val); \
+ } while (0)
+# define MMIO_ONB32(base, offset, val) \
+ *(volatile CARD32 *)(void *)(((CARD8*)(base)) + (offset)) = (val)
+
+# define MMIO_OUT8(base, offset, val) \
+ (*xf86WriteMmio8)((CARD8)(val), base, offset)
+# define MMIO_OUT16(base, offset, val) \
+ (*xf86WriteMmio16)((CARD16)(val), base, offset)
+# define MMIO_ONB8(base, offset, val) \
+ (*xf86WriteMmioNB8)((CARD8)(val), base, offset)
+# define MMIO_ONB16(base, offset, val) \
+ (*xf86WriteMmioNB16)((CARD16)(val), base, offset)
+# define MMIO_MOVE32(base, offset, val) \
+ MMIO_OUT32(base, offset, val)
+
+# elif defined(__powerpc__)
+ /*
+ * we provide byteswapping and no byteswapping functions here
+ * with byteswapping as default,
+ * drivers that don't need byteswapping should define PPC_MMIO_IS_BE
+ */
+# define MMIO_IN8(base, offset) xf86ReadMmio8(base, offset)
+# define MMIO_OUT8(base, offset, val) \
+ xf86WriteMmio8(base, offset, (CARD8)(val))
+# define MMIO_ONB8(base, offset, val) \
+ xf86WriteMmioNB8(base, offset, (CARD8)(val))
+
+# if defined(PPC_MMIO_IS_BE) /* No byteswapping */
+# define MMIO_IN16(base, offset) xf86ReadMmio16Be(base, offset)
+# define MMIO_IN32(base, offset) xf86ReadMmio32Be(base, offset)
+# define MMIO_OUT16(base, offset, val) \
+ xf86WriteMmio16Be(base, offset, (CARD16)(val))
+# define MMIO_OUT32(base, offset, val) \
+ xf86WriteMmio32Be(base, offset, (CARD32)(val))
+# define MMIO_ONB16(base, offset, val) \
+ xf86WriteMmioNB16Be(base, offset, (CARD16)(val))
+# define MMIO_ONB32(base, offset, val) \
+ xf86WriteMmioNB32Be(base, offset, (CARD32)(val))
+# else /* byteswapping is the default */
+# define MMIO_IN16(base, offset) xf86ReadMmio16Le(base, offset)
+# define MMIO_IN32(base, offset) xf86ReadMmio32Le(base, offset)
+# define MMIO_OUT16(base, offset, val) \
+ xf86WriteMmio16Le(base, offset, (CARD16)(val))
+# define MMIO_OUT32(base, offset, val) \
+ xf86WriteMmio32Le(base, offset, (CARD32)(val))
+# define MMIO_ONB16(base, offset, val) \
+ xf86WriteMmioNB16Le(base, offset, (CARD16)(val))
+# define MMIO_ONB32(base, offset, val) \
+ xf86WriteMmioNB32Le(base, offset, (CARD32)(val))
+# endif
+
+# define MMIO_MOVE32(base, offset, val) \
+ xf86WriteMmio32Be(base, offset, (CARD32)(val))
+
+# elif defined(__sparc__) || defined(sparc) || defined(__sparc)
+ /*
+ * Like powerpc, we provide byteswapping and no byteswapping functions
+ * here with byteswapping as default, drivers that don't need byteswapping
+ * should define SPARC_MMIO_IS_BE (perhaps create a generic macro so that we
+ * do not need to use PPC_MMIO_IS_BE and the sparc one in all the same places
+ * of drivers?).
+ */
+# define MMIO_IN8(base, offset) xf86ReadMmio8(base, offset)
+# define MMIO_OUT8(base, offset, val) \
+ xf86WriteMmio8(base, offset, (CARD8)(val))
+# define MMIO_ONB8(base, offset, val) \
+ xf86WriteMmio8NB(base, offset, (CARD8)(val))
+
+# if defined(SPARC_MMIO_IS_BE) /* No byteswapping */
+# define MMIO_IN16(base, offset) xf86ReadMmio16Be(base, offset)
+# define MMIO_IN32(base, offset) xf86ReadMmio32Be(base, offset)
+# define MMIO_OUT16(base, offset, val) \
+ xf86WriteMmio16Be(base, offset, (CARD16)(val))
+# define MMIO_OUT32(base, offset, val) \
+ xf86WriteMmio32Be(base, offset, (CARD32)(val))
+# define MMIO_ONB16(base, offset, val) \
+ xf86WriteMmio16BeNB(base, offset, (CARD16)(val))
+# define MMIO_ONB32(base, offset, val) \
+ xf86WriteMmio32BeNB(base, offset, (CARD32)(val))
+# else /* byteswapping is the default */
+# define MMIO_IN16(base, offset) xf86ReadMmio16Le(base, offset)
+# define MMIO_IN32(base, offset) xf86ReadMmio32Le(base, offset)
+# define MMIO_OUT16(base, offset, val) \
+ xf86WriteMmio16Le(base, offset, (CARD16)(val))
+# define MMIO_OUT32(base, offset, val) \
+ xf86WriteMmio32Le(base, offset, (CARD32)(val))
+# define MMIO_ONB16(base, offset, val) \
+ xf86WriteMmio16LeNB(base, offset, (CARD16)(val))
+# define MMIO_ONB32(base, offset, val) \
+ xf86WriteMmio32LeNB(base, offset, (CARD32)(val))
+# endif
+
+# define MMIO_MOVE32(base, offset, val) \
+ xf86WriteMmio32Be(base, offset, (CARD32)(val))
+
+# elif defined(__nds32__)
+ /*
+ * we provide byteswapping and no byteswapping functions here
+ * with no byteswapping as default; when endianness of CPU core
+ * and I/O devices don't match, byte swapping is necessary
+ * drivers that need byteswapping should define NDS32_MMIO_SWAP
+ */
+# define MMIO_IN8(base, offset) xf86ReadMmio8(base, offset)
+# define MMIO_OUT8(base, offset, val) \
+ xf86WriteMmio8(base, offset, (CARD8)(val))
+# define MMIO_ONB8(base, offset, val) \
+ xf86WriteMmioNB8(base, offset, (CARD8)(val))
+
+# if defined(NDS32_MMIO_SWAP) /* byteswapping */
+# define MMIO_IN16(base, offset) xf86ReadMmio16Swap(base, offset)
+# define MMIO_IN32(base, offset) xf86ReadMmio32Swap(base, offset)
+# define MMIO_OUT16(base, offset, val) \
+ xf86WriteMmio16Swap(base, offset, (CARD16)(val))
+# define MMIO_OUT32(base, offset, val) \
+ xf86WriteMmio32Swap(base, offset, (CARD32)(val))
+# define MMIO_ONB16(base, offset, val) \
+ xf86WriteMmioNB16Swap(base, offset, (CARD16)(val))
+# define MMIO_ONB32(base, offset, val) \
+ xf86WriteMmioNB32Swap(base, offset, (CARD32)(val))
+# else /* no byteswapping is the default */
+# define MMIO_IN16(base, offset) xf86ReadMmio16(base, offset)
+# define MMIO_IN32(base, offset) xf86ReadMmio32(base, offset)
+# define MMIO_OUT16(base, offset, val) \
+ xf86WriteMmio16(base, offset, (CARD16)(val))
+# define MMIO_OUT32(base, offset, val) \
+ xf86WriteMmio32(base, offset, (CARD32)(val))
+# define MMIO_ONB16(base, offset, val) \
+ xf86WriteMmioNB16(base, offset, (CARD16)(val))
+# define MMIO_ONB32(base, offset, val) \
+ xf86WriteMmioNB32(base, offset, (CARD32)(val))
+# endif
+
+# define MMIO_MOVE32(base, offset, val) \
+ xf86WriteMmio32(base, offset, (CARD32)(val))
+
+#ifdef N1213_HC /* for NDS32 N1213 hardcore */
+static __inline__ void nds32_flush_icache(char *addr)
+{
+ __asm__ volatile (
+ "isync %0;"
+ "msync;"
+ "isb;"
+ "cctl %0,L1I_VA_INVAL;"
+ "isb;"
+ : : "r"(addr) : "memory");
+}
+#else
+static __inline__ void nds32_flush_icache(char *addr)
+{
+ __asm__ volatile (
+ "isync %0;"
+ "isb;"
+ : : "r"(addr) : "memory");
+}
+#endif
+
+# else /* !__alpha__ && !__powerpc__ && !__sparc__ */
+
+# define MMIO_IN8(base, offset) \
+ *(volatile CARD8 *)(((CARD8*)(base)) + (offset))
+# define MMIO_IN16(base, offset) \
+ *(volatile CARD16 *)(void *)(((CARD8*)(base)) + (offset))
+# define MMIO_IN32(base, offset) \
+ *(volatile CARD32 *)(void *)(((CARD8*)(base)) + (offset))
+# define MMIO_OUT8(base, offset, val) \
+ *(volatile CARD8 *)(((CARD8*)(base)) + (offset)) = (val)
+# define MMIO_OUT16(base, offset, val) \
+ *(volatile CARD16 *)(void *)(((CARD8*)(base)) + (offset)) = (val)
+# define MMIO_OUT32(base, offset, val) \
+ *(volatile CARD32 *)(void *)(((CARD8*)(base)) + (offset)) = (val)
+# define MMIO_ONB8(base, offset, val) MMIO_OUT8(base, offset, val)
+# define MMIO_ONB16(base, offset, val) MMIO_OUT16(base, offset, val)
+# define MMIO_ONB32(base, offset, val) MMIO_OUT32(base, offset, val)
+
+# define MMIO_MOVE32(base, offset, val) MMIO_OUT32(base, offset, val)
+
+# endif /* __alpha__ */
+
+/*
+ * With Intel, the version in os-support/misc/SlowBcopy.s is used.
+ * This avoids port I/O during the copy (which causes problems with
+ * some hardware).
+ */
+# ifdef __alpha__
+# define slowbcopy_tobus(src,dst,count) xf86SlowBCopyToBus(src,dst,count)
+# define slowbcopy_frombus(src,dst,count) xf86SlowBCopyFromBus(src,dst,count)
+# else /* __alpha__ */
+# define slowbcopy_tobus(src,dst,count) xf86SlowBcopy(src,dst,count)
+# define slowbcopy_frombus(src,dst,count) xf86SlowBcopy(src,dst,count)
+# endif /* __alpha__ */
+
+#endif /* _COMPILER_H */
diff --git a/xorg-server/hw/xfree86/common/scoasm.h b/xorg-server/hw/xfree86/common/scoasm.h
deleted file mode 100644
index 8f80e7b1e..000000000
--- a/xorg-server/hw/xfree86/common/scoasm.h
+++ /dev/null
@@ -1,142 +0,0 @@
-
-/*
- * Copyright (c) 1996 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).
- */
-
-/*
- * scoasm.h - used to define inline versions of certain functions which
- * do NOT appear in sys/inline.h.
- */
-#ifdef HAVE_XORG_CONFIG_H
-#include <xorg-config.h>
-#endif
-
-#if defined(__SCO__) && defined(__USLC__)
-#ifndef _SCOASM_HDR_INC
-#define _SCOASM_HDR_INC
-
-asm void outl(port,val)
-{
-%reg port,val;
- movl port, %edx
- movl val, %eax
- outl (%dx)
-%reg port; mem val;
- movl port, %edx
- movl val, %eax
- outl (%dx)
-%mem port; reg val;
- movw port, %dx
- movl val, %eax
- outl (%dx)
-%mem port,val;
- movw port, %dx
- movl val, %eax
- outl (%dx)
-}
-
-asm void outw(port,val)
-{
-%reg port,val;
- movl port, %edx
- movl val, %eax
- data16
- outl (%dx)
-%reg port; mem val;
- movl port, %edx
- movw val, %ax
- data16
- outl (%dx)
-%mem port; reg val;
- movw port, %dx
- movl val, %eax
- data16
- outl (%dx)
-%mem port,val;
- movw port, %dx
- movw val, %ax
- data16
- outl (%dx)
-}
-
-asm void outb(port,val)
-{
-%reg port,val;
- movl port, %edx
- movl val, %eax
- outb (%dx)
-%reg port; mem val;
- movl port, %edx
- movb val, %al
- outb (%dx)
-%mem port; reg val;
- movw port, %dx
- movl val, %eax
- outb (%dx)
-%mem port,val;
- movw port, %dx
- movb val, %al
- outb (%dx)
-}
-
-asm int inl(port)
-{
-%reg port;
- movl port, %edx
- inl (%dx)
-%mem port;
- movw port, %dx
- inl (%dx)
-}
-
-asm int inw(port)
-{
-%reg port;
- subl %eax, %eax
- movl port, %edx
- data16
- inl (%dx)
-%mem port;
- subl %eax, %eax
- movw port, %dx
- data16
- inl (%dx)
-}
-
-asm int inb(port)
-{
-%reg port;
- subl %eax, %eax
- movl port, %edx
- inb (%dx)
-%mem port;
- subl %eax, %eax
- movw port, %dx
- inb (%dx)
-}
-
-#endif /* _SCOASM_HDR_INC */
-#endif /* __SCO__ && __USLC__ */
diff --git a/xorg-server/hw/xfree86/common/xf86.h b/xorg-server/hw/xfree86/common/xf86.h
index c91020132..54332e381 100644
--- a/xorg-server/hw/xfree86/common/xf86.h
+++ b/xorg-server/hw/xfree86/common/xf86.h
@@ -1,355 +1,353 @@
-/*
- * 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 declarations for public XFree86 functions and variables,
- * and definitions of public macros.
- *
- * "public" means available to video drivers.
- */
-
-#ifndef _XF86_H
-#define _XF86_H
-
-#if HAVE_XORG_CONFIG_H
-#include <xorg-config.h>
-#elif HAVE_DIX_CONFIG_H
-#include <dix-config.h>
-#endif
-
-#include "xf86str.h"
-#include "xf86Opt.h"
-#include <X11/Xfuncproto.h>
-#include <stdarg.h>
-#ifdef RANDR
-#include <X11/extensions/randr.h>
-#endif
-
-#include "propertyst.h"
-
-/* General parameters */
-extern _X_EXPORT int xf86DoConfigure;
-extern _X_EXPORT int xf86DoShowOptions;
-extern _X_EXPORT Bool xf86DoConfigurePass1;
-
-extern _X_EXPORT DevPrivateKeyRec xf86ScreenKeyRec;
-#define xf86ScreenKey (&xf86ScreenKeyRec)
-
-extern _X_EXPORT DevPrivateKeyRec xf86CreateRootWindowKeyRec;
-#define xf86CreateRootWindowKey (&xf86CreateRootWindowKeyRec)
-
-extern _X_EXPORT ScrnInfoPtr *xf86Screens; /* List of pointers to ScrnInfoRecs */
-extern _X_EXPORT const unsigned char byte_reversed[256];
-extern _X_EXPORT Bool fbSlotClaimed;
-#if (defined(__sparc__) || defined(__sparc)) && !defined(__OpenBSD__)
-extern _X_EXPORT Bool sbusSlotClaimed;
-#endif
-extern _X_EXPORT confDRIRec xf86ConfigDRI;
-extern _X_EXPORT Bool xf86inSuspend;
-extern _X_EXPORT Bool xf86DRI2Enabled(void);
-
-extern _X_EXPORT Bool VTSwitchEnabled; /* kbd driver */
-
-#define XF86SCRNINFO(p) ((ScrnInfoPtr)dixLookupPrivate(&(p)->devPrivates, \
- xf86ScreenKey))
-#define XF86FLIP_PIXELS() \
- do { \
- if (xf86GetFlipPixels()) { \
- pScreen->whitePixel = (pScreen->whitePixel) ? 0 : 1; \
- pScreen->blackPixel = (pScreen->blackPixel) ? 0 : 1; \
- } \
- while (0)
-
-#define BOOLTOSTRING(b) ((b) ? "TRUE" : "FALSE")
-
-#define PIX24TOBPP(p) (((p) == Pix24Use24) ? 24 : \
- (((p) == Pix24Use32) ? 32 : 0))
-
-/* Function Prototypes */
-#ifndef _NO_XF86_PROTOTYPES
-
-/* PCI related */
-#include <pciaccess.h>
-extern _X_EXPORT Bool pciSlotClaimed;
-
-extern _X_EXPORT Bool xf86CheckPciSlot(const struct pci_device *);
-extern _X_EXPORT int xf86ClaimPciSlot(struct pci_device *, DriverPtr drvp,
- int chipset, GDevPtr dev, Bool active);
-extern _X_EXPORT void xf86UnclaimPciSlot(struct pci_device *);
-extern _X_EXPORT Bool xf86ParsePciBusString(const char *busID, int *bus,
- int *device, int *func);
-extern _X_EXPORT Bool xf86ComparePciBusString(const char *busID, int bus,
- int device, int func);
-extern _X_EXPORT void xf86FormatPciBusNumber(int busnum, char *buffer);
-extern _X_EXPORT Bool xf86IsPrimaryPci(struct pci_device * pPci);
-extern _X_EXPORT Bool xf86CheckPciMemBase(struct pci_device * pPci,
- memType base);
-extern _X_EXPORT struct pci_device * xf86GetPciInfoForEntity(int entityIndex);
-extern _X_EXPORT int xf86MatchPciInstances(const char *driverName,
- int vendorID, SymTabPtr chipsets, PciChipsets *PCIchipsets,
- GDevPtr *devList, int numDevs, DriverPtr drvp, int **foundEntities);
-extern _X_EXPORT ScrnInfoPtr xf86ConfigPciEntity(ScrnInfoPtr pScrn,
- int scrnFlag, int entityIndex,PciChipsets *p_chip, void *dummy,
- EntityProc init, EntityProc enter, EntityProc leave, pointer private);
-/* Obsolete! don't use */
-extern _X_EXPORT Bool xf86ConfigActivePciEntity(ScrnInfoPtr pScrn,
- int entityIndex,PciChipsets *p_chip, void *dummy, EntityProc init,
- EntityProc enter, EntityProc leave, pointer private);
-
-/* xf86Bus.c */
-
-extern _X_EXPORT int xf86GetFbInfoForScreen(int scrnIndex);
-extern _X_EXPORT int xf86ClaimFbSlot(DriverPtr drvp, int chipset, GDevPtr dev, Bool active);
-extern _X_EXPORT int xf86ClaimNoSlot(DriverPtr drvp, int chipset, GDevPtr dev, Bool active);
-extern _X_EXPORT Bool xf86DriverHasEntities(DriverPtr drvp);
-extern _X_EXPORT void xf86AddEntityToScreen(ScrnInfoPtr pScrn, int entityIndex);
-extern _X_EXPORT void xf86SetEntityInstanceForScreen(ScrnInfoPtr pScrn, int entityIndex,
- int instance);
-extern _X_EXPORT int xf86GetNumEntityInstances(int entityIndex);
-extern _X_EXPORT GDevPtr xf86GetDevFromEntity(int entityIndex, int instance);
-extern _X_EXPORT void xf86RemoveEntityFromScreen(ScrnInfoPtr pScrn, int entityIndex);
-extern _X_EXPORT EntityInfoPtr xf86GetEntityInfo(int entityIndex);
-extern _X_EXPORT Bool xf86SetEntityFuncs(int entityIndex, EntityProc init,
- EntityProc enter, EntityProc leave, pointer);
-extern _X_EXPORT Bool xf86IsEntityPrimary(int entityIndex);
-extern _X_EXPORT void xf86EnterServerState(xf86State state);
-extern _X_EXPORT ScrnInfoPtr xf86FindScreenForEntity(int entityIndex);
-
-extern _X_EXPORT int xf86GetLastScrnFlag(int entityIndex);
-extern _X_EXPORT void xf86SetLastScrnFlag(int entityIndex, int scrnIndex);
-extern _X_EXPORT Bool xf86IsEntityShared(int entityIndex);
-extern _X_EXPORT void xf86SetEntityShared(int entityIndex);
-extern _X_EXPORT Bool xf86IsEntitySharable(int entityIndex);
-extern _X_EXPORT void xf86SetEntitySharable(int entityIndex);
-extern _X_EXPORT Bool xf86IsPrimInitDone(int entityIndex);
-extern _X_EXPORT void xf86SetPrimInitDone(int entityIndex);
-extern _X_EXPORT void xf86ClearPrimInitDone(int entityIndex);
-extern _X_EXPORT int xf86AllocateEntityPrivateIndex(void);
-extern _X_EXPORT DevUnion *xf86GetEntityPrivate(int entityIndex, int privIndex);
-
-/* xf86Configure.c */
-extern _X_EXPORT GDevPtr xf86AddBusDeviceToConfigure(const char *driver, BusType bus,
- void *busData, int chipset);
-
-/* xf86Cursor.c */
-
-extern _X_EXPORT void xf86LockZoom(ScreenPtr pScreen, int lock);
-extern _X_EXPORT void xf86InitViewport(ScrnInfoPtr pScr);
-extern _X_EXPORT void xf86SetViewport(ScreenPtr pScreen, int x, int y);
-extern _X_EXPORT void xf86ZoomViewport(ScreenPtr pScreen, int zoom);
-extern _X_EXPORT Bool xf86SwitchMode(ScreenPtr pScreen, DisplayModePtr mode);
-extern _X_EXPORT void *xf86GetPointerScreenFuncs(void);
-extern _X_EXPORT void xf86InitOrigins(void);
-extern _X_EXPORT void xf86ReconfigureLayout(void);
-
-/* xf86cvt.c */
-extern _X_EXPORT DisplayModePtr xf86CVTMode(int HDisplay, int VDisplay, float VRefresh,
- Bool Reduced, Bool Interlaced);
-
-/* xf86DPMS.c */
-
-extern _X_EXPORT Bool xf86DPMSInit(ScreenPtr pScreen, DPMSSetProcPtr set, int flags);
-
-#ifdef DPMSExtension
-extern _X_EXPORT int DPMSSet(ClientPtr client, int level);
-extern _X_EXPORT Bool DPMSSupported(void);
-#endif
-
-
-/* xf86DGA.c */
-
-#ifdef XFreeXDGA
-extern _X_EXPORT Bool DGAInit(ScreenPtr pScreen, DGAFunctionPtr funcs, DGAModePtr modes,
- int num);
-extern _X_EXPORT Bool DGAReInitModes(ScreenPtr pScreen, DGAModePtr modes, int num);
-extern _X_EXPORT xf86SetDGAModeProc xf86SetDGAMode;
-#endif
-
-/* xf86Events.c */
-
-extern _X_EXPORT void SetTimeSinceLastInputEvent(void);
-extern _X_EXPORT pointer xf86AddInputHandler(int fd, InputHandlerProc proc, pointer data);
-extern _X_EXPORT int xf86RemoveInputHandler(pointer handler);
-extern _X_EXPORT void xf86DisableInputHandler(pointer handler);
-extern _X_EXPORT void xf86EnableInputHandler(pointer handler);
-extern _X_EXPORT pointer xf86AddGeneralHandler(int fd, InputHandlerProc proc, pointer data);
-extern _X_EXPORT int xf86RemoveGeneralHandler(pointer handler);
-extern _X_EXPORT void xf86DisableGeneralHandler(pointer handler);
-extern _X_EXPORT void xf86EnableGeneralHandler(pointer handler);
-extern _X_EXPORT InputHandlerProc xf86SetConsoleHandler(InputHandlerProc handler, pointer data);
-extern _X_EXPORT void xf86InterceptSignals(int *signo);
-extern _X_EXPORT void xf86InterceptSigIll(void (*sigillhandler)(void));
-extern _X_EXPORT Bool xf86EnableVTSwitch(Bool new);
-extern _X_EXPORT void xf86ProcessActionEvent(ActionEvent action, void *arg);
-extern _X_EXPORT void xf86PrintBacktrace(void);
-
-/* xf86Helper.c */
-
-extern _X_EXPORT void xf86AddDriver(DriverPtr driver, pointer module, int flags);
-extern _X_EXPORT void xf86DeleteDriver(int drvIndex);
-extern _X_EXPORT ScrnInfoPtr xf86AllocateScreen(DriverPtr drv, int flags);
-extern _X_EXPORT void xf86DeleteScreen(int scrnIndex, int flags);
-extern _X_EXPORT int xf86AllocateScrnInfoPrivateIndex(void);
-extern _X_EXPORT Bool xf86AddPixFormat(ScrnInfoPtr pScrn, int depth, int bpp, int pad);
-extern _X_EXPORT Bool xf86SetDepthBpp(ScrnInfoPtr scrp, int depth, int bpp, int fbbpp,
- int depth24flags);
-extern _X_EXPORT void xf86PrintDepthBpp(ScrnInfoPtr scrp);
-extern _X_EXPORT Bool xf86SetWeight(ScrnInfoPtr scrp, rgb weight, rgb mask);
-extern _X_EXPORT Bool xf86SetDefaultVisual(ScrnInfoPtr scrp, int visual);
-extern _X_EXPORT Bool xf86SetGamma(ScrnInfoPtr scrp, Gamma newGamma);
-extern _X_EXPORT void xf86SetDpi(ScrnInfoPtr pScrn, int x, int y);
-extern _X_EXPORT void xf86SetBlackWhitePixels(ScreenPtr pScreen);
-extern _X_EXPORT void xf86EnableDisableFBAccess(int scrnIndex, Bool enable);
-extern _X_EXPORT void xf86VDrvMsgVerb(int scrnIndex, MessageType type, int verb,
- const char *format, va_list args);
-extern _X_EXPORT void xf86DrvMsgVerb(int scrnIndex, MessageType type, int verb,
- const char *format, ...) _X_ATTRIBUTE_PRINTF(4,5);
-extern _X_EXPORT void xf86DrvMsg(int scrnIndex, MessageType type, const char *format, ...)
- _X_ATTRIBUTE_PRINTF(3,4);
-extern _X_EXPORT void xf86MsgVerb(MessageType type, int verb, const char *format, ...)
- _X_ATTRIBUTE_PRINTF(3,4);
-extern _X_EXPORT void xf86Msg(MessageType type, const char *format, ...) _X_ATTRIBUTE_PRINTF(2,3);
-extern _X_EXPORT void xf86ErrorFVerb(int verb, const char *format, ...) _X_ATTRIBUTE_PRINTF(2,3);
-extern _X_EXPORT void xf86ErrorF(const char *format, ...) _X_ATTRIBUTE_PRINTF(1,2);
-extern _X_EXPORT const char *xf86TokenToString(SymTabPtr table, int token);
-extern _X_EXPORT int xf86StringToToken(SymTabPtr table, const char *string);
-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);
-extern _X_EXPORT int xf86GetDepth(void);
-extern _X_EXPORT rgb xf86GetWeight(void);
-extern _X_EXPORT Gamma xf86GetGamma(void);
-extern _X_EXPORT Bool xf86GetFlipPixels(void);
-extern _X_EXPORT const char *xf86GetServerName(void);
-extern _X_EXPORT Bool xf86ServerIsExiting(void);
-extern _X_EXPORT Bool xf86ServerIsResetting(void);
-extern _X_EXPORT Bool xf86ServerIsInitialising(void);
-extern _X_EXPORT Bool xf86ServerIsOnlyDetecting(void);
-extern _X_EXPORT Bool xf86CaughtSignal(void);
-extern _X_EXPORT Bool xf86GetVidModeAllowNonLocal(void);
-extern _X_EXPORT Bool xf86GetVidModeEnabled(void);
-extern _X_EXPORT Bool xf86GetModInDevAllowNonLocal(void);
-extern _X_EXPORT Bool xf86GetModInDevEnabled(void);
-extern _X_EXPORT Bool xf86GetAllowMouseOpenFail(void);
-extern _X_EXPORT Bool xf86IsPc98(void);
-extern _X_EXPORT void xf86DisableRandR(void);
-extern _X_EXPORT CARD32 xorgGetVersion(void);
-extern _X_EXPORT CARD32 xf86GetModuleVersion(pointer module);
-extern _X_EXPORT pointer xf86LoadDrvSubModule(DriverPtr drv, const char *name);
-extern _X_EXPORT pointer xf86LoadSubModule(ScrnInfoPtr pScrn, const char *name);
-extern _X_EXPORT pointer xf86LoadOneModule(char *name, pointer optlist);
-extern _X_EXPORT void xf86UnloadSubModule(pointer mod);
-extern _X_EXPORT Bool xf86LoaderCheckSymbol(const char *name);
-extern _X_EXPORT void xf86SetBackingStore(ScreenPtr pScreen);
-extern _X_EXPORT void xf86SetSilkenMouse(ScreenPtr pScreen);
-extern _X_EXPORT pointer xf86FindXvOptions(int scrnIndex, int adapt_index, char *port_name,
- char **adaptor_name, pointer *adaptor_options);
-extern _X_EXPORT void xf86GetOS(const char **name, int *major, int *minor, int *teeny);
-extern _X_EXPORT ScrnInfoPtr xf86ConfigFbEntity(ScrnInfoPtr pScrn, int scrnFlag,
- int entityIndex, EntityProc init,
- EntityProc enter, EntityProc leave,
- pointer private);
-
-extern _X_EXPORT Bool xf86IsScreenPrimary(int scrnIndex);
-extern _X_EXPORT int xf86RegisterRootWindowProperty(int ScrnIndex, Atom property, Atom type,
- int format, unsigned long len,
- pointer value);
-extern _X_EXPORT Bool xf86IsUnblank(int mode);
-
-/* xf86Init.c */
-
-extern _X_EXPORT PixmapFormatPtr xf86GetPixFormat(ScrnInfoPtr pScrn, int depth);
-extern _X_EXPORT int xf86GetBppFromDepth(ScrnInfoPtr pScrn, int depth);
-
-/* xf86Mode.c */
-
-extern _X_EXPORT int xf86GetNearestClock(ScrnInfoPtr scrp, int freq, Bool allowDiv2,
- int DivFactor, int MulFactor, int *divider);
-extern _X_EXPORT const char *xf86ModeStatusToString(ModeStatus status);
-extern _X_EXPORT ModeStatus xf86LookupMode(ScrnInfoPtr scrp, DisplayModePtr modep,
- ClockRangePtr clockRanges, LookupModeFlags strategy);
-extern _X_EXPORT ModeStatus xf86CheckModeForMonitor(DisplayModePtr mode, MonPtr monitor);
-extern _X_EXPORT ModeStatus xf86InitialCheckModeForDriver(ScrnInfoPtr scrp, DisplayModePtr mode,
- ClockRangePtr clockRanges,
- LookupModeFlags strategy,
- int maxPitch, int virtualX,
- int virtualY);
-extern _X_EXPORT ModeStatus xf86CheckModeForDriver(ScrnInfoPtr scrp, DisplayModePtr mode,
- int flags);
-extern _X_EXPORT int xf86ValidateModes(ScrnInfoPtr scrp, DisplayModePtr availModes,
- char **modeNames, ClockRangePtr clockRanges,
- int *linePitches, int minPitch, int maxPitch,
- int minHeight, int maxHeight, int pitchInc,
- int virtualX, int virtualY, int apertureSize,
- LookupModeFlags strategy);
-extern _X_EXPORT void xf86DeleteMode(DisplayModePtr *modeList, DisplayModePtr mode);
-extern _X_EXPORT void xf86PruneDriverModes(ScrnInfoPtr scrp);
-extern _X_EXPORT void xf86SetCrtcForModes(ScrnInfoPtr scrp, int adjustFlags);
-extern _X_EXPORT void xf86PrintModes(ScrnInfoPtr scrp);
-extern _X_EXPORT void xf86ShowClockRanges(ScrnInfoPtr scrp, ClockRangePtr clockRanges);
-extern _X_EXPORT double xf86ModeHSync(const DisplayModeRec *mode);
-extern _X_EXPORT double xf86ModeVRefresh(const DisplayModeRec *mode);
-extern _X_EXPORT void xf86SetModeDefaultName(DisplayModePtr mode);
-extern _X_EXPORT void xf86SetModeCrtc(DisplayModePtr p, int adjustFlags);
-extern _X_EXPORT DisplayModePtr xf86DuplicateMode(const DisplayModeRec *pMode);
-extern _X_EXPORT DisplayModePtr xf86DuplicateModes(ScrnInfoPtr pScrn, DisplayModePtr modeList);
-extern _X_EXPORT Bool xf86ModesEqual(const DisplayModeRec *pMode1,
- const DisplayModeRec *pMode2);
-extern _X_EXPORT void xf86PrintModeline(int scrnIndex,DisplayModePtr mode);
-extern _X_EXPORT DisplayModePtr xf86ModesAdd(DisplayModePtr modes, DisplayModePtr new);
-
-/* xf86Option.c */
-
-extern _X_EXPORT void xf86CollectOptions(ScrnInfoPtr pScrn, pointer extraOpts);
-
-
-/* xf86RandR.c */
-#ifdef RANDR
-extern _X_EXPORT Bool xf86RandRInit (ScreenPtr pScreen);
-extern _X_EXPORT Rotation xf86GetRotation(ScreenPtr pScreen);
-extern _X_EXPORT Bool xf86RandRSetNewVirtualAndDimensions(ScreenPtr pScreen,
- int newvirtX, int newvirtY,
- int newmmWidth, int newmmHeight, Bool resetMode);
-#endif
-
-/* xf86VidModeExtentionInit.c */
-
-extern _X_EXPORT Bool VidModeExtensionInit(ScreenPtr pScreen);
-
-#endif /* _NO_XF86_PROTOTYPES */
-
-#endif /* _XF86_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 declarations for public XFree86 functions and variables,
+ * and definitions of public macros.
+ *
+ * "public" means available to video drivers.
+ */
+
+#ifndef _XF86_H
+#define _XF86_H
+
+#if HAVE_XORG_CONFIG_H
+#include <xorg-config.h>
+#elif HAVE_DIX_CONFIG_H
+#include <dix-config.h>
+#endif
+
+#include "xf86str.h"
+#include "xf86Opt.h"
+#include <X11/Xfuncproto.h>
+#include <stdarg.h>
+#ifdef RANDR
+#include <X11/extensions/randr.h>
+#endif
+
+#include "propertyst.h"
+
+/* General parameters */
+extern _X_EXPORT int xf86DoConfigure;
+extern _X_EXPORT int xf86DoShowOptions;
+extern _X_EXPORT Bool xf86DoConfigurePass1;
+
+extern _X_EXPORT DevPrivateKeyRec xf86ScreenKeyRec;
+#define xf86ScreenKey (&xf86ScreenKeyRec)
+
+extern _X_EXPORT DevPrivateKeyRec xf86CreateRootWindowKeyRec;
+#define xf86CreateRootWindowKey (&xf86CreateRootWindowKeyRec)
+
+extern _X_EXPORT ScrnInfoPtr *xf86Screens; /* List of pointers to ScrnInfoRecs */
+extern _X_EXPORT const unsigned char byte_reversed[256];
+extern _X_EXPORT Bool fbSlotClaimed;
+#if (defined(__sparc__) || defined(__sparc)) && !defined(__OpenBSD__)
+extern _X_EXPORT Bool sbusSlotClaimed;
+#endif
+extern _X_EXPORT confDRIRec xf86ConfigDRI;
+extern _X_EXPORT Bool xf86DRI2Enabled(void);
+
+extern _X_EXPORT Bool VTSwitchEnabled; /* kbd driver */
+
+#define XF86SCRNINFO(p) ((ScrnInfoPtr)dixLookupPrivate(&(p)->devPrivates, \
+ xf86ScreenKey))
+#define XF86FLIP_PIXELS() \
+ do { \
+ if (xf86GetFlipPixels()) { \
+ pScreen->whitePixel = (pScreen->whitePixel) ? 0 : 1; \
+ pScreen->blackPixel = (pScreen->blackPixel) ? 0 : 1; \
+ } \
+ while (0)
+
+#define BOOLTOSTRING(b) ((b) ? "TRUE" : "FALSE")
+
+#define PIX24TOBPP(p) (((p) == Pix24Use24) ? 24 : \
+ (((p) == Pix24Use32) ? 32 : 0))
+
+/* Function Prototypes */
+#ifndef _NO_XF86_PROTOTYPES
+
+/* PCI related */
+#include <pciaccess.h>
+extern _X_EXPORT Bool pciSlotClaimed;
+
+extern _X_EXPORT Bool xf86CheckPciSlot(const struct pci_device *);
+extern _X_EXPORT int xf86ClaimPciSlot(struct pci_device *, DriverPtr drvp,
+ int chipset, GDevPtr dev, Bool active);
+extern _X_EXPORT void xf86UnclaimPciSlot(struct pci_device *);
+extern _X_EXPORT Bool xf86ParsePciBusString(const char *busID, int *bus,
+ int *device, int *func);
+extern _X_EXPORT Bool xf86ComparePciBusString(const char *busID, int bus,
+ int device, int func);
+extern _X_EXPORT void xf86FormatPciBusNumber(int busnum, char *buffer);
+extern _X_EXPORT Bool xf86IsPrimaryPci(struct pci_device * pPci);
+extern _X_EXPORT Bool xf86CheckPciMemBase(struct pci_device * pPci,
+ memType base);
+extern _X_EXPORT struct pci_device * xf86GetPciInfoForEntity(int entityIndex);
+extern _X_EXPORT int xf86MatchPciInstances(const char *driverName,
+ int vendorID, SymTabPtr chipsets, PciChipsets *PCIchipsets,
+ GDevPtr *devList, int numDevs, DriverPtr drvp, int **foundEntities);
+extern _X_EXPORT ScrnInfoPtr xf86ConfigPciEntity(ScrnInfoPtr pScrn,
+ int scrnFlag, int entityIndex,PciChipsets *p_chip, void *dummy,
+ EntityProc init, EntityProc enter, EntityProc leave, pointer private);
+/* Obsolete! don't use */
+extern _X_EXPORT Bool xf86ConfigActivePciEntity(ScrnInfoPtr pScrn,
+ int entityIndex,PciChipsets *p_chip, void *dummy, EntityProc init,
+ EntityProc enter, EntityProc leave, pointer private);
+
+/* xf86Bus.c */
+
+extern _X_EXPORT int xf86GetFbInfoForScreen(int scrnIndex);
+extern _X_EXPORT int xf86ClaimFbSlot(DriverPtr drvp, int chipset, GDevPtr dev, Bool active);
+extern _X_EXPORT int xf86ClaimNoSlot(DriverPtr drvp, int chipset, GDevPtr dev, Bool active);
+extern _X_EXPORT Bool xf86DriverHasEntities(DriverPtr drvp);
+extern _X_EXPORT void xf86AddEntityToScreen(ScrnInfoPtr pScrn, int entityIndex);
+extern _X_EXPORT void xf86SetEntityInstanceForScreen(ScrnInfoPtr pScrn, int entityIndex,
+ int instance);
+extern _X_EXPORT int xf86GetNumEntityInstances(int entityIndex);
+extern _X_EXPORT GDevPtr xf86GetDevFromEntity(int entityIndex, int instance);
+extern _X_EXPORT void xf86RemoveEntityFromScreen(ScrnInfoPtr pScrn, int entityIndex);
+extern _X_EXPORT EntityInfoPtr xf86GetEntityInfo(int entityIndex);
+extern _X_EXPORT Bool xf86SetEntityFuncs(int entityIndex, EntityProc init,
+ EntityProc enter, EntityProc leave, pointer);
+extern _X_EXPORT Bool xf86IsEntityPrimary(int entityIndex);
+extern _X_EXPORT ScrnInfoPtr xf86FindScreenForEntity(int entityIndex);
+
+extern _X_EXPORT int xf86GetLastScrnFlag(int entityIndex);
+extern _X_EXPORT void xf86SetLastScrnFlag(int entityIndex, int scrnIndex);
+extern _X_EXPORT Bool xf86IsEntityShared(int entityIndex);
+extern _X_EXPORT void xf86SetEntityShared(int entityIndex);
+extern _X_EXPORT Bool xf86IsEntitySharable(int entityIndex);
+extern _X_EXPORT void xf86SetEntitySharable(int entityIndex);
+extern _X_EXPORT Bool xf86IsPrimInitDone(int entityIndex);
+extern _X_EXPORT void xf86SetPrimInitDone(int entityIndex);
+extern _X_EXPORT void xf86ClearPrimInitDone(int entityIndex);
+extern _X_EXPORT int xf86AllocateEntityPrivateIndex(void);
+extern _X_EXPORT DevUnion *xf86GetEntityPrivate(int entityIndex, int privIndex);
+
+/* xf86Configure.c */
+extern _X_EXPORT GDevPtr xf86AddBusDeviceToConfigure(const char *driver, BusType bus,
+ void *busData, int chipset);
+
+/* xf86Cursor.c */
+
+extern _X_EXPORT void xf86LockZoom(ScreenPtr pScreen, int lock);
+extern _X_EXPORT void xf86InitViewport(ScrnInfoPtr pScr);
+extern _X_EXPORT void xf86SetViewport(ScreenPtr pScreen, int x, int y);
+extern _X_EXPORT void xf86ZoomViewport(ScreenPtr pScreen, int zoom);
+extern _X_EXPORT Bool xf86SwitchMode(ScreenPtr pScreen, DisplayModePtr mode);
+extern _X_EXPORT void *xf86GetPointerScreenFuncs(void);
+extern _X_EXPORT void xf86InitOrigins(void);
+extern _X_EXPORT void xf86ReconfigureLayout(void);
+
+/* xf86cvt.c */
+extern _X_EXPORT DisplayModePtr xf86CVTMode(int HDisplay, int VDisplay, float VRefresh,
+ Bool Reduced, Bool Interlaced);
+
+/* xf86DPMS.c */
+
+extern _X_EXPORT Bool xf86DPMSInit(ScreenPtr pScreen, DPMSSetProcPtr set, int flags);
+
+#ifdef DPMSExtension
+extern _X_EXPORT int DPMSSet(ClientPtr client, int level);
+extern _X_EXPORT Bool DPMSSupported(void);
+#endif
+
+
+/* xf86DGA.c */
+
+#ifdef XFreeXDGA
+extern _X_EXPORT Bool DGAInit(ScreenPtr pScreen, DGAFunctionPtr funcs, DGAModePtr modes,
+ int num);
+extern _X_EXPORT Bool DGAReInitModes(ScreenPtr pScreen, DGAModePtr modes, int num);
+extern _X_EXPORT xf86SetDGAModeProc xf86SetDGAMode;
+#endif
+
+/* xf86Events.c */
+
+extern _X_EXPORT void SetTimeSinceLastInputEvent(void);
+extern _X_EXPORT pointer xf86AddInputHandler(int fd, InputHandlerProc proc, pointer data);
+extern _X_EXPORT int xf86RemoveInputHandler(pointer handler);
+extern _X_EXPORT void xf86DisableInputHandler(pointer handler);
+extern _X_EXPORT void xf86EnableInputHandler(pointer handler);
+extern _X_EXPORT pointer xf86AddGeneralHandler(int fd, InputHandlerProc proc, pointer data);
+extern _X_EXPORT int xf86RemoveGeneralHandler(pointer handler);
+extern _X_EXPORT void xf86DisableGeneralHandler(pointer handler);
+extern _X_EXPORT void xf86EnableGeneralHandler(pointer handler);
+extern _X_EXPORT InputHandlerProc xf86SetConsoleHandler(InputHandlerProc handler, pointer data);
+extern _X_EXPORT void xf86InterceptSignals(int *signo);
+extern _X_EXPORT void xf86InterceptSigIll(void (*sigillhandler)(void));
+extern _X_EXPORT Bool xf86EnableVTSwitch(Bool new);
+extern _X_EXPORT void xf86ProcessActionEvent(ActionEvent action, void *arg);
+extern _X_EXPORT void xf86PrintBacktrace(void);
+
+/* xf86Helper.c */
+
+extern _X_EXPORT void xf86AddDriver(DriverPtr driver, pointer module, int flags);
+extern _X_EXPORT void xf86DeleteDriver(int drvIndex);
+extern _X_EXPORT ScrnInfoPtr xf86AllocateScreen(DriverPtr drv, int flags);
+extern _X_EXPORT void xf86DeleteScreen(int scrnIndex, int flags);
+extern _X_EXPORT int xf86AllocateScrnInfoPrivateIndex(void);
+extern _X_EXPORT Bool xf86AddPixFormat(ScrnInfoPtr pScrn, int depth, int bpp, int pad);
+extern _X_EXPORT Bool xf86SetDepthBpp(ScrnInfoPtr scrp, int depth, int bpp, int fbbpp,
+ int depth24flags);
+extern _X_EXPORT void xf86PrintDepthBpp(ScrnInfoPtr scrp);
+extern _X_EXPORT Bool xf86SetWeight(ScrnInfoPtr scrp, rgb weight, rgb mask);
+extern _X_EXPORT Bool xf86SetDefaultVisual(ScrnInfoPtr scrp, int visual);
+extern _X_EXPORT Bool xf86SetGamma(ScrnInfoPtr scrp, Gamma newGamma);
+extern _X_EXPORT void xf86SetDpi(ScrnInfoPtr pScrn, int x, int y);
+extern _X_EXPORT void xf86SetBlackWhitePixels(ScreenPtr pScreen);
+extern _X_EXPORT void xf86EnableDisableFBAccess(int scrnIndex, Bool enable);
+extern _X_EXPORT void xf86VDrvMsgVerb(int scrnIndex, MessageType type, int verb,
+ const char *format, va_list args);
+extern _X_EXPORT void xf86DrvMsgVerb(int scrnIndex, MessageType type, int verb,
+ const char *format, ...) _X_ATTRIBUTE_PRINTF(4,5);
+extern _X_EXPORT void xf86DrvMsg(int scrnIndex, MessageType type, const char *format, ...)
+ _X_ATTRIBUTE_PRINTF(3,4);
+extern _X_EXPORT void xf86MsgVerb(MessageType type, int verb, const char *format, ...)
+ _X_ATTRIBUTE_PRINTF(3,4);
+extern _X_EXPORT void xf86Msg(MessageType type, const char *format, ...) _X_ATTRIBUTE_PRINTF(2,3);
+extern _X_EXPORT void xf86ErrorFVerb(int verb, const char *format, ...) _X_ATTRIBUTE_PRINTF(2,3);
+extern _X_EXPORT void xf86ErrorF(const char *format, ...) _X_ATTRIBUTE_PRINTF(1,2);
+extern _X_EXPORT const char *xf86TokenToString(SymTabPtr table, int token);
+extern _X_EXPORT int xf86StringToToken(SymTabPtr table, const char *string);
+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);
+extern _X_EXPORT int xf86GetDepth(void);
+extern _X_EXPORT rgb xf86GetWeight(void);
+extern _X_EXPORT Gamma xf86GetGamma(void);
+extern _X_EXPORT Bool xf86GetFlipPixels(void);
+extern _X_EXPORT const char *xf86GetServerName(void);
+extern _X_EXPORT Bool xf86ServerIsExiting(void);
+extern _X_EXPORT Bool xf86ServerIsResetting(void);
+extern _X_EXPORT Bool xf86ServerIsInitialising(void);
+extern _X_EXPORT Bool xf86ServerIsOnlyDetecting(void);
+extern _X_EXPORT Bool xf86CaughtSignal(void);
+extern _X_EXPORT Bool xf86GetVidModeAllowNonLocal(void);
+extern _X_EXPORT Bool xf86GetVidModeEnabled(void);
+extern _X_EXPORT Bool xf86GetModInDevAllowNonLocal(void);
+extern _X_EXPORT Bool xf86GetModInDevEnabled(void);
+extern _X_EXPORT Bool xf86GetAllowMouseOpenFail(void);
+extern _X_EXPORT Bool xf86IsPc98(void);
+extern _X_EXPORT void xf86DisableRandR(void);
+extern _X_EXPORT CARD32 xorgGetVersion(void);
+extern _X_EXPORT CARD32 xf86GetModuleVersion(pointer module);
+extern _X_EXPORT pointer xf86LoadDrvSubModule(DriverPtr drv, const char *name);
+extern _X_EXPORT pointer xf86LoadSubModule(ScrnInfoPtr pScrn, const char *name);
+extern _X_EXPORT pointer xf86LoadOneModule(char *name, pointer optlist);
+extern _X_EXPORT void xf86UnloadSubModule(pointer mod);
+extern _X_EXPORT Bool xf86LoaderCheckSymbol(const char *name);
+extern _X_EXPORT void xf86SetBackingStore(ScreenPtr pScreen);
+extern _X_EXPORT void xf86SetSilkenMouse(ScreenPtr pScreen);
+extern _X_EXPORT pointer xf86FindXvOptions(int scrnIndex, int adapt_index, char *port_name,
+ char **adaptor_name, pointer *adaptor_options);
+extern _X_EXPORT void xf86GetOS(const char **name, int *major, int *minor, int *teeny);
+extern _X_EXPORT ScrnInfoPtr xf86ConfigFbEntity(ScrnInfoPtr pScrn, int scrnFlag,
+ int entityIndex, EntityProc init,
+ EntityProc enter, EntityProc leave,
+ pointer private);
+
+extern _X_EXPORT Bool xf86IsScreenPrimary(int scrnIndex);
+extern _X_EXPORT int xf86RegisterRootWindowProperty(int ScrnIndex, Atom property, Atom type,
+ int format, unsigned long len,
+ pointer value);
+extern _X_EXPORT Bool xf86IsUnblank(int mode);
+
+/* xf86Init.c */
+
+extern _X_EXPORT PixmapFormatPtr xf86GetPixFormat(ScrnInfoPtr pScrn, int depth);
+extern _X_EXPORT int xf86GetBppFromDepth(ScrnInfoPtr pScrn, int depth);
+
+/* xf86Mode.c */
+
+extern _X_EXPORT int xf86GetNearestClock(ScrnInfoPtr scrp, int freq, Bool allowDiv2,
+ int DivFactor, int MulFactor, int *divider);
+extern _X_EXPORT const char *xf86ModeStatusToString(ModeStatus status);
+extern _X_EXPORT ModeStatus xf86LookupMode(ScrnInfoPtr scrp, DisplayModePtr modep,
+ ClockRangePtr clockRanges, LookupModeFlags strategy);
+extern _X_EXPORT ModeStatus xf86CheckModeForMonitor(DisplayModePtr mode, MonPtr monitor);
+extern _X_EXPORT ModeStatus xf86InitialCheckModeForDriver(ScrnInfoPtr scrp, DisplayModePtr mode,
+ ClockRangePtr clockRanges,
+ LookupModeFlags strategy,
+ int maxPitch, int virtualX,
+ int virtualY);
+extern _X_EXPORT ModeStatus xf86CheckModeForDriver(ScrnInfoPtr scrp, DisplayModePtr mode,
+ int flags);
+extern _X_EXPORT int xf86ValidateModes(ScrnInfoPtr scrp, DisplayModePtr availModes,
+ char **modeNames, ClockRangePtr clockRanges,
+ int *linePitches, int minPitch, int maxPitch,
+ int minHeight, int maxHeight, int pitchInc,
+ int virtualX, int virtualY, int apertureSize,
+ LookupModeFlags strategy);
+extern _X_EXPORT void xf86DeleteMode(DisplayModePtr *modeList, DisplayModePtr mode);
+extern _X_EXPORT void xf86PruneDriverModes(ScrnInfoPtr scrp);
+extern _X_EXPORT void xf86SetCrtcForModes(ScrnInfoPtr scrp, int adjustFlags);
+extern _X_EXPORT void xf86PrintModes(ScrnInfoPtr scrp);
+extern _X_EXPORT void xf86ShowClockRanges(ScrnInfoPtr scrp, ClockRangePtr clockRanges);
+extern _X_EXPORT double xf86ModeHSync(const DisplayModeRec *mode);
+extern _X_EXPORT double xf86ModeVRefresh(const DisplayModeRec *mode);
+extern _X_EXPORT void xf86SetModeDefaultName(DisplayModePtr mode);
+extern _X_EXPORT void xf86SetModeCrtc(DisplayModePtr p, int adjustFlags);
+extern _X_EXPORT DisplayModePtr xf86DuplicateMode(const DisplayModeRec *pMode);
+extern _X_EXPORT DisplayModePtr xf86DuplicateModes(ScrnInfoPtr pScrn, DisplayModePtr modeList);
+extern _X_EXPORT Bool xf86ModesEqual(const DisplayModeRec *pMode1,
+ const DisplayModeRec *pMode2);
+extern _X_EXPORT void xf86PrintModeline(int scrnIndex,DisplayModePtr mode);
+extern _X_EXPORT DisplayModePtr xf86ModesAdd(DisplayModePtr modes, DisplayModePtr new);
+
+/* xf86Option.c */
+
+extern _X_EXPORT void xf86CollectOptions(ScrnInfoPtr pScrn, pointer extraOpts);
+
+
+/* xf86RandR.c */
+#ifdef RANDR
+extern _X_EXPORT Bool xf86RandRInit (ScreenPtr pScreen);
+extern _X_EXPORT Rotation xf86GetRotation(ScreenPtr pScreen);
+extern _X_EXPORT Bool xf86RandRSetNewVirtualAndDimensions(ScreenPtr pScreen,
+ int newvirtX, int newvirtY,
+ int newmmWidth, int newmmHeight, Bool resetMode);
+#endif
+
+/* xf86VidModeExtentionInit.c */
+
+extern _X_EXPORT Bool VidModeExtensionInit(ScreenPtr pScreen);
+
+#endif /* _NO_XF86_PROTOTYPES */
+
+#endif /* _XF86_H */
diff --git a/xorg-server/hw/xfree86/common/xf86Bus.c b/xorg-server/hw/xfree86/common/xf86Bus.c
index bec2343b2..3b0896863 100644
--- a/xorg-server/hw/xfree86/common/xf86Bus.c
+++ b/xorg-server/hw/xfree86/common/xf86Bus.c
@@ -1,671 +1,636 @@
-/*
- * 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 "os.h"
-#include "xf86.h"
-#include "xf86Priv.h"
-
-/* Bus-specific headers */
-
-#include "xf86Bus.h"
-
-#define XF86_OS_PRIVS
-#include "xf86_OSproc.h"
-#include "xf86VGAarbiter.h"
-
-/* Entity data */
-EntityPtr *xf86Entities = NULL; /* Bus slots claimed by drivers */
-int xf86NumEntities = 0;
-static int xf86EntityPrivateCount = 0;
-
-BusRec primaryBus = { BUS_NONE, { 0 } };
-
-/**
- * Call the driver's correct probe function.
- *
- * If the driver implements the \c DriverRec::PciProbe entry-point and an
- * appropriate PCI device (with matching Device section in the xorg.conf file)
- * is found, it is called. If \c DriverRec::PciProbe or no devices can be
- * successfully probed with it (e.g., only non-PCI devices are available),
- * the driver's \c DriverRec::Probe function is called.
- *
- * \param drv Driver to probe
- *
- * \return
- * If a device can be successfully probed by the driver, \c TRUE is
- * returned. Otherwise, \c FALSE is returned.
- */
-Bool
-xf86CallDriverProbe( DriverPtr drv, Bool detect_only )
-{
- Bool foundScreen = FALSE;
-
- if (drv->PciProbe != NULL) {
- if (xf86DoConfigure && xf86DoConfigurePass1) {
- assert(detect_only);
- foundScreen = xf86PciAddMatchingDev(drv);
- }
- else {
- assert(! detect_only);
- foundScreen = xf86PciProbeDev(drv);
- }
- }
-
- if (!foundScreen && (drv->Probe != NULL)) {
- xf86Msg( X_WARNING, "Falling back to old probe method for %s\n",
- drv->driverName);
- foundScreen = (*drv->Probe)(drv, (detect_only) ? PROBE_DETECT
- : PROBE_DEFAULT);
- }
-
- return foundScreen;
-}
-
-/**
- * @return TRUE if all buses are configured and set up correctly and FALSE
- * otherwise.
- */
-Bool
-xf86BusConfig(void)
-{
- screenLayoutPtr layout;
- int i, j;
-
- /* Enable full I/O access */
- if (xorgHWAccess)
- xorgHWAccess = xf86EnableIO();
-
- /*
- * Now call each of the Probe functions. Each successful probe will
- * result in an extra entry added to the xf86Screens[] list for each
- * instance of the hardware found.
- */
- for (i = 0; i < xf86NumDrivers; i++) {
- xorgHWFlags flags;
- if (!xorgHWAccess) {
- if (!xf86DriverList[i]->driverFunc
- || !xf86DriverList[i]->driverFunc(NULL,
- GET_REQUIRED_HW_INTERFACES,
- &flags)
- || NEED_IO_ENABLED(flags))
- continue;
- }
-
- xf86CallDriverProbe(xf86DriverList[i], FALSE);
- }
-
- /* If nothing was detected, return now */
- if (xf86NumScreens == 0) {
- xf86Msg(X_ERROR, "No devices detected.\n");
- return FALSE;
- }
-
- xf86VGAarbiterInit();
-
- /*
- * Match up the screens found by the probes against those specified
- * in the config file. Remove the ones that won't be used. Sort
- * them in the order specified.
- *
- * What is the best way to do this?
- *
- * For now, go through the screens allocated by the probes, and
- * look for screen config entry which refers to the same device
- * section as picked out by the probe.
- *
- */
- for (i = 0; i < xf86NumScreens; i++) {
- for (layout = xf86ConfigLayout.screens; layout->screen != NULL;
- layout++) {
- Bool found = FALSE;
- for (j = 0; j < xf86Screens[i]->numEntities; j++) {
-
- GDevPtr dev = xf86GetDevFromEntity(
- xf86Screens[i]->entityList[j],
- xf86Screens[i]->entityInstanceList[j]);
- if (dev == layout->screen->device) {
- /* A match has been found */
- xf86Screens[i]->confScreen = layout->screen;
- found = TRUE;
- break;
- }
- }
- if (found) break;
- }
- if (layout->screen == NULL) {
- /* No match found */
- xf86Msg(X_ERROR,
- "Screen %d deleted because of no matching config section.\n", i);
- xf86DeleteScreen(i--, 0);
- }
- }
-
- /* If no screens left, return now. */
- if (xf86NumScreens == 0) {
- xf86Msg(X_ERROR,
- "Device(s) detected, but none match those in the config file.\n");
- return FALSE;
- }
-
- return TRUE;
-}
-
-/*
- * Call the bus probes relevant to the architecture.
- *
- * The only one available so far is for PCI and SBUS.
- */
-
-void
-xf86BusProbe(void)
-{
- xf86PciProbe();
-#if (defined(__sparc__) || defined(__sparc)) && !defined(__OpenBSD__)
- xf86SbusProbe();
-#endif
-}
-
-/*
- * Determine what bus type the busID string represents. The start of the
- * bus-dependent part of the string is returned as retID.
- */
-
-BusType
-StringToBusType(const char* busID, const char **retID)
-{
- char *p, *s;
- BusType ret = BUS_NONE;
-
- /* If no type field, Default to PCI */
- if (isdigit(busID[0])) {
- if (retID)
- *retID = busID;
- return BUS_PCI;
- }
-
- s = xstrdup(busID);
- p = strtok(s, ":");
- if (p == NULL || *p == 0) {
- free(s);
- return BUS_NONE;
- }
- if (!xf86NameCmp(p, "pci") || !xf86NameCmp(p, "agp"))
- ret = BUS_PCI;
- if (!xf86NameCmp(p, "sbus"))
- ret = BUS_SBUS;
- if (ret != BUS_NONE)
- if (retID)
- *retID = busID + strlen(p) + 1;
- free(s);
- return ret;
-}
-
-int
-xf86AllocateEntity(void)
-{
- xf86NumEntities++;
- xf86Entities = xnfrealloc(xf86Entities,
- sizeof(EntityPtr) * xf86NumEntities);
- xf86Entities[xf86NumEntities - 1] = xnfcalloc(1,sizeof(EntityRec));
- xf86Entities[xf86NumEntities - 1]->entityPrivates =
- xnfcalloc(sizeof(DevUnion) * xf86EntityPrivateCount, 1);
- return xf86NumEntities - 1;
-}
-
-Bool
-xf86IsEntityPrimary(int entityIndex)
-{
- EntityPtr pEnt = xf86Entities[entityIndex];
-
- if (primaryBus.type != pEnt->bus.type) return FALSE;
-
- switch (pEnt->bus.type) {
- case BUS_PCI:
- return pEnt->bus.id.pci == primaryBus.id.pci;
- case BUS_SBUS:
- return pEnt->bus.id.sbus.fbNum == primaryBus.id.sbus.fbNum;
- default:
- return FALSE;
- }
-}
-
-Bool
-xf86SetEntityFuncs(int entityIndex, EntityProc init, EntityProc enter,
- EntityProc leave, pointer private)
-{
- if (entityIndex >= xf86NumEntities)
- return FALSE;
- xf86Entities[entityIndex]->entityInit = init;
- xf86Entities[entityIndex]->entityEnter = enter;
- xf86Entities[entityIndex]->entityLeave = leave;
- xf86Entities[entityIndex]->private = private;
- return TRUE;
-}
-
-Bool
-xf86DriverHasEntities(DriverPtr drvp)
-{
- int i;
- for (i = 0; i < xf86NumEntities; i++) {
- if (xf86Entities[i]->driver == drvp)
- return TRUE;
- }
- return FALSE;
-}
-
-void
-xf86AddEntityToScreen(ScrnInfoPtr pScrn, int entityIndex)
-{
- if (entityIndex == -1)
- return;
- if (xf86Entities[entityIndex]->inUse &&
- !(xf86Entities[entityIndex]->entityProp & IS_SHARED_ACCEL)) {
- ErrorF("Requested Entity already in use!\n");
- return;
- }
-
- pScrn->numEntities++;
- pScrn->entityList = xnfrealloc(pScrn->entityList,
- pScrn->numEntities * sizeof(int));
- pScrn->entityList[pScrn->numEntities - 1] = entityIndex;
- xf86Entities[entityIndex]->inUse = TRUE;
- pScrn->entityInstanceList = xnfrealloc(pScrn->entityInstanceList,
- pScrn->numEntities * sizeof(int));
- pScrn->entityInstanceList[pScrn->numEntities - 1] = 0;
- pScrn->domainIOBase = xf86Entities[entityIndex]->domainIO;
-}
-
-void
-xf86SetEntityInstanceForScreen(ScrnInfoPtr pScrn, int entityIndex, int instance)
-{
- int i;
-
- if (entityIndex == -1 || entityIndex >= xf86NumEntities)
- return;
-
- for (i = 0; i < pScrn->numEntities; i++) {
- if (pScrn->entityList[i] == entityIndex) {
- pScrn->entityInstanceList[i] = instance;
- break;
- }
- }
-}
-
-/*
- * XXX This needs to be updated for the case where a single entity may have
- * instances associated with more than one screen.
- */
-ScrnInfoPtr
-xf86FindScreenForEntity(int entityIndex)
-{
- int i,j;
-
- if (entityIndex == -1) return NULL;
-
- if (xf86Screens) {
- for (i = 0; i < xf86NumScreens; i++) {
- for (j = 0; j < xf86Screens[i]->numEntities; j++) {
- if ( xf86Screens[i]->entityList[j] == entityIndex )
- return xf86Screens[i];
- }
- }
- }
- return NULL;
-}
-
-void
-xf86RemoveEntityFromScreen(ScrnInfoPtr pScrn, int entityIndex)
-{
- int i;
-
- for (i = 0; i < pScrn->numEntities; i++) {
- if (pScrn->entityList[i] == entityIndex) {
- for (i++; i < pScrn->numEntities; i++)
- pScrn->entityList[i-1] = pScrn->entityList[i];
- pScrn->numEntities--;
- xf86Entities[entityIndex]->inUse = FALSE;
- break;
- }
- }
-}
-
-/*
- * xf86ClearEntitiesForScreen() - called when a screen is deleted
- * to mark it's entities unused. Called by xf86DeleteScreen().
- */
-void
-xf86ClearEntityListForScreen(int scrnIndex)
-{
- ScrnInfoPtr pScrn = xf86Screens[scrnIndex];
- int i, entityIndex;
-
- if (pScrn->entityList == NULL || pScrn->numEntities == 0) return;
-
- for (i = 0; i < pScrn->numEntities; i++) {
- entityIndex = pScrn->entityList[i];
- xf86Entities[entityIndex]->inUse = FALSE;
- /* disable resource: call the disable function */
- }
- free(pScrn->entityList);
- free(pScrn->entityInstanceList);
- pScrn->entityList = NULL;
- pScrn->entityInstanceList = NULL;
-}
-
-/*
- * Add an extra device section (GDevPtr) to an entity.
- */
-
-void
-xf86AddDevToEntity(int entityIndex, GDevPtr dev)
-{
- EntityPtr pEnt;
-
- if (entityIndex >= xf86NumEntities)
- return;
-
- pEnt = xf86Entities[entityIndex];
- pEnt->numInstances++;
- pEnt->devices = xnfrealloc(pEnt->devices,
- pEnt->numInstances * sizeof(GDevPtr));
- pEnt->devices[pEnt->numInstances - 1] = dev;
- dev->claimed = TRUE;
-}
-
-/*
- * xf86GetEntityInfo() -- This function hands information from the
- * EntityRec struct to the drivers. The EntityRec structure itself
- * remains invisible to the driver.
- */
-EntityInfoPtr
-xf86GetEntityInfo(int entityIndex)
-{
- EntityInfoPtr pEnt;
- int i;
-
- if (entityIndex == -1)
- return NULL;
-
- if (entityIndex >= xf86NumEntities)
- return NULL;
-
- pEnt = xnfcalloc(1,sizeof(EntityInfoRec));
- pEnt->index = entityIndex;
- pEnt->location = xf86Entities[entityIndex]->bus;
- pEnt->active = xf86Entities[entityIndex]->active;
- pEnt->chipset = xf86Entities[entityIndex]->chipset;
- pEnt->driver = xf86Entities[entityIndex]->driver;
- if ( (xf86Entities[entityIndex]->devices) &&
- (xf86Entities[entityIndex]->devices[0]) ) {
- for (i = 0; i < xf86Entities[entityIndex]->numInstances; i++)
- if (xf86Entities[entityIndex]->devices[i]->screen == 0)
- break;
- pEnt->device = xf86Entities[entityIndex]->devices[i];
- } else
- pEnt->device = NULL;
-
- return pEnt;
-}
-
-int
-xf86GetNumEntityInstances(int entityIndex)
-{
- if (entityIndex >= xf86NumEntities)
- return -1;
-
- return xf86Entities[entityIndex]->numInstances;
-}
-
-GDevPtr
-xf86GetDevFromEntity(int entityIndex, int instance)
-{
- int i;
-
- /* We might not use AddDevtoEntity */
- if ( (!xf86Entities[entityIndex]->devices) ||
- (!xf86Entities[entityIndex]->devices[0]) )
- return NULL;
-
- if (entityIndex >= xf86NumEntities ||
- instance >= xf86Entities[entityIndex]->numInstances)
- return NULL;
-
- for (i = 0; i < xf86Entities[entityIndex]->numInstances; i++)
- if (xf86Entities[entityIndex]->devices[i]->screen == instance)
- break;
- return xf86Entities[entityIndex]->devices[i];
-}
-
-/*
- * xf86AccessEnter() -- gets called to save the text mode VGA IO
- * resources when reentering the server after a VT switch.
- */
-void
-xf86AccessEnter(void)
-{
- int i;
-
- for (i = 0; i < xf86NumEntities; i++)
- if (xf86Entities[i]->entityEnter)
- xf86Entities[i]->entityEnter(i,xf86Entities[i]->private);
-
- xf86EnterServerState(SETUP);
-}
-
-void
-xf86AccessLeave(void)
-{
- int i;
-
- for (i = 0; i < xf86NumEntities; i++)
- if (xf86Entities[i]->entityLeave)
- xf86Entities[i]->entityLeave(i,xf86Entities[i]->private);
-}
-
-/*
- * xf86EnterServerState() -- set state the server is in.
- */
-
-typedef enum { TRI_UNSET, TRI_TRUE, TRI_FALSE } TriState;
-
-void
-xf86EnterServerState(xf86State state)
-{
- static int sigio_state;
- static TriState sigio_blocked = TRI_UNSET;
-
- /*
- * This is a good place to block SIGIO during SETUP state. SIGIO should be
- * blocked in SETUP state otherwise (u)sleep() might get interrupted
- * early. We take care not to call xf86BlockSIGIO() twice.
- */
- if ((state == SETUP) && (sigio_blocked != TRI_TRUE)) {
- sigio_state = xf86BlockSIGIO();
- sigio_blocked = TRI_TRUE;
- } else if ((state == OPERATING) && (sigio_blocked != TRI_UNSET)) {
- xf86UnblockSIGIO(sigio_state);
- sigio_blocked = TRI_FALSE;
- }
-}
-
-/*
- * xf86PostProbe() -- Allocate all non conflicting resources
- * This function gets called by xf86Init().
- */
-void
-xf86PostProbe(void)
-{
- int i;
-
- if (fbSlotClaimed && (pciSlotClaimed
-#if (defined(__sparc__) || defined(__sparc)) && !defined(__OpenBSD__)
- || sbusSlotClaimed
-#endif
- ))
- FatalError("Cannot run in framebuffer mode. Please specify busIDs "
- " for all framebuffer devices\n");
-
- for (i = 0; i < xf86NumEntities; i++)
- if (xf86Entities[i]->entityInit)
- xf86Entities[i]->entityInit(i,xf86Entities[i]->private);
-}
-
-void
-xf86PostScreenInit(void)
-{
- xf86VGAarbiterWrapFunctions();
- xf86EnterServerState(OPERATING);
-}
-
-int
-xf86GetLastScrnFlag(int entityIndex)
-{
- if(entityIndex < xf86NumEntities) {
- return xf86Entities[entityIndex]->lastScrnFlag;
- } else {
- return -1;
- }
-}
-
-void
-xf86SetLastScrnFlag(int entityIndex, int scrnIndex)
-{
- if(entityIndex < xf86NumEntities) {
- xf86Entities[entityIndex]->lastScrnFlag = scrnIndex;
- }
-}
-
-Bool
-xf86IsEntityShared(int entityIndex)
-{
- if(entityIndex < xf86NumEntities) {
- if(xf86Entities[entityIndex]->entityProp & IS_SHARED_ACCEL) {
- return TRUE;
- }
- }
- return FALSE;
-}
-
-void
-xf86SetEntityShared(int entityIndex)
-{
- if(entityIndex < xf86NumEntities) {
- xf86Entities[entityIndex]->entityProp |= IS_SHARED_ACCEL;
- }
-}
-
-Bool
-xf86IsEntitySharable(int entityIndex)
-{
- if(entityIndex < xf86NumEntities) {
- if(xf86Entities[entityIndex]->entityProp & ACCEL_IS_SHARABLE) {
- return TRUE;
- }
- }
- return FALSE;
-}
-
-void
-xf86SetEntitySharable(int entityIndex)
-{
- if(entityIndex < xf86NumEntities) {
- xf86Entities[entityIndex]->entityProp |= ACCEL_IS_SHARABLE;
- }
-}
-
-Bool
-xf86IsPrimInitDone(int entityIndex)
-{
- if(entityIndex < xf86NumEntities) {
- if(xf86Entities[entityIndex]->entityProp & SA_PRIM_INIT_DONE) {
- return TRUE;
- }
- }
- return FALSE;
-}
-
-void
-xf86SetPrimInitDone(int entityIndex)
-{
- if(entityIndex < xf86NumEntities) {
- xf86Entities[entityIndex]->entityProp |= SA_PRIM_INIT_DONE;
- }
-}
-
-void
-xf86ClearPrimInitDone(int entityIndex)
-{
- if(entityIndex < xf86NumEntities) {
- xf86Entities[entityIndex]->entityProp &= ~SA_PRIM_INIT_DONE;
- }
-}
-
-
-/*
- * Allocate a private in the entities.
- */
-
-int
-xf86AllocateEntityPrivateIndex(void)
-{
- int idx, i;
- EntityPtr pEnt;
- DevUnion *nprivs;
-
- idx = xf86EntityPrivateCount++;
- for (i = 0; i < xf86NumEntities; i++) {
- pEnt = xf86Entities[i];
- nprivs = xnfrealloc(pEnt->entityPrivates,
- xf86EntityPrivateCount * sizeof(DevUnion));
- /* Zero the new private */
- memset(&nprivs[idx], 0, sizeof(DevUnion));
- pEnt->entityPrivates = nprivs;
- }
- return idx;
-}
-
-DevUnion *
-xf86GetEntityPrivate(int entityIndex, int privIndex)
-{
- if (entityIndex >= xf86NumEntities || privIndex >= xf86EntityPrivateCount)
- return NULL;
-
- return &(xf86Entities[entityIndex]->entityPrivates[privIndex]);
-}
-
+/*
+ * 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 "os.h"
+#include "xf86.h"
+#include "xf86Priv.h"
+
+/* Bus-specific headers */
+
+#include "xf86Bus.h"
+
+#define XF86_OS_PRIVS
+#include "xf86_OSproc.h"
+#include "xf86VGAarbiter.h"
+
+/* Entity data */
+EntityPtr *xf86Entities = NULL; /* Bus slots claimed by drivers */
+int xf86NumEntities = 0;
+static int xf86EntityPrivateCount = 0;
+
+BusRec primaryBus = { BUS_NONE, { 0 } };
+
+/**
+ * Call the driver's correct probe function.
+ *
+ * If the driver implements the \c DriverRec::PciProbe entry-point and an
+ * appropriate PCI device (with matching Device section in the xorg.conf file)
+ * is found, it is called. If \c DriverRec::PciProbe or no devices can be
+ * successfully probed with it (e.g., only non-PCI devices are available),
+ * the driver's \c DriverRec::Probe function is called.
+ *
+ * \param drv Driver to probe
+ *
+ * \return
+ * If a device can be successfully probed by the driver, \c TRUE is
+ * returned. Otherwise, \c FALSE is returned.
+ */
+Bool
+xf86CallDriverProbe( DriverPtr drv, Bool detect_only )
+{
+ Bool foundScreen = FALSE;
+
+ if (drv->PciProbe != NULL) {
+ if (xf86DoConfigure && xf86DoConfigurePass1) {
+ assert(detect_only);
+ foundScreen = xf86PciAddMatchingDev(drv);
+ }
+ else {
+ assert(! detect_only);
+ foundScreen = xf86PciProbeDev(drv);
+ }
+ }
+
+ if (!foundScreen && (drv->Probe != NULL)) {
+ xf86Msg( X_WARNING, "Falling back to old probe method for %s\n",
+ drv->driverName);
+ foundScreen = (*drv->Probe)(drv, (detect_only) ? PROBE_DETECT
+ : PROBE_DEFAULT);
+ }
+
+ return foundScreen;
+}
+
+/**
+ * @return TRUE if all buses are configured and set up correctly and FALSE
+ * otherwise.
+ */
+Bool
+xf86BusConfig(void)
+{
+ screenLayoutPtr layout;
+ int i, j;
+
+ /* Enable full I/O access */
+ if (xorgHWAccess)
+ xorgHWAccess = xf86EnableIO();
+
+ /*
+ * Now call each of the Probe functions. Each successful probe will
+ * result in an extra entry added to the xf86Screens[] list for each
+ * instance of the hardware found.
+ */
+ for (i = 0; i < xf86NumDrivers; i++) {
+ xorgHWFlags flags;
+ if (!xorgHWAccess) {
+ if (!xf86DriverList[i]->driverFunc
+ || !xf86DriverList[i]->driverFunc(NULL,
+ GET_REQUIRED_HW_INTERFACES,
+ &flags)
+ || NEED_IO_ENABLED(flags))
+ continue;
+ }
+
+ xf86CallDriverProbe(xf86DriverList[i], FALSE);
+ }
+
+ /* If nothing was detected, return now */
+ if (xf86NumScreens == 0) {
+ xf86Msg(X_ERROR, "No devices detected.\n");
+ return FALSE;
+ }
+
+ xf86VGAarbiterInit();
+
+ /*
+ * Match up the screens found by the probes against those specified
+ * in the config file. Remove the ones that won't be used. Sort
+ * them in the order specified.
+ *
+ * What is the best way to do this?
+ *
+ * For now, go through the screens allocated by the probes, and
+ * look for screen config entry which refers to the same device
+ * section as picked out by the probe.
+ *
+ */
+ for (i = 0; i < xf86NumScreens; i++) {
+ for (layout = xf86ConfigLayout.screens; layout->screen != NULL;
+ layout++) {
+ Bool found = FALSE;
+ for (j = 0; j < xf86Screens[i]->numEntities; j++) {
+
+ GDevPtr dev = xf86GetDevFromEntity(
+ xf86Screens[i]->entityList[j],
+ xf86Screens[i]->entityInstanceList[j]);
+ if (dev == layout->screen->device) {
+ /* A match has been found */
+ xf86Screens[i]->confScreen = layout->screen;
+ found = TRUE;
+ break;
+ }
+ }
+ if (found) break;
+ }
+ if (layout->screen == NULL) {
+ /* No match found */
+ xf86Msg(X_ERROR,
+ "Screen %d deleted because of no matching config section.\n", i);
+ xf86DeleteScreen(i--, 0);
+ }
+ }
+
+ /* If no screens left, return now. */
+ if (xf86NumScreens == 0) {
+ xf86Msg(X_ERROR,
+ "Device(s) detected, but none match those in the config file.\n");
+ return FALSE;
+ }
+
+ return TRUE;
+}
+
+/*
+ * Call the bus probes relevant to the architecture.
+ *
+ * The only one available so far is for PCI and SBUS.
+ */
+
+void
+xf86BusProbe(void)
+{
+ xf86PciProbe();
+#if (defined(__sparc__) || defined(__sparc)) && !defined(__OpenBSD__)
+ xf86SbusProbe();
+#endif
+}
+
+/*
+ * Determine what bus type the busID string represents. The start of the
+ * bus-dependent part of the string is returned as retID.
+ */
+
+BusType
+StringToBusType(const char* busID, const char **retID)
+{
+ char *p, *s;
+ BusType ret = BUS_NONE;
+
+ /* If no type field, Default to PCI */
+ if (isdigit(busID[0])) {
+ if (retID)
+ *retID = busID;
+ return BUS_PCI;
+ }
+
+ s = xstrdup(busID);
+ p = strtok(s, ":");
+ if (p == NULL || *p == 0) {
+ free(s);
+ return BUS_NONE;
+ }
+ if (!xf86NameCmp(p, "pci") || !xf86NameCmp(p, "agp"))
+ ret = BUS_PCI;
+ if (!xf86NameCmp(p, "sbus"))
+ ret = BUS_SBUS;
+ if (ret != BUS_NONE)
+ if (retID)
+ *retID = busID + strlen(p) + 1;
+ free(s);
+ return ret;
+}
+
+int
+xf86AllocateEntity(void)
+{
+ xf86NumEntities++;
+ xf86Entities = xnfrealloc(xf86Entities,
+ sizeof(EntityPtr) * xf86NumEntities);
+ xf86Entities[xf86NumEntities - 1] = xnfcalloc(1,sizeof(EntityRec));
+ xf86Entities[xf86NumEntities - 1]->entityPrivates =
+ xnfcalloc(sizeof(DevUnion) * xf86EntityPrivateCount, 1);
+ return xf86NumEntities - 1;
+}
+
+Bool
+xf86IsEntityPrimary(int entityIndex)
+{
+ EntityPtr pEnt = xf86Entities[entityIndex];
+
+ if (primaryBus.type != pEnt->bus.type) return FALSE;
+
+ switch (pEnt->bus.type) {
+ case BUS_PCI:
+ return pEnt->bus.id.pci == primaryBus.id.pci;
+ case BUS_SBUS:
+ return pEnt->bus.id.sbus.fbNum == primaryBus.id.sbus.fbNum;
+ default:
+ return FALSE;
+ }
+}
+
+Bool
+xf86SetEntityFuncs(int entityIndex, EntityProc init, EntityProc enter,
+ EntityProc leave, pointer private)
+{
+ if (entityIndex >= xf86NumEntities)
+ return FALSE;
+ xf86Entities[entityIndex]->entityInit = init;
+ xf86Entities[entityIndex]->entityEnter = enter;
+ xf86Entities[entityIndex]->entityLeave = leave;
+ xf86Entities[entityIndex]->private = private;
+ return TRUE;
+}
+
+Bool
+xf86DriverHasEntities(DriverPtr drvp)
+{
+ int i;
+ for (i = 0; i < xf86NumEntities; i++) {
+ if (xf86Entities[i]->driver == drvp)
+ return TRUE;
+ }
+ return FALSE;
+}
+
+void
+xf86AddEntityToScreen(ScrnInfoPtr pScrn, int entityIndex)
+{
+ if (entityIndex == -1)
+ return;
+ if (xf86Entities[entityIndex]->inUse &&
+ !(xf86Entities[entityIndex]->entityProp & IS_SHARED_ACCEL)) {
+ ErrorF("Requested Entity already in use!\n");
+ return;
+ }
+
+ pScrn->numEntities++;
+ pScrn->entityList = xnfrealloc(pScrn->entityList,
+ pScrn->numEntities * sizeof(int));
+ pScrn->entityList[pScrn->numEntities - 1] = entityIndex;
+ xf86Entities[entityIndex]->inUse = TRUE;
+ pScrn->entityInstanceList = xnfrealloc(pScrn->entityInstanceList,
+ pScrn->numEntities * sizeof(int));
+ pScrn->entityInstanceList[pScrn->numEntities - 1] = 0;
+ pScrn->domainIOBase = xf86Entities[entityIndex]->domainIO;
+}
+
+void
+xf86SetEntityInstanceForScreen(ScrnInfoPtr pScrn, int entityIndex, int instance)
+{
+ int i;
+
+ if (entityIndex == -1 || entityIndex >= xf86NumEntities)
+ return;
+
+ for (i = 0; i < pScrn->numEntities; i++) {
+ if (pScrn->entityList[i] == entityIndex) {
+ pScrn->entityInstanceList[i] = instance;
+ break;
+ }
+ }
+}
+
+/*
+ * XXX This needs to be updated for the case where a single entity may have
+ * instances associated with more than one screen.
+ */
+ScrnInfoPtr
+xf86FindScreenForEntity(int entityIndex)
+{
+ int i,j;
+
+ if (entityIndex == -1) return NULL;
+
+ if (xf86Screens) {
+ for (i = 0; i < xf86NumScreens; i++) {
+ for (j = 0; j < xf86Screens[i]->numEntities; j++) {
+ if ( xf86Screens[i]->entityList[j] == entityIndex )
+ return xf86Screens[i];
+ }
+ }
+ }
+ return NULL;
+}
+
+void
+xf86RemoveEntityFromScreen(ScrnInfoPtr pScrn, int entityIndex)
+{
+ int i;
+
+ for (i = 0; i < pScrn->numEntities; i++) {
+ if (pScrn->entityList[i] == entityIndex) {
+ for (i++; i < pScrn->numEntities; i++)
+ pScrn->entityList[i-1] = pScrn->entityList[i];
+ pScrn->numEntities--;
+ xf86Entities[entityIndex]->inUse = FALSE;
+ break;
+ }
+ }
+}
+
+/*
+ * xf86ClearEntitiesForScreen() - called when a screen is deleted
+ * to mark it's entities unused. Called by xf86DeleteScreen().
+ */
+void
+xf86ClearEntityListForScreen(int scrnIndex)
+{
+ ScrnInfoPtr pScrn = xf86Screens[scrnIndex];
+ int i, entityIndex;
+
+ if (pScrn->entityList == NULL || pScrn->numEntities == 0) return;
+
+ for (i = 0; i < pScrn->numEntities; i++) {
+ entityIndex = pScrn->entityList[i];
+ xf86Entities[entityIndex]->inUse = FALSE;
+ /* disable resource: call the disable function */
+ }
+ free(pScrn->entityList);
+ free(pScrn->entityInstanceList);
+ pScrn->entityList = NULL;
+ pScrn->entityInstanceList = NULL;
+}
+
+/*
+ * Add an extra device section (GDevPtr) to an entity.
+ */
+
+void
+xf86AddDevToEntity(int entityIndex, GDevPtr dev)
+{
+ EntityPtr pEnt;
+
+ if (entityIndex >= xf86NumEntities)
+ return;
+
+ pEnt = xf86Entities[entityIndex];
+ pEnt->numInstances++;
+ pEnt->devices = xnfrealloc(pEnt->devices,
+ pEnt->numInstances * sizeof(GDevPtr));
+ pEnt->devices[pEnt->numInstances - 1] = dev;
+ dev->claimed = TRUE;
+}
+
+/*
+ * xf86GetEntityInfo() -- This function hands information from the
+ * EntityRec struct to the drivers. The EntityRec structure itself
+ * remains invisible to the driver.
+ */
+EntityInfoPtr
+xf86GetEntityInfo(int entityIndex)
+{
+ EntityInfoPtr pEnt;
+ int i;
+
+ if (entityIndex == -1)
+ return NULL;
+
+ if (entityIndex >= xf86NumEntities)
+ return NULL;
+
+ pEnt = xnfcalloc(1,sizeof(EntityInfoRec));
+ pEnt->index = entityIndex;
+ pEnt->location = xf86Entities[entityIndex]->bus;
+ pEnt->active = xf86Entities[entityIndex]->active;
+ pEnt->chipset = xf86Entities[entityIndex]->chipset;
+ pEnt->driver = xf86Entities[entityIndex]->driver;
+ if ( (xf86Entities[entityIndex]->devices) &&
+ (xf86Entities[entityIndex]->devices[0]) ) {
+ for (i = 0; i < xf86Entities[entityIndex]->numInstances; i++)
+ if (xf86Entities[entityIndex]->devices[i]->screen == 0)
+ break;
+ pEnt->device = xf86Entities[entityIndex]->devices[i];
+ } else
+ pEnt->device = NULL;
+
+ return pEnt;
+}
+
+int
+xf86GetNumEntityInstances(int entityIndex)
+{
+ if (entityIndex >= xf86NumEntities)
+ return -1;
+
+ return xf86Entities[entityIndex]->numInstances;
+}
+
+GDevPtr
+xf86GetDevFromEntity(int entityIndex, int instance)
+{
+ int i;
+
+ /* We might not use AddDevtoEntity */
+ if ( (!xf86Entities[entityIndex]->devices) ||
+ (!xf86Entities[entityIndex]->devices[0]) )
+ return NULL;
+
+ if (entityIndex >= xf86NumEntities ||
+ instance >= xf86Entities[entityIndex]->numInstances)
+ return NULL;
+
+ for (i = 0; i < xf86Entities[entityIndex]->numInstances; i++)
+ if (xf86Entities[entityIndex]->devices[i]->screen == instance)
+ break;
+ return xf86Entities[entityIndex]->devices[i];
+}
+
+/*
+ * xf86AccessEnter() -- gets called to save the text mode VGA IO
+ * resources when reentering the server after a VT switch.
+ */
+void
+xf86AccessEnter(void)
+{
+ int i;
+
+ for (i = 0; i < xf86NumEntities; i++)
+ if (xf86Entities[i]->entityEnter)
+ xf86Entities[i]->entityEnter(i,xf86Entities[i]->private);
+}
+
+void
+xf86AccessLeave(void)
+{
+ int i;
+
+ for (i = 0; i < xf86NumEntities; i++)
+ if (xf86Entities[i]->entityLeave)
+ xf86Entities[i]->entityLeave(i,xf86Entities[i]->private);
+}
+
+/*
+ * xf86PostProbe() -- Allocate all non conflicting resources
+ * This function gets called by xf86Init().
+ */
+void
+xf86PostProbe(void)
+{
+ int i;
+
+ if (fbSlotClaimed && (pciSlotClaimed
+#if (defined(__sparc__) || defined(__sparc)) && !defined(__OpenBSD__)
+ || sbusSlotClaimed
+#endif
+ ))
+ FatalError("Cannot run in framebuffer mode. Please specify busIDs "
+ " for all framebuffer devices\n");
+
+ for (i = 0; i < xf86NumEntities; i++)
+ if (xf86Entities[i]->entityInit)
+ xf86Entities[i]->entityInit(i,xf86Entities[i]->private);
+}
+
+int
+xf86GetLastScrnFlag(int entityIndex)
+{
+ if(entityIndex < xf86NumEntities) {
+ return xf86Entities[entityIndex]->lastScrnFlag;
+ } else {
+ return -1;
+ }
+}
+
+void
+xf86SetLastScrnFlag(int entityIndex, int scrnIndex)
+{
+ if(entityIndex < xf86NumEntities) {
+ xf86Entities[entityIndex]->lastScrnFlag = scrnIndex;
+ }
+}
+
+Bool
+xf86IsEntityShared(int entityIndex)
+{
+ if(entityIndex < xf86NumEntities) {
+ if(xf86Entities[entityIndex]->entityProp & IS_SHARED_ACCEL) {
+ return TRUE;
+ }
+ }
+ return FALSE;
+}
+
+void
+xf86SetEntityShared(int entityIndex)
+{
+ if(entityIndex < xf86NumEntities) {
+ xf86Entities[entityIndex]->entityProp |= IS_SHARED_ACCEL;
+ }
+}
+
+Bool
+xf86IsEntitySharable(int entityIndex)
+{
+ if(entityIndex < xf86NumEntities) {
+ if(xf86Entities[entityIndex]->entityProp & ACCEL_IS_SHARABLE) {
+ return TRUE;
+ }
+ }
+ return FALSE;
+}
+
+void
+xf86SetEntitySharable(int entityIndex)
+{
+ if(entityIndex < xf86NumEntities) {
+ xf86Entities[entityIndex]->entityProp |= ACCEL_IS_SHARABLE;
+ }
+}
+
+Bool
+xf86IsPrimInitDone(int entityIndex)
+{
+ if(entityIndex < xf86NumEntities) {
+ if(xf86Entities[entityIndex]->entityProp & SA_PRIM_INIT_DONE) {
+ return TRUE;
+ }
+ }
+ return FALSE;
+}
+
+void
+xf86SetPrimInitDone(int entityIndex)
+{
+ if(entityIndex < xf86NumEntities) {
+ xf86Entities[entityIndex]->entityProp |= SA_PRIM_INIT_DONE;
+ }
+}
+
+void
+xf86ClearPrimInitDone(int entityIndex)
+{
+ if(entityIndex < xf86NumEntities) {
+ xf86Entities[entityIndex]->entityProp &= ~SA_PRIM_INIT_DONE;
+ }
+}
+
+
+/*
+ * Allocate a private in the entities.
+ */
+
+int
+xf86AllocateEntityPrivateIndex(void)
+{
+ int idx, i;
+ EntityPtr pEnt;
+ DevUnion *nprivs;
+
+ idx = xf86EntityPrivateCount++;
+ for (i = 0; i < xf86NumEntities; i++) {
+ pEnt = xf86Entities[i];
+ nprivs = xnfrealloc(pEnt->entityPrivates,
+ xf86EntityPrivateCount * sizeof(DevUnion));
+ /* Zero the new private */
+ memset(&nprivs[idx], 0, sizeof(DevUnion));
+ pEnt->entityPrivates = nprivs;
+ }
+ return idx;
+}
+
+DevUnion *
+xf86GetEntityPrivate(int entityIndex, int privIndex)
+{
+ if (entityIndex >= xf86NumEntities || privIndex >= xf86EntityPrivateCount)
+ return NULL;
+
+ return &(xf86Entities[entityIndex]->entityPrivates[privIndex]);
+}
+
diff --git a/xorg-server/hw/xfree86/common/xf86Configure.c b/xorg-server/hw/xfree86/common/xf86Configure.c
index c106f3754..883c48cc0 100644
--- a/xorg-server/hw/xfree86/common/xf86Configure.c
+++ b/xorg-server/hw/xfree86/common/xf86Configure.c
@@ -1,784 +1,765 @@
-/*
- * Copyright 2000-2002 by Alan Hourihane, Flint Mountain, North Wales.
- *
- * 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 Alan Hourihane not be used in
- * advertising or publicity pertaining to distribution of the software without
- * specific, written prior permission. Alan Hourihane makes no representations
- * about the suitability of this software for any purpose. It is provided
- * "as is" without express or implied warranty.
- *
- * ALAN HOURIHANE DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
- * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
- * EVENT SHALL ALAN HOURIHANE 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: Alan Hourihane, alanh@fairlite.demon.co.uk
- *
- */
-
-#ifdef HAVE_XORG_CONFIG_H
-#include <xorg-config.h>
-#endif
-
-#include "xf86.h"
-#include "xf86Config.h"
-#include "xf86_OSlib.h"
-#include "xf86Priv.h"
-#define IN_XSERVER
-#include "Configint.h"
-#include "xf86DDC.h"
-#include "xf86pciBus.h"
-#if (defined(__sparc__) || defined(__sparc)) && !defined(__OpenBSD__)
-#include "xf86Bus.h"
-#include "xf86Sbus.h"
-#endif
-
-typedef struct _DevToConfig {
- GDevRec GDev;
- struct pci_device * pVideo;
-#if (defined(__sparc__) || defined(__sparc)) && !defined(__OpenBSD__)
- sbusDevicePtr sVideo;
-#endif
- int iDriver;
-} DevToConfigRec, *DevToConfigPtr;
-
-static DevToConfigPtr DevToConfig = NULL;
-static int nDevToConfig = 0, CurrentDriver;
-
-xf86MonPtr ConfiguredMonitor;
-Bool xf86DoConfigurePass1 = TRUE;
-static Bool foundMouse = FALSE;
-
-#if defined(__SCO__)
-static char *DFLT_MOUSE_PROTO = "OSMouse";
-#elif defined(__UNIXWARE__)
-static char *DFLT_MOUSE_PROTO = "OSMouse";
-static char *DFLT_MOUSE_DEV = "/dev/mouse";
-#elif defined(__FreeBSD__) || defined(__FreeBSD_kernel__) || defined(__DragonFly__)
-static char *DFLT_MOUSE_DEV = "/dev/sysmouse";
-static char *DFLT_MOUSE_PROTO = "auto";
-#elif defined(linux)
-static char DFLT_MOUSE_DEV[] = "/dev/input/mice";
-static char DFLT_MOUSE_PROTO[] = "auto";
-#else
-static char *DFLT_MOUSE_DEV = "/dev/mouse";
-static char *DFLT_MOUSE_PROTO = "auto";
-#endif
-
-/*
- * This is called by the driver, either through xf86Match???Instances() or
- * directly. We allocate a GDevRec and fill it in as much as we can, letting
- * the caller fill in the rest and/or change it as it sees fit.
- */
-GDevPtr
-xf86AddBusDeviceToConfigure(const char *driver, BusType bus, void *busData, int chipset)
-{
- int ret, i, j;
-
- if (!xf86DoConfigure || !xf86DoConfigurePass1)
- return NULL;
-
- /* Check for duplicates */
- for (i = 0; i < nDevToConfig; i++) {
- switch (bus) {
- case BUS_PCI:
- ret = xf86PciConfigure(busData, DevToConfig[i].pVideo);
- break;
-#if (defined(__sparc__) || defined(__sparc)) && !defined(__OpenBSD__)
- case BUS_SBUS:
- ret = xf86SbusConfigure(busData, DevToConfig[i].sVideo);
- break;
-#endif
- default:
- return NULL;
- }
- if (ret == 0)
- goto out;
- }
-
- /* Allocate new structure occurrence */
- i = nDevToConfig++;
- DevToConfig =
- xnfrealloc(DevToConfig, nDevToConfig * sizeof(DevToConfigRec));
- memset(DevToConfig + i, 0, sizeof(DevToConfigRec));
-
- DevToConfig[i].GDev.chipID =
- DevToConfig[i].GDev.chipRev = DevToConfig[i].GDev.irq = -1;
-
- DevToConfig[i].iDriver = CurrentDriver;
-
- /* Fill in what we know, converting the driver name to lower case */
- DevToConfig[i].GDev.driver = xnfalloc(strlen(driver) + 1);
- for (j = 0; (DevToConfig[i].GDev.driver[j] = tolower(driver[j])); j++);
-
- switch (bus) {
- case BUS_PCI:
- xf86PciConfigureNewDev(busData, DevToConfig[i].pVideo,
- &DevToConfig[i].GDev, &chipset);
- break;
-#if (defined(__sparc__) || defined(__sparc)) && !defined(__OpenBSD__)
- case BUS_SBUS:
- xf86SbusConfigureNewDev(busData, DevToConfig[i].sVideo,
- &DevToConfig[i].GDev);
- break;
-#endif
- default:
- break;
- }
-
- /* Get driver's available options */
- if (xf86DriverList[CurrentDriver]->AvailableOptions)
- DevToConfig[i].GDev.options = (OptionInfoPtr)
- (*xf86DriverList[CurrentDriver]->AvailableOptions)(chipset,
- bus);
-
- return &DevToConfig[i].GDev;
-
-out:
- return NULL;
-}
-
-static XF86ConfInputPtr
-configureInputSection (void)
-{
- XF86ConfInputPtr mouse = NULL;
- parsePrologue (XF86ConfInputPtr, XF86ConfInputRec)
-
- ptr->inp_identifier = "Keyboard0";
- ptr->inp_driver = "kbd";
- ptr->list.next = NULL;
-
- /* Crude mechanism to auto-detect mouse (os dependent) */
- {
- int fd;
-#ifdef WSCONS_SUPPORT
- fd = open("/dev/wsmouse", 0);
- if (fd >= 0) {
- DFLT_MOUSE_DEV = "/dev/wsmouse";
- DFLT_MOUSE_PROTO = "wsmouse";
- close(fd);
- } else {
- ErrorF("cannot open /dev/wsmouse\n");
- }
-#endif
-
-#ifndef __SCO__
- fd = open(DFLT_MOUSE_DEV, 0);
- if (fd != -1) {
- foundMouse = TRUE;
- close(fd);
- }
-#else
- foundMouse = TRUE;
-#endif
- }
-
- mouse = calloc(1, sizeof(XF86ConfInputRec));
- mouse->inp_identifier = "Mouse0";
- mouse->inp_driver = "mouse";
- mouse->inp_option_lst =
- xf86addNewOption(mouse->inp_option_lst, strdup("Protocol"),
- strdup(DFLT_MOUSE_PROTO));
-#ifndef __SCO__
- mouse->inp_option_lst =
- xf86addNewOption(mouse->inp_option_lst, strdup("Device"),
- strdup(DFLT_MOUSE_DEV));
-#endif
- mouse->inp_option_lst =
- xf86addNewOption(mouse->inp_option_lst, strdup("ZAxisMapping"),
- strdup("4 5 6 7"));
- ptr = (XF86ConfInputPtr)xf86addListItem((glp)ptr, (glp)mouse);
- return ptr;
-}
-
-static XF86ConfScreenPtr
-configureScreenSection (int screennum)
-{
- int i;
- int depths[] = { 1, 4, 8, 15, 16, 24/*, 32*/ };
- parsePrologue (XF86ConfScreenPtr, XF86ConfScreenRec)
-
- XNFasprintf(&ptr->scrn_identifier, "Screen%d", screennum);
- XNFasprintf(&ptr->scrn_monitor_str, "Monitor%d", screennum);
- XNFasprintf(&ptr->scrn_device_str, "Card%d", screennum);
-
- for (i=0; i<sizeof(depths)/sizeof(depths[0]); i++)
- {
- XF86ConfDisplayPtr display;
-
- display = calloc(1, sizeof(XF86ConfDisplayRec));
- display->disp_depth = depths[i];
- display->disp_black.red = display->disp_white.red = -1;
- display->disp_black.green = display->disp_white.green = -1;
- display->disp_black.blue = display->disp_white.blue = -1;
- ptr->scrn_display_lst = (XF86ConfDisplayPtr)xf86addListItem(
- (glp)ptr->scrn_display_lst, (glp)display);
- }
-
- return ptr;
-}
-
-static const char*
-optionTypeToString(OptionValueType type)
-{
- switch (type) {
- case OPTV_NONE:
- return "";
- case OPTV_INTEGER:
- return "<i>";
- case OPTV_STRING:
- return "<str>";
- case OPTV_ANYSTR:
- return "[<str>]";
- case OPTV_REAL:
- return "<f>";
- case OPTV_BOOLEAN:
- return "[<bool>]";
- case OPTV_FREQ:
- return "<freq>";
- case OPTV_PERCENT:
- return "<percent>";
- default:
- return "";
- }
-}
-
-static XF86ConfDevicePtr
-configureDeviceSection (int screennum)
-{
- OptionInfoPtr p;
- int i = 0;
- parsePrologue (XF86ConfDevicePtr, XF86ConfDeviceRec)
-
- /* Move device info to parser structure */
- if (asprintf(&ptr->dev_identifier, "Card%d", screennum) == -1)
- ptr->dev_identifier = NULL;
- ptr->dev_chipset = DevToConfig[screennum].GDev.chipset;
- ptr->dev_busid = DevToConfig[screennum].GDev.busID;
- ptr->dev_driver = DevToConfig[screennum].GDev.driver;
- ptr->dev_ramdac = DevToConfig[screennum].GDev.ramdac;
- for (i = 0; (i < MAXDACSPEEDS) && (i < CONF_MAXDACSPEEDS); i++)
- ptr->dev_dacSpeeds[i] = DevToConfig[screennum].GDev.dacSpeeds[i];
- ptr->dev_videoram = DevToConfig[screennum].GDev.videoRam;
- ptr->dev_textclockfreq = DevToConfig[screennum].GDev.textClockFreq;
- ptr->dev_bios_base = DevToConfig[screennum].GDev.BiosBase;
- ptr->dev_mem_base = DevToConfig[screennum].GDev.MemBase;
- ptr->dev_io_base = DevToConfig[screennum].GDev.IOBase;
- ptr->dev_clockchip = DevToConfig[screennum].GDev.clockchip;
- for (i = 0; (i < MAXCLOCKS) && (i < DevToConfig[screennum].GDev.numclocks); i++)
- ptr->dev_clock[i] = DevToConfig[screennum].GDev.clock[i];
- ptr->dev_clocks = i;
- ptr->dev_chipid = DevToConfig[screennum].GDev.chipID;
- ptr->dev_chiprev = DevToConfig[screennum].GDev.chipRev;
- ptr->dev_irq = DevToConfig[screennum].GDev.irq;
-
- /* Make sure older drivers don't segv */
- if (DevToConfig[screennum].GDev.options) {
- /* Fill in the available driver options for people to use */
- const char *descrip =
- " ### Available Driver options are:-\n"
- " ### Values: <i>: integer, <f>: float, "
- "<bool>: \"True\"/\"False\",\n"
- " ### <string>: \"String\", <freq>: \"<f> Hz/kHz/MHz\",\n"
- " ### <percent>: \"<f>%\"\n"
- " ### [arg]: arg optional\n";
- ptr->dev_comment = strdup(descrip);
- if (ptr->dev_comment) {
- for (p = DevToConfig[screennum].GDev.options;
- p->name != NULL; p++) {
- char *p_e;
- const char *prefix = " #Option ";
- const char *middle = " \t# ";
- const char *suffix = "\n";
- const char *opttype = optionTypeToString(p->type);
- char *optname;
- int len = strlen(ptr->dev_comment) + strlen(prefix) +
- strlen(middle) + strlen(suffix) + 1;
-
- if (asprintf(&optname, "\"%s\"", p->name) == -1)
- break;
-
- len += max(20, strlen(optname));
- len += strlen(opttype);
-
- ptr->dev_comment = realloc(ptr->dev_comment, len);
- if (!ptr->dev_comment)
- break;
- p_e = ptr->dev_comment + strlen(ptr->dev_comment);
- sprintf(p_e, "%s%-20s%s%s%s", prefix, optname, middle,
- opttype, suffix);
- free(optname);
- }
- }
- }
-
- return ptr;
-}
-
-static XF86ConfLayoutPtr
-configureLayoutSection (void)
-{
- int scrnum = 0;
- parsePrologue (XF86ConfLayoutPtr, XF86ConfLayoutRec)
-
- ptr->lay_identifier = "X.org Configured";
-
- {
- XF86ConfInputrefPtr iptr;
-
- iptr = malloc (sizeof (XF86ConfInputrefRec));
- iptr->list.next = NULL;
- iptr->iref_option_lst = NULL;
- iptr->iref_inputdev_str = "Mouse0";
- iptr->iref_option_lst =
- xf86addNewOption (iptr->iref_option_lst, strdup("CorePointer"), NULL);
- ptr->lay_input_lst = (XF86ConfInputrefPtr)
- xf86addListItem ((glp) ptr->lay_input_lst, (glp) iptr);
- }
-
- {
- XF86ConfInputrefPtr iptr;
-
- iptr = malloc (sizeof (XF86ConfInputrefRec));
- iptr->list.next = NULL;
- iptr->iref_option_lst = NULL;
- iptr->iref_inputdev_str = "Keyboard0";
- iptr->iref_option_lst =
- xf86addNewOption (iptr->iref_option_lst, strdup("CoreKeyboard"), NULL);
- ptr->lay_input_lst = (XF86ConfInputrefPtr)
- xf86addListItem ((glp) ptr->lay_input_lst, (glp) iptr);
- }
-
- for (scrnum = 0; scrnum < nDevToConfig; scrnum++) {
- XF86ConfAdjacencyPtr aptr;
-
- aptr = malloc (sizeof (XF86ConfAdjacencyRec));
- aptr->list.next = NULL;
- aptr->adj_x = 0;
- aptr->adj_y = 0;
- aptr->adj_scrnum = scrnum;
- XNFasprintf(&aptr->adj_screen_str, "Screen%d", scrnum);
- if (scrnum == 0) {
- aptr->adj_where = CONF_ADJ_ABSOLUTE;
- aptr->adj_refscreen = NULL;
- }
- else {
- aptr->adj_where = CONF_ADJ_RIGHTOF;
- XNFasprintf(&aptr->adj_refscreen, "Screen%d", scrnum - 1);
- }
- ptr->lay_adjacency_lst =
- (XF86ConfAdjacencyPtr)xf86addListItem((glp)ptr->lay_adjacency_lst,
- (glp)aptr);
- }
-
- return ptr;
-}
-
-static XF86ConfFlagsPtr
-configureFlagsSection (void)
-{
- parsePrologue (XF86ConfFlagsPtr, XF86ConfFlagsRec)
-
- return ptr;
-}
-
-static XF86ConfModulePtr
-configureModuleSection (void)
-{
- char **elist, **el;
- /* Find the list of extension & font modules. */
- const char *esubdirs[] = {
- "extensions",
- "fonts",
- NULL
- };
- parsePrologue (XF86ConfModulePtr, XF86ConfModuleRec)
-
- elist = LoaderListDirs(esubdirs, NULL);
- if (elist) {
- for (el = elist; *el; el++) {
- XF86LoadPtr module;
-
- module = calloc(1, sizeof(XF86LoadRec));
- module->load_name = *el;
- ptr->mod_load_lst = (XF86LoadPtr)xf86addListItem(
- (glp)ptr->mod_load_lst, (glp)module);
- }
- free(elist);
- }
-
- return ptr;
-}
-
-static XF86ConfFilesPtr
-configureFilesSection (void)
-{
- parsePrologue (XF86ConfFilesPtr, XF86ConfFilesRec)
-
- if (xf86ModulePath)
- ptr->file_modulepath = strdup(xf86ModulePath);
- if (defaultFontPath)
- ptr->file_fontpath = strdup(defaultFontPath);
-
- return ptr;
-}
-
-static XF86ConfMonitorPtr
-configureMonitorSection (int screennum)
-{
- parsePrologue (XF86ConfMonitorPtr, XF86ConfMonitorRec)
-
- XNFasprintf(&ptr->mon_identifier, "Monitor%d", screennum);
- ptr->mon_vendor = strdup("Monitor Vendor");
- ptr->mon_modelname = strdup("Monitor Model");
-
- return ptr;
-}
-
-/* Initialize Configure Monitor from Detailed Timing Block */
-static void handle_detailed_input(struct detailed_monitor_section *det_mon,
- void *data)
-{
- XF86ConfMonitorPtr ptr = (XF86ConfMonitorPtr) data;
-
- switch (det_mon->type) {
- case DS_NAME:
- ptr->mon_modelname = realloc(ptr->mon_modelname,
- strlen((char*)(det_mon->section.name)) +
- 1);
- strcpy(ptr->mon_modelname,
- (char*)(det_mon->section.name));
- break;
- case DS_RANGES:
- ptr->mon_hsync[ptr->mon_n_hsync].lo =
- det_mon->section.ranges.min_h;
- ptr->mon_hsync[ptr->mon_n_hsync].hi =
- det_mon->section.ranges.max_h;
- ptr->mon_n_vrefresh = 1;
- ptr->mon_vrefresh[ptr->mon_n_hsync].lo =
- det_mon->section.ranges.min_v;
- ptr->mon_vrefresh[ptr->mon_n_hsync].hi =
- det_mon->section.ranges.max_v;
- ptr->mon_n_hsync++;
- default:
- break;
- }
-}
-
-static XF86ConfMonitorPtr
-configureDDCMonitorSection (int screennum)
-{
- int len, mon_width, mon_height;
-#define displaySizeMaxLen 80
- char displaySize_string[displaySizeMaxLen];
- int displaySizeLen;
-
- parsePrologue (XF86ConfMonitorPtr, XF86ConfMonitorRec)
-
- XNFasprintf(&ptr->mon_identifier, "Monitor%d", screennum);
- ptr->mon_vendor = strdup(ConfiguredMonitor->vendor.name);
- XNFasprintf(&ptr->mon_modelname, "%x", ConfiguredMonitor->vendor.prod_id);
-
- /* features in centimetres, we want millimetres */
- mon_width = 10 * ConfiguredMonitor->features.hsize ;
- mon_height = 10 * ConfiguredMonitor->features.vsize ;
-
-#ifdef CONFIGURE_DISPLAYSIZE
- ptr->mon_width = mon_width;
- ptr->mon_height = mon_height;
-#else
- if (mon_width && mon_height) {
- /* when values available add DisplaySize option AS A COMMENT */
-
- displaySizeLen = snprintf(displaySize_string, displaySizeMaxLen,
- "\t#DisplaySize\t%5d %5d\t# mm\n",
- mon_width, mon_height);
-
- if (displaySizeLen>0 && displaySizeLen<displaySizeMaxLen) {
- if (ptr->mon_comment) {
- len = strlen(ptr->mon_comment);
- } else {
- len = 0;
- }
- if ((ptr->mon_comment =
- realloc(ptr->mon_comment, len + strlen(displaySize_string) + 1))) {
- strcpy(ptr->mon_comment + len, displaySize_string);
- }
- }
- }
-#endif /* def CONFIGURE_DISPLAYSIZE */
-
- xf86ForEachDetailedBlock(ConfiguredMonitor, handle_detailed_input,
- ptr);
-
- if (ConfiguredMonitor->features.dpms) {
- ptr->mon_option_lst = xf86addNewOption(ptr->mon_option_lst, strdup("DPMS"), NULL);
- }
-
- return ptr;
-}
-
-#if !defined(PATH_MAX)
-# define PATH_MAX 1024
-#endif
-
-void
-DoConfigure(void)
-{
- int i,j, screennum = -1;
- char *home = NULL;
- char filename[PATH_MAX];
- char *addslash = "";
- XF86ConfigPtr xf86config = NULL;
- char **vlist, **vl;
- int *dev2screen;
-
- vlist = xf86DriverlistFromCompile();
-
- if (!vlist) {
- ErrorF("Missing output drivers. Configuration failed.\n");
- goto bail;
- }
-
- ErrorF("List of video drivers:\n");
- for (vl = vlist; *vl; vl++)
- ErrorF("\t%s\n", *vl);
-
- /* Load all the drivers that were found. */
- xf86LoadModules(vlist, NULL);
-
- free(vlist);
-
- for (i = 0; i < xf86NumDrivers; i++) {
- xorgHWFlags flags;
- if (!xf86DriverList[i]->driverFunc
- || !xf86DriverList[i]->driverFunc(NULL,
- GET_REQUIRED_HW_INTERFACES,
- &flags)
- || NEED_IO_ENABLED(flags)) {
- xorgHWAccess = TRUE;
- break;
- }
- }
- /* Enable full I/O access */
- if (xorgHWAccess) {
- if(!xf86EnableIO())
- /* oops, we have failed */
- xorgHWAccess = FALSE;
- }
-
- /* Create XF86Config file structure */
- xf86config = calloc(1, sizeof(XF86ConfigRec));
-
- /* Call all of the probe functions, reporting the results. */
- for (CurrentDriver = 0; CurrentDriver < xf86NumDrivers; CurrentDriver++) {
- xorgHWFlags flags;
- Bool found_screen;
- DriverRec * const drv = xf86DriverList[CurrentDriver];
-
- if (!xorgHWAccess) {
- if (!drv->driverFunc
- || !drv->driverFunc( NULL, GET_REQUIRED_HW_INTERFACES, &flags )
- || NEED_IO_ENABLED(flags))
- continue;
- }
-
- found_screen = xf86CallDriverProbe( drv, TRUE );
- if ( found_screen && drv->Identify ) {
- (*drv->Identify)(0);
- }
- }
-
- if (nDevToConfig <= 0) {
- ErrorF("No devices to configure. Configuration failed.\n");
- goto bail;
- }
-
- /* Add device, monitor and screen sections for detected devices */
- for (screennum = 0; screennum < nDevToConfig; screennum++) {
- XF86ConfDevicePtr DevicePtr;
- XF86ConfMonitorPtr MonitorPtr;
- XF86ConfScreenPtr ScreenPtr;
-
- DevicePtr = configureDeviceSection(screennum);
- xf86config->conf_device_lst = (XF86ConfDevicePtr)xf86addListItem(
- (glp)xf86config->conf_device_lst, (glp)DevicePtr);
- MonitorPtr = configureMonitorSection(screennum);
- xf86config->conf_monitor_lst = (XF86ConfMonitorPtr)xf86addListItem(
- (glp)xf86config->conf_monitor_lst, (glp)MonitorPtr);
- ScreenPtr = configureScreenSection(screennum);
- xf86config->conf_screen_lst = (XF86ConfScreenPtr)xf86addListItem(
- (glp)xf86config->conf_screen_lst, (glp)ScreenPtr);
- }
-
- xf86config->conf_files = configureFilesSection();
- xf86config->conf_modules = configureModuleSection();
- xf86config->conf_flags = configureFlagsSection();
- xf86config->conf_videoadaptor_lst = NULL;
- xf86config->conf_modes_lst = NULL;
- xf86config->conf_vendor_lst = NULL;
- xf86config->conf_dri = NULL;
- xf86config->conf_input_lst = configureInputSection();
- xf86config->conf_layout_lst = configureLayoutSection();
-
- home = getenv("HOME");
- if ((home == NULL) || (home[0] == '\0')) {
- home = "/";
- } else {
- /* Determine if trailing slash is present or needed */
- int l = strlen(home);
-
- if (home[l-1] != '/') {
- addslash = "/";
- }
- }
-
- snprintf(filename, sizeof(filename), "%s%s" XF86CONFIGFILE ".new",
- home, addslash);
-
- if (xf86writeConfigFile(filename, xf86config) == 0) {
- xf86Msg(X_ERROR, "Unable to write config file: \"%s\": %s\n",
- filename, strerror(errno));
- goto bail;
- }
-
- xf86DoConfigurePass1 = FALSE;
- /* Try to get DDC information filled in */
- xf86ConfigFile = filename;
- if (xf86HandleConfigFile(FALSE) != CONFIG_OK) {
- goto bail;
- }
-
- xf86DoConfigurePass1 = FALSE;
-
- dev2screen = xnfcalloc(1,xf86NumDrivers*sizeof(int));
-
- {
- Bool *driverProbed = xnfcalloc(1,xf86NumDrivers*sizeof(Bool));
- for (screennum = 0; screennum < nDevToConfig; screennum++) {
- int k,l,n,oldNumScreens;
-
- i = DevToConfig[screennum].iDriver;
-
- if (driverProbed[i]) continue;
- driverProbed[i] = TRUE;
-
- oldNumScreens = xf86NumScreens;
-
- xf86CallDriverProbe( xf86DriverList[i], FALSE );
-
- /* reorder */
- k = screennum > 0 ? screennum : 1;
- for (l = oldNumScreens; l < xf86NumScreens; l++) {
- /* is screen primary? */
- Bool primary = FALSE;
- for (n = 0; n<xf86Screens[l]->numEntities; n++) {
- if (xf86IsEntityPrimary(xf86Screens[l]->entityList[n])) {
- dev2screen[0] = l;
- primary = TRUE;
- break;
- }
- }
- if (primary) continue;
- /* not primary: assign it to next device of same driver */
- /*
- * NOTE: we assume that devices in DevToConfig
- * and xf86Screens[] have the same order except
- * for the primary device which always comes first.
- */
- for (; k < nDevToConfig; k++) {
- if (DevToConfig[k].iDriver == i) {
- dev2screen[k++] = l;
- break;
- }
- }
- }
- }
- free(driverProbed);
- }
-
-
- if (nDevToConfig != xf86NumScreens) {
- ErrorF("Number of created screens does not match number of detected"
- " devices.\n Configuration failed.\n");
- goto bail;
- }
-
- xf86PostProbe();
-
- for (j = 0; j < xf86NumScreens; j++) {
- xf86Screens[j]->scrnIndex = j;
- }
-
- xf86freeMonitorList(xf86config->conf_monitor_lst);
- xf86config->conf_monitor_lst = NULL;
- xf86freeScreenList(xf86config->conf_screen_lst);
- xf86config->conf_screen_lst = NULL;
- for (j = 0; j < xf86NumScreens; j++) {
- XF86ConfMonitorPtr MonitorPtr;
- XF86ConfScreenPtr ScreenPtr;
-
- ConfiguredMonitor = NULL;
-
- if ((*xf86Screens[dev2screen[j]]->PreInit)(xf86Screens[dev2screen[j]],
- PROBE_DETECT) &&
- ConfiguredMonitor) {
- MonitorPtr = configureDDCMonitorSection(j);
- } else {
- MonitorPtr = configureMonitorSection(j);
- }
- ScreenPtr = configureScreenSection(j);
- xf86config->conf_monitor_lst = (XF86ConfMonitorPtr)xf86addListItem(
- (glp)xf86config->conf_monitor_lst, (glp)MonitorPtr);
- xf86config->conf_screen_lst = (XF86ConfScreenPtr)xf86addListItem(
- (glp)xf86config->conf_screen_lst, (glp)ScreenPtr);
- }
-
- if (xf86writeConfigFile(filename, xf86config) == 0) {
- xf86Msg(X_ERROR, "Unable to write config file: \"%s\": %s\n",
- filename, strerror(errno));
- goto bail;
- }
-
- ErrorF("\n");
-
-#ifdef __SCO__
- ErrorF("\n"__XSERVERNAME__
- " is using the kernel event driver to access the mouse.\n"
- "If you wish to use the internal "__XSERVERNAME__
- " mouse drivers, please\n"
- "edit the file and correct the Device.\n");
-#else /* !__SCO__ */
- if (!foundMouse) {
- ErrorF("\n"__XSERVERNAME__" is not able to detect your mouse.\n"
- "Edit the file and correct the Device.\n");
- } else {
- ErrorF("\n"__XSERVERNAME__" detected your mouse at device %s.\n"
- "Please check your config if the mouse is still not\n"
- "operational, as by default "__XSERVERNAME__
- " tries to autodetect\n"
- "the protocol.\n",DFLT_MOUSE_DEV);
- }
-#endif /* !__SCO__ */
-
- if (xf86NumScreens > 1) {
- ErrorF("\n"__XSERVERNAME__
- " has configured a multihead system, please check your config.\n");
- }
-
- ErrorF("\nYour %s file is %s\n\n", XF86CONFIGFILE ,filename);
- ErrorF("To test the server, run 'X -config %s'\n\n", filename);
-
-bail:
- OsCleanup(TRUE);
- AbortDDX();
- fflush(stderr);
- exit(0);
-}
+/*
+ * Copyright 2000-2002 by Alan Hourihane, Flint Mountain, North Wales.
+ *
+ * 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 Alan Hourihane not be used in
+ * advertising or publicity pertaining to distribution of the software without
+ * specific, written prior permission. Alan Hourihane makes no representations
+ * about the suitability of this software for any purpose. It is provided
+ * "as is" without express or implied warranty.
+ *
+ * ALAN HOURIHANE DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
+ * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
+ * EVENT SHALL ALAN HOURIHANE 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: Alan Hourihane, alanh@fairlite.demon.co.uk
+ *
+ */
+
+#ifdef HAVE_XORG_CONFIG_H
+#include <xorg-config.h>
+#endif
+
+#include "xf86.h"
+#include "xf86Config.h"
+#include "xf86_OSlib.h"
+#include "xf86Priv.h"
+#define IN_XSERVER
+#include "Configint.h"
+#include "xf86DDC.h"
+#include "xf86pciBus.h"
+#if (defined(__sparc__) || defined(__sparc)) && !defined(__OpenBSD__)
+#include "xf86Bus.h"
+#include "xf86Sbus.h"
+#endif
+
+typedef struct _DevToConfig {
+ GDevRec GDev;
+ struct pci_device * pVideo;
+#if (defined(__sparc__) || defined(__sparc)) && !defined(__OpenBSD__)
+ sbusDevicePtr sVideo;
+#endif
+ int iDriver;
+} DevToConfigRec, *DevToConfigPtr;
+
+static DevToConfigPtr DevToConfig = NULL;
+static int nDevToConfig = 0, CurrentDriver;
+
+xf86MonPtr ConfiguredMonitor;
+Bool xf86DoConfigurePass1 = TRUE;
+static Bool foundMouse = FALSE;
+
+#if defined(__FreeBSD__) || defined(__FreeBSD_kernel__) || defined(__DragonFly__)
+static char *DFLT_MOUSE_DEV = "/dev/sysmouse";
+static char *DFLT_MOUSE_PROTO = "auto";
+#elif defined(linux)
+static char DFLT_MOUSE_DEV[] = "/dev/input/mice";
+static char DFLT_MOUSE_PROTO[] = "auto";
+#else
+static char *DFLT_MOUSE_DEV = "/dev/mouse";
+static char *DFLT_MOUSE_PROTO = "auto";
+#endif
+
+/*
+ * This is called by the driver, either through xf86Match???Instances() or
+ * directly. We allocate a GDevRec and fill it in as much as we can, letting
+ * the caller fill in the rest and/or change it as it sees fit.
+ */
+GDevPtr
+xf86AddBusDeviceToConfigure(const char *driver, BusType bus, void *busData, int chipset)
+{
+ int ret, i, j;
+
+ if (!xf86DoConfigure || !xf86DoConfigurePass1)
+ return NULL;
+
+ /* Check for duplicates */
+ for (i = 0; i < nDevToConfig; i++) {
+ switch (bus) {
+ case BUS_PCI:
+ ret = xf86PciConfigure(busData, DevToConfig[i].pVideo);
+ break;
+#if (defined(__sparc__) || defined(__sparc)) && !defined(__OpenBSD__)
+ case BUS_SBUS:
+ ret = xf86SbusConfigure(busData, DevToConfig[i].sVideo);
+ break;
+#endif
+ default:
+ return NULL;
+ }
+ if (ret == 0)
+ goto out;
+ }
+
+ /* Allocate new structure occurrence */
+ i = nDevToConfig++;
+ DevToConfig =
+ xnfrealloc(DevToConfig, nDevToConfig * sizeof(DevToConfigRec));
+ memset(DevToConfig + i, 0, sizeof(DevToConfigRec));
+
+ DevToConfig[i].GDev.chipID =
+ DevToConfig[i].GDev.chipRev = DevToConfig[i].GDev.irq = -1;
+
+ DevToConfig[i].iDriver = CurrentDriver;
+
+ /* Fill in what we know, converting the driver name to lower case */
+ DevToConfig[i].GDev.driver = xnfalloc(strlen(driver) + 1);
+ for (j = 0; (DevToConfig[i].GDev.driver[j] = tolower(driver[j])); j++);
+
+ switch (bus) {
+ case BUS_PCI:
+ xf86PciConfigureNewDev(busData, DevToConfig[i].pVideo,
+ &DevToConfig[i].GDev, &chipset);
+ break;
+#if (defined(__sparc__) || defined(__sparc)) && !defined(__OpenBSD__)
+ case BUS_SBUS:
+ xf86SbusConfigureNewDev(busData, DevToConfig[i].sVideo,
+ &DevToConfig[i].GDev);
+ break;
+#endif
+ default:
+ break;
+ }
+
+ /* Get driver's available options */
+ if (xf86DriverList[CurrentDriver]->AvailableOptions)
+ DevToConfig[i].GDev.options = (OptionInfoPtr)
+ (*xf86DriverList[CurrentDriver]->AvailableOptions)(chipset,
+ bus);
+
+ return &DevToConfig[i].GDev;
+
+out:
+ return NULL;
+}
+
+static XF86ConfInputPtr
+configureInputSection (void)
+{
+ XF86ConfInputPtr mouse = NULL;
+ parsePrologue (XF86ConfInputPtr, XF86ConfInputRec)
+
+ ptr->inp_identifier = "Keyboard0";
+ ptr->inp_driver = "kbd";
+ ptr->list.next = NULL;
+
+ /* Crude mechanism to auto-detect mouse (os dependent) */
+ {
+ int fd;
+#ifdef WSCONS_SUPPORT
+ fd = open("/dev/wsmouse", 0);
+ if (fd >= 0) {
+ DFLT_MOUSE_DEV = "/dev/wsmouse";
+ DFLT_MOUSE_PROTO = "wsmouse";
+ close(fd);
+ } else {
+ ErrorF("cannot open /dev/wsmouse\n");
+ }
+#endif
+
+ fd = open(DFLT_MOUSE_DEV, 0);
+ if (fd != -1) {
+ foundMouse = TRUE;
+ close(fd);
+ }
+ }
+
+ mouse = calloc(1, sizeof(XF86ConfInputRec));
+ mouse->inp_identifier = "Mouse0";
+ mouse->inp_driver = "mouse";
+ mouse->inp_option_lst =
+ xf86addNewOption(mouse->inp_option_lst, strdup("Protocol"),
+ strdup(DFLT_MOUSE_PROTO));
+ mouse->inp_option_lst =
+ xf86addNewOption(mouse->inp_option_lst, strdup("Device"),
+ strdup(DFLT_MOUSE_DEV));
+ mouse->inp_option_lst =
+ xf86addNewOption(mouse->inp_option_lst, strdup("ZAxisMapping"),
+ strdup("4 5 6 7"));
+ ptr = (XF86ConfInputPtr)xf86addListItem((glp)ptr, (glp)mouse);
+ return ptr;
+}
+
+static XF86ConfScreenPtr
+configureScreenSection (int screennum)
+{
+ int i;
+ int depths[] = { 1, 4, 8, 15, 16, 24/*, 32*/ };
+ parsePrologue (XF86ConfScreenPtr, XF86ConfScreenRec)
+
+ XNFasprintf(&ptr->scrn_identifier, "Screen%d", screennum);
+ XNFasprintf(&ptr->scrn_monitor_str, "Monitor%d", screennum);
+ XNFasprintf(&ptr->scrn_device_str, "Card%d", screennum);
+
+ for (i=0; i<sizeof(depths)/sizeof(depths[0]); i++)
+ {
+ XF86ConfDisplayPtr display;
+
+ display = calloc(1, sizeof(XF86ConfDisplayRec));
+ display->disp_depth = depths[i];
+ display->disp_black.red = display->disp_white.red = -1;
+ display->disp_black.green = display->disp_white.green = -1;
+ display->disp_black.blue = display->disp_white.blue = -1;
+ ptr->scrn_display_lst = (XF86ConfDisplayPtr)xf86addListItem(
+ (glp)ptr->scrn_display_lst, (glp)display);
+ }
+
+ return ptr;
+}
+
+static const char*
+optionTypeToString(OptionValueType type)
+{
+ switch (type) {
+ case OPTV_NONE:
+ return "";
+ case OPTV_INTEGER:
+ return "<i>";
+ case OPTV_STRING:
+ return "<str>";
+ case OPTV_ANYSTR:
+ return "[<str>]";
+ case OPTV_REAL:
+ return "<f>";
+ case OPTV_BOOLEAN:
+ return "[<bool>]";
+ case OPTV_FREQ:
+ return "<freq>";
+ case OPTV_PERCENT:
+ return "<percent>";
+ default:
+ return "";
+ }
+}
+
+static XF86ConfDevicePtr
+configureDeviceSection (int screennum)
+{
+ OptionInfoPtr p;
+ int i = 0;
+ parsePrologue (XF86ConfDevicePtr, XF86ConfDeviceRec)
+
+ /* Move device info to parser structure */
+ if (asprintf(&ptr->dev_identifier, "Card%d", screennum) == -1)
+ ptr->dev_identifier = NULL;
+ ptr->dev_chipset = DevToConfig[screennum].GDev.chipset;
+ ptr->dev_busid = DevToConfig[screennum].GDev.busID;
+ ptr->dev_driver = DevToConfig[screennum].GDev.driver;
+ ptr->dev_ramdac = DevToConfig[screennum].GDev.ramdac;
+ for (i = 0; (i < MAXDACSPEEDS) && (i < CONF_MAXDACSPEEDS); i++)
+ ptr->dev_dacSpeeds[i] = DevToConfig[screennum].GDev.dacSpeeds[i];
+ ptr->dev_videoram = DevToConfig[screennum].GDev.videoRam;
+ ptr->dev_textclockfreq = DevToConfig[screennum].GDev.textClockFreq;
+ ptr->dev_bios_base = DevToConfig[screennum].GDev.BiosBase;
+ ptr->dev_mem_base = DevToConfig[screennum].GDev.MemBase;
+ ptr->dev_io_base = DevToConfig[screennum].GDev.IOBase;
+ ptr->dev_clockchip = DevToConfig[screennum].GDev.clockchip;
+ for (i = 0; (i < MAXCLOCKS) && (i < DevToConfig[screennum].GDev.numclocks); i++)
+ ptr->dev_clock[i] = DevToConfig[screennum].GDev.clock[i];
+ ptr->dev_clocks = i;
+ ptr->dev_chipid = DevToConfig[screennum].GDev.chipID;
+ ptr->dev_chiprev = DevToConfig[screennum].GDev.chipRev;
+ ptr->dev_irq = DevToConfig[screennum].GDev.irq;
+
+ /* Make sure older drivers don't segv */
+ if (DevToConfig[screennum].GDev.options) {
+ /* Fill in the available driver options for people to use */
+ const char *descrip =
+ " ### Available Driver options are:-\n"
+ " ### Values: <i>: integer, <f>: float, "
+ "<bool>: \"True\"/\"False\",\n"
+ " ### <string>: \"String\", <freq>: \"<f> Hz/kHz/MHz\",\n"
+ " ### <percent>: \"<f>%\"\n"
+ " ### [arg]: arg optional\n";
+ ptr->dev_comment = strdup(descrip);
+ if (ptr->dev_comment) {
+ for (p = DevToConfig[screennum].GDev.options;
+ p->name != NULL; p++) {
+ char *p_e;
+ const char *prefix = " #Option ";
+ const char *middle = " \t# ";
+ const char *suffix = "\n";
+ const char *opttype = optionTypeToString(p->type);
+ char *optname;
+ int len = strlen(ptr->dev_comment) + strlen(prefix) +
+ strlen(middle) + strlen(suffix) + 1;
+
+ if (asprintf(&optname, "\"%s\"", p->name) == -1)
+ break;
+
+ len += max(20, strlen(optname));
+ len += strlen(opttype);
+
+ ptr->dev_comment = realloc(ptr->dev_comment, len);
+ if (!ptr->dev_comment)
+ break;
+ p_e = ptr->dev_comment + strlen(ptr->dev_comment);
+ sprintf(p_e, "%s%-20s%s%s%s", prefix, optname, middle,
+ opttype, suffix);
+ free(optname);
+ }
+ }
+ }
+
+ return ptr;
+}
+
+static XF86ConfLayoutPtr
+configureLayoutSection (void)
+{
+ int scrnum = 0;
+ parsePrologue (XF86ConfLayoutPtr, XF86ConfLayoutRec)
+
+ ptr->lay_identifier = "X.org Configured";
+
+ {
+ XF86ConfInputrefPtr iptr;
+
+ iptr = malloc (sizeof (XF86ConfInputrefRec));
+ iptr->list.next = NULL;
+ iptr->iref_option_lst = NULL;
+ iptr->iref_inputdev_str = "Mouse0";
+ iptr->iref_option_lst =
+ xf86addNewOption (iptr->iref_option_lst, strdup("CorePointer"), NULL);
+ ptr->lay_input_lst = (XF86ConfInputrefPtr)
+ xf86addListItem ((glp) ptr->lay_input_lst, (glp) iptr);
+ }
+
+ {
+ XF86ConfInputrefPtr iptr;
+
+ iptr = malloc (sizeof (XF86ConfInputrefRec));
+ iptr->list.next = NULL;
+ iptr->iref_option_lst = NULL;
+ iptr->iref_inputdev_str = "Keyboard0";
+ iptr->iref_option_lst =
+ xf86addNewOption (iptr->iref_option_lst, strdup("CoreKeyboard"), NULL);
+ ptr->lay_input_lst = (XF86ConfInputrefPtr)
+ xf86addListItem ((glp) ptr->lay_input_lst, (glp) iptr);
+ }
+
+ for (scrnum = 0; scrnum < nDevToConfig; scrnum++) {
+ XF86ConfAdjacencyPtr aptr;
+
+ aptr = malloc (sizeof (XF86ConfAdjacencyRec));
+ aptr->list.next = NULL;
+ aptr->adj_x = 0;
+ aptr->adj_y = 0;
+ aptr->adj_scrnum = scrnum;
+ XNFasprintf(&aptr->adj_screen_str, "Screen%d", scrnum);
+ if (scrnum == 0) {
+ aptr->adj_where = CONF_ADJ_ABSOLUTE;
+ aptr->adj_refscreen = NULL;
+ }
+ else {
+ aptr->adj_where = CONF_ADJ_RIGHTOF;
+ XNFasprintf(&aptr->adj_refscreen, "Screen%d", scrnum - 1);
+ }
+ ptr->lay_adjacency_lst =
+ (XF86ConfAdjacencyPtr)xf86addListItem((glp)ptr->lay_adjacency_lst,
+ (glp)aptr);
+ }
+
+ return ptr;
+}
+
+static XF86ConfFlagsPtr
+configureFlagsSection (void)
+{
+ parsePrologue (XF86ConfFlagsPtr, XF86ConfFlagsRec)
+
+ return ptr;
+}
+
+static XF86ConfModulePtr
+configureModuleSection (void)
+{
+ char **elist, **el;
+ /* Find the list of extension & font modules. */
+ const char *esubdirs[] = {
+ "extensions",
+ "fonts",
+ NULL
+ };
+ parsePrologue (XF86ConfModulePtr, XF86ConfModuleRec)
+
+ elist = LoaderListDirs(esubdirs, NULL);
+ if (elist) {
+ for (el = elist; *el; el++) {
+ XF86LoadPtr module;
+
+ module = calloc(1, sizeof(XF86LoadRec));
+ module->load_name = *el;
+ ptr->mod_load_lst = (XF86LoadPtr)xf86addListItem(
+ (glp)ptr->mod_load_lst, (glp)module);
+ }
+ free(elist);
+ }
+
+ return ptr;
+}
+
+static XF86ConfFilesPtr
+configureFilesSection (void)
+{
+ parsePrologue (XF86ConfFilesPtr, XF86ConfFilesRec)
+
+ if (xf86ModulePath)
+ ptr->file_modulepath = strdup(xf86ModulePath);
+ if (defaultFontPath)
+ ptr->file_fontpath = strdup(defaultFontPath);
+
+ return ptr;
+}
+
+static XF86ConfMonitorPtr
+configureMonitorSection (int screennum)
+{
+ parsePrologue (XF86ConfMonitorPtr, XF86ConfMonitorRec)
+
+ XNFasprintf(&ptr->mon_identifier, "Monitor%d", screennum);
+ ptr->mon_vendor = strdup("Monitor Vendor");
+ ptr->mon_modelname = strdup("Monitor Model");
+
+ return ptr;
+}
+
+/* Initialize Configure Monitor from Detailed Timing Block */
+static void handle_detailed_input(struct detailed_monitor_section *det_mon,
+ void *data)
+{
+ XF86ConfMonitorPtr ptr = (XF86ConfMonitorPtr) data;
+
+ switch (det_mon->type) {
+ case DS_NAME:
+ ptr->mon_modelname = realloc(ptr->mon_modelname,
+ strlen((char*)(det_mon->section.name)) +
+ 1);
+ strcpy(ptr->mon_modelname,
+ (char*)(det_mon->section.name));
+ break;
+ case DS_RANGES:
+ ptr->mon_hsync[ptr->mon_n_hsync].lo =
+ det_mon->section.ranges.min_h;
+ ptr->mon_hsync[ptr->mon_n_hsync].hi =
+ det_mon->section.ranges.max_h;
+ ptr->mon_n_vrefresh = 1;
+ ptr->mon_vrefresh[ptr->mon_n_hsync].lo =
+ det_mon->section.ranges.min_v;
+ ptr->mon_vrefresh[ptr->mon_n_hsync].hi =
+ det_mon->section.ranges.max_v;
+ ptr->mon_n_hsync++;
+ default:
+ break;
+ }
+}
+
+static XF86ConfMonitorPtr
+configureDDCMonitorSection (int screennum)
+{
+ int len, mon_width, mon_height;
+#define displaySizeMaxLen 80
+ char displaySize_string[displaySizeMaxLen];
+ int displaySizeLen;
+
+ parsePrologue (XF86ConfMonitorPtr, XF86ConfMonitorRec)
+
+ XNFasprintf(&ptr->mon_identifier, "Monitor%d", screennum);
+ ptr->mon_vendor = strdup(ConfiguredMonitor->vendor.name);
+ XNFasprintf(&ptr->mon_modelname, "%x", ConfiguredMonitor->vendor.prod_id);
+
+ /* features in centimetres, we want millimetres */
+ mon_width = 10 * ConfiguredMonitor->features.hsize ;
+ mon_height = 10 * ConfiguredMonitor->features.vsize ;
+
+#ifdef CONFIGURE_DISPLAYSIZE
+ ptr->mon_width = mon_width;
+ ptr->mon_height = mon_height;
+#else
+ if (mon_width && mon_height) {
+ /* when values available add DisplaySize option AS A COMMENT */
+
+ displaySizeLen = snprintf(displaySize_string, displaySizeMaxLen,
+ "\t#DisplaySize\t%5d %5d\t# mm\n",
+ mon_width, mon_height);
+
+ if (displaySizeLen>0 && displaySizeLen<displaySizeMaxLen) {
+ if (ptr->mon_comment) {
+ len = strlen(ptr->mon_comment);
+ } else {
+ len = 0;
+ }
+ if ((ptr->mon_comment =
+ realloc(ptr->mon_comment, len + strlen(displaySize_string) + 1))) {
+ strcpy(ptr->mon_comment + len, displaySize_string);
+ }
+ }
+ }
+#endif /* def CONFIGURE_DISPLAYSIZE */
+
+ xf86ForEachDetailedBlock(ConfiguredMonitor, handle_detailed_input,
+ ptr);
+
+ if (ConfiguredMonitor->features.dpms) {
+ ptr->mon_option_lst = xf86addNewOption(ptr->mon_option_lst, strdup("DPMS"), NULL);
+ }
+
+ return ptr;
+}
+
+#if !defined(PATH_MAX)
+# define PATH_MAX 1024
+#endif
+
+void
+DoConfigure(void)
+{
+ int i,j, screennum = -1;
+ char *home = NULL;
+ char filename[PATH_MAX];
+ char *addslash = "";
+ XF86ConfigPtr xf86config = NULL;
+ char **vlist, **vl;
+ int *dev2screen;
+
+ vlist = xf86DriverlistFromCompile();
+
+ if (!vlist) {
+ ErrorF("Missing output drivers. Configuration failed.\n");
+ goto bail;
+ }
+
+ ErrorF("List of video drivers:\n");
+ for (vl = vlist; *vl; vl++)
+ ErrorF("\t%s\n", *vl);
+
+ /* Load all the drivers that were found. */
+ xf86LoadModules(vlist, NULL);
+
+ free(vlist);
+
+ for (i = 0; i < xf86NumDrivers; i++) {
+ xorgHWFlags flags;
+ if (!xf86DriverList[i]->driverFunc
+ || !xf86DriverList[i]->driverFunc(NULL,
+ GET_REQUIRED_HW_INTERFACES,
+ &flags)
+ || NEED_IO_ENABLED(flags)) {
+ xorgHWAccess = TRUE;
+ break;
+ }
+ }
+ /* Enable full I/O access */
+ if (xorgHWAccess) {
+ if(!xf86EnableIO())
+ /* oops, we have failed */
+ xorgHWAccess = FALSE;
+ }
+
+ /* Create XF86Config file structure */
+ xf86config = calloc(1, sizeof(XF86ConfigRec));
+
+ /* Call all of the probe functions, reporting the results. */
+ for (CurrentDriver = 0; CurrentDriver < xf86NumDrivers; CurrentDriver++) {
+ xorgHWFlags flags;
+ Bool found_screen;
+ DriverRec * const drv = xf86DriverList[CurrentDriver];
+
+ if (!xorgHWAccess) {
+ if (!drv->driverFunc
+ || !drv->driverFunc( NULL, GET_REQUIRED_HW_INTERFACES, &flags )
+ || NEED_IO_ENABLED(flags))
+ continue;
+ }
+
+ found_screen = xf86CallDriverProbe( drv, TRUE );
+ if ( found_screen && drv->Identify ) {
+ (*drv->Identify)(0);
+ }
+ }
+
+ if (nDevToConfig <= 0) {
+ ErrorF("No devices to configure. Configuration failed.\n");
+ goto bail;
+ }
+
+ /* Add device, monitor and screen sections for detected devices */
+ for (screennum = 0; screennum < nDevToConfig; screennum++) {
+ XF86ConfDevicePtr DevicePtr;
+ XF86ConfMonitorPtr MonitorPtr;
+ XF86ConfScreenPtr ScreenPtr;
+
+ DevicePtr = configureDeviceSection(screennum);
+ xf86config->conf_device_lst = (XF86ConfDevicePtr)xf86addListItem(
+ (glp)xf86config->conf_device_lst, (glp)DevicePtr);
+ MonitorPtr = configureMonitorSection(screennum);
+ xf86config->conf_monitor_lst = (XF86ConfMonitorPtr)xf86addListItem(
+ (glp)xf86config->conf_monitor_lst, (glp)MonitorPtr);
+ ScreenPtr = configureScreenSection(screennum);
+ xf86config->conf_screen_lst = (XF86ConfScreenPtr)xf86addListItem(
+ (glp)xf86config->conf_screen_lst, (glp)ScreenPtr);
+ }
+
+ xf86config->conf_files = configureFilesSection();
+ xf86config->conf_modules = configureModuleSection();
+ xf86config->conf_flags = configureFlagsSection();
+ xf86config->conf_videoadaptor_lst = NULL;
+ xf86config->conf_modes_lst = NULL;
+ xf86config->conf_vendor_lst = NULL;
+ xf86config->conf_dri = NULL;
+ xf86config->conf_input_lst = configureInputSection();
+ xf86config->conf_layout_lst = configureLayoutSection();
+
+ home = getenv("HOME");
+ if ((home == NULL) || (home[0] == '\0')) {
+ home = "/";
+ } else {
+ /* Determine if trailing slash is present or needed */
+ int l = strlen(home);
+
+ if (home[l-1] != '/') {
+ addslash = "/";
+ }
+ }
+
+ snprintf(filename, sizeof(filename), "%s%s" XF86CONFIGFILE ".new",
+ home, addslash);
+
+ if (xf86writeConfigFile(filename, xf86config) == 0) {
+ xf86Msg(X_ERROR, "Unable to write config file: \"%s\": %s\n",
+ filename, strerror(errno));
+ goto bail;
+ }
+
+ xf86DoConfigurePass1 = FALSE;
+ /* Try to get DDC information filled in */
+ xf86ConfigFile = filename;
+ if (xf86HandleConfigFile(FALSE) != CONFIG_OK) {
+ goto bail;
+ }
+
+ xf86DoConfigurePass1 = FALSE;
+
+ dev2screen = xnfcalloc(1,xf86NumDrivers*sizeof(int));
+
+ {
+ Bool *driverProbed = xnfcalloc(1,xf86NumDrivers*sizeof(Bool));
+ for (screennum = 0; screennum < nDevToConfig; screennum++) {
+ int k,l,n,oldNumScreens;
+
+ i = DevToConfig[screennum].iDriver;
+
+ if (driverProbed[i]) continue;
+ driverProbed[i] = TRUE;
+
+ oldNumScreens = xf86NumScreens;
+
+ xf86CallDriverProbe( xf86DriverList[i], FALSE );
+
+ /* reorder */
+ k = screennum > 0 ? screennum : 1;
+ for (l = oldNumScreens; l < xf86NumScreens; l++) {
+ /* is screen primary? */
+ Bool primary = FALSE;
+ for (n = 0; n<xf86Screens[l]->numEntities; n++) {
+ if (xf86IsEntityPrimary(xf86Screens[l]->entityList[n])) {
+ dev2screen[0] = l;
+ primary = TRUE;
+ break;
+ }
+ }
+ if (primary) continue;
+ /* not primary: assign it to next device of same driver */
+ /*
+ * NOTE: we assume that devices in DevToConfig
+ * and xf86Screens[] have the same order except
+ * for the primary device which always comes first.
+ */
+ for (; k < nDevToConfig; k++) {
+ if (DevToConfig[k].iDriver == i) {
+ dev2screen[k++] = l;
+ break;
+ }
+ }
+ }
+ }
+ free(driverProbed);
+ }
+
+
+ if (nDevToConfig != xf86NumScreens) {
+ ErrorF("Number of created screens does not match number of detected"
+ " devices.\n Configuration failed.\n");
+ goto bail;
+ }
+
+ xf86PostProbe();
+
+ for (j = 0; j < xf86NumScreens; j++) {
+ xf86Screens[j]->scrnIndex = j;
+ }
+
+ xf86freeMonitorList(xf86config->conf_monitor_lst);
+ xf86config->conf_monitor_lst = NULL;
+ xf86freeScreenList(xf86config->conf_screen_lst);
+ xf86config->conf_screen_lst = NULL;
+ for (j = 0; j < xf86NumScreens; j++) {
+ XF86ConfMonitorPtr MonitorPtr;
+ XF86ConfScreenPtr ScreenPtr;
+
+ ConfiguredMonitor = NULL;
+
+ if ((*xf86Screens[dev2screen[j]]->PreInit)(xf86Screens[dev2screen[j]],
+ PROBE_DETECT) &&
+ ConfiguredMonitor) {
+ MonitorPtr = configureDDCMonitorSection(j);
+ } else {
+ MonitorPtr = configureMonitorSection(j);
+ }
+ ScreenPtr = configureScreenSection(j);
+ xf86config->conf_monitor_lst = (XF86ConfMonitorPtr)xf86addListItem(
+ (glp)xf86config->conf_monitor_lst, (glp)MonitorPtr);
+ xf86config->conf_screen_lst = (XF86ConfScreenPtr)xf86addListItem(
+ (glp)xf86config->conf_screen_lst, (glp)ScreenPtr);
+ }
+
+ if (xf86writeConfigFile(filename, xf86config) == 0) {
+ xf86Msg(X_ERROR, "Unable to write config file: \"%s\": %s\n",
+ filename, strerror(errno));
+ goto bail;
+ }
+
+ ErrorF("\n");
+
+ if (!foundMouse) {
+ ErrorF("\n"__XSERVERNAME__" is not able to detect your mouse.\n"
+ "Edit the file and correct the Device.\n");
+ } else {
+ ErrorF("\n"__XSERVERNAME__" detected your mouse at device %s.\n"
+ "Please check your config if the mouse is still not\n"
+ "operational, as by default "__XSERVERNAME__
+ " tries to autodetect\n"
+ "the protocol.\n",DFLT_MOUSE_DEV);
+ }
+
+ if (xf86NumScreens > 1) {
+ ErrorF("\n"__XSERVERNAME__
+ " has configured a multihead system, please check your config.\n");
+ }
+
+ ErrorF("\nYour %s file is %s\n\n", XF86CONFIGFILE ,filename);
+ ErrorF("To test the server, run 'X -config %s'\n\n", filename);
+
+bail:
+ OsCleanup(TRUE);
+ AbortDDX();
+ fflush(stderr);
+ exit(0);
+}
diff --git a/xorg-server/hw/xfree86/common/xf86Cursor.c b/xorg-server/hw/xfree86/common/xf86Cursor.c
index acfa79f10..929f047cc 100644
--- a/xorg-server/hw/xfree86/common/xf86Cursor.c
+++ b/xorg-server/hw/xfree86/common/xf86Cursor.c
@@ -1,860 +1,860 @@
-/*
- * Copyright (c) 1994-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 <X11/Xmd.h>
-#include "input.h"
-#include "cursor.h"
-#include "mipointer.h"
-#include "scrnintstr.h"
-#include "globals.h"
-
-#include "compiler.h"
-
-#include "xf86.h"
-#include "xf86Priv.h"
-#include "xf86_OSproc.h"
-
-#include <X11/extensions/XIproto.h>
-#include "xf86Xinput.h"
-
-#ifdef XFreeXDGA
-#include "dgaproc.h"
-#endif
-
-typedef struct _xf86EdgeRec {
- short screen;
- short start;
- short end;
- DDXPointRec offset;
- struct _xf86EdgeRec *next;
-} xf86EdgeRec, *xf86EdgePtr;
-
-typedef struct {
- xf86EdgePtr left, right, up, down;
-} xf86ScreenLayoutRec, *xf86ScreenLayoutPtr;
-
-static Bool xf86CursorOffScreen(ScreenPtr *pScreen, int *x, int *y);
-static void xf86CrossScreen(ScreenPtr pScreen, Bool entering);
-static void xf86WarpCursor(DeviceIntPtr pDev, ScreenPtr pScreen, int x, int y);
-
-static void xf86PointerMoved(int scrnIndex, int x, int y);
-
-static miPointerScreenFuncRec xf86PointerScreenFuncs = {
- xf86CursorOffScreen,
- xf86CrossScreen,
- xf86WarpCursor,
- /* let miPointerInitialize take care of these */
- NULL,
- NULL
-};
-
-static xf86ScreenLayoutRec xf86ScreenLayout[MAXSCREENS];
-
-static Bool HardEdges;
-
-/*
- * xf86InitViewport --
- * Initialize paning & zooming parameters, so that a driver must only
- * check what resolutions are possible and whether the virtual area
- * is valid if specified.
- */
-
-void
-xf86InitViewport(ScrnInfoPtr pScr)
-{
-
- pScr->PointerMoved = xf86PointerMoved;
-
- /*
- * Compute the initial Viewport if necessary
- */
- if (pScr->display) {
- if (pScr->display->frameX0 < 0) {
- pScr->frameX0 = (pScr->virtualX - pScr->modes->HDisplay) / 2;
- pScr->frameY0 = (pScr->virtualY - pScr->modes->VDisplay) / 2;
- } else {
- pScr->frameX0 = pScr->display->frameX0;
- pScr->frameY0 = pScr->display->frameY0;
- }
- }
-
- pScr->frameX1 = pScr->frameX0 + pScr->modes->HDisplay - 1;
- pScr->frameY1 = pScr->frameY0 + pScr->modes->VDisplay - 1;
-
- /*
- * Now adjust the initial Viewport, so it lies within the virtual area
- */
- if (pScr->frameX1 >= pScr->virtualX)
- {
- pScr->frameX0 = pScr->virtualX - pScr->modes->HDisplay;
- pScr->frameX1 = pScr->frameX0 + pScr->modes->HDisplay - 1;
- }
-
- if (pScr->frameY1 >= pScr->virtualY)
- {
- pScr->frameY0 = pScr->virtualY - pScr->modes->VDisplay;
- pScr->frameY1 = pScr->frameY0 + pScr->modes->VDisplay - 1;
- }
-}
-
-
-/*
- * xf86SetViewport --
- * Scroll the visual part of the screen so the pointer is visible.
- */
-
-void
-xf86SetViewport(ScreenPtr pScreen, int x, int y)
-{
- ScrnInfoPtr pScr = XF86SCRNINFO(pScreen);
-
- (*pScr->PointerMoved)(pScreen->myNum, x, y);
-}
-
-
-static void
-xf86PointerMoved(int scrnIndex, int x, int y)
-{
- Bool frameChanged = FALSE;
- ScrnInfoPtr pScr = xf86Screens[scrnIndex];
-
- /*
- * check wether (x,y) belongs to the visual part of the screen
- * if not, change the base of the displayed frame accoring
- */
- if ( pScr->frameX0 > x) {
- pScr->frameX0 = x;
- pScr->frameX1 = x + pScr->currentMode->HDisplay - 1;
- frameChanged = TRUE ;
- }
-
- if ( pScr->frameX1 < x) {
- pScr->frameX1 = x + 1;
- pScr->frameX0 = x - pScr->currentMode->HDisplay + 1;
- frameChanged = TRUE ;
- }
-
- if ( pScr->frameY0 > y) {
- pScr->frameY0 = y;
- pScr->frameY1 = y + pScr->currentMode->VDisplay - 1;
- frameChanged = TRUE;
- }
-
- if ( pScr->frameY1 < y) {
- pScr->frameY1 = y;
- pScr->frameY0 = y - pScr->currentMode->VDisplay + 1;
- frameChanged = TRUE;
- }
-
- if (frameChanged && pScr->AdjustFrame != NULL)
- pScr->AdjustFrame(pScr->scrnIndex, pScr->frameX0, pScr->frameY0, 0);
-}
-
-/*
- * xf86LockZoom --
- * Enable/disable ZoomViewport
- */
-
-void
-xf86LockZoom(ScreenPtr pScreen, Bool lock)
-{
- XF86SCRNINFO(pScreen)->zoomLocked = lock;
-}
-
-/*
- * xf86SwitchMode --
- * This is called by both keyboard processing and the VidMode extension to
- * set a new mode.
- */
-
-Bool
-xf86SwitchMode(ScreenPtr pScreen, DisplayModePtr mode)
-{
- ScrnInfoPtr pScr = XF86SCRNINFO(pScreen);
- ScreenPtr pCursorScreen;
- Bool Switched;
- int px, py;
- DeviceIntPtr dev, it;
-
- if (!pScr->vtSema || !mode || !pScr->SwitchMode)
- return FALSE;
-
-#ifdef XFreeXDGA
- if (DGAActive(pScr->scrnIndex))
- return FALSE;
-#endif
-
- if (mode == pScr->currentMode)
- return TRUE;
-
- if (mode->HDisplay > pScr->virtualX || mode->VDisplay > pScr->virtualY)
- return FALSE;
-
- /* Let's take an educated guess for which pointer to take here. And about as
- educated as it gets is to take the first pointer we find.
- */
- for (dev = inputInfo.devices; dev; dev = dev->next)
- {
- if (IsPointerDevice(dev) && dev->spriteInfo->spriteOwner)
- break;
- }
-
- pCursorScreen = miPointerGetScreen(dev);
- if (pScreen == pCursorScreen)
- miPointerGetPosition(dev, &px, &py);
-
- xf86EnterServerState(SETUP);
- Switched = (*pScr->SwitchMode)(pScr->scrnIndex, mode, 0);
- if (Switched) {
- pScr->currentMode = mode;
-
- /*
- * Adjust frame for new display size.
- * Frame is centered around cursor position if cursor is on same screen.
- */
- if (pScreen == pCursorScreen)
- pScr->frameX0 = px - (mode->HDisplay / 2) + 1;
- else
- pScr->frameX0 = (pScr->frameX0 + pScr->frameX1 + 1 - mode->HDisplay) / 2;
-
- if (pScr->frameX0 < 0)
- pScr->frameX0 = 0;
-
- pScr->frameX1 = pScr->frameX0 + mode->HDisplay - 1;
- if (pScr->frameX1 >= pScr->virtualX) {
- pScr->frameX0 = pScr->virtualX - mode->HDisplay;
- pScr->frameX1 = pScr->virtualX - 1;
- }
-
- if (pScreen == pCursorScreen)
- pScr->frameY0 = py - (mode->VDisplay / 2) + 1;
- else
- pScr->frameY0 = (pScr->frameY0 + pScr->frameY1 + 1 - mode->VDisplay) / 2;
-
- if (pScr->frameY0 < 0)
- pScr->frameY0 = 0;
-
- pScr->frameY1 = pScr->frameY0 + mode->VDisplay - 1;
- if (pScr->frameY1 >= pScr->virtualY) {
- pScr->frameY0 = pScr->virtualY - mode->VDisplay;
- pScr->frameY1 = pScr->virtualY - 1;
- }
- }
- xf86EnterServerState(OPERATING);
-
- if (pScr->AdjustFrame)
- (*pScr->AdjustFrame)(pScr->scrnIndex, pScr->frameX0, pScr->frameY0, 0);
-
- /* The original code centered the frame around the cursor if possible.
- * Since this is hard to achieve with multiple cursors, we do the following:
- * - center around the first pointer
- * - move all other pointers to the nearest edge on the screen (or leave
- * them unmodified if they are within the boundaries).
- */
- if (pScreen == pCursorScreen)
- {
- xf86WarpCursor(dev, pScreen, px, py);
- }
-
- for (it = inputInfo.devices; it; it = it->next)
- {
- if (it == dev)
- continue;
-
- if (IsPointerDevice(it) && it->spriteInfo->spriteOwner)
- {
- pCursorScreen = miPointerGetScreen(it);
- if (pScreen == pCursorScreen)
- {
- miPointerGetPosition(it, &px, &py);
- if (px < pScr->frameX0)
- px = pScr->frameX0;
- else if (px > pScr->frameX1)
- px = pScr->frameX1;
-
- if(py < pScr->frameY0)
- py = pScr->frameY0;
- else if(py > pScr->frameY1)
- py = pScr->frameY1;
-
- xf86WarpCursor(it, pScreen, px, py);
- }
- }
- }
-
- return Switched;
-}
-
-/*
- * xf86ZoomViewport --
- * Reinitialize the visual part of the screen for another mode.
- */
-
-void
-xf86ZoomViewport(ScreenPtr pScreen, int zoom)
-{
- ScrnInfoPtr pScr = XF86SCRNINFO(pScreen);
- DisplayModePtr mode;
-
- if (pScr->zoomLocked || !(mode = pScr->currentMode))
- return;
-
- do {
- if (zoom > 0)
- mode = mode->next;
- else
- mode = mode->prev;
- } while (mode != pScr->currentMode && !(mode->type & M_T_USERDEF));
-
- (void)xf86SwitchMode(pScreen, mode);
-}
-
-
-static xf86EdgePtr
-FindEdge(xf86EdgePtr edge, int val)
-{
- while(edge && (edge->end <= val))
- edge = edge->next;
-
- if(edge && (edge->start <= val))
- return edge;
-
- return NULL;
-}
-
-/*
- * xf86CursorOffScreen --
- * Check whether it is necessary to switch to another screen
- */
-
-static Bool
-xf86CursorOffScreen(ScreenPtr *pScreen, int *x, int *y)
-{
- xf86EdgePtr edge;
- int tmp;
-
- if(screenInfo.numScreens == 1)
- return FALSE;
-
- if(*x < 0) {
- tmp = *y;
- if(tmp < 0) tmp = 0;
- if(tmp >= (*pScreen)->height) tmp = (*pScreen)->height - 1;
-
- if((edge = xf86ScreenLayout[(*pScreen)->myNum].left))
- edge = FindEdge(edge, tmp);
-
- if(!edge) *x = 0;
- else {
- *x += edge->offset.x;
- *y += edge->offset.y;
- *pScreen = xf86Screens[edge->screen]->pScreen;
- }
- }
-
- if(*x >= (*pScreen)->width) {
- tmp = *y;
- if(tmp < 0) tmp = 0;
- if(tmp >= (*pScreen)->height) tmp = (*pScreen)->height - 1;
-
- if((edge = xf86ScreenLayout[(*pScreen)->myNum].right))
- edge = FindEdge(edge, tmp);
-
- if(!edge) *x = (*pScreen)->width - 1;
- else {
- *x += edge->offset.x;
- *y += edge->offset.y;
- *pScreen = xf86Screens[edge->screen]->pScreen;
- }
- }
-
- if(*y < 0) {
- tmp = *x;
- if(tmp < 0) tmp = 0;
- if(tmp >= (*pScreen)->width) tmp = (*pScreen)->width - 1;
-
- if((edge = xf86ScreenLayout[(*pScreen)->myNum].up))
- edge = FindEdge(edge, tmp);
-
- if(!edge) *y = 0;
- else {
- *x += edge->offset.x;
- *y += edge->offset.y;
- *pScreen = xf86Screens[edge->screen]->pScreen;
- }
- }
-
- if(*y >= (*pScreen)->height) {
- tmp = *x;
- if(tmp < 0) tmp = 0;
- if(tmp >= (*pScreen)->width) tmp = (*pScreen)->width - 1;
-
- if((edge = xf86ScreenLayout[(*pScreen)->myNum].down))
- edge = FindEdge(edge, tmp);
-
- if(!edge) *y = (*pScreen)->height - 1;
- else {
- *x += edge->offset.x;
- *y += edge->offset.y;
- (*pScreen) = xf86Screens[edge->screen]->pScreen;
- }
- }
-
-
-#if 0
- /* This presents problems for overlapping screens when
- HardEdges is used. Have to think about the logic more */
- if((*x < 0) || (*x >= (*pScreen)->width) ||
- (*y < 0) || (*y >= (*pScreen)->height)) {
- /* We may have crossed more than one screen */
- xf86CursorOffScreen(pScreen, x, y);
- }
-#endif
-
- return TRUE;
-}
-
-
-
-/*
- * xf86CrossScreen --
- * Switch to another screen
- *
- * Currently nothing special happens, but mi assumes the CrossScreen
- * method exists.
- */
-
-static void
-xf86CrossScreen (ScreenPtr pScreen, Bool entering)
-{
-}
-
-
-/*
- * xf86WarpCursor --
- * Warp possible to another screen
- */
-
-/* ARGSUSED */
-static void
-xf86WarpCursor (DeviceIntPtr pDev, ScreenPtr pScreen, int x, int y)
-{
- int sigstate;
- sigstate = xf86BlockSIGIO ();
- miPointerWarpCursor(pDev, pScreen, x, y);
-
- xf86Info.currentScreen = pScreen;
- xf86UnblockSIGIO (sigstate);
-}
-
-
-void *
-xf86GetPointerScreenFuncs(void)
-{
- return (void *)&xf86PointerScreenFuncs;
-}
-
-
-static xf86EdgePtr
-AddEdge(
- xf86EdgePtr edge,
- short min,
- short max,
- short dx,
- short dy,
- short screen
-){
- xf86EdgePtr pEdge = edge, pPrev = NULL, pNew;
-
- while(1) {
- while(pEdge && (min >= pEdge->end)) {
- pPrev = pEdge;
- pEdge = pEdge->next;
- }
-
- if(!pEdge) {
- if(!(pNew = malloc(sizeof(xf86EdgeRec))))
- break;
-
- pNew->screen = screen;
- pNew->start = min;
- pNew->end = max;
- pNew->offset.x = dx;
- pNew->offset.y = dy;
- pNew->next = NULL;
-
- if(pPrev)
- pPrev->next = pNew;
- else
- edge = pNew;
-
- break;
- } else if (min < pEdge->start) {
- if(!(pNew = malloc(sizeof(xf86EdgeRec))))
- break;
-
- pNew->screen = screen;
- pNew->start = min;
- pNew->offset.x = dx;
- pNew->offset.y = dy;
- pNew->next = pEdge;
-
- if(pPrev) pPrev->next = pNew;
- else edge = pNew;
-
- if(max <= pEdge->start) {
- pNew->end = max;
- break;
- } else {
- pNew->end = pEdge->start;
- min = pEdge->end;
- }
- } else
- min = pEdge->end;
-
- pPrev = pEdge;
- pEdge = pEdge->next;
-
- if(max <= min) break;
- }
-
- return edge;
-}
-
-static void
-FillOutEdge(xf86EdgePtr pEdge, int limit)
-{
- xf86EdgePtr pNext;
- int diff;
-
- if(pEdge->start > 0) pEdge->start = 0;
-
- while((pNext = pEdge->next)) {
- diff = pNext->start - pEdge->end;
- if(diff > 0) {
- pEdge->end += diff >> 1;
- pNext->start -= diff - (diff >> 1);
- }
- pEdge = pNext;
- }
-
- if(pEdge->end < limit)
- pEdge->end = limit;
-}
-
-/*
- * xf86InitOrigins() can deal with a maximum of 32 screens
- * on 32 bit architectures, 64 on 64 bit architectures.
- */
-
-void
-xf86InitOrigins(void)
-{
- unsigned long screensLeft, prevScreensLeft, mask;
- screenLayoutPtr screen;
- ScreenPtr pScreen, refScreen;
- int x1, x2, y1, y2, left, right, top, bottom;
- int i, j, ref, minX, minY, min, max;
- xf86ScreenLayoutPtr pLayout;
- Bool OldStyleConfig = FALSE;
-
- /* need to have this set up with a config file option */
- HardEdges = FALSE;
-
- memset(xf86ScreenLayout, 0, MAXSCREENS * sizeof(xf86ScreenLayoutRec));
-
- screensLeft = prevScreensLeft = (1 << xf86NumScreens) - 1;
-
- while(1) {
- for(mask = screensLeft, i = 0; mask; mask >>= 1, i++) {
- if(!(mask & 1L)) continue;
-
- screen = &xf86ConfigLayout.screens[i];
-
- if (screen->refscreen != NULL &&
- screen->refscreen->screennum >= xf86NumScreens) {
- screensLeft &= ~(1 << i);
- xf86Msg(X_WARNING, "Not including screen \"%s\" in origins calculation.\n",
- screen->screen->id);
- continue;
- }
-
- pScreen = xf86Screens[i]->pScreen;
- switch(screen->where) {
- case PosObsolete:
- OldStyleConfig = TRUE;
- pLayout = &xf86ScreenLayout[i];
- /* force edge lists */
- if(screen->left) {
- ref = screen->left->screennum;
- if (! xf86Screens[ref] || ! xf86Screens[ref]->pScreen) {
- ErrorF("Referenced uninitialized screen in Layout!\n");
- break;
- }
- pLayout->left = AddEdge(pLayout->left,
- 0, pScreen->height,
- xf86Screens[ref]->pScreen->width, 0, ref);
- }
- if(screen->right) {
- ref = screen->right->screennum;
- if (! xf86Screens[ref] || ! xf86Screens[ref]->pScreen) {
- ErrorF("Referenced uninitialized screen in Layout!\n");
- break;
- }
- pLayout->right = AddEdge(pLayout->right,
- 0, pScreen->height, -pScreen->width, 0, ref);
- }
- if(screen->top) {
- ref = screen->top->screennum;
- if (! xf86Screens[ref] || ! xf86Screens[ref]->pScreen) {
- ErrorF("Referenced uninitialized screen in Layout!\n");
- break;
- }
- pLayout->up = AddEdge(pLayout->up,
- 0, pScreen->width,
- 0, xf86Screens[ref]->pScreen->height, ref);
- }
- if(screen->bottom) {
- ref = screen->bottom->screennum;
- if (! xf86Screens[ref] || ! xf86Screens[ref]->pScreen) {
- ErrorF("Referenced uninitialized screen in Layout!\n");
- break;
- }
- pLayout->down = AddEdge(pLayout->down,
- 0, pScreen->width, 0, -pScreen->height, ref);
- }
- /* we could also try to place it based on those
- relative locations if we wanted to */
- screen->x = screen->y = 0;
- /* FALLTHROUGH */
- case PosAbsolute:
- pScreen->x = screen->x;
- pScreen->y = screen->y;
- screensLeft &= ~(1 << i);
- break;
- case PosRelative:
- ref = screen->refscreen->screennum;
- if (! xf86Screens[ref] || ! xf86Screens[ref]->pScreen) {
- ErrorF("Referenced uninitialized screen in Layout!\n");
- break;
- }
- if(screensLeft & (1 << ref)) break;
- refScreen = xf86Screens[ref]->pScreen;
- pScreen->x = refScreen->x + screen->x;
- pScreen->y = refScreen->y + screen->y;
- screensLeft &= ~(1 << i);
- break;
- case PosRightOf:
- ref = screen->refscreen->screennum;
- if (! xf86Screens[ref] || ! xf86Screens[ref]->pScreen) {
- ErrorF("Referenced uninitialized screen in Layout!\n");
- break;
- }
- if(screensLeft & (1 << ref)) break;
- refScreen = xf86Screens[ref]->pScreen;
- pScreen->x = refScreen->x + refScreen->width;
- pScreen->y = refScreen->y;
- screensLeft &= ~(1 << i);
- break;
- case PosLeftOf:
- ref = screen->refscreen->screennum;
- if (! xf86Screens[ref] || ! xf86Screens[ref]->pScreen) {
- ErrorF("Referenced uninitialized screen in Layout!\n");
- break;
- }
- if(screensLeft & (1 << ref)) break;
- refScreen = xf86Screens[ref]->pScreen;
- pScreen->x = refScreen->x - pScreen->width;
- pScreen->y = refScreen->y;
- screensLeft &= ~(1 << i);
- break;
- case PosBelow:
- ref = screen->refscreen->screennum;
- if (! xf86Screens[ref] || ! xf86Screens[ref]->pScreen) {
- ErrorF("Referenced uninitialized screen in Layout!\n");
- break;
- }
- if(screensLeft & (1 << ref)) break;
- refScreen = xf86Screens[ref]->pScreen;
- pScreen->x = refScreen->x;
- pScreen->y = refScreen->y + refScreen->height;
- screensLeft &= ~(1 << i);
- break;
- case PosAbove:
- ref = screen->refscreen->screennum;
- if (! xf86Screens[ref] || ! xf86Screens[ref]->pScreen) {
- ErrorF("Referenced uninitialized screen in Layout!\n");
- break;
- }
- if(screensLeft & (1 << ref)) break;
- refScreen = xf86Screens[ref]->pScreen;
- pScreen->x = refScreen->x;
- pScreen->y = refScreen->y - pScreen->height;
- screensLeft &= ~(1 << i);
- break;
- default:
- ErrorF("Illegal placement keyword in Layout!\n");
- break;
- }
-
- }
-
- if(!screensLeft) break;
-
- if(screensLeft == prevScreensLeft) {
- /* All the remaining screens are referencing each other.
- Assign a value to one of them and go through again */
- i = 0;
- while(!((1 << i) & screensLeft)){ i++; }
-
- ref = xf86ConfigLayout.screens[i].refscreen->screennum;
- xf86Screens[ref]->pScreen->x = xf86Screens[ref]->pScreen->y = 0;
- screensLeft &= ~(1 << ref);
- }
-
- prevScreensLeft = screensLeft;
- }
-
- /* justify the topmost and leftmost to (0,0) */
- minX = xf86Screens[0]->pScreen->x;
- minY = xf86Screens[0]->pScreen->y;
-
- for(i = 1; i < xf86NumScreens; i++) {
- if(xf86Screens[i]->pScreen->x < minX)
- minX = xf86Screens[i]->pScreen->x;
- if(xf86Screens[i]->pScreen->y < minY)
- minY = xf86Screens[i]->pScreen->y;
- }
-
- if (minX || minY) {
- for(i = 0; i < xf86NumScreens; i++) {
- xf86Screens[i]->pScreen->x -= minX;
- xf86Screens[i]->pScreen->y -= minY;
- }
- }
-
-
- /* Create the edge lists */
-
- if(!OldStyleConfig) {
- for(i = 0; i < xf86NumScreens; i++) {
- pLayout = &xf86ScreenLayout[i];
-
- pScreen = xf86Screens[i]->pScreen;
-
- left = pScreen->x;
- right = left + pScreen->width;
- top = pScreen->y;
- bottom = top + pScreen->height;
-
- for(j = 0; j < xf86NumScreens; j++) {
- if(i == j) continue;
-
- refScreen = xf86Screens[j]->pScreen;
-
- x1 = refScreen->x;
- x2 = x1 + refScreen->width;
- y1 = refScreen->y;
- y2 = y1 + refScreen->height;
-
- if((bottom > y1) && (top < y2)) {
- min = y1 - top;
- if(min < 0) min = 0;
- max = pScreen->height - (bottom - y2);
- if(max > pScreen->height) max = pScreen->height;
-
- if(((left - 1) >= x1) && ((left - 1) < x2))
- pLayout->left = AddEdge(pLayout->left, min, max,
- pScreen->x - refScreen->x,
- pScreen->y - refScreen->y, j);
-
- if((right >= x1) && (right < x2))
- pLayout->right = AddEdge(pLayout->right, min, max,
- pScreen->x - refScreen->x,
- pScreen->y - refScreen->y, j);
- }
-
-
- if((left < x2) && (right > x1)) {
- min = x1 - left;
- if(min < 0) min = 0;
- max = pScreen->width - (right - x2);
- if(max > pScreen->width) max = pScreen->width;
-
- if(((top - 1) >= y1) && ((top - 1) < y2))
- pLayout->up = AddEdge(pLayout->up, min, max,
- pScreen->x - refScreen->x,
- pScreen->y - refScreen->y, j);
-
- if((bottom >= y1) && (bottom < y2))
- pLayout->down = AddEdge(pLayout->down, min, max,
- pScreen->x - refScreen->x,
- pScreen->y - refScreen->y, j);
- }
- }
- }
- }
-
- if(!HardEdges && !OldStyleConfig) {
- for(i = 0; i < xf86NumScreens; i++) {
- pLayout = &xf86ScreenLayout[i];
- pScreen = xf86Screens[i]->pScreen;
- if(pLayout->left)
- FillOutEdge(pLayout->left, pScreen->height);
- if(pLayout->right)
- FillOutEdge(pLayout->right, pScreen->height);
- if(pLayout->up)
- FillOutEdge(pLayout->up, pScreen->width);
- if(pLayout->down)
- FillOutEdge(pLayout->down, pScreen->width);
- }
- }
-}
-
-void
-xf86ReconfigureLayout(void)
-{
- int i;
-
- for (i = 0; i < MAXSCREENS; i++) {
- xf86ScreenLayoutPtr sl = &xf86ScreenLayout[i];
- /* we don't have to zero these, xf86InitOrigins() takes care of that */
- free(sl->left);
- free(sl->right);
- free(sl->up);
- free(sl->down);
- }
-
- xf86InitOrigins();
-}
-
-
+/*
+ * Copyright (c) 1994-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 <X11/Xmd.h>
+#include "input.h"
+#include "cursor.h"
+#include "mipointer.h"
+#include "scrnintstr.h"
+#include "globals.h"
+
+#include "compiler.h"
+
+#include "xf86.h"
+#include "xf86Priv.h"
+#include "xf86_OSproc.h"
+
+#include <X11/extensions/XIproto.h>
+#include "xf86Xinput.h"
+
+#ifdef XFreeXDGA
+#include "dgaproc.h"
+#endif
+
+typedef struct _xf86EdgeRec {
+ short screen;
+ short start;
+ short end;
+ DDXPointRec offset;
+ struct _xf86EdgeRec *next;
+} xf86EdgeRec, *xf86EdgePtr;
+
+typedef struct {
+ xf86EdgePtr left, right, up, down;
+} xf86ScreenLayoutRec, *xf86ScreenLayoutPtr;
+
+static Bool xf86CursorOffScreen(ScreenPtr *pScreen, int *x, int *y);
+static void xf86CrossScreen(ScreenPtr pScreen, Bool entering);
+static void xf86WarpCursor(DeviceIntPtr pDev, ScreenPtr pScreen, int x, int y);
+
+static void xf86PointerMoved(int scrnIndex, int x, int y);
+
+static miPointerScreenFuncRec xf86PointerScreenFuncs = {
+ xf86CursorOffScreen,
+ xf86CrossScreen,
+ xf86WarpCursor,
+ /* let miPointerInitialize take care of these */
+ NULL,
+ NULL
+};
+
+static xf86ScreenLayoutRec xf86ScreenLayout[MAXSCREENS];
+
+static Bool HardEdges;
+
+/*
+ * xf86InitViewport --
+ * Initialize paning & zooming parameters, so that a driver must only
+ * check what resolutions are possible and whether the virtual area
+ * is valid if specified.
+ */
+
+void
+xf86InitViewport(ScrnInfoPtr pScr)
+{
+
+ pScr->PointerMoved = xf86PointerMoved;
+
+ /*
+ * Compute the initial Viewport if necessary
+ */
+ if (pScr->display) {
+ if (pScr->display->frameX0 < 0) {
+ pScr->frameX0 = (pScr->virtualX - pScr->modes->HDisplay) / 2;
+ pScr->frameY0 = (pScr->virtualY - pScr->modes->VDisplay) / 2;
+ } else {
+ pScr->frameX0 = pScr->display->frameX0;
+ pScr->frameY0 = pScr->display->frameY0;
+ }
+ }
+
+ pScr->frameX1 = pScr->frameX0 + pScr->modes->HDisplay - 1;
+ pScr->frameY1 = pScr->frameY0 + pScr->modes->VDisplay - 1;
+
+ /*
+ * Now adjust the initial Viewport, so it lies within the virtual area
+ */
+ if (pScr->frameX1 >= pScr->virtualX)
+ {
+ pScr->frameX0 = pScr->virtualX - pScr->modes->HDisplay;
+ pScr->frameX1 = pScr->frameX0 + pScr->modes->HDisplay - 1;
+ }
+
+ if (pScr->frameY1 >= pScr->virtualY)
+ {
+ pScr->frameY0 = pScr->virtualY - pScr->modes->VDisplay;
+ pScr->frameY1 = pScr->frameY0 + pScr->modes->VDisplay - 1;
+ }
+}
+
+
+/*
+ * xf86SetViewport --
+ * Scroll the visual part of the screen so the pointer is visible.
+ */
+
+void
+xf86SetViewport(ScreenPtr pScreen, int x, int y)
+{
+ ScrnInfoPtr pScr = XF86SCRNINFO(pScreen);
+
+ (*pScr->PointerMoved)(pScreen->myNum, x, y);
+}
+
+
+static void
+xf86PointerMoved(int scrnIndex, int x, int y)
+{
+ Bool frameChanged = FALSE;
+ ScrnInfoPtr pScr = xf86Screens[scrnIndex];
+
+ /*
+ * check wether (x,y) belongs to the visual part of the screen
+ * if not, change the base of the displayed frame accoring
+ */
+ if ( pScr->frameX0 > x) {
+ pScr->frameX0 = x;
+ pScr->frameX1 = x + pScr->currentMode->HDisplay - 1;
+ frameChanged = TRUE ;
+ }
+
+ if ( pScr->frameX1 < x) {
+ pScr->frameX1 = x + 1;
+ pScr->frameX0 = x - pScr->currentMode->HDisplay + 1;
+ frameChanged = TRUE ;
+ }
+
+ if ( pScr->frameY0 > y) {
+ pScr->frameY0 = y;
+ pScr->frameY1 = y + pScr->currentMode->VDisplay - 1;
+ frameChanged = TRUE;
+ }
+
+ if ( pScr->frameY1 < y) {
+ pScr->frameY1 = y;
+ pScr->frameY0 = y - pScr->currentMode->VDisplay + 1;
+ frameChanged = TRUE;
+ }
+
+ if (frameChanged && pScr->AdjustFrame != NULL)
+ pScr->AdjustFrame(pScr->scrnIndex, pScr->frameX0, pScr->frameY0, 0);
+}
+
+/*
+ * xf86LockZoom --
+ * Enable/disable ZoomViewport
+ */
+
+void
+xf86LockZoom(ScreenPtr pScreen, Bool lock)
+{
+ XF86SCRNINFO(pScreen)->zoomLocked = lock;
+}
+
+/*
+ * xf86SwitchMode --
+ * This is called by both keyboard processing and the VidMode extension to
+ * set a new mode.
+ */
+
+Bool
+xf86SwitchMode(ScreenPtr pScreen, DisplayModePtr mode)
+{
+ ScrnInfoPtr pScr = XF86SCRNINFO(pScreen);
+ ScreenPtr pCursorScreen;
+ Bool Switched;
+ int px, py, was_blocked;
+ DeviceIntPtr dev, it;
+
+ if (!pScr->vtSema || !mode || !pScr->SwitchMode)
+ return FALSE;
+
+#ifdef XFreeXDGA
+ if (DGAActive(pScr->scrnIndex))
+ return FALSE;
+#endif
+
+ if (mode == pScr->currentMode)
+ return TRUE;
+
+ if (mode->HDisplay > pScr->virtualX || mode->VDisplay > pScr->virtualY)
+ return FALSE;
+
+ /* Let's take an educated guess for which pointer to take here. And about as
+ educated as it gets is to take the first pointer we find.
+ */
+ for (dev = inputInfo.devices; dev; dev = dev->next)
+ {
+ if (IsPointerDevice(dev) && dev->spriteInfo->spriteOwner)
+ break;
+ }
+
+ pCursorScreen = miPointerGetScreen(dev);
+ if (pScreen == pCursorScreen)
+ miPointerGetPosition(dev, &px, &py);
+
+ was_blocked = xf86BlockSIGIO();
+ Switched = (*pScr->SwitchMode)(pScr->scrnIndex, mode, 0);
+ if (Switched) {
+ pScr->currentMode = mode;
+
+ /*
+ * Adjust frame for new display size.
+ * Frame is centered around cursor position if cursor is on same screen.
+ */
+ if (pScreen == pCursorScreen)
+ pScr->frameX0 = px - (mode->HDisplay / 2) + 1;
+ else
+ pScr->frameX0 = (pScr->frameX0 + pScr->frameX1 + 1 - mode->HDisplay) / 2;
+
+ if (pScr->frameX0 < 0)
+ pScr->frameX0 = 0;
+
+ pScr->frameX1 = pScr->frameX0 + mode->HDisplay - 1;
+ if (pScr->frameX1 >= pScr->virtualX) {
+ pScr->frameX0 = pScr->virtualX - mode->HDisplay;
+ pScr->frameX1 = pScr->virtualX - 1;
+ }
+
+ if (pScreen == pCursorScreen)
+ pScr->frameY0 = py - (mode->VDisplay / 2) + 1;
+ else
+ pScr->frameY0 = (pScr->frameY0 + pScr->frameY1 + 1 - mode->VDisplay) / 2;
+
+ if (pScr->frameY0 < 0)
+ pScr->frameY0 = 0;
+
+ pScr->frameY1 = pScr->frameY0 + mode->VDisplay - 1;
+ if (pScr->frameY1 >= pScr->virtualY) {
+ pScr->frameY0 = pScr->virtualY - mode->VDisplay;
+ pScr->frameY1 = pScr->virtualY - 1;
+ }
+ }
+ xf86UnblockSIGIO(was_blocked);
+
+ if (pScr->AdjustFrame)
+ (*pScr->AdjustFrame)(pScr->scrnIndex, pScr->frameX0, pScr->frameY0, 0);
+
+ /* The original code centered the frame around the cursor if possible.
+ * Since this is hard to achieve with multiple cursors, we do the following:
+ * - center around the first pointer
+ * - move all other pointers to the nearest edge on the screen (or leave
+ * them unmodified if they are within the boundaries).
+ */
+ if (pScreen == pCursorScreen)
+ {
+ xf86WarpCursor(dev, pScreen, px, py);
+ }
+
+ for (it = inputInfo.devices; it; it = it->next)
+ {
+ if (it == dev)
+ continue;
+
+ if (IsPointerDevice(it) && it->spriteInfo->spriteOwner)
+ {
+ pCursorScreen = miPointerGetScreen(it);
+ if (pScreen == pCursorScreen)
+ {
+ miPointerGetPosition(it, &px, &py);
+ if (px < pScr->frameX0)
+ px = pScr->frameX0;
+ else if (px > pScr->frameX1)
+ px = pScr->frameX1;
+
+ if(py < pScr->frameY0)
+ py = pScr->frameY0;
+ else if(py > pScr->frameY1)
+ py = pScr->frameY1;
+
+ xf86WarpCursor(it, pScreen, px, py);
+ }
+ }
+ }
+
+ return Switched;
+}
+
+/*
+ * xf86ZoomViewport --
+ * Reinitialize the visual part of the screen for another mode.
+ */
+
+void
+xf86ZoomViewport(ScreenPtr pScreen, int zoom)
+{
+ ScrnInfoPtr pScr = XF86SCRNINFO(pScreen);
+ DisplayModePtr mode;
+
+ if (pScr->zoomLocked || !(mode = pScr->currentMode))
+ return;
+
+ do {
+ if (zoom > 0)
+ mode = mode->next;
+ else
+ mode = mode->prev;
+ } while (mode != pScr->currentMode && !(mode->type & M_T_USERDEF));
+
+ (void)xf86SwitchMode(pScreen, mode);
+}
+
+
+static xf86EdgePtr
+FindEdge(xf86EdgePtr edge, int val)
+{
+ while(edge && (edge->end <= val))
+ edge = edge->next;
+
+ if(edge && (edge->start <= val))
+ return edge;
+
+ return NULL;
+}
+
+/*
+ * xf86CursorOffScreen --
+ * Check whether it is necessary to switch to another screen
+ */
+
+static Bool
+xf86CursorOffScreen(ScreenPtr *pScreen, int *x, int *y)
+{
+ xf86EdgePtr edge;
+ int tmp;
+
+ if(screenInfo.numScreens == 1)
+ return FALSE;
+
+ if(*x < 0) {
+ tmp = *y;
+ if(tmp < 0) tmp = 0;
+ if(tmp >= (*pScreen)->height) tmp = (*pScreen)->height - 1;
+
+ if((edge = xf86ScreenLayout[(*pScreen)->myNum].left))
+ edge = FindEdge(edge, tmp);
+
+ if(!edge) *x = 0;
+ else {
+ *x += edge->offset.x;
+ *y += edge->offset.y;
+ *pScreen = xf86Screens[edge->screen]->pScreen;
+ }
+ }
+
+ if(*x >= (*pScreen)->width) {
+ tmp = *y;
+ if(tmp < 0) tmp = 0;
+ if(tmp >= (*pScreen)->height) tmp = (*pScreen)->height - 1;
+
+ if((edge = xf86ScreenLayout[(*pScreen)->myNum].right))
+ edge = FindEdge(edge, tmp);
+
+ if(!edge) *x = (*pScreen)->width - 1;
+ else {
+ *x += edge->offset.x;
+ *y += edge->offset.y;
+ *pScreen = xf86Screens[edge->screen]->pScreen;
+ }
+ }
+
+ if(*y < 0) {
+ tmp = *x;
+ if(tmp < 0) tmp = 0;
+ if(tmp >= (*pScreen)->width) tmp = (*pScreen)->width - 1;
+
+ if((edge = xf86ScreenLayout[(*pScreen)->myNum].up))
+ edge = FindEdge(edge, tmp);
+
+ if(!edge) *y = 0;
+ else {
+ *x += edge->offset.x;
+ *y += edge->offset.y;
+ *pScreen = xf86Screens[edge->screen]->pScreen;
+ }
+ }
+
+ if(*y >= (*pScreen)->height) {
+ tmp = *x;
+ if(tmp < 0) tmp = 0;
+ if(tmp >= (*pScreen)->width) tmp = (*pScreen)->width - 1;
+
+ if((edge = xf86ScreenLayout[(*pScreen)->myNum].down))
+ edge = FindEdge(edge, tmp);
+
+ if(!edge) *y = (*pScreen)->height - 1;
+ else {
+ *x += edge->offset.x;
+ *y += edge->offset.y;
+ (*pScreen) = xf86Screens[edge->screen]->pScreen;
+ }
+ }
+
+
+#if 0
+ /* This presents problems for overlapping screens when
+ HardEdges is used. Have to think about the logic more */
+ if((*x < 0) || (*x >= (*pScreen)->width) ||
+ (*y < 0) || (*y >= (*pScreen)->height)) {
+ /* We may have crossed more than one screen */
+ xf86CursorOffScreen(pScreen, x, y);
+ }
+#endif
+
+ return TRUE;
+}
+
+
+
+/*
+ * xf86CrossScreen --
+ * Switch to another screen
+ *
+ * Currently nothing special happens, but mi assumes the CrossScreen
+ * method exists.
+ */
+
+static void
+xf86CrossScreen (ScreenPtr pScreen, Bool entering)
+{
+}
+
+
+/*
+ * xf86WarpCursor --
+ * Warp possible to another screen
+ */
+
+/* ARGSUSED */
+static void
+xf86WarpCursor (DeviceIntPtr pDev, ScreenPtr pScreen, int x, int y)
+{
+ int sigstate;
+ sigstate = xf86BlockSIGIO ();
+ miPointerWarpCursor(pDev, pScreen, x, y);
+
+ xf86Info.currentScreen = pScreen;
+ xf86UnblockSIGIO (sigstate);
+}
+
+
+void *
+xf86GetPointerScreenFuncs(void)
+{
+ return (void *)&xf86PointerScreenFuncs;
+}
+
+
+static xf86EdgePtr
+AddEdge(
+ xf86EdgePtr edge,
+ short min,
+ short max,
+ short dx,
+ short dy,
+ short screen
+){
+ xf86EdgePtr pEdge = edge, pPrev = NULL, pNew;
+
+ while(1) {
+ while(pEdge && (min >= pEdge->end)) {
+ pPrev = pEdge;
+ pEdge = pEdge->next;
+ }
+
+ if(!pEdge) {
+ if(!(pNew = malloc(sizeof(xf86EdgeRec))))
+ break;
+
+ pNew->screen = screen;
+ pNew->start = min;
+ pNew->end = max;
+ pNew->offset.x = dx;
+ pNew->offset.y = dy;
+ pNew->next = NULL;
+
+ if(pPrev)
+ pPrev->next = pNew;
+ else
+ edge = pNew;
+
+ break;
+ } else if (min < pEdge->start) {
+ if(!(pNew = malloc(sizeof(xf86EdgeRec))))
+ break;
+
+ pNew->screen = screen;
+ pNew->start = min;
+ pNew->offset.x = dx;
+ pNew->offset.y = dy;
+ pNew->next = pEdge;
+
+ if(pPrev) pPrev->next = pNew;
+ else edge = pNew;
+
+ if(max <= pEdge->start) {
+ pNew->end = max;
+ break;
+ } else {
+ pNew->end = pEdge->start;
+ min = pEdge->end;
+ }
+ } else
+ min = pEdge->end;
+
+ pPrev = pEdge;
+ pEdge = pEdge->next;
+
+ if(max <= min) break;
+ }
+
+ return edge;
+}
+
+static void
+FillOutEdge(xf86EdgePtr pEdge, int limit)
+{
+ xf86EdgePtr pNext;
+ int diff;
+
+ if(pEdge->start > 0) pEdge->start = 0;
+
+ while((pNext = pEdge->next)) {
+ diff = pNext->start - pEdge->end;
+ if(diff > 0) {
+ pEdge->end += diff >> 1;
+ pNext->start -= diff - (diff >> 1);
+ }
+ pEdge = pNext;
+ }
+
+ if(pEdge->end < limit)
+ pEdge->end = limit;
+}
+
+/*
+ * xf86InitOrigins() can deal with a maximum of 32 screens
+ * on 32 bit architectures, 64 on 64 bit architectures.
+ */
+
+void
+xf86InitOrigins(void)
+{
+ unsigned long screensLeft, prevScreensLeft, mask;
+ screenLayoutPtr screen;
+ ScreenPtr pScreen, refScreen;
+ int x1, x2, y1, y2, left, right, top, bottom;
+ int i, j, ref, minX, minY, min, max;
+ xf86ScreenLayoutPtr pLayout;
+ Bool OldStyleConfig = FALSE;
+
+ /* need to have this set up with a config file option */
+ HardEdges = FALSE;
+
+ memset(xf86ScreenLayout, 0, MAXSCREENS * sizeof(xf86ScreenLayoutRec));
+
+ screensLeft = prevScreensLeft = (1 << xf86NumScreens) - 1;
+
+ while(1) {
+ for(mask = screensLeft, i = 0; mask; mask >>= 1, i++) {
+ if(!(mask & 1L)) continue;
+
+ screen = &xf86ConfigLayout.screens[i];
+
+ if (screen->refscreen != NULL &&
+ screen->refscreen->screennum >= xf86NumScreens) {
+ screensLeft &= ~(1 << i);
+ xf86Msg(X_WARNING, "Not including screen \"%s\" in origins calculation.\n",
+ screen->screen->id);
+ continue;
+ }
+
+ pScreen = xf86Screens[i]->pScreen;
+ switch(screen->where) {
+ case PosObsolete:
+ OldStyleConfig = TRUE;
+ pLayout = &xf86ScreenLayout[i];
+ /* force edge lists */
+ if(screen->left) {
+ ref = screen->left->screennum;
+ if (! xf86Screens[ref] || ! xf86Screens[ref]->pScreen) {
+ ErrorF("Referenced uninitialized screen in Layout!\n");
+ break;
+ }
+ pLayout->left = AddEdge(pLayout->left,
+ 0, pScreen->height,
+ xf86Screens[ref]->pScreen->width, 0, ref);
+ }
+ if(screen->right) {
+ ref = screen->right->screennum;
+ if (! xf86Screens[ref] || ! xf86Screens[ref]->pScreen) {
+ ErrorF("Referenced uninitialized screen in Layout!\n");
+ break;
+ }
+ pLayout->right = AddEdge(pLayout->right,
+ 0, pScreen->height, -pScreen->width, 0, ref);
+ }
+ if(screen->top) {
+ ref = screen->top->screennum;
+ if (! xf86Screens[ref] || ! xf86Screens[ref]->pScreen) {
+ ErrorF("Referenced uninitialized screen in Layout!\n");
+ break;
+ }
+ pLayout->up = AddEdge(pLayout->up,
+ 0, pScreen->width,
+ 0, xf86Screens[ref]->pScreen->height, ref);
+ }
+ if(screen->bottom) {
+ ref = screen->bottom->screennum;
+ if (! xf86Screens[ref] || ! xf86Screens[ref]->pScreen) {
+ ErrorF("Referenced uninitialized screen in Layout!\n");
+ break;
+ }
+ pLayout->down = AddEdge(pLayout->down,
+ 0, pScreen->width, 0, -pScreen->height, ref);
+ }
+ /* we could also try to place it based on those
+ relative locations if we wanted to */
+ screen->x = screen->y = 0;
+ /* FALLTHROUGH */
+ case PosAbsolute:
+ pScreen->x = screen->x;
+ pScreen->y = screen->y;
+ screensLeft &= ~(1 << i);
+ break;
+ case PosRelative:
+ ref = screen->refscreen->screennum;
+ if (! xf86Screens[ref] || ! xf86Screens[ref]->pScreen) {
+ ErrorF("Referenced uninitialized screen in Layout!\n");
+ break;
+ }
+ if(screensLeft & (1 << ref)) break;
+ refScreen = xf86Screens[ref]->pScreen;
+ pScreen->x = refScreen->x + screen->x;
+ pScreen->y = refScreen->y + screen->y;
+ screensLeft &= ~(1 << i);
+ break;
+ case PosRightOf:
+ ref = screen->refscreen->screennum;
+ if (! xf86Screens[ref] || ! xf86Screens[ref]->pScreen) {
+ ErrorF("Referenced uninitialized screen in Layout!\n");
+ break;
+ }
+ if(screensLeft & (1 << ref)) break;
+ refScreen = xf86Screens[ref]->pScreen;
+ pScreen->x = refScreen->x + refScreen->width;
+ pScreen->y = refScreen->y;
+ screensLeft &= ~(1 << i);
+ break;
+ case PosLeftOf:
+ ref = screen->refscreen->screennum;
+ if (! xf86Screens[ref] || ! xf86Screens[ref]->pScreen) {
+ ErrorF("Referenced uninitialized screen in Layout!\n");
+ break;
+ }
+ if(screensLeft & (1 << ref)) break;
+ refScreen = xf86Screens[ref]->pScreen;
+ pScreen->x = refScreen->x - pScreen->width;
+ pScreen->y = refScreen->y;
+ screensLeft &= ~(1 << i);
+ break;
+ case PosBelow:
+ ref = screen->refscreen->screennum;
+ if (! xf86Screens[ref] || ! xf86Screens[ref]->pScreen) {
+ ErrorF("Referenced uninitialized screen in Layout!\n");
+ break;
+ }
+ if(screensLeft & (1 << ref)) break;
+ refScreen = xf86Screens[ref]->pScreen;
+ pScreen->x = refScreen->x;
+ pScreen->y = refScreen->y + refScreen->height;
+ screensLeft &= ~(1 << i);
+ break;
+ case PosAbove:
+ ref = screen->refscreen->screennum;
+ if (! xf86Screens[ref] || ! xf86Screens[ref]->pScreen) {
+ ErrorF("Referenced uninitialized screen in Layout!\n");
+ break;
+ }
+ if(screensLeft & (1 << ref)) break;
+ refScreen = xf86Screens[ref]->pScreen;
+ pScreen->x = refScreen->x;
+ pScreen->y = refScreen->y - pScreen->height;
+ screensLeft &= ~(1 << i);
+ break;
+ default:
+ ErrorF("Illegal placement keyword in Layout!\n");
+ break;
+ }
+
+ }
+
+ if(!screensLeft) break;
+
+ if(screensLeft == prevScreensLeft) {
+ /* All the remaining screens are referencing each other.
+ Assign a value to one of them and go through again */
+ i = 0;
+ while(!((1 << i) & screensLeft)){ i++; }
+
+ ref = xf86ConfigLayout.screens[i].refscreen->screennum;
+ xf86Screens[ref]->pScreen->x = xf86Screens[ref]->pScreen->y = 0;
+ screensLeft &= ~(1 << ref);
+ }
+
+ prevScreensLeft = screensLeft;
+ }
+
+ /* justify the topmost and leftmost to (0,0) */
+ minX = xf86Screens[0]->pScreen->x;
+ minY = xf86Screens[0]->pScreen->y;
+
+ for(i = 1; i < xf86NumScreens; i++) {
+ if(xf86Screens[i]->pScreen->x < minX)
+ minX = xf86Screens[i]->pScreen->x;
+ if(xf86Screens[i]->pScreen->y < minY)
+ minY = xf86Screens[i]->pScreen->y;
+ }
+
+ if (minX || minY) {
+ for(i = 0; i < xf86NumScreens; i++) {
+ xf86Screens[i]->pScreen->x -= minX;
+ xf86Screens[i]->pScreen->y -= minY;
+ }
+ }
+
+
+ /* Create the edge lists */
+
+ if(!OldStyleConfig) {
+ for(i = 0; i < xf86NumScreens; i++) {
+ pLayout = &xf86ScreenLayout[i];
+
+ pScreen = xf86Screens[i]->pScreen;
+
+ left = pScreen->x;
+ right = left + pScreen->width;
+ top = pScreen->y;
+ bottom = top + pScreen->height;
+
+ for(j = 0; j < xf86NumScreens; j++) {
+ if(i == j) continue;
+
+ refScreen = xf86Screens[j]->pScreen;
+
+ x1 = refScreen->x;
+ x2 = x1 + refScreen->width;
+ y1 = refScreen->y;
+ y2 = y1 + refScreen->height;
+
+ if((bottom > y1) && (top < y2)) {
+ min = y1 - top;
+ if(min < 0) min = 0;
+ max = pScreen->height - (bottom - y2);
+ if(max > pScreen->height) max = pScreen->height;
+
+ if(((left - 1) >= x1) && ((left - 1) < x2))
+ pLayout->left = AddEdge(pLayout->left, min, max,
+ pScreen->x - refScreen->x,
+ pScreen->y - refScreen->y, j);
+
+ if((right >= x1) && (right < x2))
+ pLayout->right = AddEdge(pLayout->right, min, max,
+ pScreen->x - refScreen->x,
+ pScreen->y - refScreen->y, j);
+ }
+
+
+ if((left < x2) && (right > x1)) {
+ min = x1 - left;
+ if(min < 0) min = 0;
+ max = pScreen->width - (right - x2);
+ if(max > pScreen->width) max = pScreen->width;
+
+ if(((top - 1) >= y1) && ((top - 1) < y2))
+ pLayout->up = AddEdge(pLayout->up, min, max,
+ pScreen->x - refScreen->x,
+ pScreen->y - refScreen->y, j);
+
+ if((bottom >= y1) && (bottom < y2))
+ pLayout->down = AddEdge(pLayout->down, min, max,
+ pScreen->x - refScreen->x,
+ pScreen->y - refScreen->y, j);
+ }
+ }
+ }
+ }
+
+ if(!HardEdges && !OldStyleConfig) {
+ for(i = 0; i < xf86NumScreens; i++) {
+ pLayout = &xf86ScreenLayout[i];
+ pScreen = xf86Screens[i]->pScreen;
+ if(pLayout->left)
+ FillOutEdge(pLayout->left, pScreen->height);
+ if(pLayout->right)
+ FillOutEdge(pLayout->right, pScreen->height);
+ if(pLayout->up)
+ FillOutEdge(pLayout->up, pScreen->width);
+ if(pLayout->down)
+ FillOutEdge(pLayout->down, pScreen->width);
+ }
+ }
+}
+
+void
+xf86ReconfigureLayout(void)
+{
+ int i;
+
+ for (i = 0; i < MAXSCREENS; i++) {
+ xf86ScreenLayoutPtr sl = &xf86ScreenLayout[i];
+ /* we don't have to zero these, xf86InitOrigins() takes care of that */
+ free(sl->left);
+ free(sl->right);
+ free(sl->up);
+ free(sl->down);
+ }
+
+ xf86InitOrigins();
+}
+
+
diff --git a/xorg-server/hw/xfree86/common/xf86Events.c b/xorg-server/hw/xfree86/common/xf86Events.c
index 004807483..84c0d182a 100644
--- a/xorg-server/hw/xfree86/common/xf86Events.c
+++ b/xorg-server/hw/xfree86/common/xf86Events.c
@@ -1,758 +1,753 @@
-/*
- * Copyright 1990,91 by Thomas Roell, Dinkelscherben, Germany.
- *
- * 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 Thomas Roell not be used in
- * advertising or publicity pertaining to distribution of the software without
- * specific, written prior permission. Thomas Roell makes no representations
- * about the suitability of this software for any purpose. It is provided
- * "as is" without express or implied warranty.
- *
- * THOMAS ROELL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
- * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
- * EVENT SHALL THOMAS ROELL 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) 1994-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).
- */
-
-/* [JCH-96/01/21] Extended std reverse map to four buttons. */
-
-#ifdef HAVE_XORG_CONFIG_H
-#include <xorg-config.h>
-#endif
-
-#include <X11/X.h>
-#include <X11/Xpoll.h>
-#include <X11/Xproto.h>
-#include "misc.h"
-#include "compiler.h"
-#include "xf86.h"
-#include "xf86Priv.h"
-#define XF86_OS_PRIVS
-#include "xf86_OSlib.h"
-#include <X11/keysym.h>
-
-#ifdef XFreeXDGA
-#include "dgaproc.h"
-#endif
-
-#include <X11/extensions/XI.h>
-#include <X11/extensions/XIproto.h>
-#include "inputstr.h"
-#include "xf86Xinput.h"
-
-#include "mi.h"
-#include "mipointer.h"
-
-#include "xkbsrv.h"
-#include "xkbstr.h"
-
-#ifdef DPMSExtension
-#include <X11/extensions/dpmsconst.h>
-#include "dpmsproc.h"
-#endif
-
-/*
- * This is a toggling variable:
- * FALSE = No VT switching keys have been pressed last time around
- * TRUE = Possible VT switch Pending
- * (DWH - 12/2/93)
- *
- * This has been generalised to work with Linux and *BSD+syscons (DHD)
- */
-
-Bool VTSwitchEnabled = TRUE; /* Allows run-time disabling for
- *BSD and for avoiding VT
- switches when using the DRI
- automatic full screen mode.*/
-
-extern fd_set EnabledDevices;
-
-#ifdef XF86PM
-extern void (*xf86OSPMClose)(void);
-#endif
-
-static void xf86VTSwitch(void);
-
-/*
- * Allow arbitrary drivers or other XFree86 code to register with our main
- * Wakeup handler.
- */
-typedef struct x_IHRec {
- int fd;
- InputHandlerProc ihproc;
- pointer data;
- Bool enabled;
- struct x_IHRec * next;
-} IHRec, *IHPtr;
-
-static IHPtr InputHandlers = NULL;
-
-
-Bool
-LegalModifier(unsigned int key, DeviceIntPtr pDev)
-{
- return TRUE;
-}
-
-/*
- * TimeSinceLastInputEvent --
- * Function used for screensaver purposes by the os module. Returns the
- * time in milliseconds since there last was any input.
- */
-int
-TimeSinceLastInputEvent(void)
-{
- if (xf86Info.lastEventTime == 0) {
- xf86Info.lastEventTime = GetTimeInMillis();
- }
- return GetTimeInMillis() - xf86Info.lastEventTime;
-}
-
-/*
- * SetTimeSinceLastInputEvent --
- * Set the lastEventTime to now.
- */
-void
-SetTimeSinceLastInputEvent(void)
-{
- xf86Info.lastEventTime = GetTimeInMillis();
-}
-
-/*
- * ProcessInputEvents --
- * Retrieve all waiting input events and pass them to DIX in their
- * correct chronological order. Only reads from the system pointer
- * and keyboard.
- */
-void
-ProcessInputEvents (void)
-{
- int x, y;
-
- mieqProcessInputEvents();
-
- /* FIXME: This is a problem if we have multiple pointers */
- miPointerGetPosition(inputInfo.pointer, &x, &y);
- xf86SetViewport(xf86Info.currentScreen, x, y);
-}
-
-/*
- * Handle keyboard events that cause some kind of "action"
- * (i.e., server termination, video mode changes, VT switches, etc.)
- */
-void
-xf86ProcessActionEvent(ActionEvent action, void *arg)
-{
- DebugF("ProcessActionEvent(%d,%x)\n", (int) action, arg);
- switch (action) {
- case ACTION_TERMINATE:
- if (!xf86Info.dontZap) {
-#ifdef XFreeXDGA
- DGAShutdown();
-#endif
- GiveUp(0);
- }
- break;
- case ACTION_NEXT_MODE:
- if (!xf86Info.dontZoom)
- xf86ZoomViewport(xf86Info.currentScreen, 1);
- break;
- case ACTION_PREV_MODE:
- if (!xf86Info.dontZoom)
- xf86ZoomViewport(xf86Info.currentScreen, -1);
- break;
- case ACTION_SWITCHSCREEN:
- if (VTSwitchEnabled && !xf86Info.dontVTSwitch && arg) {
- int vtno = *((int *) arg);
-
- if (vtno != xf86Info.vtno) {
- if (!xf86VTActivate(vtno)) {
- ErrorF("Failed to switch from vt%02d to vt%02d: %s\n",
- xf86Info.vtno, vtno, strerror(errno));
- }
- }
- }
- break;
- case ACTION_SWITCHSCREEN_NEXT:
- if (VTSwitchEnabled && !xf86Info.dontVTSwitch) {
- if (!xf86VTActivate(xf86Info.vtno + 1)) {
- /* If first try failed, assume this is the last VT and
- * try wrapping around to the first vt.
- */
- if (!xf86VTActivate(1)) {
- ErrorF("Failed to switch from vt%02d to next vt: %s\n",
- xf86Info.vtno, strerror(errno));
- }
- }
- }
- break;
- case ACTION_SWITCHSCREEN_PREV:
- if (VTSwitchEnabled && !xf86Info.dontVTSwitch && xf86Info.vtno > 0) {
- if (!xf86VTActivate(xf86Info.vtno - 1)) {
- /* Don't know what the maximum VT is, so can't wrap around */
- ErrorF("Failed to switch from vt%02d to previous vt: %s\n",
- xf86Info.vtno, strerror(errno));
- }
- }
- break;
- default:
- break;
- }
-}
-
-/*
- * xf86Wakeup --
- * Os wakeup handler.
- */
-
-/* ARGSUSED */
-void
-xf86Wakeup(pointer blockData, int err, pointer pReadmask)
-{
- fd_set* LastSelectMask = (fd_set*)pReadmask;
- fd_set devicesWithInput;
- InputInfoPtr pInfo;
-
- if (err >= 0) {
-
- XFD_ANDSET(&devicesWithInput, LastSelectMask, &EnabledDevices);
- if (XFD_ANYSET(&devicesWithInput)) {
- pInfo = xf86InputDevs;
- while (pInfo) {
- if (pInfo->read_input && pInfo->fd >= 0 &&
- (FD_ISSET(pInfo->fd, &devicesWithInput) != 0)) {
- int sigstate = xf86BlockSIGIO();
-
- /*
- * Remove the descriptior from the set because more than one
- * device may share the same file descriptor.
- */
- FD_CLR(pInfo->fd, &devicesWithInput);
-
- pInfo->read_input(pInfo);
- xf86UnblockSIGIO(sigstate);
- }
- pInfo = pInfo->next;
- }
- }
- }
-
- if (err >= 0) { /* we don't want the handlers called if select() */
- IHPtr ih; /* returned with an error condition, do we? */
-
- for (ih = InputHandlers; ih; ih = ih->next) {
- if (ih->enabled && ih->fd >= 0 && ih->ihproc &&
- (FD_ISSET(ih->fd, ((fd_set *)pReadmask)) != 0)) {
- ih->ihproc(ih->fd, ih->data);
- }
- }
- }
-
- if (xf86VTSwitchPending()) xf86VTSwitch();
-}
-
-
-/*
- * xf86SigioReadInput --
- * signal handler for the SIGIO signal.
- */
-static void
-xf86SigioReadInput(int fd, void *closure)
-{
- int errno_save = errno;
- InputInfoPtr pInfo = closure;
-
- pInfo->read_input(pInfo);
-
- errno = errno_save;
-}
-
-/*
- * xf86AddEnabledDevice --
- *
- */
-void
-xf86AddEnabledDevice(InputInfoPtr pInfo)
-{
- if (!xf86InstallSIGIOHandler (pInfo->fd, xf86SigioReadInput, pInfo)) {
- AddEnabledDevice(pInfo->fd);
- }
-}
-
-/*
- * xf86RemoveEnabledDevice --
- *
- */
-void
-xf86RemoveEnabledDevice(InputInfoPtr pInfo)
-{
- if (!xf86RemoveSIGIOHandler (pInfo->fd)) {
- RemoveEnabledDevice(pInfo->fd);
- }
-}
-
-static int *xf86SignalIntercept = NULL;
-
-void
-xf86InterceptSignals(int *signo)
-{
- if ((xf86SignalIntercept = signo))
- *signo = -1;
-}
-
-static void (*xf86SigIllHandler)(void) = NULL;
-
-void
-xf86InterceptSigIll(void (*sigillhandler)(void))
-{
- xf86SigIllHandler = sigillhandler;
-}
-
-/*
- * xf86SigWrapper --
- * Catch unexpected signals and exit or continue cleanly.
- */
-int
-xf86SigWrapper(int signo)
-{
- if ((signo == SIGILL) && xf86SigIllHandler) {
- (*xf86SigIllHandler)();
- return 0; /* continue */
- }
-
- if (xf86SignalIntercept && (*xf86SignalIntercept < 0)) {
- *xf86SignalIntercept = signo;
- return 0; /* continue */
- }
-
- xf86Info.caughtSignal = TRUE;
- return 1; /* abort */
-}
-
-/*
- * xf86PrintBacktrace --
- * Print a stack backtrace for debugging purposes.
- */
-void
-xf86PrintBacktrace(void)
-{
- xorg_backtrace();
-}
-
-static void
-xf86ReleaseKeys(DeviceIntPtr pDev)
-{
- KeyClassPtr keyc;
- int i, j, nevents, sigstate;
-
- if (!pDev || !pDev->key)
- return;
-
- keyc = pDev->key;
-
- /*
- * Hmm... here is the biggest hack of every time !
- * It may be possible that a switch-vt procedure has finished BEFORE
- * you released all keys neccessary to do this. That peculiar behavior
- * can fool the X-server pretty much, cause it assumes that some keys
- * were not released. TWM may stuck alsmost completly....
- * OK, what we are doing here is after returning from the vt-switch
- * exeplicitely unrelease all keyboard keys before the input-devices
- * are reenabled.
- */
-
- for (i = keyc->xkbInfo->desc->min_key_code;
- i < keyc->xkbInfo->desc->max_key_code;
- i++) {
- if (key_is_down(pDev, i, KEY_POSTED)) {
- sigstate = xf86BlockSIGIO ();
- nevents = GetKeyboardEvents(xf86Events, pDev, KeyRelease, i);
- for (j = 0; j < nevents; j++)
- mieqEnqueue(pDev, (InternalEvent*)(xf86Events + j)->event);
- xf86UnblockSIGIO(sigstate);
- }
- }
-}
-
-/*
- * xf86VTSwitch --
- * Handle requests for switching the vt.
- */
-static void
-xf86VTSwitch(void)
-{
- int i, prevSIGIO;
- InputInfoPtr pInfo;
- IHPtr ih;
-
- DebugF("xf86VTSwitch()\n");
-
-#ifdef XFreeXDGA
- if(!DGAVTSwitch())
- return;
-#endif
-
- /*
- * Since all screens are currently all in the same state it is sufficient
- * check the first. This might change in future.
- */
- if (xf86Screens[0]->vtSema) {
-
- DebugF("xf86VTSwitch: Leaving, xf86Exiting is %s\n",
- BOOLTOSTRING((dispatchException & DE_TERMINATE) ? TRUE : FALSE));
-#ifdef DPMSExtension
- if (DPMSPowerLevel != DPMSModeOn)
- DPMSSet(serverClient, DPMSModeOn);
-#endif
- for (i = 0; i < xf86NumScreens; i++) {
- if (!(dispatchException & DE_TERMINATE))
- if (xf86Screens[i]->EnableDisableFBAccess)
- (*xf86Screens[i]->EnableDisableFBAccess) (i, FALSE);
- }
-
- /*
- * Keep the order: Disable Device > LeaveVT
- * EnterVT > EnableDevice
- */
- for (ih = InputHandlers; ih; ih = ih->next)
- xf86DisableInputHandler(ih);
- for (pInfo = xf86InputDevs; pInfo; pInfo = pInfo->next) {
- if (pInfo->dev) {
- xf86ReleaseKeys(pInfo->dev);
- ProcessInputEvents();
- DisableDevice(pInfo->dev, TRUE);
- }
- }
- xf86EnterServerState(SETUP);
- for (i = 0; i < xf86NumScreens; i++)
- xf86Screens[i]->LeaveVT(i, 0);
-
- xf86AccessLeave(); /* We need this here, otherwise */
-
- if (!xf86VTSwitchAway()) {
- /*
- * switch failed
- */
-
- DebugF("xf86VTSwitch: Leave failed\n");
- prevSIGIO = xf86BlockSIGIO();
- xf86AccessEnter();
- xf86EnterServerState(SETUP);
- for (i = 0; i < xf86NumScreens; i++) {
- if (!xf86Screens[i]->EnterVT(i, 0))
- FatalError("EnterVT failed for screen %d\n", i);
- }
- xf86EnterServerState(OPERATING);
- if (!(dispatchException & DE_TERMINATE)) {
- for (i = 0; i < xf86NumScreens; i++) {
- if (xf86Screens[i]->EnableDisableFBAccess)
- (*xf86Screens[i]->EnableDisableFBAccess) (i, TRUE);
- }
- }
- dixSaveScreens(serverClient, SCREEN_SAVER_FORCER, ScreenSaverReset);
-
- pInfo = xf86InputDevs;
- while (pInfo) {
- if (pInfo->dev)
- EnableDevice(pInfo->dev, TRUE);
- pInfo = pInfo->next;
- }
- for (ih = InputHandlers; ih; ih = ih->next)
- xf86EnableInputHandler(ih);
-
- xf86UnblockSIGIO(prevSIGIO);
-
- } else {
-#ifdef XF86PM
- if (xf86OSPMClose)
- xf86OSPMClose();
- xf86OSPMClose = NULL;
-#endif
-
- for (i = 0; i < xf86NumScreens; i++) {
- /*
- * zero all access functions to
- * trap calls when switched away.
- */
- xf86Screens[i]->vtSema = FALSE;
- }
- if (xorgHWAccess)
- xf86DisableIO();
- }
- } else {
-
- DebugF("xf86VTSwitch: Entering\n");
- if (!xf86VTSwitchTo()) return;
-
- prevSIGIO = xf86BlockSIGIO();
-#ifdef XF86PM
- xf86OSPMClose = xf86OSPMOpen();
-#endif
-
- if (xorgHWAccess)
- xf86EnableIO();
- xf86AccessEnter();
- xf86EnterServerState(SETUP);
- for (i = 0; i < xf86NumScreens; i++) {
- xf86Screens[i]->vtSema = TRUE;
- if (!xf86Screens[i]->EnterVT(i, 0))
- FatalError("EnterVT failed for screen %d\n", i);
- }
- xf86EnterServerState(OPERATING);
- for (i = 0; i < xf86NumScreens; i++) {
- if (xf86Screens[i]->EnableDisableFBAccess)
- (*xf86Screens[i]->EnableDisableFBAccess)(i, TRUE);
- }
-
- /* Turn screen saver off when switching back */
- dixSaveScreens(serverClient, SCREEN_SAVER_FORCER, ScreenSaverReset);
-
- pInfo = xf86InputDevs;
- while (pInfo) {
- if (pInfo->dev)
- EnableDevice(pInfo->dev, TRUE);
- pInfo = pInfo->next;
- }
-
- for (ih = InputHandlers; ih; ih = ih->next)
- xf86EnableInputHandler(ih);
-
- xf86UnblockSIGIO(prevSIGIO);
- }
-}
-
-
-/* Input handler registration */
-
-static pointer
-addInputHandler(int fd, InputHandlerProc proc, pointer data)
-{
- IHPtr ih;
-
- if (fd < 0 || !proc)
- return NULL;
-
- ih = calloc(sizeof(*ih), 1);
- if (!ih)
- return NULL;
-
- ih->fd = fd;
- ih->ihproc = proc;
- ih->data = data;
- ih->enabled = TRUE;
-
- ih->next = InputHandlers;
- InputHandlers = ih;
-
- return ih;
-}
-
-pointer
-xf86AddInputHandler(int fd, InputHandlerProc proc, pointer data)
-{
- IHPtr ih = addInputHandler(fd, proc, data);
-
- if (ih)
- AddEnabledDevice(fd);
- return ih;
-}
-
-pointer
-xf86AddGeneralHandler(int fd, InputHandlerProc proc, pointer data)
-{
- IHPtr ih = addInputHandler(fd, proc, data);
-
- if (ih)
- AddGeneralSocket(fd);
- return ih;
-}
-
-/**
- * Set the handler for the console's fd. Replaces (and returns) the previous
- * handler or NULL, whichever appropriate.
- * proc may be NULL if the server should not handle events on the console.
- */
-InputHandlerProc
-xf86SetConsoleHandler(InputHandlerProc proc, pointer data)
-{
- static InputHandlerProc handler = NULL;
- InputHandlerProc old_handler = handler;
-
- if (old_handler)
- xf86RemoveGeneralHandler(old_handler);
-
- xf86AddGeneralHandler(xf86Info.consoleFd, proc, data);
- handler = proc;
-
- return old_handler;
-}
-
-static void
-removeInputHandler(IHPtr ih)
-{
- IHPtr p;
-
- if (ih == InputHandlers)
- InputHandlers = ih->next;
- else {
- p = InputHandlers;
- while (p && p->next != ih)
- p = p->next;
- if (ih)
- p->next = ih->next;
- }
- free(ih);
-}
-
-int
-xf86RemoveInputHandler(pointer handler)
-{
- IHPtr ih;
- int fd;
-
- if (!handler)
- return -1;
-
- ih = handler;
- fd = ih->fd;
-
- if (ih->fd >= 0)
- RemoveEnabledDevice(ih->fd);
- removeInputHandler(ih);
-
- return fd;
-}
-
-int
-xf86RemoveGeneralHandler(pointer handler)
-{
- IHPtr ih;
- int fd;
-
- if (!handler)
- return -1;
-
- ih = handler;
- fd = ih->fd;
-
- if (ih->fd >= 0)
- RemoveGeneralSocket(ih->fd);
- removeInputHandler(ih);
-
- return fd;
-}
-
-void
-xf86DisableInputHandler(pointer handler)
-{
- IHPtr ih;
-
- if (!handler)
- return;
-
- ih = handler;
- ih->enabled = FALSE;
- if (ih->fd >= 0)
- RemoveEnabledDevice(ih->fd);
-}
-
-void
-xf86DisableGeneralHandler(pointer handler)
-{
- IHPtr ih;
-
- if (!handler)
- return;
-
- ih = handler;
- ih->enabled = FALSE;
- if (ih->fd >= 0)
- RemoveGeneralSocket(ih->fd);
-}
-
-void
-xf86EnableInputHandler(pointer handler)
-{
- IHPtr ih;
-
- if (!handler)
- return;
-
- ih = handler;
- ih->enabled = TRUE;
- if (ih->fd >= 0)
- AddEnabledDevice(ih->fd);
-}
-
-void
-xf86EnableGeneralHandler(pointer handler)
-{
- IHPtr ih;
-
- if (!handler)
- return;
-
- ih = handler;
- ih->enabled = TRUE;
- if (ih->fd >= 0)
- AddGeneralSocket(ih->fd);
-}
-
-/*
- * As used currently by the DRI, the return value is ignored.
- */
-Bool
-xf86EnableVTSwitch(Bool new)
-{
- static Bool def = TRUE;
- Bool old;
-
- old = VTSwitchEnabled;
- if (!new) {
- /* Disable VT switching */
- def = VTSwitchEnabled;
- VTSwitchEnabled = FALSE;
- } else {
- /* Restore VT switching to default */
- VTSwitchEnabled = def;
- }
- return old;
-}
-
-void
-DDXRingBell(int volume, int pitch, int duration) {
- xf86OSRingBell(volume, pitch, duration);
-}
+/*
+ * Copyright 1990,91 by Thomas Roell, Dinkelscherben, Germany.
+ *
+ * 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 Thomas Roell not be used in
+ * advertising or publicity pertaining to distribution of the software without
+ * specific, written prior permission. Thomas Roell makes no representations
+ * about the suitability of this software for any purpose. It is provided
+ * "as is" without express or implied warranty.
+ *
+ * THOMAS ROELL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
+ * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
+ * EVENT SHALL THOMAS ROELL 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) 1994-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).
+ */
+
+/* [JCH-96/01/21] Extended std reverse map to four buttons. */
+
+#ifdef HAVE_XORG_CONFIG_H
+#include <xorg-config.h>
+#endif
+
+#include <X11/X.h>
+#include <X11/Xpoll.h>
+#include <X11/Xproto.h>
+#include "misc.h"
+#include "compiler.h"
+#include "xf86.h"
+#include "xf86Priv.h"
+#define XF86_OS_PRIVS
+#include "xf86_OSlib.h"
+#include <X11/keysym.h>
+
+#ifdef XFreeXDGA
+#include "dgaproc.h"
+#endif
+
+#include <X11/extensions/XI.h>
+#include <X11/extensions/XIproto.h>
+#include "inputstr.h"
+#include "xf86Xinput.h"
+
+#include "mi.h"
+#include "mipointer.h"
+
+#include "xkbsrv.h"
+#include "xkbstr.h"
+
+#ifdef DPMSExtension
+#include <X11/extensions/dpmsconst.h>
+#include "dpmsproc.h"
+#endif
+
+/*
+ * This is a toggling variable:
+ * FALSE = No VT switching keys have been pressed last time around
+ * TRUE = Possible VT switch Pending
+ * (DWH - 12/2/93)
+ *
+ * This has been generalised to work with Linux and *BSD+syscons (DHD)
+ */
+
+Bool VTSwitchEnabled = TRUE; /* Allows run-time disabling for
+ *BSD and for avoiding VT
+ switches when using the DRI
+ automatic full screen mode.*/
+
+extern fd_set EnabledDevices;
+
+#ifdef XF86PM
+extern void (*xf86OSPMClose)(void);
+#endif
+
+static void xf86VTSwitch(void);
+
+/*
+ * Allow arbitrary drivers or other XFree86 code to register with our main
+ * Wakeup handler.
+ */
+typedef struct x_IHRec {
+ int fd;
+ InputHandlerProc ihproc;
+ pointer data;
+ Bool enabled;
+ struct x_IHRec * next;
+} IHRec, *IHPtr;
+
+static IHPtr InputHandlers = NULL;
+
+
+Bool
+LegalModifier(unsigned int key, DeviceIntPtr pDev)
+{
+ return TRUE;
+}
+
+/*
+ * TimeSinceLastInputEvent --
+ * Function used for screensaver purposes by the os module. Returns the
+ * time in milliseconds since there last was any input.
+ */
+int
+TimeSinceLastInputEvent(void)
+{
+ if (xf86Info.lastEventTime == 0) {
+ xf86Info.lastEventTime = GetTimeInMillis();
+ }
+ return GetTimeInMillis() - xf86Info.lastEventTime;
+}
+
+/*
+ * SetTimeSinceLastInputEvent --
+ * Set the lastEventTime to now.
+ */
+void
+SetTimeSinceLastInputEvent(void)
+{
+ xf86Info.lastEventTime = GetTimeInMillis();
+}
+
+/*
+ * ProcessInputEvents --
+ * Retrieve all waiting input events and pass them to DIX in their
+ * correct chronological order. Only reads from the system pointer
+ * and keyboard.
+ */
+void
+ProcessInputEvents (void)
+{
+ int x, y;
+
+ mieqProcessInputEvents();
+
+ /* FIXME: This is a problem if we have multiple pointers */
+ miPointerGetPosition(inputInfo.pointer, &x, &y);
+ xf86SetViewport(xf86Info.currentScreen, x, y);
+}
+
+/*
+ * Handle keyboard events that cause some kind of "action"
+ * (i.e., server termination, video mode changes, VT switches, etc.)
+ */
+void
+xf86ProcessActionEvent(ActionEvent action, void *arg)
+{
+ DebugF("ProcessActionEvent(%d,%x)\n", (int) action, arg);
+ switch (action) {
+ case ACTION_TERMINATE:
+ if (!xf86Info.dontZap) {
+#ifdef XFreeXDGA
+ DGAShutdown();
+#endif
+ GiveUp(0);
+ }
+ break;
+ case ACTION_NEXT_MODE:
+ if (!xf86Info.dontZoom)
+ xf86ZoomViewport(xf86Info.currentScreen, 1);
+ break;
+ case ACTION_PREV_MODE:
+ if (!xf86Info.dontZoom)
+ xf86ZoomViewport(xf86Info.currentScreen, -1);
+ break;
+ case ACTION_SWITCHSCREEN:
+ if (VTSwitchEnabled && !xf86Info.dontVTSwitch && arg) {
+ int vtno = *((int *) arg);
+
+ if (vtno != xf86Info.vtno) {
+ if (!xf86VTActivate(vtno)) {
+ ErrorF("Failed to switch from vt%02d to vt%02d: %s\n",
+ xf86Info.vtno, vtno, strerror(errno));
+ }
+ }
+ }
+ break;
+ case ACTION_SWITCHSCREEN_NEXT:
+ if (VTSwitchEnabled && !xf86Info.dontVTSwitch) {
+ if (!xf86VTActivate(xf86Info.vtno + 1)) {
+ /* If first try failed, assume this is the last VT and
+ * try wrapping around to the first vt.
+ */
+ if (!xf86VTActivate(1)) {
+ ErrorF("Failed to switch from vt%02d to next vt: %s\n",
+ xf86Info.vtno, strerror(errno));
+ }
+ }
+ }
+ break;
+ case ACTION_SWITCHSCREEN_PREV:
+ if (VTSwitchEnabled && !xf86Info.dontVTSwitch && xf86Info.vtno > 0) {
+ if (!xf86VTActivate(xf86Info.vtno - 1)) {
+ /* Don't know what the maximum VT is, so can't wrap around */
+ ErrorF("Failed to switch from vt%02d to previous vt: %s\n",
+ xf86Info.vtno, strerror(errno));
+ }
+ }
+ break;
+ default:
+ break;
+ }
+}
+
+/*
+ * xf86Wakeup --
+ * Os wakeup handler.
+ */
+
+/* ARGSUSED */
+void
+xf86Wakeup(pointer blockData, int err, pointer pReadmask)
+{
+ fd_set* LastSelectMask = (fd_set*)pReadmask;
+ fd_set devicesWithInput;
+ InputInfoPtr pInfo;
+
+ if (err >= 0) {
+
+ XFD_ANDSET(&devicesWithInput, LastSelectMask, &EnabledDevices);
+ if (XFD_ANYSET(&devicesWithInput)) {
+ pInfo = xf86InputDevs;
+ while (pInfo) {
+ if (pInfo->read_input && pInfo->fd >= 0 &&
+ (FD_ISSET(pInfo->fd, &devicesWithInput) != 0)) {
+ int sigstate = xf86BlockSIGIO();
+
+ /*
+ * Remove the descriptior from the set because more than one
+ * device may share the same file descriptor.
+ */
+ FD_CLR(pInfo->fd, &devicesWithInput);
+
+ pInfo->read_input(pInfo);
+ xf86UnblockSIGIO(sigstate);
+ }
+ pInfo = pInfo->next;
+ }
+ }
+ }
+
+ if (err >= 0) { /* we don't want the handlers called if select() */
+ IHPtr ih; /* returned with an error condition, do we? */
+
+ for (ih = InputHandlers; ih; ih = ih->next) {
+ if (ih->enabled && ih->fd >= 0 && ih->ihproc &&
+ (FD_ISSET(ih->fd, ((fd_set *)pReadmask)) != 0)) {
+ ih->ihproc(ih->fd, ih->data);
+ }
+ }
+ }
+
+ if (xf86VTSwitchPending()) xf86VTSwitch();
+}
+
+
+/*
+ * xf86SigioReadInput --
+ * signal handler for the SIGIO signal.
+ */
+static void
+xf86SigioReadInput(int fd, void *closure)
+{
+ int errno_save = errno;
+ InputInfoPtr pInfo = closure;
+
+ pInfo->read_input(pInfo);
+
+ errno = errno_save;
+}
+
+/*
+ * xf86AddEnabledDevice --
+ *
+ */
+void
+xf86AddEnabledDevice(InputInfoPtr pInfo)
+{
+ if (!xf86InstallSIGIOHandler (pInfo->fd, xf86SigioReadInput, pInfo)) {
+ AddEnabledDevice(pInfo->fd);
+ }
+}
+
+/*
+ * xf86RemoveEnabledDevice --
+ *
+ */
+void
+xf86RemoveEnabledDevice(InputInfoPtr pInfo)
+{
+ if (!xf86RemoveSIGIOHandler (pInfo->fd)) {
+ RemoveEnabledDevice(pInfo->fd);
+ }
+}
+
+static int *xf86SignalIntercept = NULL;
+
+void
+xf86InterceptSignals(int *signo)
+{
+ if ((xf86SignalIntercept = signo))
+ *signo = -1;
+}
+
+static void (*xf86SigIllHandler)(void) = NULL;
+
+void
+xf86InterceptSigIll(void (*sigillhandler)(void))
+{
+ xf86SigIllHandler = sigillhandler;
+}
+
+/*
+ * xf86SigWrapper --
+ * Catch unexpected signals and exit or continue cleanly.
+ */
+int
+xf86SigWrapper(int signo)
+{
+ if ((signo == SIGILL) && xf86SigIllHandler) {
+ (*xf86SigIllHandler)();
+ return 0; /* continue */
+ }
+
+ if (xf86SignalIntercept && (*xf86SignalIntercept < 0)) {
+ *xf86SignalIntercept = signo;
+ return 0; /* continue */
+ }
+
+ xf86Info.caughtSignal = TRUE;
+ return 1; /* abort */
+}
+
+/*
+ * xf86PrintBacktrace --
+ * Print a stack backtrace for debugging purposes.
+ */
+void
+xf86PrintBacktrace(void)
+{
+ xorg_backtrace();
+}
+
+static void
+xf86ReleaseKeys(DeviceIntPtr pDev)
+{
+ KeyClassPtr keyc;
+ int i, j, nevents, sigstate;
+
+ if (!pDev || !pDev->key)
+ return;
+
+ keyc = pDev->key;
+
+ /*
+ * Hmm... here is the biggest hack of every time !
+ * It may be possible that a switch-vt procedure has finished BEFORE
+ * you released all keys neccessary to do this. That peculiar behavior
+ * can fool the X-server pretty much, cause it assumes that some keys
+ * were not released. TWM may stuck alsmost completly....
+ * OK, what we are doing here is after returning from the vt-switch
+ * exeplicitely unrelease all keyboard keys before the input-devices
+ * are reenabled.
+ */
+
+ for (i = keyc->xkbInfo->desc->min_key_code;
+ i < keyc->xkbInfo->desc->max_key_code;
+ i++) {
+ if (key_is_down(pDev, i, KEY_POSTED)) {
+ sigstate = xf86BlockSIGIO ();
+ nevents = GetKeyboardEvents(xf86Events, pDev, KeyRelease, i);
+ for (j = 0; j < nevents; j++)
+ mieqEnqueue(pDev, (InternalEvent*)(xf86Events + j)->event);
+ xf86UnblockSIGIO(sigstate);
+ }
+ }
+}
+
+/*
+ * xf86VTSwitch --
+ * Handle requests for switching the vt.
+ */
+static void
+xf86VTSwitch(void)
+{
+ int i;
+ static int prevSIGIO;
+ InputInfoPtr pInfo;
+ IHPtr ih;
+
+ DebugF("xf86VTSwitch()\n");
+
+#ifdef XFreeXDGA
+ if(!DGAVTSwitch())
+ return;
+#endif
+
+ /*
+ * Since all screens are currently all in the same state it is sufficient
+ * check the first. This might change in future.
+ */
+ if (xf86Screens[0]->vtSema) {
+
+ DebugF("xf86VTSwitch: Leaving, xf86Exiting is %s\n",
+ BOOLTOSTRING((dispatchException & DE_TERMINATE) ? TRUE : FALSE));
+#ifdef DPMSExtension
+ if (DPMSPowerLevel != DPMSModeOn)
+ DPMSSet(serverClient, DPMSModeOn);
+#endif
+ for (i = 0; i < xf86NumScreens; i++) {
+ if (!(dispatchException & DE_TERMINATE))
+ if (xf86Screens[i]->EnableDisableFBAccess)
+ (*xf86Screens[i]->EnableDisableFBAccess) (i, FALSE);
+ }
+
+ /*
+ * Keep the order: Disable Device > LeaveVT
+ * EnterVT > EnableDevice
+ */
+ for (ih = InputHandlers; ih; ih = ih->next)
+ xf86DisableInputHandler(ih);
+ for (pInfo = xf86InputDevs; pInfo; pInfo = pInfo->next) {
+ if (pInfo->dev) {
+ xf86ReleaseKeys(pInfo->dev);
+ ProcessInputEvents();
+ DisableDevice(pInfo->dev, TRUE);
+ }
+ }
+
+ prevSIGIO = xf86BlockSIGIO();
+ for (i = 0; i < xf86NumScreens; i++)
+ xf86Screens[i]->LeaveVT(i, 0);
+
+ xf86AccessLeave(); /* We need this here, otherwise */
+
+ if (!xf86VTSwitchAway()) {
+ /*
+ * switch failed
+ */
+
+ DebugF("xf86VTSwitch: Leave failed\n");
+ xf86AccessEnter();
+ for (i = 0; i < xf86NumScreens; i++) {
+ if (!xf86Screens[i]->EnterVT(i, 0))
+ FatalError("EnterVT failed for screen %d\n", i);
+ }
+ if (!(dispatchException & DE_TERMINATE)) {
+ for (i = 0; i < xf86NumScreens; i++) {
+ if (xf86Screens[i]->EnableDisableFBAccess)
+ (*xf86Screens[i]->EnableDisableFBAccess) (i, TRUE);
+ }
+ }
+ dixSaveScreens(serverClient, SCREEN_SAVER_FORCER, ScreenSaverReset);
+
+ pInfo = xf86InputDevs;
+ while (pInfo) {
+ if (pInfo->dev)
+ EnableDevice(pInfo->dev, TRUE);
+ pInfo = pInfo->next;
+ }
+ for (ih = InputHandlers; ih; ih = ih->next)
+ xf86EnableInputHandler(ih);
+
+ xf86UnblockSIGIO(prevSIGIO);
+
+ } else {
+#ifdef XF86PM
+ if (xf86OSPMClose)
+ xf86OSPMClose();
+ xf86OSPMClose = NULL;
+#endif
+
+ for (i = 0; i < xf86NumScreens; i++) {
+ /*
+ * zero all access functions to
+ * trap calls when switched away.
+ */
+ xf86Screens[i]->vtSema = FALSE;
+ }
+ if (xorgHWAccess)
+ xf86DisableIO();
+ }
+ } else {
+ DebugF("xf86VTSwitch: Entering\n");
+ if (!xf86VTSwitchTo()) return;
+
+#ifdef XF86PM
+ xf86OSPMClose = xf86OSPMOpen();
+#endif
+
+ if (xorgHWAccess)
+ xf86EnableIO();
+ xf86AccessEnter();
+ for (i = 0; i < xf86NumScreens; i++) {
+ xf86Screens[i]->vtSema = TRUE;
+ if (!xf86Screens[i]->EnterVT(i, 0))
+ FatalError("EnterVT failed for screen %d\n", i);
+ }
+ for (i = 0; i < xf86NumScreens; i++) {
+ if (xf86Screens[i]->EnableDisableFBAccess)
+ (*xf86Screens[i]->EnableDisableFBAccess)(i, TRUE);
+ }
+
+ /* Turn screen saver off when switching back */
+ dixSaveScreens(serverClient, SCREEN_SAVER_FORCER, ScreenSaverReset);
+
+ pInfo = xf86InputDevs;
+ while (pInfo) {
+ if (pInfo->dev)
+ EnableDevice(pInfo->dev, TRUE);
+ pInfo = pInfo->next;
+ }
+
+ for (ih = InputHandlers; ih; ih = ih->next)
+ xf86EnableInputHandler(ih);
+
+ xf86UnblockSIGIO(prevSIGIO);
+ }
+}
+
+
+/* Input handler registration */
+
+static pointer
+addInputHandler(int fd, InputHandlerProc proc, pointer data)
+{
+ IHPtr ih;
+
+ if (fd < 0 || !proc)
+ return NULL;
+
+ ih = calloc(sizeof(*ih), 1);
+ if (!ih)
+ return NULL;
+
+ ih->fd = fd;
+ ih->ihproc = proc;
+ ih->data = data;
+ ih->enabled = TRUE;
+
+ ih->next = InputHandlers;
+ InputHandlers = ih;
+
+ return ih;
+}
+
+pointer
+xf86AddInputHandler(int fd, InputHandlerProc proc, pointer data)
+{
+ IHPtr ih = addInputHandler(fd, proc, data);
+
+ if (ih)
+ AddEnabledDevice(fd);
+ return ih;
+}
+
+pointer
+xf86AddGeneralHandler(int fd, InputHandlerProc proc, pointer data)
+{
+ IHPtr ih = addInputHandler(fd, proc, data);
+
+ if (ih)
+ AddGeneralSocket(fd);
+ return ih;
+}
+
+/**
+ * Set the handler for the console's fd. Replaces (and returns) the previous
+ * handler or NULL, whichever appropriate.
+ * proc may be NULL if the server should not handle events on the console.
+ */
+InputHandlerProc
+xf86SetConsoleHandler(InputHandlerProc proc, pointer data)
+{
+ static InputHandlerProc handler = NULL;
+ InputHandlerProc old_handler = handler;
+
+ if (old_handler)
+ xf86RemoveGeneralHandler(old_handler);
+
+ xf86AddGeneralHandler(xf86Info.consoleFd, proc, data);
+ handler = proc;
+
+ return old_handler;
+}
+
+static void
+removeInputHandler(IHPtr ih)
+{
+ IHPtr p;
+
+ if (ih == InputHandlers)
+ InputHandlers = ih->next;
+ else {
+ p = InputHandlers;
+ while (p && p->next != ih)
+ p = p->next;
+ if (ih)
+ p->next = ih->next;
+ }
+ free(ih);
+}
+
+int
+xf86RemoveInputHandler(pointer handler)
+{
+ IHPtr ih;
+ int fd;
+
+ if (!handler)
+ return -1;
+
+ ih = handler;
+ fd = ih->fd;
+
+ if (ih->fd >= 0)
+ RemoveEnabledDevice(ih->fd);
+ removeInputHandler(ih);
+
+ return fd;
+}
+
+int
+xf86RemoveGeneralHandler(pointer handler)
+{
+ IHPtr ih;
+ int fd;
+
+ if (!handler)
+ return -1;
+
+ ih = handler;
+ fd = ih->fd;
+
+ if (ih->fd >= 0)
+ RemoveGeneralSocket(ih->fd);
+ removeInputHandler(ih);
+
+ return fd;
+}
+
+void
+xf86DisableInputHandler(pointer handler)
+{
+ IHPtr ih;
+
+ if (!handler)
+ return;
+
+ ih = handler;
+ ih->enabled = FALSE;
+ if (ih->fd >= 0)
+ RemoveEnabledDevice(ih->fd);
+}
+
+void
+xf86DisableGeneralHandler(pointer handler)
+{
+ IHPtr ih;
+
+ if (!handler)
+ return;
+
+ ih = handler;
+ ih->enabled = FALSE;
+ if (ih->fd >= 0)
+ RemoveGeneralSocket(ih->fd);
+}
+
+void
+xf86EnableInputHandler(pointer handler)
+{
+ IHPtr ih;
+
+ if (!handler)
+ return;
+
+ ih = handler;
+ ih->enabled = TRUE;
+ if (ih->fd >= 0)
+ AddEnabledDevice(ih->fd);
+}
+
+void
+xf86EnableGeneralHandler(pointer handler)
+{
+ IHPtr ih;
+
+ if (!handler)
+ return;
+
+ ih = handler;
+ ih->enabled = TRUE;
+ if (ih->fd >= 0)
+ AddGeneralSocket(ih->fd);
+}
+
+/*
+ * As used currently by the DRI, the return value is ignored.
+ */
+Bool
+xf86EnableVTSwitch(Bool new)
+{
+ static Bool def = TRUE;
+ Bool old;
+
+ old = VTSwitchEnabled;
+ if (!new) {
+ /* Disable VT switching */
+ def = VTSwitchEnabled;
+ VTSwitchEnabled = FALSE;
+ } else {
+ /* Restore VT switching to default */
+ VTSwitchEnabled = def;
+ }
+ return old;
+}
+
+void
+DDXRingBell(int volume, int pitch, int duration) {
+ xf86OSRingBell(volume, pitch, duration);
+}
diff --git a/xorg-server/hw/xfree86/common/xf86Globals.c b/xorg-server/hw/xfree86/common/xf86Globals.c
index 02f20f690..16d55577e 100644
--- a/xorg-server/hw/xfree86/common/xf86Globals.c
+++ b/xorg-server/hw/xfree86/common/xf86Globals.c
@@ -1,198 +1,197 @@
-
-/*
- * 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 all the XFree86 global variables.
- */
-
-#ifdef HAVE_XORG_CONFIG_H
-#include <xorg-config.h>
-#endif
-
-#include <X11/X.h>
-#include "os.h"
-#include "windowstr.h"
-#include "propertyst.h"
-#include "xf86.h"
-#include "xf86Priv.h"
-#include "xf86Parser.h"
-#include "xf86Xinput.h"
-#include "xf86InPriv.h"
-#include "xf86Config.h"
-
-/* Globals that video drivers may access */
-
-DevPrivateKeyRec xf86CreateRootWindowKeyRec;
-DevPrivateKeyRec xf86ScreenKeyRec;
-
-ScrnInfoPtr *xf86Screens = NULL; /* List of ScrnInfos */
-const unsigned char byte_reversed[256] =
-{
- 0x00, 0x80, 0x40, 0xc0, 0x20, 0xa0, 0x60, 0xe0,
- 0x10, 0x90, 0x50, 0xd0, 0x30, 0xb0, 0x70, 0xf0,
- 0x08, 0x88, 0x48, 0xc8, 0x28, 0xa8, 0x68, 0xe8,
- 0x18, 0x98, 0x58, 0xd8, 0x38, 0xb8, 0x78, 0xf8,
- 0x04, 0x84, 0x44, 0xc4, 0x24, 0xa4, 0x64, 0xe4,
- 0x14, 0x94, 0x54, 0xd4, 0x34, 0xb4, 0x74, 0xf4,
- 0x0c, 0x8c, 0x4c, 0xcc, 0x2c, 0xac, 0x6c, 0xec,
- 0x1c, 0x9c, 0x5c, 0xdc, 0x3c, 0xbc, 0x7c, 0xfc,
- 0x02, 0x82, 0x42, 0xc2, 0x22, 0xa2, 0x62, 0xe2,
- 0x12, 0x92, 0x52, 0xd2, 0x32, 0xb2, 0x72, 0xf2,
- 0x0a, 0x8a, 0x4a, 0xca, 0x2a, 0xaa, 0x6a, 0xea,
- 0x1a, 0x9a, 0x5a, 0xda, 0x3a, 0xba, 0x7a, 0xfa,
- 0x06, 0x86, 0x46, 0xc6, 0x26, 0xa6, 0x66, 0xe6,
- 0x16, 0x96, 0x56, 0xd6, 0x36, 0xb6, 0x76, 0xf6,
- 0x0e, 0x8e, 0x4e, 0xce, 0x2e, 0xae, 0x6e, 0xee,
- 0x1e, 0x9e, 0x5e, 0xde, 0x3e, 0xbe, 0x7e, 0xfe,
- 0x01, 0x81, 0x41, 0xc1, 0x21, 0xa1, 0x61, 0xe1,
- 0x11, 0x91, 0x51, 0xd1, 0x31, 0xb1, 0x71, 0xf1,
- 0x09, 0x89, 0x49, 0xc9, 0x29, 0xa9, 0x69, 0xe9,
- 0x19, 0x99, 0x59, 0xd9, 0x39, 0xb9, 0x79, 0xf9,
- 0x05, 0x85, 0x45, 0xc5, 0x25, 0xa5, 0x65, 0xe5,
- 0x15, 0x95, 0x55, 0xd5, 0x35, 0xb5, 0x75, 0xf5,
- 0x0d, 0x8d, 0x4d, 0xcd, 0x2d, 0xad, 0x6d, 0xed,
- 0x1d, 0x9d, 0x5d, 0xdd, 0x3d, 0xbd, 0x7d, 0xfd,
- 0x03, 0x83, 0x43, 0xc3, 0x23, 0xa3, 0x63, 0xe3,
- 0x13, 0x93, 0x53, 0xd3, 0x33, 0xb3, 0x73, 0xf3,
- 0x0b, 0x8b, 0x4b, 0xcb, 0x2b, 0xab, 0x6b, 0xeb,
- 0x1b, 0x9b, 0x5b, 0xdb, 0x3b, 0xbb, 0x7b, 0xfb,
- 0x07, 0x87, 0x47, 0xc7, 0x27, 0xa7, 0x67, 0xe7,
- 0x17, 0x97, 0x57, 0xd7, 0x37, 0xb7, 0x77, 0xf7,
- 0x0f, 0x8f, 0x4f, 0xcf, 0x2f, 0xaf, 0x6f, 0xef,
- 0x1f, 0x9f, 0x5f, 0xdf, 0x3f, 0xbf, 0x7f, 0xff,
-};
-
-/* Globals that input drivers may access */
-InputInfoPtr xf86InputDevs = NULL;
-
-
-/* Globals that video drivers may not access */
-
-xf86InfoRec xf86Info = {
- .consoleFd = -1,
- .vtno = -1,
- .vtSysreq = FALSE,
- .lastEventTime = -1,
- .vtRequestsPending = FALSE,
-#ifdef sun
- .vtPendingNum = -1,
-#endif
- .dontVTSwitch = FALSE,
- .dontZap = FALSE,
- .dontZoom = FALSE,
- .notrapSignals = FALSE,
- .caughtSignal = FALSE,
- .currentScreen = NULL,
-#ifdef CSRG_BASED
- .screenFd = -1,
- .consType = -1,
-#endif
- .allowMouseOpenFail = FALSE,
- .vidModeEnabled = TRUE,
- .vidModeAllowNonLocal = FALSE,
- .miscModInDevEnabled = TRUE,
- .miscModInDevAllowNonLocal = FALSE,
- .pixmap24 = Pix24DontCare,
- .pix24From = X_DEFAULT,
-#ifdef SUPPORT_PC98
- .pc98 = FALSE,
-#endif
- .pmFlag = TRUE,
- .log = LogNone,
- .disableRandR = FALSE,
- .randRFrom = X_DEFAULT,
-#if defined(CONFIG_HAL) || defined(CONFIG_UDEV)
- .forceInputDevices = FALSE,
- .autoAddDevices = TRUE,
- .autoEnableDevices = TRUE
-#else
- .forceInputDevices = TRUE,
- .autoAddDevices = FALSE,
- .autoEnableDevices = FALSE
-#endif
-};
-const char *xf86ConfigFile = NULL;
-const char *xf86ConfigDir = NULL;
-const char *xf86ModulePath = DEFAULT_MODULE_PATH;
-MessageType xf86ModPathFrom = X_DEFAULT;
-const char *xf86LogFile = DEFAULT_LOGPREFIX;
-MessageType xf86LogFileFrom = X_DEFAULT;
-Bool xf86LogFileWasOpened = FALSE;
-serverLayoutRec xf86ConfigLayout = {NULL, };
-confDRIRec xf86ConfigDRI = {0, };
-XF86ConfigPtr xf86configptr = NULL;
-Bool xf86Resetting = FALSE;
-Bool xf86Initialising = FALSE;
-Bool xf86DoConfigure = FALSE;
-Bool xf86DoShowOptions = FALSE;
-DriverPtr *xf86DriverList = NULL;
-int xf86NumDrivers = 0;
-InputDriverPtr *xf86InputDriverList = NULL;
-int xf86NumInputDrivers = 0;
-int xf86NumScreens = 0;
-
-const char *xf86VisualNames[] = {
- "StaticGray",
- "GrayScale",
- "StaticColor",
- "PseudoColor",
- "TrueColor",
- "DirectColor"
-};
-
-/* Parameters set only from the command line */
-char *xf86ServerName = "no-name";
-Bool xf86fpFlag = FALSE;
-Bool xf86sFlag = FALSE;
-Bool xf86bsEnableFlag = FALSE;
-Bool xf86bsDisableFlag = FALSE;
-Bool xf86silkenMouseDisableFlag = FALSE;
-Bool xf86xkbdirFlag = FALSE;
-#ifdef HAVE_ACPI
-Bool xf86acpiDisableFlag = FALSE;
-#endif
-char *xf86LayoutName = NULL;
-char *xf86ScreenName = NULL;
-char *xf86PointerName = NULL;
-char *xf86KeyboardName = NULL;
-int xf86Verbose = DEFAULT_VERBOSE;
-int xf86LogVerbose = DEFAULT_LOG_VERBOSE;
-int xf86FbBpp = -1;
-Pix24Flags xf86Pix24 = Pix24DontCare;
-int xf86Depth = -1;
-rgb xf86Weight = {0, 0, 0};
-Bool xf86FlipPixels = FALSE;
-Gamma xf86Gamma = {0.0, 0.0, 0.0};
-Bool xf86AllowMouseOpenFail = FALSE;
-#ifdef XF86VIDMODE
-Bool xf86VidModeDisabled = FALSE;
-Bool xf86VidModeAllowNonLocal = FALSE;
-#endif
-RootWinPropPtr *xf86RegisteredPropertiesTable = NULL;
-Bool xf86inSuspend = FALSE;
-Bool xorgHWAccess = FALSE;
+
+/*
+ * 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 all the XFree86 global variables.
+ */
+
+#ifdef HAVE_XORG_CONFIG_H
+#include <xorg-config.h>
+#endif
+
+#include <X11/X.h>
+#include "os.h"
+#include "windowstr.h"
+#include "propertyst.h"
+#include "xf86.h"
+#include "xf86Priv.h"
+#include "xf86Parser.h"
+#include "xf86Xinput.h"
+#include "xf86InPriv.h"
+#include "xf86Config.h"
+
+/* Globals that video drivers may access */
+
+DevPrivateKeyRec xf86CreateRootWindowKeyRec;
+DevPrivateKeyRec xf86ScreenKeyRec;
+
+ScrnInfoPtr *xf86Screens = NULL; /* List of ScrnInfos */
+const unsigned char byte_reversed[256] =
+{
+ 0x00, 0x80, 0x40, 0xc0, 0x20, 0xa0, 0x60, 0xe0,
+ 0x10, 0x90, 0x50, 0xd0, 0x30, 0xb0, 0x70, 0xf0,
+ 0x08, 0x88, 0x48, 0xc8, 0x28, 0xa8, 0x68, 0xe8,
+ 0x18, 0x98, 0x58, 0xd8, 0x38, 0xb8, 0x78, 0xf8,
+ 0x04, 0x84, 0x44, 0xc4, 0x24, 0xa4, 0x64, 0xe4,
+ 0x14, 0x94, 0x54, 0xd4, 0x34, 0xb4, 0x74, 0xf4,
+ 0x0c, 0x8c, 0x4c, 0xcc, 0x2c, 0xac, 0x6c, 0xec,
+ 0x1c, 0x9c, 0x5c, 0xdc, 0x3c, 0xbc, 0x7c, 0xfc,
+ 0x02, 0x82, 0x42, 0xc2, 0x22, 0xa2, 0x62, 0xe2,
+ 0x12, 0x92, 0x52, 0xd2, 0x32, 0xb2, 0x72, 0xf2,
+ 0x0a, 0x8a, 0x4a, 0xca, 0x2a, 0xaa, 0x6a, 0xea,
+ 0x1a, 0x9a, 0x5a, 0xda, 0x3a, 0xba, 0x7a, 0xfa,
+ 0x06, 0x86, 0x46, 0xc6, 0x26, 0xa6, 0x66, 0xe6,
+ 0x16, 0x96, 0x56, 0xd6, 0x36, 0xb6, 0x76, 0xf6,
+ 0x0e, 0x8e, 0x4e, 0xce, 0x2e, 0xae, 0x6e, 0xee,
+ 0x1e, 0x9e, 0x5e, 0xde, 0x3e, 0xbe, 0x7e, 0xfe,
+ 0x01, 0x81, 0x41, 0xc1, 0x21, 0xa1, 0x61, 0xe1,
+ 0x11, 0x91, 0x51, 0xd1, 0x31, 0xb1, 0x71, 0xf1,
+ 0x09, 0x89, 0x49, 0xc9, 0x29, 0xa9, 0x69, 0xe9,
+ 0x19, 0x99, 0x59, 0xd9, 0x39, 0xb9, 0x79, 0xf9,
+ 0x05, 0x85, 0x45, 0xc5, 0x25, 0xa5, 0x65, 0xe5,
+ 0x15, 0x95, 0x55, 0xd5, 0x35, 0xb5, 0x75, 0xf5,
+ 0x0d, 0x8d, 0x4d, 0xcd, 0x2d, 0xad, 0x6d, 0xed,
+ 0x1d, 0x9d, 0x5d, 0xdd, 0x3d, 0xbd, 0x7d, 0xfd,
+ 0x03, 0x83, 0x43, 0xc3, 0x23, 0xa3, 0x63, 0xe3,
+ 0x13, 0x93, 0x53, 0xd3, 0x33, 0xb3, 0x73, 0xf3,
+ 0x0b, 0x8b, 0x4b, 0xcb, 0x2b, 0xab, 0x6b, 0xeb,
+ 0x1b, 0x9b, 0x5b, 0xdb, 0x3b, 0xbb, 0x7b, 0xfb,
+ 0x07, 0x87, 0x47, 0xc7, 0x27, 0xa7, 0x67, 0xe7,
+ 0x17, 0x97, 0x57, 0xd7, 0x37, 0xb7, 0x77, 0xf7,
+ 0x0f, 0x8f, 0x4f, 0xcf, 0x2f, 0xaf, 0x6f, 0xef,
+ 0x1f, 0x9f, 0x5f, 0xdf, 0x3f, 0xbf, 0x7f, 0xff,
+};
+
+/* Globals that input drivers may access */
+InputInfoPtr xf86InputDevs = NULL;
+
+
+/* Globals that video drivers may not access */
+
+xf86InfoRec xf86Info = {
+ .consoleFd = -1,
+ .vtno = -1,
+ .vtSysreq = FALSE,
+ .lastEventTime = -1,
+ .vtRequestsPending = FALSE,
+#ifdef sun
+ .vtPendingNum = -1,
+#endif
+ .dontVTSwitch = FALSE,
+ .dontZap = FALSE,
+ .dontZoom = FALSE,
+ .notrapSignals = FALSE,
+ .caughtSignal = FALSE,
+ .currentScreen = NULL,
+#ifdef CSRG_BASED
+ .screenFd = -1,
+ .consType = -1,
+#endif
+ .allowMouseOpenFail = FALSE,
+ .vidModeEnabled = TRUE,
+ .vidModeAllowNonLocal = FALSE,
+ .miscModInDevEnabled = TRUE,
+ .miscModInDevAllowNonLocal = FALSE,
+ .pixmap24 = Pix24DontCare,
+ .pix24From = X_DEFAULT,
+#ifdef SUPPORT_PC98
+ .pc98 = FALSE,
+#endif
+ .pmFlag = TRUE,
+ .log = LogNone,
+ .disableRandR = FALSE,
+ .randRFrom = X_DEFAULT,
+#if defined(CONFIG_HAL) || defined(CONFIG_UDEV)
+ .forceInputDevices = FALSE,
+ .autoAddDevices = TRUE,
+ .autoEnableDevices = TRUE
+#else
+ .forceInputDevices = TRUE,
+ .autoAddDevices = FALSE,
+ .autoEnableDevices = FALSE
+#endif
+};
+const char *xf86ConfigFile = NULL;
+const char *xf86ConfigDir = NULL;
+const char *xf86ModulePath = DEFAULT_MODULE_PATH;
+MessageType xf86ModPathFrom = X_DEFAULT;
+const char *xf86LogFile = DEFAULT_LOGPREFIX;
+MessageType xf86LogFileFrom = X_DEFAULT;
+Bool xf86LogFileWasOpened = FALSE;
+serverLayoutRec xf86ConfigLayout = {NULL, };
+confDRIRec xf86ConfigDRI = {0, };
+XF86ConfigPtr xf86configptr = NULL;
+Bool xf86Resetting = FALSE;
+Bool xf86Initialising = FALSE;
+Bool xf86DoConfigure = FALSE;
+Bool xf86DoShowOptions = FALSE;
+DriverPtr *xf86DriverList = NULL;
+int xf86NumDrivers = 0;
+InputDriverPtr *xf86InputDriverList = NULL;
+int xf86NumInputDrivers = 0;
+int xf86NumScreens = 0;
+
+const char *xf86VisualNames[] = {
+ "StaticGray",
+ "GrayScale",
+ "StaticColor",
+ "PseudoColor",
+ "TrueColor",
+ "DirectColor"
+};
+
+/* Parameters set only from the command line */
+char *xf86ServerName = "no-name";
+Bool xf86fpFlag = FALSE;
+Bool xf86sFlag = FALSE;
+Bool xf86bsEnableFlag = FALSE;
+Bool xf86bsDisableFlag = FALSE;
+Bool xf86silkenMouseDisableFlag = FALSE;
+Bool xf86xkbdirFlag = FALSE;
+#ifdef HAVE_ACPI
+Bool xf86acpiDisableFlag = FALSE;
+#endif
+char *xf86LayoutName = NULL;
+char *xf86ScreenName = NULL;
+char *xf86PointerName = NULL;
+char *xf86KeyboardName = NULL;
+int xf86Verbose = DEFAULT_VERBOSE;
+int xf86LogVerbose = DEFAULT_LOG_VERBOSE;
+int xf86FbBpp = -1;
+Pix24Flags xf86Pix24 = Pix24DontCare;
+int xf86Depth = -1;
+rgb xf86Weight = {0, 0, 0};
+Bool xf86FlipPixels = FALSE;
+Gamma xf86Gamma = {0.0, 0.0, 0.0};
+Bool xf86AllowMouseOpenFail = FALSE;
+#ifdef XF86VIDMODE
+Bool xf86VidModeDisabled = FALSE;
+Bool xf86VidModeAllowNonLocal = FALSE;
+#endif
+RootWinPropPtr *xf86RegisteredPropertiesTable = NULL;
+Bool xorgHWAccess = FALSE;
diff --git a/xorg-server/hw/xfree86/common/xf86Init.c b/xorg-server/hw/xfree86/common/xf86Init.c
index f3ce3f696..a1fda54cd 100644
--- a/xorg-server/hw/xfree86/common/xf86Init.c
+++ b/xorg-server/hw/xfree86/common/xf86Init.c
@@ -1,1510 +1,1497 @@
-/*
- * Loosely based on code bearing the following copyright:
- *
- * Copyright 1990,91 by Thomas Roell, Dinkelscherben, Germany.
- */
-/*
- * Copyright (c) 1992-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 <stdlib.h>
-#include <errno.h>
-
-#undef HAS_UTSNAME
-#if !defined(WIN32)
-#define HAS_UTSNAME 1
-#include <sys/utsname.h>
-#endif
-
-#include <X11/X.h>
-#include <X11/Xmd.h>
-#include <X11/Xproto.h>
-#include <X11/Xatom.h>
-#include "input.h"
-#include "servermd.h"
-#include "windowstr.h"
-#include "scrnintstr.h"
-#include "site.h"
-#include "mi.h"
-
-#include "compiler.h"
-
-#include "loaderProcs.h"
-#ifdef XFreeXDGA
-#include "dgaproc.h"
-#endif
-
-#define XF86_OS_PRIVS
-#include "xf86.h"
-#include "xf86Priv.h"
-#include "xf86Config.h"
-#include "xf86_OSlib.h"
-#include "xf86cmap.h"
-#include "xorgVersion.h"
-#include "xf86Build.h"
-#include "mipointer.h"
-#include <X11/extensions/XI.h>
-#include <X11/extensions/XIproto.h>
-#include "xf86DDC.h"
-#include "xf86Xinput.h"
-#include "xf86InPriv.h"
-#include "picturestr.h"
-
-#include "xf86Bus.h"
-#include "xf86VGAarbiter.h"
-#include "globals.h"
-
-#ifdef DPMSExtension
-#include <X11/extensions/dpmsconst.h>
-#include "dpmsproc.h"
-#endif
-#include <hotplug.h>
-
-
-#ifdef XF86PM
-void (*xf86OSPMClose)(void) = NULL;
-#endif
-static Bool xorgHWOpenConsole = FALSE;
-
-/* Common pixmap formats */
-
-static PixmapFormatRec formats[MAXFORMATS] = {
- { 1, 1, BITMAP_SCANLINE_PAD },
- { 4, 8, BITMAP_SCANLINE_PAD },
- { 8, 8, BITMAP_SCANLINE_PAD },
- { 15, 16, BITMAP_SCANLINE_PAD },
- { 16, 16, BITMAP_SCANLINE_PAD },
- { 24, 32, BITMAP_SCANLINE_PAD },
- { 32, 32, BITMAP_SCANLINE_PAD },
-};
-static int numFormats = 7;
-static Bool formatsDone = FALSE;
-
-#ifndef OSNAME
-#define OSNAME " unknown"
-#endif
-#ifndef OSVENDOR
-#define OSVENDOR ""
-#endif
-#ifndef PRE_RELEASE
-#define PRE_RELEASE XORG_VERSION_SNAP
-#endif
-
-static void
-xf86PrintBanner(void)
-{
-#if PRE_RELEASE
- xf86ErrorFVerb(0, "\n"
- "This is a pre-release version of the X server from " XVENDORNAME ".\n"
- "It is not supported in any way.\n"
- "Bugs may be filed in the bugzilla at http://bugs.freedesktop.org/.\n"
- "Select the \"xorg\" product for bugs you find in this release.\n"
- "Before reporting bugs in pre-release versions please check the\n"
- "latest version in the X.Org Foundation git repository.\n"
- "See http://wiki.x.org/wiki/GitPage for git access instructions.\n");
-#endif
- xf86ErrorFVerb(0, "\nX.Org X Server %d.%d.%d",
- XORG_VERSION_MAJOR,
- XORG_VERSION_MINOR,
- XORG_VERSION_PATCH);
-#if XORG_VERSION_SNAP > 0
- xf86ErrorFVerb(0, ".%d", XORG_VERSION_SNAP);
-#endif
-
-#if XORG_VERSION_SNAP >= 900
- /* When the minor number is 99, that signifies that the we are making
- * a release candidate for a major version. (X.0.0)
- * When the patch number is 99, that signifies that the we are making
- * a release candidate for a minor version. (X.Y.0)
- * When the patch number is < 99, then we are making a release
- * candidate for the next point release. (X.Y.Z)
- */
-#if XORG_VERSION_MINOR >= 99
- xf86ErrorFVerb(0, " (%d.0.0 RC %d)", XORG_VERSION_MAJOR+1,
- XORG_VERSION_SNAP - 900);
-#elif XORG_VERSION_PATCH == 99
- xf86ErrorFVerb(0, " (%d.%d.0 RC %d)", XORG_VERSION_MAJOR,
- XORG_VERSION_MINOR + 1, XORG_VERSION_SNAP - 900);
-#else
- xf86ErrorFVerb(0, " (%d.%d.%d RC %d)", XORG_VERSION_MAJOR,
- XORG_VERSION_MINOR, XORG_VERSION_PATCH + 1,
- XORG_VERSION_SNAP - 900);
-#endif
-#endif
-
-#ifdef XORG_CUSTOM_VERSION
- xf86ErrorFVerb(0, " (%s)", XORG_CUSTOM_VERSION);
-#endif
-#ifndef XORG_DATE
-# define XORG_DATE "Unknown"
-#endif
- xf86ErrorFVerb(0, "\nRelease Date: %s\n", XORG_DATE);
- xf86ErrorFVerb(0, "X Protocol Version %d, Revision %d\n",
- X_PROTOCOL, X_PROTOCOL_REVISION);
- xf86ErrorFVerb(0, "Build Operating System: %s %s\n", OSNAME, OSVENDOR);
-#ifdef HAS_UTSNAME
- {
- struct utsname name;
-
- /* Linux & BSD state that 0 is success, SysV (including Solaris, HP-UX,
- and Irix) and Single Unix Spec 3 just say that non-negative is success.
- All agree that failure is represented by a negative number.
- */
- if (uname(&name) >= 0) {
- xf86ErrorFVerb(0, "Current Operating System: %s %s %s %s %s\n",
- name.sysname, name.nodename, name.release, name.version, name.machine);
-#ifdef linux
- do {
- char buf[80];
- int fd = open("/proc/cmdline", O_RDONLY);
- if (fd != -1) {
- xf86ErrorFVerb(0, "Kernel command line: ");
- memset(buf, 0, 80);
- while (read(fd, buf, 80) > 0) {
- xf86ErrorFVerb(0, "%.80s", buf);
- memset(buf, 0, 80);
- }
- close(fd);
- }
- } while (0);
-#endif
- }
- }
-#endif
-#if defined(BUILD_DATE) && (BUILD_DATE > 19000000)
- {
- struct tm t;
- char buf[100];
-
- memset(&t, 0, sizeof(t));
- memset(buf, 0, sizeof(buf));
- t.tm_mday = BUILD_DATE % 100;
- t.tm_mon = (BUILD_DATE / 100) % 100 - 1;
- t.tm_year = BUILD_DATE / 10000 - 1900;
-#if defined(BUILD_TIME)
- t.tm_sec = BUILD_TIME % 100;
- t.tm_min = (BUILD_TIME / 100) % 100;
- t.tm_hour = (BUILD_TIME / 10000) % 100;
- if (strftime(buf, sizeof(buf), "%d %B %Y %I:%M:%S%p", &t))
- xf86ErrorFVerb(0, "Build Date: %s\n", buf);
-#else
- if (strftime(buf, sizeof(buf), "%d %B %Y", &t))
- xf86ErrorFVerb(0, "Build Date: %s\n", buf);
-#endif
- }
-#endif
-#if defined(BUILDERSTRING)
- xf86ErrorFVerb(0, "%s \n", BUILDERSTRING);
-#endif
- xf86ErrorFVerb(0, "Current version of pixman: %s\n",
- pixman_version_string());
- xf86ErrorFVerb(0, "\tBefore reporting problems, check "
- ""__VENDORDWEBSUPPORT__"\n"
- "\tto make sure that you have the latest version.\n");
-}
-
-static void
-xf86PrintMarkers(void)
-{
- LogPrintMarkers();
-}
-
-static Bool
-xf86CreateRootWindow(WindowPtr pWin)
-{
- int ret = TRUE;
- int err = Success;
- ScreenPtr pScreen = pWin->drawable.pScreen;
- RootWinPropPtr pProp;
- CreateWindowProcPtr CreateWindow = (CreateWindowProcPtr)
- dixLookupPrivate(&pScreen->devPrivates, xf86CreateRootWindowKey);
-
- DebugF("xf86CreateRootWindow(%p)\n", pWin);
-
- if ( pScreen->CreateWindow != xf86CreateRootWindow ) {
- /* Can't find hook we are hung on */
- xf86DrvMsg(pScreen->myNum, X_WARNING /* X_ERROR */,
- "xf86CreateRootWindow %p called when not in pScreen->CreateWindow %p n",
- (void *)xf86CreateRootWindow,
- (void *)pScreen->CreateWindow );
- }
-
- /* Unhook this function ... */
- pScreen->CreateWindow = CreateWindow;
- dixSetPrivate(&pScreen->devPrivates, xf86CreateRootWindowKey, NULL);
-
- /* ... and call the previous CreateWindow fuction, if any */
- if (NULL!=pScreen->CreateWindow) {
- ret = (*pScreen->CreateWindow)(pWin);
- }
-
- /* Now do our stuff */
- if (xf86RegisteredPropertiesTable != NULL) {
- if (pWin->parent == NULL && xf86RegisteredPropertiesTable != NULL) {
- for (pProp = xf86RegisteredPropertiesTable[pScreen->myNum];
- pProp != NULL && err==Success;
- pProp = pProp->next )
- {
- Atom prop;
-
- prop = MakeAtom(pProp->name, strlen(pProp->name), TRUE);
- err = dixChangeWindowProperty(serverClient, pWin,
- prop, pProp->type,
- pProp->format, PropModeReplace,
- pProp->size, pProp->data,
- FALSE);
- }
-
- /* Look at err */
- ret &= (err==Success);
-
- } else {
- xf86Msg(X_ERROR, "xf86CreateRootWindow unexpectedly called with "
- "non-root window %p (parent %p)\n",
- (void *)pWin, (void *)pWin->parent);
- ret = FALSE;
- }
- }
-
- DebugF("xf86CreateRootWindow() returns %d\n", ret);
- return ret;
-}
-
-
-static void
-InstallSignalHandlers(void)
-{
- /*
- * Install signal handler for unexpected signals
- */
- xf86Info.caughtSignal=FALSE;
- if (!xf86Info.notrapSignals) {
- OsRegisterSigWrapper(xf86SigWrapper);
- } else {
- signal(SIGSEGV, SIG_DFL);
- signal(SIGILL, SIG_DFL);
-#ifdef SIGEMT
- signal(SIGEMT, SIG_DFL);
-#endif
- signal(SIGFPE, SIG_DFL);
- signal(SIGBUS, SIG_DFL);
- signal(SIGSYS, SIG_DFL);
- signal(SIGXCPU, SIG_DFL);
- signal(SIGXFSZ, SIG_DFL);
- }
-}
-
-/*
- * InitOutput --
- * Initialize screenInfo for all actually accessible framebuffers.
- * That includes vt-manager setup, querying all possible devices and
- * collecting the pixmap formats.
- */
-void
-InitOutput(ScreenInfo *pScreenInfo, int argc, char **argv)
-{
- int i, j, k, scr_index;
- char **modulelist;
- pointer *optionlist;
- Pix24Flags screenpix24, pix24;
- MessageType pix24From = X_DEFAULT;
- Bool pix24Fail = FALSE;
- Bool autoconfig = FALSE;
- GDevPtr configured_device;
-
- xf86Initialising = TRUE;
-
- if (serverGeneration == 1) {
- if ((xf86ServerName = strrchr(argv[0], '/')) != 0)
- xf86ServerName++;
- else
- xf86ServerName = argv[0];
-
- xf86PrintBanner();
- xf86PrintMarkers();
- if (xf86LogFile) {
- time_t t;
- const char *ct;
- t = time(NULL);
- ct = ctime(&t);
- xf86MsgVerb(xf86LogFileFrom, 0, "Log file: \"%s\", Time: %s",
- xf86LogFile, ct);
- }
-
- /* Read and parse the config file */
- if (!xf86DoConfigure && !xf86DoShowOptions) {
- switch (xf86HandleConfigFile(FALSE)) {
- case CONFIG_OK:
- break;
- case CONFIG_PARSE_ERROR:
- xf86Msg(X_ERROR, "Error parsing the config file\n");
- return;
- case CONFIG_NOFILE:
- autoconfig = TRUE;
- break;
- }
- }
-
- InstallSignalHandlers();
-
- /* Initialise the loader */
- LoaderInit();
-
- /* Tell the loader the default module search path */
- LoaderSetPath(xf86ModulePath);
-
- if (xf86Info.ignoreABI) {
- LoaderSetOptions(LDR_OPT_ABI_MISMATCH_NONFATAL);
- }
-
- if (xf86DoShowOptions)
- DoShowOptions();
-
- /* Do a general bus probe. This will be a PCI probe for x86 platforms */
- xf86BusProbe();
-
- if (xf86DoConfigure)
- DoConfigure();
-
- if (autoconfig) {
- if (!xf86AutoConfig()) {
- xf86Msg(X_ERROR, "Auto configuration failed\n");
- return;
- }
- }
-
-#ifdef XF86PM
- xf86OSPMClose = xf86OSPMOpen();
-#endif
-
- /* Load all modules specified explicitly in the config file */
- if ((modulelist = xf86ModulelistFromConfig(&optionlist))) {
- xf86LoadModules(modulelist, optionlist);
- free(modulelist);
- free(optionlist);
- }
-
- /* Load all driver modules specified in the config file */
- /* If there aren't any specified in the config file, autoconfig them */
- /* FIXME: Does not handle multiple active screen sections, but I'm not
- * sure if we really want to handle that case*/
- configured_device = xf86ConfigLayout.screens->screen->device;
- if ((!configured_device) || (!configured_device->driver)) {
- if (!autoConfigDevice(configured_device)) {
- xf86Msg(X_ERROR, "Automatic driver configuration failed\n");
- return ;
- }
- }
- if ((modulelist = xf86DriverlistFromConfig())) {
- xf86LoadModules(modulelist, NULL);
- free(modulelist);
- }
-
- /* Load all input driver modules specified in the config file. */
- if ((modulelist = xf86InputDriverlistFromConfig())) {
- xf86LoadModules(modulelist, NULL);
- free(modulelist);
- }
-
- /*
- * It is expected that xf86AddDriver()/xf86AddInputDriver will be
- * called for each driver as it is loaded. Those functions save the
- * module pointers for drivers.
- * XXX Nothing keeps track of them for other modules.
- */
- /* XXX What do we do if not all of these could be loaded? */
-
- /*
- * At this point, xf86DriverList[] is all filled in with entries for
- * each of the drivers to try and xf86NumDrivers has the number of
- * drivers. If there are none, return now.
- */
-
- if (xf86NumDrivers == 0) {
- xf86Msg(X_ERROR, "No drivers available.\n");
- return;
- }
-
- /*
- * Call each of the Identify functions and call the driverFunc to check
- * if HW access is required. The Identify functions print out some
- * identifying information, and anything else that might be
- * needed at this early stage.
- */
-
- for (i = 0; i < xf86NumDrivers; i++) {
- if (xf86DriverList[i]->Identify != NULL)
- xf86DriverList[i]->Identify(0);
-
- if (!xorgHWAccess || !xorgHWOpenConsole) {
- xorgHWFlags flags;
- if(!xf86DriverList[i]->driverFunc
- || !xf86DriverList[i]->driverFunc(NULL,
- GET_REQUIRED_HW_INTERFACES,
- &flags))
- flags = HW_IO;
-
- if(NEED_IO_ENABLED(flags))
- xorgHWAccess = TRUE;
- if(!(flags & HW_SKIP_CONSOLE))
- xorgHWOpenConsole = TRUE;
- }
- }
-
- if (xorgHWOpenConsole)
- xf86OpenConsole();
- else
- xf86Info.dontVTSwitch = TRUE;
-
- if (xf86BusConfig() == FALSE)
- return;
-
- xf86PostProbe();
-
- /*
- * Sort the drivers to match the requested ording. Using a slow
- * bubble sort.
- */
- for (j = 0; j < xf86NumScreens - 1; j++) {
- for (i = 0; i < xf86NumScreens - j - 1; i++) {
- if (xf86Screens[i + 1]->confScreen->screennum <
- xf86Screens[i]->confScreen->screennum) {
- ScrnInfoPtr tmpScrn = xf86Screens[i + 1];
- xf86Screens[i + 1] = xf86Screens[i];
- xf86Screens[i] = tmpScrn;
- }
- }
- }
- /* Fix up the indexes */
- for (i = 0; i < xf86NumScreens; i++) {
- xf86Screens[i]->scrnIndex = i;
- }
-
- /*
- * Call the driver's PreInit()'s to complete initialisation for the first
- * generation.
- */
-
- for (i = 0; i < xf86NumScreens; i++) {
- xf86VGAarbiterScrnInit(xf86Screens[i]);
- xf86VGAarbiterLock(xf86Screens[i]);
- if (xf86Screens[i]->PreInit &&
- xf86Screens[i]->PreInit(xf86Screens[i], 0))
- xf86Screens[i]->configured = TRUE;
- xf86VGAarbiterUnlock(xf86Screens[i]);
- }
- for (i = 0; i < xf86NumScreens; i++)
- if (!xf86Screens[i]->configured)
- xf86DeleteScreen(i--, 0);
-
- /*
- * If no screens left, return now.
- */
-
- if (xf86NumScreens == 0) {
- xf86Msg(X_ERROR,
- "Screen(s) found, but none have a usable configuration.\n");
- return;
- }
-
- for (i = 0; i < xf86NumScreens; i++) {
- if (xf86Screens[i]->name == NULL) {
- XNFasprintf(&xf86Screens[i]->name, "screen%d", i);
- xf86MsgVerb(X_WARNING, 0,
- "Screen driver %d has no name set, using `%s'.\n",
- i, xf86Screens[i]->name);
- }
- }
-
- /* Remove (unload) drivers that are not required */
- for (i = 0; i < xf86NumDrivers; i++)
- if (xf86DriverList[i] && xf86DriverList[i]->refCount <= 0)
- xf86DeleteDriver(i);
-
- /*
- * At this stage we know how many screens there are.
- */
-
- for (i = 0; i < xf86NumScreens; i++)
- xf86InitViewport(xf86Screens[i]);
-
- /*
- * Collect all pixmap formats and check for conflicts at the display
- * level. Should we die here? Or just delete the offending screens?
- */
- screenpix24 = Pix24DontCare;
- for (i = 0; i < xf86NumScreens; i++) {
- if (xf86Screens[i]->imageByteOrder !=
- xf86Screens[0]->imageByteOrder)
- FatalError("Inconsistent display bitmapBitOrder. Exiting\n");
- if (xf86Screens[i]->bitmapScanlinePad !=
- xf86Screens[0]->bitmapScanlinePad)
- FatalError("Inconsistent display bitmapScanlinePad. Exiting\n");
- if (xf86Screens[i]->bitmapScanlineUnit !=
- xf86Screens[0]->bitmapScanlineUnit)
- FatalError("Inconsistent display bitmapScanlineUnit. Exiting\n");
- if (xf86Screens[i]->bitmapBitOrder !=
- xf86Screens[0]->bitmapBitOrder)
- FatalError("Inconsistent display bitmapBitOrder. Exiting\n");
-
- /* Determine the depth 24 pixmap format the screens would like */
- if (xf86Screens[i]->pixmap24 != Pix24DontCare) {
- if (screenpix24 == Pix24DontCare)
- screenpix24 = xf86Screens[i]->pixmap24;
- else if (screenpix24 != xf86Screens[i]->pixmap24)
- FatalError("Inconsistent depth 24 pixmap format. Exiting\n");
- }
- }
- /* check if screenpix24 is consistent with the config/cmdline */
- if (xf86Info.pixmap24 != Pix24DontCare) {
- pix24 = xf86Info.pixmap24;
- pix24From = xf86Info.pix24From;
- if (screenpix24 != Pix24DontCare && screenpix24 != xf86Info.pixmap24)
- pix24Fail = TRUE;
- } else if (screenpix24 != Pix24DontCare) {
- pix24 = screenpix24;
- pix24From = X_PROBED;
- } else
- pix24 = Pix24Use32;
-
- if (pix24Fail)
- FatalError("Screen(s) can't use the required depth 24 pixmap format"
- " (%d). Exiting\n", PIX24TOBPP(pix24));
-
- /* Initialise the depth 24 format */
- for (j = 0; j < numFormats && formats[j].depth != 24; j++)
- ;
- formats[j].bitsPerPixel = PIX24TOBPP(pix24);
-
- /* Collect additional formats */
- for (i = 0; i < xf86NumScreens; i++) {
- for (j = 0; j < xf86Screens[i]->numFormats; j++) {
- for (k = 0; ; k++) {
- if (k >= numFormats) {
- if (k >= MAXFORMATS)
- FatalError("Too many pixmap formats! Exiting\n");
- formats[k] = xf86Screens[i]->formats[j];
- numFormats++;
- break;
- }
- if (formats[k].depth == xf86Screens[i]->formats[j].depth) {
- if ((formats[k].bitsPerPixel ==
- xf86Screens[i]->formats[j].bitsPerPixel) &&
- (formats[k].scanlinePad ==
- xf86Screens[i]->formats[j].scanlinePad))
- break;
- FatalError("Inconsistent pixmap format for depth %d."
- " Exiting\n", formats[k].depth);
- }
- }
- }
- }
- formatsDone = TRUE;
-
- if (xf86Info.vtno >= 0 ) {
-#define VT_ATOM_NAME "XFree86_VT"
- Atom VTAtom=-1;
- CARD32 *VT = NULL;
- int ret;
-
- /* This memory needs to stay available until the screen has been
- initialized, and we can create the property for real.
- */
- if ( (VT = malloc(sizeof(CARD32)))==NULL ) {
- FatalError("Unable to make VT property - out of memory. Exiting...\n");
- }
- *VT = xf86Info.vtno;
-
- VTAtom = MakeAtom(VT_ATOM_NAME, sizeof(VT_ATOM_NAME) - 1, TRUE);
-
- for (i = 0, ret = Success; i < xf86NumScreens && ret == Success; i++) {
- ret = xf86RegisterRootWindowProperty(xf86Screens[i]->scrnIndex,
- VTAtom, XA_INTEGER, 32,
- 1, VT );
- if (ret != Success)
- xf86DrvMsg(xf86Screens[i]->scrnIndex, X_WARNING,
- "Failed to register VT property\n");
- }
- }
-
- /* If a screen uses depth 24, show what the pixmap format is */
- for (i = 0; i < xf86NumScreens; i++) {
- if (xf86Screens[i]->depth == 24) {
- xf86Msg(pix24From, "Depth 24 pixmap format is %d bpp\n",
- PIX24TOBPP(pix24));
- break;
- }
- }
- } else {
- /*
- * serverGeneration != 1; some OSs have to do things here, too.
- */
- if (xorgHWOpenConsole)
- xf86OpenConsole();
-
-#ifdef XF86PM
- /*
- should we reopen it here? We need to deal with an already opened
- device. We could leave this to the OS layer. For now we simply
- close it here
- */
- if (xf86OSPMClose)
- xf86OSPMClose();
- if ((xf86OSPMClose = xf86OSPMOpen()) != NULL)
- xf86MsgVerb(X_INFO, 3, "APM registered successfully\n");
-#endif
-
- /* Make sure full I/O access is enabled */
- if (xorgHWAccess)
- xf86EnableIO();
- }
-
- /*
- * Use the previously collected parts to setup pScreenInfo
- */
-
- pScreenInfo->imageByteOrder = xf86Screens[0]->imageByteOrder;
- pScreenInfo->bitmapScanlinePad = xf86Screens[0]->bitmapScanlinePad;
- pScreenInfo->bitmapScanlineUnit = xf86Screens[0]->bitmapScanlineUnit;
- pScreenInfo->bitmapBitOrder = xf86Screens[0]->bitmapBitOrder;
- pScreenInfo->numPixmapFormats = numFormats;
- for (i = 0; i < numFormats; i++)
- pScreenInfo->formats[i] = formats[i];
-
- /* Make sure the server's VT is active */
-
- if (serverGeneration != 1) {
- xf86Resetting = TRUE;
- /* All screens are in the same state, so just check the first */
- if (!xf86Screens[0]->vtSema) {
-#ifdef HAS_USL_VTS
- ioctl(xf86Info.consoleFd, VT_RELDISP, VT_ACKACQ);
-#endif
- xf86AccessEnter();
- xf86EnterServerState(SETUP);
- }
- }
-#ifdef SCO325
- else {
- /*
- * Under SCO we must ack that we got the console at startup,
- * I think this is the safest way to assure it.
- */
- static int once = 1;
- if (once) {
- once = 0;
- if (ioctl(xf86Info.consoleFd, VT_RELDISP, VT_ACKACQ) < 0)
- xf86Msg(X_WARNING, "VT_ACKACQ failed");
- }
- }
-#endif /* SCO325 */
-
- for (i = 0; i < xf86NumScreens; i++)
- if (!xf86ColormapAllocatePrivates(xf86Screens[i]))
- FatalError("Cannot register DDX private keys");
-
- if (!dixRegisterPrivateKey(&xf86ScreenKeyRec, PRIVATE_SCREEN, 0) ||
- !dixRegisterPrivateKey(&xf86CreateRootWindowKeyRec, PRIVATE_SCREEN, 0))
- FatalError("Cannot register DDX private keys");
-
- for (i = 0; i < xf86NumScreens; i++) {
- xf86VGAarbiterLock(xf86Screens[i]);
- /*
- * Almost everything uses these defaults, and many of those that
- * don't, will wrap them.
- */
- xf86Screens[i]->EnableDisableFBAccess = xf86EnableDisableFBAccess;
-#ifdef XFreeXDGA
- xf86Screens[i]->SetDGAMode = xf86SetDGAMode;
-#endif
- xf86Screens[i]->DPMSSet = NULL;
- xf86Screens[i]->LoadPalette = NULL;
- xf86Screens[i]->SetOverscan = NULL;
- xf86Screens[i]->DriverFunc = NULL;
- xf86Screens[i]->pScreen = NULL;
- scr_index = AddScreen(xf86Screens[i]->ScreenInit, argc, argv);
- xf86VGAarbiterUnlock(xf86Screens[i]);
- if (scr_index == i) {
- /*
- * Hook in our ScrnInfoRec, and initialise some other pScreen
- * fields.
- */
- dixSetPrivate(&screenInfo.screens[scr_index]->devPrivates,
- xf86ScreenKey, xf86Screens[i]);
- xf86Screens[i]->pScreen = screenInfo.screens[scr_index];
- /* The driver should set this, but make sure it is set anyway */
- xf86Screens[i]->vtSema = TRUE;
- } else {
- /* This shouldn't normally happen */
- FatalError("AddScreen/ScreenInit failed for driver %d\n", i);
- }
-
- DebugF("InitOutput - xf86Screens[%d]->pScreen = %p\n",
- i, xf86Screens[i]->pScreen );
- DebugF("xf86Screens[%d]->pScreen->CreateWindow = %p\n",
- i, xf86Screens[i]->pScreen->CreateWindow );
-
- dixSetPrivate(&screenInfo.screens[scr_index]->devPrivates,
- xf86CreateRootWindowKey,
- xf86Screens[i]->pScreen->CreateWindow);
- xf86Screens[i]->pScreen->CreateWindow = xf86CreateRootWindow;
-
- if (PictureGetSubpixelOrder (xf86Screens[i]->pScreen) == SubPixelUnknown)
- {
- xf86MonPtr DDC = (xf86MonPtr)(xf86Screens[i]->monitor->DDC);
- PictureSetSubpixelOrder (xf86Screens[i]->pScreen,
- DDC ?
- (DDC->features.input_type ?
- SubPixelHorizontalRGB : SubPixelNone) :
- SubPixelUnknown);
- }
-#ifdef RANDR
- if (!xf86Info.disableRandR)
- xf86RandRInit (screenInfo.screens[scr_index]);
- xf86Msg(xf86Info.randRFrom, "RandR %s\n",
- xf86Info.disableRandR ? "disabled" : "enabled");
-#endif
- }
-
- xf86PostScreenInit();
-
- xf86InitOrigins();
-
- xf86Resetting = FALSE;
- xf86Initialising = FALSE;
-
- RegisterBlockAndWakeupHandlers((BlockHandlerProcPtr)NoopDDA, xf86Wakeup,
- NULL);
-}
-
-/*
- * InitInput --
- * Initialize all supported input devices.
- */
-
-void
-InitInput(int argc, char **argv)
-{
- InputInfoPtr* pDev;
- DeviceIntPtr dev;
-
- xf86Info.vtRequestsPending = FALSE;
-
- mieqInit();
-
- GetEventList(&xf86Events);
-
- /* Call the PreInit function for each input device instance. */
- for (pDev = xf86ConfigLayout.inputs; pDev && *pDev; pDev++) {
- /* Replace obsolete keyboard driver with kbd */
- if (!xf86NameCmp((*pDev)->driver, "keyboard")) {
- strcpy((*pDev)->driver, "kbd");
- }
-
- /* If one fails, the others will too */
- if (xf86NewInputDevice(*pDev, &dev, TRUE) == BadAlloc)
- break;
- }
-
- config_init();
-}
-
-void
-CloseInput (void)
-{
- config_fini();
-}
-
-/*
- * OsVendorInit --
- * OS/Vendor-specific initialisations. Called from OsInit(), which
- * is called by dix before establishing the well known sockets.
- */
-
-void
-OsVendorInit(void)
-{
- static Bool beenHere = FALSE;
-
- signal(SIGCHLD, SIG_DFL); /* Need to wait for child processes */
-
- if (!beenHere) {
- umask(022);
- xf86LogInit();
- }
-
- /* Set stderr to non-blocking. */
-#ifndef O_NONBLOCK
-#if defined(FNDELAY)
-#define O_NONBLOCK FNDELAY
-#elif defined(O_NDELAY)
-#define O_NONBLOCK O_NDELAY
-#endif
-
-#ifdef O_NONBLOCK
- if (!beenHere) {
- if (geteuid() == 0 && getuid() != geteuid())
- {
- int status;
-
- status = fcntl(fileno(stderr), F_GETFL, 0);
- if (status != -1) {
- fcntl(fileno(stderr), F_SETFL, status | O_NONBLOCK);
- }
- }
- }
-#endif
-#endif
-
- beenHere = TRUE;
-}
-
-/*
- * ddxGiveUp --
- * Device dependent cleanup. Called by by dix before normal server death.
- * For SYSV386 we must switch the terminal back to normal mode. No error-
- * checking here, since there should be restored as much as possible.
- */
-
-void
-ddxGiveUp(void)
-{
- int i;
-
- xf86VGAarbiterFini();
-
-#ifdef XF86PM
- if (xf86OSPMClose)
- xf86OSPMClose();
- xf86OSPMClose = NULL;
-#endif
-
- for (i = 0; i < xf86NumScreens; i++) {
- /*
- * zero all access functions to
- * trap calls when switched away.
- */
- xf86Screens[i]->vtSema = FALSE;
- }
-
-#ifdef XFreeXDGA
- DGAShutdown();
-#endif
-
- if (xorgHWOpenConsole)
- xf86CloseConsole();
-
- xf86CloseLog();
-
- /* If an unexpected signal was caught, dump a core for debugging */
- if (xf86Info.caughtSignal)
- OsAbort();
-}
-
-
-
-/*
- * AbortDDX --
- * DDX - specific abort routine. Called by AbortServer(). The attempt is
- * made to restore all original setting of the displays. Also all devices
- * are closed.
- */
-
-void
-AbortDDX(void)
-{
- int i;
-
- /*
- * try to restore the original video state
- */
-#ifdef DPMSExtension /* Turn screens back on */
- if (DPMSPowerLevel != DPMSModeOn)
- DPMSSet(serverClient, DPMSModeOn);
-#endif
- if (xf86Screens) {
- if (xf86Screens[0]->vtSema)
- xf86EnterServerState(SETUP);
- for (i = 0; i < xf86NumScreens; i++)
- if (xf86Screens[i]->vtSema) {
- /*
- * if we are aborting before ScreenInit() has finished
- * we might not have been wrapped yet. Therefore enable
- * screen explicitely.
- */
- xf86VGAarbiterLock(xf86Screens[i]);
- (xf86Screens[i]->LeaveVT)(i, 0);
- xf86VGAarbiterUnlock(xf86Screens[i]);
- }
- }
-
- xf86AccessLeave();
-
- /*
- * This is needed for an abnormal server exit, since the normal exit stuff
- * MUST also be performed (i.e. the vt must be left in a defined state)
- */
- ddxGiveUp();
-}
-
-void
-OsVendorFatalError(void)
-{
-#ifdef VENDORSUPPORT
- ErrorF("\nPlease refer to your Operating System Vendor support pages\n"
- "at %s for support on this crash.\n",VENDORSUPPORT);
-#else
- ErrorF("\nPlease consult the "XVENDORNAME" support \n"
- "\t at "__VENDORDWEBSUPPORT__"\n for help. \n");
-#endif
- if (xf86LogFile && xf86LogFileWasOpened)
- ErrorF("Please also check the log file at \"%s\" for additional "
- "information.\n", xf86LogFile);
- ErrorF("\n");
-}
-
-int
-xf86SetVerbosity(int verb)
-{
- int save = xf86Verbose;
-
- xf86Verbose = verb;
- LogSetParameter(XLOG_VERBOSITY, verb);
- return save;
-}
-
-int
-xf86SetLogVerbosity(int verb)
-{
- int save = xf86LogVerbose;
-
- xf86LogVerbose = verb;
- LogSetParameter(XLOG_FILE_VERBOSITY, verb);
- return save;
-}
-
-static void
-xf86PrintDefaultModulePath(void)
-{
- ErrorF("%s\n", DEFAULT_MODULE_PATH);
-}
-
-static void
-xf86PrintDefaultLibraryPath(void)
-{
- ErrorF("%s\n", DEFAULT_LIBRARY_PATH);
-}
-
-/*
- * ddxProcessArgument --
- * Process device-dependent command line args. Returns 0 if argument is
- * not device dependent, otherwise Count of number of elements of argv
- * that are part of a device dependent commandline option.
- *
- */
-
-/* ARGSUSED */
-int
-ddxProcessArgument(int argc, char **argv, int i)
-{
-#define CHECK_FOR_REQUIRED_ARGUMENT() \
- if (((i + 1) >= argc) || (!argv[i + 1])) { \
- ErrorF("Required argument to %s not specified\n", argv[i]); \
- UseMsg(); \
- FatalError("Required argument to %s not specified\n", argv[i]); \
- }
-
- /* First the options that are only allowed for root */
- if (!strcmp(argv[i], "-modulepath") || !strcmp(argv[i], "-logfile")) {
- if ( (geteuid() == 0) && (getuid() != 0) ) {
- FatalError("The '%s' option can only be used by root.\n", argv[i]);
- }
- else if (!strcmp(argv[i], "-modulepath"))
- {
- char *mp;
- CHECK_FOR_REQUIRED_ARGUMENT();
- mp = strdup(argv[i + 1]);
- if (!mp)
- FatalError("Can't allocate memory for ModulePath\n");
- xf86ModulePath = mp;
- xf86ModPathFrom = X_CMDLINE;
- return 2;
- }
- else if (!strcmp(argv[i], "-logfile"))
- {
- char *lf;
- CHECK_FOR_REQUIRED_ARGUMENT();
- lf = strdup(argv[i + 1]);
- if (!lf)
- FatalError("Can't allocate memory for LogFile\n");
- xf86LogFile = lf;
- xf86LogFileFrom = X_CMDLINE;
- return 2;
- }
- }
- if (!strcmp(argv[i], "-config") || !strcmp(argv[i], "-xf86config"))
- {
- CHECK_FOR_REQUIRED_ARGUMENT();
- if (getuid() != 0 && !xf86PathIsSafe(argv[i + 1])) {
- FatalError("\nInvalid argument for %s\n"
- "\tFor non-root users, the file specified with %s must be\n"
- "\ta relative path and must not contain any \"..\" elements.\n"
- "\tUsing default "__XCONFIGFILE__" search path.\n\n",
- argv[i], argv[i]);
- }
- xf86ConfigFile = argv[i + 1];
- return 2;
- }
- if (!strcmp(argv[i], "-configdir"))
- {
- CHECK_FOR_REQUIRED_ARGUMENT();
- if (getuid() != 0 && !xf86PathIsSafe(argv[i + 1])) {
- FatalError("\nInvalid argument for %s\n"
- "\tFor non-root users, the file specified with %s must be\n"
- "\ta relative path and must not contain any \"..\" elements.\n"
- "\tUsing default "__XCONFIGDIR__" search path.\n\n",
- argv[i], argv[i]);
- }
- xf86ConfigDir = argv[i + 1];
- return 2;
- }
- if (!strcmp(argv[i],"-flipPixels"))
- {
- xf86FlipPixels = TRUE;
- return 1;
- }
-#ifdef XF86VIDMODE
- if (!strcmp(argv[i],"-disableVidMode"))
- {
- xf86VidModeDisabled = TRUE;
- return 1;
- }
- if (!strcmp(argv[i],"-allowNonLocalXvidtune"))
- {
- xf86VidModeAllowNonLocal = TRUE;
- return 1;
- }
-#endif
- if (!strcmp(argv[i],"-allowMouseOpenFail"))
- {
- xf86AllowMouseOpenFail = TRUE;
- return 1;
- }
- if (!strcmp(argv[i],"-ignoreABI"))
- {
- LoaderSetOptions(LDR_OPT_ABI_MISMATCH_NONFATAL);
- return 1;
- }
- if (!strcmp(argv[i],"-verbose"))
- {
- if (++i < argc && argv[i])
- {
- char *end;
- long val;
- val = strtol(argv[i], &end, 0);
- if (*end == '\0')
- {
- xf86SetVerbosity(val);
- return 2;
- }
- }
- xf86SetVerbosity(++xf86Verbose);
- return 1;
- }
- if (!strcmp(argv[i],"-logverbose"))
- {
- if (++i < argc && argv[i])
- {
- char *end;
- long val;
- val = strtol(argv[i], &end, 0);
- if (*end == '\0')
- {
- xf86SetLogVerbosity(val);
- return 2;
- }
- }
- xf86SetLogVerbosity(++xf86LogVerbose);
- return 1;
- }
- if (!strcmp(argv[i],"-quiet"))
- {
- xf86SetVerbosity(-1);
- return 1;
- }
- if (!strcmp(argv[i],"-showconfig") || !strcmp(argv[i],"-version"))
- {
- xf86PrintBanner();
- exit(0);
- }
- if (!strcmp(argv[i],"-showDefaultModulePath"))
- {
- xf86PrintDefaultModulePath();
- exit(0);
- }
- if (!strcmp(argv[i],"-showDefaultLibPath"))
- {
- xf86PrintDefaultLibraryPath();
- exit(0);
- }
- /* Notice the -fp flag, but allow it to pass to the dix layer */
- if (!strcmp(argv[i], "-fp"))
- {
- xf86fpFlag = TRUE;
- return 0;
- }
- /* Notice the -bs flag, but allow it to pass to the dix layer */
- if (!strcmp(argv[i], "-bs"))
- {
- xf86bsDisableFlag = TRUE;
- return 0;
- }
- /* Notice the +bs flag, but allow it to pass to the dix layer */
- if (!strcmp(argv[i], "+bs"))
- {
- xf86bsEnableFlag = TRUE;
- return 0;
- }
- /* Notice the -s flag, but allow it to pass to the dix layer */
- if (!strcmp(argv[i], "-s"))
- {
- xf86sFlag = TRUE;
- return 0;
- }
- if (!strcmp(argv[i], "-pixmap24"))
- {
- xf86Pix24 = Pix24Use24;
- return 1;
- }
- if (!strcmp(argv[i], "-pixmap32"))
- {
- xf86Pix24 = Pix24Use32;
- return 1;
- }
- if (!strcmp(argv[i], "-fbbpp"))
- {
- int bpp;
- CHECK_FOR_REQUIRED_ARGUMENT();
- if (sscanf(argv[++i], "%d", &bpp) == 1)
- {
- xf86FbBpp = bpp;
- return 2;
- }
- else
- {
- ErrorF("Invalid fbbpp\n");
- return 0;
- }
- }
- if (!strcmp(argv[i], "-depth"))
- {
- int depth;
- CHECK_FOR_REQUIRED_ARGUMENT();
- if (sscanf(argv[++i], "%d", &depth) == 1)
- {
- xf86Depth = depth;
- return 2;
- }
- else
- {
- ErrorF("Invalid depth\n");
- return 0;
- }
- }
- if (!strcmp(argv[i], "-weight"))
- {
- int red, green, blue;
- CHECK_FOR_REQUIRED_ARGUMENT();
- if (sscanf(argv[++i], "%1d%1d%1d", &red, &green, &blue) == 3)
- {
- xf86Weight.red = red;
- xf86Weight.green = green;
- xf86Weight.blue = blue;
- return 2;
- }
- else
- {
- ErrorF("Invalid weighting\n");
- return 0;
- }
- }
- if (!strcmp(argv[i], "-gamma") || !strcmp(argv[i], "-rgamma") ||
- !strcmp(argv[i], "-ggamma") || !strcmp(argv[i], "-bgamma"))
- {
- double gamma;
- CHECK_FOR_REQUIRED_ARGUMENT();
- if (sscanf(argv[++i], "%lf", &gamma) == 1) {
- if (gamma < GAMMA_MIN || gamma > GAMMA_MAX) {
- ErrorF("gamma out of range, only %.2f <= gamma_value <= %.1f"
- " is valid\n", GAMMA_MIN, GAMMA_MAX);
- return 0;
- }
- if (!strcmp(argv[i-1], "-gamma"))
- xf86Gamma.red = xf86Gamma.green = xf86Gamma.blue = gamma;
- else if (!strcmp(argv[i-1], "-rgamma")) xf86Gamma.red = gamma;
- else if (!strcmp(argv[i-1], "-ggamma")) xf86Gamma.green = gamma;
- else if (!strcmp(argv[i-1], "-bgamma")) xf86Gamma.blue = gamma;
- return 2;
- }
- }
- if (!strcmp(argv[i], "-layout"))
- {
- CHECK_FOR_REQUIRED_ARGUMENT();
- xf86LayoutName = argv[++i];
- return 2;
- }
- if (!strcmp(argv[i], "-screen"))
- {
- CHECK_FOR_REQUIRED_ARGUMENT();
- xf86ScreenName = argv[++i];
- return 2;
- }
- if (!strcmp(argv[i], "-pointer"))
- {
- CHECK_FOR_REQUIRED_ARGUMENT();
- xf86PointerName = argv[++i];
- return 2;
- }
- if (!strcmp(argv[i], "-keyboard"))
- {
- CHECK_FOR_REQUIRED_ARGUMENT();
- xf86KeyboardName = argv[++i];
- return 2;
- }
- if (!strcmp(argv[i], "-nosilk"))
- {
- xf86silkenMouseDisableFlag = TRUE;
- return 1;
- }
-#ifdef HAVE_ACPI
- if (!strcmp(argv[i], "-noacpi"))
- {
- xf86acpiDisableFlag = TRUE;
- return 1;
- }
-#endif
- if (!strcmp(argv[i], "-configure"))
- {
- if (getuid() != 0 && geteuid() == 0) {
- ErrorF("The '-configure' option can only be used by root.\n");
- exit(1);
- }
- xf86DoConfigure = TRUE;
- xf86AllowMouseOpenFail = TRUE;
- return 1;
- }
- if (!strcmp(argv[i], "-showopts"))
- {
- if (getuid() != 0 && geteuid() == 0) {
- ErrorF("The '-showopts' option can only be used by root.\n");
- exit(1);
- }
- xf86DoShowOptions = TRUE;
- return 1;
- }
- if (!strcmp(argv[i], "-isolateDevice"))
- {
- CHECK_FOR_REQUIRED_ARGUMENT();
- if (strncmp(argv[++i], "PCI:", 4)) {
- FatalError("Bus types other than PCI not yet isolable\n");
- }
- xf86PciIsolateDevice(argv[i]);
- return 2;
- }
- /* Notice cmdline xkbdir, but pass to dix as well */
- if (!strcmp(argv[i], "-xkbdir"))
- {
- xf86xkbdirFlag = TRUE;
- return 0;
- }
-
- /* OS-specific processing */
- return xf86ProcessArgument(argc, argv, i);
-}
-
-/*
- * ddxUseMsg --
- * Print out correct use of device dependent commandline options.
- * Maybe the user now knows what really to do ...
- */
-
-void
-ddxUseMsg(void)
-{
- ErrorF("\n");
- ErrorF("\n");
- ErrorF("Device Dependent Usage\n");
- if (getuid() == 0 || geteuid() != 0)
- {
- ErrorF("-modulepath paths specify the module search path\n");
- ErrorF("-logfile file specify a log file name\n");
- ErrorF("-configure probe for devices and write an "__XCONFIGFILE__"\n");
- ErrorF("-showopts print available options for all installed drivers\n");
- }
- ErrorF("-config file specify a configuration file, relative to the\n");
- ErrorF(" "__XCONFIGFILE__" search path, only root can use absolute\n");
- ErrorF("-configdir dir specify a configuration directory, relative to the\n");
- ErrorF(" "__XCONFIGDIR__" search path, only root can use absolute\n");
- ErrorF("-verbose [n] verbose startup messages\n");
- ErrorF("-logverbose [n] verbose log messages\n");
- ErrorF("-quiet minimal startup messages\n");
- ErrorF("-pixmap24 use 24bpp pixmaps for depth 24\n");
- ErrorF("-pixmap32 use 32bpp pixmaps for depth 24\n");
- ErrorF("-fbbpp n set bpp for the framebuffer. Default: 8\n");
- ErrorF("-depth n set colour depth. Default: 8\n");
- ErrorF("-gamma f set gamma value (0.1 < f < 10.0) Default: 1.0\n");
- ErrorF("-rgamma f set gamma value for red phase\n");
- ErrorF("-ggamma f set gamma value for green phase\n");
- ErrorF("-bgamma f set gamma value for blue phase\n");
- ErrorF("-weight nnn set RGB weighting at 16 bpp. Default: 565\n");
- ErrorF("-layout name specify the ServerLayout section name\n");
- ErrorF("-screen name specify the Screen section name\n");
- ErrorF("-keyboard name specify the core keyboard InputDevice name\n");
- ErrorF("-pointer name specify the core pointer InputDevice name\n");
- ErrorF("-nosilk disable Silken Mouse\n");
- ErrorF("-flipPixels swap default black/white Pixel values\n");
-#ifdef XF86VIDMODE
- ErrorF("-disableVidMode disable mode adjustments with xvidtune\n");
- ErrorF("-allowNonLocalXvidtune allow xvidtune to be run as a non-local client\n");
-#endif
- ErrorF("-allowMouseOpenFail start server even if the mouse can't be initialized\n");
- ErrorF("-ignoreABI make module ABI mismatches non-fatal\n");
- ErrorF("-isolateDevice bus_id restrict device resets to bus_id (PCI only)\n");
- 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");
- /* OS-specific usage */
- xf86UseMsg();
- ErrorF("\n");
-}
-
-
-/*
- * xf86LoadModules iterates over a list that is being passed in.
- */
-Bool
-xf86LoadModules(char **list, pointer *optlist)
-{
- int errmaj, errmin;
- pointer opt;
- int i;
- char *name;
- Bool failed = FALSE;
-
- if (!list)
- return TRUE;
-
- for (i = 0; list[i] != NULL; i++) {
-
- /* Normalise the module name */
- name = xf86NormalizeName(list[i]);
-
- /* Skip empty names */
- if (name == NULL || *name == '\0')
- continue;
-
- /* Replace obsolete keyboard driver with kbd */
- if (!xf86NameCmp(name, "keyboard")) {
- strcpy(name, "kbd");
- }
-
- if (optlist)
- opt = optlist[i];
- else
- opt = NULL;
-
- if (!LoadModule(name, NULL, NULL, NULL, opt, NULL, &errmaj, &errmin)) {
- LoaderErrorMsg(NULL, name, errmaj, errmin);
- failed = TRUE;
- }
- free(name);
- }
- return !failed;
-}
-
-/* Pixmap format stuff */
-
-PixmapFormatPtr
-xf86GetPixFormat(ScrnInfoPtr pScrn, int depth)
-{
- int i;
- static PixmapFormatRec format; /* XXX not reentrant */
-
- /*
- * When the formats[] list initialisation isn't complete, check the
- * depth 24 pixmap config/cmdline options and screen-specified formats.
- */
-
- if (!formatsDone) {
- if (depth == 24) {
- Pix24Flags pix24 = Pix24DontCare;
-
- format.depth = 24;
- format.scanlinePad = BITMAP_SCANLINE_PAD;
- if (xf86Info.pixmap24 != Pix24DontCare)
- pix24 = xf86Info.pixmap24;
- else if (pScrn->pixmap24 != Pix24DontCare)
- pix24 = pScrn->pixmap24;
- if (pix24 == Pix24Use24)
- format.bitsPerPixel = 24;
- else
- format.bitsPerPixel = 32;
- return &format;
- }
- }
-
- for (i = 0; i < numFormats; i++)
- if (formats[i].depth == depth)
- break;
- if (i != numFormats)
- return &formats[i];
- else if (!formatsDone) {
- /* Check for screen-specified formats */
- for (i = 0; i < pScrn->numFormats; i++)
- if (pScrn->formats[i].depth == depth)
- break;
- if (i != pScrn->numFormats)
- return &pScrn->formats[i];
- }
- return NULL;
-}
-
-int
-xf86GetBppFromDepth(ScrnInfoPtr pScrn, int depth)
-{
- PixmapFormatPtr format;
-
-
- format = xf86GetPixFormat(pScrn, depth);
- if (format)
- return format->bitsPerPixel;
- else
- return 0;
-}
+/*
+ * Loosely based on code bearing the following copyright:
+ *
+ * Copyright 1990,91 by Thomas Roell, Dinkelscherben, Germany.
+ */
+/*
+ * Copyright (c) 1992-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 <stdlib.h>
+#include <errno.h>
+
+#undef HAS_UTSNAME
+#if !defined(WIN32)
+#define HAS_UTSNAME 1
+#include <sys/utsname.h>
+#endif
+
+#include <X11/X.h>
+#include <X11/Xmd.h>
+#include <X11/Xproto.h>
+#include <X11/Xatom.h>
+#include "input.h"
+#include "servermd.h"
+#include "windowstr.h"
+#include "scrnintstr.h"
+#include "site.h"
+#include "mi.h"
+
+#include "compiler.h"
+
+#include "loaderProcs.h"
+#ifdef XFreeXDGA
+#include "dgaproc.h"
+#endif
+
+#define XF86_OS_PRIVS
+#include "xf86.h"
+#include "xf86Priv.h"
+#include "xf86Config.h"
+#include "xf86_OSlib.h"
+#include "xf86cmap.h"
+#include "xorgVersion.h"
+#include "xf86Build.h"
+#include "mipointer.h"
+#include <X11/extensions/XI.h>
+#include <X11/extensions/XIproto.h>
+#include "xf86DDC.h"
+#include "xf86Xinput.h"
+#include "xf86InPriv.h"
+#include "picturestr.h"
+
+#include "xf86Bus.h"
+#include "xf86VGAarbiter.h"
+#include "globals.h"
+
+#ifdef DPMSExtension
+#include <X11/extensions/dpmsconst.h>
+#include "dpmsproc.h"
+#endif
+#include <hotplug.h>
+
+
+#ifdef XF86PM
+void (*xf86OSPMClose)(void) = NULL;
+#endif
+static Bool xorgHWOpenConsole = FALSE;
+
+/* Common pixmap formats */
+
+static PixmapFormatRec formats[MAXFORMATS] = {
+ { 1, 1, BITMAP_SCANLINE_PAD },
+ { 4, 8, BITMAP_SCANLINE_PAD },
+ { 8, 8, BITMAP_SCANLINE_PAD },
+ { 15, 16, BITMAP_SCANLINE_PAD },
+ { 16, 16, BITMAP_SCANLINE_PAD },
+ { 24, 32, BITMAP_SCANLINE_PAD },
+ { 32, 32, BITMAP_SCANLINE_PAD },
+};
+static int numFormats = 7;
+static Bool formatsDone = FALSE;
+
+#ifndef OSNAME
+#define OSNAME " unknown"
+#endif
+#ifndef OSVENDOR
+#define OSVENDOR ""
+#endif
+#ifndef PRE_RELEASE
+#define PRE_RELEASE XORG_VERSION_SNAP
+#endif
+
+static void
+xf86PrintBanner(void)
+{
+#if PRE_RELEASE
+ xf86ErrorFVerb(0, "\n"
+ "This is a pre-release version of the X server from " XVENDORNAME ".\n"
+ "It is not supported in any way.\n"
+ "Bugs may be filed in the bugzilla at http://bugs.freedesktop.org/.\n"
+ "Select the \"xorg\" product for bugs you find in this release.\n"
+ "Before reporting bugs in pre-release versions please check the\n"
+ "latest version in the X.Org Foundation git repository.\n"
+ "See http://wiki.x.org/wiki/GitPage for git access instructions.\n");
+#endif
+ xf86ErrorFVerb(0, "\nX.Org X Server %d.%d.%d",
+ XORG_VERSION_MAJOR,
+ XORG_VERSION_MINOR,
+ XORG_VERSION_PATCH);
+#if XORG_VERSION_SNAP > 0
+ xf86ErrorFVerb(0, ".%d", XORG_VERSION_SNAP);
+#endif
+
+#if XORG_VERSION_SNAP >= 900
+ /* When the minor number is 99, that signifies that the we are making
+ * a release candidate for a major version. (X.0.0)
+ * When the patch number is 99, that signifies that the we are making
+ * a release candidate for a minor version. (X.Y.0)
+ * When the patch number is < 99, then we are making a release
+ * candidate for the next point release. (X.Y.Z)
+ */
+#if XORG_VERSION_MINOR >= 99
+ xf86ErrorFVerb(0, " (%d.0.0 RC %d)", XORG_VERSION_MAJOR+1,
+ XORG_VERSION_SNAP - 900);
+#elif XORG_VERSION_PATCH == 99
+ xf86ErrorFVerb(0, " (%d.%d.0 RC %d)", XORG_VERSION_MAJOR,
+ XORG_VERSION_MINOR + 1, XORG_VERSION_SNAP - 900);
+#else
+ xf86ErrorFVerb(0, " (%d.%d.%d RC %d)", XORG_VERSION_MAJOR,
+ XORG_VERSION_MINOR, XORG_VERSION_PATCH + 1,
+ XORG_VERSION_SNAP - 900);
+#endif
+#endif
+
+#ifdef XORG_CUSTOM_VERSION
+ xf86ErrorFVerb(0, " (%s)", XORG_CUSTOM_VERSION);
+#endif
+#ifndef XORG_DATE
+# define XORG_DATE "Unknown"
+#endif
+ xf86ErrorFVerb(0, "\nRelease Date: %s\n", XORG_DATE);
+ xf86ErrorFVerb(0, "X Protocol Version %d, Revision %d\n",
+ X_PROTOCOL, X_PROTOCOL_REVISION);
+ xf86ErrorFVerb(0, "Build Operating System: %s %s\n", OSNAME, OSVENDOR);
+#ifdef HAS_UTSNAME
+ {
+ struct utsname name;
+
+ /* Linux & BSD state that 0 is success, SysV (including Solaris, HP-UX,
+ and Irix) and Single Unix Spec 3 just say that non-negative is success.
+ All agree that failure is represented by a negative number.
+ */
+ if (uname(&name) >= 0) {
+ xf86ErrorFVerb(0, "Current Operating System: %s %s %s %s %s\n",
+ name.sysname, name.nodename, name.release, name.version, name.machine);
+#ifdef linux
+ do {
+ char buf[80];
+ int fd = open("/proc/cmdline", O_RDONLY);
+ if (fd != -1) {
+ xf86ErrorFVerb(0, "Kernel command line: ");
+ memset(buf, 0, 80);
+ while (read(fd, buf, 80) > 0) {
+ xf86ErrorFVerb(0, "%.80s", buf);
+ memset(buf, 0, 80);
+ }
+ close(fd);
+ }
+ } while (0);
+#endif
+ }
+ }
+#endif
+#if defined(BUILD_DATE) && (BUILD_DATE > 19000000)
+ {
+ struct tm t;
+ char buf[100];
+
+ memset(&t, 0, sizeof(t));
+ memset(buf, 0, sizeof(buf));
+ t.tm_mday = BUILD_DATE % 100;
+ t.tm_mon = (BUILD_DATE / 100) % 100 - 1;
+ t.tm_year = BUILD_DATE / 10000 - 1900;
+#if defined(BUILD_TIME)
+ t.tm_sec = BUILD_TIME % 100;
+ t.tm_min = (BUILD_TIME / 100) % 100;
+ t.tm_hour = (BUILD_TIME / 10000) % 100;
+ if (strftime(buf, sizeof(buf), "%d %B %Y %I:%M:%S%p", &t))
+ xf86ErrorFVerb(0, "Build Date: %s\n", buf);
+#else
+ if (strftime(buf, sizeof(buf), "%d %B %Y", &t))
+ xf86ErrorFVerb(0, "Build Date: %s\n", buf);
+#endif
+ }
+#endif
+#if defined(BUILDERSTRING)
+ xf86ErrorFVerb(0, "%s \n", BUILDERSTRING);
+#endif
+ xf86ErrorFVerb(0, "Current version of pixman: %s\n",
+ pixman_version_string());
+ xf86ErrorFVerb(0, "\tBefore reporting problems, check "
+ ""__VENDORDWEBSUPPORT__"\n"
+ "\tto make sure that you have the latest version.\n");
+}
+
+static void
+xf86PrintMarkers(void)
+{
+ LogPrintMarkers();
+}
+
+static Bool
+xf86CreateRootWindow(WindowPtr pWin)
+{
+ int ret = TRUE;
+ int err = Success;
+ ScreenPtr pScreen = pWin->drawable.pScreen;
+ RootWinPropPtr pProp;
+ CreateWindowProcPtr CreateWindow = (CreateWindowProcPtr)
+ dixLookupPrivate(&pScreen->devPrivates, xf86CreateRootWindowKey);
+
+ DebugF("xf86CreateRootWindow(%p)\n", pWin);
+
+ if ( pScreen->CreateWindow != xf86CreateRootWindow ) {
+ /* Can't find hook we are hung on */
+ xf86DrvMsg(pScreen->myNum, X_WARNING /* X_ERROR */,
+ "xf86CreateRootWindow %p called when not in pScreen->CreateWindow %p n",
+ (void *)xf86CreateRootWindow,
+ (void *)pScreen->CreateWindow );
+ }
+
+ /* Unhook this function ... */
+ pScreen->CreateWindow = CreateWindow;
+ dixSetPrivate(&pScreen->devPrivates, xf86CreateRootWindowKey, NULL);
+
+ /* ... and call the previous CreateWindow fuction, if any */
+ if (NULL!=pScreen->CreateWindow) {
+ ret = (*pScreen->CreateWindow)(pWin);
+ }
+
+ /* Now do our stuff */
+ if (xf86RegisteredPropertiesTable != NULL) {
+ if (pWin->parent == NULL && xf86RegisteredPropertiesTable != NULL) {
+ for (pProp = xf86RegisteredPropertiesTable[pScreen->myNum];
+ pProp != NULL && err==Success;
+ pProp = pProp->next )
+ {
+ Atom prop;
+
+ prop = MakeAtom(pProp->name, strlen(pProp->name), TRUE);
+ err = dixChangeWindowProperty(serverClient, pWin,
+ prop, pProp->type,
+ pProp->format, PropModeReplace,
+ pProp->size, pProp->data,
+ FALSE);
+ }
+
+ /* Look at err */
+ ret &= (err==Success);
+
+ } else {
+ xf86Msg(X_ERROR, "xf86CreateRootWindow unexpectedly called with "
+ "non-root window %p (parent %p)\n",
+ (void *)pWin, (void *)pWin->parent);
+ ret = FALSE;
+ }
+ }
+
+ DebugF("xf86CreateRootWindow() returns %d\n", ret);
+ return ret;
+}
+
+
+static void
+InstallSignalHandlers(void)
+{
+ /*
+ * Install signal handler for unexpected signals
+ */
+ xf86Info.caughtSignal=FALSE;
+ if (!xf86Info.notrapSignals) {
+ OsRegisterSigWrapper(xf86SigWrapper);
+ } else {
+ signal(SIGSEGV, SIG_DFL);
+ signal(SIGILL, SIG_DFL);
+#ifdef SIGEMT
+ signal(SIGEMT, SIG_DFL);
+#endif
+ signal(SIGFPE, SIG_DFL);
+ signal(SIGBUS, SIG_DFL);
+ signal(SIGSYS, SIG_DFL);
+ signal(SIGXCPU, SIG_DFL);
+ signal(SIGXFSZ, SIG_DFL);
+ }
+}
+
+/*
+ * InitOutput --
+ * Initialize screenInfo for all actually accessible framebuffers.
+ * That includes vt-manager setup, querying all possible devices and
+ * collecting the pixmap formats.
+ */
+void
+InitOutput(ScreenInfo *pScreenInfo, int argc, char **argv)
+{
+ int i, j, k, scr_index, was_blocked = 0;
+ char **modulelist;
+ pointer *optionlist;
+ Pix24Flags screenpix24, pix24;
+ MessageType pix24From = X_DEFAULT;
+ Bool pix24Fail = FALSE;
+ Bool autoconfig = FALSE;
+ GDevPtr configured_device;
+
+ xf86Initialising = TRUE;
+
+ if (serverGeneration == 1) {
+ if ((xf86ServerName = strrchr(argv[0], '/')) != 0)
+ xf86ServerName++;
+ else
+ xf86ServerName = argv[0];
+
+ xf86PrintBanner();
+ xf86PrintMarkers();
+ if (xf86LogFile) {
+ time_t t;
+ const char *ct;
+ t = time(NULL);
+ ct = ctime(&t);
+ xf86MsgVerb(xf86LogFileFrom, 0, "Log file: \"%s\", Time: %s",
+ xf86LogFile, ct);
+ }
+
+ /* Read and parse the config file */
+ if (!xf86DoConfigure && !xf86DoShowOptions) {
+ switch (xf86HandleConfigFile(FALSE)) {
+ case CONFIG_OK:
+ break;
+ case CONFIG_PARSE_ERROR:
+ xf86Msg(X_ERROR, "Error parsing the config file\n");
+ return;
+ case CONFIG_NOFILE:
+ autoconfig = TRUE;
+ break;
+ }
+ }
+
+ InstallSignalHandlers();
+
+ /* Initialise the loader */
+ LoaderInit();
+
+ /* Tell the loader the default module search path */
+ LoaderSetPath(xf86ModulePath);
+
+ if (xf86Info.ignoreABI) {
+ LoaderSetOptions(LDR_OPT_ABI_MISMATCH_NONFATAL);
+ }
+
+ if (xf86DoShowOptions)
+ DoShowOptions();
+
+ /* Do a general bus probe. This will be a PCI probe for x86 platforms */
+ xf86BusProbe();
+
+ if (xf86DoConfigure)
+ DoConfigure();
+
+ if (autoconfig) {
+ if (!xf86AutoConfig()) {
+ xf86Msg(X_ERROR, "Auto configuration failed\n");
+ return;
+ }
+ }
+
+#ifdef XF86PM
+ xf86OSPMClose = xf86OSPMOpen();
+#endif
+
+ /* Load all modules specified explicitly in the config file */
+ if ((modulelist = xf86ModulelistFromConfig(&optionlist))) {
+ xf86LoadModules(modulelist, optionlist);
+ free(modulelist);
+ free(optionlist);
+ }
+
+ /* Load all driver modules specified in the config file */
+ /* If there aren't any specified in the config file, autoconfig them */
+ /* FIXME: Does not handle multiple active screen sections, but I'm not
+ * sure if we really want to handle that case*/
+ configured_device = xf86ConfigLayout.screens->screen->device;
+ if ((!configured_device) || (!configured_device->driver)) {
+ if (!autoConfigDevice(configured_device)) {
+ xf86Msg(X_ERROR, "Automatic driver configuration failed\n");
+ return ;
+ }
+ }
+ if ((modulelist = xf86DriverlistFromConfig())) {
+ xf86LoadModules(modulelist, NULL);
+ free(modulelist);
+ }
+
+ /* Load all input driver modules specified in the config file. */
+ if ((modulelist = xf86InputDriverlistFromConfig())) {
+ xf86LoadModules(modulelist, NULL);
+ free(modulelist);
+ }
+
+ /*
+ * It is expected that xf86AddDriver()/xf86AddInputDriver will be
+ * called for each driver as it is loaded. Those functions save the
+ * module pointers for drivers.
+ * XXX Nothing keeps track of them for other modules.
+ */
+ /* XXX What do we do if not all of these could be loaded? */
+
+ /*
+ * At this point, xf86DriverList[] is all filled in with entries for
+ * each of the drivers to try and xf86NumDrivers has the number of
+ * drivers. If there are none, return now.
+ */
+
+ if (xf86NumDrivers == 0) {
+ xf86Msg(X_ERROR, "No drivers available.\n");
+ return;
+ }
+
+ /*
+ * Call each of the Identify functions and call the driverFunc to check
+ * if HW access is required. The Identify functions print out some
+ * identifying information, and anything else that might be
+ * needed at this early stage.
+ */
+
+ for (i = 0; i < xf86NumDrivers; i++) {
+ if (xf86DriverList[i]->Identify != NULL)
+ xf86DriverList[i]->Identify(0);
+
+ if (!xorgHWAccess || !xorgHWOpenConsole) {
+ xorgHWFlags flags;
+ if(!xf86DriverList[i]->driverFunc
+ || !xf86DriverList[i]->driverFunc(NULL,
+ GET_REQUIRED_HW_INTERFACES,
+ &flags))
+ flags = HW_IO;
+
+ if(NEED_IO_ENABLED(flags))
+ xorgHWAccess = TRUE;
+ if(!(flags & HW_SKIP_CONSOLE))
+ xorgHWOpenConsole = TRUE;
+ }
+ }
+
+ if (xorgHWOpenConsole)
+ xf86OpenConsole();
+ else
+ xf86Info.dontVTSwitch = TRUE;
+
+ if (xf86BusConfig() == FALSE)
+ return;
+
+ xf86PostProbe();
+
+ /*
+ * Sort the drivers to match the requested ording. Using a slow
+ * bubble sort.
+ */
+ for (j = 0; j < xf86NumScreens - 1; j++) {
+ for (i = 0; i < xf86NumScreens - j - 1; i++) {
+ if (xf86Screens[i + 1]->confScreen->screennum <
+ xf86Screens[i]->confScreen->screennum) {
+ ScrnInfoPtr tmpScrn = xf86Screens[i + 1];
+ xf86Screens[i + 1] = xf86Screens[i];
+ xf86Screens[i] = tmpScrn;
+ }
+ }
+ }
+ /* Fix up the indexes */
+ for (i = 0; i < xf86NumScreens; i++) {
+ xf86Screens[i]->scrnIndex = i;
+ }
+
+ /*
+ * Call the driver's PreInit()'s to complete initialisation for the first
+ * generation.
+ */
+
+ for (i = 0; i < xf86NumScreens; i++) {
+ xf86VGAarbiterScrnInit(xf86Screens[i]);
+ xf86VGAarbiterLock(xf86Screens[i]);
+ if (xf86Screens[i]->PreInit &&
+ xf86Screens[i]->PreInit(xf86Screens[i], 0))
+ xf86Screens[i]->configured = TRUE;
+ xf86VGAarbiterUnlock(xf86Screens[i]);
+ }
+ for (i = 0; i < xf86NumScreens; i++)
+ if (!xf86Screens[i]->configured)
+ xf86DeleteScreen(i--, 0);
+
+ /*
+ * If no screens left, return now.
+ */
+
+ if (xf86NumScreens == 0) {
+ xf86Msg(X_ERROR,
+ "Screen(s) found, but none have a usable configuration.\n");
+ return;
+ }
+
+ for (i = 0; i < xf86NumScreens; i++) {
+ if (xf86Screens[i]->name == NULL) {
+ XNFasprintf(&xf86Screens[i]->name, "screen%d", i);
+ xf86MsgVerb(X_WARNING, 0,
+ "Screen driver %d has no name set, using `%s'.\n",
+ i, xf86Screens[i]->name);
+ }
+ }
+
+ /* Remove (unload) drivers that are not required */
+ for (i = 0; i < xf86NumDrivers; i++)
+ if (xf86DriverList[i] && xf86DriverList[i]->refCount <= 0)
+ xf86DeleteDriver(i);
+
+ /*
+ * At this stage we know how many screens there are.
+ */
+
+ for (i = 0; i < xf86NumScreens; i++)
+ xf86InitViewport(xf86Screens[i]);
+
+ /*
+ * Collect all pixmap formats and check for conflicts at the display
+ * level. Should we die here? Or just delete the offending screens?
+ */
+ screenpix24 = Pix24DontCare;
+ for (i = 0; i < xf86NumScreens; i++) {
+ if (xf86Screens[i]->imageByteOrder !=
+ xf86Screens[0]->imageByteOrder)
+ FatalError("Inconsistent display bitmapBitOrder. Exiting\n");
+ if (xf86Screens[i]->bitmapScanlinePad !=
+ xf86Screens[0]->bitmapScanlinePad)
+ FatalError("Inconsistent display bitmapScanlinePad. Exiting\n");
+ if (xf86Screens[i]->bitmapScanlineUnit !=
+ xf86Screens[0]->bitmapScanlineUnit)
+ FatalError("Inconsistent display bitmapScanlineUnit. Exiting\n");
+ if (xf86Screens[i]->bitmapBitOrder !=
+ xf86Screens[0]->bitmapBitOrder)
+ FatalError("Inconsistent display bitmapBitOrder. Exiting\n");
+
+ /* Determine the depth 24 pixmap format the screens would like */
+ if (xf86Screens[i]->pixmap24 != Pix24DontCare) {
+ if (screenpix24 == Pix24DontCare)
+ screenpix24 = xf86Screens[i]->pixmap24;
+ else if (screenpix24 != xf86Screens[i]->pixmap24)
+ FatalError("Inconsistent depth 24 pixmap format. Exiting\n");
+ }
+ }
+ /* check if screenpix24 is consistent with the config/cmdline */
+ if (xf86Info.pixmap24 != Pix24DontCare) {
+ pix24 = xf86Info.pixmap24;
+ pix24From = xf86Info.pix24From;
+ if (screenpix24 != Pix24DontCare && screenpix24 != xf86Info.pixmap24)
+ pix24Fail = TRUE;
+ } else if (screenpix24 != Pix24DontCare) {
+ pix24 = screenpix24;
+ pix24From = X_PROBED;
+ } else
+ pix24 = Pix24Use32;
+
+ if (pix24Fail)
+ FatalError("Screen(s) can't use the required depth 24 pixmap format"
+ " (%d). Exiting\n", PIX24TOBPP(pix24));
+
+ /* Initialise the depth 24 format */
+ for (j = 0; j < numFormats && formats[j].depth != 24; j++)
+ ;
+ formats[j].bitsPerPixel = PIX24TOBPP(pix24);
+
+ /* Collect additional formats */
+ for (i = 0; i < xf86NumScreens; i++) {
+ for (j = 0; j < xf86Screens[i]->numFormats; j++) {
+ for (k = 0; ; k++) {
+ if (k >= numFormats) {
+ if (k >= MAXFORMATS)
+ FatalError("Too many pixmap formats! Exiting\n");
+ formats[k] = xf86Screens[i]->formats[j];
+ numFormats++;
+ break;
+ }
+ if (formats[k].depth == xf86Screens[i]->formats[j].depth) {
+ if ((formats[k].bitsPerPixel ==
+ xf86Screens[i]->formats[j].bitsPerPixel) &&
+ (formats[k].scanlinePad ==
+ xf86Screens[i]->formats[j].scanlinePad))
+ break;
+ FatalError("Inconsistent pixmap format for depth %d."
+ " Exiting\n", formats[k].depth);
+ }
+ }
+ }
+ }
+ formatsDone = TRUE;
+
+ if (xf86Info.vtno >= 0 ) {
+#define VT_ATOM_NAME "XFree86_VT"
+ Atom VTAtom=-1;
+ CARD32 *VT = NULL;
+ int ret;
+
+ /* This memory needs to stay available until the screen has been
+ initialized, and we can create the property for real.
+ */
+ if ( (VT = malloc(sizeof(CARD32)))==NULL ) {
+ FatalError("Unable to make VT property - out of memory. Exiting...\n");
+ }
+ *VT = xf86Info.vtno;
+
+ VTAtom = MakeAtom(VT_ATOM_NAME, sizeof(VT_ATOM_NAME) - 1, TRUE);
+
+ for (i = 0, ret = Success; i < xf86NumScreens && ret == Success; i++) {
+ ret = xf86RegisterRootWindowProperty(xf86Screens[i]->scrnIndex,
+ VTAtom, XA_INTEGER, 32,
+ 1, VT );
+ if (ret != Success)
+ xf86DrvMsg(xf86Screens[i]->scrnIndex, X_WARNING,
+ "Failed to register VT property\n");
+ }
+ }
+
+ /* If a screen uses depth 24, show what the pixmap format is */
+ for (i = 0; i < xf86NumScreens; i++) {
+ if (xf86Screens[i]->depth == 24) {
+ xf86Msg(pix24From, "Depth 24 pixmap format is %d bpp\n",
+ PIX24TOBPP(pix24));
+ break;
+ }
+ }
+ } else {
+ /*
+ * serverGeneration != 1; some OSs have to do things here, too.
+ */
+ if (xorgHWOpenConsole)
+ xf86OpenConsole();
+
+#ifdef XF86PM
+ /*
+ should we reopen it here? We need to deal with an already opened
+ device. We could leave this to the OS layer. For now we simply
+ close it here
+ */
+ if (xf86OSPMClose)
+ xf86OSPMClose();
+ if ((xf86OSPMClose = xf86OSPMOpen()) != NULL)
+ xf86MsgVerb(X_INFO, 3, "APM registered successfully\n");
+#endif
+
+ /* Make sure full I/O access is enabled */
+ if (xorgHWAccess)
+ xf86EnableIO();
+ }
+
+ /*
+ * Use the previously collected parts to setup pScreenInfo
+ */
+
+ pScreenInfo->imageByteOrder = xf86Screens[0]->imageByteOrder;
+ pScreenInfo->bitmapScanlinePad = xf86Screens[0]->bitmapScanlinePad;
+ pScreenInfo->bitmapScanlineUnit = xf86Screens[0]->bitmapScanlineUnit;
+ pScreenInfo->bitmapBitOrder = xf86Screens[0]->bitmapBitOrder;
+ pScreenInfo->numPixmapFormats = numFormats;
+ for (i = 0; i < numFormats; i++)
+ pScreenInfo->formats[i] = formats[i];
+
+ /* Make sure the server's VT is active */
+
+ if (serverGeneration != 1) {
+ xf86Resetting = TRUE;
+ /* All screens are in the same state, so just check the first */
+ if (!xf86Screens[0]->vtSema) {
+#ifdef HAS_USL_VTS
+ ioctl(xf86Info.consoleFd, VT_RELDISP, VT_ACKACQ);
+#endif
+ xf86AccessEnter();
+ was_blocked = xf86BlockSIGIO();
+ }
+ }
+
+ for (i = 0; i < xf86NumScreens; i++)
+ if (!xf86ColormapAllocatePrivates(xf86Screens[i]))
+ FatalError("Cannot register DDX private keys");
+
+ if (!dixRegisterPrivateKey(&xf86ScreenKeyRec, PRIVATE_SCREEN, 0) ||
+ !dixRegisterPrivateKey(&xf86CreateRootWindowKeyRec, PRIVATE_SCREEN, 0))
+ FatalError("Cannot register DDX private keys");
+
+ for (i = 0; i < xf86NumScreens; i++) {
+ xf86VGAarbiterLock(xf86Screens[i]);
+ /*
+ * Almost everything uses these defaults, and many of those that
+ * don't, will wrap them.
+ */
+ xf86Screens[i]->EnableDisableFBAccess = xf86EnableDisableFBAccess;
+#ifdef XFreeXDGA
+ xf86Screens[i]->SetDGAMode = xf86SetDGAMode;
+#endif
+ xf86Screens[i]->DPMSSet = NULL;
+ xf86Screens[i]->LoadPalette = NULL;
+ xf86Screens[i]->SetOverscan = NULL;
+ xf86Screens[i]->DriverFunc = NULL;
+ xf86Screens[i]->pScreen = NULL;
+ scr_index = AddScreen(xf86Screens[i]->ScreenInit, argc, argv);
+ xf86VGAarbiterUnlock(xf86Screens[i]);
+ if (scr_index == i) {
+ /*
+ * Hook in our ScrnInfoRec, and initialise some other pScreen
+ * fields.
+ */
+ dixSetPrivate(&screenInfo.screens[scr_index]->devPrivates,
+ xf86ScreenKey, xf86Screens[i]);
+ xf86Screens[i]->pScreen = screenInfo.screens[scr_index];
+ /* The driver should set this, but make sure it is set anyway */
+ xf86Screens[i]->vtSema = TRUE;
+ } else {
+ /* This shouldn't normally happen */
+ FatalError("AddScreen/ScreenInit failed for driver %d\n", i);
+ }
+
+ DebugF("InitOutput - xf86Screens[%d]->pScreen = %p\n",
+ i, xf86Screens[i]->pScreen );
+ DebugF("xf86Screens[%d]->pScreen->CreateWindow = %p\n",
+ i, xf86Screens[i]->pScreen->CreateWindow );
+
+ dixSetPrivate(&screenInfo.screens[scr_index]->devPrivates,
+ xf86CreateRootWindowKey,
+ xf86Screens[i]->pScreen->CreateWindow);
+ xf86Screens[i]->pScreen->CreateWindow = xf86CreateRootWindow;
+
+ if (PictureGetSubpixelOrder (xf86Screens[i]->pScreen) == SubPixelUnknown)
+ {
+ xf86MonPtr DDC = (xf86MonPtr)(xf86Screens[i]->monitor->DDC);
+ PictureSetSubpixelOrder (xf86Screens[i]->pScreen,
+ DDC ?
+ (DDC->features.input_type ?
+ SubPixelHorizontalRGB : SubPixelNone) :
+ SubPixelUnknown);
+ }
+#ifdef RANDR
+ if (!xf86Info.disableRandR)
+ xf86RandRInit (screenInfo.screens[scr_index]);
+ xf86Msg(xf86Info.randRFrom, "RandR %s\n",
+ xf86Info.disableRandR ? "disabled" : "enabled");
+#endif
+ }
+
+ xf86VGAarbiterWrapFunctions();
+ xf86UnblockSIGIO(was_blocked);
+
+ xf86InitOrigins();
+
+ xf86Resetting = FALSE;
+ xf86Initialising = FALSE;
+
+ RegisterBlockAndWakeupHandlers((BlockHandlerProcPtr)NoopDDA, xf86Wakeup,
+ NULL);
+}
+
+/*
+ * InitInput --
+ * Initialize all supported input devices.
+ */
+
+void
+InitInput(int argc, char **argv)
+{
+ InputInfoPtr* pDev;
+ DeviceIntPtr dev;
+
+ xf86Info.vtRequestsPending = FALSE;
+
+ mieqInit();
+
+ GetEventList(&xf86Events);
+
+ /* Call the PreInit function for each input device instance. */
+ for (pDev = xf86ConfigLayout.inputs; pDev && *pDev; pDev++) {
+ /* Replace obsolete keyboard driver with kbd */
+ if (!xf86NameCmp((*pDev)->driver, "keyboard")) {
+ strcpy((*pDev)->driver, "kbd");
+ }
+
+ /* If one fails, the others will too */
+ if (xf86NewInputDevice(*pDev, &dev, TRUE) == BadAlloc)
+ break;
+ }
+
+ config_init();
+}
+
+void
+CloseInput (void)
+{
+ config_fini();
+}
+
+/*
+ * OsVendorInit --
+ * OS/Vendor-specific initialisations. Called from OsInit(), which
+ * is called by dix before establishing the well known sockets.
+ */
+
+void
+OsVendorInit(void)
+{
+ static Bool beenHere = FALSE;
+
+ signal(SIGCHLD, SIG_DFL); /* Need to wait for child processes */
+
+ if (!beenHere) {
+ umask(022);
+ xf86LogInit();
+ }
+
+ /* Set stderr to non-blocking. */
+#ifndef O_NONBLOCK
+#if defined(FNDELAY)
+#define O_NONBLOCK FNDELAY
+#elif defined(O_NDELAY)
+#define O_NONBLOCK O_NDELAY
+#endif
+
+#ifdef O_NONBLOCK
+ if (!beenHere) {
+ if (geteuid() == 0 && getuid() != geteuid())
+ {
+ int status;
+
+ status = fcntl(fileno(stderr), F_GETFL, 0);
+ if (status != -1) {
+ fcntl(fileno(stderr), F_SETFL, status | O_NONBLOCK);
+ }
+ }
+ }
+#endif
+#endif
+
+ beenHere = TRUE;
+}
+
+/*
+ * ddxGiveUp --
+ * Device dependent cleanup. Called by by dix before normal server death.
+ * For SYSV386 we must switch the terminal back to normal mode. No error-
+ * checking here, since there should be restored as much as possible.
+ */
+
+void
+ddxGiveUp(void)
+{
+ int i;
+
+ xf86VGAarbiterFini();
+
+#ifdef XF86PM
+ if (xf86OSPMClose)
+ xf86OSPMClose();
+ xf86OSPMClose = NULL;
+#endif
+
+ for (i = 0; i < xf86NumScreens; i++) {
+ /*
+ * zero all access functions to
+ * trap calls when switched away.
+ */
+ xf86Screens[i]->vtSema = FALSE;
+ }
+
+#ifdef XFreeXDGA
+ DGAShutdown();
+#endif
+
+ if (xorgHWOpenConsole)
+ xf86CloseConsole();
+
+ xf86CloseLog();
+
+ /* If an unexpected signal was caught, dump a core for debugging */
+ if (xf86Info.caughtSignal)
+ OsAbort();
+}
+
+
+
+/*
+ * AbortDDX --
+ * DDX - specific abort routine. Called by AbortServer(). The attempt is
+ * made to restore all original setting of the displays. Also all devices
+ * are closed.
+ */
+
+void
+AbortDDX(void)
+{
+ int i;
+
+ xf86BlockSIGIO();
+
+ /*
+ * try to restore the original video state
+ */
+#ifdef DPMSExtension /* Turn screens back on */
+ if (DPMSPowerLevel != DPMSModeOn)
+ DPMSSet(serverClient, DPMSModeOn);
+#endif
+ if (xf86Screens) {
+ for (i = 0; i < xf86NumScreens; i++)
+ if (xf86Screens[i]->vtSema) {
+ /*
+ * if we are aborting before ScreenInit() has finished
+ * we might not have been wrapped yet. Therefore enable
+ * screen explicitely.
+ */
+ xf86VGAarbiterLock(xf86Screens[i]);
+ (xf86Screens[i]->LeaveVT)(i, 0);
+ xf86VGAarbiterUnlock(xf86Screens[i]);
+ }
+ }
+
+ xf86AccessLeave();
+
+ /*
+ * This is needed for an abnormal server exit, since the normal exit stuff
+ * MUST also be performed (i.e. the vt must be left in a defined state)
+ */
+ ddxGiveUp();
+}
+
+void
+OsVendorFatalError(void)
+{
+#ifdef VENDORSUPPORT
+ ErrorF("\nPlease refer to your Operating System Vendor support pages\n"
+ "at %s for support on this crash.\n",VENDORSUPPORT);
+#else
+ ErrorF("\nPlease consult the "XVENDORNAME" support \n"
+ "\t at "__VENDORDWEBSUPPORT__"\n for help. \n");
+#endif
+ if (xf86LogFile && xf86LogFileWasOpened)
+ ErrorF("Please also check the log file at \"%s\" for additional "
+ "information.\n", xf86LogFile);
+ ErrorF("\n");
+}
+
+int
+xf86SetVerbosity(int verb)
+{
+ int save = xf86Verbose;
+
+ xf86Verbose = verb;
+ LogSetParameter(XLOG_VERBOSITY, verb);
+ return save;
+}
+
+int
+xf86SetLogVerbosity(int verb)
+{
+ int save = xf86LogVerbose;
+
+ xf86LogVerbose = verb;
+ LogSetParameter(XLOG_FILE_VERBOSITY, verb);
+ return save;
+}
+
+static void
+xf86PrintDefaultModulePath(void)
+{
+ ErrorF("%s\n", DEFAULT_MODULE_PATH);
+}
+
+static void
+xf86PrintDefaultLibraryPath(void)
+{
+ ErrorF("%s\n", DEFAULT_LIBRARY_PATH);
+}
+
+/*
+ * ddxProcessArgument --
+ * Process device-dependent command line args. Returns 0 if argument is
+ * not device dependent, otherwise Count of number of elements of argv
+ * that are part of a device dependent commandline option.
+ *
+ */
+
+/* ARGSUSED */
+int
+ddxProcessArgument(int argc, char **argv, int i)
+{
+#define CHECK_FOR_REQUIRED_ARGUMENT() \
+ if (((i + 1) >= argc) || (!argv[i + 1])) { \
+ ErrorF("Required argument to %s not specified\n", argv[i]); \
+ UseMsg(); \
+ FatalError("Required argument to %s not specified\n", argv[i]); \
+ }
+
+ /* First the options that are only allowed for root */
+ if (!strcmp(argv[i], "-modulepath") || !strcmp(argv[i], "-logfile")) {
+ if ( (geteuid() == 0) && (getuid() != 0) ) {
+ FatalError("The '%s' option can only be used by root.\n", argv[i]);
+ }
+ else if (!strcmp(argv[i], "-modulepath"))
+ {
+ char *mp;
+ CHECK_FOR_REQUIRED_ARGUMENT();
+ mp = strdup(argv[i + 1]);
+ if (!mp)
+ FatalError("Can't allocate memory for ModulePath\n");
+ xf86ModulePath = mp;
+ xf86ModPathFrom = X_CMDLINE;
+ return 2;
+ }
+ else if (!strcmp(argv[i], "-logfile"))
+ {
+ char *lf;
+ CHECK_FOR_REQUIRED_ARGUMENT();
+ lf = strdup(argv[i + 1]);
+ if (!lf)
+ FatalError("Can't allocate memory for LogFile\n");
+ xf86LogFile = lf;
+ xf86LogFileFrom = X_CMDLINE;
+ return 2;
+ }
+ }
+ if (!strcmp(argv[i], "-config") || !strcmp(argv[i], "-xf86config"))
+ {
+ CHECK_FOR_REQUIRED_ARGUMENT();
+ if (getuid() != 0 && !xf86PathIsSafe(argv[i + 1])) {
+ FatalError("\nInvalid argument for %s\n"
+ "\tFor non-root users, the file specified with %s must be\n"
+ "\ta relative path and must not contain any \"..\" elements.\n"
+ "\tUsing default "__XCONFIGFILE__" search path.\n\n",
+ argv[i], argv[i]);
+ }
+ xf86ConfigFile = argv[i + 1];
+ return 2;
+ }
+ if (!strcmp(argv[i], "-configdir"))
+ {
+ CHECK_FOR_REQUIRED_ARGUMENT();
+ if (getuid() != 0 && !xf86PathIsSafe(argv[i + 1])) {
+ FatalError("\nInvalid argument for %s\n"
+ "\tFor non-root users, the file specified with %s must be\n"
+ "\ta relative path and must not contain any \"..\" elements.\n"
+ "\tUsing default "__XCONFIGDIR__" search path.\n\n",
+ argv[i], argv[i]);
+ }
+ xf86ConfigDir = argv[i + 1];
+ return 2;
+ }
+ if (!strcmp(argv[i],"-flipPixels"))
+ {
+ xf86FlipPixels = TRUE;
+ return 1;
+ }
+#ifdef XF86VIDMODE
+ if (!strcmp(argv[i],"-disableVidMode"))
+ {
+ xf86VidModeDisabled = TRUE;
+ return 1;
+ }
+ if (!strcmp(argv[i],"-allowNonLocalXvidtune"))
+ {
+ xf86VidModeAllowNonLocal = TRUE;
+ return 1;
+ }
+#endif
+ if (!strcmp(argv[i],"-allowMouseOpenFail"))
+ {
+ xf86AllowMouseOpenFail = TRUE;
+ return 1;
+ }
+ if (!strcmp(argv[i],"-ignoreABI"))
+ {
+ LoaderSetOptions(LDR_OPT_ABI_MISMATCH_NONFATAL);
+ return 1;
+ }
+ if (!strcmp(argv[i],"-verbose"))
+ {
+ if (++i < argc && argv[i])
+ {
+ char *end;
+ long val;
+ val = strtol(argv[i], &end, 0);
+ if (*end == '\0')
+ {
+ xf86SetVerbosity(val);
+ return 2;
+ }
+ }
+ xf86SetVerbosity(++xf86Verbose);
+ return 1;
+ }
+ if (!strcmp(argv[i],"-logverbose"))
+ {
+ if (++i < argc && argv[i])
+ {
+ char *end;
+ long val;
+ val = strtol(argv[i], &end, 0);
+ if (*end == '\0')
+ {
+ xf86SetLogVerbosity(val);
+ return 2;
+ }
+ }
+ xf86SetLogVerbosity(++xf86LogVerbose);
+ return 1;
+ }
+ if (!strcmp(argv[i],"-quiet"))
+ {
+ xf86SetVerbosity(-1);
+ return 1;
+ }
+ if (!strcmp(argv[i],"-showconfig") || !strcmp(argv[i],"-version"))
+ {
+ xf86PrintBanner();
+ exit(0);
+ }
+ if (!strcmp(argv[i],"-showDefaultModulePath"))
+ {
+ xf86PrintDefaultModulePath();
+ exit(0);
+ }
+ if (!strcmp(argv[i],"-showDefaultLibPath"))
+ {
+ xf86PrintDefaultLibraryPath();
+ exit(0);
+ }
+ /* Notice the -fp flag, but allow it to pass to the dix layer */
+ if (!strcmp(argv[i], "-fp"))
+ {
+ xf86fpFlag = TRUE;
+ return 0;
+ }
+ /* Notice the -bs flag, but allow it to pass to the dix layer */
+ if (!strcmp(argv[i], "-bs"))
+ {
+ xf86bsDisableFlag = TRUE;
+ return 0;
+ }
+ /* Notice the +bs flag, but allow it to pass to the dix layer */
+ if (!strcmp(argv[i], "+bs"))
+ {
+ xf86bsEnableFlag = TRUE;
+ return 0;
+ }
+ /* Notice the -s flag, but allow it to pass to the dix layer */
+ if (!strcmp(argv[i], "-s"))
+ {
+ xf86sFlag = TRUE;
+ return 0;
+ }
+ if (!strcmp(argv[i], "-pixmap24"))
+ {
+ xf86Pix24 = Pix24Use24;
+ return 1;
+ }
+ if (!strcmp(argv[i], "-pixmap32"))
+ {
+ xf86Pix24 = Pix24Use32;
+ return 1;
+ }
+ if (!strcmp(argv[i], "-fbbpp"))
+ {
+ int bpp;
+ CHECK_FOR_REQUIRED_ARGUMENT();
+ if (sscanf(argv[++i], "%d", &bpp) == 1)
+ {
+ xf86FbBpp = bpp;
+ return 2;
+ }
+ else
+ {
+ ErrorF("Invalid fbbpp\n");
+ return 0;
+ }
+ }
+ if (!strcmp(argv[i], "-depth"))
+ {
+ int depth;
+ CHECK_FOR_REQUIRED_ARGUMENT();
+ if (sscanf(argv[++i], "%d", &depth) == 1)
+ {
+ xf86Depth = depth;
+ return 2;
+ }
+ else
+ {
+ ErrorF("Invalid depth\n");
+ return 0;
+ }
+ }
+ if (!strcmp(argv[i], "-weight"))
+ {
+ int red, green, blue;
+ CHECK_FOR_REQUIRED_ARGUMENT();
+ if (sscanf(argv[++i], "%1d%1d%1d", &red, &green, &blue) == 3)
+ {
+ xf86Weight.red = red;
+ xf86Weight.green = green;
+ xf86Weight.blue = blue;
+ return 2;
+ }
+ else
+ {
+ ErrorF("Invalid weighting\n");
+ return 0;
+ }
+ }
+ if (!strcmp(argv[i], "-gamma") || !strcmp(argv[i], "-rgamma") ||
+ !strcmp(argv[i], "-ggamma") || !strcmp(argv[i], "-bgamma"))
+ {
+ double gamma;
+ CHECK_FOR_REQUIRED_ARGUMENT();
+ if (sscanf(argv[++i], "%lf", &gamma) == 1) {
+ if (gamma < GAMMA_MIN || gamma > GAMMA_MAX) {
+ ErrorF("gamma out of range, only %.2f <= gamma_value <= %.1f"
+ " is valid\n", GAMMA_MIN, GAMMA_MAX);
+ return 0;
+ }
+ if (!strcmp(argv[i-1], "-gamma"))
+ xf86Gamma.red = xf86Gamma.green = xf86Gamma.blue = gamma;
+ else if (!strcmp(argv[i-1], "-rgamma")) xf86Gamma.red = gamma;
+ else if (!strcmp(argv[i-1], "-ggamma")) xf86Gamma.green = gamma;
+ else if (!strcmp(argv[i-1], "-bgamma")) xf86Gamma.blue = gamma;
+ return 2;
+ }
+ }
+ if (!strcmp(argv[i], "-layout"))
+ {
+ CHECK_FOR_REQUIRED_ARGUMENT();
+ xf86LayoutName = argv[++i];
+ return 2;
+ }
+ if (!strcmp(argv[i], "-screen"))
+ {
+ CHECK_FOR_REQUIRED_ARGUMENT();
+ xf86ScreenName = argv[++i];
+ return 2;
+ }
+ if (!strcmp(argv[i], "-pointer"))
+ {
+ CHECK_FOR_REQUIRED_ARGUMENT();
+ xf86PointerName = argv[++i];
+ return 2;
+ }
+ if (!strcmp(argv[i], "-keyboard"))
+ {
+ CHECK_FOR_REQUIRED_ARGUMENT();
+ xf86KeyboardName = argv[++i];
+ return 2;
+ }
+ if (!strcmp(argv[i], "-nosilk"))
+ {
+ xf86silkenMouseDisableFlag = TRUE;
+ return 1;
+ }
+#ifdef HAVE_ACPI
+ if (!strcmp(argv[i], "-noacpi"))
+ {
+ xf86acpiDisableFlag = TRUE;
+ return 1;
+ }
+#endif
+ if (!strcmp(argv[i], "-configure"))
+ {
+ if (getuid() != 0 && geteuid() == 0) {
+ ErrorF("The '-configure' option can only be used by root.\n");
+ exit(1);
+ }
+ xf86DoConfigure = TRUE;
+ xf86AllowMouseOpenFail = TRUE;
+ return 1;
+ }
+ if (!strcmp(argv[i], "-showopts"))
+ {
+ if (getuid() != 0 && geteuid() == 0) {
+ ErrorF("The '-showopts' option can only be used by root.\n");
+ exit(1);
+ }
+ xf86DoShowOptions = TRUE;
+ return 1;
+ }
+ if (!strcmp(argv[i], "-isolateDevice"))
+ {
+ CHECK_FOR_REQUIRED_ARGUMENT();
+ if (strncmp(argv[++i], "PCI:", 4)) {
+ FatalError("Bus types other than PCI not yet isolable\n");
+ }
+ xf86PciIsolateDevice(argv[i]);
+ return 2;
+ }
+ /* Notice cmdline xkbdir, but pass to dix as well */
+ if (!strcmp(argv[i], "-xkbdir"))
+ {
+ xf86xkbdirFlag = TRUE;
+ return 0;
+ }
+
+ /* OS-specific processing */
+ return xf86ProcessArgument(argc, argv, i);
+}
+
+/*
+ * ddxUseMsg --
+ * Print out correct use of device dependent commandline options.
+ * Maybe the user now knows what really to do ...
+ */
+
+void
+ddxUseMsg(void)
+{
+ ErrorF("\n");
+ ErrorF("\n");
+ ErrorF("Device Dependent Usage\n");
+ if (getuid() == 0 || geteuid() != 0)
+ {
+ ErrorF("-modulepath paths specify the module search path\n");
+ ErrorF("-logfile file specify a log file name\n");
+ ErrorF("-configure probe for devices and write an "__XCONFIGFILE__"\n");
+ ErrorF("-showopts print available options for all installed drivers\n");
+ }
+ ErrorF("-config file specify a configuration file, relative to the\n");
+ ErrorF(" "__XCONFIGFILE__" search path, only root can use absolute\n");
+ ErrorF("-configdir dir specify a configuration directory, relative to the\n");
+ ErrorF(" "__XCONFIGDIR__" search path, only root can use absolute\n");
+ ErrorF("-verbose [n] verbose startup messages\n");
+ ErrorF("-logverbose [n] verbose log messages\n");
+ ErrorF("-quiet minimal startup messages\n");
+ ErrorF("-pixmap24 use 24bpp pixmaps for depth 24\n");
+ ErrorF("-pixmap32 use 32bpp pixmaps for depth 24\n");
+ ErrorF("-fbbpp n set bpp for the framebuffer. Default: 8\n");
+ ErrorF("-depth n set colour depth. Default: 8\n");
+ ErrorF("-gamma f set gamma value (0.1 < f < 10.0) Default: 1.0\n");
+ ErrorF("-rgamma f set gamma value for red phase\n");
+ ErrorF("-ggamma f set gamma value for green phase\n");
+ ErrorF("-bgamma f set gamma value for blue phase\n");
+ ErrorF("-weight nnn set RGB weighting at 16 bpp. Default: 565\n");
+ ErrorF("-layout name specify the ServerLayout section name\n");
+ ErrorF("-screen name specify the Screen section name\n");
+ ErrorF("-keyboard name specify the core keyboard InputDevice name\n");
+ ErrorF("-pointer name specify the core pointer InputDevice name\n");
+ ErrorF("-nosilk disable Silken Mouse\n");
+ ErrorF("-flipPixels swap default black/white Pixel values\n");
+#ifdef XF86VIDMODE
+ ErrorF("-disableVidMode disable mode adjustments with xvidtune\n");
+ ErrorF("-allowNonLocalXvidtune allow xvidtune to be run as a non-local client\n");
+#endif
+ ErrorF("-allowMouseOpenFail start server even if the mouse can't be initialized\n");
+ ErrorF("-ignoreABI make module ABI mismatches non-fatal\n");
+ ErrorF("-isolateDevice bus_id restrict device resets to bus_id (PCI only)\n");
+ 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");
+ /* OS-specific usage */
+ xf86UseMsg();
+ ErrorF("\n");
+}
+
+
+/*
+ * xf86LoadModules iterates over a list that is being passed in.
+ */
+Bool
+xf86LoadModules(char **list, pointer *optlist)
+{
+ int errmaj, errmin;
+ pointer opt;
+ int i;
+ char *name;
+ Bool failed = FALSE;
+
+ if (!list)
+ return TRUE;
+
+ for (i = 0; list[i] != NULL; i++) {
+
+ /* Normalise the module name */
+ name = xf86NormalizeName(list[i]);
+
+ /* Skip empty names */
+ if (name == NULL || *name == '\0')
+ continue;
+
+ /* Replace obsolete keyboard driver with kbd */
+ if (!xf86NameCmp(name, "keyboard")) {
+ strcpy(name, "kbd");
+ }
+
+ if (optlist)
+ opt = optlist[i];
+ else
+ opt = NULL;
+
+ if (!LoadModule(name, NULL, NULL, NULL, opt, NULL, &errmaj, &errmin)) {
+ LoaderErrorMsg(NULL, name, errmaj, errmin);
+ failed = TRUE;
+ }
+ free(name);
+ }
+ return !failed;
+}
+
+/* Pixmap format stuff */
+
+PixmapFormatPtr
+xf86GetPixFormat(ScrnInfoPtr pScrn, int depth)
+{
+ int i;
+ static PixmapFormatRec format; /* XXX not reentrant */
+
+ /*
+ * When the formats[] list initialisation isn't complete, check the
+ * depth 24 pixmap config/cmdline options and screen-specified formats.
+ */
+
+ if (!formatsDone) {
+ if (depth == 24) {
+ Pix24Flags pix24 = Pix24DontCare;
+
+ format.depth = 24;
+ format.scanlinePad = BITMAP_SCANLINE_PAD;
+ if (xf86Info.pixmap24 != Pix24DontCare)
+ pix24 = xf86Info.pixmap24;
+ else if (pScrn->pixmap24 != Pix24DontCare)
+ pix24 = pScrn->pixmap24;
+ if (pix24 == Pix24Use24)
+ format.bitsPerPixel = 24;
+ else
+ format.bitsPerPixel = 32;
+ return &format;
+ }
+ }
+
+ for (i = 0; i < numFormats; i++)
+ if (formats[i].depth == depth)
+ break;
+ if (i != numFormats)
+ return &formats[i];
+ else if (!formatsDone) {
+ /* Check for screen-specified formats */
+ for (i = 0; i < pScrn->numFormats; i++)
+ if (pScrn->formats[i].depth == depth)
+ break;
+ if (i != pScrn->numFormats)
+ return &pScrn->formats[i];
+ }
+ return NULL;
+}
+
+int
+xf86GetBppFromDepth(ScrnInfoPtr pScrn, int depth)
+{
+ PixmapFormatPtr format;
+
+
+ format = xf86GetPixFormat(pScrn, depth);
+ if (format)
+ return format->bitsPerPixel;
+ else
+ return 0;
+}
diff --git a/xorg-server/hw/xfree86/common/xf86PM.c b/xorg-server/hw/xfree86/common/xf86PM.c
index 7af89b5b4..16b6bdc4a 100644
--- a/xorg-server/hw/xfree86/common/xf86PM.c
+++ b/xorg-server/hw/xfree86/common/xf86PM.c
@@ -33,6 +33,7 @@
#include "xf86.h"
#include "xf86Priv.h"
#include "xf86Xinput.h"
+#include "xf86_OSproc.h"
int (*xf86PMGetEventFromOs)(int fd,pmEvent *events,int num) = NULL;
pmWait (*xf86PMConfirmEventToOs)(int fd,pmEvent event) = NULL;
@@ -61,14 +62,14 @@ eventName(pmEvent event, char **str)
}
}
+static int sigio_blocked_for_suspend;
+
static void
suspend (pmEvent event, Bool undo)
{
int i;
InputInfoPtr pInfo;
- xf86inSuspend = TRUE;
-
for (i = 0; i < xf86NumScreens; i++) {
if (xf86Screens[i]->EnableDisableFBAccess)
(*xf86Screens[i]->EnableDisableFBAccess) (i, FALSE);
@@ -78,7 +79,7 @@ suspend (pmEvent event, Bool undo)
DisableDevice(pInfo->dev, TRUE);
pInfo = pInfo->next;
}
- xf86EnterServerState(SETUP);
+ sigio_blocked_for_suspend = xf86BlockSIGIO();
for (i = 0; i < xf86NumScreens; i++) {
if (xf86Screens[i]->PMEvent)
xf86Screens[i]->PMEvent(i,event,undo);
@@ -98,7 +99,6 @@ resume(pmEvent event, Bool undo)
InputInfoPtr pInfo;
xf86AccessEnter();
- xf86EnterServerState(SETUP);
for (i = 0; i < xf86NumScreens; i++) {
if (xf86Screens[i]->PMEvent)
xf86Screens[i]->PMEvent(i,event,undo);
@@ -107,7 +107,7 @@ resume(pmEvent event, Bool undo)
xf86Screens[i]->EnterVT(i, 0);
}
}
- xf86EnterServerState(OPERATING);
+ xf86UnblockSIGIO(sigio_blocked_for_suspend);
for (i = 0; i < xf86NumScreens; i++) {
if (xf86Screens[i]->EnableDisableFBAccess)
(*xf86Screens[i]->EnableDisableFBAccess) (i, TRUE);
@@ -118,18 +118,12 @@ resume(pmEvent event, Bool undo)
EnableDevice(pInfo->dev, TRUE);
pInfo = pInfo->next;
}
- xf86inSuspend = FALSE;
}
static void
DoApmEvent(pmEvent event, Bool undo)
{
- /*
- * we leave that as a global function for now. I don't know if
- * this might cause problems in the future. It is a global server
- * variable therefore it needs to be in a server info structure
- */
- int i, setup = 0;
+ int i, was_blocked;
switch(event) {
#if 0
@@ -159,14 +153,13 @@ DoApmEvent(pmEvent event, Bool undo)
}
break;
default:
+ was_blocked = xf86BlockSIGIO();
for (i = 0; i < xf86NumScreens; i++) {
if (xf86Screens[i]->PMEvent) {
- if (!setup) xf86EnterServerState(SETUP);
- setup = 1;
xf86Screens[i]->PMEvent(i,event,undo);
}
}
- if (setup) xf86EnterServerState(OPERATING);
+ xf86UnblockSIGIO(was_blocked);
break;
}
}
diff --git a/xorg-server/hw/xfree86/common/xf86Priv.h b/xorg-server/hw/xfree86/common/xf86Priv.h
index 01e178372..7137a5363 100644
--- a/xorg-server/hw/xfree86/common/xf86Priv.h
+++ b/xorg-server/hw/xfree86/common/xf86Priv.h
@@ -1,158 +1,157 @@
-/*
- * Copyright (c) 1997-2002 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 declarations for private XFree86 functions and variables,
- * and definitions of private macros.
- *
- * "private" means not available to video drivers.
- */
-
-#ifndef _XF86PRIV_H
-#define _XF86PRIV_H
-
-#include "xf86Privstr.h"
-#include "propertyst.h"
-#include "input.h"
-
-/*
- * Parameters set ONLY from the command line options
- * The global state of these things is held in xf86InfoRec (when appropriate).
- */
-extern _X_EXPORT const char *xf86ConfigFile;
-extern _X_EXPORT const char *xf86ConfigDir;
-extern _X_EXPORT Bool xf86AllowMouseOpenFail;
-#ifdef XF86VIDMODE
-extern _X_EXPORT Bool xf86VidModeDisabled;
-extern _X_EXPORT Bool xf86VidModeAllowNonLocal;
-#endif
-extern _X_EXPORT Bool xf86fpFlag;
-extern _X_EXPORT Bool xf86sFlag;
-extern _X_EXPORT Bool xf86bsEnableFlag;
-extern _X_EXPORT Bool xf86bsDisableFlag;
-extern _X_EXPORT Bool xf86silkenMouseDisableFlag;
-extern _X_EXPORT Bool xf86xkbdirFlag;
-#ifdef HAVE_ACPI
-extern _X_EXPORT Bool xf86acpiDisableFlag;
-#endif
-extern _X_EXPORT char *xf86LayoutName;
-extern _X_EXPORT char *xf86ScreenName;
-extern _X_EXPORT char *xf86PointerName;
-extern _X_EXPORT char *xf86KeyboardName;
-extern _X_EXPORT int xf86FbBpp;
-extern _X_EXPORT int xf86Depth;
-extern _X_EXPORT Pix24Flags xf86Pix24;
-extern _X_EXPORT rgb xf86Weight;
-extern _X_EXPORT Bool xf86FlipPixels;
-extern _X_EXPORT Gamma xf86Gamma;
-extern _X_EXPORT char *xf86ServerName;
-
-/* Other parameters */
-
-extern _X_EXPORT xf86InfoRec xf86Info;
-extern _X_EXPORT const char *xf86ModulePath;
-extern _X_EXPORT MessageType xf86ModPathFrom;
-extern _X_EXPORT const char *xf86LogFile;
-extern _X_EXPORT MessageType xf86LogFileFrom;
-extern _X_EXPORT Bool xf86LogFileWasOpened;
-extern _X_EXPORT serverLayoutRec xf86ConfigLayout;
-
-extern _X_EXPORT DriverPtr *xf86DriverList;
-extern _X_EXPORT int xf86NumDrivers;
-extern _X_EXPORT Bool xf86Resetting;
-extern _X_EXPORT Bool xf86Initialising;
-extern _X_EXPORT int xf86NumScreens;
-extern _X_EXPORT const char *xf86VisualNames[];
-extern _X_EXPORT int xf86Verbose; /* verbosity level */
-extern _X_EXPORT int xf86LogVerbose; /* log file verbosity level */
-extern _X_EXPORT Bool xorgHWAccess;
-
-extern _X_EXPORT RootWinPropPtr *xf86RegisteredPropertiesTable;
-
-#ifndef DEFAULT_VERBOSE
-#define DEFAULT_VERBOSE 0
-#endif
-#ifndef DEFAULT_LOG_VERBOSE
-#define DEFAULT_LOG_VERBOSE 3
-#endif
-#ifndef DEFAULT_DPI
-#define DEFAULT_DPI 96
-#endif
-
-/* Function Prototypes */
-#ifndef _NO_XF86_PROTOTYPES
-
-/* xf86Bus.c */
-extern _X_EXPORT Bool xf86BusConfig(void);
-extern _X_EXPORT void xf86BusProbe(void);
-extern _X_EXPORT void xf86AccessEnter(void);
-extern _X_EXPORT void xf86AccessLeave(void);
-extern _X_EXPORT void xf86PostProbe(void);
-extern _X_EXPORT void xf86ClearEntityListForScreen(int scrnIndex);
-extern _X_EXPORT void xf86AddDevToEntity(int entityIndex, GDevPtr dev);
-extern _X_EXPORT void xf86PostScreenInit(void);
-
-/* xf86Config.c */
-
-extern _X_EXPORT Bool xf86PathIsSafe(const char *path);
-
-/* xf86DefaultModes */
-
-extern _X_EXPORT const DisplayModeRec xf86DefaultModes[];
-extern _X_EXPORT const int xf86NumDefaultModes;
-
-/* xf86Configure.c */
-extern _X_EXPORT void DoConfigure(void);
-
-/* xf86ShowOpts.c */
-extern _X_EXPORT void DoShowOptions(void);
-
-/* xf86Events.c */
-
-extern _X_EXPORT void xf86Wakeup(pointer blockData, int err, pointer pReadmask);
-extern _X_HIDDEN int xf86SigWrapper(int signo);
-extern _X_EXPORT void xf86HandlePMEvents(int fd, pointer data);
-extern _X_EXPORT int (*xf86PMGetEventFromOs)(int fd,pmEvent *events,int num);
-extern _X_EXPORT pmWait (*xf86PMConfirmEventToOs)(int fd,pmEvent event);
-
-/* xf86Helper.c */
-extern _X_EXPORT void xf86LogInit(void);
-extern _X_EXPORT void xf86CloseLog(void);
-
-/* xf86Init.c */
-extern _X_EXPORT Bool xf86LoadModules(char **list, pointer *optlist);
-extern _X_EXPORT int xf86SetVerbosity(int verb);
-extern _X_EXPORT int xf86SetLogVerbosity(int verb);
-extern _X_EXPORT Bool xf86CallDriverProbe( struct _DriverRec * drv, Bool detect_only );
-
-/* xf86Xinput.c */
-extern _X_EXPORT EventList *xf86Events;
-
-#endif /* _NO_XF86_PROTOTYPES */
-
-
-#endif /* _XF86PRIV_H */
+/*
+ * Copyright (c) 1997-2002 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 declarations for private XFree86 functions and variables,
+ * and definitions of private macros.
+ *
+ * "private" means not available to video drivers.
+ */
+
+#ifndef _XF86PRIV_H
+#define _XF86PRIV_H
+
+#include "xf86Privstr.h"
+#include "propertyst.h"
+#include "input.h"
+
+/*
+ * Parameters set ONLY from the command line options
+ * The global state of these things is held in xf86InfoRec (when appropriate).
+ */
+extern _X_EXPORT const char *xf86ConfigFile;
+extern _X_EXPORT const char *xf86ConfigDir;
+extern _X_EXPORT Bool xf86AllowMouseOpenFail;
+#ifdef XF86VIDMODE
+extern _X_EXPORT Bool xf86VidModeDisabled;
+extern _X_EXPORT Bool xf86VidModeAllowNonLocal;
+#endif
+extern _X_EXPORT Bool xf86fpFlag;
+extern _X_EXPORT Bool xf86sFlag;
+extern _X_EXPORT Bool xf86bsEnableFlag;
+extern _X_EXPORT Bool xf86bsDisableFlag;
+extern _X_EXPORT Bool xf86silkenMouseDisableFlag;
+extern _X_EXPORT Bool xf86xkbdirFlag;
+#ifdef HAVE_ACPI
+extern _X_EXPORT Bool xf86acpiDisableFlag;
+#endif
+extern _X_EXPORT char *xf86LayoutName;
+extern _X_EXPORT char *xf86ScreenName;
+extern _X_EXPORT char *xf86PointerName;
+extern _X_EXPORT char *xf86KeyboardName;
+extern _X_EXPORT int xf86FbBpp;
+extern _X_EXPORT int xf86Depth;
+extern _X_EXPORT Pix24Flags xf86Pix24;
+extern _X_EXPORT rgb xf86Weight;
+extern _X_EXPORT Bool xf86FlipPixels;
+extern _X_EXPORT Gamma xf86Gamma;
+extern _X_EXPORT char *xf86ServerName;
+
+/* Other parameters */
+
+extern _X_EXPORT xf86InfoRec xf86Info;
+extern _X_EXPORT const char *xf86ModulePath;
+extern _X_EXPORT MessageType xf86ModPathFrom;
+extern _X_EXPORT const char *xf86LogFile;
+extern _X_EXPORT MessageType xf86LogFileFrom;
+extern _X_EXPORT Bool xf86LogFileWasOpened;
+extern _X_EXPORT serverLayoutRec xf86ConfigLayout;
+
+extern _X_EXPORT DriverPtr *xf86DriverList;
+extern _X_EXPORT int xf86NumDrivers;
+extern _X_EXPORT Bool xf86Resetting;
+extern _X_EXPORT Bool xf86Initialising;
+extern _X_EXPORT int xf86NumScreens;
+extern _X_EXPORT const char *xf86VisualNames[];
+extern _X_EXPORT int xf86Verbose; /* verbosity level */
+extern _X_EXPORT int xf86LogVerbose; /* log file verbosity level */
+extern _X_EXPORT Bool xorgHWAccess;
+
+extern _X_EXPORT RootWinPropPtr *xf86RegisteredPropertiesTable;
+
+#ifndef DEFAULT_VERBOSE
+#define DEFAULT_VERBOSE 0
+#endif
+#ifndef DEFAULT_LOG_VERBOSE
+#define DEFAULT_LOG_VERBOSE 3
+#endif
+#ifndef DEFAULT_DPI
+#define DEFAULT_DPI 96
+#endif
+
+/* Function Prototypes */
+#ifndef _NO_XF86_PROTOTYPES
+
+/* xf86Bus.c */
+extern _X_EXPORT Bool xf86BusConfig(void);
+extern _X_EXPORT void xf86BusProbe(void);
+extern _X_EXPORT void xf86AccessEnter(void);
+extern _X_EXPORT void xf86AccessLeave(void);
+extern _X_EXPORT void xf86PostProbe(void);
+extern _X_EXPORT void xf86ClearEntityListForScreen(int scrnIndex);
+extern _X_EXPORT void xf86AddDevToEntity(int entityIndex, GDevPtr dev);
+
+/* xf86Config.c */
+
+extern _X_EXPORT Bool xf86PathIsSafe(const char *path);
+
+/* xf86DefaultModes */
+
+extern _X_EXPORT const DisplayModeRec xf86DefaultModes[];
+extern _X_EXPORT const int xf86NumDefaultModes;
+
+/* xf86Configure.c */
+extern _X_EXPORT void DoConfigure(void);
+
+/* xf86ShowOpts.c */
+extern _X_EXPORT void DoShowOptions(void);
+
+/* xf86Events.c */
+
+extern _X_EXPORT void xf86Wakeup(pointer blockData, int err, pointer pReadmask);
+extern _X_HIDDEN int xf86SigWrapper(int signo);
+extern _X_EXPORT void xf86HandlePMEvents(int fd, pointer data);
+extern _X_EXPORT int (*xf86PMGetEventFromOs)(int fd,pmEvent *events,int num);
+extern _X_EXPORT pmWait (*xf86PMConfirmEventToOs)(int fd,pmEvent event);
+
+/* xf86Helper.c */
+extern _X_EXPORT void xf86LogInit(void);
+extern _X_EXPORT void xf86CloseLog(void);
+
+/* xf86Init.c */
+extern _X_EXPORT Bool xf86LoadModules(char **list, pointer *optlist);
+extern _X_EXPORT int xf86SetVerbosity(int verb);
+extern _X_EXPORT int xf86SetLogVerbosity(int verb);
+extern _X_EXPORT Bool xf86CallDriverProbe( struct _DriverRec * drv, Bool detect_only );
+
+/* xf86Xinput.c */
+extern _X_EXPORT EventList *xf86Events;
+
+#endif /* _NO_XF86_PROTOTYPES */
+
+
+#endif /* _XF86PRIV_H */
diff --git a/xorg-server/hw/xfree86/common/xf86str.h b/xorg-server/hw/xfree86/common/xf86str.h
index 74ad759c5..0493dc53c 100644
--- a/xorg-server/hw/xfree86/common/xf86str.h
+++ b/xorg-server/hw/xfree86/common/xf86str.h
@@ -1,913 +1,906 @@
-
-/*
- * 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 public XFree86 data structures/types.
- * Any data structures that video drivers need to access should go here.
- */
-
-#ifndef _XF86STR_H
-#define _XF86STR_H
-
-#include "misc.h"
-#include "input.h"
-#include "scrnintstr.h"
-#include "pixmapstr.h"
-#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).
- * On most platforms \c uintptr_t will suffice. However, on some mixed
- * 32-bit / 64-bit platforms, such as 32-bit binaries on 64-bit PowerPC, this
- * must be 64-bits.
- */
-#include <inttypes.h>
-#if defined(__powerpc__)
-typedef uint64_t memType;
-#else
-typedef uintptr_t memType;
-#endif
-
-
-/* Video mode flags */
-
-typedef enum {
- V_PHSYNC = 0x0001,
- V_NHSYNC = 0x0002,
- V_PVSYNC = 0x0004,
- V_NVSYNC = 0x0008,
- V_INTERLACE = 0x0010,
- V_DBLSCAN = 0x0020,
- V_CSYNC = 0x0040,
- V_PCSYNC = 0x0080,
- V_NCSYNC = 0x0100,
- V_HSKEW = 0x0200, /* hskew provided */
- V_BCAST = 0x0400,
- V_PIXMUX = 0x1000,
- V_DBLCLK = 0x2000,
- V_CLKDIV2 = 0x4000
-} ModeFlags;
-
-typedef enum {
- INTERLACE_HALVE_V = 0x0001 /* Halve V values for interlacing */
-} CrtcAdjustFlags;
-
-/* Flags passed to ChipValidMode() */
-typedef enum {
- MODECHECK_INITIAL = 0,
- MODECHECK_FINAL = 1
-} ModeCheckFlags;
-
-/* These are possible return values for xf86CheckMode() and ValidMode() */
-typedef enum {
- MODE_OK = 0, /* Mode OK */
- MODE_HSYNC, /* hsync out of range */
- MODE_VSYNC, /* vsync out of range */
- MODE_H_ILLEGAL, /* mode has illegal horizontal timings */
- MODE_V_ILLEGAL, /* mode has illegal horizontal timings */
- MODE_BAD_WIDTH, /* requires an unsupported linepitch */
- MODE_NOMODE, /* no mode with a maching name */
- MODE_NO_INTERLACE, /* interlaced mode not supported */
- MODE_NO_DBLESCAN, /* doublescan mode not supported */
- MODE_NO_VSCAN, /* multiscan mode not supported */
- MODE_MEM, /* insufficient video memory */
- MODE_VIRTUAL_X, /* mode width too large for specified virtual size */
- MODE_VIRTUAL_Y, /* mode height too large for specified virtual size */
- MODE_MEM_VIRT, /* insufficient video memory given virtual size */
- MODE_NOCLOCK, /* no fixed clock available */
- MODE_CLOCK_HIGH, /* clock required is too high */
- MODE_CLOCK_LOW, /* clock required is too low */
- MODE_CLOCK_RANGE, /* clock/mode isn't in a ClockRange */
- MODE_BAD_HVALUE, /* horizontal timing was out of range */
- MODE_BAD_VVALUE, /* vertical timing was out of range */
- MODE_BAD_VSCAN, /* VScan value out of range */
- MODE_HSYNC_NARROW, /* horizontal sync too narrow */
- MODE_HSYNC_WIDE, /* horizontal sync too wide */
- MODE_HBLANK_NARROW, /* horizontal blanking too narrow */
- MODE_HBLANK_WIDE, /* horizontal blanking too wide */
- MODE_VSYNC_NARROW, /* vertical sync too narrow */
- MODE_VSYNC_WIDE, /* vertical sync too wide */
- MODE_VBLANK_NARROW, /* vertical blanking too narrow */
- MODE_VBLANK_WIDE, /* vertical blanking too wide */
- MODE_PANEL, /* exceeds panel dimensions */
- MODE_INTERLACE_WIDTH, /* width too large for interlaced mode */
- MODE_ONE_WIDTH, /* only one width is supported */
- MODE_ONE_HEIGHT, /* only one height is supported */
- MODE_ONE_SIZE, /* only one resolution is supported */
- MODE_NO_REDUCED, /* monitor doesn't accept reduced blanking */
- MODE_BANDWIDTH, /* mode requires too much memory bandwidth */
- MODE_BAD = -2, /* unspecified reason */
- MODE_ERROR = -1 /* error condition */
-} ModeStatus;
-
-/*
- * The mode sets are, from best to worst: USERDEF, DRIVER, and DEFAULT/BUILTIN.
- * Preferred will bubble a mode to the top within a set.
- */
-# define M_T_BUILTIN 0x01 /* built-in mode */
-# define M_T_CLOCK_C (0x02 | M_T_BUILTIN) /* built-in mode - configure clock */
-# define M_T_CRTC_C (0x04 | M_T_BUILTIN) /* built-in mode - configure CRTC */
-# define M_T_CLOCK_CRTC_C (M_T_CLOCK_C | M_T_CRTC_C)
- /* built-in mode - configure CRTC and clock */
-# define M_T_PREFERRED 0x08 /* preferred mode within a set */
-# define M_T_DEFAULT 0x10 /* (VESA) default modes */
-# define M_T_USERDEF 0x20 /* One of the modes from the config file */
-# define M_T_DRIVER 0x40 /* Supplied by the driver (EDID, etc) */
-# define M_T_USERPREF 0x80 /* mode preferred by the user config */
-
-/* Video mode */
-typedef struct _DisplayModeRec {
- struct _DisplayModeRec * prev;
- struct _DisplayModeRec * next;
- char * name; /* identifier for the mode */
- ModeStatus status;
- int type;
-
- /* These are the values that the user sees/provides */
- int Clock; /* pixel clock freq (kHz) */
- int HDisplay; /* horizontal timing */
- int HSyncStart;
- int HSyncEnd;
- int HTotal;
- int HSkew;
- int VDisplay; /* vertical timing */
- int VSyncStart;
- int VSyncEnd;
- int VTotal;
- int VScan;
- int Flags;
-
- /* These are the values the hardware uses */
- int ClockIndex;
- int SynthClock; /* Actual clock freq to
- * be programmed (kHz) */
- int CrtcHDisplay;
- int CrtcHBlankStart;
- int CrtcHSyncStart;
- int CrtcHSyncEnd;
- int CrtcHBlankEnd;
- int CrtcHTotal;
- int CrtcHSkew;
- int CrtcVDisplay;
- int CrtcVBlankStart;
- int CrtcVSyncStart;
- int CrtcVSyncEnd;
- int CrtcVBlankEnd;
- int CrtcVTotal;
- Bool CrtcHAdjusted;
- Bool CrtcVAdjusted;
- int PrivSize;
- INT32 * Private;
- int PrivFlags;
-
- float HSync, VRefresh;
-} DisplayModeRec, *DisplayModePtr;
-
-/* The monitor description */
-
-#define MAX_HSYNC 8
-#define MAX_VREFRESH 8
-
-typedef struct { float hi, lo; } range;
-
-typedef struct { CARD32 red, green, blue; } rgb;
-
-typedef struct { float red, green, blue; } Gamma;
-
-/* The permitted gamma range is 1 / GAMMA_MAX <= g <= GAMMA_MAX */
-#define GAMMA_MAX 10.0
-#define GAMMA_MIN (1.0 / GAMMA_MAX)
-#define GAMMA_ZERO (GAMMA_MIN / 100.0)
-
-typedef struct {
- char * id;
- char * vendor;
- char * model;
- int nHsync;
- range hsync[MAX_HSYNC];
- int nVrefresh;
- range vrefresh[MAX_VREFRESH];
- DisplayModePtr Modes; /* Start of the monitor's mode list */
- DisplayModePtr Last; /* End of the monitor's mode list */
- Gamma gamma; /* Gamma of the monitor */
- int widthmm;
- int heightmm;
- pointer options;
- pointer DDC;
- Bool reducedblanking; /* Allow CVT reduced blanking modes? */
- int maxPixClock; /* in kHz, like mode->Clock */
-} MonRec, *MonPtr;
-
-/* the list of clock ranges */
-typedef struct x_ClockRange {
- struct x_ClockRange *next;
- int minClock; /* (kHz) */
- int maxClock; /* (kHz) */
- int clockIndex; /* -1 for programmable clocks */
- Bool interlaceAllowed;
- Bool doubleScanAllowed;
- int ClockMulFactor;
- int ClockDivFactor;
- int PrivFlags;
-} ClockRange, *ClockRangePtr;
-
-/*
- * The driverFunc. xorgDriverFuncOp specifies the action driver should
- * perform. If requested option is not supported function should return
- * FALSE. pointer can be used to pass arguments to the function or
- * to return data to the caller.
- */
-typedef struct _ScrnInfoRec *ScrnInfoPtr;
-
-/* do not change order */
-typedef enum {
- RR_GET_INFO,
- RR_SET_CONFIG,
- RR_GET_MODE_MM,
- GET_REQUIRED_HW_INTERFACES = 10
-} xorgDriverFuncOp;
-
-typedef Bool xorgDriverFuncProc (ScrnInfoPtr, xorgDriverFuncOp,
- pointer);
-
-/* RR_GET_INFO, RR_SET_CONFIG */
-typedef struct {
- int rotation;
- int rate;
- int width;
- int height;
-} xorgRRConfig;
-
-typedef union {
- short RRRotations;
- xorgRRConfig RRConfig;
-} xorgRRRotation, *xorgRRRotationPtr;
-
-/* RR_GET_MODE_MM */
-typedef struct {
- DisplayModePtr mode;
- int virtX;
- int virtY;
- int mmWidth;
- int mmHeight;
-} xorgRRModeMM, *xorgRRModeMMPtr;
-
-/* GET_REQUIRED_HW_INTERFACES */
-#define HW_IO 1
-#define HW_MMIO 2
-#define HW_SKIP_CONSOLE 4
-#define NEED_IO_ENABLED(x) (x & HW_IO)
-
-typedef CARD32 xorgHWFlags;
-
-/*
- * The driver list struct. This contains the information required for each
- * driver before a ScrnInfoRec has been allocated.
- */
-struct _DriverRec;
-
-typedef struct {
- int driverVersion;
- char * driverName;
- void (*Identify)(int flags);
- Bool (*Probe)(struct _DriverRec *drv, int flags);
- const OptionInfoRec * (*AvailableOptions)(int chipid, int bustype);
- pointer module;
- int refCount;
-} DriverRec1;
-
-struct _SymTabRec;
-struct _PciChipsets;
-
-typedef struct _DriverRec {
- int driverVersion;
- char * driverName;
- void (*Identify)(int flags);
- Bool (*Probe)(struct _DriverRec *drv, int flags);
- const OptionInfoRec * (*AvailableOptions)(int chipid, int bustype);
- pointer module;
- int refCount;
- xorgDriverFuncProc *driverFunc;
-
- const struct pci_id_match * supported_devices;
- Bool (*PciProbe)( struct _DriverRec * drv, int entity_num,
- struct pci_device * dev, intptr_t match_data );
-} DriverRec, *DriverPtr;
-
-/*
- * AddDriver flags
- */
-#define HaveDriverFuncs 1
-
-/*
- * These are the private bus types. New types can be added here. Types
- * required for the public interface should be added to xf86str.h, with
- * function prototypes added to xf86.h.
- */
-
-/* Tolerate prior #include <linux/input.h> */
-#if defined(linux) && defined(_INPUT_H)
-#undef BUS_NONE
-#undef BUS_PCI
-#undef BUS_SBUS
-#undef BUS_last
-#endif
-
-typedef enum {
- BUS_NONE,
- BUS_PCI,
- BUS_SBUS,
- BUS_last /* Keep last */
-} BusType;
-
-struct pci_device;
-
-typedef struct {
- int fbNum;
-} SbusBusId;
-
-typedef struct _bus {
- BusType type;
- union {
- struct pci_device *pci;
- SbusBusId sbus;
- } id;
-} BusRec, *BusPtr;
-
-#define MAXCLOCKS 128
-typedef enum {
- DAC_BPP8 = 0,
- DAC_BPP16,
- DAC_BPP24,
- DAC_BPP32,
- MAXDACSPEEDS
-} DacSpeedIndex;
-
-typedef struct {
- char * identifier;
- char * vendor;
- char * board;
- char * chipset;
- char * ramdac;
- char * driver;
- struct _confscreenrec * myScreenSection;
- Bool claimed;
- int dacSpeeds[MAXDACSPEEDS];
- int numclocks;
- int clock[MAXCLOCKS];
- char * clockchip;
- char * busID;
- Bool active;
- Bool inUse;
- int videoRam;
- int textClockFreq;
- unsigned long BiosBase; /* Base address of video BIOS */
- unsigned long MemBase; /* Frame buffer base address */
- unsigned long IOBase;
- int chipID;
- int chipRev;
- pointer options;
- int irq;
- int screen; /* For multi-CRTC cards */
-} GDevRec, *GDevPtr;
-
-typedef struct {
- int frameX0;
- int frameY0;
- int virtualX;
- int virtualY;
- int depth;
- int fbbpp;
- rgb weight;
- rgb blackColour;
- rgb whiteColour;
- int defaultVisual;
- char ** modes;
- pointer options;
-} DispRec, *DispPtr;
-
-typedef struct _confxvportrec {
- char * identifier;
- pointer options;
-} confXvPortRec, *confXvPortPtr;
-
-typedef struct _confxvadaptrec {
- char * identifier;
- int numports;
- confXvPortPtr ports;
- pointer options;
-} confXvAdaptorRec, *confXvAdaptorPtr;
-
-typedef struct _confscreenrec {
- char * id;
- int screennum;
- int defaultdepth;
- int defaultbpp;
- int defaultfbbpp;
- MonPtr monitor;
- GDevPtr device;
- int numdisplays;
- DispPtr displays;
- int numxvadaptors;
- confXvAdaptorPtr xvadaptors;
- pointer options;
-} confScreenRec, *confScreenPtr;
-
-typedef enum {
- PosObsolete = -1,
- PosAbsolute = 0,
- PosRightOf,
- PosLeftOf,
- PosAbove,
- PosBelow,
- PosRelative
-} PositionType;
-
-typedef struct _screenlayoutrec {
- confScreenPtr screen;
- char * topname;
- confScreenPtr top;
- char * bottomname;
- confScreenPtr bottom;
- char * leftname;
- confScreenPtr left;
- char * rightname;
- confScreenPtr right;
- PositionType where;
- int x;
- int y;
- char * refname;
- confScreenPtr refscreen;
-} screenLayoutRec, *screenLayoutPtr;
-
-typedef struct _InputInfoRec InputInfoRec;
-
-typedef struct _serverlayoutrec {
- char * id;
- screenLayoutPtr screens;
- GDevPtr inactives;
- InputInfoRec** inputs; /* NULL terminated */
- pointer options;
-} serverLayoutRec, *serverLayoutPtr;
-
-typedef struct _confdribufferrec {
- int count;
- int size;
- enum {
- XF86DRI_WC_HINT = 0x0001 /* Placeholder: not implemented */
- } flags;
-} confDRIBufferRec, *confDRIBufferPtr;
-
-typedef struct _confdrirec {
- int group;
- int mode;
- int bufs_count;
- confDRIBufferRec *bufs;
-} confDRIRec, *confDRIPtr;
-
-/* These values should be adjusted when new fields are added to ScrnInfoRec */
-#define NUM_RESERVED_INTS 16
-#define NUM_RESERVED_POINTERS 14
-#define NUM_RESERVED_FUNCS 10
-
-typedef pointer (*funcPointer)(void);
-
-/* flags for depth 24 pixmap options */
-typedef enum {
- Pix24DontCare = 0,
- Pix24Use24,
- Pix24Use32
-} Pix24Flags;
-
-/* Power management events: so far we only support APM */
-
-typedef enum {
- XF86_APM_UNKNOWN = -1,
- XF86_APM_SYS_STANDBY,
- XF86_APM_SYS_SUSPEND,
- XF86_APM_CRITICAL_SUSPEND,
- XF86_APM_USER_STANDBY,
- XF86_APM_USER_SUSPEND,
- XF86_APM_STANDBY_RESUME,
- XF86_APM_NORMAL_RESUME,
- XF86_APM_CRITICAL_RESUME,
- XF86_APM_LOW_BATTERY,
- XF86_APM_POWER_STATUS_CHANGE,
- XF86_APM_UPDATE_TIME,
- XF86_APM_CAPABILITY_CHANGED,
- XF86_APM_STANDBY_FAILED,
- XF86_APM_SUSPEND_FAILED
-} pmEvent;
-
-typedef enum {
- PM_WAIT,
- PM_CONTINUE,
- PM_FAILED,
- PM_NONE
-} pmWait;
-
-typedef struct _PciChipsets {
- /**
- * Key used to match this device with its name in an array of
- * \c SymTabRec.
- */
- int numChipset;
-
- /**
- * This value is quirky. Depending on the driver, it can take on one of
- * three meanings. In drivers that have exactly one vendor ID (e.g.,
- * radeon, mga, i810) the low 16-bits are the device ID.
- *
- * In drivers that can have multiple vendor IDs (e.g., the glint driver
- * can have either 3dlabs' ID or TI's ID, the i740 driver can have either
- * Intel's ID or Real3D's ID, etc.) the low 16-bits are the device ID and
- * the high 16-bits are the vendor ID.
- *
- * In drivers that don't have a specific vendor (e.g., vga) contains the
- * device ID for either the generic VGA or generic 8514 devices. This
- * turns out to be the same as the subclass and programming interface
- * value (e.g., the full 24-bit class for the VGA device is 0x030000 (or
- * 0x000101) and for 8514 is 0x030001).
- */
- int PCIid;
-
-/* dummy place holders for drivers to build against old/new servers */
-#define RES_UNDEFINED NULL
-#define RES_EXCLUSIVE_VGA NULL
-#define RES_SHARED_VGA NULL
- void *dummy;
-} PciChipsets;
-
-
-/* Entity properties */
-typedef void (*EntityProc)(int entityIndex,pointer private);
-
-typedef struct _entityInfo {
- int index;
- BusRec location;
- int chipset;
- Bool active;
- GDevPtr device;
- DriverPtr driver;
-} EntityInfoRec, *EntityInfoPtr;
-
-/* server states */
-
-typedef enum {
- SETUP,
- OPERATING
-} xf86State;
-
-/* DGA */
-
-typedef struct {
- int num; /* A unique identifier for the mode (num > 0) */
- DisplayModePtr mode;
- int flags; /* DGA_CONCURRENT_ACCESS, etc... */
- int imageWidth; /* linear accessible portion (pixels) */
- int imageHeight;
- int pixmapWidth; /* Xlib accessible portion (pixels) */
- int pixmapHeight; /* both fields ignored if no concurrent access */
- int bytesPerScanline;
- int byteOrder; /* MSBFirst, LSBFirst */
- int depth;
- int bitsPerPixel;
- unsigned long red_mask;
- unsigned long green_mask;
- unsigned long blue_mask;
- short visualClass;
- int viewportWidth;
- int viewportHeight;
- int xViewportStep; /* viewport position granularity */
- int yViewportStep;
- int maxViewportX; /* max viewport origin */
- int maxViewportY;
- int viewportFlags; /* types of page flipping possible */
- int offset; /* offset into physical memory */
- unsigned char *address; /* server's mapped framebuffer */
- int reserved1;
- int reserved2;
-} DGAModeRec, *DGAModePtr;
-
-typedef struct {
- DGAModePtr mode;
- PixmapPtr pPix;
-} DGADeviceRec, *DGADevicePtr;
-
-/*
- * Flags for driver Probe() functions.
- */
-#define PROBE_DEFAULT 0x00
-#define PROBE_DETECT 0x01
-#define PROBE_TRYHARD 0x02
-
-/*
- * Driver entry point types
- */
-
-typedef Bool xf86ProbeProc (DriverPtr, int);
-typedef Bool xf86PreInitProc (ScrnInfoPtr, int);
-typedef Bool xf86ScreenInitProc (int, ScreenPtr, int, char**);
-typedef Bool xf86SwitchModeProc (int, DisplayModePtr, int);
-typedef void xf86AdjustFrameProc (int, int, int, int);
-typedef Bool xf86EnterVTProc (int, int);
-typedef void xf86LeaveVTProc (int, int);
-typedef void xf86FreeScreenProc (int, int);
-typedef ModeStatus xf86ValidModeProc (int, DisplayModePtr, Bool, int);
-typedef void xf86EnableDisableFBAccessProc(int, Bool);
-typedef int xf86SetDGAModeProc (int, int, DGADevicePtr);
-typedef int xf86ChangeGammaProc (int, Gamma);
-typedef void xf86PointerMovedProc (int, int, int);
-typedef Bool xf86PMEventProc (int, pmEvent, Bool);
-typedef void xf86DPMSSetProc (ScrnInfoPtr, int, int);
-typedef void xf86LoadPaletteProc (ScrnInfoPtr, int, int *, LOCO *, VisualPtr);
-typedef void xf86SetOverscanProc (ScrnInfoPtr, int);
-typedef void xf86ModeSetProc (ScrnInfoPtr);
-
-
-/*
- * ScrnInfoRec
- *
- * There is one of these for each screen, and it holds all the screen-specific
- * information.
- *
- * Note: the size and layout must be kept the same across versions. New
- * fields are to be added in place of the "reserved*" fields. No fields
- * are to be dependent on compile-time defines.
- */
-
-
-typedef struct _ScrnInfoRec {
- int driverVersion;
- char * driverName; /* canonical name used in */
- /* the config file */
- ScreenPtr pScreen; /* Pointer to the ScreenRec */
- int scrnIndex; /* Number of this screen */
- Bool configured; /* Is this screen valid */
- int origIndex; /* initial number assigned to
- * this screen before
- * finalising the number of
- * available screens */
-
- /* Display-wide screenInfo values needed by this screen */
- int imageByteOrder;
- int bitmapScanlineUnit;
- int bitmapScanlinePad;
- int bitmapBitOrder;
- int numFormats;
- PixmapFormatRec formats[MAXFORMATS];
- PixmapFormatRec fbFormat;
-
- int bitsPerPixel; /* fb bpp */
- Pix24Flags pixmap24; /* pixmap pref for depth 24 */
- int depth; /* depth of default visual */
- MessageType depthFrom; /* set from config? */
- MessageType bitsPerPixelFrom; /* set from config? */
- rgb weight; /* r/g/b weights */
- rgb mask; /* rgb masks */
- rgb offset; /* rgb offsets */
- int rgbBits; /* Number of bits in r/g/b */
- Gamma gamma; /* Gamma of the monitor */
- int defaultVisual; /* default visual class */
- int maxHValue; /* max horizontal timing */
- int maxVValue; /* max vertical timing value */
- int virtualX; /* Virtual width */
- int virtualY; /* Virtual height */
- int xInc; /* Horizontal timing increment */
- MessageType virtualFrom; /* set from config? */
- int displayWidth; /* memory pitch */
- int frameX0; /* viewport position */
- int frameY0;
- int frameX1;
- int frameY1;
- int zoomLocked; /* Disallow mode changes */
- DisplayModePtr modePool; /* list of compatible modes */
- DisplayModePtr modes; /* list of actual modes */
- DisplayModePtr currentMode; /* current mode
- * This was previously
- * overloaded with the modes
- * field, which is a pointer
- * into a circular list */
- confScreenPtr confScreen; /* Screen config info */
- MonPtr monitor; /* Monitor information */
- DispPtr display; /* Display information */
- int * entityList; /* List of device entities */
- int numEntities;
- int widthmm; /* physical display dimensions
- * in mm */
- int heightmm;
- int xDpi; /* width DPI */
- int yDpi; /* height DPI */
- char * name; /* Name to prefix messages */
- pointer driverPrivate; /* Driver private area */
- DevUnion * privates; /* Other privates can hook in
- * here */
- DriverPtr drv; /* xf86DriverList[] entry */
- pointer module; /* Pointer to module head */
- int colorKey;
- int overlayFlags;
-
- /* Some of these may be moved out of here into the driver private area */
-
- char * chipset; /* chipset name */
- char * ramdac; /* ramdac name */
- char * clockchip; /* clock name */
- Bool progClock; /* clock is programmable */
- int numClocks; /* number of clocks */
- int clock[MAXCLOCKS]; /* list of clock frequencies */
- int videoRam; /* amount of video ram (kb) */
- 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 */
- pointer options;
-
- int chipID;
- int chipRev;
-
- /* Allow screens to be enabled/disabled individually */
- Bool vtSema;
-
- /* hw cursor moves at SIGIO time */
- Bool silkenMouse;
-
- /* Storage for clockRanges and adjustFlags for use with the VidMode ext */
- ClockRangePtr clockRanges;
- int adjustFlags;
-
- /*
- * These can be used when the minor ABI version is incremented.
- * The NUM_* parameters must be reduced appropriately to keep the
- * structure size and alignment unchanged.
- */
- int reservedInt[NUM_RESERVED_INTS];
-
- int * entityInstanceList;
- struct pci_device *vgaDev;
-
- pointer reservedPtr[NUM_RESERVED_POINTERS];
-
- /*
- * Driver entry points.
- *
- */
-
- xf86ProbeProc *Probe;
- xf86PreInitProc *PreInit;
- xf86ScreenInitProc *ScreenInit;
- xf86SwitchModeProc *SwitchMode;
- xf86AdjustFrameProc *AdjustFrame;
- xf86EnterVTProc *EnterVT;
- xf86LeaveVTProc *LeaveVT;
- xf86FreeScreenProc *FreeScreen;
- xf86ValidModeProc *ValidMode;
- xf86EnableDisableFBAccessProc *EnableDisableFBAccess;
- xf86SetDGAModeProc *SetDGAMode;
- xf86ChangeGammaProc *ChangeGamma;
- xf86PointerMovedProc *PointerMoved;
- xf86PMEventProc *PMEvent;
- xf86DPMSSetProc *DPMSSet;
- xf86LoadPaletteProc *LoadPalette;
- xf86SetOverscanProc *SetOverscan;
- xorgDriverFuncProc *DriverFunc;
- xf86ModeSetProc *ModeSet;
-
- /*
- * This can be used when the minor ABI version is incremented.
- * The NUM_* parameter must be reduced appropriately to keep the
- * structure size and alignment unchanged.
- */
- funcPointer reservedFuncs[NUM_RESERVED_FUNCS];
-
-} ScrnInfoRec;
-
-
-typedef struct {
- Bool (*OpenFramebuffer)(
- ScrnInfoPtr pScrn,
- char **name,
- unsigned char **mem,
- int *size,
- int *offset,
- int *extra
- );
- void (*CloseFramebuffer)(ScrnInfoPtr pScrn);
- Bool (*SetMode)(ScrnInfoPtr pScrn, DGAModePtr pMode);
- void (*SetViewport)(ScrnInfoPtr pScrn, int x, int y, int flags);
- int (*GetViewport)(ScrnInfoPtr pScrn);
- void (*Sync)(ScrnInfoPtr);
- void (*FillRect)(
- ScrnInfoPtr pScrn,
- int x, int y, int w, int h,
- unsigned long color
- );
- void (*BlitRect)(
- ScrnInfoPtr pScrn,
- int srcx, int srcy,
- int w, int h,
- int dstx, int dsty
- );
- void (*BlitTransRect)(
- ScrnInfoPtr pScrn,
- int srcx, int srcy,
- int w, int h,
- int dstx, int dsty,
- unsigned long color
- );
-} DGAFunctionRec, *DGAFunctionPtr;
-
-typedef struct _SymTabRec {
- int token; /* id of the token */
- const char * name; /* token name */
-} SymTabRec, *SymTabPtr;
-
-/* flags for xf86LookupMode */
-typedef enum {
- LOOKUP_DEFAULT = 0, /* Use default mode lookup method */
- LOOKUP_BEST_REFRESH, /* Pick modes with best refresh */
- LOOKUP_CLOSEST_CLOCK, /* Pick modes with the closest clock */
- LOOKUP_LIST_ORDER, /* Pick first useful mode in list */
- LOOKUP_CLKDIV2 = 0x0100, /* Allow half clocks */
- LOOKUP_OPTIONAL_TOLERANCES = 0x0200 /* Allow missing hsync/vrefresh */
-} LookupModeFlags;
-
-#define NoDepth24Support 0x00
-#define Support24bppFb 0x01 /* 24bpp framebuffer supported */
-#define Support32bppFb 0x02 /* 32bpp framebuffer supported */
-#define SupportConvert24to32 0x04 /* Can convert 24bpp pixmap to 32bpp */
-#define SupportConvert32to24 0x08 /* Can convert 32bpp pixmap to 24bpp */
-#define PreferConvert24to32 0x10 /* prefer 24bpp pixmap to 32bpp conv */
-#define PreferConvert32to24 0x20 /* prefer 32bpp pixmap to 24bpp conv */
-
-
-/* For DPMS */
-typedef void (*DPMSSetProcPtr)(ScrnInfoPtr, int, int);
-
-/* Input handler proc */
-typedef void (*InputHandlerProc)(int fd, pointer data);
-
-/* These are used by xf86GetClocks */
-#define CLK_REG_SAVE -1
-#define CLK_REG_RESTORE -2
-
-/*
- * misc constants
- */
-#define INTERLACE_REFRESH_WEIGHT 1.5
-#define SYNC_TOLERANCE 0.01 /* 1 percent */
-#define CLOCK_TOLERANCE 2000 /* Clock matching tolerance (2MHz) */
-
-
-#define OVERLAY_8_32_DUALFB 0x00000001
-#define OVERLAY_8_24_DUALFB 0x00000002
-#define OVERLAY_8_16_DUALFB 0x00000004
-#define OVERLAY_8_32_PLANAR 0x00000008
-
-/* Values of xf86Info.mouseFlags */
-#define MF_CLEAR_DTR 1
-#define MF_CLEAR_RTS 2
-
-/* Action Events */
-typedef enum {
- ACTION_TERMINATE = 0, /* Terminate Server */
- ACTION_NEXT_MODE = 10, /* Switch to next video mode */
- ACTION_PREV_MODE,
- ACTION_SWITCHSCREEN = 100, /* VT switch */
- ACTION_SWITCHSCREEN_NEXT,
- ACTION_SWITCHSCREEN_PREV,
-} ActionEvent;
-
-#endif /* _XF86STR_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 public XFree86 data structures/types.
+ * Any data structures that video drivers need to access should go here.
+ */
+
+#ifndef _XF86STR_H
+#define _XF86STR_H
+
+#include "misc.h"
+#include "input.h"
+#include "scrnintstr.h"
+#include "pixmapstr.h"
+#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).
+ * On most platforms \c uintptr_t will suffice. However, on some mixed
+ * 32-bit / 64-bit platforms, such as 32-bit binaries on 64-bit PowerPC, this
+ * must be 64-bits.
+ */
+#include <inttypes.h>
+#if defined(__powerpc__)
+typedef uint64_t memType;
+#else
+typedef uintptr_t memType;
+#endif
+
+
+/* Video mode flags */
+
+typedef enum {
+ V_PHSYNC = 0x0001,
+ V_NHSYNC = 0x0002,
+ V_PVSYNC = 0x0004,
+ V_NVSYNC = 0x0008,
+ V_INTERLACE = 0x0010,
+ V_DBLSCAN = 0x0020,
+ V_CSYNC = 0x0040,
+ V_PCSYNC = 0x0080,
+ V_NCSYNC = 0x0100,
+ V_HSKEW = 0x0200, /* hskew provided */
+ V_BCAST = 0x0400,
+ V_PIXMUX = 0x1000,
+ V_DBLCLK = 0x2000,
+ V_CLKDIV2 = 0x4000
+} ModeFlags;
+
+typedef enum {
+ INTERLACE_HALVE_V = 0x0001 /* Halve V values for interlacing */
+} CrtcAdjustFlags;
+
+/* Flags passed to ChipValidMode() */
+typedef enum {
+ MODECHECK_INITIAL = 0,
+ MODECHECK_FINAL = 1
+} ModeCheckFlags;
+
+/* These are possible return values for xf86CheckMode() and ValidMode() */
+typedef enum {
+ MODE_OK = 0, /* Mode OK */
+ MODE_HSYNC, /* hsync out of range */
+ MODE_VSYNC, /* vsync out of range */
+ MODE_H_ILLEGAL, /* mode has illegal horizontal timings */
+ MODE_V_ILLEGAL, /* mode has illegal horizontal timings */
+ MODE_BAD_WIDTH, /* requires an unsupported linepitch */
+ MODE_NOMODE, /* no mode with a maching name */
+ MODE_NO_INTERLACE, /* interlaced mode not supported */
+ MODE_NO_DBLESCAN, /* doublescan mode not supported */
+ MODE_NO_VSCAN, /* multiscan mode not supported */
+ MODE_MEM, /* insufficient video memory */
+ MODE_VIRTUAL_X, /* mode width too large for specified virtual size */
+ MODE_VIRTUAL_Y, /* mode height too large for specified virtual size */
+ MODE_MEM_VIRT, /* insufficient video memory given virtual size */
+ MODE_NOCLOCK, /* no fixed clock available */
+ MODE_CLOCK_HIGH, /* clock required is too high */
+ MODE_CLOCK_LOW, /* clock required is too low */
+ MODE_CLOCK_RANGE, /* clock/mode isn't in a ClockRange */
+ MODE_BAD_HVALUE, /* horizontal timing was out of range */
+ MODE_BAD_VVALUE, /* vertical timing was out of range */
+ MODE_BAD_VSCAN, /* VScan value out of range */
+ MODE_HSYNC_NARROW, /* horizontal sync too narrow */
+ MODE_HSYNC_WIDE, /* horizontal sync too wide */
+ MODE_HBLANK_NARROW, /* horizontal blanking too narrow */
+ MODE_HBLANK_WIDE, /* horizontal blanking too wide */
+ MODE_VSYNC_NARROW, /* vertical sync too narrow */
+ MODE_VSYNC_WIDE, /* vertical sync too wide */
+ MODE_VBLANK_NARROW, /* vertical blanking too narrow */
+ MODE_VBLANK_WIDE, /* vertical blanking too wide */
+ MODE_PANEL, /* exceeds panel dimensions */
+ MODE_INTERLACE_WIDTH, /* width too large for interlaced mode */
+ MODE_ONE_WIDTH, /* only one width is supported */
+ MODE_ONE_HEIGHT, /* only one height is supported */
+ MODE_ONE_SIZE, /* only one resolution is supported */
+ MODE_NO_REDUCED, /* monitor doesn't accept reduced blanking */
+ MODE_BANDWIDTH, /* mode requires too much memory bandwidth */
+ MODE_BAD = -2, /* unspecified reason */
+ MODE_ERROR = -1 /* error condition */
+} ModeStatus;
+
+/*
+ * The mode sets are, from best to worst: USERDEF, DRIVER, and DEFAULT/BUILTIN.
+ * Preferred will bubble a mode to the top within a set.
+ */
+# define M_T_BUILTIN 0x01 /* built-in mode */
+# define M_T_CLOCK_C (0x02 | M_T_BUILTIN) /* built-in mode - configure clock */
+# define M_T_CRTC_C (0x04 | M_T_BUILTIN) /* built-in mode - configure CRTC */
+# define M_T_CLOCK_CRTC_C (M_T_CLOCK_C | M_T_CRTC_C)
+ /* built-in mode - configure CRTC and clock */
+# define M_T_PREFERRED 0x08 /* preferred mode within a set */
+# define M_T_DEFAULT 0x10 /* (VESA) default modes */
+# define M_T_USERDEF 0x20 /* One of the modes from the config file */
+# define M_T_DRIVER 0x40 /* Supplied by the driver (EDID, etc) */
+# define M_T_USERPREF 0x80 /* mode preferred by the user config */
+
+/* Video mode */
+typedef struct _DisplayModeRec {
+ struct _DisplayModeRec * prev;
+ struct _DisplayModeRec * next;
+ char * name; /* identifier for the mode */
+ ModeStatus status;
+ int type;
+
+ /* These are the values that the user sees/provides */
+ int Clock; /* pixel clock freq (kHz) */
+ int HDisplay; /* horizontal timing */
+ int HSyncStart;
+ int HSyncEnd;
+ int HTotal;
+ int HSkew;
+ int VDisplay; /* vertical timing */
+ int VSyncStart;
+ int VSyncEnd;
+ int VTotal;
+ int VScan;
+ int Flags;
+
+ /* These are the values the hardware uses */
+ int ClockIndex;
+ int SynthClock; /* Actual clock freq to
+ * be programmed (kHz) */
+ int CrtcHDisplay;
+ int CrtcHBlankStart;
+ int CrtcHSyncStart;
+ int CrtcHSyncEnd;
+ int CrtcHBlankEnd;
+ int CrtcHTotal;
+ int CrtcHSkew;
+ int CrtcVDisplay;
+ int CrtcVBlankStart;
+ int CrtcVSyncStart;
+ int CrtcVSyncEnd;
+ int CrtcVBlankEnd;
+ int CrtcVTotal;
+ Bool CrtcHAdjusted;
+ Bool CrtcVAdjusted;
+ int PrivSize;
+ INT32 * Private;
+ int PrivFlags;
+
+ float HSync, VRefresh;
+} DisplayModeRec, *DisplayModePtr;
+
+/* The monitor description */
+
+#define MAX_HSYNC 8
+#define MAX_VREFRESH 8
+
+typedef struct { float hi, lo; } range;
+
+typedef struct { CARD32 red, green, blue; } rgb;
+
+typedef struct { float red, green, blue; } Gamma;
+
+/* The permitted gamma range is 1 / GAMMA_MAX <= g <= GAMMA_MAX */
+#define GAMMA_MAX 10.0
+#define GAMMA_MIN (1.0 / GAMMA_MAX)
+#define GAMMA_ZERO (GAMMA_MIN / 100.0)
+
+typedef struct {
+ char * id;
+ char * vendor;
+ char * model;
+ int nHsync;
+ range hsync[MAX_HSYNC];
+ int nVrefresh;
+ range vrefresh[MAX_VREFRESH];
+ DisplayModePtr Modes; /* Start of the monitor's mode list */
+ DisplayModePtr Last; /* End of the monitor's mode list */
+ Gamma gamma; /* Gamma of the monitor */
+ int widthmm;
+ int heightmm;
+ pointer options;
+ pointer DDC;
+ Bool reducedblanking; /* Allow CVT reduced blanking modes? */
+ int maxPixClock; /* in kHz, like mode->Clock */
+} MonRec, *MonPtr;
+
+/* the list of clock ranges */
+typedef struct x_ClockRange {
+ struct x_ClockRange *next;
+ int minClock; /* (kHz) */
+ int maxClock; /* (kHz) */
+ int clockIndex; /* -1 for programmable clocks */
+ Bool interlaceAllowed;
+ Bool doubleScanAllowed;
+ int ClockMulFactor;
+ int ClockDivFactor;
+ int PrivFlags;
+} ClockRange, *ClockRangePtr;
+
+/*
+ * The driverFunc. xorgDriverFuncOp specifies the action driver should
+ * perform. If requested option is not supported function should return
+ * FALSE. pointer can be used to pass arguments to the function or
+ * to return data to the caller.
+ */
+typedef struct _ScrnInfoRec *ScrnInfoPtr;
+
+/* do not change order */
+typedef enum {
+ RR_GET_INFO,
+ RR_SET_CONFIG,
+ RR_GET_MODE_MM,
+ GET_REQUIRED_HW_INTERFACES = 10
+} xorgDriverFuncOp;
+
+typedef Bool xorgDriverFuncProc (ScrnInfoPtr, xorgDriverFuncOp,
+ pointer);
+
+/* RR_GET_INFO, RR_SET_CONFIG */
+typedef struct {
+ int rotation;
+ int rate;
+ int width;
+ int height;
+} xorgRRConfig;
+
+typedef union {
+ short RRRotations;
+ xorgRRConfig RRConfig;
+} xorgRRRotation, *xorgRRRotationPtr;
+
+/* RR_GET_MODE_MM */
+typedef struct {
+ DisplayModePtr mode;
+ int virtX;
+ int virtY;
+ int mmWidth;
+ int mmHeight;
+} xorgRRModeMM, *xorgRRModeMMPtr;
+
+/* GET_REQUIRED_HW_INTERFACES */
+#define HW_IO 1
+#define HW_MMIO 2
+#define HW_SKIP_CONSOLE 4
+#define NEED_IO_ENABLED(x) (x & HW_IO)
+
+typedef CARD32 xorgHWFlags;
+
+/*
+ * The driver list struct. This contains the information required for each
+ * driver before a ScrnInfoRec has been allocated.
+ */
+struct _DriverRec;
+
+typedef struct {
+ int driverVersion;
+ char * driverName;
+ void (*Identify)(int flags);
+ Bool (*Probe)(struct _DriverRec *drv, int flags);
+ const OptionInfoRec * (*AvailableOptions)(int chipid, int bustype);
+ pointer module;
+ int refCount;
+} DriverRec1;
+
+struct _SymTabRec;
+struct _PciChipsets;
+
+typedef struct _DriverRec {
+ int driverVersion;
+ char * driverName;
+ void (*Identify)(int flags);
+ Bool (*Probe)(struct _DriverRec *drv, int flags);
+ const OptionInfoRec * (*AvailableOptions)(int chipid, int bustype);
+ pointer module;
+ int refCount;
+ xorgDriverFuncProc *driverFunc;
+
+ const struct pci_id_match * supported_devices;
+ Bool (*PciProbe)( struct _DriverRec * drv, int entity_num,
+ struct pci_device * dev, intptr_t match_data );
+} DriverRec, *DriverPtr;
+
+/*
+ * AddDriver flags
+ */
+#define HaveDriverFuncs 1
+
+/*
+ * These are the private bus types. New types can be added here. Types
+ * required for the public interface should be added to xf86str.h, with
+ * function prototypes added to xf86.h.
+ */
+
+/* Tolerate prior #include <linux/input.h> */
+#if defined(linux) && defined(_INPUT_H)
+#undef BUS_NONE
+#undef BUS_PCI
+#undef BUS_SBUS
+#undef BUS_last
+#endif
+
+typedef enum {
+ BUS_NONE,
+ BUS_PCI,
+ BUS_SBUS,
+ BUS_last /* Keep last */
+} BusType;
+
+struct pci_device;
+
+typedef struct {
+ int fbNum;
+} SbusBusId;
+
+typedef struct _bus {
+ BusType type;
+ union {
+ struct pci_device *pci;
+ SbusBusId sbus;
+ } id;
+} BusRec, *BusPtr;
+
+#define MAXCLOCKS 128
+typedef enum {
+ DAC_BPP8 = 0,
+ DAC_BPP16,
+ DAC_BPP24,
+ DAC_BPP32,
+ MAXDACSPEEDS
+} DacSpeedIndex;
+
+typedef struct {
+ char * identifier;
+ char * vendor;
+ char * board;
+ char * chipset;
+ char * ramdac;
+ char * driver;
+ struct _confscreenrec * myScreenSection;
+ Bool claimed;
+ int dacSpeeds[MAXDACSPEEDS];
+ int numclocks;
+ int clock[MAXCLOCKS];
+ char * clockchip;
+ char * busID;
+ Bool active;
+ Bool inUse;
+ int videoRam;
+ int textClockFreq;
+ unsigned long BiosBase; /* Base address of video BIOS */
+ unsigned long MemBase; /* Frame buffer base address */
+ unsigned long IOBase;
+ int chipID;
+ int chipRev;
+ pointer options;
+ int irq;
+ int screen; /* For multi-CRTC cards */
+} GDevRec, *GDevPtr;
+
+typedef struct {
+ int frameX0;
+ int frameY0;
+ int virtualX;
+ int virtualY;
+ int depth;
+ int fbbpp;
+ rgb weight;
+ rgb blackColour;
+ rgb whiteColour;
+ int defaultVisual;
+ char ** modes;
+ pointer options;
+} DispRec, *DispPtr;
+
+typedef struct _confxvportrec {
+ char * identifier;
+ pointer options;
+} confXvPortRec, *confXvPortPtr;
+
+typedef struct _confxvadaptrec {
+ char * identifier;
+ int numports;
+ confXvPortPtr ports;
+ pointer options;
+} confXvAdaptorRec, *confXvAdaptorPtr;
+
+typedef struct _confscreenrec {
+ char * id;
+ int screennum;
+ int defaultdepth;
+ int defaultbpp;
+ int defaultfbbpp;
+ MonPtr monitor;
+ GDevPtr device;
+ int numdisplays;
+ DispPtr displays;
+ int numxvadaptors;
+ confXvAdaptorPtr xvadaptors;
+ pointer options;
+} confScreenRec, *confScreenPtr;
+
+typedef enum {
+ PosObsolete = -1,
+ PosAbsolute = 0,
+ PosRightOf,
+ PosLeftOf,
+ PosAbove,
+ PosBelow,
+ PosRelative
+} PositionType;
+
+typedef struct _screenlayoutrec {
+ confScreenPtr screen;
+ char * topname;
+ confScreenPtr top;
+ char * bottomname;
+ confScreenPtr bottom;
+ char * leftname;
+ confScreenPtr left;
+ char * rightname;
+ confScreenPtr right;
+ PositionType where;
+ int x;
+ int y;
+ char * refname;
+ confScreenPtr refscreen;
+} screenLayoutRec, *screenLayoutPtr;
+
+typedef struct _InputInfoRec InputInfoRec;
+
+typedef struct _serverlayoutrec {
+ char * id;
+ screenLayoutPtr screens;
+ GDevPtr inactives;
+ InputInfoRec** inputs; /* NULL terminated */
+ pointer options;
+} serverLayoutRec, *serverLayoutPtr;
+
+typedef struct _confdribufferrec {
+ int count;
+ int size;
+ enum {
+ XF86DRI_WC_HINT = 0x0001 /* Placeholder: not implemented */
+ } flags;
+} confDRIBufferRec, *confDRIBufferPtr;
+
+typedef struct _confdrirec {
+ int group;
+ int mode;
+ int bufs_count;
+ confDRIBufferRec *bufs;
+} confDRIRec, *confDRIPtr;
+
+/* These values should be adjusted when new fields are added to ScrnInfoRec */
+#define NUM_RESERVED_INTS 16
+#define NUM_RESERVED_POINTERS 14
+#define NUM_RESERVED_FUNCS 10
+
+typedef pointer (*funcPointer)(void);
+
+/* flags for depth 24 pixmap options */
+typedef enum {
+ Pix24DontCare = 0,
+ Pix24Use24,
+ Pix24Use32
+} Pix24Flags;
+
+/* Power management events: so far we only support APM */
+
+typedef enum {
+ XF86_APM_UNKNOWN = -1,
+ XF86_APM_SYS_STANDBY,
+ XF86_APM_SYS_SUSPEND,
+ XF86_APM_CRITICAL_SUSPEND,
+ XF86_APM_USER_STANDBY,
+ XF86_APM_USER_SUSPEND,
+ XF86_APM_STANDBY_RESUME,
+ XF86_APM_NORMAL_RESUME,
+ XF86_APM_CRITICAL_RESUME,
+ XF86_APM_LOW_BATTERY,
+ XF86_APM_POWER_STATUS_CHANGE,
+ XF86_APM_UPDATE_TIME,
+ XF86_APM_CAPABILITY_CHANGED,
+ XF86_APM_STANDBY_FAILED,
+ XF86_APM_SUSPEND_FAILED
+} pmEvent;
+
+typedef enum {
+ PM_WAIT,
+ PM_CONTINUE,
+ PM_FAILED,
+ PM_NONE
+} pmWait;
+
+typedef struct _PciChipsets {
+ /**
+ * Key used to match this device with its name in an array of
+ * \c SymTabRec.
+ */
+ int numChipset;
+
+ /**
+ * This value is quirky. Depending on the driver, it can take on one of
+ * three meanings. In drivers that have exactly one vendor ID (e.g.,
+ * radeon, mga, i810) the low 16-bits are the device ID.
+ *
+ * In drivers that can have multiple vendor IDs (e.g., the glint driver
+ * can have either 3dlabs' ID or TI's ID, the i740 driver can have either
+ * Intel's ID or Real3D's ID, etc.) the low 16-bits are the device ID and
+ * the high 16-bits are the vendor ID.
+ *
+ * In drivers that don't have a specific vendor (e.g., vga) contains the
+ * device ID for either the generic VGA or generic 8514 devices. This
+ * turns out to be the same as the subclass and programming interface
+ * value (e.g., the full 24-bit class for the VGA device is 0x030000 (or
+ * 0x000101) and for 8514 is 0x030001).
+ */
+ int PCIid;
+
+/* dummy place holders for drivers to build against old/new servers */
+#define RES_UNDEFINED NULL
+#define RES_EXCLUSIVE_VGA NULL
+#define RES_SHARED_VGA NULL
+ void *dummy;
+} PciChipsets;
+
+
+/* Entity properties */
+typedef void (*EntityProc)(int entityIndex,pointer private);
+
+typedef struct _entityInfo {
+ int index;
+ BusRec location;
+ int chipset;
+ Bool active;
+ GDevPtr device;
+ DriverPtr driver;
+} EntityInfoRec, *EntityInfoPtr;
+
+/* DGA */
+
+typedef struct {
+ int num; /* A unique identifier for the mode (num > 0) */
+ DisplayModePtr mode;
+ int flags; /* DGA_CONCURRENT_ACCESS, etc... */
+ int imageWidth; /* linear accessible portion (pixels) */
+ int imageHeight;
+ int pixmapWidth; /* Xlib accessible portion (pixels) */
+ int pixmapHeight; /* both fields ignored if no concurrent access */
+ int bytesPerScanline;
+ int byteOrder; /* MSBFirst, LSBFirst */
+ int depth;
+ int bitsPerPixel;
+ unsigned long red_mask;
+ unsigned long green_mask;
+ unsigned long blue_mask;
+ short visualClass;
+ int viewportWidth;
+ int viewportHeight;
+ int xViewportStep; /* viewport position granularity */
+ int yViewportStep;
+ int maxViewportX; /* max viewport origin */
+ int maxViewportY;
+ int viewportFlags; /* types of page flipping possible */
+ int offset; /* offset into physical memory */
+ unsigned char *address; /* server's mapped framebuffer */
+ int reserved1;
+ int reserved2;
+} DGAModeRec, *DGAModePtr;
+
+typedef struct {
+ DGAModePtr mode;
+ PixmapPtr pPix;
+} DGADeviceRec, *DGADevicePtr;
+
+/*
+ * Flags for driver Probe() functions.
+ */
+#define PROBE_DEFAULT 0x00
+#define PROBE_DETECT 0x01
+#define PROBE_TRYHARD 0x02
+
+/*
+ * Driver entry point types
+ */
+
+typedef Bool xf86ProbeProc (DriverPtr, int);
+typedef Bool xf86PreInitProc (ScrnInfoPtr, int);
+typedef Bool xf86ScreenInitProc (int, ScreenPtr, int, char**);
+typedef Bool xf86SwitchModeProc (int, DisplayModePtr, int);
+typedef void xf86AdjustFrameProc (int, int, int, int);
+typedef Bool xf86EnterVTProc (int, int);
+typedef void xf86LeaveVTProc (int, int);
+typedef void xf86FreeScreenProc (int, int);
+typedef ModeStatus xf86ValidModeProc (int, DisplayModePtr, Bool, int);
+typedef void xf86EnableDisableFBAccessProc(int, Bool);
+typedef int xf86SetDGAModeProc (int, int, DGADevicePtr);
+typedef int xf86ChangeGammaProc (int, Gamma);
+typedef void xf86PointerMovedProc (int, int, int);
+typedef Bool xf86PMEventProc (int, pmEvent, Bool);
+typedef void xf86DPMSSetProc (ScrnInfoPtr, int, int);
+typedef void xf86LoadPaletteProc (ScrnInfoPtr, int, int *, LOCO *, VisualPtr);
+typedef void xf86SetOverscanProc (ScrnInfoPtr, int);
+typedef void xf86ModeSetProc (ScrnInfoPtr);
+
+
+/*
+ * ScrnInfoRec
+ *
+ * There is one of these for each screen, and it holds all the screen-specific
+ * information.
+ *
+ * Note: the size and layout must be kept the same across versions. New
+ * fields are to be added in place of the "reserved*" fields. No fields
+ * are to be dependent on compile-time defines.
+ */
+
+
+typedef struct _ScrnInfoRec {
+ int driverVersion;
+ char * driverName; /* canonical name used in */
+ /* the config file */
+ ScreenPtr pScreen; /* Pointer to the ScreenRec */
+ int scrnIndex; /* Number of this screen */
+ Bool configured; /* Is this screen valid */
+ int origIndex; /* initial number assigned to
+ * this screen before
+ * finalising the number of
+ * available screens */
+
+ /* Display-wide screenInfo values needed by this screen */
+ int imageByteOrder;
+ int bitmapScanlineUnit;
+ int bitmapScanlinePad;
+ int bitmapBitOrder;
+ int numFormats;
+ PixmapFormatRec formats[MAXFORMATS];
+ PixmapFormatRec fbFormat;
+
+ int bitsPerPixel; /* fb bpp */
+ Pix24Flags pixmap24; /* pixmap pref for depth 24 */
+ int depth; /* depth of default visual */
+ MessageType depthFrom; /* set from config? */
+ MessageType bitsPerPixelFrom; /* set from config? */
+ rgb weight; /* r/g/b weights */
+ rgb mask; /* rgb masks */
+ rgb offset; /* rgb offsets */
+ int rgbBits; /* Number of bits in r/g/b */
+ Gamma gamma; /* Gamma of the monitor */
+ int defaultVisual; /* default visual class */
+ int maxHValue; /* max horizontal timing */
+ int maxVValue; /* max vertical timing value */
+ int virtualX; /* Virtual width */
+ int virtualY; /* Virtual height */
+ int xInc; /* Horizontal timing increment */
+ MessageType virtualFrom; /* set from config? */
+ int displayWidth; /* memory pitch */
+ int frameX0; /* viewport position */
+ int frameY0;
+ int frameX1;
+ int frameY1;
+ int zoomLocked; /* Disallow mode changes */
+ DisplayModePtr modePool; /* list of compatible modes */
+ DisplayModePtr modes; /* list of actual modes */
+ DisplayModePtr currentMode; /* current mode
+ * This was previously
+ * overloaded with the modes
+ * field, which is a pointer
+ * into a circular list */
+ confScreenPtr confScreen; /* Screen config info */
+ MonPtr monitor; /* Monitor information */
+ DispPtr display; /* Display information */
+ int * entityList; /* List of device entities */
+ int numEntities;
+ int widthmm; /* physical display dimensions
+ * in mm */
+ int heightmm;
+ int xDpi; /* width DPI */
+ int yDpi; /* height DPI */
+ char * name; /* Name to prefix messages */
+ pointer driverPrivate; /* Driver private area */
+ DevUnion * privates; /* Other privates can hook in
+ * here */
+ DriverPtr drv; /* xf86DriverList[] entry */
+ pointer module; /* Pointer to module head */
+ int colorKey;
+ int overlayFlags;
+
+ /* Some of these may be moved out of here into the driver private area */
+
+ char * chipset; /* chipset name */
+ char * ramdac; /* ramdac name */
+ char * clockchip; /* clock name */
+ Bool progClock; /* clock is programmable */
+ int numClocks; /* number of clocks */
+ int clock[MAXCLOCKS]; /* list of clock frequencies */
+ int videoRam; /* amount of video ram (kb) */
+ 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 */
+ pointer options;
+
+ int chipID;
+ int chipRev;
+
+ /* Allow screens to be enabled/disabled individually */
+ Bool vtSema;
+
+ /* hw cursor moves at SIGIO time */
+ Bool silkenMouse;
+
+ /* Storage for clockRanges and adjustFlags for use with the VidMode ext */
+ ClockRangePtr clockRanges;
+ int adjustFlags;
+
+ /*
+ * These can be used when the minor ABI version is incremented.
+ * The NUM_* parameters must be reduced appropriately to keep the
+ * structure size and alignment unchanged.
+ */
+ int reservedInt[NUM_RESERVED_INTS];
+
+ int * entityInstanceList;
+ struct pci_device *vgaDev;
+
+ pointer reservedPtr[NUM_RESERVED_POINTERS];
+
+ /*
+ * Driver entry points.
+ *
+ */
+
+ xf86ProbeProc *Probe;
+ xf86PreInitProc *PreInit;
+ xf86ScreenInitProc *ScreenInit;
+ xf86SwitchModeProc *SwitchMode;
+ xf86AdjustFrameProc *AdjustFrame;
+ xf86EnterVTProc *EnterVT;
+ xf86LeaveVTProc *LeaveVT;
+ xf86FreeScreenProc *FreeScreen;
+ xf86ValidModeProc *ValidMode;
+ xf86EnableDisableFBAccessProc *EnableDisableFBAccess;
+ xf86SetDGAModeProc *SetDGAMode;
+ xf86ChangeGammaProc *ChangeGamma;
+ xf86PointerMovedProc *PointerMoved;
+ xf86PMEventProc *PMEvent;
+ xf86DPMSSetProc *DPMSSet;
+ xf86LoadPaletteProc *LoadPalette;
+ xf86SetOverscanProc *SetOverscan;
+ xorgDriverFuncProc *DriverFunc;
+ xf86ModeSetProc *ModeSet;
+
+ /*
+ * This can be used when the minor ABI version is incremented.
+ * The NUM_* parameter must be reduced appropriately to keep the
+ * structure size and alignment unchanged.
+ */
+ funcPointer reservedFuncs[NUM_RESERVED_FUNCS];
+
+} ScrnInfoRec;
+
+
+typedef struct {
+ Bool (*OpenFramebuffer)(
+ ScrnInfoPtr pScrn,
+ char **name,
+ unsigned char **mem,
+ int *size,
+ int *offset,
+ int *extra
+ );
+ void (*CloseFramebuffer)(ScrnInfoPtr pScrn);
+ Bool (*SetMode)(ScrnInfoPtr pScrn, DGAModePtr pMode);
+ void (*SetViewport)(ScrnInfoPtr pScrn, int x, int y, int flags);
+ int (*GetViewport)(ScrnInfoPtr pScrn);
+ void (*Sync)(ScrnInfoPtr);
+ void (*FillRect)(
+ ScrnInfoPtr pScrn,
+ int x, int y, int w, int h,
+ unsigned long color
+ );
+ void (*BlitRect)(
+ ScrnInfoPtr pScrn,
+ int srcx, int srcy,
+ int w, int h,
+ int dstx, int dsty
+ );
+ void (*BlitTransRect)(
+ ScrnInfoPtr pScrn,
+ int srcx, int srcy,
+ int w, int h,
+ int dstx, int dsty,
+ unsigned long color
+ );
+} DGAFunctionRec, *DGAFunctionPtr;
+
+typedef struct _SymTabRec {
+ int token; /* id of the token */
+ const char * name; /* token name */
+} SymTabRec, *SymTabPtr;
+
+/* flags for xf86LookupMode */
+typedef enum {
+ LOOKUP_DEFAULT = 0, /* Use default mode lookup method */
+ LOOKUP_BEST_REFRESH, /* Pick modes with best refresh */
+ LOOKUP_CLOSEST_CLOCK, /* Pick modes with the closest clock */
+ LOOKUP_LIST_ORDER, /* Pick first useful mode in list */
+ LOOKUP_CLKDIV2 = 0x0100, /* Allow half clocks */
+ LOOKUP_OPTIONAL_TOLERANCES = 0x0200 /* Allow missing hsync/vrefresh */
+} LookupModeFlags;
+
+#define NoDepth24Support 0x00
+#define Support24bppFb 0x01 /* 24bpp framebuffer supported */
+#define Support32bppFb 0x02 /* 32bpp framebuffer supported */
+#define SupportConvert24to32 0x04 /* Can convert 24bpp pixmap to 32bpp */
+#define SupportConvert32to24 0x08 /* Can convert 32bpp pixmap to 24bpp */
+#define PreferConvert24to32 0x10 /* prefer 24bpp pixmap to 32bpp conv */
+#define PreferConvert32to24 0x20 /* prefer 32bpp pixmap to 24bpp conv */
+
+
+/* For DPMS */
+typedef void (*DPMSSetProcPtr)(ScrnInfoPtr, int, int);
+
+/* Input handler proc */
+typedef void (*InputHandlerProc)(int fd, pointer data);
+
+/* These are used by xf86GetClocks */
+#define CLK_REG_SAVE -1
+#define CLK_REG_RESTORE -2
+
+/*
+ * misc constants
+ */
+#define INTERLACE_REFRESH_WEIGHT 1.5
+#define SYNC_TOLERANCE 0.01 /* 1 percent */
+#define CLOCK_TOLERANCE 2000 /* Clock matching tolerance (2MHz) */
+
+
+#define OVERLAY_8_32_DUALFB 0x00000001
+#define OVERLAY_8_24_DUALFB 0x00000002
+#define OVERLAY_8_16_DUALFB 0x00000004
+#define OVERLAY_8_32_PLANAR 0x00000008
+
+/* Values of xf86Info.mouseFlags */
+#define MF_CLEAR_DTR 1
+#define MF_CLEAR_RTS 2
+
+/* Action Events */
+typedef enum {
+ ACTION_TERMINATE = 0, /* Terminate Server */
+ ACTION_NEXT_MODE = 10, /* Switch to next video mode */
+ ACTION_PREV_MODE,
+ ACTION_SWITCHSCREEN = 100, /* VT switch */
+ ACTION_SWITCHSCREEN_NEXT,
+ ACTION_SWITCHSCREEN_PREV,
+} ActionEvent;
+
+#endif /* _XF86STR_H */
diff --git a/xorg-server/hw/xfree86/ddc/ddc.c b/xorg-server/hw/xfree86/ddc/ddc.c
index e9b8a52eb..179f42ccd 100644
--- a/xorg-server/hw/xfree86/ddc/ddc.c
+++ b/xorg-server/hw/xfree86/ddc/ddc.c
@@ -1,506 +1,503 @@
-/* xf86DDC.c
- *
- * Copyright 1998,1999 by Egbert Eich <Egbert.Eich@Physik.TU-Darmstadt.DE>
- */
-
-/*
- * A note on terminology. DDC1 is the original dumb serial protocol, and
- * can only do up to 128 bytes of EDID. DDC2 is I2C-encapsulated and
- * introduces extension blocks. EDID is the old display identification
- * block, DisplayID is the new one.
- */
-
-#ifdef HAVE_XORG_CONFIG_H
-#include <xorg-config.h>
-#endif
-
-#include "misc.h"
-#include "xf86.h"
-#include "xf86_OSproc.h"
-#include "xf86DDC.h"
-#include <string.h>
-
-#define RETRIES 4
-
-typedef enum {
- DDCOPT_NODDC1,
- DDCOPT_NODDC2,
- DDCOPT_NODDC
-} DDCOpts;
-
-static const OptionInfoRec DDCOptions[] = {
- { DDCOPT_NODDC1, "NoDDC1", OPTV_BOOLEAN, {0}, FALSE },
- { DDCOPT_NODDC2, "NoDDC2", OPTV_BOOLEAN, {0}, FALSE },
- { DDCOPT_NODDC, "NoDDC", OPTV_BOOLEAN, {0}, FALSE },
- { -1, NULL, OPTV_NONE, {0}, FALSE },
-};
-
-/* DDC1 */
-
-static int
-find_start(unsigned int *ptr)
-{
- unsigned int comp[9], test[9];
- int i,j;
-
- for (i=0;i<9;i++){
- comp[i] = *(ptr++);
- test[i] = 1;
- }
- for (i=0;i<127;i++){
- for (j=0;j<9;j++){
- test[j] = test[j] & !(comp[j] ^ *(ptr++));
- }
- }
- for (i=0;i<9;i++)
- if (test[i]) return i+1;
- return -1;
-}
-
-static unsigned char *
-find_header(unsigned char *block)
-{
- unsigned char *ptr, *head_ptr, *end;
- unsigned char header[]={0x00, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x00};
-
- ptr = block;
- end = block + EDID1_LEN;
- while (ptr<end) {
- int i;
- head_ptr = ptr;
- for (i=0;i<8;i++){
- if (header[i] != *(head_ptr++)) break;
- if (head_ptr == end) head_ptr = block;
- }
- if (i==8) break;
- ptr++;
- }
- if (ptr == end) return NULL;
- return ptr;
-}
-
-static unsigned char *
-resort(unsigned char *s_block)
-{
- unsigned char *d_new, *d_ptr, *d_end, *s_ptr, *s_end;
- unsigned char tmp;
-
- s_end = s_block + EDID1_LEN;
- d_new = malloc(EDID1_LEN);
- if (!d_new) return NULL;
- d_end = d_new + EDID1_LEN;
-
- s_ptr = find_header(s_block);
- if (!s_ptr) return NULL;
- for (d_ptr=d_new;d_ptr<d_end;d_ptr++){
- tmp = *(s_ptr++);
- *d_ptr = tmp;
- if (s_ptr == s_end) s_ptr = s_block;
- }
- free(s_block);
- return d_new;
-}
-
-static int
-DDC_checksum(const unsigned char *block, int len)
-{
- int i, result = 0;
- int not_null = 0;
-
- for (i=0;i<len;i++) {
- not_null |= block[i];
- result += block[i];
- }
-
-#ifdef DEBUG
- if (result & 0xFF) ErrorF("DDC checksum not correct\n");
- if (!not_null) ErrorF("DDC read all Null\n");
-#endif
-
- /* catch the trivial case where all bytes are 0 */
- if (!not_null) return 1;
-
- return result&0xFF;
-}
-
-static unsigned char *
-GetEDID_DDC1(unsigned int *s_ptr)
-{
- unsigned char *d_block, *d_pos;
- unsigned int *s_pos, *s_end;
- int s_start;
- int i,j;
- s_start = find_start(s_ptr);
- if (s_start==-1) return NULL;
- s_end = s_ptr + NUM;
- s_pos = s_ptr + s_start;
- d_block=malloc(EDID1_LEN);
- if (!d_block) return NULL;
- d_pos = d_block;
- for (i=0;i<EDID1_LEN;i++) {
- for (j=0;j<8;j++) {
- *d_pos <<= 1;
- if (*s_pos) {
- *d_pos |= 0x01;
- }
- s_pos++; if (s_pos == s_end) s_pos=s_ptr;
- };
- s_pos++; if (s_pos == s_end) s_pos=s_ptr;
- d_pos++;
- }
- free(s_ptr);
- if (d_block && DDC_checksum(d_block,EDID1_LEN)) {
- free(d_block);
- return NULL;
- }
- return (resort(d_block));
-}
-
-/* fetch entire EDID record; DDC bit needs to be masked */
-static unsigned int *
-FetchEDID_DDC1(register ScrnInfoPtr pScrn,
- register unsigned int (*read_DDC)(ScrnInfoPtr))
-{
- int count = NUM;
- unsigned int *ptr, *xp;
-
- ptr=xp=malloc(sizeof(int)*NUM);
-
- if (!ptr) return NULL;
- do {
- /* wait for next retrace */
- *xp = read_DDC(pScrn);
- xp++;
- } while(--count);
- return ptr;
-}
-
-/* test if DDC1 return 0 if not */
-static Bool
-TestDDC1(ScrnInfoPtr pScrn, unsigned int (*read_DDC)(ScrnInfoPtr))
-{
- int old, count;
-
- old = read_DDC(pScrn);
- count = HEADER * BITS_PER_BYTE;
- do {
- /* wait for next retrace */
- if (old != read_DDC(pScrn)) break;
- } while(count--);
- return count;
-}
-
-/*
- * read EDID record , pass it to callback function to interpret.
- * callback function will store it for further use by calling
- * function; it will also decide if we need to reread it
- */
-static unsigned char *
-EDIDRead_DDC1(ScrnInfoPtr pScrn, DDC1SetSpeedProc DDCSpeed,
- unsigned int (*read_DDC)(ScrnInfoPtr))
-{
- unsigned char *EDID_block = NULL;
- int count = RETRIES;
-
- if (!read_DDC) {
- xf86DrvMsg(pScrn->scrnIndex, X_PROBED,
- "chipset doesn't support DDC1\n");
- return NULL;
- };
-
- if (TestDDC1(pScrn,read_DDC)==-1) {
- xf86DrvMsg(pScrn->scrnIndex, X_PROBED, "No DDC signal\n");
- return NULL;
- };
-
- if (DDCSpeed) DDCSpeed(pScrn,DDC_FAST);
- do {
- EDID_block = GetEDID_DDC1(FetchEDID_DDC1(pScrn,read_DDC));
- count --;
- } while (!EDID_block && count);
- if (DDCSpeed) DDCSpeed(pScrn,DDC_SLOW);
-
- return EDID_block;
-}
-
-/**
- * Attempts to probe the monitor for EDID information, if NoDDC and NoDDC1 are
- * unset. EDID information blocks are interpreted and the results returned in
- * an xf86MonPtr.
- *
- * This function does not affect the list of modes used by drivers -- it is up
- * to the driver to decide policy on what to do with EDID information.
- *
- * @return pointer to a new xf86MonPtr containing the EDID information.
- * @return NULL if no monitor attached or failure to interpret the EDID.
- */
-xf86MonPtr
-xf86DoEDID_DDC1(
- int scrnIndex, DDC1SetSpeedProc DDC1SetSpeed,
- unsigned int (*DDC1Read)(ScrnInfoPtr)
-)
-{
- ScrnInfoPtr pScrn = xf86Screens[scrnIndex];
- unsigned char *EDID_block = NULL;
- xf86MonPtr tmp = NULL;
- int sigio;
- /* Default DDC and DDC1 to enabled. */
- Bool noddc = FALSE, noddc1 = FALSE;
- OptionInfoPtr options;
-
- options = xnfalloc(sizeof(DDCOptions));
- (void)memcpy(options, DDCOptions, sizeof(DDCOptions));
- xf86ProcessOptions(pScrn->scrnIndex, pScrn->options, options);
-
- xf86GetOptValBool(options, DDCOPT_NODDC, &noddc);
- xf86GetOptValBool(options, DDCOPT_NODDC1, &noddc1);
- free(options);
-
- if (noddc || noddc1)
- return NULL;
-
- sigio = xf86BlockSIGIO();
- EDID_block = EDIDRead_DDC1(pScrn,DDC1SetSpeed,DDC1Read);
- xf86UnblockSIGIO(sigio);
-
- if (EDID_block){
- tmp = xf86InterpretEDID(scrnIndex,EDID_block);
- }
-#ifdef DEBUG
- else ErrorF("No EDID block returned\n");
- if (!tmp)
- ErrorF("Cannot interpret EDID block\n");
-#endif
- return tmp;
-}
-
-/* DDC2 */
-
-static I2CDevPtr
-DDC2MakeDevice(I2CBusPtr pBus, int address, char *name)
-{
- I2CDevPtr dev = NULL;
-
- if (!(dev = xf86I2CFindDev(pBus, address))) {
- dev = xf86CreateI2CDevRec();
- dev->DevName = name;
- dev->SlaveAddr = address;
- dev->ByteTimeout = 2200; /* VESA DDC spec 3 p. 43 (+10 %) */
- dev->StartTimeout = 550;
- dev->BitTimeout = 40;
- dev->AcknTimeout = 40;
-
- dev->pI2CBus = pBus;
- if (!xf86I2CDevInit(dev)) {
- xf86DrvMsg(pBus->scrnIndex, X_PROBED, "No DDC2 device\n");
- return NULL;
- }
- }
-
- return dev;
-}
-
-static I2CDevPtr
-DDC2Init(int scrnIndex, I2CBusPtr pBus)
-{
- I2CDevPtr dev = NULL;
-
- /*
- * Slow down the bus so that older monitors don't
- * miss things.
- */
- pBus->RiseFallTime = 20;
-
- dev = DDC2MakeDevice(pBus, 0x00A0, "ddc2");
- if (xf86I2CProbeAddress(pBus, 0x0060))
- DDC2MakeDevice(pBus, 0x0060, "E-EDID segment register");
-
- return dev;
-}
-
-/* Mmmm, smell the hacks */
-static void
-EEDIDStop(I2CDevPtr d)
-{
-}
-
-/* block is the EDID block number. a segment is two blocks. */
-static Bool
-DDC2Read(I2CDevPtr dev, int block, unsigned char *R_Buffer)
-{
- unsigned char W_Buffer[1];
- int i, segment;
- I2CDevPtr seg;
- void (*stop)(I2CDevPtr);
-
- for (i = 0; i < RETRIES; i++) {
- /* Stop bits reset the segment pointer to 0, so be careful here. */
- segment = block >> 1;
- if (segment) {
- Bool b;
-
- if (!(seg = xf86I2CFindDev(dev->pI2CBus, 0x0060)))
- return FALSE;
-
- W_Buffer[0] = segment;
-
- stop = dev->pI2CBus->I2CStop;
- dev->pI2CBus->I2CStop = EEDIDStop;
-
- b = xf86I2CWriteRead(seg, W_Buffer, 1, NULL, 0);
-
- dev->pI2CBus->I2CStop = stop;
- if (!b) {
- dev->pI2CBus->I2CStop(dev);
- continue;
- }
- }
-
- W_Buffer[0] = (block & 0x01) * EDID1_LEN;
-
- if (xf86I2CWriteRead(dev, W_Buffer, 1, R_Buffer, EDID1_LEN)) {
- if (!DDC_checksum(R_Buffer, EDID1_LEN))
- return TRUE;
- }
- }
-
- return FALSE;
-}
-
-/**
- * Attempts to probe the monitor for EDID information, if NoDDC and NoDDC2 are
- * unset. EDID information blocks are interpreted and the results returned in
- * an xf86MonPtr. Unlike xf86DoEDID_DDC[12](), this function will return
- * the complete EDID data, including all extension blocks, if the 'complete'
- * parameter is TRUE;
- *
- * This function does not affect the list of modes used by drivers -- it is up
- * to the driver to decide policy on what to do with EDID information.
- *
- * @return pointer to a new xf86MonPtr containing the EDID information.
- * @return NULL if no monitor attached or failure to interpret the EDID.
- */
-xf86MonPtr
-xf86DoEEDID(int scrnIndex, I2CBusPtr pBus, Bool complete)
-{
- ScrnInfoPtr pScrn = xf86Screens[scrnIndex];
- unsigned char *EDID_block = NULL;
- xf86MonPtr tmp = NULL;
- I2CDevPtr dev = NULL;
- /* Default DDC and DDC2 to enabled. */
- Bool noddc = FALSE, noddc2 = FALSE;
- OptionInfoPtr options;
-
- options = malloc(sizeof(DDCOptions));
- if (!options)
- return NULL;
- memcpy(options, DDCOptions, sizeof(DDCOptions));
- xf86ProcessOptions(pScrn->scrnIndex, pScrn->options, options);
-
- xf86GetOptValBool(options, DDCOPT_NODDC, &noddc);
- xf86GetOptValBool(options, DDCOPT_NODDC2, &noddc2);
- free(options);
-
- if (noddc || noddc2)
- return NULL;
-
- if (!(dev = DDC2Init(scrnIndex, pBus)))
- return NULL;
-
- EDID_block = calloc(1, EDID1_LEN);
- if (!EDID_block)
- return NULL;
-
- if (DDC2Read(dev, 0, EDID_block)) {
- int i, n = EDID_block[0x7e];
-
- if (complete && n) {
- EDID_block = realloc(EDID_block, EDID1_LEN * (1+n));
-
- for (i = 0; i < n; i++)
- DDC2Read(dev, i+1, EDID_block + (EDID1_LEN * (1+i)));
- }
-
- tmp = xf86InterpretEEDID(scrnIndex, EDID_block);
- }
-
- if (tmp && complete)
- tmp->flags |= MONITOR_EDID_COMPLETE_RAWDATA;
-
- return tmp;
-}
-
-/**
- * Attempts to probe the monitor for EDID information, if NoDDC and NoDDC2 are
- * unset. EDID information blocks are interpreted and the results returned in
- * an xf86MonPtr.
- *
- * This function does not affect the list of modes used by drivers -- it is up
- * to the driver to decide policy on what to do with EDID information.
- *
- * @return pointer to a new xf86MonPtr containing the EDID information.
- * @return NULL if no monitor attached or failure to interpret the EDID.
- */
-xf86MonPtr
-xf86DoEDID_DDC2(int scrnIndex, I2CBusPtr pBus)
-{
- return xf86DoEEDID(scrnIndex, pBus, FALSE);
-}
-
-/* XXX write me */
-static void *
-DDC2ReadDisplayID(void)
-{
- return FALSE;
-}
-
-/**
- * Attempts to probe the monitor for DisplayID information, if NoDDC and
- * NoDDC2 are unset. DisplayID blocks are interpreted and the results
- * returned in an xf86MonPtr.
- *
- * This function does not affect the list of modes used by drivers -- it is up
- * to the driver to decide policy on what to do with DisplayID information.
- *
- * @return pointer to a new xf86MonPtr containing the DisplayID information.
- * @return NULL if no monitor attached or failure to interpret the DisplayID.
- */
-xf86MonPtr
-xf86DoDisplayID(int scrnIndex, I2CBusPtr pBus)
-{
- ScrnInfoPtr pScrn = xf86Screens[scrnIndex];
- unsigned char *did = NULL;
- xf86MonPtr tmp = NULL;
- I2CDevPtr dev = NULL;
- /* Default DDC and DDC2 to enabled. */
- Bool noddc = FALSE, noddc2 = FALSE;
- OptionInfoPtr options;
-
- options = malloc(sizeof(DDCOptions));
- if (!options)
- return NULL;
- memcpy(options, DDCOptions, sizeof(DDCOptions));
- xf86ProcessOptions(pScrn->scrnIndex, pScrn->options, options);
-
- xf86GetOptValBool(options, DDCOPT_NODDC, &noddc);
- xf86GetOptValBool(options, DDCOPT_NODDC2, &noddc2);
- free(options);
-
- if (noddc || noddc2)
- return NULL;
-
- if (!(dev = DDC2Init(scrnIndex, pBus)))
- return NULL;
-
- if ((did = DDC2ReadDisplayID())) {
- tmp = calloc(1, sizeof(*tmp));
- if (!tmp)
- return NULL;
-
- tmp->scrnIndex = scrnIndex;
- tmp->flags |= MONITOR_DISPLAYID;
- tmp->rawData = did;
- }
-
- return tmp;
-}
+/* xf86DDC.c
+ *
+ * Copyright 1998,1999 by Egbert Eich <Egbert.Eich@Physik.TU-Darmstadt.DE>
+ */
+
+/*
+ * A note on terminology. DDC1 is the original dumb serial protocol, and
+ * can only do up to 128 bytes of EDID. DDC2 is I2C-encapsulated and
+ * introduces extension blocks. EDID is the old display identification
+ * block, DisplayID is the new one.
+ */
+
+#ifdef HAVE_XORG_CONFIG_H
+#include <xorg-config.h>
+#endif
+
+#include "misc.h"
+#include "xf86.h"
+#include "xf86_OSproc.h"
+#include "xf86DDC.h"
+#include <string.h>
+
+#define RETRIES 4
+
+typedef enum {
+ DDCOPT_NODDC1,
+ DDCOPT_NODDC2,
+ DDCOPT_NODDC
+} DDCOpts;
+
+static const OptionInfoRec DDCOptions[] = {
+ { DDCOPT_NODDC1, "NoDDC1", OPTV_BOOLEAN, {0}, FALSE },
+ { DDCOPT_NODDC2, "NoDDC2", OPTV_BOOLEAN, {0}, FALSE },
+ { DDCOPT_NODDC, "NoDDC", OPTV_BOOLEAN, {0}, FALSE },
+ { -1, NULL, OPTV_NONE, {0}, FALSE },
+};
+
+/* DDC1 */
+
+static int
+find_start(unsigned int *ptr)
+{
+ unsigned int comp[9], test[9];
+ int i,j;
+
+ for (i=0;i<9;i++){
+ comp[i] = *(ptr++);
+ test[i] = 1;
+ }
+ for (i=0;i<127;i++){
+ for (j=0;j<9;j++){
+ test[j] = test[j] & !(comp[j] ^ *(ptr++));
+ }
+ }
+ for (i=0;i<9;i++)
+ if (test[i]) return i+1;
+ return -1;
+}
+
+static unsigned char *
+find_header(unsigned char *block)
+{
+ unsigned char *ptr, *head_ptr, *end;
+ unsigned char header[]={0x00, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x00};
+
+ ptr = block;
+ end = block + EDID1_LEN;
+ while (ptr<end) {
+ int i;
+ head_ptr = ptr;
+ for (i=0;i<8;i++){
+ if (header[i] != *(head_ptr++)) break;
+ if (head_ptr == end) head_ptr = block;
+ }
+ if (i==8) break;
+ ptr++;
+ }
+ if (ptr == end) return NULL;
+ return ptr;
+}
+
+static unsigned char *
+resort(unsigned char *s_block)
+{
+ unsigned char *d_new, *d_ptr, *d_end, *s_ptr, *s_end;
+ unsigned char tmp;
+
+ s_end = s_block + EDID1_LEN;
+ d_new = malloc(EDID1_LEN);
+ if (!d_new) return NULL;
+ d_end = d_new + EDID1_LEN;
+
+ s_ptr = find_header(s_block);
+ if (!s_ptr) return NULL;
+ for (d_ptr=d_new;d_ptr<d_end;d_ptr++){
+ tmp = *(s_ptr++);
+ *d_ptr = tmp;
+ if (s_ptr == s_end) s_ptr = s_block;
+ }
+ free(s_block);
+ return d_new;
+}
+
+static int
+DDC_checksum(const unsigned char *block, int len)
+{
+ int i, result = 0;
+ int not_null = 0;
+
+ for (i=0;i<len;i++) {
+ not_null |= block[i];
+ result += block[i];
+ }
+
+#ifdef DEBUG
+ if (result & 0xFF) ErrorF("DDC checksum not correct\n");
+ if (!not_null) ErrorF("DDC read all Null\n");
+#endif
+
+ /* catch the trivial case where all bytes are 0 */
+ if (!not_null) return 1;
+
+ return result&0xFF;
+}
+
+static unsigned char *
+GetEDID_DDC1(unsigned int *s_ptr)
+{
+ unsigned char *d_block, *d_pos;
+ unsigned int *s_pos, *s_end;
+ int s_start;
+ int i,j;
+ s_start = find_start(s_ptr);
+ if (s_start==-1) return NULL;
+ s_end = s_ptr + NUM;
+ s_pos = s_ptr + s_start;
+ d_block=malloc(EDID1_LEN);
+ if (!d_block) return NULL;
+ d_pos = d_block;
+ for (i=0;i<EDID1_LEN;i++) {
+ for (j=0;j<8;j++) {
+ *d_pos <<= 1;
+ if (*s_pos) {
+ *d_pos |= 0x01;
+ }
+ s_pos++; if (s_pos == s_end) s_pos=s_ptr;
+ };
+ s_pos++; if (s_pos == s_end) s_pos=s_ptr;
+ d_pos++;
+ }
+ free(s_ptr);
+ if (d_block && DDC_checksum(d_block,EDID1_LEN)) {
+ free(d_block);
+ return NULL;
+ }
+ return (resort(d_block));
+}
+
+/* fetch entire EDID record; DDC bit needs to be masked */
+static unsigned int *
+FetchEDID_DDC1(register ScrnInfoPtr pScrn,
+ register unsigned int (*read_DDC)(ScrnInfoPtr))
+{
+ int count = NUM;
+ unsigned int *ptr, *xp;
+
+ ptr=xp=malloc(sizeof(int)*NUM);
+
+ if (!ptr) return NULL;
+ do {
+ /* wait for next retrace */
+ *xp = read_DDC(pScrn);
+ xp++;
+ } while(--count);
+ return ptr;
+}
+
+/* test if DDC1 return 0 if not */
+static Bool
+TestDDC1(ScrnInfoPtr pScrn, unsigned int (*read_DDC)(ScrnInfoPtr))
+{
+ int old, count;
+
+ old = read_DDC(pScrn);
+ count = HEADER * BITS_PER_BYTE;
+ do {
+ /* wait for next retrace */
+ if (old != read_DDC(pScrn)) break;
+ } while(count--);
+ return count;
+}
+
+/*
+ * read EDID record , pass it to callback function to interpret.
+ * callback function will store it for further use by calling
+ * function; it will also decide if we need to reread it
+ */
+static unsigned char *
+EDIDRead_DDC1(ScrnInfoPtr pScrn, DDC1SetSpeedProc DDCSpeed,
+ unsigned int (*read_DDC)(ScrnInfoPtr))
+{
+ unsigned char *EDID_block = NULL;
+ int count = RETRIES;
+
+ if (!read_DDC) {
+ xf86DrvMsg(pScrn->scrnIndex, X_PROBED,
+ "chipset doesn't support DDC1\n");
+ return NULL;
+ };
+
+ if (TestDDC1(pScrn,read_DDC)==-1) {
+ xf86DrvMsg(pScrn->scrnIndex, X_PROBED, "No DDC signal\n");
+ return NULL;
+ };
+
+ if (DDCSpeed) DDCSpeed(pScrn,DDC_FAST);
+ do {
+ EDID_block = GetEDID_DDC1(FetchEDID_DDC1(pScrn,read_DDC));
+ count --;
+ } while (!EDID_block && count);
+ if (DDCSpeed) DDCSpeed(pScrn,DDC_SLOW);
+
+ return EDID_block;
+}
+
+/**
+ * Attempts to probe the monitor for EDID information, if NoDDC and NoDDC1 are
+ * unset. EDID information blocks are interpreted and the results returned in
+ * an xf86MonPtr.
+ *
+ * This function does not affect the list of modes used by drivers -- it is up
+ * to the driver to decide policy on what to do with EDID information.
+ *
+ * @return pointer to a new xf86MonPtr containing the EDID information.
+ * @return NULL if no monitor attached or failure to interpret the EDID.
+ */
+xf86MonPtr
+xf86DoEDID_DDC1(int scrnIndex, DDC1SetSpeedProc DDC1SetSpeed,
+ unsigned int (*DDC1Read)(ScrnInfoPtr))
+{
+ ScrnInfoPtr pScrn = xf86Screens[scrnIndex];
+ unsigned char *EDID_block = NULL;
+ xf86MonPtr tmp = NULL;
+ /* Default DDC and DDC1 to enabled. */
+ Bool noddc = FALSE, noddc1 = FALSE;
+ OptionInfoPtr options;
+
+ options = xnfalloc(sizeof(DDCOptions));
+ (void)memcpy(options, DDCOptions, sizeof(DDCOptions));
+ xf86ProcessOptions(pScrn->scrnIndex, pScrn->options, options);
+
+ xf86GetOptValBool(options, DDCOPT_NODDC, &noddc);
+ xf86GetOptValBool(options, DDCOPT_NODDC1, &noddc1);
+ free(options);
+
+ if (noddc || noddc1)
+ return NULL;
+
+ OsBlockSignals();
+ EDID_block = EDIDRead_DDC1(pScrn,DDC1SetSpeed,DDC1Read);
+ OsReleaseSignals();
+
+ if (EDID_block){
+ tmp = xf86InterpretEDID(scrnIndex,EDID_block);
+ }
+#ifdef DEBUG
+ else ErrorF("No EDID block returned\n");
+ if (!tmp)
+ ErrorF("Cannot interpret EDID block\n");
+#endif
+ return tmp;
+}
+
+/* DDC2 */
+
+static I2CDevPtr
+DDC2MakeDevice(I2CBusPtr pBus, int address, char *name)
+{
+ I2CDevPtr dev = NULL;
+
+ if (!(dev = xf86I2CFindDev(pBus, address))) {
+ dev = xf86CreateI2CDevRec();
+ dev->DevName = name;
+ dev->SlaveAddr = address;
+ dev->ByteTimeout = 2200; /* VESA DDC spec 3 p. 43 (+10 %) */
+ dev->StartTimeout = 550;
+ dev->BitTimeout = 40;
+ dev->AcknTimeout = 40;
+
+ dev->pI2CBus = pBus;
+ if (!xf86I2CDevInit(dev)) {
+ xf86DrvMsg(pBus->scrnIndex, X_PROBED, "No DDC2 device\n");
+ return NULL;
+ }
+ }
+
+ return dev;
+}
+
+static I2CDevPtr
+DDC2Init(int scrnIndex, I2CBusPtr pBus)
+{
+ I2CDevPtr dev = NULL;
+
+ /*
+ * Slow down the bus so that older monitors don't
+ * miss things.
+ */
+ pBus->RiseFallTime = 20;
+
+ dev = DDC2MakeDevice(pBus, 0x00A0, "ddc2");
+ if (xf86I2CProbeAddress(pBus, 0x0060))
+ DDC2MakeDevice(pBus, 0x0060, "E-EDID segment register");
+
+ return dev;
+}
+
+/* Mmmm, smell the hacks */
+static void
+EEDIDStop(I2CDevPtr d)
+{
+}
+
+/* block is the EDID block number. a segment is two blocks. */
+static Bool
+DDC2Read(I2CDevPtr dev, int block, unsigned char *R_Buffer)
+{
+ unsigned char W_Buffer[1];
+ int i, segment;
+ I2CDevPtr seg;
+ void (*stop)(I2CDevPtr);
+
+ for (i = 0; i < RETRIES; i++) {
+ /* Stop bits reset the segment pointer to 0, so be careful here. */
+ segment = block >> 1;
+ if (segment) {
+ Bool b;
+
+ if (!(seg = xf86I2CFindDev(dev->pI2CBus, 0x0060)))
+ return FALSE;
+
+ W_Buffer[0] = segment;
+
+ stop = dev->pI2CBus->I2CStop;
+ dev->pI2CBus->I2CStop = EEDIDStop;
+
+ b = xf86I2CWriteRead(seg, W_Buffer, 1, NULL, 0);
+
+ dev->pI2CBus->I2CStop = stop;
+ if (!b) {
+ dev->pI2CBus->I2CStop(dev);
+ continue;
+ }
+ }
+
+ W_Buffer[0] = (block & 0x01) * EDID1_LEN;
+
+ if (xf86I2CWriteRead(dev, W_Buffer, 1, R_Buffer, EDID1_LEN)) {
+ if (!DDC_checksum(R_Buffer, EDID1_LEN))
+ return TRUE;
+ }
+ }
+
+ return FALSE;
+}
+
+/**
+ * Attempts to probe the monitor for EDID information, if NoDDC and NoDDC2 are
+ * unset. EDID information blocks are interpreted and the results returned in
+ * an xf86MonPtr. Unlike xf86DoEDID_DDC[12](), this function will return
+ * the complete EDID data, including all extension blocks, if the 'complete'
+ * parameter is TRUE;
+ *
+ * This function does not affect the list of modes used by drivers -- it is up
+ * to the driver to decide policy on what to do with EDID information.
+ *
+ * @return pointer to a new xf86MonPtr containing the EDID information.
+ * @return NULL if no monitor attached or failure to interpret the EDID.
+ */
+xf86MonPtr
+xf86DoEEDID(int scrnIndex, I2CBusPtr pBus, Bool complete)
+{
+ ScrnInfoPtr pScrn = xf86Screens[scrnIndex];
+ unsigned char *EDID_block = NULL;
+ xf86MonPtr tmp = NULL;
+ I2CDevPtr dev = NULL;
+ /* Default DDC and DDC2 to enabled. */
+ Bool noddc = FALSE, noddc2 = FALSE;
+ OptionInfoPtr options;
+
+ options = malloc(sizeof(DDCOptions));
+ if (!options)
+ return NULL;
+ memcpy(options, DDCOptions, sizeof(DDCOptions));
+ xf86ProcessOptions(pScrn->scrnIndex, pScrn->options, options);
+
+ xf86GetOptValBool(options, DDCOPT_NODDC, &noddc);
+ xf86GetOptValBool(options, DDCOPT_NODDC2, &noddc2);
+ free(options);
+
+ if (noddc || noddc2)
+ return NULL;
+
+ if (!(dev = DDC2Init(scrnIndex, pBus)))
+ return NULL;
+
+ EDID_block = calloc(1, EDID1_LEN);
+ if (!EDID_block)
+ return NULL;
+
+ if (DDC2Read(dev, 0, EDID_block)) {
+ int i, n = EDID_block[0x7e];
+
+ if (complete && n) {
+ EDID_block = realloc(EDID_block, EDID1_LEN * (1+n));
+
+ for (i = 0; i < n; i++)
+ DDC2Read(dev, i+1, EDID_block + (EDID1_LEN * (1+i)));
+ }
+
+ tmp = xf86InterpretEEDID(scrnIndex, EDID_block);
+ }
+
+ if (tmp && complete)
+ tmp->flags |= MONITOR_EDID_COMPLETE_RAWDATA;
+
+ return tmp;
+}
+
+/**
+ * Attempts to probe the monitor for EDID information, if NoDDC and NoDDC2 are
+ * unset. EDID information blocks are interpreted and the results returned in
+ * an xf86MonPtr.
+ *
+ * This function does not affect the list of modes used by drivers -- it is up
+ * to the driver to decide policy on what to do with EDID information.
+ *
+ * @return pointer to a new xf86MonPtr containing the EDID information.
+ * @return NULL if no monitor attached or failure to interpret the EDID.
+ */
+xf86MonPtr
+xf86DoEDID_DDC2(int scrnIndex, I2CBusPtr pBus)
+{
+ return xf86DoEEDID(scrnIndex, pBus, FALSE);
+}
+
+/* XXX write me */
+static void *
+DDC2ReadDisplayID(void)
+{
+ return FALSE;
+}
+
+/**
+ * Attempts to probe the monitor for DisplayID information, if NoDDC and
+ * NoDDC2 are unset. DisplayID blocks are interpreted and the results
+ * returned in an xf86MonPtr.
+ *
+ * This function does not affect the list of modes used by drivers -- it is up
+ * to the driver to decide policy on what to do with DisplayID information.
+ *
+ * @return pointer to a new xf86MonPtr containing the DisplayID information.
+ * @return NULL if no monitor attached or failure to interpret the DisplayID.
+ */
+xf86MonPtr
+xf86DoDisplayID(int scrnIndex, I2CBusPtr pBus)
+{
+ ScrnInfoPtr pScrn = xf86Screens[scrnIndex];
+ unsigned char *did = NULL;
+ xf86MonPtr tmp = NULL;
+ I2CDevPtr dev = NULL;
+ /* Default DDC and DDC2 to enabled. */
+ Bool noddc = FALSE, noddc2 = FALSE;
+ OptionInfoPtr options;
+
+ options = malloc(sizeof(DDCOptions));
+ if (!options)
+ return NULL;
+ memcpy(options, DDCOptions, sizeof(DDCOptions));
+ xf86ProcessOptions(pScrn->scrnIndex, pScrn->options, options);
+
+ xf86GetOptValBool(options, DDCOPT_NODDC, &noddc);
+ xf86GetOptValBool(options, DDCOPT_NODDC2, &noddc2);
+ free(options);
+
+ if (noddc || noddc2)
+ return NULL;
+
+ if (!(dev = DDC2Init(scrnIndex, pBus)))
+ return NULL;
+
+ if ((did = DDC2ReadDisplayID())) {
+ tmp = calloc(1, sizeof(*tmp));
+ if (!tmp)
+ return NULL;
+
+ tmp->scrnIndex = scrnIndex;
+ tmp->flags |= MONITOR_DISPLAYID;
+ tmp->rawData = did;
+ }
+
+ return tmp;
+}
diff --git a/xorg-server/hw/xfree86/int10/helper_exec.c b/xorg-server/hw/xfree86/int10/helper_exec.c
index a55390194..b9af473b1 100644
--- a/xorg-server/hw/xfree86/int10/helper_exec.c
+++ b/xorg-server/hw/xfree86/int10/helper_exec.c
@@ -1,732 +1,733 @@
-/*
- * XFree86 int10 module
- * execute BIOS int 10h calls in x86 real mode environment
- * Copyright 1999 Egbert Eich
- *
- * Part of this code was inspired by the VBIOS POSTing code in DOSEMU
- * developed by the "DOSEMU-Development-Team"
- */
-
-/*
- * To debug port accesses define PRINT_PORT to 1.
- * Note! You also have to comment out ioperm()
- * in xf86EnableIO(). Otherwise we won't trap
- * on PIO.
- */
-
-#ifdef HAVE_XORG_CONFIG_H
-#include <xorg-config.h>
-#endif
-
-#define PRINT_PORT 0
-
-#include <unistd.h>
-
-#include <X11/Xos.h>
-#include "xf86.h"
-#include "xf86_OSproc.h"
-#include "compiler.h"
-#define _INT10_PRIVATE
-#include "int10Defines.h"
-#include "xf86int10.h"
-#include "Pci.h"
-#ifdef _X86EMU
-#include "x86emu/x86emui.h"
-#else
-#define DEBUG_IO_TRACE() 0
-#endif
-#include <pciaccess.h>
-
-static int pciCfg1in(CARD16 addr, CARD32 *val);
-static int pciCfg1out(CARD16 addr, CARD32 val);
-static int pciCfg1inw(CARD16 addr, CARD16 *val);
-static int pciCfg1outw(CARD16 addr, CARD16 val);
-static int pciCfg1inb(CARD16 addr, CARD8 *val);
-static int pciCfg1outb(CARD16 addr, CARD8 val);
-#if defined (_PC)
-static void SetResetBIOSVars(xf86Int10InfoPtr pInt, Bool set);
-#endif
-
-#define REG pInt
-
-int
-setup_int(xf86Int10InfoPtr pInt)
-{
- if (pInt != Int10Current) {
- if (!MapCurrentInt10(pInt))
- return -1;
- Int10Current = pInt;
- }
- X86_EAX = (CARD32) pInt->ax;
- X86_EBX = (CARD32) pInt->bx;
- X86_ECX = (CARD32) pInt->cx;
- X86_EDX = (CARD32) pInt->dx;
- X86_ESI = (CARD32) pInt->si;
- X86_EDI = (CARD32) pInt->di;
- X86_EBP = (CARD32) pInt->bp;
- X86_ESP = 0x1000; X86_SS = pInt->stackseg >> 4;
- X86_EIP = 0x0600; X86_CS = 0x0; /* address of 'hlt' */
- X86_DS = 0x40; /* standard pc ds */
- X86_ES = pInt->es;
- X86_FS = 0;
- X86_GS = 0;
- X86_EFLAGS = X86_IF_MASK | X86_IOPL_MASK;
-#if defined (_PC)
- if (pInt->Flags & SET_BIOS_SCRATCH)
- SetResetBIOSVars(pInt, TRUE);
-#endif
- return xf86BlockSIGIO();
-}
-
-void
-finish_int(xf86Int10InfoPtr pInt, int sig)
-{
- xf86UnblockSIGIO(sig);
- pInt->ax = (CARD32) X86_EAX;
- pInt->bx = (CARD32) X86_EBX;
- pInt->cx = (CARD32) X86_ECX;
- pInt->dx = (CARD32) X86_EDX;
- pInt->si = (CARD32) X86_ESI;
- pInt->di = (CARD32) X86_EDI;
- pInt->es = (CARD16) X86_ES;
- pInt->bp = (CARD32) X86_EBP;
- pInt->flags = (CARD32) X86_FLAGS;
-#if defined (_PC)
- if (pInt->Flags & RESTORE_BIOS_SCRATCH)
- SetResetBIOSVars(pInt, FALSE);
-#endif
-}
-
-/* general software interrupt handler */
-CARD32
-getIntVect(xf86Int10InfoPtr pInt,int num)
-{
- return MEM_RW(pInt, num << 2) + (MEM_RW(pInt, (num << 2) + 2) << 4);
-}
-
-void
-pushw(xf86Int10InfoPtr pInt, CARD16 val)
-{
- X86_ESP -= 2;
- MEM_WW(pInt, ((CARD32) X86_SS << 4) + X86_SP, val);
-}
-
-int
-run_bios_int(int num, xf86Int10InfoPtr pInt)
-{
- CARD32 eflags;
-#ifndef _PC
- /* check if bios vector is initialized */
- if (MEM_RW(pInt, (num << 2) + 2) == (SYS_BIOS >> 4)) { /* SYS_BIOS_SEG ?*/
-
- if (num == 21 && X86_AH == 0x4e) {
- xf86DrvMsg(pInt->scrnIndex, X_NOTICE,
- "Failing Find-Matching-File on non-PC"
- " (int 21, func 4e)\n");
- X86_AX = 2;
- SET_FLAG(F_CF);
- return 1;
- } else {
- xf86DrvMsgVerb(pInt->scrnIndex, X_NOT_IMPLEMENTED, 2,
- "Ignoring int 0x%02x call\n", num);
- if (xf86GetVerbosity() > 3) {
- dump_registers(pInt);
- stack_trace(pInt);
- }
- return 1;
- }
- }
-#endif
-#ifdef PRINT_INT
- ErrorF("calling card BIOS at: ");
-#endif
- eflags = X86_EFLAGS;
-#if 0
- eflags = eflags | IF_MASK;
- X86_EFLAGS = X86_EFLAGS & ~(VIF_MASK | TF_MASK | IF_MASK | NT_MASK);
-#endif
- pushw(pInt, eflags);
- pushw(pInt, X86_CS);
- pushw(pInt, X86_IP);
- X86_CS = MEM_RW(pInt, (num << 2) + 2);
- X86_IP = MEM_RW(pInt, num << 2);
-#ifdef PRINT_INT
- ErrorF("0x%x:%lx\n", X86_CS, X86_EIP);
-#endif
- return 1;
-}
-
-/* Debugging stuff */
-void
-dump_code(xf86Int10InfoPtr pInt)
-{
- int i;
- unsigned long lina = SEG_ADR((CARD32), X86_CS, IP);
-
- xf86DrvMsgVerb(pInt->scrnIndex, X_INFO, 3, "code at 0x%8.8lx:\n", lina);
- for (i=0; i<0x10; i++)
- xf86ErrorFVerb(3, " %2.2x", MEM_RB(pInt, lina + i));
- xf86ErrorFVerb(3, "\n");
- for (; i<0x20; i++)
- xf86ErrorFVerb(3, " %2.2x", MEM_RB(pInt, lina + i));
- xf86ErrorFVerb(3, "\n");
-}
-
-void
-dump_registers(xf86Int10InfoPtr pInt)
-{
- xf86DrvMsgVerb(pInt->scrnIndex, X_INFO, 3,
- "EAX=0x%8.8lx, EBX=0x%8.8lx, ECX=0x%8.8lx, EDX=0x%8.8lx\n",
- (unsigned long)X86_EAX, (unsigned long)X86_EBX,
- (unsigned long)X86_ECX, (unsigned long)X86_EDX);
- xf86DrvMsgVerb(pInt->scrnIndex, X_INFO, 3,
- "ESP=0x%8.8lx, EBP=0x%8.8lx, ESI=0x%8.8lx, EDI=0x%8.8lx\n",
- (unsigned long)X86_ESP, (unsigned long)X86_EBP,
- (unsigned long)X86_ESI, (unsigned long)X86_EDI);
- xf86DrvMsgVerb(pInt->scrnIndex, X_INFO, 3,
- "CS=0x%4.4x, SS=0x%4.4x,"
- " DS=0x%4.4x, ES=0x%4.4x, FS=0x%4.4x, GS=0x%4.4x\n",
- X86_CS, X86_SS, X86_DS, X86_ES, X86_FS, X86_GS);
- xf86DrvMsgVerb(pInt->scrnIndex, X_INFO, 3,
- "EIP=0x%8.8lx, EFLAGS=0x%8.8lx\n",
- (unsigned long)X86_EIP, (unsigned long)X86_EFLAGS);
-}
-
-void
-stack_trace(xf86Int10InfoPtr pInt)
-{
- int i = 0;
- unsigned long stack = SEG_ADR((CARD32), X86_SS, SP);
- unsigned long tail = (CARD32)((X86_SS << 4) + 0x1000);
-
- if (stack >= tail) return;
-
- xf86MsgVerb(X_INFO, 3, "stack at 0x%8.8lx:\n", stack);
- for (; stack < tail; stack++) {
- xf86ErrorFVerb(3, " %2.2x", MEM_RB(pInt, stack));
- i = (i + 1) % 0x10;
- if (!i)
- xf86ErrorFVerb(3, "\n");
- }
- if (i)
- xf86ErrorFVerb(3, "\n");
-}
-
-int
-port_rep_inb(xf86Int10InfoPtr pInt,
- CARD16 port, CARD32 base, int d_f, CARD32 count)
-{
- register int inc = d_f ? -1 : 1;
- CARD32 dst = base;
- if (PRINT_PORT && DEBUG_IO_TRACE())
- ErrorF(" rep_insb(%#x) %ld bytes at %8.8lx %s\n",
- port, count, base, d_f ? "up" : "down");
- while (count--) {
- MEM_WB(pInt, dst, x_inb(port));
- dst += inc;
- }
- return dst - base;
-}
-
-int
-port_rep_inw(xf86Int10InfoPtr pInt,
- CARD16 port, CARD32 base, int d_f, CARD32 count)
-{
- register int inc = d_f ? -2 : 2;
- CARD32 dst = base;
- if (PRINT_PORT && DEBUG_IO_TRACE())
- ErrorF(" rep_insw(%#x) %ld bytes at %8.8lx %s\n",
- port, count, base, d_f ? "up" : "down");
- while (count--) {
- MEM_WW(pInt, dst, x_inw(port));
- dst += inc;
- }
- return dst - base;
-}
-
-int
-port_rep_inl(xf86Int10InfoPtr pInt,
- CARD16 port, CARD32 base, int d_f, CARD32 count)
-{
- register int inc = d_f ? -4 : 4;
- CARD32 dst = base;
- if (PRINT_PORT && DEBUG_IO_TRACE())
- ErrorF(" rep_insl(%#x) %ld bytes at %8.8lx %s\n",
- port, count, base, d_f ? "up" : "down");
- while (count--) {
- MEM_WL(pInt, dst, x_inl(port));
- dst += inc;
- }
- return dst - base;
-}
-
-int
-port_rep_outb(xf86Int10InfoPtr pInt,
- CARD16 port, CARD32 base, int d_f, CARD32 count)
-{
- register int inc = d_f ? -1 : 1;
- CARD32 dst = base;
- if (PRINT_PORT && DEBUG_IO_TRACE())
- ErrorF(" rep_outb(%#x) %ld bytes at %8.8lx %s\n",
- port, count, base, d_f ? "up" : "down");
- while (count--) {
- x_outb(port, MEM_RB(pInt, dst));
- dst += inc;
- }
- return dst - base;
-}
-
-int
-port_rep_outw(xf86Int10InfoPtr pInt,
- CARD16 port, CARD32 base, int d_f, CARD32 count)
-{
- register int inc = d_f ? -2 : 2;
- CARD32 dst = base;
- if (PRINT_PORT && DEBUG_IO_TRACE())
- ErrorF(" rep_outw(%#x) %ld bytes at %8.8lx %s\n",
- port, count, base, d_f ? "up" : "down");
- while (count--) {
- x_outw(port, MEM_RW(pInt, dst));
- dst += inc;
- }
- return dst - base;
-}
-
-int
-port_rep_outl(xf86Int10InfoPtr pInt,
- CARD16 port, CARD32 base, int d_f, CARD32 count)
-{
- register int inc = d_f ? -4 : 4;
- CARD32 dst = base;
- if (PRINT_PORT && DEBUG_IO_TRACE())
- ErrorF(" rep_outl(%#x) %ld bytes at %8.8lx %s\n",
- port, count, base, d_f ? "up" : "down");
- while (count--) {
- x_outl(port, MEM_RL(pInt, dst));
- dst += inc;
- }
- return dst - base;
-}
-
-CARD8
-x_inb(CARD16 port)
-{
- CARD8 val;
-
- if (port == 0x40) {
- Int10Current->inb40time++;
- val = (CARD8)(Int10Current->inb40time >>
- ((Int10Current->inb40time & 1) << 3));
- if (PRINT_PORT && DEBUG_IO_TRACE())
- ErrorF(" inb(%#x) = %2.2x\n", port, val);
-#ifdef __NOT_YET__
- } else if (port < 0x0100) { /* Don't interfere with mainboard */
- val = 0;
- xf86DrvMsgVerb(Int10Current->scrnIndex, X_NOT_IMPLEMENTED, 2,
- "inb 0x%4.4x\n", port);
- if (xf86GetVerbosity() > 3) {
- dump_registers(Int10Current);
- stack_trace(Int10Current);
- }
-#endif /* __NOT_YET__ */
- } else if (!pciCfg1inb(port, &val)) {
- val = inb(Int10Current->ioBase + port);
- if (PRINT_PORT && DEBUG_IO_TRACE())
- ErrorF(" inb(%#x) = %2.2x\n", port, val);
- }
- return val;
-}
-
-CARD16
-x_inw(CARD16 port)
-{
- CARD16 val;
-
- if (port == 0x5c) {
- struct timeval tv;
-
- /*
- * Emulate a PC98's timer. Typical resolution is 3.26 usec.
- * Approximate this by dividing by 3.
- */
- X_GETTIMEOFDAY(&tv);
- val = (CARD16)(tv.tv_usec / 3);
- } else if (!pciCfg1inw(port, &val)) {
- val = inw(Int10Current->ioBase + port);
- if (PRINT_PORT && DEBUG_IO_TRACE())
- ErrorF(" inw(%#x) = %4.4x\n", port, val);
- }
- return val;
-}
-
-void
-x_outb(CARD16 port, CARD8 val)
-{
- if ((port == 0x43) && (val == 0)) {
- struct timeval tv;
- /*
- * Emulate a PC's timer 0. Such timers typically have a resolution of
- * some .838 usec per tick, but this can only provide 1 usec per tick.
- * (Not that this matters much, given inherent emulation delays.) Use
- * the bottom bit as a byte select. See inb(0x40) above.
- */
- X_GETTIMEOFDAY(&tv);
- Int10Current->inb40time = (CARD16)(tv.tv_usec | 1);
- if (PRINT_PORT && DEBUG_IO_TRACE())
- ErrorF(" outb(%#x, %2.2x)\n", port, val);
-#ifdef __NOT_YET__
- } else if (port < 0x0100) { /* Don't interfere with mainboard */
- xf86DrvMsgVerb(Int10Current->scrnIndex, X_NOT_IMPLEMENTED, 2,
- "outb 0x%4.4x,0x%2.2x\n", port, val);
- if (xf86GetVerbosity() > 3) {
- dump_registers(Int10Current);
- stack_trace(Int10Current);
- }
-#endif /* __NOT_YET__ */
- } else if (!pciCfg1outb(port, val)) {
- if (PRINT_PORT && DEBUG_IO_TRACE())
- ErrorF(" outb(%#x, %2.2x)\n", port, val);
- outb(Int10Current->ioBase + port, val);
- }
-}
-
-void
-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);
- }
-}
-
-CARD32
-x_inl(CARD16 port)
-{
- CARD32 val;
-
- if (!pciCfg1in(port, &val)) {
- val = inl(Int10Current->ioBase + port);
- if (PRINT_PORT && DEBUG_IO_TRACE())
- ErrorF(" inl(%#x) = %8.8lx\n", port, val);
- }
- return val;
-}
-
-void
-x_outl(CARD16 port, CARD32 val)
-{
- if (!pciCfg1out(port, val)) {
- if (PRINT_PORT && DEBUG_IO_TRACE())
- ErrorF(" outl(%#x, %8.8lx)\n", port, val);
- outl(Int10Current->ioBase + port, val);
- }
-}
-
-CARD8
-Mem_rb(CARD32 addr)
-{
- return (*Int10Current->mem->rb)(Int10Current, addr);
-}
-
-CARD16
-Mem_rw(CARD32 addr)
-{
- return (*Int10Current->mem->rw)(Int10Current, addr);
-}
-
-CARD32
-Mem_rl(CARD32 addr)
-{
- return (*Int10Current->mem->rl)(Int10Current, addr);
-}
-
-void
-Mem_wb(CARD32 addr, CARD8 val)
-{
- (*Int10Current->mem->wb)(Int10Current, addr, val);
-}
-
-void
-Mem_ww(CARD32 addr, CARD16 val)
-{
- (*Int10Current->mem->ww)(Int10Current, addr, val);
-}
-
-void
-Mem_wl(CARD32 addr, CARD32 val)
-{
- (*Int10Current->mem->wl)(Int10Current, addr, val);
-}
-
-static CARD32 PciCfg1Addr = 0;
-
-#define PCI_DOM_FROM_TAG(tag) (((tag) >> 24) & (PCI_DOM_MASK))
-#define PCI_BUS_FROM_TAG(tag) (((tag) >> 16) & (PCI_DOMBUS_MASK))
-#define PCI_DEV_FROM_TAG(tag) (((tag) & 0x0000f800u) >> 11)
-#define PCI_FUNC_FROM_TAG(tag) (((tag) & 0x00000700u) >> 8)
-
-#define PCI_OFFSET(x) ((x) & 0x000000ff)
-#define PCI_TAG(x) ((x) & 0x7fffff00)
-
-static struct pci_device*
-pci_device_for_cfg_address (CARD32 addr)
-{
- struct pci_device *dev = NULL;
- PCITAG 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)),
- .dev = PCI_DEV_FROM_TAG(tag),
- .func = PCI_FUNC_FROM_TAG(tag),
- .match_data = 0
- };
-
- struct pci_device_iterator *iter =
- pci_slot_match_iterator_create (&slot_match);
-
- if (iter)
- dev = pci_device_next(iter);
-
- pci_iterator_destroy(iter);
-
- return dev;
-}
-
-static int
-pciCfg1in(CARD16 addr, CARD32 *val)
-{
- if (addr == 0xCF8) {
- *val = PciCfg1Addr;
- return 1;
- }
- if (addr == 0xCFC) {
- pci_device_cfg_read_u32(pci_device_for_cfg_address(PciCfg1Addr),
- val, PCI_OFFSET(PciCfg1Addr));
- if (PRINT_PORT && DEBUG_IO_TRACE())
- ErrorF(" cfg_inl(%#lx) = %8.8lx\n", PciCfg1Addr, *val);
- return 1;
- }
- return 0;
-}
-
-static int
-pciCfg1out(CARD16 addr, CARD32 val)
-{
- if (addr == 0xCF8) {
- PciCfg1Addr = val;
- return 1;
- }
- if (addr == 0xCFC) {
- if (PRINT_PORT && DEBUG_IO_TRACE())
- ErrorF(" cfg_outl(%#lx, %8.8lx)\n", PciCfg1Addr, val);
- pci_device_cfg_write_u32(pci_device_for_cfg_address(PciCfg1Addr),
- val, PCI_OFFSET(PciCfg1Addr));
- return 1;
- }
- return 0;
-}
-
-static int
-pciCfg1inw(CARD16 addr, CARD16 *val)
-{
- int shift;
-
- if ((addr >= 0xCF8) && (addr <= 0xCFB)) {
- shift = (addr - 0xCF8) * 8;
- *val = (PciCfg1Addr >> shift) & 0xffff;
- return 1;
- }
- if ((addr >= 0xCFC) && (addr <= 0xCFF)) {
- const unsigned offset = addr - 0xCFC;
-
- pci_device_cfg_read_u16(pci_device_for_cfg_address(PciCfg1Addr),
- val, PCI_OFFSET(PciCfg1Addr) + offset);
- if (PRINT_PORT && DEBUG_IO_TRACE())
- ErrorF(" cfg_inw(%#lx) = %4.4x\n", PciCfg1Addr + offset, *val);
- return 1;
- }
- return 0;
-}
-
-static int
-pciCfg1outw(CARD16 addr, CARD16 val)
-{
- int shift;
-
- if ((addr >= 0xCF8) && (addr <= 0xCFB)) {
- shift = (addr - 0xCF8) * 8;
- PciCfg1Addr &= ~(0xffff << shift);
- PciCfg1Addr |= ((CARD32) val) << shift;
- return 1;
- }
- if ((addr >= 0xCFC) && (addr <= 0xCFF)) {
- const unsigned offset = addr - 0xCFC;
-
- if (PRINT_PORT && DEBUG_IO_TRACE())
- ErrorF(" cfg_outw(%#lx, %4.4x)\n", PciCfg1Addr + offset, val);
- pci_device_cfg_write_u16(pci_device_for_cfg_address(PciCfg1Addr),
- val, PCI_OFFSET(PciCfg1Addr) + offset);
- return 1;
- }
- return 0;
-}
-
-static int
-pciCfg1inb(CARD16 addr, CARD8 *val)
-{
- int shift;
-
- if ((addr >= 0xCF8) && (addr <= 0xCFB)) {
- shift = (addr - 0xCF8) * 8;
- *val = (PciCfg1Addr >> shift) & 0xff;
- return 1;
- }
- if ((addr >= 0xCFC) && (addr <= 0xCFF)) {
- const unsigned offset = addr - 0xCFC;
-
- pci_device_cfg_read_u8(pci_device_for_cfg_address(PciCfg1Addr),
- val, PCI_OFFSET(PciCfg1Addr) + offset);
- if (PRINT_PORT && DEBUG_IO_TRACE())
- ErrorF(" cfg_inb(%#lx) = %2.2x\n", PciCfg1Addr + offset, *val);
- return 1;
- }
- return 0;
-}
-
-static int
-pciCfg1outb(CARD16 addr, CARD8 val)
-{
- int shift;
-
- if ((addr >= 0xCF8) && (addr <= 0xCFB)) {
- shift = (addr - 0xCF8) * 8;
- PciCfg1Addr &= ~(0xff << shift);
- PciCfg1Addr |= ((CARD32) val) << shift;
- return 1;
- }
- if ((addr >= 0xCFC) && (addr <= 0xCFF)) {
- const unsigned offset = addr - 0xCFC;
-
- if (PRINT_PORT && DEBUG_IO_TRACE())
- ErrorF(" cfg_outb(%#lx, %2.2x)\n", PciCfg1Addr + offset, val);
- pci_device_cfg_write_u8(pci_device_for_cfg_address(PciCfg1Addr),
- val, PCI_OFFSET(PciCfg1Addr) + offset);
- return 1;
- }
- return 0;
-}
-
-CARD8
-bios_checksum(const CARD8 *start, int size)
-{
- CARD8 sum = 0;
-
- while (size-- > 0)
- sum += *start++;
- return sum;
-}
-
-/*
- * Lock/Unlock legacy VGA. Some Bioses try to be very clever and make
- * an attempt to detect a legacy ISA card. If they find one they might
- * act very strange: for example they might configure the card as a
- * monochrome card. This might cause some drivers to choke.
- * To avoid this we attempt legacy VGA by writing to all know VGA
- * disable registers before we call the BIOS initialization and
- * restore the original values afterwards. In beween we hold our
- * breath. To get to a (possibly exising) ISA card need to disable
- * our current PCI card.
- */
-/*
- * This is just for booting: we just want to catch pure
- * legacy vga therefore we don't worry about mmio etc.
- * This stuff should really go into vgaHW.c. However then
- * the driver would have to load the vga-module prior to
- * doing int10.
- */
-void
-LockLegacyVGA(xf86Int10InfoPtr pInt, legacyVGAPtr vga)
-{
- vga->save_msr = inb(pInt->ioBase + 0x03CC);
- vga->save_vse = inb(pInt->ioBase + 0x03C3);
-#ifndef __ia64__
- vga->save_46e8 = inb(pInt->ioBase + 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);
-#ifndef __ia64__
- outb(pInt->ioBase + 0x46E8, ~(CARD8)0x08 & vga->save_46e8);
-#endif
- outb(pInt->ioBase + 0x0102, ~(CARD8)0x01 & vga->save_pos102);
-}
-
-void
-UnlockLegacyVGA(xf86Int10InfoPtr pInt, legacyVGAPtr vga)
-{
- outb(pInt->ioBase + 0x0102, vga->save_pos102);
-#ifndef __ia64__
- outb(pInt->ioBase + 0x46E8, vga->save_46e8);
-#endif
- outb(pInt->ioBase + 0x03C3, vga->save_vse);
- outb(pInt->ioBase + 0x03C2, vga->save_msr);
-}
-
-#if defined (_PC)
-static void
-SetResetBIOSVars(xf86Int10InfoPtr pInt, Bool set)
-{
- int pagesize = getpagesize();
- unsigned char* base = xf86MapVidMem(pInt->scrnIndex,
- VIDMEM_MMIO, 0, pagesize);
- int i;
-
- if (set) {
- for (i = BIOS_SCRATCH_OFF; i < BIOS_SCRATCH_END; i++)
- MEM_WW(pInt, i, *(base + i));
- } else {
- for (i = BIOS_SCRATCH_OFF; i < BIOS_SCRATCH_END; i++)
- *(base + i) = MEM_RW(pInt, i);
- }
-
- xf86UnMapVidMem(pInt->scrnIndex,base,pagesize);
-}
-
-void
-xf86Int10SaveRestoreBIOSVars(xf86Int10InfoPtr pInt, Bool save)
-{
- int pagesize = getpagesize();
- unsigned char* base;
- int i;
-
- if (!xf86IsEntityPrimary(pInt->entityIndex)
- || (!save && !pInt->BIOSScratch))
- return;
-
- base = xf86MapVidMem(pInt->scrnIndex, VIDMEM_MMIO, 0, pagesize);
- base += BIOS_SCRATCH_OFF;
- if (save) {
- if ((pInt->BIOSScratch
- = xnfalloc(BIOS_SCRATCH_LEN)))
- for (i = 0; i < BIOS_SCRATCH_LEN; i++)
- *(((char*)pInt->BIOSScratch + i)) = *(base + i);
- } else {
- if (pInt->BIOSScratch) {
- for (i = 0; i < BIOS_SCRATCH_LEN; i++)
- *(base + i) = *(pInt->BIOSScratch + i);
- free(pInt->BIOSScratch);
- pInt->BIOSScratch = NULL;
- }
- }
-
- xf86UnMapVidMem(pInt->scrnIndex,base - BIOS_SCRATCH_OFF ,pagesize);
-}
-#endif
-
-xf86Int10InfoPtr
-xf86InitInt10(int entityIndex)
-{
- return xf86ExtendedInitInt10(entityIndex, 0);
-}
+/*
+ * XFree86 int10 module
+ * execute BIOS int 10h calls in x86 real mode environment
+ * Copyright 1999 Egbert Eich
+ *
+ * Part of this code was inspired by the VBIOS POSTing code in DOSEMU
+ * developed by the "DOSEMU-Development-Team"
+ */
+
+/*
+ * To debug port accesses define PRINT_PORT to 1.
+ * Note! You also have to comment out ioperm()
+ * in xf86EnableIO(). Otherwise we won't trap
+ * on PIO.
+ */
+
+#ifdef HAVE_XORG_CONFIG_H
+#include <xorg-config.h>
+#endif
+
+#define PRINT_PORT 0
+
+#include <unistd.h>
+
+#include <X11/Xos.h>
+#include "xf86.h"
+#include "xf86_OSproc.h"
+#include "compiler.h"
+#define _INT10_PRIVATE
+#include "int10Defines.h"
+#include "xf86int10.h"
+#include "Pci.h"
+#ifdef _X86EMU
+#include "x86emu/x86emui.h"
+#else
+#define DEBUG_IO_TRACE() 0
+#endif
+#include <pciaccess.h>
+
+static int pciCfg1in(CARD16 addr, CARD32 *val);
+static int pciCfg1out(CARD16 addr, CARD32 val);
+static int pciCfg1inw(CARD16 addr, CARD16 *val);
+static int pciCfg1outw(CARD16 addr, CARD16 val);
+static int pciCfg1inb(CARD16 addr, CARD8 *val);
+static int pciCfg1outb(CARD16 addr, CARD8 val);
+#if defined (_PC)
+static void SetResetBIOSVars(xf86Int10InfoPtr pInt, Bool set);
+#endif
+
+#define REG pInt
+
+int
+setup_int(xf86Int10InfoPtr pInt)
+{
+ if (pInt != Int10Current) {
+ if (!MapCurrentInt10(pInt))
+ return -1;
+ Int10Current = pInt;
+ }
+ X86_EAX = (CARD32) pInt->ax;
+ X86_EBX = (CARD32) pInt->bx;
+ X86_ECX = (CARD32) pInt->cx;
+ X86_EDX = (CARD32) pInt->dx;
+ X86_ESI = (CARD32) pInt->si;
+ X86_EDI = (CARD32) pInt->di;
+ X86_EBP = (CARD32) pInt->bp;
+ X86_ESP = 0x1000; X86_SS = pInt->stackseg >> 4;
+ X86_EIP = 0x0600; X86_CS = 0x0; /* address of 'hlt' */
+ X86_DS = 0x40; /* standard pc ds */
+ X86_ES = pInt->es;
+ X86_FS = 0;
+ X86_GS = 0;
+ X86_EFLAGS = X86_IF_MASK | X86_IOPL_MASK;
+#if defined (_PC)
+ if (pInt->Flags & SET_BIOS_SCRATCH)
+ SetResetBIOSVars(pInt, TRUE);
+#endif
+ OsBlockSignals();
+ return 0;
+}
+
+void
+finish_int(xf86Int10InfoPtr pInt, int sig)
+{
+ OsReleaseSignals();
+ pInt->ax = (CARD32) X86_EAX;
+ pInt->bx = (CARD32) X86_EBX;
+ pInt->cx = (CARD32) X86_ECX;
+ pInt->dx = (CARD32) X86_EDX;
+ pInt->si = (CARD32) X86_ESI;
+ pInt->di = (CARD32) X86_EDI;
+ pInt->es = (CARD16) X86_ES;
+ pInt->bp = (CARD32) X86_EBP;
+ pInt->flags = (CARD32) X86_FLAGS;
+#if defined (_PC)
+ if (pInt->Flags & RESTORE_BIOS_SCRATCH)
+ SetResetBIOSVars(pInt, FALSE);
+#endif
+}
+
+/* general software interrupt handler */
+CARD32
+getIntVect(xf86Int10InfoPtr pInt,int num)
+{
+ return MEM_RW(pInt, num << 2) + (MEM_RW(pInt, (num << 2) + 2) << 4);
+}
+
+void
+pushw(xf86Int10InfoPtr pInt, CARD16 val)
+{
+ X86_ESP -= 2;
+ MEM_WW(pInt, ((CARD32) X86_SS << 4) + X86_SP, val);
+}
+
+int
+run_bios_int(int num, xf86Int10InfoPtr pInt)
+{
+ CARD32 eflags;
+#ifndef _PC
+ /* check if bios vector is initialized */
+ if (MEM_RW(pInt, (num << 2) + 2) == (SYS_BIOS >> 4)) { /* SYS_BIOS_SEG ?*/
+
+ if (num == 21 && X86_AH == 0x4e) {
+ xf86DrvMsg(pInt->scrnIndex, X_NOTICE,
+ "Failing Find-Matching-File on non-PC"
+ " (int 21, func 4e)\n");
+ X86_AX = 2;
+ SET_FLAG(F_CF);
+ return 1;
+ } else {
+ xf86DrvMsgVerb(pInt->scrnIndex, X_NOT_IMPLEMENTED, 2,
+ "Ignoring int 0x%02x call\n", num);
+ if (xf86GetVerbosity() > 3) {
+ dump_registers(pInt);
+ stack_trace(pInt);
+ }
+ return 1;
+ }
+ }
+#endif
+#ifdef PRINT_INT
+ ErrorF("calling card BIOS at: ");
+#endif
+ eflags = X86_EFLAGS;
+#if 0
+ eflags = eflags | IF_MASK;
+ X86_EFLAGS = X86_EFLAGS & ~(VIF_MASK | TF_MASK | IF_MASK | NT_MASK);
+#endif
+ pushw(pInt, eflags);
+ pushw(pInt, X86_CS);
+ pushw(pInt, X86_IP);
+ X86_CS = MEM_RW(pInt, (num << 2) + 2);
+ X86_IP = MEM_RW(pInt, num << 2);
+#ifdef PRINT_INT
+ ErrorF("0x%x:%lx\n", X86_CS, X86_EIP);
+#endif
+ return 1;
+}
+
+/* Debugging stuff */
+void
+dump_code(xf86Int10InfoPtr pInt)
+{
+ int i;
+ unsigned long lina = SEG_ADR((CARD32), X86_CS, IP);
+
+ xf86DrvMsgVerb(pInt->scrnIndex, X_INFO, 3, "code at 0x%8.8lx:\n", lina);
+ for (i=0; i<0x10; i++)
+ xf86ErrorFVerb(3, " %2.2x", MEM_RB(pInt, lina + i));
+ xf86ErrorFVerb(3, "\n");
+ for (; i<0x20; i++)
+ xf86ErrorFVerb(3, " %2.2x", MEM_RB(pInt, lina + i));
+ xf86ErrorFVerb(3, "\n");
+}
+
+void
+dump_registers(xf86Int10InfoPtr pInt)
+{
+ xf86DrvMsgVerb(pInt->scrnIndex, X_INFO, 3,
+ "EAX=0x%8.8lx, EBX=0x%8.8lx, ECX=0x%8.8lx, EDX=0x%8.8lx\n",
+ (unsigned long)X86_EAX, (unsigned long)X86_EBX,
+ (unsigned long)X86_ECX, (unsigned long)X86_EDX);
+ xf86DrvMsgVerb(pInt->scrnIndex, X_INFO, 3,
+ "ESP=0x%8.8lx, EBP=0x%8.8lx, ESI=0x%8.8lx, EDI=0x%8.8lx\n",
+ (unsigned long)X86_ESP, (unsigned long)X86_EBP,
+ (unsigned long)X86_ESI, (unsigned long)X86_EDI);
+ xf86DrvMsgVerb(pInt->scrnIndex, X_INFO, 3,
+ "CS=0x%4.4x, SS=0x%4.4x,"
+ " DS=0x%4.4x, ES=0x%4.4x, FS=0x%4.4x, GS=0x%4.4x\n",
+ X86_CS, X86_SS, X86_DS, X86_ES, X86_FS, X86_GS);
+ xf86DrvMsgVerb(pInt->scrnIndex, X_INFO, 3,
+ "EIP=0x%8.8lx, EFLAGS=0x%8.8lx\n",
+ (unsigned long)X86_EIP, (unsigned long)X86_EFLAGS);
+}
+
+void
+stack_trace(xf86Int10InfoPtr pInt)
+{
+ int i = 0;
+ unsigned long stack = SEG_ADR((CARD32), X86_SS, SP);
+ unsigned long tail = (CARD32)((X86_SS << 4) + 0x1000);
+
+ if (stack >= tail) return;
+
+ xf86MsgVerb(X_INFO, 3, "stack at 0x%8.8lx:\n", stack);
+ for (; stack < tail; stack++) {
+ xf86ErrorFVerb(3, " %2.2x", MEM_RB(pInt, stack));
+ i = (i + 1) % 0x10;
+ if (!i)
+ xf86ErrorFVerb(3, "\n");
+ }
+ if (i)
+ xf86ErrorFVerb(3, "\n");
+}
+
+int
+port_rep_inb(xf86Int10InfoPtr pInt,
+ CARD16 port, CARD32 base, int d_f, CARD32 count)
+{
+ register int inc = d_f ? -1 : 1;
+ CARD32 dst = base;
+ if (PRINT_PORT && DEBUG_IO_TRACE())
+ ErrorF(" rep_insb(%#x) %ld bytes at %8.8lx %s\n",
+ port, count, base, d_f ? "up" : "down");
+ while (count--) {
+ MEM_WB(pInt, dst, x_inb(port));
+ dst += inc;
+ }
+ return dst - base;
+}
+
+int
+port_rep_inw(xf86Int10InfoPtr pInt,
+ CARD16 port, CARD32 base, int d_f, CARD32 count)
+{
+ register int inc = d_f ? -2 : 2;
+ CARD32 dst = base;
+ if (PRINT_PORT && DEBUG_IO_TRACE())
+ ErrorF(" rep_insw(%#x) %ld bytes at %8.8lx %s\n",
+ port, count, base, d_f ? "up" : "down");
+ while (count--) {
+ MEM_WW(pInt, dst, x_inw(port));
+ dst += inc;
+ }
+ return dst - base;
+}
+
+int
+port_rep_inl(xf86Int10InfoPtr pInt,
+ CARD16 port, CARD32 base, int d_f, CARD32 count)
+{
+ register int inc = d_f ? -4 : 4;
+ CARD32 dst = base;
+ if (PRINT_PORT && DEBUG_IO_TRACE())
+ ErrorF(" rep_insl(%#x) %ld bytes at %8.8lx %s\n",
+ port, count, base, d_f ? "up" : "down");
+ while (count--) {
+ MEM_WL(pInt, dst, x_inl(port));
+ dst += inc;
+ }
+ return dst - base;
+}
+
+int
+port_rep_outb(xf86Int10InfoPtr pInt,
+ CARD16 port, CARD32 base, int d_f, CARD32 count)
+{
+ register int inc = d_f ? -1 : 1;
+ CARD32 dst = base;
+ if (PRINT_PORT && DEBUG_IO_TRACE())
+ ErrorF(" rep_outb(%#x) %ld bytes at %8.8lx %s\n",
+ port, count, base, d_f ? "up" : "down");
+ while (count--) {
+ x_outb(port, MEM_RB(pInt, dst));
+ dst += inc;
+ }
+ return dst - base;
+}
+
+int
+port_rep_outw(xf86Int10InfoPtr pInt,
+ CARD16 port, CARD32 base, int d_f, CARD32 count)
+{
+ register int inc = d_f ? -2 : 2;
+ CARD32 dst = base;
+ if (PRINT_PORT && DEBUG_IO_TRACE())
+ ErrorF(" rep_outw(%#x) %ld bytes at %8.8lx %s\n",
+ port, count, base, d_f ? "up" : "down");
+ while (count--) {
+ x_outw(port, MEM_RW(pInt, dst));
+ dst += inc;
+ }
+ return dst - base;
+}
+
+int
+port_rep_outl(xf86Int10InfoPtr pInt,
+ CARD16 port, CARD32 base, int d_f, CARD32 count)
+{
+ register int inc = d_f ? -4 : 4;
+ CARD32 dst = base;
+ if (PRINT_PORT && DEBUG_IO_TRACE())
+ ErrorF(" rep_outl(%#x) %ld bytes at %8.8lx %s\n",
+ port, count, base, d_f ? "up" : "down");
+ while (count--) {
+ x_outl(port, MEM_RL(pInt, dst));
+ dst += inc;
+ }
+ return dst - base;
+}
+
+CARD8
+x_inb(CARD16 port)
+{
+ CARD8 val;
+
+ if (port == 0x40) {
+ Int10Current->inb40time++;
+ val = (CARD8)(Int10Current->inb40time >>
+ ((Int10Current->inb40time & 1) << 3));
+ if (PRINT_PORT && DEBUG_IO_TRACE())
+ ErrorF(" inb(%#x) = %2.2x\n", port, val);
+#ifdef __NOT_YET__
+ } else if (port < 0x0100) { /* Don't interfere with mainboard */
+ val = 0;
+ xf86DrvMsgVerb(Int10Current->scrnIndex, X_NOT_IMPLEMENTED, 2,
+ "inb 0x%4.4x\n", port);
+ if (xf86GetVerbosity() > 3) {
+ dump_registers(Int10Current);
+ stack_trace(Int10Current);
+ }
+#endif /* __NOT_YET__ */
+ } else if (!pciCfg1inb(port, &val)) {
+ val = inb(Int10Current->ioBase + port);
+ if (PRINT_PORT && DEBUG_IO_TRACE())
+ ErrorF(" inb(%#x) = %2.2x\n", port, val);
+ }
+ return val;
+}
+
+CARD16
+x_inw(CARD16 port)
+{
+ CARD16 val;
+
+ if (port == 0x5c) {
+ struct timeval tv;
+
+ /*
+ * Emulate a PC98's timer. Typical resolution is 3.26 usec.
+ * Approximate this by dividing by 3.
+ */
+ X_GETTIMEOFDAY(&tv);
+ val = (CARD16)(tv.tv_usec / 3);
+ } else if (!pciCfg1inw(port, &val)) {
+ val = inw(Int10Current->ioBase + port);
+ if (PRINT_PORT && DEBUG_IO_TRACE())
+ ErrorF(" inw(%#x) = %4.4x\n", port, val);
+ }
+ return val;
+}
+
+void
+x_outb(CARD16 port, CARD8 val)
+{
+ if ((port == 0x43) && (val == 0)) {
+ struct timeval tv;
+ /*
+ * Emulate a PC's timer 0. Such timers typically have a resolution of
+ * some .838 usec per tick, but this can only provide 1 usec per tick.
+ * (Not that this matters much, given inherent emulation delays.) Use
+ * the bottom bit as a byte select. See inb(0x40) above.
+ */
+ X_GETTIMEOFDAY(&tv);
+ Int10Current->inb40time = (CARD16)(tv.tv_usec | 1);
+ if (PRINT_PORT && DEBUG_IO_TRACE())
+ ErrorF(" outb(%#x, %2.2x)\n", port, val);
+#ifdef __NOT_YET__
+ } else if (port < 0x0100) { /* Don't interfere with mainboard */
+ xf86DrvMsgVerb(Int10Current->scrnIndex, X_NOT_IMPLEMENTED, 2,
+ "outb 0x%4.4x,0x%2.2x\n", port, val);
+ if (xf86GetVerbosity() > 3) {
+ dump_registers(Int10Current);
+ stack_trace(Int10Current);
+ }
+#endif /* __NOT_YET__ */
+ } else if (!pciCfg1outb(port, val)) {
+ if (PRINT_PORT && DEBUG_IO_TRACE())
+ ErrorF(" outb(%#x, %2.2x)\n", port, val);
+ outb(Int10Current->ioBase + port, val);
+ }
+}
+
+void
+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);
+ }
+}
+
+CARD32
+x_inl(CARD16 port)
+{
+ CARD32 val;
+
+ if (!pciCfg1in(port, &val)) {
+ val = inl(Int10Current->ioBase + port);
+ if (PRINT_PORT && DEBUG_IO_TRACE())
+ ErrorF(" inl(%#x) = %8.8lx\n", port, val);
+ }
+ return val;
+}
+
+void
+x_outl(CARD16 port, CARD32 val)
+{
+ if (!pciCfg1out(port, val)) {
+ if (PRINT_PORT && DEBUG_IO_TRACE())
+ ErrorF(" outl(%#x, %8.8lx)\n", port, val);
+ outl(Int10Current->ioBase + port, val);
+ }
+}
+
+CARD8
+Mem_rb(CARD32 addr)
+{
+ return (*Int10Current->mem->rb)(Int10Current, addr);
+}
+
+CARD16
+Mem_rw(CARD32 addr)
+{
+ return (*Int10Current->mem->rw)(Int10Current, addr);
+}
+
+CARD32
+Mem_rl(CARD32 addr)
+{
+ return (*Int10Current->mem->rl)(Int10Current, addr);
+}
+
+void
+Mem_wb(CARD32 addr, CARD8 val)
+{
+ (*Int10Current->mem->wb)(Int10Current, addr, val);
+}
+
+void
+Mem_ww(CARD32 addr, CARD16 val)
+{
+ (*Int10Current->mem->ww)(Int10Current, addr, val);
+}
+
+void
+Mem_wl(CARD32 addr, CARD32 val)
+{
+ (*Int10Current->mem->wl)(Int10Current, addr, val);
+}
+
+static CARD32 PciCfg1Addr = 0;
+
+#define PCI_DOM_FROM_TAG(tag) (((tag) >> 24) & (PCI_DOM_MASK))
+#define PCI_BUS_FROM_TAG(tag) (((tag) >> 16) & (PCI_DOMBUS_MASK))
+#define PCI_DEV_FROM_TAG(tag) (((tag) & 0x0000f800u) >> 11)
+#define PCI_FUNC_FROM_TAG(tag) (((tag) & 0x00000700u) >> 8)
+
+#define PCI_OFFSET(x) ((x) & 0x000000ff)
+#define PCI_TAG(x) ((x) & 0x7fffff00)
+
+static struct pci_device*
+pci_device_for_cfg_address (CARD32 addr)
+{
+ struct pci_device *dev = NULL;
+ PCITAG 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)),
+ .dev = PCI_DEV_FROM_TAG(tag),
+ .func = PCI_FUNC_FROM_TAG(tag),
+ .match_data = 0
+ };
+
+ struct pci_device_iterator *iter =
+ pci_slot_match_iterator_create (&slot_match);
+
+ if (iter)
+ dev = pci_device_next(iter);
+
+ pci_iterator_destroy(iter);
+
+ return dev;
+}
+
+static int
+pciCfg1in(CARD16 addr, CARD32 *val)
+{
+ if (addr == 0xCF8) {
+ *val = PciCfg1Addr;
+ return 1;
+ }
+ if (addr == 0xCFC) {
+ pci_device_cfg_read_u32(pci_device_for_cfg_address(PciCfg1Addr),
+ val, PCI_OFFSET(PciCfg1Addr));
+ if (PRINT_PORT && DEBUG_IO_TRACE())
+ ErrorF(" cfg_inl(%#lx) = %8.8lx\n", PciCfg1Addr, *val);
+ return 1;
+ }
+ return 0;
+}
+
+static int
+pciCfg1out(CARD16 addr, CARD32 val)
+{
+ if (addr == 0xCF8) {
+ PciCfg1Addr = val;
+ return 1;
+ }
+ if (addr == 0xCFC) {
+ if (PRINT_PORT && DEBUG_IO_TRACE())
+ ErrorF(" cfg_outl(%#lx, %8.8lx)\n", PciCfg1Addr, val);
+ pci_device_cfg_write_u32(pci_device_for_cfg_address(PciCfg1Addr),
+ val, PCI_OFFSET(PciCfg1Addr));
+ return 1;
+ }
+ return 0;
+}
+
+static int
+pciCfg1inw(CARD16 addr, CARD16 *val)
+{
+ int shift;
+
+ if ((addr >= 0xCF8) && (addr <= 0xCFB)) {
+ shift = (addr - 0xCF8) * 8;
+ *val = (PciCfg1Addr >> shift) & 0xffff;
+ return 1;
+ }
+ if ((addr >= 0xCFC) && (addr <= 0xCFF)) {
+ const unsigned offset = addr - 0xCFC;
+
+ pci_device_cfg_read_u16(pci_device_for_cfg_address(PciCfg1Addr),
+ val, PCI_OFFSET(PciCfg1Addr) + offset);
+ if (PRINT_PORT && DEBUG_IO_TRACE())
+ ErrorF(" cfg_inw(%#lx) = %4.4x\n", PciCfg1Addr + offset, *val);
+ return 1;
+ }
+ return 0;
+}
+
+static int
+pciCfg1outw(CARD16 addr, CARD16 val)
+{
+ int shift;
+
+ if ((addr >= 0xCF8) && (addr <= 0xCFB)) {
+ shift = (addr - 0xCF8) * 8;
+ PciCfg1Addr &= ~(0xffff << shift);
+ PciCfg1Addr |= ((CARD32) val) << shift;
+ return 1;
+ }
+ if ((addr >= 0xCFC) && (addr <= 0xCFF)) {
+ const unsigned offset = addr - 0xCFC;
+
+ if (PRINT_PORT && DEBUG_IO_TRACE())
+ ErrorF(" cfg_outw(%#lx, %4.4x)\n", PciCfg1Addr + offset, val);
+ pci_device_cfg_write_u16(pci_device_for_cfg_address(PciCfg1Addr),
+ val, PCI_OFFSET(PciCfg1Addr) + offset);
+ return 1;
+ }
+ return 0;
+}
+
+static int
+pciCfg1inb(CARD16 addr, CARD8 *val)
+{
+ int shift;
+
+ if ((addr >= 0xCF8) && (addr <= 0xCFB)) {
+ shift = (addr - 0xCF8) * 8;
+ *val = (PciCfg1Addr >> shift) & 0xff;
+ return 1;
+ }
+ if ((addr >= 0xCFC) && (addr <= 0xCFF)) {
+ const unsigned offset = addr - 0xCFC;
+
+ pci_device_cfg_read_u8(pci_device_for_cfg_address(PciCfg1Addr),
+ val, PCI_OFFSET(PciCfg1Addr) + offset);
+ if (PRINT_PORT && DEBUG_IO_TRACE())
+ ErrorF(" cfg_inb(%#lx) = %2.2x\n", PciCfg1Addr + offset, *val);
+ return 1;
+ }
+ return 0;
+}
+
+static int
+pciCfg1outb(CARD16 addr, CARD8 val)
+{
+ int shift;
+
+ if ((addr >= 0xCF8) && (addr <= 0xCFB)) {
+ shift = (addr - 0xCF8) * 8;
+ PciCfg1Addr &= ~(0xff << shift);
+ PciCfg1Addr |= ((CARD32) val) << shift;
+ return 1;
+ }
+ if ((addr >= 0xCFC) && (addr <= 0xCFF)) {
+ const unsigned offset = addr - 0xCFC;
+
+ if (PRINT_PORT && DEBUG_IO_TRACE())
+ ErrorF(" cfg_outb(%#lx, %2.2x)\n", PciCfg1Addr + offset, val);
+ pci_device_cfg_write_u8(pci_device_for_cfg_address(PciCfg1Addr),
+ val, PCI_OFFSET(PciCfg1Addr) + offset);
+ return 1;
+ }
+ return 0;
+}
+
+CARD8
+bios_checksum(const CARD8 *start, int size)
+{
+ CARD8 sum = 0;
+
+ while (size-- > 0)
+ sum += *start++;
+ return sum;
+}
+
+/*
+ * Lock/Unlock legacy VGA. Some Bioses try to be very clever and make
+ * an attempt to detect a legacy ISA card. If they find one they might
+ * act very strange: for example they might configure the card as a
+ * monochrome card. This might cause some drivers to choke.
+ * To avoid this we attempt legacy VGA by writing to all know VGA
+ * disable registers before we call the BIOS initialization and
+ * restore the original values afterwards. In beween we hold our
+ * breath. To get to a (possibly exising) ISA card need to disable
+ * our current PCI card.
+ */
+/*
+ * This is just for booting: we just want to catch pure
+ * legacy vga therefore we don't worry about mmio etc.
+ * This stuff should really go into vgaHW.c. However then
+ * the driver would have to load the vga-module prior to
+ * doing int10.
+ */
+void
+LockLegacyVGA(xf86Int10InfoPtr pInt, legacyVGAPtr vga)
+{
+ vga->save_msr = inb(pInt->ioBase + 0x03CC);
+ vga->save_vse = inb(pInt->ioBase + 0x03C3);
+#ifndef __ia64__
+ vga->save_46e8 = inb(pInt->ioBase + 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);
+#ifndef __ia64__
+ outb(pInt->ioBase + 0x46E8, ~(CARD8)0x08 & vga->save_46e8);
+#endif
+ outb(pInt->ioBase + 0x0102, ~(CARD8)0x01 & vga->save_pos102);
+}
+
+void
+UnlockLegacyVGA(xf86Int10InfoPtr pInt, legacyVGAPtr vga)
+{
+ outb(pInt->ioBase + 0x0102, vga->save_pos102);
+#ifndef __ia64__
+ outb(pInt->ioBase + 0x46E8, vga->save_46e8);
+#endif
+ outb(pInt->ioBase + 0x03C3, vga->save_vse);
+ outb(pInt->ioBase + 0x03C2, vga->save_msr);
+}
+
+#if defined (_PC)
+static void
+SetResetBIOSVars(xf86Int10InfoPtr pInt, Bool set)
+{
+ int pagesize = getpagesize();
+ unsigned char* base = xf86MapVidMem(pInt->scrnIndex,
+ VIDMEM_MMIO, 0, pagesize);
+ int i;
+
+ if (set) {
+ for (i = BIOS_SCRATCH_OFF; i < BIOS_SCRATCH_END; i++)
+ MEM_WW(pInt, i, *(base + i));
+ } else {
+ for (i = BIOS_SCRATCH_OFF; i < BIOS_SCRATCH_END; i++)
+ *(base + i) = MEM_RW(pInt, i);
+ }
+
+ xf86UnMapVidMem(pInt->scrnIndex,base,pagesize);
+}
+
+void
+xf86Int10SaveRestoreBIOSVars(xf86Int10InfoPtr pInt, Bool save)
+{
+ int pagesize = getpagesize();
+ unsigned char* base;
+ int i;
+
+ if (!xf86IsEntityPrimary(pInt->entityIndex)
+ || (!save && !pInt->BIOSScratch))
+ return;
+
+ base = xf86MapVidMem(pInt->scrnIndex, VIDMEM_MMIO, 0, pagesize);
+ base += BIOS_SCRATCH_OFF;
+ if (save) {
+ if ((pInt->BIOSScratch
+ = xnfalloc(BIOS_SCRATCH_LEN)))
+ for (i = 0; i < BIOS_SCRATCH_LEN; i++)
+ *(((char*)pInt->BIOSScratch + i)) = *(base + i);
+ } else {
+ if (pInt->BIOSScratch) {
+ for (i = 0; i < BIOS_SCRATCH_LEN; i++)
+ *(base + i) = *(pInt->BIOSScratch + i);
+ free(pInt->BIOSScratch);
+ pInt->BIOSScratch = NULL;
+ }
+ }
+
+ xf86UnMapVidMem(pInt->scrnIndex,base - BIOS_SCRATCH_OFF ,pagesize);
+}
+#endif
+
+xf86Int10InfoPtr
+xf86InitInt10(int entityIndex)
+{
+ return xf86ExtendedInitInt10(entityIndex, 0);
+}
diff --git a/xorg-server/hw/xfree86/loader/loader.c b/xorg-server/hw/xfree86/loader/loader.c
index dce3b22f6..159b61198 100644
--- a/xorg-server/hw/xfree86/loader/loader.c
+++ b/xorg-server/hw/xfree86/loader/loader.c
@@ -1,228 +1,208 @@
-/*
- * Copyright 1995-1998 by Metro Link, Inc.
- *
- * 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, Inc. not be used in
- * advertising or publicity pertaining to distribution of the software without
- * specific, written prior permission. Metro Link, Inc. makes no
- * representations about the suitability of this software for any purpose.
- * It is provided "as is" without express or implied warranty.
- *
- * METRO LINK, INC. DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
- * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
- * EVENT SHALL METRO LINK, INC. 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) 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).
- */
-
-#ifdef HAVE_XORG_CONFIG_H
-#include <xorg-config.h>
-#endif
-
-#include <errno.h>
-#include <stdio.h>
-#include <stdlib.h>
-#include <sys/types.h>
-#include <unistd.h>
-#include <sys/stat.h>
-#include <fcntl.h>
-#include <string.h>
-#include <stdarg.h>
-
-#include "os.h"
-#include "loader.h"
-#include "loaderProcs.h"
-#include "xf86.h"
-#include "xf86Priv.h"
-#include "compiler.h"
-
-#ifdef HAVE_DLFCN_H
-
-#include <dlfcn.h>
-#include <X11/Xos.h>
-
-#if defined(DL_LAZY)
-#define DLOPEN_LAZY DL_LAZY
-#elif defined(RTLD_LAZY)
-#define DLOPEN_LAZY RTLD_LAZY
-#elif defined(__FreeBSD__)
-#define DLOPEN_LAZY 1
-#else
-#define DLOPEN_LAZY 0
-#endif
-
-#if defined(LD_GLOBAL)
-#define DLOPEN_GLOBAL LD_GLOBAL
-#elif defined(RTLD_GLOBAL)
-#define DLOPEN_GLOBAL RTLD_GLOBAL
-#else
-#define DLOPEN_GLOBAL 0
-#endif
-
-#else
-#error i have no dynamic linker and i must scream
-#endif
-
-extern void *xorg_symbols[];
-
-void
-LoaderInit(void)
-{
- xf86MsgVerb(X_INFO, 2, "Loader magic: %p\n", (void *)xorg_symbols);
- xf86MsgVerb(X_INFO, 2, "Module ABI versions:\n");
- xf86ErrorFVerb(2, "\t%s: %d.%d\n", ABI_CLASS_ANSIC,
- GET_ABI_MAJOR(LoaderVersionInfo.ansicVersion),
- GET_ABI_MINOR(LoaderVersionInfo.ansicVersion));
- xf86ErrorFVerb(2, "\t%s: %d.%d\n", ABI_CLASS_VIDEODRV,
- GET_ABI_MAJOR(LoaderVersionInfo.videodrvVersion),
- GET_ABI_MINOR(LoaderVersionInfo.videodrvVersion));
- xf86ErrorFVerb(2, "\t%s : %d.%d\n", ABI_CLASS_XINPUT,
- GET_ABI_MAJOR(LoaderVersionInfo.xinputVersion),
- GET_ABI_MINOR(LoaderVersionInfo.xinputVersion));
- xf86ErrorFVerb(2, "\t%s : %d.%d\n", ABI_CLASS_EXTENSION,
- GET_ABI_MAJOR(LoaderVersionInfo.extensionVersion),
- GET_ABI_MINOR(LoaderVersionInfo.extensionVersion));
-
-#if defined(__UNIXWARE__) && !defined(__GNUC__)
- /* For UnixWare we need to load the C Runtime libraries which are
- * normally auto-linked by the compiler. Otherwise we are bound to
- * see unresolved symbols when trying to use the type "long long".
- * Obviously, this does not apply if the GNU C compiler is used.
- */
- {
- int errmaj, errmin, wasLoaded; /* place holders */
- char *xcrtpath = DEFAULT_MODULE_PATH "/libcrt.a";
- char *uwcrtpath = "/usr/ccs/lib/libcrt.a";
- char *path;
- struct stat st;
-
- if(stat(xcrtpath, &st) < 0)
- path = uwcrtpath; /* fallback: try to get libcrt.a from the uccs */
- else
- path = xcrtpath; /* get the libcrt.a we compiled with */
- LoaderOpen (path, &errmaj, &errmin, &wasLoaded, 0);
- }
-#endif
-}
-
-/* Public Interface to the loader. */
-
-void *
-LoaderOpen(const char *module, int *errmaj, int *errmin)
-{
- void *ret;
-
-#if defined(DEBUG)
- ErrorF("LoaderOpen(%s)\n", module);
-#endif
-
- xf86Msg(X_INFO, "Loading %s\n", module);
-
- if (!(ret = dlopen(module, DLOPEN_LAZY | DLOPEN_GLOBAL))) {
- xf86Msg(X_ERROR, "Failed to load %s: %s\n", module, dlerror());
- if (errmaj)
- *errmaj = LDR_NOLOAD;
- if (errmin)
- *errmin = LDR_NOLOAD;
- return NULL;
- }
-
- return ret;
-}
-
-void *
-LoaderSymbol(const char *name)
-{
- static void *global_scope = NULL;
- void *p;
-
- p = dlsym(RTLD_DEFAULT, name);
- if (p != NULL)
- return p;
-
- if (!global_scope)
- global_scope = dlopen(NULL, DLOPEN_LAZY | DLOPEN_GLOBAL);
-
- if (global_scope)
- return dlsym(global_scope, name);
-
- return NULL;
-}
-
-void
-LoaderUnload(const char *name, void *handle)
-{
- xf86Msg(X_INFO, "Unloading %s\n", name);
- if (handle)
- dlclose(handle);
-}
-
-unsigned long LoaderOptions = 0;
-
-void
-LoaderSetOptions(unsigned long opts)
-{
- LoaderOptions |= opts;
-}
-
-Bool
-LoaderShouldIgnoreABI(void)
-{
- return (LoaderOptions & LDR_OPT_ABI_MISMATCH_NONFATAL) != 0;
-}
-
-int
-LoaderGetABIVersion(const char *abiclass)
-{
- struct {
- const char *name;
- int version;
- } classes[] = {
- { ABI_CLASS_ANSIC, LoaderVersionInfo.ansicVersion },
- { ABI_CLASS_VIDEODRV, LoaderVersionInfo.videodrvVersion },
- { ABI_CLASS_XINPUT, LoaderVersionInfo.xinputVersion },
- { ABI_CLASS_EXTENSION, LoaderVersionInfo.extensionVersion },
- { ABI_CLASS_FONT, LoaderVersionInfo.fontVersion },
- { NULL, 0 }
- };
- int i;
-
- for(i = 0; classes[i].name; i++) {
- if(!strcmp(classes[i].name, abiclass)) {
- return classes[i].version;
- }
- }
-
- return 0;
-}
+/*
+ * Copyright 1995-1998 by Metro Link, Inc.
+ *
+ * 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, Inc. not be used in
+ * advertising or publicity pertaining to distribution of the software without
+ * specific, written prior permission. Metro Link, Inc. makes no
+ * representations about the suitability of this software for any purpose.
+ * It is provided "as is" without express or implied warranty.
+ *
+ * METRO LINK, INC. DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
+ * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
+ * EVENT SHALL METRO LINK, INC. 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) 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).
+ */
+
+#ifdef HAVE_XORG_CONFIG_H
+#include <xorg-config.h>
+#endif
+
+#include <errno.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <sys/types.h>
+#include <unistd.h>
+#include <sys/stat.h>
+#include <fcntl.h>
+#include <string.h>
+#include <stdarg.h>
+
+#include "os.h"
+#include "loader.h"
+#include "loaderProcs.h"
+#include "xf86.h"
+#include "xf86Priv.h"
+#include "compiler.h"
+
+#ifdef HAVE_DLFCN_H
+
+#include <dlfcn.h>
+#include <X11/Xos.h>
+
+#if defined(DL_LAZY)
+#define DLOPEN_LAZY DL_LAZY
+#elif defined(RTLD_LAZY)
+#define DLOPEN_LAZY RTLD_LAZY
+#elif defined(__FreeBSD__)
+#define DLOPEN_LAZY 1
+#else
+#define DLOPEN_LAZY 0
+#endif
+
+#if defined(LD_GLOBAL)
+#define DLOPEN_GLOBAL LD_GLOBAL
+#elif defined(RTLD_GLOBAL)
+#define DLOPEN_GLOBAL RTLD_GLOBAL
+#else
+#define DLOPEN_GLOBAL 0
+#endif
+
+#else
+#error i have no dynamic linker and i must scream
+#endif
+
+extern void *xorg_symbols[];
+
+void
+LoaderInit(void)
+{
+ xf86MsgVerb(X_INFO, 2, "Loader magic: %p\n", (void *)xorg_symbols);
+ xf86MsgVerb(X_INFO, 2, "Module ABI versions:\n");
+ xf86ErrorFVerb(2, "\t%s: %d.%d\n", ABI_CLASS_ANSIC,
+ GET_ABI_MAJOR(LoaderVersionInfo.ansicVersion),
+ GET_ABI_MINOR(LoaderVersionInfo.ansicVersion));
+ xf86ErrorFVerb(2, "\t%s: %d.%d\n", ABI_CLASS_VIDEODRV,
+ GET_ABI_MAJOR(LoaderVersionInfo.videodrvVersion),
+ GET_ABI_MINOR(LoaderVersionInfo.videodrvVersion));
+ xf86ErrorFVerb(2, "\t%s : %d.%d\n", ABI_CLASS_XINPUT,
+ GET_ABI_MAJOR(LoaderVersionInfo.xinputVersion),
+ GET_ABI_MINOR(LoaderVersionInfo.xinputVersion));
+ xf86ErrorFVerb(2, "\t%s : %d.%d\n", ABI_CLASS_EXTENSION,
+ GET_ABI_MAJOR(LoaderVersionInfo.extensionVersion),
+ GET_ABI_MINOR(LoaderVersionInfo.extensionVersion));
+
+}
+
+/* Public Interface to the loader. */
+
+void *
+LoaderOpen(const char *module, int *errmaj, int *errmin)
+{
+ void *ret;
+
+#if defined(DEBUG)
+ ErrorF("LoaderOpen(%s)\n", module);
+#endif
+
+ xf86Msg(X_INFO, "Loading %s\n", module);
+
+ if (!(ret = dlopen(module, DLOPEN_LAZY | DLOPEN_GLOBAL))) {
+ xf86Msg(X_ERROR, "Failed to load %s: %s\n", module, dlerror());
+ if (errmaj)
+ *errmaj = LDR_NOLOAD;
+ if (errmin)
+ *errmin = LDR_NOLOAD;
+ return NULL;
+ }
+
+ return ret;
+}
+
+void *
+LoaderSymbol(const char *name)
+{
+ static void *global_scope = NULL;
+ void *p;
+
+ p = dlsym(RTLD_DEFAULT, name);
+ if (p != NULL)
+ return p;
+
+ if (!global_scope)
+ global_scope = dlopen(NULL, DLOPEN_LAZY | DLOPEN_GLOBAL);
+
+ if (global_scope)
+ return dlsym(global_scope, name);
+
+ return NULL;
+}
+
+void
+LoaderUnload(const char *name, void *handle)
+{
+ xf86Msg(X_INFO, "Unloading %s\n", name);
+ if (handle)
+ dlclose(handle);
+}
+
+unsigned long LoaderOptions = 0;
+
+void
+LoaderSetOptions(unsigned long opts)
+{
+ LoaderOptions |= opts;
+}
+
+Bool
+LoaderShouldIgnoreABI(void)
+{
+ return (LoaderOptions & LDR_OPT_ABI_MISMATCH_NONFATAL) != 0;
+}
+
+int
+LoaderGetABIVersion(const char *abiclass)
+{
+ struct {
+ const char *name;
+ int version;
+ } classes[] = {
+ { ABI_CLASS_ANSIC, LoaderVersionInfo.ansicVersion },
+ { ABI_CLASS_VIDEODRV, LoaderVersionInfo.videodrvVersion },
+ { ABI_CLASS_XINPUT, LoaderVersionInfo.xinputVersion },
+ { ABI_CLASS_EXTENSION, LoaderVersionInfo.extensionVersion },
+ { ABI_CLASS_FONT, LoaderVersionInfo.fontVersion },
+ { NULL, 0 }
+ };
+ int i;
+
+ for(i = 0; classes[i].name; i++) {
+ if(!strcmp(classes[i].name, abiclass)) {
+ return classes[i].version;
+ }
+ }
+
+ return 0;
+}
diff --git a/xorg-server/hw/xfree86/loader/os.c b/xorg-server/hw/xfree86/loader/os.c
index 5acce0024..6b5ac7e86 100644
--- a/xorg-server/hw/xfree86/loader/os.c
+++ b/xorg-server/hw/xfree86/loader/os.c
@@ -50,8 +50,6 @@
#define OSNAME "openbsd"
#elif defined(__GNU__)
#define OSNAME "hurd"
-#elif defined(__SCO__)
-#define OSNAME "sco"
#elif defined(SVR4) && defined(sun)
#define OSNAME "solaris"
#elif defined(SVR5)
diff --git a/xorg-server/hw/xfree86/loader/sdksyms.sh b/xorg-server/hw/xfree86/loader/sdksyms.sh
index c25aaf010..f60b8ed74 100644
--- a/xorg-server/hw/xfree86/loader/sdksyms.sh
+++ b/xorg-server/hw/xfree86/loader/sdksyms.sh
@@ -1,420 +1,424 @@
-#!/bin/sh
-
-cat > sdksyms.c << EOF
-/* This file is automatically generated by sdksyms.sh. */
-#pragma GCC diagnostic ignored "-Wdeprecated-declarations"
-
-#ifdef HAVE_XORG_CONFIG_H
-#include <xorg-config.h>
-#endif
-
-
-/* These must be included first */
-#include "misc.h"
-#include "miscstruct.h"
-
-
-/* render/Makefile.am */
-#include "picture.h"
-#include "mipict.h"
-#include "glyphstr.h"
-#include "picturestr.h"
-
-
-/* fb/Makefile.am -- module */
-/*
-#include "fb.h"
-#include "fbrop.h"
-#include "fboverlay.h"
-#include "wfbrename.h"
-#include "fbpict.h"
- */
-
-
-/* miext/shadow/Makefile.am -- module */
-/*
-#include "shadow.h"
- */
-
-
-/* miext/damage/Makefile.am */
-#include "damage.h"
-#include "damagestr.h"
-
-/* miext/sync/Makefile.am */
-#include "misync.h"
-#include "misyncstr.h"
-
-/* Xext/Makefile.am -- half is module, half is builtin */
-/*
-#include "xvdix.h"
-#include "xvmcext.h"
- */
-#include "geext.h"
-#include "geint.h"
-#include "shmint.h"
-#include "syncsdk.h"
-#if XINERAMA
-# include "panoramiXsrv.h"
-# include "panoramiX.h"
-#endif
-
-
-/* hw/xfree86/int10/Makefile.am -- module */
-/*
-#include "xf86int10.h"
- */
-
-
-/* hw/xfree86/i2c/Makefile.am -- "mostly" modules */
-#include "xf86i2c.h"
-/*
-#include "bt829.h"
-#include "fi1236.h"
-#include "msp3430.h"
-#include "tda8425.h"
-#include "tda9850.h"
-#include "tda9885.h"
-#include "uda1380.h"
-#include "i2c_def.h"
- */
-
-
-/* hw/xfree86/modes/Makefile.am */
-#include "xf86Crtc.h"
-#include "xf86Modes.h"
-#include "xf86RandR12.h"
-/* #include "xf86Rename.h" */
-
-
-/* hw/xfree86/ddc/Makefile.am */
-#include "edid.h"
-#include "xf86DDC.h"
-
-
-/* hw/xfree86/dri2/Makefile.am -- module */
-/*
-#if DRI2
-# include "dri2.h"
-#endif
- */
-
-
-/* hw/xfree86/vgahw/Makefile.am -- module */
-/*
-#include "vgaHW.h"
- */
-
-
-/* hw/xfree86/fbdevhw/Makefile.am -- module */
-/*
-#include "fbdevhw.h"
- */
-
-
-/* hw/xfree86/common/Makefile.am */
-#include "compiler.h"
-#include "fourcc.h"
-#include "xf86.h"
-#include "xf86Module.h"
-#include "xf86Opt.h"
-#include "xf86PciInfo.h"
-#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"
-# include "xf86xvmc.h"
-# include "xf86xvpriv.h"
-#endif
-/* XF86VidMode code is in libextmod module */
-/*
-#if XF86VIDMODE
-# include "vidmodeproc.h"
-#endif
- */
-#include "xorgVersion.h"
-#if defined(__sparc__) || defined(__sparc)
-# include "xf86sbusBus.h"
-#endif
-
-
-/* hw/xfree86/ramdac/Makefile.am */
-#include "BT.h"
-#include "IBM.h"
-#include "TI.h"
-#include "xf86Cursor.h"
-#include "xf86RamDac.h"
-
-
-/* hw/xfree86/shadowfb/Makefile.am -- module */
-/*
-#include "shadowfb.h"
- */
-
-
-/* hw/xfree86/os-support/solaris/Makefile.am */
-#if defined(sun386)
-# include "agpgart.h"
-#endif
-
-
-/* hw/xfree86/os-support/Makefile.am */
-#include "xf86_OSproc.h"
-#include "xf86_OSlib.h"
-
-
-/* hw/xfree86/os-support/bus/Makefile.am */
-#include "xf86Pci.h"
-#if defined(__sparc__) || defined(__sparc)
-# include "xf86Sbus.h"
-#endif
-
-
-/* hw/xfree86/xaa/Makefile.am -- module */
-/*
-#include "xaa.h"
-#include "xaalocal.h"
-#include "xaarop.h"
- */
-
-
-/* hw/xfree86/dixmods/extmod/Makefile.am -- module */
-/*
-#include "dgaproc.h"
- */
-
-
-/* hw/xfree86/parser/Makefile.am */
-#include "xf86Parser.h"
-#include "xf86Optrec.h"
-
-
-/* hw/xfree86/vbe/Makefile.am -- module */
-/*
-#include "vbe.h"
-#include "vbeModes.h"
- */
-
-
-/* hw/xfree86/dri/Makefile.am -- module */
-/*
-#if XF86DRI
-# include "dri.h"
-# include "sarea.h"
-# include "dristruct.h"
-#endif
- */
-
-
-/* mi/Makefile.am */
-#include "micmap.h"
-#include "miline.h"
-#include "mipointer.h"
-#include "mi.h"
-#include "mibstore.h"
-#include "migc.h"
-#include "mipointrst.h"
-#include "mizerarc.h"
-#include "micoord.h"
-#include "mifillarc.h"
-#include "mispans.h"
-#include "miwideline.h"
-#include "mistruct.h"
-#include "mifpoly.h"
-#include "mioverlay.h"
-
-
-/* randr/Makefile.am */
-#include "randrstr.h"
-#include "rrtransform.h"
-
-
-/* dbe/Makefile.am -- module */
-/*
-#include "dbestruct.h"
- */
-
-
-/* exa/Makefile.am -- module */
-/*
-#include "exa.h"
- */
-
-
-/* xfixes/Makefile.am */
-#include "xfixes.h"
-
-
-/* include/Makefile.am */
-#include "XIstubs.h"
-#include "Xprintf.h"
-#include "closestr.h"
-#include "closure.h"
-#include "colormap.h"
-#include "colormapst.h"
-#include "hotplug.h"
-#include "cursor.h"
-#include "cursorstr.h"
-#include "dix.h"
-#include "dixaccess.h"
-#include "dixevents.h"
-#include "dixfont.h"
-#include "dixfontstr.h"
-#include "dixgrabs.h"
-#include "dixstruct.h"
-#include "exevents.h"
-#include "extension.h"
-#include "extinit.h"
-#include "extnsionst.h"
-#include "gc.h"
-#include "gcstruct.h"
-#include "globals.h"
-#include "input.h"
-#include "inputstr.h"
-/* already included */
-/*
-#include "misc.h"
-#include "miscstruct.h"
- */
-#include "opaque.h"
-#include "os.h"
-#include "pixmap.h"
-#include "pixmapstr.h"
-#include "privates.h"
-#include "property.h"
-#include "propertyst.h"
-#include "ptrveloc.h"
-#include "region.h"
-#include "regionstr.h"
-#include "registry.h"
-#include "resource.h"
-#include "rgb.h"
-#include "screenint.h"
-#include "scrnintstr.h"
-#include "selection.h"
-#include "servermd.h"
-#include "site.h"
-#include "swaprep.h"
-#include "swapreq.h"
-#include "validate.h"
-#include "window.h"
-#include "windowstr.h"
-#include "xace.h"
-#include "xkbfile.h"
-#include "xkbsrv.h"
-#include "xkbstr.h"
-#include "xkbrules.h"
-#include "xserver-properties.h"
-
-EOF
-
-topdir=$1
-shift
-LC_ALL=C
-export LC_ALL
-${CPP:-cpp} "$@" -DXorgLoader sdksyms.c | ${AWK:-awk} -v topdir=$topdir '
-BEGIN {
- sdk = 0;
- print("/*");
- print(" * These symbols are referenced to ensure they");
- print(" * will be available in the X Server binary.");
- print(" */");
- printf("/* topdir=%s */\n", topdir);
- print("_X_HIDDEN void *xorg_symbols[] = {");
-
- printf("sdksyms.c:") > "sdksyms.dep";
-}
-/^# [0-9]+ "/ {
- # Process text after a include in a relative path or when the
- # processed file has a basename matching $top_srcdir.
- # Note that indexing starts at 1; 0 means no match, and there
- # is a starting ".
- sdk = $3 !~ /^"\// || index($3, topdir) == 2;
-
- if (sdk && $3 ~ /\.h"$/) {
- # remove quotes
- gsub(/"/, "", $3);
- line = $2;
- header = $3;
- if (! headers[$3]) {
- printf(" \\\n %s", $3) >> "sdksyms.dep";
- headers[$3] = 1;
- }
- }
- next;
-}
-
-/^extern[ ]/ {
- if (sdk) {
- n = 3;
-
- # skip attribute, if any
- while ($n ~ /^(__attribute__|__global)/ ||
- # skip modifiers, if any
- $n ~ /^\*?(unsigned|const|volatile|struct)$/ ||
- # skip pointer
- $n ~ /\*$/)
- n++;
-
- # type specifier may not be set, as in
- # extern _X_EXPORT unsigned name(...)
- if ($n !~ /[^a-zA-Z0-9_]/)
- n++;
-
- # match
- # extern _X_EXPORT type (* name[])(...)
- if ($n ~ /^[^a-zA-Z0-9_]+$/)
- n++;
-
- # match
- # extern _X_EXPORT const name *const ...
- if ($n ~ /^([^a-zA-Z0-9_]+)?const$/)
- n++;
-
- # actual name may be in the next line, as in
- # extern _X_EXPORT type
- # possibly ending with a *
- # name(...)
- if ($n == "" || $n ~ /^\*+$/) {
- getline;
- n = 1;
- }
-
- # dont modify $0 or $n
- symbol = $n;
-
- # remove starting non word chars
- sub(/^[^a-zA-Z0-9_]+/, "",symbol);
-
- # remove from first non word to end of line
- sub(/[^a-zA-Z0-9_].*/, "", symbol);
-
- #print;
- printf(" (void *) &%-50s /* %s:%s */\n", symbol ",", header, line);
- }
-}
-
-{
- line++;
-}
-
-END {
- print("};");
-
- print("") >> "sdksyms.dep";
-}' > _sdksyms.c
-
-STATUS=$?
-
-cat _sdksyms.c >> sdksyms.c
-rm _sdksyms.c
-
-[ $? != 0 ] && exit $?
-
-exit $STATUS
+#!/bin/sh
+
+cat > sdksyms.c << EOF
+/* This file is automatically generated by sdksyms.sh. */
+#pragma GCC diagnostic ignored "-Wdeprecated-declarations"
+
+#ifdef HAVE_XORG_CONFIG_H
+#include <xorg-config.h>
+#endif
+
+
+/* These must be included first */
+#include "misc.h"
+#include "miscstruct.h"
+
+
+/* render/Makefile.am */
+#include "picture.h"
+#include "mipict.h"
+#include "glyphstr.h"
+#include "picturestr.h"
+
+
+/* fb/Makefile.am -- module */
+/*
+#include "fb.h"
+#include "fbrop.h"
+#include "fboverlay.h"
+#include "wfbrename.h"
+#include "fbpict.h"
+ */
+
+
+/* miext/shadow/Makefile.am -- module */
+/*
+#include "shadow.h"
+ */
+
+
+/* miext/damage/Makefile.am */
+#include "damage.h"
+#include "damagestr.h"
+
+/* miext/sync/Makefile.am */
+#include "misync.h"
+#include "misyncstr.h"
+
+/* Xext/Makefile.am -- half is module, half is builtin */
+/*
+#include "xvdix.h"
+#include "xvmcext.h"
+ */
+#include "geext.h"
+#include "geint.h"
+#include "shmint.h"
+#include "syncsdk.h"
+#if XINERAMA
+# include "panoramiXsrv.h"
+# include "panoramiX.h"
+#endif
+
+
+/* hw/xfree86/int10/Makefile.am -- module */
+/*
+#include "xf86int10.h"
+ */
+
+
+/* hw/xfree86/i2c/Makefile.am -- "mostly" modules */
+#include "xf86i2c.h"
+/*
+#include "bt829.h"
+#include "fi1236.h"
+#include "msp3430.h"
+#include "tda8425.h"
+#include "tda9850.h"
+#include "tda9885.h"
+#include "uda1380.h"
+#include "i2c_def.h"
+ */
+
+
+/* hw/xfree86/modes/Makefile.am */
+#include "xf86Crtc.h"
+#include "xf86Modes.h"
+#include "xf86RandR12.h"
+/* #include "xf86Rename.h" */
+
+
+/* hw/xfree86/ddc/Makefile.am */
+#include "edid.h"
+#include "xf86DDC.h"
+
+
+/* hw/xfree86/dri2/Makefile.am -- module */
+/*
+#if DRI2
+# include "dri2.h"
+#endif
+ */
+
+
+/* hw/xfree86/vgahw/Makefile.am -- module */
+/*
+#include "vgaHW.h"
+ */
+
+
+/* hw/xfree86/fbdevhw/Makefile.am -- module */
+/*
+#include "fbdevhw.h"
+ */
+
+
+/* hw/xfree86/common/Makefile.am */
+#include "compiler.h"
+#include "fourcc.h"
+#include "xf86.h"
+#include "xf86Module.h"
+#include "xf86Opt.h"
+#include "xf86PciInfo.h"
+#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"
+# include "xf86xvmc.h"
+# include "xf86xvpriv.h"
+#endif
+/* XF86VidMode code is in libextmod module */
+/*
+#if XF86VIDMODE
+# include "vidmodeproc.h"
+#endif
+ */
+#include "xorgVersion.h"
+#if defined(__sparc__) || defined(__sparc)
+# include "xf86sbusBus.h"
+#endif
+
+
+/* hw/xfree86/ramdac/Makefile.am */
+#include "BT.h"
+#include "IBM.h"
+#include "TI.h"
+#include "xf86Cursor.h"
+#include "xf86RamDac.h"
+
+
+/* hw/xfree86/shadowfb/Makefile.am -- module */
+/*
+#include "shadowfb.h"
+ */
+
+
+/* hw/xfree86/os-support/solaris/Makefile.am */
+#if defined(sun386)
+# include "agpgart.h"
+#endif
+
+
+/* hw/xfree86/os-support/Makefile.am */
+#include "xf86_OSproc.h"
+#include "xf86_OSlib.h"
+
+
+/* hw/xfree86/os-support/bus/Makefile.am */
+#include "xf86Pci.h"
+#if defined(__sparc__) || defined(__sparc)
+# include "xf86Sbus.h"
+#endif
+
+
+/* hw/xfree86/xaa/Makefile.am -- module */
+/*
+#include "xaa.h"
+#include "xaalocal.h"
+#include "xaarop.h"
+ */
+
+
+/* hw/xfree86/dixmods/extmod/Makefile.am -- module */
+/*
+#include "dgaproc.h"
+ */
+
+
+/* hw/xfree86/parser/Makefile.am */
+#include "xf86Parser.h"
+#include "xf86Optrec.h"
+
+
+/* hw/xfree86/vbe/Makefile.am -- module */
+/*
+#include "vbe.h"
+#include "vbeModes.h"
+ */
+
+
+/* hw/xfree86/dri/Makefile.am -- module */
+/*
+#if XF86DRI
+# include "dri.h"
+# include "sarea.h"
+# include "dristruct.h"
+#endif
+ */
+
+
+/* mi/Makefile.am */
+#include "micmap.h"
+#include "miline.h"
+#include "mipointer.h"
+#include "mi.h"
+#include "mibstore.h"
+#include "migc.h"
+#include "mipointrst.h"
+#include "mizerarc.h"
+#include "micoord.h"
+#include "mifillarc.h"
+#include "mispans.h"
+#include "miwideline.h"
+#include "mistruct.h"
+#include "mifpoly.h"
+#include "mioverlay.h"
+
+
+/* randr/Makefile.am */
+#include "randrstr.h"
+#include "rrtransform.h"
+
+
+/* dbe/Makefile.am -- module */
+/*
+#include "dbestruct.h"
+ */
+
+
+/* exa/Makefile.am -- module */
+/*
+#include "exa.h"
+ */
+
+
+/* xfixes/Makefile.am */
+#include "xfixes.h"
+
+
+/* include/Makefile.am */
+#include "XIstubs.h"
+#include "Xprintf.h"
+#include "closestr.h"
+#include "closure.h"
+#include "colormap.h"
+#include "colormapst.h"
+#include "hotplug.h"
+#include "cursor.h"
+#include "cursorstr.h"
+#include "dix.h"
+#include "dixaccess.h"
+#include "dixevents.h"
+#include "dixfont.h"
+#include "dixfontstr.h"
+#include "dixgrabs.h"
+#include "dixstruct.h"
+#include "exevents.h"
+#include "extension.h"
+#include "extinit.h"
+#include "extnsionst.h"
+#include "gc.h"
+#include "gcstruct.h"
+#include "globals.h"
+#include "input.h"
+#include "inputstr.h"
+/* already included */
+/*
+#include "misc.h"
+#include "miscstruct.h"
+ */
+#include "opaque.h"
+#include "os.h"
+#include "pixmap.h"
+#include "pixmapstr.h"
+#include "privates.h"
+#include "property.h"
+#include "propertyst.h"
+#include "ptrveloc.h"
+#include "region.h"
+#include "regionstr.h"
+#include "registry.h"
+#include "resource.h"
+#include "rgb.h"
+#include "screenint.h"
+#include "scrnintstr.h"
+#include "selection.h"
+#include "servermd.h"
+#include "site.h"
+#include "swaprep.h"
+#include "swapreq.h"
+#include "validate.h"
+#include "window.h"
+#include "windowstr.h"
+#include "xace.h"
+#include "xkbfile.h"
+#include "xkbsrv.h"
+#include "xkbstr.h"
+#include "xkbrules.h"
+#include "xserver-properties.h"
+
+EOF
+
+topdir=$1
+shift
+LC_ALL=C
+export LC_ALL
+${CPP:-cpp} "$@" -DXorgLoader sdksyms.c | ${AWK:-awk} -v topdir=$topdir '
+BEGIN {
+ sdk = 0;
+ print("/*");
+ print(" * These symbols are referenced to ensure they");
+ print(" * will be available in the X Server binary.");
+ print(" */");
+ printf("/* topdir=%s */\n", topdir);
+ print("_X_HIDDEN void *xorg_symbols[] = {");
+
+ printf("sdksyms.c:") > "sdksyms.dep";
+}
+/^# [0-9]+ "/ {
+ # Process text after a include in a relative path or when the
+ # processed file has a basename matching $top_srcdir.
+ # Note that indexing starts at 1; 0 means no match, and there
+ # is a starting ".
+ sdk = $3 !~ /^"\// || index($3, topdir) == 2;
+
+ if (sdk && $3 ~ /\.h"$/) {
+ # remove quotes
+ gsub(/"/, "", $3);
+ line = $2;
+ header = $3;
+ if (! headers[$3]) {
+ printf(" \\\n %s", $3) >> "sdksyms.dep";
+ headers[$3] = 1;
+ }
+ }
+ next;
+}
+
+/^extern[ ]/ {
+ if (sdk) {
+ n = 3;
+
+ # skip attribute, if any
+ while ($n ~ /^(__attribute__|__global)/ ||
+ # skip modifiers, if any
+ $n ~ /^\*?(unsigned|const|volatile|struct)$/ ||
+ # skip pointer
+ $n ~ /^[a-zA-Z0-9_]*\*$/)
+ n++;
+
+ # type specifier may not be set, as in
+ # extern _X_EXPORT unsigned name(...)
+ if ($n !~ /[^a-zA-Z0-9_]/)
+ n++;
+
+ # go back if we are at the parameter list already
+ if ($n ~ /^[(]([^*].*)?$/)
+ n--;
+
+ # match
+ # extern _X_EXPORT type (* name[])(...)
+ if ($n ~ /^[^a-zA-Z0-9_]+$/)
+ n++;
+
+ # match
+ # extern _X_EXPORT const name *const ...
+ if ($n ~ /^([^a-zA-Z0-9_]+)?const$/)
+ n++;
+
+ # actual name may be in the next line, as in
+ # extern _X_EXPORT type
+ # possibly ending with a *
+ # name(...)
+ if ($n == "" || $n ~ /^\*+$/) {
+ getline;
+ n = 1;
+ }
+
+ # dont modify $0 or $n
+ symbol = $n;
+
+ # remove starting non word chars
+ sub(/^[^a-zA-Z0-9_]+/, "",symbol);
+
+ # remove from first non word to end of line
+ sub(/[^a-zA-Z0-9_].*/, "", symbol);
+
+ #print;
+ printf(" (void *) &%-50s /* %s:%s */\n", symbol ",", header, line);
+ }
+}
+
+{
+ line++;
+}
+
+END {
+ print("};");
+
+ print("") >> "sdksyms.dep";
+}' > _sdksyms.c
+
+STATUS=$?
+
+cat _sdksyms.c >> sdksyms.c
+rm _sdksyms.c
+
+[ $? != 0 ] && exit $?
+
+exit $STATUS
diff --git a/xorg-server/hw/xfree86/modes/xf86EdidModes.c b/xorg-server/hw/xfree86/modes/xf86EdidModes.c
index f8cd9a0ca..d9ece7a14 100644
--- a/xorg-server/hw/xfree86/modes/xf86EdidModes.c
+++ b/xorg-server/hw/xfree86/modes/xf86EdidModes.c
@@ -1,1211 +1,1216 @@
-/*
- * Copyright 2006 Luc Verhaegen.
- * Copyright 2008 Red Hat, 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, 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
- * 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.
- */
-
-/**
- * @file This file covers code to convert a xf86MonPtr containing EDID-probed
- * information into a list of modes, including applying monitor-specific
- * quirks to fix broken EDID data.
- */
-#ifdef HAVE_XORG_CONFIG_H
-#include <xorg-config.h>
-#else
-#ifdef HAVE_CONFIG_H
-#include <config.h>
-#endif
-#endif
-
-#define _PARSE_EDID_
-#include "xf86.h"
-#include "xf86DDC.h"
-#include <X11/Xatom.h>
-#include "property.h"
-#include "propertyst.h"
-#include "xf86Crtc.h"
-#include <string.h>
-#include <math.h>
-
-static void handle_detailed_rblank(struct detailed_monitor_section *det_mon,
- void *data)
-{
- if (det_mon->type == DS_RANGES)
- if (det_mon->section.ranges.supported_blanking & CVT_REDUCED)
- *(Bool*)data = TRUE;
-}
-
-static Bool
-xf86MonitorSupportsReducedBlanking(xf86MonPtr DDC)
-{
- /* EDID 1.4 explicitly defines RB support */
- if (DDC->ver.revision >= 4) {
- Bool ret = FALSE;
-
- xf86ForEachDetailedBlock(DDC, handle_detailed_rblank, &ret);
- return ret;
- }
-
- /* For anything older, assume digital means RB support. Boo. */
- if (DDC->features.input_type)
- return TRUE;
-
- return FALSE;
-}
-
-static Bool quirk_prefer_large_60 (int scrnIndex, xf86MonPtr DDC)
-{
- /* Belinea 10 15 55 */
- if (memcmp (DDC->vendor.name, "MAX", 4) == 0 &&
- ((DDC->vendor.prod_id == 1516) ||
- (DDC->vendor.prod_id == 0x77e)))
- return TRUE;
-
- /* Acer AL1706 */
- if (memcmp (DDC->vendor.name, "ACR", 4) == 0 &&
- DDC->vendor.prod_id == 44358)
- return TRUE;
-
- /* Bug #10814: Samsung SyncMaster 225BW */
- if (memcmp (DDC->vendor.name, "SAM", 4) == 0 &&
- DDC->vendor.prod_id == 596)
- return TRUE;
-
- /* Bug #10545: Samsung SyncMaster 226BW */
- if (memcmp (DDC->vendor.name, "SAM", 4) == 0 &&
- DDC->vendor.prod_id == 638)
- return TRUE;
-
- /* Acer F51 */
- if (memcmp (DDC->vendor.name, "API", 4) == 0 &&
- DDC->vendor.prod_id == 0x7602)
- return TRUE;
-
-
- return FALSE;
-}
-
-static Bool quirk_prefer_large_75 (int scrnIndex, xf86MonPtr DDC)
-{
- /* Bug #11603: Funai Electronics PM36B */
- if (memcmp (DDC->vendor.name, "FCM", 4) == 0 &&
- DDC->vendor.prod_id == 13600)
- return TRUE;
-
- return FALSE;
-}
-
-static Bool quirk_detailed_h_in_cm (int scrnIndex, xf86MonPtr DDC)
-{
- /* Bug #11603: Funai Electronics PM36B */
- if (memcmp (DDC->vendor.name, "FCM", 4) == 0 &&
- DDC->vendor.prod_id == 13600)
- return TRUE;
-
- return FALSE;
-}
-
-static Bool quirk_detailed_v_in_cm (int scrnIndex, xf86MonPtr DDC)
-{
- /* Bug #11603: Funai Electronics PM36B */
- if (memcmp (DDC->vendor.name, "FCM", 4) == 0 &&
- DDC->vendor.prod_id == 13600)
- return TRUE;
-
- /* Bug #21000: LGPhilipsLCD LP154W01-TLAJ */
- if (memcmp (DDC->vendor.name, "LPL", 4) == 0 &&
- DDC->vendor.prod_id == 47360)
- return TRUE;
-
- /* Bug #10304: LGPhilipsLCD LP154W01-A5 */
- if (memcmp(DDC->vendor.name, "LPL", 4) == 0 &&
- DDC->vendor.prod_id == 0)
- return TRUE;
-
- /* Bug #24482: LGPhilipsLCD LP154W01-TLA1 */
- if (memcmp(DDC->vendor.name, "LPL", 4) == 0 &&
- DDC->vendor.prod_id == 0x2a00)
- return TRUE;
-
- /* Bug #21750: Samsung Syncmaster 2333HD */
- if (memcmp (DDC->vendor.name, "SAM", 4) == 0 &&
- DDC->vendor.prod_id == 1157)
- return TRUE;
-
- return FALSE;
-}
-
-static Bool quirk_detailed_use_maximum_size (int scrnIndex, xf86MonPtr DDC)
-{
- /* Bug #21324: Iiyama Vision Master 450 */
- if (memcmp (DDC->vendor.name, "IVM", 4) == 0 &&
- DDC->vendor.prod_id == 6400)
- return TRUE;
-
- return FALSE;
-}
-
-static Bool quirk_135_clock_too_high (int scrnIndex, xf86MonPtr DDC)
-{
- /* Envision Peripherals, Inc. EN-7100e. See bug #9550. */
- if (memcmp (DDC->vendor.name, "EPI", 4) == 0 &&
- DDC->vendor.prod_id == 59264)
- return TRUE;
-
- return FALSE;
-}
-
-static Bool quirk_first_detailed_preferred (int scrnIndex, xf86MonPtr DDC)
-{
- /* Philips 107p5 CRT. Reported on xorg@ with pastebin. */
- if (memcmp (DDC->vendor.name, "PHL", 4) == 0 &&
- DDC->vendor.prod_id == 57364)
- return TRUE;
-
- /* Proview AY765C 17" LCD. See bug #15160*/
- if (memcmp (DDC->vendor.name, "PTS", 4) == 0 &&
- DDC->vendor.prod_id == 765)
- return TRUE;
-
- /* ACR of some sort RH #284231 */
- if (memcmp (DDC->vendor.name, "ACR", 4) == 0 &&
- DDC->vendor.prod_id == 2423)
- return TRUE;
-
- /* Peacock Ergovision 19. See rh#492359 */
- if (memcmp (DDC->vendor.name, "PEA", 4) == 0 &&
- DDC->vendor.prod_id == 9003)
- return TRUE;
-
- return FALSE;
-}
-
-static Bool quirk_detailed_sync_pp(int scrnIndex, xf86MonPtr DDC)
-{
- /* Bug #12439: Samsung SyncMaster 205BW */
- if (memcmp (DDC->vendor.name, "SAM", 4) == 0 &&
- DDC->vendor.prod_id == 541)
- return TRUE;
- return FALSE;
-}
-
-/* This should probably be made more generic */
-static Bool quirk_dvi_single_link(int scrnIndex, xf86MonPtr DDC)
-{
- /* Red Hat bug #453106: Apple 23" Cinema Display */
- if (memcmp (DDC->vendor.name, "APL", 4) == 0 &&
- DDC->vendor.prod_id == 0x921c)
- return TRUE;
- return FALSE;
-}
-
-typedef struct {
- Bool (*detect) (int scrnIndex, xf86MonPtr DDC);
- ddc_quirk_t quirk;
- char *description;
-} ddc_quirk_map_t;
-
-static const ddc_quirk_map_t ddc_quirks[] = {
- {
- quirk_prefer_large_60, DDC_QUIRK_PREFER_LARGE_60,
- "Detailed timing is not preferred, use largest mode at 60Hz"
- },
- {
- quirk_135_clock_too_high, DDC_QUIRK_135_CLOCK_TOO_HIGH,
- "Recommended 135MHz pixel clock is too high"
- },
- {
- quirk_prefer_large_75, DDC_QUIRK_PREFER_LARGE_75,
- "Detailed timing is not preferred, use largest mode at 75Hz"
- },
- {
- quirk_detailed_h_in_cm, DDC_QUIRK_DETAILED_H_IN_CM,
- "Detailed timings give horizontal size in cm."
- },
- {
- quirk_detailed_v_in_cm, DDC_QUIRK_DETAILED_V_IN_CM,
- "Detailed timings give vertical size in cm."
- },
- {
- quirk_detailed_use_maximum_size, DDC_QUIRK_DETAILED_USE_MAXIMUM_SIZE,
- "Use maximum size instead of detailed timing sizes."
- },
- {
- quirk_first_detailed_preferred, DDC_QUIRK_FIRST_DETAILED_PREFERRED,
- "First detailed timing was not marked as preferred."
- },
- {
- quirk_detailed_sync_pp, DDC_QUIRK_DETAILED_SYNC_PP,
- "Use +hsync +vsync for detailed timing."
- },
- {
- quirk_dvi_single_link, DDC_QUIRK_DVI_SINGLE_LINK,
- "Forcing maximum pixel clock to single DVI link."
- },
- {
- NULL, DDC_QUIRK_NONE,
- "No known quirks"
- },
-};
-
-/*
- * These more or less come from the DMT spec. The 720x400 modes are
- * inferred from historical 80x25 practice. The 640x480@67 and 832x624@75
- * modes are old-school Mac modes. The EDID spec says the 1152x864@75 mode
- * should be 1152x870, again for the Mac, but instead we use the x864 DMT
- * mode.
- *
- * The DMT modes have been fact-checked; the rest are mild guesses.
- */
-#define MODEPREFIX NULL, NULL, NULL, 0, M_T_DRIVER
-#define MODESUFFIX 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,FALSE,FALSE,0,NULL,0,0.0,0.0
-
-static const DisplayModeRec DDCEstablishedModes[17] = {
- { MODEPREFIX, 40000, 800, 840, 968, 1056, 0, 600, 601, 605, 628, 0, V_PHSYNC | V_PVSYNC, MODESUFFIX }, /* 800x600@60Hz */
- { MODEPREFIX, 36000, 800, 824, 896, 1024, 0, 600, 601, 603, 625, 0, V_PHSYNC | V_PVSYNC, MODESUFFIX }, /* 800x600@56Hz */
- { MODEPREFIX, 31500, 640, 656, 720, 840, 0, 480, 481, 484, 500, 0, V_NHSYNC | V_NVSYNC, MODESUFFIX }, /* 640x480@75Hz */
- { MODEPREFIX, 31500, 640, 664, 704, 832, 0, 480, 489, 492, 520, 0, V_NHSYNC | V_NVSYNC, MODESUFFIX }, /* 640x480@72Hz */
- { MODEPREFIX, 30240, 640, 704, 768, 864, 0, 480, 483, 486, 525, 0, V_NHSYNC | V_NVSYNC, MODESUFFIX }, /* 640x480@67Hz */
- { MODEPREFIX, 25175, 640, 656, 752, 800, 0, 480, 490, 492, 525, 0, V_NHSYNC | V_NVSYNC, MODESUFFIX }, /* 640x480@60Hz */
- { MODEPREFIX, 35500, 720, 738, 846, 900, 0, 400, 421, 423, 449, 0, V_NHSYNC | V_NVSYNC, MODESUFFIX }, /* 720x400@88Hz */
- { MODEPREFIX, 28320, 720, 738, 846, 900, 0, 400, 412, 414, 449, 0, V_NHSYNC | V_PVSYNC, MODESUFFIX }, /* 720x400@70Hz */
- { MODEPREFIX, 135000, 1280, 1296, 1440, 1688, 0, 1024, 1025, 1028, 1066, 0, V_PHSYNC | V_PVSYNC, MODESUFFIX }, /* 1280x1024@75Hz */
- { MODEPREFIX, 78750, 1024, 1040, 1136, 1312, 0, 768, 769, 772, 800, 0, V_PHSYNC | V_PVSYNC, MODESUFFIX }, /* 1024x768@75Hz */
- { MODEPREFIX, 75000, 1024, 1048, 1184, 1328, 0, 768, 771, 777, 806, 0, V_NHSYNC | V_NVSYNC, MODESUFFIX }, /* 1024x768@70Hz */
- { MODEPREFIX, 65000, 1024, 1048, 1184, 1344, 0, 768, 771, 777, 806, 0, V_NHSYNC | V_NVSYNC, MODESUFFIX }, /* 1024x768@60Hz */
- { MODEPREFIX, 44900, 1024, 1032, 1208, 1264, 0, 768, 768, 772, 817, 0, V_PHSYNC | V_PVSYNC | V_INTERLACE, MODESUFFIX }, /* 1024x768@43Hz */
- { MODEPREFIX, 57284, 832, 864, 928, 1152, 0, 624, 625, 628, 667, 0, V_NHSYNC | V_NVSYNC, MODESUFFIX }, /* 832x624@75Hz */
- { MODEPREFIX, 49500, 800, 816, 896, 1056, 0, 600, 601, 604, 625, 0, V_PHSYNC | V_PVSYNC, MODESUFFIX }, /* 800x600@75Hz */
- { MODEPREFIX, 50000, 800, 856, 976, 1040, 0, 600, 637, 643, 666, 0, V_PHSYNC | V_PVSYNC, MODESUFFIX }, /* 800x600@72Hz */
- { MODEPREFIX, 108000, 1152, 1216, 1344, 1600, 0, 864, 865, 868, 900, 0, V_PHSYNC | V_PVSYNC, MODESUFFIX }, /* 1152x864@75Hz */
-};
-
-static DisplayModePtr
-DDCModesFromEstablished(int scrnIndex, struct established_timings *timing,
- ddc_quirk_t quirks)
-{
- DisplayModePtr Modes = NULL, Mode = NULL;
- CARD32 bits = (timing->t1) | (timing->t2 << 8) |
- ((timing->t_manu & 0x80) << 9);
- int i;
-
- for (i = 0; i < 17; i++) {
- if (bits & (0x01 << i)) {
- Mode = xf86DuplicateMode(&DDCEstablishedModes[i]);
- Modes = xf86ModesAdd(Modes, Mode);
- }
- }
-
- return Modes;
-}
-
-/* Autogenerated from the DMT spec */
-const DisplayModeRec DMTModes[] = {
- { MODEPREFIX, 31500, 640, 672, 736, 832, 0, 350, 382, 385, 445, 0, V_PHSYNC | V_NVSYNC, MODESUFFIX }, /* 640x350@85Hz */
- { MODEPREFIX, 31500, 640, 672, 736, 832, 0, 400, 401, 404, 445, 0, V_NHSYNC | V_PVSYNC, MODESUFFIX }, /* 640x400@85Hz */
- { MODEPREFIX, 35500, 720, 756, 828, 936, 0, 400, 401, 404, 446, 0, V_NHSYNC | V_PVSYNC, MODESUFFIX }, /* 720x400@85Hz */
- { MODEPREFIX, 25175, 640, 656, 752, 800, 0, 480, 490, 492, 525, 0, V_NHSYNC | V_NVSYNC, MODESUFFIX }, /* 640x480@60Hz */
- { MODEPREFIX, 31500, 640, 664, 704, 832, 0, 480, 489, 492, 520, 0, V_NHSYNC | V_NVSYNC, MODESUFFIX }, /* 640x480@72Hz */
- { MODEPREFIX, 31500, 640, 656, 720, 840, 0, 480, 481, 484, 500, 0, V_NHSYNC | V_NVSYNC, MODESUFFIX }, /* 640x480@75Hz */
- { MODEPREFIX, 36000, 640, 696, 752, 832, 0, 480, 481, 484, 509, 0, V_NHSYNC | V_NVSYNC, MODESUFFIX }, /* 640x480@85Hz */
- { MODEPREFIX, 36000, 800, 824, 896, 1024, 0, 600, 601, 603, 625, 0, V_PHSYNC | V_PVSYNC, MODESUFFIX }, /* 800x600@56Hz */
- { MODEPREFIX, 40000, 800, 840, 968, 1056, 0, 600, 601, 605, 628, 0, V_PHSYNC | V_PVSYNC, MODESUFFIX }, /* 800x600@60Hz */
- { MODEPREFIX, 50000, 800, 856, 976, 1040, 0, 600, 637, 643, 666, 0, V_PHSYNC | V_PVSYNC, MODESUFFIX }, /* 800x600@72Hz */
- { MODEPREFIX, 49500, 800, 816, 896, 1056, 0, 600, 601, 604, 625, 0, V_PHSYNC | V_PVSYNC, MODESUFFIX }, /* 800x600@75Hz */
- { MODEPREFIX, 56250, 800, 832, 896, 1048, 0, 600, 601, 604, 631, 0, V_PHSYNC | V_PVSYNC, MODESUFFIX }, /* 800x600@85Hz */
- { MODEPREFIX, 73250, 800, 848, 880, 960, 0, 600, 603, 607, 636, 0, V_PHSYNC | V_NVSYNC, MODESUFFIX }, /* 800x600@120Hz RB */
- { MODEPREFIX, 33750, 848, 864, 976, 1088, 0, 480, 486, 494, 517, 0, V_PHSYNC | V_PVSYNC, MODESUFFIX }, /* 848x480@60Hz */
- { MODEPREFIX, 44900, 1024, 1032, 1208, 1264, 0, 768, 768, 772, 817, 0, V_PHSYNC | V_PVSYNC | V_INTERLACE, MODESUFFIX }, /* 1024x768@43Hz (interlaced) */
- { MODEPREFIX, 65000, 1024, 1048, 1184, 1344, 0, 768, 771, 777, 806, 0, V_NHSYNC | V_NVSYNC, MODESUFFIX }, /* 1024x768@60Hz */
- { MODEPREFIX, 75000, 1024, 1048, 1184, 1328, 0, 768, 771, 777, 806, 0, V_NHSYNC | V_NVSYNC, MODESUFFIX }, /* 1024x768@70Hz */
- { MODEPREFIX, 78750, 1024, 1040, 1136, 1312, 0, 768, 769, 772, 800, 0, V_PHSYNC | V_PVSYNC, MODESUFFIX }, /* 1024x768@75Hz */
- { MODEPREFIX, 94500, 1024, 1072, 1168, 1376, 0, 768, 769, 772, 808, 0, V_PHSYNC | V_PVSYNC, MODESUFFIX }, /* 1024x768@85Hz */
- { MODEPREFIX, 115500, 1024, 1072, 1104, 1184, 0, 768, 771, 775, 813, 0, V_PHSYNC | V_NVSYNC, MODESUFFIX }, /* 1024x768@120Hz RB */
- { MODEPREFIX, 108000, 1152, 1216, 1344, 1600, 0, 864, 865, 868, 900, 0, V_PHSYNC | V_PVSYNC, MODESUFFIX }, /* 1152x864@75Hz */
- { MODEPREFIX, 68250, 1280, 1328, 1360, 1440, 0, 768, 771, 778, 790, 0, V_PHSYNC | V_NVSYNC, MODESUFFIX }, /* 1280x768@60Hz RB */
- { MODEPREFIX, 79500, 1280, 1344, 1472, 1664, 0, 768, 771, 778, 798, 0, V_NHSYNC | V_PVSYNC, MODESUFFIX }, /* 1280x768@60Hz */
- { MODEPREFIX, 102250, 1280, 1360, 1488, 1696, 0, 768, 771, 778, 805, 0, V_NHSYNC | V_PVSYNC, MODESUFFIX }, /* 1280x768@75Hz */
- { MODEPREFIX, 117500, 1280, 1360, 1496, 1712, 0, 768, 771, 778, 809, 0, V_NHSYNC | V_PVSYNC, MODESUFFIX }, /* 1280x768@85Hz */
- { MODEPREFIX, 140250, 1280, 1328, 1360, 1440, 0, 768, 771, 778, 813, 0, V_PHSYNC | V_NVSYNC, MODESUFFIX }, /* 1280x768@120Hz RB */
- { MODEPREFIX, 71000, 1280, 1328, 1360, 1440, 0, 800, 803, 809, 823, 0, V_PHSYNC | V_NVSYNC, MODESUFFIX }, /* 1280x800@60Hz RB */
- { MODEPREFIX, 83500, 1280, 1352, 1480, 1680, 0, 800, 803, 809, 831, 0, V_NHSYNC | V_PVSYNC, MODESUFFIX }, /* 1280x800@60Hz */
- { MODEPREFIX, 106500, 1280, 1360, 1488, 1696, 0, 800, 803, 809, 838, 0, V_NHSYNC | V_PVSYNC, MODESUFFIX }, /* 1280x800@75Hz */
- { MODEPREFIX, 122500, 1280, 1360, 1496, 1712, 0, 800, 803, 809, 843, 0, V_NHSYNC | V_PVSYNC, MODESUFFIX }, /* 1280x800@85Hz */
- { MODEPREFIX, 146250, 1280, 1328, 1360, 1440, 0, 800, 803, 809, 847, 0, V_PHSYNC | V_NVSYNC, MODESUFFIX }, /* 1280x800@120Hz RB */
- { MODEPREFIX, 108000, 1280, 1376, 1488, 1800, 0, 960, 961, 964, 1000, 0, V_PHSYNC | V_PVSYNC, MODESUFFIX }, /* 1280x960@60Hz */
- { MODEPREFIX, 148500, 1280, 1344, 1504, 1728, 0, 960, 961, 964, 1011, 0, V_PHSYNC | V_PVSYNC, MODESUFFIX }, /* 1280x960@85Hz */
- { MODEPREFIX, 175500, 1280, 1328, 1360, 1440, 0, 960, 963, 967, 1017, 0, V_PHSYNC | V_NVSYNC, MODESUFFIX }, /* 1280x960@120Hz RB */
- { MODEPREFIX, 108000, 1280, 1328, 1440, 1688, 0, 1024, 1025, 1028, 1066, 0, V_PHSYNC | V_PVSYNC, MODESUFFIX }, /* 1280x1024@60Hz */
- { MODEPREFIX, 135000, 1280, 1296, 1440, 1688, 0, 1024, 1025, 1028, 1066, 0, V_PHSYNC | V_PVSYNC, MODESUFFIX }, /* 1280x1024@75Hz */
- { MODEPREFIX, 157500, 1280, 1344, 1504, 1728, 0, 1024, 1025, 1028, 1072, 0, V_PHSYNC | V_PVSYNC, MODESUFFIX }, /* 1280x1024@85Hz */
- { MODEPREFIX, 187250, 1280, 1328, 1360, 1440, 0, 1024, 1027, 1034, 1084, 0, V_PHSYNC | V_NVSYNC, MODESUFFIX }, /* 1280x1024@120Hz RB */
- { MODEPREFIX, 85500, 1360, 1424, 1536, 1792, 0, 768, 771, 777, 795, 0, V_PHSYNC | V_PVSYNC, MODESUFFIX }, /* 1360x768@60Hz */
- { MODEPREFIX, 148250, 1360, 1408, 1440, 1520, 0, 768, 771, 776, 813, 0, V_PHSYNC | V_NVSYNC, MODESUFFIX }, /* 1360x768@120Hz RB */
- { MODEPREFIX, 101000, 1400, 1448, 1480, 1560, 0, 1050, 1053, 1057, 1080, 0, V_PHSYNC | V_NVSYNC, MODESUFFIX }, /* 1400x1050@60Hz RB */
- { MODEPREFIX, 121750, 1400, 1488, 1632, 1864, 0, 1050, 1053, 1057, 1089, 0, V_NHSYNC | V_PVSYNC, MODESUFFIX }, /* 1400x1050@60Hz */
- { MODEPREFIX, 156000, 1400, 1504, 1648, 1896, 0, 1050, 1053, 1057, 1099, 0, V_NHSYNC | V_PVSYNC, MODESUFFIX }, /* 1400x1050@75Hz */
- { MODEPREFIX, 179500, 1400, 1504, 1656, 1912, 0, 1050, 1053, 1057, 1105, 0, V_NHSYNC | V_PVSYNC, MODESUFFIX }, /* 1400x1050@85Hz */
- { MODEPREFIX, 208000, 1400, 1448, 1480, 1560, 0, 1050, 1053, 1057, 1112, 0, V_PHSYNC | V_NVSYNC, MODESUFFIX }, /* 1400x1050@120Hz RB */
- { MODEPREFIX, 88750, 1440, 1488, 1520, 1600, 0, 900, 903, 909, 926, 0, V_PHSYNC | V_NVSYNC, MODESUFFIX }, /* 1440x900@60Hz RB */
- { MODEPREFIX, 106500, 1440, 1520, 1672, 1904, 0, 900, 903, 909, 934, 0, V_NHSYNC | V_PVSYNC, MODESUFFIX }, /* 1440x900@60Hz */
- { MODEPREFIX, 136750, 1440, 1536, 1688, 1936, 0, 900, 903, 909, 942, 0, V_NHSYNC | V_PVSYNC, MODESUFFIX }, /* 1440x900@75Hz */
- { MODEPREFIX, 157000, 1440, 1544, 1696, 1952, 0, 900, 903, 909, 948, 0, V_NHSYNC | V_PVSYNC, MODESUFFIX }, /* 1440x900@85Hz */
- { MODEPREFIX, 182750, 1440, 1488, 1520, 1600, 0, 900, 903, 909, 953, 0, V_PHSYNC | V_NVSYNC, MODESUFFIX }, /* 1440x900@120Hz RB */
- { MODEPREFIX, 162000, 1600, 1664, 1856, 2160, 0, 1200, 1201, 1204, 1250, 0, V_PHSYNC | V_PVSYNC, MODESUFFIX }, /* 1600x1200@60Hz */
- { MODEPREFIX, 175500, 1600, 1664, 1856, 2160, 0, 1200, 1201, 1204, 1250, 0, V_PHSYNC | V_PVSYNC, MODESUFFIX }, /* 1600x1200@65Hz */
- { MODEPREFIX, 189000, 1600, 1664, 1856, 2160, 0, 1200, 1201, 1204, 1250, 0, V_PHSYNC | V_PVSYNC, MODESUFFIX }, /* 1600x1200@70Hz */
- { MODEPREFIX, 202500, 1600, 1664, 1856, 2160, 0, 1200, 1201, 1204, 1250, 0, V_PHSYNC | V_PVSYNC, MODESUFFIX }, /* 1600x1200@75Hz */
- { MODEPREFIX, 229500, 1600, 1664, 1856, 2160, 0, 1200, 1201, 1204, 1250, 0, V_PHSYNC | V_PVSYNC, MODESUFFIX }, /* 1600x1200@85Hz */
- { MODEPREFIX, 268250, 1600, 1648, 1680, 1760, 0, 1200, 1203, 1207, 1271, 0, V_PHSYNC | V_NVSYNC, MODESUFFIX }, /* 1600x1200@120Hz RB */
- { MODEPREFIX, 119000, 1680, 1728, 1760, 1840, 0, 1050, 1053, 1059, 1080, 0, V_PHSYNC | V_NVSYNC, MODESUFFIX }, /* 1680x1050@60Hz RB */
- { MODEPREFIX, 146250, 1680, 1784, 1960, 2240, 0, 1050, 1053, 1059, 1089, 0, V_NHSYNC | V_PVSYNC, MODESUFFIX }, /* 1680x1050@60Hz */
- { MODEPREFIX, 187000, 1680, 1800, 1976, 2272, 0, 1050, 1053, 1059, 1099, 0, V_NHSYNC | V_PVSYNC, MODESUFFIX }, /* 1680x1050@75Hz */
- { MODEPREFIX, 214750, 1680, 1808, 1984, 2288, 0, 1050, 1053, 1059, 1105, 0, V_NHSYNC | V_PVSYNC, MODESUFFIX }, /* 1680x1050@85Hz */
- { MODEPREFIX, 245500, 1680, 1728, 1760, 1840, 0, 1050, 1053, 1059, 1112, 0, V_PHSYNC | V_NVSYNC, MODESUFFIX }, /* 1680x1050@120Hz RB */
- { MODEPREFIX, 204750, 1792, 1920, 2120, 2448, 0, 1344, 1345, 1348, 1394, 0, V_NHSYNC | V_PVSYNC, MODESUFFIX }, /* 1792x1344@60Hz */
- { MODEPREFIX, 261000, 1792, 1888, 2104, 2456, 0, 1344, 1345, 1348, 1417, 0, V_NHSYNC | V_PVSYNC, MODESUFFIX }, /* 1792x1344@75Hz */
- { MODEPREFIX, 333250, 1792, 1840, 1872, 1952, 0, 1344, 1347, 1351, 1423, 0, V_PHSYNC | V_NVSYNC, MODESUFFIX }, /* 1792x1344@120Hz RB */
- { MODEPREFIX, 218250, 1856, 1952, 2176, 2528, 0, 1392, 1393, 1396, 1439, 0, V_NHSYNC | V_PVSYNC, MODESUFFIX }, /* 1856x1392@60Hz */
- { MODEPREFIX, 288000, 1856, 1984, 2208, 2560, 0, 1392, 1393, 1396, 1500, 0, V_NHSYNC | V_PVSYNC, MODESUFFIX }, /* 1856x1392@75Hz */
- { MODEPREFIX, 356500, 1856, 1904, 1936, 2016, 0, 1392, 1395, 1399, 1474, 0, V_PHSYNC | V_NVSYNC, MODESUFFIX }, /* 1856x1392@120Hz RB */
- { MODEPREFIX, 154000, 1920, 1968, 2000, 2080, 0, 1200, 1203, 1209, 1235, 0, V_PHSYNC | V_NVSYNC, MODESUFFIX }, /* 1920x1200@60Hz RB */
- { MODEPREFIX, 193250, 1920, 2056, 2256, 2592, 0, 1200, 1203, 1209, 1245, 0, V_NHSYNC | V_PVSYNC, MODESUFFIX }, /* 1920x1200@60Hz */
- { MODEPREFIX, 245250, 1920, 2056, 2264, 2608, 0, 1200, 1203, 1209, 1255, 0, V_NHSYNC | V_PVSYNC, MODESUFFIX }, /* 1920x1200@75Hz */
- { MODEPREFIX, 281250, 1920, 2064, 2272, 2624, 0, 1200, 1203, 1209, 1262, 0, V_NHSYNC | V_PVSYNC, MODESUFFIX }, /* 1920x1200@85Hz */
- { MODEPREFIX, 317000, 1920, 1968, 2000, 2080, 0, 1200, 1203, 1209, 1271, 0, V_PHSYNC | V_NVSYNC, MODESUFFIX }, /* 1920x1200@120Hz RB */
- { MODEPREFIX, 234000, 1920, 2048, 2256, 2600, 0, 1440, 1441, 1444, 1500, 0, V_NHSYNC | V_PVSYNC, MODESUFFIX }, /* 1920x1440@60Hz */
- { MODEPREFIX, 297000, 1920, 2064, 2288, 2640, 0, 1440, 1441, 1444, 1500, 0, V_NHSYNC | V_PVSYNC, MODESUFFIX }, /* 1920x1440@75Hz */
- { MODEPREFIX, 380500, 1920, 1968, 2000, 2080, 0, 1440, 1443, 1447, 1525, 0, V_PHSYNC | V_NVSYNC, MODESUFFIX }, /* 1920x1440@120Hz RB */
- { MODEPREFIX, 268500, 2560, 2608, 2640, 2720, 0, 1600, 1603, 1609, 1646, 0, V_PHSYNC | V_NVSYNC, MODESUFFIX }, /* 2560x1600@60Hz RB */
- { MODEPREFIX, 348500, 2560, 2752, 3032, 3504, 0, 1600, 1603, 1609, 1658, 0, V_NHSYNC | V_PVSYNC, MODESUFFIX }, /* 2560x1600@60Hz */
- { MODEPREFIX, 443250, 2560, 2768, 3048, 3536, 0, 1600, 1603, 1609, 1672, 0, V_NHSYNC | V_PVSYNC, MODESUFFIX }, /* 2560x1600@75Hz */
- { MODEPREFIX, 505250, 2560, 2768, 3048, 3536, 0, 1600, 1603, 1609, 1682, 0, V_NHSYNC | V_PVSYNC, MODESUFFIX }, /* 2560x1600@85Hz */
- { MODEPREFIX, 552750, 2560, 2608, 2640, 2720, 0, 1600, 1603, 1609, 1694, 0, V_PHSYNC | V_NVSYNC, MODESUFFIX }, /* 2560x1600@120Hz RB */
-};
-
-#define LEVEL_DMT 0
-#define LEVEL_GTF 1
-#define LEVEL_CVT 2
-
-static int
-MonitorStandardTimingLevel(xf86MonPtr DDC)
-{
- if (DDC->ver.revision >= 2) {
- if (DDC->ver.revision >= 4 && CVT_SUPPORTED(DDC->features.msc)) {
- return LEVEL_CVT;
- }
- return LEVEL_GTF;
- }
- return LEVEL_DMT;
-}
-
-static int
-ModeRefresh(const DisplayModeRec *mode)
-{
- return (int)(xf86ModeVRefresh(mode) + 0.5);
-}
-
-/*
- * If rb is not set, then we'll not consider reduced-blanking modes as
- * part of the DMT pool. For the 'standard' EDID mode descriptor there's
- * no way to specify whether the mode should be RB or not.
- */
-DisplayModePtr
-FindDMTMode(int hsize, int vsize, int refresh, Bool rb)
-{
- int i;
- const DisplayModeRec *ret;
-
- for (i = 0; i < sizeof(DMTModes) / sizeof(DisplayModeRec); i++) {
- ret = &DMTModes[i];
-
- if (!rb && xf86ModeIsReduced(ret))
- continue;
-
- if (ret->HDisplay == hsize &&
- ret->VDisplay == vsize &&
- refresh == ModeRefresh(ret))
- return xf86DuplicateMode(ret);
- }
-
- return NULL;
-}
-
-/*
- * Appendix B of the EDID 1.4 spec defines the right thing to do here.
- * If the timing given here matches a mode defined in the VESA DMT standard,
- * we _must_ use that. If the device supports CVT modes, then we should
- * generate a CVT timing. If both of the above fail, use GTF.
- *
- * There are some wrinkles here. EDID 1.1 and 1.0 sinks can't really
- * "support" GTF, since it wasn't a standard yet; so if they ask for a
- * timing in this section that isn't defined in DMT, returning a GTF mode
- * may not actually be valid. EDID 1.3 sinks often report support for
- * some CVT modes, but they are not required to support CVT timings for
- * modes in the standard timing descriptor, so we should _not_ treat them
- * as CVT-compliant (unless specified in an extension block I suppose).
- *
- * EDID 1.4 requires that all sink devices support both GTF and CVT timings
- * for modes in this section, but does say that CVT is preferred.
- */
-static DisplayModePtr
-DDCModesFromStandardTiming(struct std_timings *timing, ddc_quirk_t quirks,
- int timing_level, Bool rb)
-{
- DisplayModePtr Modes = NULL, Mode = NULL;
- int i, hsize, vsize, refresh;
-
- for (i = 0; i < STD_TIMINGS; i++) {
- hsize = timing[i].hsize;
- vsize = timing[i].vsize;
- refresh = timing[i].refresh;
-
- /* HDTV hack, because you can't say 1366 */
- if (refresh == 60 &&
- ((hsize == 1360 && vsize == 765) ||
- (hsize == 1368 && vsize == 769))) {
- Mode = xf86CVTMode(1366, 768, 60, FALSE, FALSE);
- Mode->HDisplay = 1366;
- Mode->HSyncStart--;
- Mode->HSyncEnd--;
- } else if (hsize && vsize && refresh) {
- Mode = FindDMTMode(hsize, vsize, refresh, rb);
-
- if (!Mode) {
- if (timing_level == LEVEL_CVT)
- /* pass rb here too? */
- Mode = xf86CVTMode(hsize, vsize, refresh, FALSE, FALSE);
- else if (timing_level == LEVEL_GTF)
- Mode = xf86GTFMode(hsize, vsize, refresh, FALSE, FALSE);
- }
-
- }
-
- if (Mode) {
- Mode->type = M_T_DRIVER;
- Modes = xf86ModesAdd(Modes, Mode);
- }
- Mode = NULL;
- }
-
- return Modes;
-}
-
-static void
-DDCModeDoInterlaceQuirks(DisplayModePtr mode)
-{
- /*
- * EDID is delightfully ambiguous about how interlaced modes are to be
- * encoded. X's internal representation is of frame height, but some
- * HDTV detailed timings are encoded as field height.
- *
- * The format list here is from CEA, in frame size. Technically we
- * should be checking refresh rate too. Whatever.
- */
- static const struct {
- int w, h;
- } cea_interlaced[] = {
- { 1920, 1080 },
- { 720, 480 },
- { 1440, 480 },
- { 2880, 480 },
- { 720, 576 },
- { 1440, 576 },
- { 2880, 576 },
- };
- static const int n_modes = sizeof(cea_interlaced)/sizeof(cea_interlaced[0]);
- int i;
-
- for (i = 0; i < n_modes; i++) {
- if ((mode->HDisplay == cea_interlaced[i].w) &&
- (mode->VDisplay == cea_interlaced[i].h / 2)) {
- mode->VDisplay *= 2;
- mode->VSyncStart *= 2;
- mode->VSyncEnd *= 2;
- mode->VTotal *= 2;
- mode->VTotal |= 1;
- }
- }
-
- mode->Flags |= V_INTERLACE;
-}
-
-/*
- *
- */
-static DisplayModePtr
-DDCModeFromDetailedTiming(int scrnIndex, struct detailed_timings *timing,
- Bool preferred, ddc_quirk_t quirks)
-{
- DisplayModePtr Mode;
-
- /*
- * Refuse to create modes that are insufficiently large. 64 is a random
- * number, maybe the spec says something about what the minimum is. In
- * particular I see this frequently with _old_ EDID, 1.0 or so, so maybe
- * our parser is just being too aggresive there.
- */
- if (timing->h_active < 64 || timing->v_active < 64) {
- xf86DrvMsg(scrnIndex, X_INFO,
- "%s: Ignoring tiny %dx%d mode\n", __func__,
- timing->h_active, timing->v_active);
- return NULL;
- }
-
- /* We don't do stereo */
- if (timing->stereo) {
- xf86DrvMsg(scrnIndex, X_INFO,
- "%s: Ignoring: We don't handle stereo.\n", __func__);
- return NULL;
- }
-
- /* We only do seperate sync currently */
- if (timing->sync != 0x03) {
- xf86DrvMsg(scrnIndex, X_INFO,
- "%s: %dx%d Warning: We only handle separate"
- " sync.\n", __func__, timing->h_active, timing->v_active);
- }
-
- Mode = xnfcalloc(1, sizeof(DisplayModeRec));
-
- Mode->type = M_T_DRIVER;
- if (preferred)
- Mode->type |= M_T_PREFERRED;
-
- if( ( quirks & DDC_QUIRK_135_CLOCK_TOO_HIGH ) &&
- timing->clock == 135000000 )
- Mode->Clock = 108880;
- else
- Mode->Clock = timing->clock / 1000.0;
-
- Mode->HDisplay = timing->h_active;
- Mode->HSyncStart = timing->h_active + timing->h_sync_off;
- Mode->HSyncEnd = Mode->HSyncStart + timing->h_sync_width;
- Mode->HTotal = timing->h_active + timing->h_blanking;
-
- Mode->VDisplay = timing->v_active;
- Mode->VSyncStart = timing->v_active + timing->v_sync_off;
- Mode->VSyncEnd = Mode->VSyncStart + timing->v_sync_width;
- Mode->VTotal = timing->v_active + timing->v_blanking;
-
- /* perform basic check on the detail timing */
- if (Mode->HSyncEnd > Mode->HTotal || Mode->VSyncEnd > Mode->VTotal) {
- free(Mode);
- return NULL;
- }
-
- /* We ignore h/v_size and h/v_border for now. */
-
- if (timing->interlaced)
- DDCModeDoInterlaceQuirks(Mode);
-
- if (quirks & DDC_QUIRK_DETAILED_SYNC_PP)
- Mode->Flags |= V_PVSYNC | V_PHSYNC;
- else {
- if (timing->misc & 0x02)
- Mode->Flags |= V_PVSYNC;
- else
- Mode->Flags |= V_NVSYNC;
-
- if (timing->misc & 0x01)
- Mode->Flags |= V_PHSYNC;
- else
- Mode->Flags |= V_NHSYNC;
- }
-
- xf86SetModeDefaultName(Mode);
-
- return Mode;
-}
-
-static DisplayModePtr
-DDCModesFromCVT(int scrnIndex, struct cvt_timings *t)
-{
- DisplayModePtr modes = NULL;
- int i;
-
- for (i = 0; i < 4; i++) {
- if (t[i].height) {
- if (t[i].rates & 0x10)
- modes = xf86ModesAdd(modes,
- xf86CVTMode(t[i].width, t[i].height, 50, 0, 0));
- if (t[i].rates & 0x08)
- modes = xf86ModesAdd(modes,
- xf86CVTMode(t[i].width, t[i].height, 60, 0, 0));
- if (t[i].rates & 0x04)
- modes = xf86ModesAdd(modes,
- xf86CVTMode(t[i].width, t[i].height, 75, 0, 0));
- if (t[i].rates & 0x02)
- modes = xf86ModesAdd(modes,
- xf86CVTMode(t[i].width, t[i].height, 85, 0, 0));
- if (t[i].rates & 0x01)
- modes = xf86ModesAdd(modes,
- xf86CVTMode(t[i].width, t[i].height, 60, 1, 0));
- } else break;
- }
-
- return modes;
-}
-
-static const struct {
- short w;
- short h;
- short r;
- short rb;
-} EstIIIModes[] = {
- /* byte 6 */
- { 640, 350, 85, 0 },
- { 640, 400, 85, 0 },
- { 720, 400, 85, 0 },
- { 640, 480, 85, 0 },
- { 848, 480, 60, 0 },
- { 800, 600, 85, 0 },
- { 1024, 768, 85, 0 },
- { 1152, 864, 75, 0 },
- /* byte 7 */
- { 1280, 768, 60, 1 },
- { 1280, 768, 60, 0 },
- { 1280, 768, 75, 0 },
- { 1280, 768, 85, 0 },
- { 1280, 960, 60, 0 },
- { 1280, 960, 85, 0 },
- { 1280, 1024, 60, 0 },
- { 1280, 1024, 85, 0 },
- /* byte 8 */
- { 1360, 768, 60, 0 },
- { 1440, 900, 60, 1 },
- { 1440, 900, 60, 0 },
- { 1440, 900, 75, 0 },
- { 1440, 900, 85, 0 },
- { 1400, 1050, 60, 1 },
- { 1400, 1050, 60, 0 },
- { 1400, 1050, 75, 0 },
- /* byte 9 */
- { 1400, 1050, 85, 0 },
- { 1680, 1050, 60, 1 },
- { 1680, 1050, 60, 0 },
- { 1680, 1050, 75, 0 },
- { 1680, 1050, 85, 0 },
- { 1600, 1200, 60, 0 },
- { 1600, 1200, 65, 0 },
- { 1600, 1200, 70, 0 },
- /* byte 10 */
- { 1600, 1200, 75, 0 },
- { 1600, 1200, 85, 0 },
- { 1792, 1344, 60, 0 },
- { 1792, 1344, 85, 0 },
- { 1856, 1392, 60, 0 },
- { 1856, 1392, 75, 0 },
- { 1920, 1200, 60, 1 },
- { 1920, 1200, 60, 0 },
- /* byte 11 */
- { 1920, 1200, 75, 0 },
- { 1920, 1200, 85, 0 },
- { 1920, 1440, 60, 0 },
- { 1920, 1440, 75, 0 },
-};
-
-static DisplayModePtr
-DDCModesFromEstIII(unsigned char *est)
-{
- DisplayModePtr modes = NULL;
- int i, j, m;
-
- for (i = 0; i < 6; i++) {
- for (j = 7; j > 0; j--) {
- if (est[i] & (1 << j)) {
- m = (i * 8) + (7 - j);
- modes = xf86ModesAdd(modes,
- FindDMTMode(EstIIIModes[m].w,
- EstIIIModes[m].h,
- EstIIIModes[m].r,
- EstIIIModes[m].rb));
- }
- }
- }
-
- return modes;
-}
-
-/*
- * This is only valid when the sink claims to be continuous-frequency
- * but does not supply a detailed range descriptor. Such sinks are
- * arguably broken. Currently the mode validation code isn't aware of
- * this; the non-RANDR code even punts the decision of optional sync
- * range checking to the driver. Loss.
- */
-static void
-DDCGuessRangesFromModes(int scrnIndex, MonPtr Monitor, DisplayModePtr Modes)
-{
- DisplayModePtr Mode = Modes;
-
- if (!Monitor || !Modes)
- return;
-
- /* set up the ranges for scanning through the modes */
- Monitor->nHsync = 1;
- Monitor->hsync[0].lo = 1024.0;
- Monitor->hsync[0].hi = 0.0;
-
- Monitor->nVrefresh = 1;
- Monitor->vrefresh[0].lo = 1024.0;
- Monitor->vrefresh[0].hi = 0.0;
-
- while (Mode) {
- if (!Mode->HSync)
- Mode->HSync = ((float) Mode->Clock ) / ((float) Mode->HTotal);
-
- if (!Mode->VRefresh)
- Mode->VRefresh = (1000.0 * ((float) Mode->Clock)) /
- ((float) (Mode->HTotal * Mode->VTotal));
-
- if (Mode->HSync < Monitor->hsync[0].lo)
- Monitor->hsync[0].lo = Mode->HSync;
-
- if (Mode->HSync > Monitor->hsync[0].hi)
- Monitor->hsync[0].hi = Mode->HSync;
-
- if (Mode->VRefresh < Monitor->vrefresh[0].lo)
- Monitor->vrefresh[0].lo = Mode->VRefresh;
-
- if (Mode->VRefresh > Monitor->vrefresh[0].hi)
- Monitor->vrefresh[0].hi = Mode->VRefresh;
-
- Mode = Mode->next;
- }
-}
-
-ddc_quirk_t
-xf86DDCDetectQuirks(int scrnIndex, xf86MonPtr DDC, Bool verbose)
-{
- ddc_quirk_t quirks;
- int i;
-
- quirks = DDC_QUIRK_NONE;
- for (i = 0; ddc_quirks[i].detect; i++) {
- if (ddc_quirks[i].detect (scrnIndex, DDC)) {
- if (verbose) {
- xf86DrvMsg (scrnIndex, X_INFO, " EDID quirk: %s\n",
- ddc_quirks[i].description);
- }
- quirks |= ddc_quirks[i].quirk;
- }
- }
-
- return quirks;
-}
-
-void xf86DetTimingApplyQuirks(struct detailed_monitor_section *det_mon,
- ddc_quirk_t quirks,
- int hsize, int vsize)
-{
- if (det_mon->type != DT)
- return;
-
- if (quirks & DDC_QUIRK_DETAILED_H_IN_CM)
- det_mon->section.d_timings.h_size *= 10;
-
- if (quirks & DDC_QUIRK_DETAILED_V_IN_CM)
- det_mon->section.d_timings.v_size *= 10;
-
- if (quirks & DDC_QUIRK_DETAILED_USE_MAXIMUM_SIZE) {
- det_mon->section.d_timings.h_size = 10 * hsize;
- det_mon->section.d_timings.v_size = 10 * vsize;
- }
-}
-
-/**
- * Applies monitor-specific quirks to the decoded EDID information.
- *
- * Note that some quirks applying to the mode list are still implemented in
- * xf86DDCGetModes.
- */
-void
-xf86DDCApplyQuirks(int scrnIndex, xf86MonPtr DDC)
-{
- ddc_quirk_t quirks = xf86DDCDetectQuirks (scrnIndex, DDC, FALSE);
- int i;
-
- for (i = 0; i < DET_TIMINGS; i++) {
- xf86DetTimingApplyQuirks(DDC->det_mon + i, quirks,
- DDC->features.hsize,
- DDC->features.vsize);
- }
-}
-
-/**
- * Walks the modes list, finding the mode with the largest area which is
- * closest to the target refresh rate, and marks it as the only preferred mode.
-*/
-static void
-xf86DDCSetPreferredRefresh(int scrnIndex, DisplayModePtr modes,
- float target_refresh)
-{
- DisplayModePtr mode, best = modes;
-
- for (mode = modes; mode; mode = mode->next)
- {
- mode->type &= ~M_T_PREFERRED;
-
- if (mode == best) continue;
-
- if (mode->HDisplay * mode->VDisplay >
- best->HDisplay * best->VDisplay)
- {
- best = mode;
- continue;
- }
- if (mode->HDisplay * mode->VDisplay ==
- best->HDisplay * best->VDisplay)
- {
- double mode_refresh = xf86ModeVRefresh (mode);
- double best_refresh = xf86ModeVRefresh (best);
- double mode_dist = fabs(mode_refresh - target_refresh);
- double best_dist = fabs(best_refresh - target_refresh);
-
- if (mode_dist < best_dist)
- {
- best = mode;
- continue;
- }
- }
- }
- if (best)
- best->type |= M_T_PREFERRED;
-}
-
-#define CEA_VIDEO_MODES_NUM 64
-static const DisplayModeRec CEAVideoModes[CEA_VIDEO_MODES_NUM] = {
- { MODEPREFIX, 25175, 640, 656, 752, 800, 0, 480, 490, 492, 525, 0, V_NHSYNC | V_NVSYNC, MODESUFFIX }, /* VIC 1:640x480@60Hz */
- { MODEPREFIX, 27000, 720, 736, 798, 858, 0, 480, 489, 495, 525, 0, V_NHSYNC | V_NVSYNC, MODESUFFIX }, /* VIC 2:720x480@60Hz */
- { MODEPREFIX, 27000, 720, 736, 798, 858, 0, 480, 489, 495, 525, 0, V_NHSYNC | V_NVSYNC, MODESUFFIX }, /* VIC 3:720x480@60Hz */
- { MODEPREFIX, 74250, 1280, 1390, 1430, 1650, 0, 720, 725, 730, 750, 0, V_PHSYNC | V_PVSYNC, MODESUFFIX }, /* VIC 4: 1280x720@60Hz */
- { MODEPREFIX, 74250, 1920, 2008, 2052, 2200, 0, 1080, 1084, 1094, 1125, 0, V_PHSYNC | V_PVSYNC | V_INTERLACE, MODESUFFIX }, /* VIC 5:1920x1080i@60Hz */
- { MODEPREFIX, 27000, 1440, 1478, 1602, 1716, 0, 480, 488, 494, 525, 0, V_NHSYNC | V_NVSYNC | V_INTERLACE, MODESUFFIX }, /* VIC 6:1440x480i@60Hz */
- { MODEPREFIX, 27000, 1440, 1478, 1602, 1716, 0, 480, 488, 494, 525, 0, V_NHSYNC | V_NVSYNC | V_INTERLACE, MODESUFFIX }, /* VIC 7:1440x480i@60Hz */
- { MODEPREFIX, 27000, 1440, 1478, 1602, 1716, 0, 240, 244, 247, 262, 0, V_NHSYNC | V_NVSYNC, MODESUFFIX }, /* VIC 8:1440x240@60Hz */
- { MODEPREFIX, 27000, 1440, 1478, 1602, 1716, 0, 240, 244, 247, 262, 0, V_NHSYNC | V_NVSYNC, MODESUFFIX }, /* VIC 9:1440x240@60Hz */
- { MODEPREFIX, 54000, 2880, 2956, 3204, 3432, 0, 480, 488, 494, 525, 0, V_NHSYNC | V_NVSYNC | V_INTERLACE, MODESUFFIX }, /* VIC 10:2880x480i@60Hz */
- { MODEPREFIX, 54000, 2880, 2956, 3204, 3432, 0, 480, 488, 494, 525, 0, V_NHSYNC | V_NVSYNC | V_INTERLACE, MODESUFFIX }, /* VIC 11:2880x480i@60Hz */
- { MODEPREFIX, 54000, 2880, 2956, 3204, 3432, 0, 240, 244, 247, 262, 0, V_NHSYNC | V_NVSYNC, MODESUFFIX }, /* VIC 12:2880x240@60Hz */
- { MODEPREFIX, 54000, 2880, 2956, 3204, 3432, 0, 240, 244, 247, 262, 0, V_NHSYNC | V_NVSYNC, MODESUFFIX }, /* VIC 13:2880x240@60Hz */
- { MODEPREFIX, 54000, 1440, 1472, 1596, 1716, 0, 480, 489, 495, 525, 0, V_NHSYNC | V_NVSYNC, MODESUFFIX }, /* VIC 14:1440x480@60Hz */
- { MODEPREFIX, 54000, 1440, 1472, 1596, 1716, 0, 480, 489, 495, 525, 0, V_NHSYNC | V_NVSYNC, MODESUFFIX }, /* VIC 15:1440x480@60Hz */
- { MODEPREFIX, 148500, 1920, 2008, 2052, 2200, 0, 1080, 1084, 1089, 1125, 0, V_PHSYNC | V_PVSYNC, MODESUFFIX }, /* VIC 16:1920x1080@60Hz */
- { MODEPREFIX, 27000, 720, 732, 796, 864, 0, 576, 581, 586, 625, 0, V_NHSYNC | V_NVSYNC, MODESUFFIX }, /* VIC 17:720x576@50Hz */
- { MODEPREFIX, 27000, 720, 732, 796, 864, 0, 576, 581, 586, 625, 0, V_NHSYNC | V_NVSYNC, MODESUFFIX }, /* VIC 18:720x576@50Hz */
- { MODEPREFIX, 74250, 1280, 1720, 1760, 1980, 0, 720, 725, 730, 750, 0, V_PHSYNC | V_PVSYNC, MODESUFFIX }, /* VIC 19: 1280x720@50Hz */
- { MODEPREFIX, 74250, 1920, 2448, 2492, 2640, 0, 1080, 1084, 1094, 1125, 0, V_PHSYNC | V_PVSYNC | V_INTERLACE, MODESUFFIX }, /* VIC 20:1920x1080i@50Hz */
- { MODEPREFIX, 27000, 1440, 1464, 1590, 1728, 0, 576, 580, 586, 625, 0, V_NHSYNC | V_NVSYNC | V_INTERLACE, MODESUFFIX }, /* VIC 21:1440x576i@50Hz */
- { MODEPREFIX, 27000, 1440, 1464, 1590, 1728, 0, 576, 580, 586, 625, 0, V_NHSYNC | V_NVSYNC | V_INTERLACE, MODESUFFIX }, /* VIC 22:1440x576i@50Hz */
- { MODEPREFIX, 27000, 1440, 1464, 1590, 1728, 0, 288, 290, 293, 312, 0, V_NHSYNC | V_NVSYNC, MODESUFFIX }, /* VIC 23:1440x288@50Hz */
- { MODEPREFIX, 27000, 1440, 1464, 1590, 1728, 0, 288, 290, 293, 312, 0, V_NHSYNC | V_NVSYNC, MODESUFFIX }, /* VIC 24:1440x288@50Hz */
- { MODEPREFIX, 54000, 2880, 2928, 3180, 3456, 0, 576, 580, 586, 625, 0, V_NHSYNC | V_NVSYNC | V_INTERLACE, MODESUFFIX }, /* VIC 25:2880x576i@50Hz */
- { MODEPREFIX, 54000, 2880, 2928, 3180, 3456, 0, 576, 580, 586, 625, 0, V_NHSYNC | V_NVSYNC | V_INTERLACE, MODESUFFIX }, /* VIC 26:2880x576i@50Hz */
- { MODEPREFIX, 54000, 2880, 2928, 3180, 3456, 0, 288, 290, 293, 312, 0, V_NHSYNC | V_NVSYNC, MODESUFFIX }, /* VIC 27:2880x288@50Hz */
- { MODEPREFIX, 54000, 2880, 2928, 3180, 3456, 0, 288, 290, 293, 312, 0, V_NHSYNC | V_NVSYNC, MODESUFFIX }, /* VIC 28:2880x288@50Hz */
- { MODEPREFIX, 54000, 1440, 1464, 1592, 1728, 0, 576, 581, 586, 625, 0, V_NHSYNC | V_NVSYNC, MODESUFFIX }, /* VIC 29:1440x576@50Hz */
- { MODEPREFIX, 54000, 1440, 1464, 1592, 1728, 0, 576, 581, 586, 625, 0, V_NHSYNC | V_NVSYNC, MODESUFFIX }, /* VIC 30:1440x576@50Hz */
- { MODEPREFIX, 148500, 1920, 2448, 2492, 2640, 0, 1080, 1084, 1089, 1125, 0, V_PHSYNC | V_PVSYNC, MODESUFFIX }, /* VIC 31:1920x1080@50Hz */
- { MODEPREFIX, 74250, 1920, 2558, 2602, 2750, 0, 1080, 1084, 1089, 1125, 0, V_PHSYNC | V_PVSYNC, MODESUFFIX }, /* VIC 32:1920x1080@24Hz */
- { MODEPREFIX, 74250, 1920, 2448, 2492, 2640, 0, 1080, 1084, 1089, 1125, 0, V_PHSYNC | V_PVSYNC, MODESUFFIX }, /* VIC 33:1920x1080@25Hz */
- { MODEPREFIX, 74250, 1920, 2008, 2052, 2200, 0, 1080, 1084, 1089, 1125, 0, V_PHSYNC | V_PVSYNC, MODESUFFIX }, /* VIC 34:1920x1080@30Hz */
- { MODEPREFIX, 108000, 2880, 2944, 3192, 3432, 0, 480, 489, 495, 525, 0, V_NHSYNC | V_NVSYNC, MODESUFFIX }, /* VIC 35:2880x480@60Hz */
- { MODEPREFIX, 108000, 2880, 2944, 3192, 3432, 0, 480, 489, 495, 525, 0, V_NHSYNC | V_NVSYNC, MODESUFFIX }, /* VIC 36:2880x480@60Hz */
- { MODEPREFIX, 108000, 2880, 2928, 3184, 3456, 0, 576, 581, 586, 625, 0, V_NHSYNC | V_NVSYNC, MODESUFFIX }, /* VIC 37:2880x576@50Hz */
- { MODEPREFIX, 108000, 2880, 2928, 3184, 3456, 0, 576, 581, 586, 625, 0, V_NHSYNC | V_NVSYNC, MODESUFFIX }, /* VIC 38:2880x576@50Hz */
- { MODEPREFIX, 72000, 1920, 1952, 2120, 2304, 0, 1080, 1126, 1136, 1250, 0, V_PHSYNC | V_NVSYNC | V_INTERLACE, MODESUFFIX }, /* VIC 39:1920x1080i@50Hz */
- { MODEPREFIX, 148500, 1920, 2448, 2492, 2640, 0, 1080, 1084, 1094, 1125, 0, V_PHSYNC | V_PVSYNC | V_INTERLACE, MODESUFFIX }, /* VIC 40:1920x1080i@100Hz */
- { MODEPREFIX, 148500, 1280, 1720, 1760, 1980, 0, 720, 725, 730, 750, 0, V_PHSYNC | V_PVSYNC, MODESUFFIX }, /* VIC 41:1280x720@100Hz */
- { MODEPREFIX, 54000, 720, 732, 796, 864, 0, 576, 581, 586, 625, 0, V_NHSYNC | V_NVSYNC, MODESUFFIX }, /* VIC 42:720x576@100Hz */
- { MODEPREFIX, 54000, 720, 732, 796, 864, 0, 576, 581, 586, 625, 0, V_NHSYNC | V_NVSYNC, MODESUFFIX }, /* VIC 43:720x576@100Hz */
- { MODEPREFIX, 54000, 1440, 1464, 1590, 1728, 0, 576, 580, 586, 625, 0, V_NHSYNC | V_NVSYNC, MODESUFFIX }, /* VIC 44:1440x576i@100Hz */
- { MODEPREFIX, 54000, 1440, 1464, 1590, 1728, 0, 576, 580, 586, 625, 0, V_NHSYNC | V_NVSYNC, MODESUFFIX }, /* VIC 45:1440x576i@100Hz */
- { MODEPREFIX, 148500, 1920, 2008, 2052, 2200, 0, 1080, 1084, 1094, 1125, 0, V_PHSYNC | V_PVSYNC | V_INTERLACE, MODESUFFIX }, /* VIC 46:1920x1080i@120Hz */
- { MODEPREFIX, 148500, 1280, 1390, 1430, 1650, 0, 720, 725, 730, 750, 0, V_PHSYNC | V_PVSYNC, MODESUFFIX }, /* VIC 47:1280x720@120Hz */
- { MODEPREFIX, 54000, 720, 736, 798, 858, 0, 480, 489, 495, 525, 0, V_NHSYNC | V_NVSYNC, MODESUFFIX }, /* VIC 48:720x480@120Hz */
- { MODEPREFIX, 54000, 720, 736, 798, 858, 0, 480, 489, 495, 525, 0, V_NHSYNC | V_NVSYNC, MODESUFFIX }, /* VIC 49:720x480@120Hz */
- { MODEPREFIX, 54000, 1440, 1478, 1602, 1716, 0, 480, 488, 494, 525, 0, V_NHSYNC | V_NVSYNC | V_INTERLACE, MODESUFFIX },/* VIC 50:1440x480i@120Hz */
- { MODEPREFIX, 54000, 1440, 1478, 1602, 1716, 0, 480, 488, 494, 525, 0, V_NHSYNC | V_NVSYNC | V_INTERLACE, MODESUFFIX },/* VIC 51:1440x480i@120Hz */
- { MODEPREFIX, 108000, 720, 732, 796, 864, 0, 576, 581, 586, 625, 0, V_NHSYNC | V_NVSYNC, MODESUFFIX }, /* VIC 52:720x576@200Hz */
- { MODEPREFIX, 108000, 720, 732, 796, 864, 0, 576, 581, 586, 625, 0, V_NHSYNC | V_NVSYNC, MODESUFFIX }, /* VIC 53:720x576@200Hz */
- { MODEPREFIX, 108000, 1440, 1464, 1590, 1728, 0, 576, 580, 586, 625, 0, V_NHSYNC | V_NVSYNC | V_INTERLACE, MODESUFFIX },/* VIC 54:1440x576i@200Hz */
- { MODEPREFIX, 108000, 1440, 1464, 1590, 1728, 0, 576, 580, 586, 625, 0, V_NHSYNC | V_NVSYNC | V_INTERLACE, MODESUFFIX },/* VIC 55:1440x576i@200Hz */
- { MODEPREFIX, 108000, 720, 736, 798, 858, 0, 480, 489, 495, 525, 0, V_NHSYNC | V_NVSYNC, MODESUFFIX }, /* VIC 56:720x480@240Hz */
- { MODEPREFIX, 108000, 720, 736, 798, 858, 0, 480, 489, 495, 525, 0, V_NHSYNC | V_NVSYNC, MODESUFFIX }, /* VIC 57:720x480@240Hz */
- { MODEPREFIX, 108000, 1440, 1478, 1602, 1716, 0, 480, 488, 494, 525, 0, V_NHSYNC | V_NVSYNC | V_INTERLACE, MODESUFFIX },/* VIC 58:1440x480i@240 */
- { MODEPREFIX, 108000, 1440, 1478, 1602, 1716, 0, 480, 488, 494, 525, 0, V_NHSYNC | V_NVSYNC | V_INTERLACE, MODESUFFIX },/* VIC 59:1440x480i@240 */
- { MODEPREFIX, 59400, 1280, 3040, 3080, 3300, 0, 720, 725, 730, 750, 0, V_PHSYNC | V_PVSYNC, MODESUFFIX }, /* VIC 60: 1280x720@24Hz */
- { MODEPREFIX, 74250, 3700, 3740, 1430, 3960, 0, 720, 725, 730, 750, 0, V_PHSYNC | V_PVSYNC, MODESUFFIX }, /* VIC 61: 1280x720@25Hz */
- { MODEPREFIX, 74250, 1280, 3040, 3080, 3300, 0, 720, 725, 730, 750, 0, V_PHSYNC | V_PVSYNC, MODESUFFIX }, /* VIC 62: 1280x720@30Hz */
- { MODEPREFIX, 297000, 1920, 2008, 2052, 2200, 0, 1080, 1084, 1089, 1125, 0, V_PHSYNC | V_PVSYNC, MODESUFFIX }, /* VIC 63: 1920x1080@120Hz */
- { MODEPREFIX, 297000, 1920, 2448, 2492, 2640, 0, 1080, 1084, 1094, 1125, 0, V_PHSYNC | V_PVSYNC, MODESUFFIX }, /* VIC 64:1920x1080@100Hz */
-};
-
-/* chose mode line by cea short video descriptor*/
-static void handle_cea_svd(struct cea_video_block *video, void *data)
-{
- DisplayModePtr Mode;
- DisplayModePtr *Modes = (DisplayModePtr *) data;
- int vid;
-
- vid = video ->video_code & 0x7f;
- if (vid < CEA_VIDEO_MODES_NUM) {
- Mode = xf86DuplicateMode(CEAVideoModes + vid);
- *Modes = xf86ModesAdd(*Modes, Mode);
- }
-}
-
-static DisplayModePtr
-DDCModesFromCEAExtension(int scrnIndex, xf86MonPtr MonPtr)
-{
- DisplayModePtr Modes = NULL;
-
- xf86ForEachVideoBlock(MonPtr,
- handle_cea_svd,
- &Modes);
-
- return Modes;
-}
-
-struct det_modes_parameter {
- xf86MonPtr DDC;
- ddc_quirk_t quirks;
- DisplayModePtr Modes;
- Bool rb;
- Bool preferred;
- int timing_level;
-};
-
-static void handle_detailed_modes(struct detailed_monitor_section *det_mon,
- void *data)
-{
- DisplayModePtr Mode;
- struct det_modes_parameter *p = (struct det_modes_parameter *)data;
-
- xf86DetTimingApplyQuirks(det_mon,p->quirks,
- p->DDC->features.hsize,
- p->DDC->features.vsize);
-
- switch (det_mon->type) {
- case DT:
- Mode = DDCModeFromDetailedTiming(p->DDC->scrnIndex,
- &det_mon->section.d_timings,
- p->preferred,
- p->quirks);
- p->preferred = FALSE;
- p->Modes = xf86ModesAdd(p->Modes, Mode);
- break;
- case DS_STD_TIMINGS:
- Mode = DDCModesFromStandardTiming(det_mon->section.std_t,
- p->quirks, p->timing_level,p->rb);
- p->Modes = xf86ModesAdd(p->Modes, Mode);
- break;
- case DS_CVT:
- Mode = DDCModesFromCVT(p->DDC->scrnIndex, det_mon->section.cvt);
- p->Modes = xf86ModesAdd(p->Modes, Mode);
- break;
- case DS_EST_III:
- Mode = DDCModesFromEstIII(det_mon->section.est_iii);
- p->Modes = xf86ModesAdd(p->Modes, Mode);
- break;
- default:
- break;
- }
-}
-
-DisplayModePtr
-xf86DDCGetModes(int scrnIndex, xf86MonPtr DDC)
-{
- DisplayModePtr Modes = NULL, Mode;
- ddc_quirk_t quirks;
- Bool preferred, rb;
- int timing_level;
- struct det_modes_parameter p;
-
- xf86DrvMsg (scrnIndex, X_INFO, "EDID vendor \"%s\", prod id %d\n",
- DDC->vendor.name, DDC->vendor.prod_id);
-
- quirks = xf86DDCDetectQuirks(scrnIndex, DDC, TRUE);
-
- preferred = PREFERRED_TIMING_MODE(DDC->features.msc);
- if (DDC->ver.revision >= 4)
- preferred = TRUE;
- if (quirks & DDC_QUIRK_FIRST_DETAILED_PREFERRED)
- preferred = TRUE;
- if (quirks & (DDC_QUIRK_PREFER_LARGE_60 | DDC_QUIRK_PREFER_LARGE_75))
- preferred = FALSE;
-
- rb = xf86MonitorSupportsReducedBlanking(DDC);
-
- timing_level = MonitorStandardTimingLevel(DDC);
-
- p.quirks = quirks;
- p.DDC = DDC;
- p.Modes = Modes;
- p.rb = rb;
- p.preferred = preferred;
- p.timing_level = timing_level;
- xf86ForEachDetailedBlock(DDC, handle_detailed_modes, &p);
- Modes = p.Modes;
-
- /* Add established timings */
- Mode = DDCModesFromEstablished(scrnIndex, &DDC->timings1, quirks);
- Modes = xf86ModesAdd(Modes, Mode);
-
- /* Add standard timings */
- Mode = DDCModesFromStandardTiming(DDC->timings2, quirks, timing_level, rb);
- Modes = xf86ModesAdd(Modes, Mode);
-
- /* Add cea-extension mode timings */
- Mode = DDCModesFromCEAExtension(scrnIndex,DDC);
- Modes = xf86ModesAdd(Modes, Mode);
-
- if (quirks & DDC_QUIRK_PREFER_LARGE_60)
- xf86DDCSetPreferredRefresh(scrnIndex, Modes, 60);
-
- if (quirks & DDC_QUIRK_PREFER_LARGE_75)
- xf86DDCSetPreferredRefresh(scrnIndex, Modes, 75);
-
- Modes = xf86PruneDuplicateModes(Modes);
-
- return Modes;
-}
-
-struct det_mon_parameter {
- MonPtr Monitor;
- ddc_quirk_t quirks;
- Bool have_hsync;
- Bool have_vrefresh;
- Bool have_maxpixclock;
-};
-
-static void handle_detailed_monset(struct detailed_monitor_section *det_mon,
- void *data)
-{
- int clock;
- struct det_mon_parameter *p = (struct det_mon_parameter *)data;
- int scrnIndex = ((xf86MonPtr)(p->Monitor->DDC))->scrnIndex;
-
- switch (det_mon->type) {
- case DS_RANGES:
- if (!p->have_hsync) {
- if (!p->Monitor->nHsync)
- xf86DrvMsg(scrnIndex, X_INFO,
- "Using EDID range info for horizontal sync\n");
- p->Monitor->hsync[p->Monitor->nHsync].lo =
- det_mon->section.ranges.min_h;
- p->Monitor->hsync[p->Monitor->nHsync].hi =
- det_mon->section.ranges.max_h;
- p->Monitor->nHsync++;
- } else {
- xf86DrvMsg(scrnIndex, X_INFO,
- "Using hsync ranges from config file\n");
- }
-
- if (!p->have_vrefresh) {
- if (!p->Monitor->nVrefresh)
- xf86DrvMsg(scrnIndex, X_INFO,
- "Using EDID range info for vertical refresh\n");
- p->Monitor->vrefresh[p->Monitor->nVrefresh].lo =
- det_mon->section.ranges.min_v;
- p->Monitor->vrefresh[p->Monitor->nVrefresh].hi =
- det_mon->section.ranges.max_v;
- p->Monitor->nVrefresh++;
- } else {
- xf86DrvMsg(scrnIndex, X_INFO,
- "Using vrefresh ranges from config file\n");
- }
-
- clock = det_mon->section.ranges.max_clock * 1000;
- if (p->quirks & DDC_QUIRK_DVI_SINGLE_LINK)
- clock = min(clock, 165000);
- if (!p->have_maxpixclock && clock > p->Monitor->maxPixClock)
- p->Monitor->maxPixClock = clock;
-
- break;
- default:
- break;
- }
-}
-
-/*
- * Fill out MonPtr with xf86MonPtr information.
- */
-void
-xf86EdidMonitorSet(int scrnIndex, MonPtr Monitor, xf86MonPtr DDC)
-{
- DisplayModePtr Modes = NULL, Mode;
- struct det_mon_parameter p;
-
- if (!Monitor || !DDC)
- return;
-
- Monitor->DDC = DDC;
-
- if (Monitor->widthmm <= 0 || Monitor->heightmm <= 0) {
- Monitor->widthmm = 10 * DDC->features.hsize;
- Monitor->heightmm = 10 * DDC->features.vsize;
- }
-
- Monitor->reducedblanking = xf86MonitorSupportsReducedBlanking(DDC);
-
- Modes = xf86DDCGetModes(scrnIndex, DDC);
-
- /* Go through the detailed monitor sections */
- p.Monitor = Monitor;
- p.quirks = xf86DDCDetectQuirks(scrnIndex, Monitor->DDC, FALSE);
- p.have_hsync = (Monitor->nHsync != 0);
- p.have_vrefresh = (Monitor->nVrefresh != 0);
- p.have_maxpixclock = (Monitor->maxPixClock != 0);
- xf86ForEachDetailedBlock(DDC, handle_detailed_monset, &p);
-
- if (Modes) {
- /* Print Modes */
- xf86DrvMsg(scrnIndex, X_INFO, "Printing DDC gathered Modelines:\n");
-
- Mode = Modes;
- while (Mode) {
- xf86PrintModeline(scrnIndex, Mode);
- Mode = Mode->next;
- }
-
- /* Do we still need ranges to be filled in? */
- if (!Monitor->nHsync || !Monitor->nVrefresh)
- DDCGuessRangesFromModes(scrnIndex, Monitor, Modes);
-
- /* look for last Mode */
- Mode = Modes;
-
- while (Mode->next)
- Mode = Mode->next;
-
- /* add to MonPtr */
- if (Monitor->Modes) {
- Monitor->Last->next = Modes;
- Modes->prev = Monitor->Last;
- Monitor->Last = Mode;
- } else {
- Monitor->Modes = Modes;
- Monitor->Last = Mode;
- }
- }
-}
+/*
+ * Copyright 2006 Luc Verhaegen.
+ * Copyright 2008 Red Hat, 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, 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
+ * 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.
+ */
+
+/**
+ * @file This file covers code to convert a xf86MonPtr containing EDID-probed
+ * information into a list of modes, including applying monitor-specific
+ * quirks to fix broken EDID data.
+ */
+#ifdef HAVE_XORG_CONFIG_H
+#include <xorg-config.h>
+#else
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+#endif
+
+#define _PARSE_EDID_
+#include "xf86.h"
+#include "xf86DDC.h"
+#include <X11/Xatom.h>
+#include "property.h"
+#include "propertyst.h"
+#include "xf86Crtc.h"
+#include <string.h>
+#include <math.h>
+
+static void handle_detailed_rblank(struct detailed_monitor_section *det_mon,
+ void *data)
+{
+ if (det_mon->type == DS_RANGES)
+ if (det_mon->section.ranges.supported_blanking & CVT_REDUCED)
+ *(Bool*)data = TRUE;
+}
+
+static Bool
+xf86MonitorSupportsReducedBlanking(xf86MonPtr DDC)
+{
+ /* EDID 1.4 explicitly defines RB support */
+ if (DDC->ver.revision >= 4) {
+ Bool ret = FALSE;
+
+ xf86ForEachDetailedBlock(DDC, handle_detailed_rblank, &ret);
+ return ret;
+ }
+
+ /* For anything older, assume digital means RB support. Boo. */
+ if (DDC->features.input_type)
+ return TRUE;
+
+ return FALSE;
+}
+
+static Bool quirk_prefer_large_60 (int scrnIndex, xf86MonPtr DDC)
+{
+ /* Belinea 10 15 55 */
+ if (memcmp (DDC->vendor.name, "MAX", 4) == 0 &&
+ ((DDC->vendor.prod_id == 1516) ||
+ (DDC->vendor.prod_id == 0x77e)))
+ return TRUE;
+
+ /* Acer AL1706 */
+ if (memcmp (DDC->vendor.name, "ACR", 4) == 0 &&
+ DDC->vendor.prod_id == 44358)
+ return TRUE;
+
+ /* Bug #10814: Samsung SyncMaster 225BW */
+ if (memcmp (DDC->vendor.name, "SAM", 4) == 0 &&
+ DDC->vendor.prod_id == 596)
+ return TRUE;
+
+ /* Bug #10545: Samsung SyncMaster 226BW */
+ if (memcmp (DDC->vendor.name, "SAM", 4) == 0 &&
+ DDC->vendor.prod_id == 638)
+ return TRUE;
+
+ /* Acer F51 */
+ if (memcmp (DDC->vendor.name, "API", 4) == 0 &&
+ DDC->vendor.prod_id == 0x7602)
+ return TRUE;
+
+
+ return FALSE;
+}
+
+static Bool quirk_prefer_large_75 (int scrnIndex, xf86MonPtr DDC)
+{
+ /* Bug #11603: Funai Electronics PM36B */
+ if (memcmp (DDC->vendor.name, "FCM", 4) == 0 &&
+ DDC->vendor.prod_id == 13600)
+ return TRUE;
+
+ return FALSE;
+}
+
+static Bool quirk_detailed_h_in_cm (int scrnIndex, xf86MonPtr DDC)
+{
+ /* Bug #11603: Funai Electronics PM36B */
+ if (memcmp (DDC->vendor.name, "FCM", 4) == 0 &&
+ DDC->vendor.prod_id == 13600)
+ return TRUE;
+
+ return FALSE;
+}
+
+static Bool quirk_detailed_v_in_cm (int scrnIndex, xf86MonPtr DDC)
+{
+ /* Bug #11603: Funai Electronics PM36B */
+ if (memcmp (DDC->vendor.name, "FCM", 4) == 0 &&
+ DDC->vendor.prod_id == 13600)
+ return TRUE;
+
+ /* Bug #21000: LGPhilipsLCD LP154W01-TLAJ */
+ if (memcmp (DDC->vendor.name, "LPL", 4) == 0 &&
+ DDC->vendor.prod_id == 47360)
+ return TRUE;
+
+ /* Bug #10304: LGPhilipsLCD LP154W01-A5 */
+ if (memcmp(DDC->vendor.name, "LPL", 4) == 0 &&
+ DDC->vendor.prod_id == 0)
+ return TRUE;
+
+ /* Bug #24482: LGPhilipsLCD LP154W01-TLA1 */
+ if (memcmp(DDC->vendor.name, "LPL", 4) == 0 &&
+ DDC->vendor.prod_id == 0x2a00)
+ return TRUE;
+
+ /* Bug #28414: HP Compaq NC8430 LP154W01-TLA8 */
+ if (memcmp (DDC->vendor.name, "LPL", 4) == 0 &&
+ DDC->vendor.prod_id == 5750)
+ return TRUE;
+
+ /* Bug #21750: Samsung Syncmaster 2333HD */
+ if (memcmp (DDC->vendor.name, "SAM", 4) == 0 &&
+ DDC->vendor.prod_id == 1157)
+ return TRUE;
+
+ return FALSE;
+}
+
+static Bool quirk_detailed_use_maximum_size (int scrnIndex, xf86MonPtr DDC)
+{
+ /* Bug #21324: Iiyama Vision Master 450 */
+ if (memcmp (DDC->vendor.name, "IVM", 4) == 0 &&
+ DDC->vendor.prod_id == 6400)
+ return TRUE;
+
+ return FALSE;
+}
+
+static Bool quirk_135_clock_too_high (int scrnIndex, xf86MonPtr DDC)
+{
+ /* Envision Peripherals, Inc. EN-7100e. See bug #9550. */
+ if (memcmp (DDC->vendor.name, "EPI", 4) == 0 &&
+ DDC->vendor.prod_id == 59264)
+ return TRUE;
+
+ return FALSE;
+}
+
+static Bool quirk_first_detailed_preferred (int scrnIndex, xf86MonPtr DDC)
+{
+ /* Philips 107p5 CRT. Reported on xorg@ with pastebin. */
+ if (memcmp (DDC->vendor.name, "PHL", 4) == 0 &&
+ DDC->vendor.prod_id == 57364)
+ return TRUE;
+
+ /* Proview AY765C 17" LCD. See bug #15160*/
+ if (memcmp (DDC->vendor.name, "PTS", 4) == 0 &&
+ DDC->vendor.prod_id == 765)
+ return TRUE;
+
+ /* ACR of some sort RH #284231 */
+ if (memcmp (DDC->vendor.name, "ACR", 4) == 0 &&
+ DDC->vendor.prod_id == 2423)
+ return TRUE;
+
+ /* Peacock Ergovision 19. See rh#492359 */
+ if (memcmp (DDC->vendor.name, "PEA", 4) == 0 &&
+ DDC->vendor.prod_id == 9003)
+ return TRUE;
+
+ return FALSE;
+}
+
+static Bool quirk_detailed_sync_pp(int scrnIndex, xf86MonPtr DDC)
+{
+ /* Bug #12439: Samsung SyncMaster 205BW */
+ if (memcmp (DDC->vendor.name, "SAM", 4) == 0 &&
+ DDC->vendor.prod_id == 541)
+ return TRUE;
+ return FALSE;
+}
+
+/* This should probably be made more generic */
+static Bool quirk_dvi_single_link(int scrnIndex, xf86MonPtr DDC)
+{
+ /* Red Hat bug #453106: Apple 23" Cinema Display */
+ if (memcmp (DDC->vendor.name, "APL", 4) == 0 &&
+ DDC->vendor.prod_id == 0x921c)
+ return TRUE;
+ return FALSE;
+}
+
+typedef struct {
+ Bool (*detect) (int scrnIndex, xf86MonPtr DDC);
+ ddc_quirk_t quirk;
+ char *description;
+} ddc_quirk_map_t;
+
+static const ddc_quirk_map_t ddc_quirks[] = {
+ {
+ quirk_prefer_large_60, DDC_QUIRK_PREFER_LARGE_60,
+ "Detailed timing is not preferred, use largest mode at 60Hz"
+ },
+ {
+ quirk_135_clock_too_high, DDC_QUIRK_135_CLOCK_TOO_HIGH,
+ "Recommended 135MHz pixel clock is too high"
+ },
+ {
+ quirk_prefer_large_75, DDC_QUIRK_PREFER_LARGE_75,
+ "Detailed timing is not preferred, use largest mode at 75Hz"
+ },
+ {
+ quirk_detailed_h_in_cm, DDC_QUIRK_DETAILED_H_IN_CM,
+ "Detailed timings give horizontal size in cm."
+ },
+ {
+ quirk_detailed_v_in_cm, DDC_QUIRK_DETAILED_V_IN_CM,
+ "Detailed timings give vertical size in cm."
+ },
+ {
+ quirk_detailed_use_maximum_size, DDC_QUIRK_DETAILED_USE_MAXIMUM_SIZE,
+ "Use maximum size instead of detailed timing sizes."
+ },
+ {
+ quirk_first_detailed_preferred, DDC_QUIRK_FIRST_DETAILED_PREFERRED,
+ "First detailed timing was not marked as preferred."
+ },
+ {
+ quirk_detailed_sync_pp, DDC_QUIRK_DETAILED_SYNC_PP,
+ "Use +hsync +vsync for detailed timing."
+ },
+ {
+ quirk_dvi_single_link, DDC_QUIRK_DVI_SINGLE_LINK,
+ "Forcing maximum pixel clock to single DVI link."
+ },
+ {
+ NULL, DDC_QUIRK_NONE,
+ "No known quirks"
+ },
+};
+
+/*
+ * These more or less come from the DMT spec. The 720x400 modes are
+ * inferred from historical 80x25 practice. The 640x480@67 and 832x624@75
+ * modes are old-school Mac modes. The EDID spec says the 1152x864@75 mode
+ * should be 1152x870, again for the Mac, but instead we use the x864 DMT
+ * mode.
+ *
+ * The DMT modes have been fact-checked; the rest are mild guesses.
+ */
+#define MODEPREFIX NULL, NULL, NULL, 0, M_T_DRIVER
+#define MODESUFFIX 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,FALSE,FALSE,0,NULL,0,0.0,0.0
+
+static const DisplayModeRec DDCEstablishedModes[17] = {
+ { MODEPREFIX, 40000, 800, 840, 968, 1056, 0, 600, 601, 605, 628, 0, V_PHSYNC | V_PVSYNC, MODESUFFIX }, /* 800x600@60Hz */
+ { MODEPREFIX, 36000, 800, 824, 896, 1024, 0, 600, 601, 603, 625, 0, V_PHSYNC | V_PVSYNC, MODESUFFIX }, /* 800x600@56Hz */
+ { MODEPREFIX, 31500, 640, 656, 720, 840, 0, 480, 481, 484, 500, 0, V_NHSYNC | V_NVSYNC, MODESUFFIX }, /* 640x480@75Hz */
+ { MODEPREFIX, 31500, 640, 664, 704, 832, 0, 480, 489, 492, 520, 0, V_NHSYNC | V_NVSYNC, MODESUFFIX }, /* 640x480@72Hz */
+ { MODEPREFIX, 30240, 640, 704, 768, 864, 0, 480, 483, 486, 525, 0, V_NHSYNC | V_NVSYNC, MODESUFFIX }, /* 640x480@67Hz */
+ { MODEPREFIX, 25175, 640, 656, 752, 800, 0, 480, 490, 492, 525, 0, V_NHSYNC | V_NVSYNC, MODESUFFIX }, /* 640x480@60Hz */
+ { MODEPREFIX, 35500, 720, 738, 846, 900, 0, 400, 421, 423, 449, 0, V_NHSYNC | V_NVSYNC, MODESUFFIX }, /* 720x400@88Hz */
+ { MODEPREFIX, 28320, 720, 738, 846, 900, 0, 400, 412, 414, 449, 0, V_NHSYNC | V_PVSYNC, MODESUFFIX }, /* 720x400@70Hz */
+ { MODEPREFIX, 135000, 1280, 1296, 1440, 1688, 0, 1024, 1025, 1028, 1066, 0, V_PHSYNC | V_PVSYNC, MODESUFFIX }, /* 1280x1024@75Hz */
+ { MODEPREFIX, 78750, 1024, 1040, 1136, 1312, 0, 768, 769, 772, 800, 0, V_PHSYNC | V_PVSYNC, MODESUFFIX }, /* 1024x768@75Hz */
+ { MODEPREFIX, 75000, 1024, 1048, 1184, 1328, 0, 768, 771, 777, 806, 0, V_NHSYNC | V_NVSYNC, MODESUFFIX }, /* 1024x768@70Hz */
+ { MODEPREFIX, 65000, 1024, 1048, 1184, 1344, 0, 768, 771, 777, 806, 0, V_NHSYNC | V_NVSYNC, MODESUFFIX }, /* 1024x768@60Hz */
+ { MODEPREFIX, 44900, 1024, 1032, 1208, 1264, 0, 768, 768, 772, 817, 0, V_PHSYNC | V_PVSYNC | V_INTERLACE, MODESUFFIX }, /* 1024x768@43Hz */
+ { MODEPREFIX, 57284, 832, 864, 928, 1152, 0, 624, 625, 628, 667, 0, V_NHSYNC | V_NVSYNC, MODESUFFIX }, /* 832x624@75Hz */
+ { MODEPREFIX, 49500, 800, 816, 896, 1056, 0, 600, 601, 604, 625, 0, V_PHSYNC | V_PVSYNC, MODESUFFIX }, /* 800x600@75Hz */
+ { MODEPREFIX, 50000, 800, 856, 976, 1040, 0, 600, 637, 643, 666, 0, V_PHSYNC | V_PVSYNC, MODESUFFIX }, /* 800x600@72Hz */
+ { MODEPREFIX, 108000, 1152, 1216, 1344, 1600, 0, 864, 865, 868, 900, 0, V_PHSYNC | V_PVSYNC, MODESUFFIX }, /* 1152x864@75Hz */
+};
+
+static DisplayModePtr
+DDCModesFromEstablished(int scrnIndex, struct established_timings *timing,
+ ddc_quirk_t quirks)
+{
+ DisplayModePtr Modes = NULL, Mode = NULL;
+ CARD32 bits = (timing->t1) | (timing->t2 << 8) |
+ ((timing->t_manu & 0x80) << 9);
+ int i;
+
+ for (i = 0; i < 17; i++) {
+ if (bits & (0x01 << i)) {
+ Mode = xf86DuplicateMode(&DDCEstablishedModes[i]);
+ Modes = xf86ModesAdd(Modes, Mode);
+ }
+ }
+
+ return Modes;
+}
+
+/* Autogenerated from the DMT spec */
+const DisplayModeRec DMTModes[] = {
+ { MODEPREFIX, 31500, 640, 672, 736, 832, 0, 350, 382, 385, 445, 0, V_PHSYNC | V_NVSYNC, MODESUFFIX }, /* 640x350@85Hz */
+ { MODEPREFIX, 31500, 640, 672, 736, 832, 0, 400, 401, 404, 445, 0, V_NHSYNC | V_PVSYNC, MODESUFFIX }, /* 640x400@85Hz */
+ { MODEPREFIX, 35500, 720, 756, 828, 936, 0, 400, 401, 404, 446, 0, V_NHSYNC | V_PVSYNC, MODESUFFIX }, /* 720x400@85Hz */
+ { MODEPREFIX, 25175, 640, 656, 752, 800, 0, 480, 490, 492, 525, 0, V_NHSYNC | V_NVSYNC, MODESUFFIX }, /* 640x480@60Hz */
+ { MODEPREFIX, 31500, 640, 664, 704, 832, 0, 480, 489, 492, 520, 0, V_NHSYNC | V_NVSYNC, MODESUFFIX }, /* 640x480@72Hz */
+ { MODEPREFIX, 31500, 640, 656, 720, 840, 0, 480, 481, 484, 500, 0, V_NHSYNC | V_NVSYNC, MODESUFFIX }, /* 640x480@75Hz */
+ { MODEPREFIX, 36000, 640, 696, 752, 832, 0, 480, 481, 484, 509, 0, V_NHSYNC | V_NVSYNC, MODESUFFIX }, /* 640x480@85Hz */
+ { MODEPREFIX, 36000, 800, 824, 896, 1024, 0, 600, 601, 603, 625, 0, V_PHSYNC | V_PVSYNC, MODESUFFIX }, /* 800x600@56Hz */
+ { MODEPREFIX, 40000, 800, 840, 968, 1056, 0, 600, 601, 605, 628, 0, V_PHSYNC | V_PVSYNC, MODESUFFIX }, /* 800x600@60Hz */
+ { MODEPREFIX, 50000, 800, 856, 976, 1040, 0, 600, 637, 643, 666, 0, V_PHSYNC | V_PVSYNC, MODESUFFIX }, /* 800x600@72Hz */
+ { MODEPREFIX, 49500, 800, 816, 896, 1056, 0, 600, 601, 604, 625, 0, V_PHSYNC | V_PVSYNC, MODESUFFIX }, /* 800x600@75Hz */
+ { MODEPREFIX, 56250, 800, 832, 896, 1048, 0, 600, 601, 604, 631, 0, V_PHSYNC | V_PVSYNC, MODESUFFIX }, /* 800x600@85Hz */
+ { MODEPREFIX, 73250, 800, 848, 880, 960, 0, 600, 603, 607, 636, 0, V_PHSYNC | V_NVSYNC, MODESUFFIX }, /* 800x600@120Hz RB */
+ { MODEPREFIX, 33750, 848, 864, 976, 1088, 0, 480, 486, 494, 517, 0, V_PHSYNC | V_PVSYNC, MODESUFFIX }, /* 848x480@60Hz */
+ { MODEPREFIX, 44900, 1024, 1032, 1208, 1264, 0, 768, 768, 772, 817, 0, V_PHSYNC | V_PVSYNC | V_INTERLACE, MODESUFFIX }, /* 1024x768@43Hz (interlaced) */
+ { MODEPREFIX, 65000, 1024, 1048, 1184, 1344, 0, 768, 771, 777, 806, 0, V_NHSYNC | V_NVSYNC, MODESUFFIX }, /* 1024x768@60Hz */
+ { MODEPREFIX, 75000, 1024, 1048, 1184, 1328, 0, 768, 771, 777, 806, 0, V_NHSYNC | V_NVSYNC, MODESUFFIX }, /* 1024x768@70Hz */
+ { MODEPREFIX, 78750, 1024, 1040, 1136, 1312, 0, 768, 769, 772, 800, 0, V_PHSYNC | V_PVSYNC, MODESUFFIX }, /* 1024x768@75Hz */
+ { MODEPREFIX, 94500, 1024, 1072, 1168, 1376, 0, 768, 769, 772, 808, 0, V_PHSYNC | V_PVSYNC, MODESUFFIX }, /* 1024x768@85Hz */
+ { MODEPREFIX, 115500, 1024, 1072, 1104, 1184, 0, 768, 771, 775, 813, 0, V_PHSYNC | V_NVSYNC, MODESUFFIX }, /* 1024x768@120Hz RB */
+ { MODEPREFIX, 108000, 1152, 1216, 1344, 1600, 0, 864, 865, 868, 900, 0, V_PHSYNC | V_PVSYNC, MODESUFFIX }, /* 1152x864@75Hz */
+ { MODEPREFIX, 68250, 1280, 1328, 1360, 1440, 0, 768, 771, 778, 790, 0, V_PHSYNC | V_NVSYNC, MODESUFFIX }, /* 1280x768@60Hz RB */
+ { MODEPREFIX, 79500, 1280, 1344, 1472, 1664, 0, 768, 771, 778, 798, 0, V_NHSYNC | V_PVSYNC, MODESUFFIX }, /* 1280x768@60Hz */
+ { MODEPREFIX, 102250, 1280, 1360, 1488, 1696, 0, 768, 771, 778, 805, 0, V_NHSYNC | V_PVSYNC, MODESUFFIX }, /* 1280x768@75Hz */
+ { MODEPREFIX, 117500, 1280, 1360, 1496, 1712, 0, 768, 771, 778, 809, 0, V_NHSYNC | V_PVSYNC, MODESUFFIX }, /* 1280x768@85Hz */
+ { MODEPREFIX, 140250, 1280, 1328, 1360, 1440, 0, 768, 771, 778, 813, 0, V_PHSYNC | V_NVSYNC, MODESUFFIX }, /* 1280x768@120Hz RB */
+ { MODEPREFIX, 71000, 1280, 1328, 1360, 1440, 0, 800, 803, 809, 823, 0, V_PHSYNC | V_NVSYNC, MODESUFFIX }, /* 1280x800@60Hz RB */
+ { MODEPREFIX, 83500, 1280, 1352, 1480, 1680, 0, 800, 803, 809, 831, 0, V_NHSYNC | V_PVSYNC, MODESUFFIX }, /* 1280x800@60Hz */
+ { MODEPREFIX, 106500, 1280, 1360, 1488, 1696, 0, 800, 803, 809, 838, 0, V_NHSYNC | V_PVSYNC, MODESUFFIX }, /* 1280x800@75Hz */
+ { MODEPREFIX, 122500, 1280, 1360, 1496, 1712, 0, 800, 803, 809, 843, 0, V_NHSYNC | V_PVSYNC, MODESUFFIX }, /* 1280x800@85Hz */
+ { MODEPREFIX, 146250, 1280, 1328, 1360, 1440, 0, 800, 803, 809, 847, 0, V_PHSYNC | V_NVSYNC, MODESUFFIX }, /* 1280x800@120Hz RB */
+ { MODEPREFIX, 108000, 1280, 1376, 1488, 1800, 0, 960, 961, 964, 1000, 0, V_PHSYNC | V_PVSYNC, MODESUFFIX }, /* 1280x960@60Hz */
+ { MODEPREFIX, 148500, 1280, 1344, 1504, 1728, 0, 960, 961, 964, 1011, 0, V_PHSYNC | V_PVSYNC, MODESUFFIX }, /* 1280x960@85Hz */
+ { MODEPREFIX, 175500, 1280, 1328, 1360, 1440, 0, 960, 963, 967, 1017, 0, V_PHSYNC | V_NVSYNC, MODESUFFIX }, /* 1280x960@120Hz RB */
+ { MODEPREFIX, 108000, 1280, 1328, 1440, 1688, 0, 1024, 1025, 1028, 1066, 0, V_PHSYNC | V_PVSYNC, MODESUFFIX }, /* 1280x1024@60Hz */
+ { MODEPREFIX, 135000, 1280, 1296, 1440, 1688, 0, 1024, 1025, 1028, 1066, 0, V_PHSYNC | V_PVSYNC, MODESUFFIX }, /* 1280x1024@75Hz */
+ { MODEPREFIX, 157500, 1280, 1344, 1504, 1728, 0, 1024, 1025, 1028, 1072, 0, V_PHSYNC | V_PVSYNC, MODESUFFIX }, /* 1280x1024@85Hz */
+ { MODEPREFIX, 187250, 1280, 1328, 1360, 1440, 0, 1024, 1027, 1034, 1084, 0, V_PHSYNC | V_NVSYNC, MODESUFFIX }, /* 1280x1024@120Hz RB */
+ { MODEPREFIX, 85500, 1360, 1424, 1536, 1792, 0, 768, 771, 777, 795, 0, V_PHSYNC | V_PVSYNC, MODESUFFIX }, /* 1360x768@60Hz */
+ { MODEPREFIX, 148250, 1360, 1408, 1440, 1520, 0, 768, 771, 776, 813, 0, V_PHSYNC | V_NVSYNC, MODESUFFIX }, /* 1360x768@120Hz RB */
+ { MODEPREFIX, 101000, 1400, 1448, 1480, 1560, 0, 1050, 1053, 1057, 1080, 0, V_PHSYNC | V_NVSYNC, MODESUFFIX }, /* 1400x1050@60Hz RB */
+ { MODEPREFIX, 121750, 1400, 1488, 1632, 1864, 0, 1050, 1053, 1057, 1089, 0, V_NHSYNC | V_PVSYNC, MODESUFFIX }, /* 1400x1050@60Hz */
+ { MODEPREFIX, 156000, 1400, 1504, 1648, 1896, 0, 1050, 1053, 1057, 1099, 0, V_NHSYNC | V_PVSYNC, MODESUFFIX }, /* 1400x1050@75Hz */
+ { MODEPREFIX, 179500, 1400, 1504, 1656, 1912, 0, 1050, 1053, 1057, 1105, 0, V_NHSYNC | V_PVSYNC, MODESUFFIX }, /* 1400x1050@85Hz */
+ { MODEPREFIX, 208000, 1400, 1448, 1480, 1560, 0, 1050, 1053, 1057, 1112, 0, V_PHSYNC | V_NVSYNC, MODESUFFIX }, /* 1400x1050@120Hz RB */
+ { MODEPREFIX, 88750, 1440, 1488, 1520, 1600, 0, 900, 903, 909, 926, 0, V_PHSYNC | V_NVSYNC, MODESUFFIX }, /* 1440x900@60Hz RB */
+ { MODEPREFIX, 106500, 1440, 1520, 1672, 1904, 0, 900, 903, 909, 934, 0, V_NHSYNC | V_PVSYNC, MODESUFFIX }, /* 1440x900@60Hz */
+ { MODEPREFIX, 136750, 1440, 1536, 1688, 1936, 0, 900, 903, 909, 942, 0, V_NHSYNC | V_PVSYNC, MODESUFFIX }, /* 1440x900@75Hz */
+ { MODEPREFIX, 157000, 1440, 1544, 1696, 1952, 0, 900, 903, 909, 948, 0, V_NHSYNC | V_PVSYNC, MODESUFFIX }, /* 1440x900@85Hz */
+ { MODEPREFIX, 182750, 1440, 1488, 1520, 1600, 0, 900, 903, 909, 953, 0, V_PHSYNC | V_NVSYNC, MODESUFFIX }, /* 1440x900@120Hz RB */
+ { MODEPREFIX, 162000, 1600, 1664, 1856, 2160, 0, 1200, 1201, 1204, 1250, 0, V_PHSYNC | V_PVSYNC, MODESUFFIX }, /* 1600x1200@60Hz */
+ { MODEPREFIX, 175500, 1600, 1664, 1856, 2160, 0, 1200, 1201, 1204, 1250, 0, V_PHSYNC | V_PVSYNC, MODESUFFIX }, /* 1600x1200@65Hz */
+ { MODEPREFIX, 189000, 1600, 1664, 1856, 2160, 0, 1200, 1201, 1204, 1250, 0, V_PHSYNC | V_PVSYNC, MODESUFFIX }, /* 1600x1200@70Hz */
+ { MODEPREFIX, 202500, 1600, 1664, 1856, 2160, 0, 1200, 1201, 1204, 1250, 0, V_PHSYNC | V_PVSYNC, MODESUFFIX }, /* 1600x1200@75Hz */
+ { MODEPREFIX, 229500, 1600, 1664, 1856, 2160, 0, 1200, 1201, 1204, 1250, 0, V_PHSYNC | V_PVSYNC, MODESUFFIX }, /* 1600x1200@85Hz */
+ { MODEPREFIX, 268250, 1600, 1648, 1680, 1760, 0, 1200, 1203, 1207, 1271, 0, V_PHSYNC | V_NVSYNC, MODESUFFIX }, /* 1600x1200@120Hz RB */
+ { MODEPREFIX, 119000, 1680, 1728, 1760, 1840, 0, 1050, 1053, 1059, 1080, 0, V_PHSYNC | V_NVSYNC, MODESUFFIX }, /* 1680x1050@60Hz RB */
+ { MODEPREFIX, 146250, 1680, 1784, 1960, 2240, 0, 1050, 1053, 1059, 1089, 0, V_NHSYNC | V_PVSYNC, MODESUFFIX }, /* 1680x1050@60Hz */
+ { MODEPREFIX, 187000, 1680, 1800, 1976, 2272, 0, 1050, 1053, 1059, 1099, 0, V_NHSYNC | V_PVSYNC, MODESUFFIX }, /* 1680x1050@75Hz */
+ { MODEPREFIX, 214750, 1680, 1808, 1984, 2288, 0, 1050, 1053, 1059, 1105, 0, V_NHSYNC | V_PVSYNC, MODESUFFIX }, /* 1680x1050@85Hz */
+ { MODEPREFIX, 245500, 1680, 1728, 1760, 1840, 0, 1050, 1053, 1059, 1112, 0, V_PHSYNC | V_NVSYNC, MODESUFFIX }, /* 1680x1050@120Hz RB */
+ { MODEPREFIX, 204750, 1792, 1920, 2120, 2448, 0, 1344, 1345, 1348, 1394, 0, V_NHSYNC | V_PVSYNC, MODESUFFIX }, /* 1792x1344@60Hz */
+ { MODEPREFIX, 261000, 1792, 1888, 2104, 2456, 0, 1344, 1345, 1348, 1417, 0, V_NHSYNC | V_PVSYNC, MODESUFFIX }, /* 1792x1344@75Hz */
+ { MODEPREFIX, 333250, 1792, 1840, 1872, 1952, 0, 1344, 1347, 1351, 1423, 0, V_PHSYNC | V_NVSYNC, MODESUFFIX }, /* 1792x1344@120Hz RB */
+ { MODEPREFIX, 218250, 1856, 1952, 2176, 2528, 0, 1392, 1393, 1396, 1439, 0, V_NHSYNC | V_PVSYNC, MODESUFFIX }, /* 1856x1392@60Hz */
+ { MODEPREFIX, 288000, 1856, 1984, 2208, 2560, 0, 1392, 1393, 1396, 1500, 0, V_NHSYNC | V_PVSYNC, MODESUFFIX }, /* 1856x1392@75Hz */
+ { MODEPREFIX, 356500, 1856, 1904, 1936, 2016, 0, 1392, 1395, 1399, 1474, 0, V_PHSYNC | V_NVSYNC, MODESUFFIX }, /* 1856x1392@120Hz RB */
+ { MODEPREFIX, 154000, 1920, 1968, 2000, 2080, 0, 1200, 1203, 1209, 1235, 0, V_PHSYNC | V_NVSYNC, MODESUFFIX }, /* 1920x1200@60Hz RB */
+ { MODEPREFIX, 193250, 1920, 2056, 2256, 2592, 0, 1200, 1203, 1209, 1245, 0, V_NHSYNC | V_PVSYNC, MODESUFFIX }, /* 1920x1200@60Hz */
+ { MODEPREFIX, 245250, 1920, 2056, 2264, 2608, 0, 1200, 1203, 1209, 1255, 0, V_NHSYNC | V_PVSYNC, MODESUFFIX }, /* 1920x1200@75Hz */
+ { MODEPREFIX, 281250, 1920, 2064, 2272, 2624, 0, 1200, 1203, 1209, 1262, 0, V_NHSYNC | V_PVSYNC, MODESUFFIX }, /* 1920x1200@85Hz */
+ { MODEPREFIX, 317000, 1920, 1968, 2000, 2080, 0, 1200, 1203, 1209, 1271, 0, V_PHSYNC | V_NVSYNC, MODESUFFIX }, /* 1920x1200@120Hz RB */
+ { MODEPREFIX, 234000, 1920, 2048, 2256, 2600, 0, 1440, 1441, 1444, 1500, 0, V_NHSYNC | V_PVSYNC, MODESUFFIX }, /* 1920x1440@60Hz */
+ { MODEPREFIX, 297000, 1920, 2064, 2288, 2640, 0, 1440, 1441, 1444, 1500, 0, V_NHSYNC | V_PVSYNC, MODESUFFIX }, /* 1920x1440@75Hz */
+ { MODEPREFIX, 380500, 1920, 1968, 2000, 2080, 0, 1440, 1443, 1447, 1525, 0, V_PHSYNC | V_NVSYNC, MODESUFFIX }, /* 1920x1440@120Hz RB */
+ { MODEPREFIX, 268500, 2560, 2608, 2640, 2720, 0, 1600, 1603, 1609, 1646, 0, V_PHSYNC | V_NVSYNC, MODESUFFIX }, /* 2560x1600@60Hz RB */
+ { MODEPREFIX, 348500, 2560, 2752, 3032, 3504, 0, 1600, 1603, 1609, 1658, 0, V_NHSYNC | V_PVSYNC, MODESUFFIX }, /* 2560x1600@60Hz */
+ { MODEPREFIX, 443250, 2560, 2768, 3048, 3536, 0, 1600, 1603, 1609, 1672, 0, V_NHSYNC | V_PVSYNC, MODESUFFIX }, /* 2560x1600@75Hz */
+ { MODEPREFIX, 505250, 2560, 2768, 3048, 3536, 0, 1600, 1603, 1609, 1682, 0, V_NHSYNC | V_PVSYNC, MODESUFFIX }, /* 2560x1600@85Hz */
+ { MODEPREFIX, 552750, 2560, 2608, 2640, 2720, 0, 1600, 1603, 1609, 1694, 0, V_PHSYNC | V_NVSYNC, MODESUFFIX }, /* 2560x1600@120Hz RB */
+};
+
+#define LEVEL_DMT 0
+#define LEVEL_GTF 1
+#define LEVEL_CVT 2
+
+static int
+MonitorStandardTimingLevel(xf86MonPtr DDC)
+{
+ if (DDC->ver.revision >= 2) {
+ if (DDC->ver.revision >= 4 && CVT_SUPPORTED(DDC->features.msc)) {
+ return LEVEL_CVT;
+ }
+ return LEVEL_GTF;
+ }
+ return LEVEL_DMT;
+}
+
+static int
+ModeRefresh(const DisplayModeRec *mode)
+{
+ return (int)(xf86ModeVRefresh(mode) + 0.5);
+}
+
+/*
+ * If rb is not set, then we'll not consider reduced-blanking modes as
+ * part of the DMT pool. For the 'standard' EDID mode descriptor there's
+ * no way to specify whether the mode should be RB or not.
+ */
+DisplayModePtr
+FindDMTMode(int hsize, int vsize, int refresh, Bool rb)
+{
+ int i;
+ const DisplayModeRec *ret;
+
+ for (i = 0; i < sizeof(DMTModes) / sizeof(DisplayModeRec); i++) {
+ ret = &DMTModes[i];
+
+ if (!rb && xf86ModeIsReduced(ret))
+ continue;
+
+ if (ret->HDisplay == hsize &&
+ ret->VDisplay == vsize &&
+ refresh == ModeRefresh(ret))
+ return xf86DuplicateMode(ret);
+ }
+
+ return NULL;
+}
+
+/*
+ * Appendix B of the EDID 1.4 spec defines the right thing to do here.
+ * If the timing given here matches a mode defined in the VESA DMT standard,
+ * we _must_ use that. If the device supports CVT modes, then we should
+ * generate a CVT timing. If both of the above fail, use GTF.
+ *
+ * There are some wrinkles here. EDID 1.1 and 1.0 sinks can't really
+ * "support" GTF, since it wasn't a standard yet; so if they ask for a
+ * timing in this section that isn't defined in DMT, returning a GTF mode
+ * may not actually be valid. EDID 1.3 sinks often report support for
+ * some CVT modes, but they are not required to support CVT timings for
+ * modes in the standard timing descriptor, so we should _not_ treat them
+ * as CVT-compliant (unless specified in an extension block I suppose).
+ *
+ * EDID 1.4 requires that all sink devices support both GTF and CVT timings
+ * for modes in this section, but does say that CVT is preferred.
+ */
+static DisplayModePtr
+DDCModesFromStandardTiming(struct std_timings *timing, ddc_quirk_t quirks,
+ int timing_level, Bool rb)
+{
+ DisplayModePtr Modes = NULL, Mode = NULL;
+ int i, hsize, vsize, refresh;
+
+ for (i = 0; i < STD_TIMINGS; i++) {
+ hsize = timing[i].hsize;
+ vsize = timing[i].vsize;
+ refresh = timing[i].refresh;
+
+ /* HDTV hack, because you can't say 1366 */
+ if (refresh == 60 &&
+ ((hsize == 1360 && vsize == 765) ||
+ (hsize == 1368 && vsize == 769))) {
+ Mode = xf86CVTMode(1366, 768, 60, FALSE, FALSE);
+ Mode->HDisplay = 1366;
+ Mode->HSyncStart--;
+ Mode->HSyncEnd--;
+ } else if (hsize && vsize && refresh) {
+ Mode = FindDMTMode(hsize, vsize, refresh, rb);
+
+ if (!Mode) {
+ if (timing_level == LEVEL_CVT)
+ /* pass rb here too? */
+ Mode = xf86CVTMode(hsize, vsize, refresh, FALSE, FALSE);
+ else if (timing_level == LEVEL_GTF)
+ Mode = xf86GTFMode(hsize, vsize, refresh, FALSE, FALSE);
+ }
+
+ }
+
+ if (Mode) {
+ Mode->type = M_T_DRIVER;
+ Modes = xf86ModesAdd(Modes, Mode);
+ }
+ Mode = NULL;
+ }
+
+ return Modes;
+}
+
+static void
+DDCModeDoInterlaceQuirks(DisplayModePtr mode)
+{
+ /*
+ * EDID is delightfully ambiguous about how interlaced modes are to be
+ * encoded. X's internal representation is of frame height, but some
+ * HDTV detailed timings are encoded as field height.
+ *
+ * The format list here is from CEA, in frame size. Technically we
+ * should be checking refresh rate too. Whatever.
+ */
+ static const struct {
+ int w, h;
+ } cea_interlaced[] = {
+ { 1920, 1080 },
+ { 720, 480 },
+ { 1440, 480 },
+ { 2880, 480 },
+ { 720, 576 },
+ { 1440, 576 },
+ { 2880, 576 },
+ };
+ static const int n_modes = sizeof(cea_interlaced)/sizeof(cea_interlaced[0]);
+ int i;
+
+ for (i = 0; i < n_modes; i++) {
+ if ((mode->HDisplay == cea_interlaced[i].w) &&
+ (mode->VDisplay == cea_interlaced[i].h / 2)) {
+ mode->VDisplay *= 2;
+ mode->VSyncStart *= 2;
+ mode->VSyncEnd *= 2;
+ mode->VTotal *= 2;
+ mode->VTotal |= 1;
+ }
+ }
+
+ mode->Flags |= V_INTERLACE;
+}
+
+/*
+ *
+ */
+static DisplayModePtr
+DDCModeFromDetailedTiming(int scrnIndex, struct detailed_timings *timing,
+ Bool preferred, ddc_quirk_t quirks)
+{
+ DisplayModePtr Mode;
+
+ /*
+ * Refuse to create modes that are insufficiently large. 64 is a random
+ * number, maybe the spec says something about what the minimum is. In
+ * particular I see this frequently with _old_ EDID, 1.0 or so, so maybe
+ * our parser is just being too aggresive there.
+ */
+ if (timing->h_active < 64 || timing->v_active < 64) {
+ xf86DrvMsg(scrnIndex, X_INFO,
+ "%s: Ignoring tiny %dx%d mode\n", __func__,
+ timing->h_active, timing->v_active);
+ return NULL;
+ }
+
+ /* We don't do stereo */
+ if (timing->stereo) {
+ xf86DrvMsg(scrnIndex, X_INFO,
+ "%s: Ignoring: We don't handle stereo.\n", __func__);
+ return NULL;
+ }
+
+ /* We only do seperate sync currently */
+ if (timing->sync != 0x03) {
+ xf86DrvMsg(scrnIndex, X_INFO,
+ "%s: %dx%d Warning: We only handle separate"
+ " sync.\n", __func__, timing->h_active, timing->v_active);
+ }
+
+ Mode = xnfcalloc(1, sizeof(DisplayModeRec));
+
+ Mode->type = M_T_DRIVER;
+ if (preferred)
+ Mode->type |= M_T_PREFERRED;
+
+ if( ( quirks & DDC_QUIRK_135_CLOCK_TOO_HIGH ) &&
+ timing->clock == 135000000 )
+ Mode->Clock = 108880;
+ else
+ Mode->Clock = timing->clock / 1000.0;
+
+ Mode->HDisplay = timing->h_active;
+ Mode->HSyncStart = timing->h_active + timing->h_sync_off;
+ Mode->HSyncEnd = Mode->HSyncStart + timing->h_sync_width;
+ Mode->HTotal = timing->h_active + timing->h_blanking;
+
+ Mode->VDisplay = timing->v_active;
+ Mode->VSyncStart = timing->v_active + timing->v_sync_off;
+ Mode->VSyncEnd = Mode->VSyncStart + timing->v_sync_width;
+ Mode->VTotal = timing->v_active + timing->v_blanking;
+
+ /* perform basic check on the detail timing */
+ if (Mode->HSyncEnd > Mode->HTotal || Mode->VSyncEnd > Mode->VTotal) {
+ free(Mode);
+ return NULL;
+ }
+
+ /* We ignore h/v_size and h/v_border for now. */
+
+ if (timing->interlaced)
+ DDCModeDoInterlaceQuirks(Mode);
+
+ if (quirks & DDC_QUIRK_DETAILED_SYNC_PP)
+ Mode->Flags |= V_PVSYNC | V_PHSYNC;
+ else {
+ if (timing->misc & 0x02)
+ Mode->Flags |= V_PVSYNC;
+ else
+ Mode->Flags |= V_NVSYNC;
+
+ if (timing->misc & 0x01)
+ Mode->Flags |= V_PHSYNC;
+ else
+ Mode->Flags |= V_NHSYNC;
+ }
+
+ xf86SetModeDefaultName(Mode);
+
+ return Mode;
+}
+
+static DisplayModePtr
+DDCModesFromCVT(int scrnIndex, struct cvt_timings *t)
+{
+ DisplayModePtr modes = NULL;
+ int i;
+
+ for (i = 0; i < 4; i++) {
+ if (t[i].height) {
+ if (t[i].rates & 0x10)
+ modes = xf86ModesAdd(modes,
+ xf86CVTMode(t[i].width, t[i].height, 50, 0, 0));
+ if (t[i].rates & 0x08)
+ modes = xf86ModesAdd(modes,
+ xf86CVTMode(t[i].width, t[i].height, 60, 0, 0));
+ if (t[i].rates & 0x04)
+ modes = xf86ModesAdd(modes,
+ xf86CVTMode(t[i].width, t[i].height, 75, 0, 0));
+ if (t[i].rates & 0x02)
+ modes = xf86ModesAdd(modes,
+ xf86CVTMode(t[i].width, t[i].height, 85, 0, 0));
+ if (t[i].rates & 0x01)
+ modes = xf86ModesAdd(modes,
+ xf86CVTMode(t[i].width, t[i].height, 60, 1, 0));
+ } else break;
+ }
+
+ return modes;
+}
+
+static const struct {
+ short w;
+ short h;
+ short r;
+ short rb;
+} EstIIIModes[] = {
+ /* byte 6 */
+ { 640, 350, 85, 0 },
+ { 640, 400, 85, 0 },
+ { 720, 400, 85, 0 },
+ { 640, 480, 85, 0 },
+ { 848, 480, 60, 0 },
+ { 800, 600, 85, 0 },
+ { 1024, 768, 85, 0 },
+ { 1152, 864, 75, 0 },
+ /* byte 7 */
+ { 1280, 768, 60, 1 },
+ { 1280, 768, 60, 0 },
+ { 1280, 768, 75, 0 },
+ { 1280, 768, 85, 0 },
+ { 1280, 960, 60, 0 },
+ { 1280, 960, 85, 0 },
+ { 1280, 1024, 60, 0 },
+ { 1280, 1024, 85, 0 },
+ /* byte 8 */
+ { 1360, 768, 60, 0 },
+ { 1440, 900, 60, 1 },
+ { 1440, 900, 60, 0 },
+ { 1440, 900, 75, 0 },
+ { 1440, 900, 85, 0 },
+ { 1400, 1050, 60, 1 },
+ { 1400, 1050, 60, 0 },
+ { 1400, 1050, 75, 0 },
+ /* byte 9 */
+ { 1400, 1050, 85, 0 },
+ { 1680, 1050, 60, 1 },
+ { 1680, 1050, 60, 0 },
+ { 1680, 1050, 75, 0 },
+ { 1680, 1050, 85, 0 },
+ { 1600, 1200, 60, 0 },
+ { 1600, 1200, 65, 0 },
+ { 1600, 1200, 70, 0 },
+ /* byte 10 */
+ { 1600, 1200, 75, 0 },
+ { 1600, 1200, 85, 0 },
+ { 1792, 1344, 60, 0 },
+ { 1792, 1344, 85, 0 },
+ { 1856, 1392, 60, 0 },
+ { 1856, 1392, 75, 0 },
+ { 1920, 1200, 60, 1 },
+ { 1920, 1200, 60, 0 },
+ /* byte 11 */
+ { 1920, 1200, 75, 0 },
+ { 1920, 1200, 85, 0 },
+ { 1920, 1440, 60, 0 },
+ { 1920, 1440, 75, 0 },
+};
+
+static DisplayModePtr
+DDCModesFromEstIII(unsigned char *est)
+{
+ DisplayModePtr modes = NULL;
+ int i, j, m;
+
+ for (i = 0; i < 6; i++) {
+ for (j = 7; j > 0; j--) {
+ if (est[i] & (1 << j)) {
+ m = (i * 8) + (7 - j);
+ modes = xf86ModesAdd(modes,
+ FindDMTMode(EstIIIModes[m].w,
+ EstIIIModes[m].h,
+ EstIIIModes[m].r,
+ EstIIIModes[m].rb));
+ }
+ }
+ }
+
+ return modes;
+}
+
+/*
+ * This is only valid when the sink claims to be continuous-frequency
+ * but does not supply a detailed range descriptor. Such sinks are
+ * arguably broken. Currently the mode validation code isn't aware of
+ * this; the non-RANDR code even punts the decision of optional sync
+ * range checking to the driver. Loss.
+ */
+static void
+DDCGuessRangesFromModes(int scrnIndex, MonPtr Monitor, DisplayModePtr Modes)
+{
+ DisplayModePtr Mode = Modes;
+
+ if (!Monitor || !Modes)
+ return;
+
+ /* set up the ranges for scanning through the modes */
+ Monitor->nHsync = 1;
+ Monitor->hsync[0].lo = 1024.0;
+ Monitor->hsync[0].hi = 0.0;
+
+ Monitor->nVrefresh = 1;
+ Monitor->vrefresh[0].lo = 1024.0;
+ Monitor->vrefresh[0].hi = 0.0;
+
+ while (Mode) {
+ if (!Mode->HSync)
+ Mode->HSync = ((float) Mode->Clock ) / ((float) Mode->HTotal);
+
+ if (!Mode->VRefresh)
+ Mode->VRefresh = (1000.0 * ((float) Mode->Clock)) /
+ ((float) (Mode->HTotal * Mode->VTotal));
+
+ if (Mode->HSync < Monitor->hsync[0].lo)
+ Monitor->hsync[0].lo = Mode->HSync;
+
+ if (Mode->HSync > Monitor->hsync[0].hi)
+ Monitor->hsync[0].hi = Mode->HSync;
+
+ if (Mode->VRefresh < Monitor->vrefresh[0].lo)
+ Monitor->vrefresh[0].lo = Mode->VRefresh;
+
+ if (Mode->VRefresh > Monitor->vrefresh[0].hi)
+ Monitor->vrefresh[0].hi = Mode->VRefresh;
+
+ Mode = Mode->next;
+ }
+}
+
+ddc_quirk_t
+xf86DDCDetectQuirks(int scrnIndex, xf86MonPtr DDC, Bool verbose)
+{
+ ddc_quirk_t quirks;
+ int i;
+
+ quirks = DDC_QUIRK_NONE;
+ for (i = 0; ddc_quirks[i].detect; i++) {
+ if (ddc_quirks[i].detect (scrnIndex, DDC)) {
+ if (verbose) {
+ xf86DrvMsg (scrnIndex, X_INFO, " EDID quirk: %s\n",
+ ddc_quirks[i].description);
+ }
+ quirks |= ddc_quirks[i].quirk;
+ }
+ }
+
+ return quirks;
+}
+
+void xf86DetTimingApplyQuirks(struct detailed_monitor_section *det_mon,
+ ddc_quirk_t quirks,
+ int hsize, int vsize)
+{
+ if (det_mon->type != DT)
+ return;
+
+ if (quirks & DDC_QUIRK_DETAILED_H_IN_CM)
+ det_mon->section.d_timings.h_size *= 10;
+
+ if (quirks & DDC_QUIRK_DETAILED_V_IN_CM)
+ det_mon->section.d_timings.v_size *= 10;
+
+ if (quirks & DDC_QUIRK_DETAILED_USE_MAXIMUM_SIZE) {
+ det_mon->section.d_timings.h_size = 10 * hsize;
+ det_mon->section.d_timings.v_size = 10 * vsize;
+ }
+}
+
+/**
+ * Applies monitor-specific quirks to the decoded EDID information.
+ *
+ * Note that some quirks applying to the mode list are still implemented in
+ * xf86DDCGetModes.
+ */
+void
+xf86DDCApplyQuirks(int scrnIndex, xf86MonPtr DDC)
+{
+ ddc_quirk_t quirks = xf86DDCDetectQuirks (scrnIndex, DDC, FALSE);
+ int i;
+
+ for (i = 0; i < DET_TIMINGS; i++) {
+ xf86DetTimingApplyQuirks(DDC->det_mon + i, quirks,
+ DDC->features.hsize,
+ DDC->features.vsize);
+ }
+}
+
+/**
+ * Walks the modes list, finding the mode with the largest area which is
+ * closest to the target refresh rate, and marks it as the only preferred mode.
+*/
+static void
+xf86DDCSetPreferredRefresh(int scrnIndex, DisplayModePtr modes,
+ float target_refresh)
+{
+ DisplayModePtr mode, best = modes;
+
+ for (mode = modes; mode; mode = mode->next)
+ {
+ mode->type &= ~M_T_PREFERRED;
+
+ if (mode == best) continue;
+
+ if (mode->HDisplay * mode->VDisplay >
+ best->HDisplay * best->VDisplay)
+ {
+ best = mode;
+ continue;
+ }
+ if (mode->HDisplay * mode->VDisplay ==
+ best->HDisplay * best->VDisplay)
+ {
+ double mode_refresh = xf86ModeVRefresh (mode);
+ double best_refresh = xf86ModeVRefresh (best);
+ double mode_dist = fabs(mode_refresh - target_refresh);
+ double best_dist = fabs(best_refresh - target_refresh);
+
+ if (mode_dist < best_dist)
+ {
+ best = mode;
+ continue;
+ }
+ }
+ }
+ if (best)
+ best->type |= M_T_PREFERRED;
+}
+
+#define CEA_VIDEO_MODES_NUM 64
+static const DisplayModeRec CEAVideoModes[CEA_VIDEO_MODES_NUM] = {
+ { MODEPREFIX, 25175, 640, 656, 752, 800, 0, 480, 490, 492, 525, 0, V_NHSYNC | V_NVSYNC, MODESUFFIX }, /* VIC 1:640x480@60Hz */
+ { MODEPREFIX, 27000, 720, 736, 798, 858, 0, 480, 489, 495, 525, 0, V_NHSYNC | V_NVSYNC, MODESUFFIX }, /* VIC 2:720x480@60Hz */
+ { MODEPREFIX, 27000, 720, 736, 798, 858, 0, 480, 489, 495, 525, 0, V_NHSYNC | V_NVSYNC, MODESUFFIX }, /* VIC 3:720x480@60Hz */
+ { MODEPREFIX, 74250, 1280, 1390, 1430, 1650, 0, 720, 725, 730, 750, 0, V_PHSYNC | V_PVSYNC, MODESUFFIX }, /* VIC 4: 1280x720@60Hz */
+ { MODEPREFIX, 74250, 1920, 2008, 2052, 2200, 0, 1080, 1084, 1094, 1125, 0, V_PHSYNC | V_PVSYNC | V_INTERLACE, MODESUFFIX }, /* VIC 5:1920x1080i@60Hz */
+ { MODEPREFIX, 27000, 1440, 1478, 1602, 1716, 0, 480, 488, 494, 525, 0, V_NHSYNC | V_NVSYNC | V_INTERLACE, MODESUFFIX }, /* VIC 6:1440x480i@60Hz */
+ { MODEPREFIX, 27000, 1440, 1478, 1602, 1716, 0, 480, 488, 494, 525, 0, V_NHSYNC | V_NVSYNC | V_INTERLACE, MODESUFFIX }, /* VIC 7:1440x480i@60Hz */
+ { MODEPREFIX, 27000, 1440, 1478, 1602, 1716, 0, 240, 244, 247, 262, 0, V_NHSYNC | V_NVSYNC, MODESUFFIX }, /* VIC 8:1440x240@60Hz */
+ { MODEPREFIX, 27000, 1440, 1478, 1602, 1716, 0, 240, 244, 247, 262, 0, V_NHSYNC | V_NVSYNC, MODESUFFIX }, /* VIC 9:1440x240@60Hz */
+ { MODEPREFIX, 54000, 2880, 2956, 3204, 3432, 0, 480, 488, 494, 525, 0, V_NHSYNC | V_NVSYNC | V_INTERLACE, MODESUFFIX }, /* VIC 10:2880x480i@60Hz */
+ { MODEPREFIX, 54000, 2880, 2956, 3204, 3432, 0, 480, 488, 494, 525, 0, V_NHSYNC | V_NVSYNC | V_INTERLACE, MODESUFFIX }, /* VIC 11:2880x480i@60Hz */
+ { MODEPREFIX, 54000, 2880, 2956, 3204, 3432, 0, 240, 244, 247, 262, 0, V_NHSYNC | V_NVSYNC, MODESUFFIX }, /* VIC 12:2880x240@60Hz */
+ { MODEPREFIX, 54000, 2880, 2956, 3204, 3432, 0, 240, 244, 247, 262, 0, V_NHSYNC | V_NVSYNC, MODESUFFIX }, /* VIC 13:2880x240@60Hz */
+ { MODEPREFIX, 54000, 1440, 1472, 1596, 1716, 0, 480, 489, 495, 525, 0, V_NHSYNC | V_NVSYNC, MODESUFFIX }, /* VIC 14:1440x480@60Hz */
+ { MODEPREFIX, 54000, 1440, 1472, 1596, 1716, 0, 480, 489, 495, 525, 0, V_NHSYNC | V_NVSYNC, MODESUFFIX }, /* VIC 15:1440x480@60Hz */
+ { MODEPREFIX, 148500, 1920, 2008, 2052, 2200, 0, 1080, 1084, 1089, 1125, 0, V_PHSYNC | V_PVSYNC, MODESUFFIX }, /* VIC 16:1920x1080@60Hz */
+ { MODEPREFIX, 27000, 720, 732, 796, 864, 0, 576, 581, 586, 625, 0, V_NHSYNC | V_NVSYNC, MODESUFFIX }, /* VIC 17:720x576@50Hz */
+ { MODEPREFIX, 27000, 720, 732, 796, 864, 0, 576, 581, 586, 625, 0, V_NHSYNC | V_NVSYNC, MODESUFFIX }, /* VIC 18:720x576@50Hz */
+ { MODEPREFIX, 74250, 1280, 1720, 1760, 1980, 0, 720, 725, 730, 750, 0, V_PHSYNC | V_PVSYNC, MODESUFFIX }, /* VIC 19: 1280x720@50Hz */
+ { MODEPREFIX, 74250, 1920, 2448, 2492, 2640, 0, 1080, 1084, 1094, 1125, 0, V_PHSYNC | V_PVSYNC | V_INTERLACE, MODESUFFIX }, /* VIC 20:1920x1080i@50Hz */
+ { MODEPREFIX, 27000, 1440, 1464, 1590, 1728, 0, 576, 580, 586, 625, 0, V_NHSYNC | V_NVSYNC | V_INTERLACE, MODESUFFIX }, /* VIC 21:1440x576i@50Hz */
+ { MODEPREFIX, 27000, 1440, 1464, 1590, 1728, 0, 576, 580, 586, 625, 0, V_NHSYNC | V_NVSYNC | V_INTERLACE, MODESUFFIX }, /* VIC 22:1440x576i@50Hz */
+ { MODEPREFIX, 27000, 1440, 1464, 1590, 1728, 0, 288, 290, 293, 312, 0, V_NHSYNC | V_NVSYNC, MODESUFFIX }, /* VIC 23:1440x288@50Hz */
+ { MODEPREFIX, 27000, 1440, 1464, 1590, 1728, 0, 288, 290, 293, 312, 0, V_NHSYNC | V_NVSYNC, MODESUFFIX }, /* VIC 24:1440x288@50Hz */
+ { MODEPREFIX, 54000, 2880, 2928, 3180, 3456, 0, 576, 580, 586, 625, 0, V_NHSYNC | V_NVSYNC | V_INTERLACE, MODESUFFIX }, /* VIC 25:2880x576i@50Hz */
+ { MODEPREFIX, 54000, 2880, 2928, 3180, 3456, 0, 576, 580, 586, 625, 0, V_NHSYNC | V_NVSYNC | V_INTERLACE, MODESUFFIX }, /* VIC 26:2880x576i@50Hz */
+ { MODEPREFIX, 54000, 2880, 2928, 3180, 3456, 0, 288, 290, 293, 312, 0, V_NHSYNC | V_NVSYNC, MODESUFFIX }, /* VIC 27:2880x288@50Hz */
+ { MODEPREFIX, 54000, 2880, 2928, 3180, 3456, 0, 288, 290, 293, 312, 0, V_NHSYNC | V_NVSYNC, MODESUFFIX }, /* VIC 28:2880x288@50Hz */
+ { MODEPREFIX, 54000, 1440, 1464, 1592, 1728, 0, 576, 581, 586, 625, 0, V_NHSYNC | V_NVSYNC, MODESUFFIX }, /* VIC 29:1440x576@50Hz */
+ { MODEPREFIX, 54000, 1440, 1464, 1592, 1728, 0, 576, 581, 586, 625, 0, V_NHSYNC | V_NVSYNC, MODESUFFIX }, /* VIC 30:1440x576@50Hz */
+ { MODEPREFIX, 148500, 1920, 2448, 2492, 2640, 0, 1080, 1084, 1089, 1125, 0, V_PHSYNC | V_PVSYNC, MODESUFFIX }, /* VIC 31:1920x1080@50Hz */
+ { MODEPREFIX, 74250, 1920, 2558, 2602, 2750, 0, 1080, 1084, 1089, 1125, 0, V_PHSYNC | V_PVSYNC, MODESUFFIX }, /* VIC 32:1920x1080@24Hz */
+ { MODEPREFIX, 74250, 1920, 2448, 2492, 2640, 0, 1080, 1084, 1089, 1125, 0, V_PHSYNC | V_PVSYNC, MODESUFFIX }, /* VIC 33:1920x1080@25Hz */
+ { MODEPREFIX, 74250, 1920, 2008, 2052, 2200, 0, 1080, 1084, 1089, 1125, 0, V_PHSYNC | V_PVSYNC, MODESUFFIX }, /* VIC 34:1920x1080@30Hz */
+ { MODEPREFIX, 108000, 2880, 2944, 3192, 3432, 0, 480, 489, 495, 525, 0, V_NHSYNC | V_NVSYNC, MODESUFFIX }, /* VIC 35:2880x480@60Hz */
+ { MODEPREFIX, 108000, 2880, 2944, 3192, 3432, 0, 480, 489, 495, 525, 0, V_NHSYNC | V_NVSYNC, MODESUFFIX }, /* VIC 36:2880x480@60Hz */
+ { MODEPREFIX, 108000, 2880, 2928, 3184, 3456, 0, 576, 581, 586, 625, 0, V_NHSYNC | V_NVSYNC, MODESUFFIX }, /* VIC 37:2880x576@50Hz */
+ { MODEPREFIX, 108000, 2880, 2928, 3184, 3456, 0, 576, 581, 586, 625, 0, V_NHSYNC | V_NVSYNC, MODESUFFIX }, /* VIC 38:2880x576@50Hz */
+ { MODEPREFIX, 72000, 1920, 1952, 2120, 2304, 0, 1080, 1126, 1136, 1250, 0, V_PHSYNC | V_NVSYNC | V_INTERLACE, MODESUFFIX }, /* VIC 39:1920x1080i@50Hz */
+ { MODEPREFIX, 148500, 1920, 2448, 2492, 2640, 0, 1080, 1084, 1094, 1125, 0, V_PHSYNC | V_PVSYNC | V_INTERLACE, MODESUFFIX }, /* VIC 40:1920x1080i@100Hz */
+ { MODEPREFIX, 148500, 1280, 1720, 1760, 1980, 0, 720, 725, 730, 750, 0, V_PHSYNC | V_PVSYNC, MODESUFFIX }, /* VIC 41:1280x720@100Hz */
+ { MODEPREFIX, 54000, 720, 732, 796, 864, 0, 576, 581, 586, 625, 0, V_NHSYNC | V_NVSYNC, MODESUFFIX }, /* VIC 42:720x576@100Hz */
+ { MODEPREFIX, 54000, 720, 732, 796, 864, 0, 576, 581, 586, 625, 0, V_NHSYNC | V_NVSYNC, MODESUFFIX }, /* VIC 43:720x576@100Hz */
+ { MODEPREFIX, 54000, 1440, 1464, 1590, 1728, 0, 576, 580, 586, 625, 0, V_NHSYNC | V_NVSYNC, MODESUFFIX }, /* VIC 44:1440x576i@100Hz */
+ { MODEPREFIX, 54000, 1440, 1464, 1590, 1728, 0, 576, 580, 586, 625, 0, V_NHSYNC | V_NVSYNC, MODESUFFIX }, /* VIC 45:1440x576i@100Hz */
+ { MODEPREFIX, 148500, 1920, 2008, 2052, 2200, 0, 1080, 1084, 1094, 1125, 0, V_PHSYNC | V_PVSYNC | V_INTERLACE, MODESUFFIX }, /* VIC 46:1920x1080i@120Hz */
+ { MODEPREFIX, 148500, 1280, 1390, 1430, 1650, 0, 720, 725, 730, 750, 0, V_PHSYNC | V_PVSYNC, MODESUFFIX }, /* VIC 47:1280x720@120Hz */
+ { MODEPREFIX, 54000, 720, 736, 798, 858, 0, 480, 489, 495, 525, 0, V_NHSYNC | V_NVSYNC, MODESUFFIX }, /* VIC 48:720x480@120Hz */
+ { MODEPREFIX, 54000, 720, 736, 798, 858, 0, 480, 489, 495, 525, 0, V_NHSYNC | V_NVSYNC, MODESUFFIX }, /* VIC 49:720x480@120Hz */
+ { MODEPREFIX, 54000, 1440, 1478, 1602, 1716, 0, 480, 488, 494, 525, 0, V_NHSYNC | V_NVSYNC | V_INTERLACE, MODESUFFIX },/* VIC 50:1440x480i@120Hz */
+ { MODEPREFIX, 54000, 1440, 1478, 1602, 1716, 0, 480, 488, 494, 525, 0, V_NHSYNC | V_NVSYNC | V_INTERLACE, MODESUFFIX },/* VIC 51:1440x480i@120Hz */
+ { MODEPREFIX, 108000, 720, 732, 796, 864, 0, 576, 581, 586, 625, 0, V_NHSYNC | V_NVSYNC, MODESUFFIX }, /* VIC 52:720x576@200Hz */
+ { MODEPREFIX, 108000, 720, 732, 796, 864, 0, 576, 581, 586, 625, 0, V_NHSYNC | V_NVSYNC, MODESUFFIX }, /* VIC 53:720x576@200Hz */
+ { MODEPREFIX, 108000, 1440, 1464, 1590, 1728, 0, 576, 580, 586, 625, 0, V_NHSYNC | V_NVSYNC | V_INTERLACE, MODESUFFIX },/* VIC 54:1440x576i@200Hz */
+ { MODEPREFIX, 108000, 1440, 1464, 1590, 1728, 0, 576, 580, 586, 625, 0, V_NHSYNC | V_NVSYNC | V_INTERLACE, MODESUFFIX },/* VIC 55:1440x576i@200Hz */
+ { MODEPREFIX, 108000, 720, 736, 798, 858, 0, 480, 489, 495, 525, 0, V_NHSYNC | V_NVSYNC, MODESUFFIX }, /* VIC 56:720x480@240Hz */
+ { MODEPREFIX, 108000, 720, 736, 798, 858, 0, 480, 489, 495, 525, 0, V_NHSYNC | V_NVSYNC, MODESUFFIX }, /* VIC 57:720x480@240Hz */
+ { MODEPREFIX, 108000, 1440, 1478, 1602, 1716, 0, 480, 488, 494, 525, 0, V_NHSYNC | V_NVSYNC | V_INTERLACE, MODESUFFIX },/* VIC 58:1440x480i@240 */
+ { MODEPREFIX, 108000, 1440, 1478, 1602, 1716, 0, 480, 488, 494, 525, 0, V_NHSYNC | V_NVSYNC | V_INTERLACE, MODESUFFIX },/* VIC 59:1440x480i@240 */
+ { MODEPREFIX, 59400, 1280, 3040, 3080, 3300, 0, 720, 725, 730, 750, 0, V_PHSYNC | V_PVSYNC, MODESUFFIX }, /* VIC 60: 1280x720@24Hz */
+ { MODEPREFIX, 74250, 3700, 3740, 1430, 3960, 0, 720, 725, 730, 750, 0, V_PHSYNC | V_PVSYNC, MODESUFFIX }, /* VIC 61: 1280x720@25Hz */
+ { MODEPREFIX, 74250, 1280, 3040, 3080, 3300, 0, 720, 725, 730, 750, 0, V_PHSYNC | V_PVSYNC, MODESUFFIX }, /* VIC 62: 1280x720@30Hz */
+ { MODEPREFIX, 297000, 1920, 2008, 2052, 2200, 0, 1080, 1084, 1089, 1125, 0, V_PHSYNC | V_PVSYNC, MODESUFFIX }, /* VIC 63: 1920x1080@120Hz */
+ { MODEPREFIX, 297000, 1920, 2448, 2492, 2640, 0, 1080, 1084, 1094, 1125, 0, V_PHSYNC | V_PVSYNC, MODESUFFIX }, /* VIC 64:1920x1080@100Hz */
+};
+
+/* chose mode line by cea short video descriptor*/
+static void handle_cea_svd(struct cea_video_block *video, void *data)
+{
+ DisplayModePtr Mode;
+ DisplayModePtr *Modes = (DisplayModePtr *) data;
+ int vid;
+
+ vid = video ->video_code & 0x7f;
+ if (vid < CEA_VIDEO_MODES_NUM) {
+ Mode = xf86DuplicateMode(CEAVideoModes + vid);
+ *Modes = xf86ModesAdd(*Modes, Mode);
+ }
+}
+
+static DisplayModePtr
+DDCModesFromCEAExtension(int scrnIndex, xf86MonPtr MonPtr)
+{
+ DisplayModePtr Modes = NULL;
+
+ xf86ForEachVideoBlock(MonPtr,
+ handle_cea_svd,
+ &Modes);
+
+ return Modes;
+}
+
+struct det_modes_parameter {
+ xf86MonPtr DDC;
+ ddc_quirk_t quirks;
+ DisplayModePtr Modes;
+ Bool rb;
+ Bool preferred;
+ int timing_level;
+};
+
+static void handle_detailed_modes(struct detailed_monitor_section *det_mon,
+ void *data)
+{
+ DisplayModePtr Mode;
+ struct det_modes_parameter *p = (struct det_modes_parameter *)data;
+
+ xf86DetTimingApplyQuirks(det_mon,p->quirks,
+ p->DDC->features.hsize,
+ p->DDC->features.vsize);
+
+ switch (det_mon->type) {
+ case DT:
+ Mode = DDCModeFromDetailedTiming(p->DDC->scrnIndex,
+ &det_mon->section.d_timings,
+ p->preferred,
+ p->quirks);
+ p->preferred = FALSE;
+ p->Modes = xf86ModesAdd(p->Modes, Mode);
+ break;
+ case DS_STD_TIMINGS:
+ Mode = DDCModesFromStandardTiming(det_mon->section.std_t,
+ p->quirks, p->timing_level,p->rb);
+ p->Modes = xf86ModesAdd(p->Modes, Mode);
+ break;
+ case DS_CVT:
+ Mode = DDCModesFromCVT(p->DDC->scrnIndex, det_mon->section.cvt);
+ p->Modes = xf86ModesAdd(p->Modes, Mode);
+ break;
+ case DS_EST_III:
+ Mode = DDCModesFromEstIII(det_mon->section.est_iii);
+ p->Modes = xf86ModesAdd(p->Modes, Mode);
+ break;
+ default:
+ break;
+ }
+}
+
+DisplayModePtr
+xf86DDCGetModes(int scrnIndex, xf86MonPtr DDC)
+{
+ DisplayModePtr Modes = NULL, Mode;
+ ddc_quirk_t quirks;
+ Bool preferred, rb;
+ int timing_level;
+ struct det_modes_parameter p;
+
+ xf86DrvMsg (scrnIndex, X_INFO, "EDID vendor \"%s\", prod id %d\n",
+ DDC->vendor.name, DDC->vendor.prod_id);
+
+ quirks = xf86DDCDetectQuirks(scrnIndex, DDC, TRUE);
+
+ preferred = PREFERRED_TIMING_MODE(DDC->features.msc);
+ if (DDC->ver.revision >= 4)
+ preferred = TRUE;
+ if (quirks & DDC_QUIRK_FIRST_DETAILED_PREFERRED)
+ preferred = TRUE;
+ if (quirks & (DDC_QUIRK_PREFER_LARGE_60 | DDC_QUIRK_PREFER_LARGE_75))
+ preferred = FALSE;
+
+ rb = xf86MonitorSupportsReducedBlanking(DDC);
+
+ timing_level = MonitorStandardTimingLevel(DDC);
+
+ p.quirks = quirks;
+ p.DDC = DDC;
+ p.Modes = Modes;
+ p.rb = rb;
+ p.preferred = preferred;
+ p.timing_level = timing_level;
+ xf86ForEachDetailedBlock(DDC, handle_detailed_modes, &p);
+ Modes = p.Modes;
+
+ /* Add established timings */
+ Mode = DDCModesFromEstablished(scrnIndex, &DDC->timings1, quirks);
+ Modes = xf86ModesAdd(Modes, Mode);
+
+ /* Add standard timings */
+ Mode = DDCModesFromStandardTiming(DDC->timings2, quirks, timing_level, rb);
+ Modes = xf86ModesAdd(Modes, Mode);
+
+ /* Add cea-extension mode timings */
+ Mode = DDCModesFromCEAExtension(scrnIndex,DDC);
+ Modes = xf86ModesAdd(Modes, Mode);
+
+ if (quirks & DDC_QUIRK_PREFER_LARGE_60)
+ xf86DDCSetPreferredRefresh(scrnIndex, Modes, 60);
+
+ if (quirks & DDC_QUIRK_PREFER_LARGE_75)
+ xf86DDCSetPreferredRefresh(scrnIndex, Modes, 75);
+
+ Modes = xf86PruneDuplicateModes(Modes);
+
+ return Modes;
+}
+
+struct det_mon_parameter {
+ MonPtr Monitor;
+ ddc_quirk_t quirks;
+ Bool have_hsync;
+ Bool have_vrefresh;
+ Bool have_maxpixclock;
+};
+
+static void handle_detailed_monset(struct detailed_monitor_section *det_mon,
+ void *data)
+{
+ int clock;
+ struct det_mon_parameter *p = (struct det_mon_parameter *)data;
+ int scrnIndex = ((xf86MonPtr)(p->Monitor->DDC))->scrnIndex;
+
+ switch (det_mon->type) {
+ case DS_RANGES:
+ if (!p->have_hsync) {
+ if (!p->Monitor->nHsync)
+ xf86DrvMsg(scrnIndex, X_INFO,
+ "Using EDID range info for horizontal sync\n");
+ p->Monitor->hsync[p->Monitor->nHsync].lo =
+ det_mon->section.ranges.min_h;
+ p->Monitor->hsync[p->Monitor->nHsync].hi =
+ det_mon->section.ranges.max_h;
+ p->Monitor->nHsync++;
+ } else {
+ xf86DrvMsg(scrnIndex, X_INFO,
+ "Using hsync ranges from config file\n");
+ }
+
+ if (!p->have_vrefresh) {
+ if (!p->Monitor->nVrefresh)
+ xf86DrvMsg(scrnIndex, X_INFO,
+ "Using EDID range info for vertical refresh\n");
+ p->Monitor->vrefresh[p->Monitor->nVrefresh].lo =
+ det_mon->section.ranges.min_v;
+ p->Monitor->vrefresh[p->Monitor->nVrefresh].hi =
+ det_mon->section.ranges.max_v;
+ p->Monitor->nVrefresh++;
+ } else {
+ xf86DrvMsg(scrnIndex, X_INFO,
+ "Using vrefresh ranges from config file\n");
+ }
+
+ clock = det_mon->section.ranges.max_clock * 1000;
+ if (p->quirks & DDC_QUIRK_DVI_SINGLE_LINK)
+ clock = min(clock, 165000);
+ if (!p->have_maxpixclock && clock > p->Monitor->maxPixClock)
+ p->Monitor->maxPixClock = clock;
+
+ break;
+ default:
+ break;
+ }
+}
+
+/*
+ * Fill out MonPtr with xf86MonPtr information.
+ */
+void
+xf86EdidMonitorSet(int scrnIndex, MonPtr Monitor, xf86MonPtr DDC)
+{
+ DisplayModePtr Modes = NULL, Mode;
+ struct det_mon_parameter p;
+
+ if (!Monitor || !DDC)
+ return;
+
+ Monitor->DDC = DDC;
+
+ if (Monitor->widthmm <= 0 || Monitor->heightmm <= 0) {
+ Monitor->widthmm = 10 * DDC->features.hsize;
+ Monitor->heightmm = 10 * DDC->features.vsize;
+ }
+
+ Monitor->reducedblanking = xf86MonitorSupportsReducedBlanking(DDC);
+
+ Modes = xf86DDCGetModes(scrnIndex, DDC);
+
+ /* Go through the detailed monitor sections */
+ p.Monitor = Monitor;
+ p.quirks = xf86DDCDetectQuirks(scrnIndex, Monitor->DDC, FALSE);
+ p.have_hsync = (Monitor->nHsync != 0);
+ p.have_vrefresh = (Monitor->nVrefresh != 0);
+ p.have_maxpixclock = (Monitor->maxPixClock != 0);
+ xf86ForEachDetailedBlock(DDC, handle_detailed_monset, &p);
+
+ if (Modes) {
+ /* Print Modes */
+ xf86DrvMsg(scrnIndex, X_INFO, "Printing DDC gathered Modelines:\n");
+
+ Mode = Modes;
+ while (Mode) {
+ xf86PrintModeline(scrnIndex, Mode);
+ Mode = Mode->next;
+ }
+
+ /* Do we still need ranges to be filled in? */
+ if (!Monitor->nHsync || !Monitor->nVrefresh)
+ DDCGuessRangesFromModes(scrnIndex, Monitor, Modes);
+
+ /* look for last Mode */
+ Mode = Modes;
+
+ while (Mode->next)
+ Mode = Mode->next;
+
+ /* add to MonPtr */
+ if (Monitor->Modes) {
+ Monitor->Last->next = Modes;
+ Modes->prev = Monitor->Last;
+ Monitor->Last = Mode;
+ } else {
+ Monitor->Modes = Modes;
+ Monitor->Last = Mode;
+ }
+ }
+}
diff --git a/xorg-server/hw/xfree86/os-support/Makefile.am b/xorg-server/hw/xfree86/os-support/Makefile.am
index c0504d5eb..3af4328ff 100644
--- a/xorg-server/hw/xfree86/os-support/Makefile.am
+++ b/xorg-server/hw/xfree86/os-support/Makefile.am
@@ -1,26 +1,26 @@
-SUBDIRS = bus @XORG_OS_SUBDIR@ misc $(DRI_SUBDIRS)
-DIST_SUBDIRS = bsd bus misc linux solaris sco hurd
-
-sdk_HEADERS = xf86_OSproc.h xf86_OSlib.h
-
-EXTRA_DIST = int10Defines.h xf86OSpriv.h
-
-# to get the grouping semantics right, you have to glom these three together
-# as one library, otherwise libtool will actively defeat your attempts to
-# list them multiple times on the link line.
-noinst_LTLIBRARIES = libxorgos.la
-libxorgos_la_SOURCES = xorgos.c
-libxorgos_la_LIBADD = @XORG_OS_SUBDIR@/lib@XORG_OS_SUBDIR@.la \
- bus/libbus.la \
- misc/libmisc.la
-
-AM_CFLAGS = $(DIX_CFLAGS)
-
-xorgos.c:
- touch $@
-
-DISTCLEANFILES = xorgos.c
-
-# FIXME: These don't seem to be used anywhere
-EXTRA_DIST += \
- shared/bios_devmem.c
+SUBDIRS = bus @XORG_OS_SUBDIR@ misc $(DRI_SUBDIRS)
+DIST_SUBDIRS = bsd bus misc linux solaris hurd
+
+sdk_HEADERS = xf86_OSproc.h xf86_OSlib.h
+
+EXTRA_DIST = int10Defines.h xf86OSpriv.h
+
+# to get the grouping semantics right, you have to glom these three together
+# as one library, otherwise libtool will actively defeat your attempts to
+# list them multiple times on the link line.
+noinst_LTLIBRARIES = libxorgos.la
+libxorgos_la_SOURCES = xorgos.c
+libxorgos_la_LIBADD = @XORG_OS_SUBDIR@/lib@XORG_OS_SUBDIR@.la \
+ bus/libbus.la \
+ misc/libmisc.la
+
+AM_CFLAGS = $(DIX_CFLAGS)
+
+xorgos.c:
+ touch $@
+
+DISTCLEANFILES = xorgos.c
+
+# FIXME: These don't seem to be used anywhere
+EXTRA_DIST += \
+ shared/bios_devmem.c
diff --git a/xorg-server/hw/xfree86/os-support/sco/Makefile.am b/xorg-server/hw/xfree86/os-support/sco/Makefile.am
deleted file mode 100644
index b5d40f7a5..000000000
--- a/xorg-server/hw/xfree86/os-support/sco/Makefile.am
+++ /dev/null
@@ -1,5 +0,0 @@
-EXTRA_DIST = \
- VTsw_sco.c \
- sco_init.c \
- sco_iop.c \
- sco_video.c
diff --git a/xorg-server/hw/xfree86/os-support/sco/VTsw_sco.c b/xorg-server/hw/xfree86/os-support/sco/VTsw_sco.c
deleted file mode 100644
index c9ef7d5cd..000000000
--- a/xorg-server/hw/xfree86/os-support/sco/VTsw_sco.c
+++ /dev/null
@@ -1,127 +0,0 @@
-/*
- * Copyright 1993 by David Wexelblat <dwex@goblin.org>
- * Copyright 1993 by David McCullough <davidm@stallion.oz.au>
- *
- * 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"
-
-/* For the event driver prototypes */
-#include <sys/event.h>
-#include <mouse.h>
-
-/*
- * Handle the VT-switching interface for SCO
- */
-
-/*
- * This function is the signal handler for the VT-switching signal. It
- * is only referenced inside the OS-support layer. NOTE: we do NOT need
- * to re-arm the signal here, since we used sigaction() to set the signal
- * disposition in sco_init.c. If we had used signal(), we would need to
- * re-arm the signal here. All we need to do now is record the fact that
- * we got the signal. XFree86 handles the rest.
- */
-void
-xf86VTRequest(int sig)
-{
- xf86Info.vtRequestsPending = TRUE;
- return;
-}
-
-Bool
-xf86VTSwitchPending(void)
-{
- return xf86Info.vtRequestsPending ? TRUE : FALSE;
-}
-
-/*
- * When we switch away, we need to flush and suspend the event driver
- * before the VT_RELDISP. We also need to get the current LED status
- * and preserve it, so that we can restore it when we come back.
- */
-static int sco_ledstatus = -1;
-static unsigned int sco_ledstate = 0;
-
-Bool
-xf86VTSwitchAway(void)
-{
- ev_flush();
- ev_suspend();
-
- sco_ledstatus = ioctl(xf86Info.consoleFd, KDGETLED, &sco_ledstate);
-
- xf86Info.vtRequestsPending = FALSE;
- if (ioctl(xf86Info.consoleFd, VT_RELDISP, VT_TRUE) < 0) {
- return FALSE;
- } else {
- return TRUE;
- }
-}
-
-/*
- * When we come back to the X server, we need to resume the event driver,
- * and we need to restore the LED settings to what they were when we
- * switched away.
- */
-Bool
-xf86VTSwitchTo(void)
-{
- ev_resume();
-
- xf86Info.vtRequestsPending = FALSE;
- if (ioctl(xf86Info.consoleFd, VT_RELDISP, VT_ACKACQ) < 0) {
- return FALSE;
- } else {
- if (sco_ledstatus >= 0) {
- ioctl (xf86Info.consoleFd, KDSETLED, sco_ledstate);
- }
- sco_ledstatus = -1;
-
- /*
- * Convince the console driver this screen is in graphics mode,
- * otherwise it assumes it can do more to the screen than it should.
- */
- if (ioctl(xf86Info.consoleFd, KDSETMODE, KD_GRAPHICS) < 0) {
- ErrorF("Failed to set graphics mode (%s)\n", strerror(errno));
- }
-
- return TRUE;
- }
-}
-
-Bool
-xf86VTActivate(int vtno)
-{
- if (ioctl(xf86Info.consoleFd, VT_ACTIVATE, vtno - 1) < 0) {
- return FALSE;
- }
-
- return TRUE;
-}
diff --git a/xorg-server/hw/xfree86/os-support/sco/sco_init.c b/xorg-server/hw/xfree86/os-support/sco/sco_init.c
deleted file mode 100644
index fd4c898dd..000000000
--- a/xorg-server/hw/xfree86/os-support/sco/sco_init.c
+++ /dev/null
@@ -1,294 +0,0 @@
-/*
- * Copyright 2001-2005 by J. Kean Johnston <jkj@sco.com>
- *
- * 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 J. Kean Johnston not be used in
- * advertising or publicity pertaining to distribution of the software without
- * specific, written prior permission. J. Kean Johnston makes no
- * representations about the suitability of this software for any purpose.
- * It is provided "as is" without express or implied warranty.
- *
- * J. KEAN JOHNSTON DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
- * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
- * EVENT SHALL J. KEAN JOHNSTON 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.
- */
-
-/* Re-written May 2001 to represent the current state of reality */
-
-#ifdef HAVE_XORG_CONFIG_H
-#include <xorg-config.h>
-#endif
-
-#include <X11/X.h>
-#include <X11/Xmd.h>
-
-#include "compiler.h"
-
-#include "xf86.h"
-#include "xf86Priv.h"
-#include "xf86_OSlib.h"
-
-static Bool KeepTty = FALSE;
-static int VTnum = -1;
-static char vtdevice[48];
-static int sco_console_mode = -1;
-
-extern Bool mpxLock;
-
-void
-xf86OpenConsole(void)
-{
- int i, ioctl_ret;
- struct vt_mode VT;
- struct vid_info vidinf;
- struct sigaction sigvtsw;
- char *ttn;
-
- if (serverGeneration == 1) {
- /* check if we're run with euid==0 */
- if (geteuid() != 0) {
- FatalError("xf86OpenConsole: Server must be setuid root\n");
- }
-
- /* If we are run in the background we will get SIGTTOU. Ignore it. */
- OsSignal (SIGTTOU, SIG_IGN);
-
- /*
- * Set up the virtual terminal (multiscreen in SCO parlance).
- * For the actual console itself, screens are numbered from
- * 1 to (usually) 16. However, it is possible to have a nested
- * server, and it is also possible to be on a multi-console
- * system such as MaxSpeed or SunRiver. Therefore, we should
- * not make any assumptions about the TTY name we are on, and
- * instead we rely on ttyname() to give us the real TTY name.
- * Previously, we tried to determine the TTY name manually.
- * This is wrong. The only time we need to futz with the TTY name
- * is if we were given the name of a TTY to run on explicity on
- * the command line.
- */
-
- if (VTnum == -1) {
- /*
- * No device was specified. We need to query the kernel to see which
- * console device we are on (and in fact if we are on a console at all).
- */
- ttn = ttyname (1);
-
- if (ttn == (char *)0) {
- FatalError ("xf86OpenConsole: Could not determine TTY name: %s\n",
- strerror(errno));
- }
- strlcpy (vtdevice, ttn, sizeof(vtdevice));
- } else if (VTnum >= 0) {
- snprintf (vtdevice, sizeof(vtdevice), "/dev/tty%02d", VTnum);
- }
-
- /*
- * Now we can dispose of stdin/stdout
- */
- fclose (stdin);
- fclose (stdout);
-
- if ((xf86Info.consoleFd = open(vtdevice, O_RDWR | O_NDELAY, 0)) < 0) {
- FatalError("xf86OpenConsole: Cannot open %s: %s\n", vtdevice,
- strerror(errno));
- }
-
- /*
- * We make 100% sure we use the correct VT number. This can get ugly
- * where there are multi-consoles in use, so we make sure we query
- * the kernel for the correct VT number. It knows best, we don't.
- */
- vidinf.size = sizeof(vidinf);
- if (ioctl (xf86Info.consoleFd, CONS_GETINFO, &vidinf) < 0) {
- FatalError ("xf86OpenConsole: %s not a console device "
- "or error querying device: %s\n", vtdevice, strerror (errno));
- }
- xf86Info.vtno = vidinf.m_num;
- VTnum = vidinf.m_num + 1; /* 0-based */
-
- ErrorF("(using VT%02d device %s)\n\n", VTnum, vtdevice);
-
- /* We activate the console just in case its not the one we are on */
- if (ioctl(xf86Info.consoleFd, VT_ACTIVATE, xf86Info.vtno) != 0) {
- ErrorF("xf86OpenConsole: VT_ACTIVATE failed (%s)\n", strerror(errno));
- }
-
- /* Disassociate from controling TTY */
- if (!KeepTty) {
- setpgrp();
- }
-
- /*
- * Now we get the current mode that the console device is in. We will
- * use this later when we close the console device to restore it to
- * that same mode.
- */
- if ((sco_console_mode = ioctl(xf86Info.consoleFd, CONS_GET, 0L)) < 0) {
- FatalError("xf86OpenConsole: CONS_GET failed on console (%s)\n",
- strerror(errno));
- }
-
- if (ioctl(xf86Info.consoleFd, VT_GETMODE, &VT) < 0) {
- FatalError("xf86OpenConsole: VT_GETMODE failed (%s)\n", strerror(errno));
- }
-
- sigvtsw.sa_handler = xf86VTRequest;
- sigfillset(&sigvtsw.sa_mask);
- sigvtsw.sa_flags = 0;
-
- /* NOTE: Using sigaction means we dont have to re-arm the signal */
- sigaction(SIGUSR1, &sigvtsw, NULL);
-
- VT.mode = VT_PROCESS;
- VT.relsig = SIGUSR1;
- VT.acqsig = SIGUSR1;
- VT.frsig = SIGINT; /* Not implemented */
- VT.waitv = 0;
-
- /*
- * The SCO X server tries the following call 5 times. Lets do the same
- * thing. It shouldn't really be required but sometimes things take a
- * while to settle down when switching screens. *helpless shrug* I know
- * its sucks but ...
- */
-
- ioctl_ret = 0;
- for (i = 0; i < 5; i++) {
- ioctl_ret = ioctl(xf86Info.consoleFd, VT_SETMODE, &VT);
- if (ioctl_ret >= 0)
- break;
- usleep(999999); /* Dont use nap() - it forces linking with -lx */
- }
-
- if (ioctl_ret < 0) {
- FatalError("xf86OpenConsole: VT_SETMODE failed (%s)\n", strerror(errno));
- }
-
- /*
- * Convince the console driver we are in graphics mode.
- */
- if (ioctl(xf86Info.consoleFd, KDSETMODE, KD_GRAPHICS) < 0) {
- ErrorF("Failed to set graphics mode (%s)\n", strerror(errno));
- }
- } else { /* serverGeneration != 1 */
- if (ioctl(xf86Info.consoleFd, VT_ACTIVATE, xf86Info.vtno) != 0) {
- ErrorF("xf86OpenConsole: VT_ACTIVATE failed (%s)\n", strerror(errno));
- }
- }
-}
-
-/*
- * Restore the console to its previous state. This may cause flicker if
- * the screen was previous in a graphics mode, because we first set it
- * to text mode. This has the advantage of getting the console driver
- * to do a soft reset on the card, which really does help settle the
- * video card down again after coming out of Xfree86.
- */
-void
-xf86CloseConsole(void)
-{
- struct vt_mode VT;
- struct sigaction sigvtsw;
-
- /* Set text mode (possibly briefly) */
- ioctl(xf86Info.consoleFd, KDSETMODE, KD_TEXT0);
-
- /* Restore the original mode */
- if (sco_console_mode != -1) {
- ioctl(xf86Info.consoleFd, MODESWITCH | sco_console_mode, 0L);
- }
-
- ioctl(xf86Info.consoleFd, VT_RELDISP, 1); /* Release the display */
-
- sigvtsw.sa_handler = SIG_DFL;
- sigfillset(&sigvtsw.sa_mask);
- sigvtsw.sa_flags = 0;
-
- sigaction(SIGUSR1, &sigvtsw, NULL);
-
- VT.mode = VT_AUTO;
- VT.waitv = 0;
- VT.relsig = SIGUSR1;
- VT.acqsig = SIGUSR1;
- VT.frsig = SIGINT;
- ioctl(xf86Info.consoleFd, VT_SETMODE, &VT); /* Revert to auto handling */
-
- close(xf86Info.consoleFd); /* We're done with the device */
-}
-
-int
-xf86ProcessArgument(int argc, char *argv[], int i)
-{
- /*
- * Keep server from detaching from controlling tty. This is useful
- * when debugging (so the server can receive keyboard signals).
- */
- if (!strcmp(argv[i], "-keeptty")) {
- KeepTty = TRUE;
- return 1;
- }
-
- /*
- * By default, the X server wants to bind itself to CPU 0. This makes
- * sure that the server has full access to the I/O ports at IOPL 3.
- * Some SMP systems have trouble with I/O on CPU's other than 0. If,
- * however, you have a system that is well behaved, you can specify
- * this argument and let the scheduler decide which CPU the server
- * should run on.
- */
- if (!strcmp(argv[i], "-nompxlock")) {
- mpxLock = FALSE;
- return 1;
- }
-
- /*
- * Specify the VT number to run on (NOT the device).
- */
- if ((argv[i][0] == 'v') && (argv[i][1] == 't')) {
- if (sscanf(argv[i], "vt%2d", &VTnum) == 0) {
- UseMsg();
- VTnum = -1;
- return 0;
- }
- if (VTnum <= 0) {
- UseMsg();
- VTnum = -1;
- return 0;
- }
- return 1;
- }
-
- /*
- * Use a device the user specifies.
- */
- if (!strcmp(argv[i], "-crt")) {
- if (++i > argc) {
- UseMsg();
- VTnum = -1;
- return 0;
- } else {
- VTnum = -2;
- strlcpy (vtdevice, argv[i], sizeof(vtdevice));
- return 2;
- }
- }
- return 0;
-}
-
-void
-xf86UseMsg(void)
-{
- ErrorF("vtXX use the specified VT number\n");
- ErrorF("-crt DEVICE use the specified VT device\n");
- ErrorF("-nompxlock dont bind X server to CPU 0\n");
- ErrorF("-keeptty ");
- ErrorF("don't detach controlling tty (for debugging only)\n");
-}
diff --git a/xorg-server/hw/xfree86/os-support/sco/sco_iop.c b/xorg-server/hw/xfree86/os-support/sco/sco_iop.c
deleted file mode 100644
index 3da4fcf3a..000000000
--- a/xorg-server/hw/xfree86/os-support/sco/sco_iop.c
+++ /dev/null
@@ -1,90 +0,0 @@
-/*
- * Copyright 2001 by J. Kean Johnston <jkj@caldera.com>
- *
- * 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 J. Kean Johnston not be used in
- * advertising or publicity pertaining to distribution of the software without
- * specific, written prior permission. J. Kean Johnston makes no
- * representations about the suitability of this software for any purpose.
- * It is provided "as is" without express or implied warranty.
- *
- * J. KEAN JOHNSTON DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
- * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
- * EVENT SHALL J. KEAN JOHNSTON 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 "compiler.h"
-
-#define _NEED_SYSI86
-#include "xf86.h"
-#include "xf86Priv.h"
-#include "xf86OSpriv.h"
-#include "xf86_OSlib.h"
-
-
-/***************************************************************************/
-/* I/O Permissions section */
-/***************************************************************************/
-
-/*
- * There is a right way and a wrong way of doing this. Unfortunately, we
- * are forced to do it the wrong way. The right way is to be told the range
- * or ranges of I/O ports the driver(s) need access to, in order to use the
- * CONS_IOPERM ioctl() to grant access only to those ports we care about.
- * This way we can guarantee some small level of stability because a driver
- * does not have access to all ports (which would mean it could play with
- * the PIT and thus affect scheduling times, or a whole slew of other
- * nasty things). However, because XFree86 currently only enables or disables
- * ALL port access, we need to run at IOPL 3, which basically means the
- * X Server runs at the same level as the kernel. You can image why this is
- * unsafe. Oh, and this is not a problem unique to OSR5, other OSes are
- * affected by this as well.
- *
- * So, for the time being, we change our IOPL until such time as the XFree86
- * architecture is changed to allow for tighter control of I/O ports. If and
- * when it is, then the CONS_ADDIOP/DELIOP ioctl() should be used to enable
- * or disable access to the desired ports.
- */
-
-extern long sysi86 (int cmd, ...);
-
-static Bool IOEnabled = FALSE;
-
-Bool
-xf86EnableIO(void)
-{
- if (IOEnabled)
- return TRUE;
-
- if (sysi86(SI86V86, V86SC_IOPL, PS_IOPL) < 0) {
- xf86Msg(X_WARNING,"Failed to set IOPL for extended I/O\n");
- return FALSE;
- }
-
- IOEnabled = TRUE;
- return TRUE;
-}
-
-void
-xf86DisableIO(void)
-{
- if (!IOEnabled)
- return;
-
- sysi86(SI86V86, V86SC_IOPL, 0);
- IOEnabled = FALSE;
-}
diff --git a/xorg-server/hw/xfree86/os-support/sco/sco_video.c b/xorg-server/hw/xfree86/os-support/sco/sco_video.c
deleted file mode 100644
index f63b71df8..000000000
--- a/xorg-server/hw/xfree86/os-support/sco/sco_video.c
+++ /dev/null
@@ -1,290 +0,0 @@
-/*
- * Copyright 2001 by J. Kean Johnston <jkj@sco.com>
- *
- * 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 J. Kean Johnston not be used in
- * advertising or publicity pertaining to distribution of the software without
- * specific, written prior permission. J. Kean Johnston makes no
- * representations about the suitability of this software for any purpose.
- * It is provided "as is" without express or implied warranty.
- *
- * J. KEAN JOHNSTON DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
- * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
- * EVENT SHALL J. KEAN JOHNSTON 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.
- */
-
-/* Re-written May 2001 to represent the current state of reality */
-
-/*
- * This file contains the completely re-written SCO OpenServer video
- * routines for XFree86 4.x. Much of this is based on the SCO X server
- * code (which is an X11R5 server) and will probably only work on
- * OpenServer versions 5.0.5, 5.0.6 and later. Please send me (jkj@sco.com)
- * email if you have any questions.
- *
- * Ideally, you should use OSR5.0.6A or later, with the updated console
- * driver for 5.0.6A (its the default driver in 5.0.7 and later).
- * However, if you are running on an older system, this code will detect
- * that and adjust accordingly.
- */
-
-#ifdef HAVE_XORG_CONFIG_H
-#include <xorg-config.h>
-#endif
-
-#include <X11/X.h>
-#include "input.h"
-#include "scrnintstr.h"
-
-#define _NEED_SYSI86
-#include "xf86.h"
-#include "xf86Priv.h"
-#include "xf86OSpriv.h"
-#include "xf86_OSlib.h"
-
-#include <sys/ci/ciioctl.h>
-#define MPXNAME "/dev/atp1"
-#define BASECPU 1
-
-Bool mpxLock = TRUE;
-
-#define USE_VASMETHOD 1
-
-/***************************************************************************/
-/* Video Memory Mapping section */
-/***************************************************************************/
-
-static int sco_mcdone = 0, sco_ismc = 0;
-
-/***************************************************************************/
-/*
- * To map the video memory, we first need to see if we are on a multi-console
- * system. If we are, we need to try to use an existing video class in the
- * kernel. We do this by retrieving the list of currently defined classes
- * (via the new CONS_GETCLASS ioctl()) to see if we have a class that will
- * match the range of memory we desire. If we can't find one, we have an
- * error and we abort.
- *
- * If we are not using a multi-console, we can simply use mmap() to map in
- * the frame buffer, using the classs-access method as a fall-back only if
- * the mmap() fails (it shouldn't). We always set the appropriate pointers
- * in the config structure to point ot the right function to map and unmap
- * the video memory. An alternative to using mmap() is to use the new
- * CONS_ADDVAS call, which will use vasmalloc() and vasbind() in the kernel
- * to map the physical address to a virtual one, which it then returns.
- * I am not 100% sure if this is faster or not, but it may prove easier to
- * debug things. Just to be on the safe side, I have included both methods
- * here, and the mmap() method can be used by setting USE_VASMETHOD to 0
- * above.
- */
-
-#if !defined(CONS_ADDVAS)
-# undef USE_VASMETHOD
-# define USE_VASMETHOD 0
-#endif
-
-static int
-scoIsMultiConsole (void)
-{
- int x;
-
- if (sco_mcdone)
- return sco_ismc;
- x = access ("/usr/lib/vidconf/.multiconsole", F_OK);
- if (x == 0)
- sco_ismc = 1;
- sco_mcdone = 1;
- return sco_ismc;
-}
-
-/*
- * This maps memory using mmap()
- */
-static pointer
-mapVidMemMMAP(int ScreenNum, unsigned long Base, unsigned long Size, int flags)
-{
- int fd;
- unsigned long realBase, alignOff;
- pointer base;
-
- fd = open (DEV_MEM, (flags & VIDMEM_READONLY) ? O_RDONLY : O_RDWR);
- if (fd < 0) {
- FatalError("xf86MapVidMem: failed to open %s (%s)\n", DEV_MEM,
- strerror(errno));
- return 0; /* NOTREACHED */
- }
-
- realBase = Base & ~(getpagesize() - 1);
- alignOff = Base - realBase;
-
- DebugF("base: %lx, realBase: %lx, alignOff: %lx\n", Base,realBase,alignOff);
-
- base = mmap((caddr_t)0, Size + alignOff,
- (flags & VIDMEM_READONLY) ? PROT_READ : (PROT_READ | PROT_WRITE),
- MAP_SHARED, fd, (off_t)realBase);
- close(fd);
- if (base == MAP_FAILED) {
- FatalError("xf86MapVidMem: Could not mmap framebuffer (0x%08x,0x%x) (%s)\n",
- Base, Size, strerror(errno));
- return 0; /* NOTREACHED */
- }
-
- DebugF("base: %lx aligned base: %lx\n",base, base + alignOff);
- return (pointer)((char *)base + alignOff);
-}
-
-#if (USE_VASMETHOD)
-/*
- * This maps memory using the virtual address space (VAS) console calls.
- */
-static pointer
-mapVidMemVAS(int ScreenNum, unsigned long Base, unsigned long Size, int flags)
-{
- struct vidvasmem vas;
- pointer base;
-
- vas.base = (long)Base;
- vas.size = (long)Size;
-
- base = (pointer)ioctl (xf86Info.consoleFd, CONS_ADDVAS, &vas);
- if (base == (pointer)-1) {
- return mapVidMemMMAP(ScreenNum, Base, Size, flags);
- }
- return base;
-}
-#endif /* USE_VASMETHOD */
-
-struct vidclass vidclasslist[] = {
- { "VBE", "", 0xf0000000, 0x2000000, 0 },
- { "P9000", "", 0xc0000000, 0x400000, 0 },
- { "TULIP", "", 0x80000000, 0x400000, 0 },
- { "VIPER", "", 0xa0000000, 0x400000, 0 },
- { "S3T", "", 0xa0000000, 0x200000, 0 },
- { "S3DT", "", 0x4000000, 0x400000, 0 },
- { "MGA", "", 0x2200000, 0x4000, 0 },
- { "CLVGA", "", 0xa0000, 0x20000, 0 },
- { "OLIVE", "", 0xd8000000, 0x400000, 0 },
- { "S3C", "", 0xa0000, 0x10000, 0 },
- { "MGAVLB", "", 0xac000, 0x34000, 0 },
- { "ATI8514", "", 0xFF000, 0x1000, 0 },
- { "GXREGS", "", 0xb0000, 0x10000, 0 },
- { "GX", "", 0xa0000, 0x10000, 0 },
- { "CT64300", "", 0xa0000000, 0x400000, 0 },
- { "SVGA", "", 0xa0000, 0x20000, 0 },
- { "S3V", "", 0xa0000000, 0x400000, 0 },
- { "8514A", "", 0xFF000, 0x1000, 0 },
- { "VGA", "", 0xa0000, 0x10000, 0 },
- { 0 }
-};
-
-static pointer
-mapVidMemVC(int ScreenNum, unsigned long Base, unsigned long Size, int flags)
-{
- struct vidclass *vcp;
- char *class = NULL;
- pointer base;
-
- for (vcp = vidclasslist; vcp->name; vcp++) {
- if ((vcp->base == Base) && (vcp->size == Size)) {
- class = vcp->name;
- break;
- }
- }
-
- if (class == NULL) {
- /*
- * As a fall-back, we will try and use the mmap() approach. This may
- * prove to be the wrong thing to do, but time and testing will tell.
- */
- ErrorF("xf86MapVidMem: No class map defined for (0x%08x,0x%08x)\n", Base, Size);
-#if USE_VASMETHOD
- return mapVidMemVAS(ScreenNum, Base, Size, flags);
-#else /* !USE_VASMETHOD */
- return mapVidMemMMAP(ScreenNum, Base, Size, flags);
-#endif
- }
-
- /*
- * We found a suitable class. Try and use it.
- */
- base = (pointer)ioctl(xf86Info.consoleFd, MAP_CLASS, class);
- if ((int)base == -1) {
- FatalError("xf86MapVidMem: Failed to map video memory class `%s'\n", class);
- return 0; /* NOTREACHED */
- }
-
- return base;
-}
-
-/*
- * Unmapping the video memory is easy. We always call munmap(), as it is
- * safe to do so even if we haven't actually mapped in any pages via mmap().
- * In the case where we used the video class, we don't need to do anything
- * as the kernel will clean up the TSS when we exit, and will undo the
- * vasbind() that was done when the class was originally mapped. If we used
- * vasmap, we simply undo the map. Again, it is benign to call vasunmap
- * even if we got the frame buffer via some other mechanism (like mmap).
- */
-
-static void
-unmapVidMem(int ScreenNum, pointer Base, unsigned long Size)
-{
-#if USE_VASMETHOD
- struct vidvasmem vas;
- int x;
-
- vas.base = (long)Base;
- vas.size = (long)Size;
-
- x = ioctl (xf86Info.consoleFd, CONS_DELVAS, &vas);
- if (x == 0)
- return;
-#endif /* USE_VASMETHOD */
-
- munmap(Base, Size);
-}
-
-/*
- * Set things up to point to our local functions. When the kernel gets
- * MTRR support, we will need to add the required functions for that
- * here too. MTRR support will most likely appear in 5.0.8 or 5.1.0.
- *
- * We also want to lock the X server process to the base CPU in an MPX
- * system, since we will be going to IOPL 3. Most engine drivers can cope
- * with I/O access on any CPU but there are a few (AST Manhattan I believe)
- * that can't, so the server needs to be locked to CPU0.
- */
-void
-xf86OSInitVidMem(VidMemInfoPtr pVidMem)
-{
- int mpx_fd;
-
- if (scoIsMultiConsole ()) {
- pVidMem->mapMem = mapVidMemVC;
- } else {
-#if USE_VASMETHOD
- pVidMem->mapMem = mapVidMemVAS;
-#else
- pVidMem->mapMem = mapVidMemMMAP;
-#endif
- }
-
- pVidMem->unmapMem = unmapVidMem;
- pVidMem->linearSupported = TRUE;
- pVidMem->initialised = TRUE;
-
- if (mpxLock && (mpx_fd = open (MPXNAME, O_RDONLY)) > 0) {
- if (ioctl (mpx_fd, ACPU_XLOCK, BASECPU) < 0)
- ErrorF ("xf86OSInitVidMem: Can not bind to CPU 0 (%s)\n",
- strerror(errno));
- close (mpx_fd);
- }
-}
-
diff --git a/xorg-server/hw/xfree86/os-support/xf86_OSlib.h b/xorg-server/hw/xfree86/os-support/xf86_OSlib.h
index c53fc0dac..3b646da70 100644
--- a/xorg-server/hw/xfree86/os-support/xf86_OSlib.h
+++ b/xorg-server/hw/xfree86/os-support/xf86_OSlib.h
@@ -85,22 +85,11 @@
/**************************************************************************/
#if (defined(SYSV) || defined(SVR4)) && \
(defined(sun) || defined(__i386__))
-# ifdef SCO325
-# ifndef _SVID3
-# define _SVID3
-# endif
-# ifndef _NO_STATIC
-# define _NO_STATIC
-# endif
-# endif
# include <sys/ioctl.h>
# include <signal.h>
# include <termio.h>
# include <sys/stat.h>
# include <sys/types.h>
-# if defined(__SCO__)
-# include <sys/param.h>
-# endif
# include <errno.h>
@@ -140,15 +129,7 @@
# if !defined(sun)
# include <sys/emap.h>
# endif
-# if defined(SCO325)
-# include <sys/vtkd.h>
-# include <sys/console.h>
-# include <sys/scankbd.h>
-# include <sys/vid.h>
-# define LED_CAP CLKED
-# define LED_NUM NLKED
-# define LED_SCR SLKED
-# elif defined(HAS_USL_VTS)
+# if defined(HAS_USL_VTS)
# if !defined(sun)
# include <sys/at_ansi.h>
# endif
@@ -177,20 +158,12 @@
# define VT_ACKACQ 2
# endif /* !VT_ACKACQ */
-# if defined(__SCO__)
-# include <sys/sysmacros.h>
-# define POSIX_TTY
-# endif /* __SCO__ */
-# if defined(SVR4) || defined(SCO325)
+# if defined(SVR4)
# include <sys/mman.h>
# if !(defined(sun) && defined (SVR4))
# define DEV_MEM "/dev/pmem"
# endif
-# ifdef SCO325
-# undef DEV_MEM
-# define DEV_MEM "/dev/mem"
-# endif
# define CLEARDTR_SUPPORT
# define POSIX_TTY
# endif /* SVR4 */
diff --git a/xorg-server/hw/xfree86/parser/Makefile.am b/xorg-server/hw/xfree86/parser/Makefile.am
index 6fe7b87c1..fb5d49e88 100644
--- a/xorg-server/hw/xfree86/parser/Makefile.am
+++ b/xorg-server/hw/xfree86/parser/Makefile.am
@@ -1,51 +1,51 @@
-if INSTALL_LIBXF86CONFIG
-noinst_LTLIBRARIES = libxf86config_internal.la
-lib_LIBRARIES = libxf86config.a
-LIBHEADERS = \
- xf86Optrec.h \
- xf86Parser.h
-else
-noinst_LTLIBRARIES = libxf86config_internal.la
-endif
-
-INTERNAL_SOURCES= \
- Device.c \
- Files.c \
- Flags.c \
- Input.c \
- InputClass.c \
- Layout.c \
- Module.c \
- Video.c \
- Monitor.c \
- Pointer.c \
- Screen.c \
- Vendor.c \
- read.c \
- scan.c \
- write.c \
- DRI.c \
- Extensions.c
-
-libxf86config_internal_la_SOURCES = \
- $(INTERNAL_SOURCES)
-
-libxf86config_a_SOURCES = \
- $(TOP_SRCDIR)/os/xprintf.c \
- $(INTERNAL_SOURCES)
-libxf86config_a_CFLAGS = $(AM_CFLAGS)
-
-AM_CFLAGS = $(DIX_CFLAGS) $(XORG_CFLAGS) \
- -DSYSCONFDIR=\"$(sysconfdir)\" \
- -DDATADIR=\"$(datadir)\"
-
-EXTRA_DIST = \
- Configint.h \
- configProcs.h \
- xf86Optrec.h \
- xf86Parser.h \
- xf86tokens.h
-
-sdk_HEADERS = \
- xf86Parser.h \
- xf86Optrec.h
+if INSTALL_LIBXF86CONFIG
+noinst_LTLIBRARIES = libxf86config_internal.la
+lib_LIBRARIES = libxf86config.a
+LIBHEADERS = \
+ xf86Optrec.h \
+ xf86Parser.h
+else
+noinst_LTLIBRARIES = libxf86config_internal.la
+endif
+
+INTERNAL_SOURCES= \
+ Device.c \
+ Files.c \
+ Flags.c \
+ Input.c \
+ InputClass.c \
+ Layout.c \
+ Module.c \
+ Video.c \
+ Monitor.c \
+ Pointer.c \
+ Screen.c \
+ Vendor.c \
+ read.c \
+ scan.c \
+ write.c \
+ DRI.c \
+ Extensions.c
+
+libxf86config_internal_la_SOURCES = \
+ $(INTERNAL_SOURCES)
+
+libxf86config_a_SOURCES = \
+ $(top_srcdir)/os/xprintf.c \
+ $(INTERNAL_SOURCES)
+libxf86config_a_CFLAGS = $(AM_CFLAGS)
+
+AM_CFLAGS = $(DIX_CFLAGS) $(XORG_CFLAGS) \
+ -DSYSCONFDIR=\"$(sysconfdir)\" \
+ -DDATADIR=\"$(datadir)\"
+
+EXTRA_DIST = \
+ Configint.h \
+ configProcs.h \
+ xf86Optrec.h \
+ xf86Parser.h \
+ xf86tokens.h
+
+sdk_HEADERS = \
+ xf86Parser.h \
+ xf86Optrec.h
diff --git a/xorg-server/os/access.c b/xorg-server/os/access.c
index bb857a0f3..4684b6466 100644
--- a/xorg-server/os/access.c
+++ b/xorg-server/os/access.c
@@ -1,2102 +1,2098 @@
-/***********************************************************
-
-Copyright 1987, 1998 The Open Group
-
-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, and/or sell copies of the Software, and to permit persons
-to whom the Software is furnished to do so, provided that the above
-copyright notice(s) and this permission notice appear in all copies of
-the Software and that both the above copyright notice(s) and this
-permission notice appear in supporting documentation.
-
-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
-OF THIRD PARTY RIGHTS. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
-HOLDERS INCLUDED IN THIS NOTICE BE LIABLE FOR ANY CLAIM, OR 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.
-
-Except as contained in this notice, the name of a copyright holder
-shall not be used in advertising or otherwise to promote the sale, use
-or other dealings in this Software without prior written authorization
-of the copyright holder.
-
-X Window System is a trademark of 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.
-
-******************************************************************/
-
-/*
- * Copyright (c) 2004, 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.
- */
-
-#ifdef HAVE_DIX_CONFIG_H
-#include <dix-config.h>
-#endif
-
-#ifdef WIN32
-#include <X11/Xwinsock.h>
-#endif
-
-#include <stdio.h>
-#include <stdlib.h>
-#define XSERV_t
-#define TRANS_SERVER
-#define TRANS_REOPEN
-#include <X11/Xtrans/Xtrans.h>
-#include <X11/Xauth.h>
-#include <X11/X.h>
-#include <X11/Xproto.h>
-#include "misc.h"
-#include "site.h"
-#include <errno.h>
-#include <sys/types.h>
-#ifndef WIN32
-#include <sys/socket.h>
-#include <sys/ioctl.h>
-#include <ctype.h>
-
-#if defined(TCPCONN) || defined(STREAMSCONN) || defined(__SCO__)
-#include <netinet/in.h>
-#endif /* TCPCONN || STREAMSCONN || __SCO__ */
-
-#ifdef HAS_GETPEERUCRED
-# include <ucred.h>
-# ifdef sun
-# include <zone.h>
-# endif
-#endif
-
-#if defined(SVR4) || (defined(SYSV) && defined(__i386__)) || defined(__GNU__)
-# include <sys/utsname.h>
-#endif
-#if defined(SYSV) && defined(__i386__)
-# include <sys/stream.h>
-#endif
-#ifdef __GNU__
-#undef SIOCGIFCONF
-#include <netdb.h>
-#else /*!__GNU__*/
-# include <net/if.h>
-#endif /*__GNU__ */
-
-#ifdef SVR4
-#include <sys/sockio.h>
-#include <sys/stropts.h>
-#endif
-
-#include <netdb.h>
-
-#ifdef CSRG_BASED
-#include <sys/param.h>
-#if (BSD >= 199103)
-#define VARIABLE_IFREQ
-#endif
-#endif
-
-#ifdef BSD44SOCKETS
-#ifndef VARIABLE_IFREQ
-#define VARIABLE_IFREQ
-#endif
-#endif
-
-#ifdef HAS_GETIFADDRS
-#include <ifaddrs.h>
-#endif
-
-/* Solaris provides an extended interface SIOCGLIFCONF. Other systems
- * may have this as well, but the code has only been tested on Solaris
- * so far, so we only enable it there. Other platforms may be added as
- * needed.
- *
- * Test for Solaris commented out -- TSI @ UQV 2003.06.13
- */
-#ifdef SIOCGLIFCONF
-/* #if defined(sun) */
-#define USE_SIOCGLIFCONF
-/* #endif */
-#endif
-
-#endif /* WIN32 */
-
-#ifndef PATH_MAX
-#include <sys/param.h>
-#ifndef PATH_MAX
-#ifdef MAXPATHLEN
-#define PATH_MAX MAXPATHLEN
-#else
-#define PATH_MAX 1024
-#endif
-#endif
-#endif
-
-#ifdef __SCO__
-/* The system defined value is wrong. MAXPATHLEN is set in sco5.cf. */
-#undef PATH_MAX
-#endif
-
-#define X_INCLUDE_NETDB_H
-#include <X11/Xos_r.h>
-
-#include "dixstruct.h"
-#include "osdep.h"
-
-#include "xace.h"
-
-#ifndef PATH_MAX
-#ifdef MAXPATHLEN
-#define PATH_MAX MAXPATHLEN
-#else
-#define PATH_MAX 1024
-#endif
-#endif
-
-Bool defeatAccessControl = FALSE;
-
-#define acmp(a1, a2, len) memcmp((char *)(a1), (char *)(a2), len)
-#define acopy(a1, a2, len) memmove((char *)(a2), (char *)(a1), len)
-#define addrEqual(fam, address, length, host) \
- ((fam) == (host)->family &&\
- (length) == (host)->len &&\
- !acmp (address, (host)->addr, length))
-
-static int ConvertAddr(struct sockaddr * /*saddr*/,
- int * /*len*/,
- pointer * /*addr*/);
-
-static int CheckAddr(int /*family*/,
- const void * /*pAddr*/,
- unsigned /*length*/);
-
-static Bool NewHost(int /*family*/,
- const void * /*addr*/,
- int /*len*/,
- int /* addingLocalHosts */);
-
-/* XFree86 bug #156: To keep track of which hosts were explicitly requested in
- /etc/X<display>.hosts, we've added a requested field to the HOST struct,
- and a LocalHostRequested variable. These default to FALSE, but are set
- to TRUE in ResetHosts when reading in /etc/X<display>.hosts. They are
- checked in DisableLocalHost(), which is called to disable the default
- local host entries when stronger authentication is turned on. */
-
-typedef struct _host {
- short family;
- short len;
- unsigned char *addr;
- struct _host *next;
- int requested;
-} HOST;
-
-#define MakeHost(h,l) (h)=malloc(sizeof *(h)+(l));\
- if (h) { \
- (h)->addr=(unsigned char *) ((h) + 1);\
- (h)->requested = FALSE; \
- }
-#define FreeHost(h) free(h)
-static HOST *selfhosts = NULL;
-static HOST *validhosts = NULL;
-static int AccessEnabled = DEFAULT_ACCESS_CONTROL;
-static int LocalHostEnabled = FALSE;
-static int LocalHostRequested = FALSE;
-static int UsingXdmcp = FALSE;
-
-/* FamilyServerInterpreted implementation */
-static Bool siAddrMatch(int family, pointer addr, int len, HOST *host,
- ClientPtr client);
-static int siCheckAddr(const char *addrString, int length);
-static void siTypesInitialize(void);
-
-/*
- * called when authorization is not enabled to add the
- * local host to the access list
- */
-
-void
-EnableLocalHost (void)
-{
- if (!UsingXdmcp)
- {
- LocalHostEnabled = TRUE;
- AddLocalHosts ();
- }
-}
-
-/*
- * called when authorization is enabled to keep us secure
- */
-void
-DisableLocalHost (void)
-{
- HOST *self;
-
- if (!LocalHostRequested) /* Fix for XFree86 bug #156 */
- LocalHostEnabled = FALSE;
- for (self = selfhosts; self; self = self->next) {
- if (!self->requested) /* Fix for XFree86 bug #156 */
- (void) RemoveHost ((ClientPtr)NULL, self->family, self->len, (pointer)self->addr);
- }
-}
-
-/*
- * called at init time when XDMCP will be used; xdmcp always
- * adds local hosts manually when needed
- */
-
-void
-AccessUsingXdmcp (void)
-{
- UsingXdmcp = TRUE;
- LocalHostEnabled = FALSE;
-}
-
-
-#if defined(SVR4) && !defined(SCO325) && !defined(sun) && defined(SIOCGIFCONF) && !defined(USE_SIOCGLIFCONF)
-
-/* Deal with different SIOCGIFCONF ioctl semantics on these OSs */
-
-static int
-ifioctl (int fd, int cmd, char *arg)
-{
- struct strioctl ioc;
- int ret;
-
- memset((char *) &ioc, 0, sizeof(ioc));
- ioc.ic_cmd = cmd;
- ioc.ic_timout = 0;
- if (cmd == SIOCGIFCONF)
- {
- ioc.ic_len = ((struct ifconf *) arg)->ifc_len;
- ioc.ic_dp = ((struct ifconf *) arg)->ifc_buf;
- }
- else
- {
- ioc.ic_len = sizeof(struct ifreq);
- ioc.ic_dp = arg;
- }
- ret = ioctl(fd, I_STR, (char *) &ioc);
- if (ret >= 0 && cmd == SIOCGIFCONF)
-#ifdef SVR4
- ((struct ifconf *) arg)->ifc_len = ioc.ic_len;
-#endif
- return ret;
-}
-#else /* Case sun, SCO325 and others */
-#define ifioctl ioctl
-#endif
-
-/*
- * DefineSelf (fd):
- *
- * Define this host for access control. Find all the hosts the OS knows about
- * for this fd and add them to the selfhosts list.
- */
-
-#if !defined(SIOCGIFCONF)
-void
-DefineSelf (int fd)
-{
-#if !defined(TCPCONN) && !defined(STREAMSCONN) && !defined(UNIXCONN)
- return;
-#else
- register int n;
- int len;
- caddr_t addr;
- int family;
- register HOST *host;
-
-#ifndef WIN32
- struct utsname name;
-#else
- struct {
- char nodename[512];
- } name;
-#endif
-
- register struct hostent *hp;
-
- union {
- struct sockaddr sa;
- struct sockaddr_in in;
-#if defined(IPv6) && defined(AF_INET6)
- struct sockaddr_in6 in6;
-#endif
- } saddr;
-
- struct sockaddr_in *inetaddr;
- struct sockaddr_in6 *inet6addr;
- struct sockaddr_in broad_addr;
-#ifdef XTHREADS_NEEDS_BYNAMEPARAMS
- _Xgethostbynameparams hparams;
-#endif
-
- /* Why not use gethostname()? Well, at least on my system, I've had to
- * make an ugly kernel patch to get a name longer than 8 characters, and
- * uname() lets me access to the whole string (it smashes release, you
- * see), whereas gethostname() kindly truncates it for me.
- */
-#ifndef WIN32
- uname(&name);
-#else
- gethostname(name.nodename, sizeof(name.nodename));
-#endif
-
- hp = _XGethostbyname(name.nodename, hparams);
- if (hp != NULL)
- {
- #ifdef h_addr
- #define hp_addr *list
- char **list;
-
- /* iterate over the addresses */
- for (list = hp->h_addr_list; *list; list++)
- #else
- #define hp_addr hp->h_addr
- #endif
- {
- saddr.sa.sa_family = hp->h_addrtype;
- switch (hp->h_addrtype) {
- case AF_INET:
- inetaddr = (struct sockaddr_in *) (&(saddr.sa));
- acopy ( hp_addr, &(inetaddr->sin_addr), hp->h_length);
- len = sizeof(saddr.sa);
- break;
-#if defined(IPv6) && defined(AF_INET6)
- case AF_INET6:
- inet6addr = (struct sockaddr_in6 *) (&(saddr.sa));
- acopy ( hp_addr, &(inet6addr->sin6_addr), hp->h_length);
- len = sizeof(saddr.in6);
- break;
-#endif
- default:
- goto DefineLocalHost;
- }
- family = ConvertAddr ( &(saddr.sa), &len, (pointer *)&addr);
- if ( family != -1 && family != FamilyLocal )
- {
- for (host = selfhosts;
- host && !addrEqual (family, addr, len, host);
- host = host->next) ;
- if (!host)
- {
- /* add this host to the host list. */
- MakeHost(host,len)
- if (host)
- {
- host->family = family;
- host->len = len;
- acopy ( addr, host->addr, len);
- host->next = selfhosts;
- selfhosts = host;
- }
- #ifdef XDMCP
- /*
- * If this is an Internet Address, but not the localhost
- * address (127.0.0.1), nor the bogus address (0.0.0.0),
- * register it.
- */
- if (family == FamilyInternet &&
- !(len == 4 &&
- ((addr[0] == 127) ||
- (addr[0] == 0 && addr[1] == 0 &&
- addr[2] == 0 && addr[3] == 0)))
- )
- {
- XdmcpRegisterConnection (family, (char *)addr, len);
- broad_addr = *inetaddr;
- ((struct sockaddr_in *) &broad_addr)->sin_addr.s_addr =
- htonl (INADDR_BROADCAST);
- XdmcpRegisterBroadcastAddress ((struct sockaddr_in *)
- &broad_addr);
- }
- #if defined(IPv6) && defined(AF_INET6)
- else if (family == FamilyInternet6 &&
- !(IN6_IS_ADDR_LOOPBACK((struct in6_addr *)addr)))
- {
- XdmcpRegisterConnection (family, (char *)addr, len);
- }
- #endif
-
- #endif /* XDMCP */
- }
- }
- }
- }
- /*
- * now add a host of family FamilyLocalHost...
- */
-DefineLocalHost:
- for (host = selfhosts;
- host && !addrEqual(FamilyLocalHost, "", 0, host);
- host = host->next);
- if (!host)
- {
- MakeHost(host, 0);
- if (host)
- {
- host->family = FamilyLocalHost;
- host->len = 0;
- acopy("", host->addr, 0);
- host->next = selfhosts;
- selfhosts = host;
- }
- }
-#endif /* !TCPCONN && !STREAMSCONN && !UNIXCONN */
-}
-
-#else
-
-#ifdef USE_SIOCGLIFCONF
-#define ifr_type struct lifreq
-#else
-#define ifr_type struct ifreq
-#endif
-
-#ifdef VARIABLE_IFREQ
-#define ifr_size(p) (sizeof (struct ifreq) + \
- (p->ifr_addr.sa_len > sizeof (p->ifr_addr) ? \
- p->ifr_addr.sa_len - sizeof (p->ifr_addr) : 0))
-#define ifraddr_size(a) (a.sa_len)
-#else
-#define ifr_size(p) (sizeof (ifr_type))
-#define ifraddr_size(a) (sizeof (a))
-#endif
-
-#if defined(IPv6) && defined(AF_INET6)
-#include <arpa/inet.h>
-#endif
-
-#if defined(IPv6) && defined(AF_INET6)
-static void
-in6_fillscopeid(struct sockaddr_in6 *sin6)
-{
-#if defined(__KAME__)
- if (IN6_IS_ADDR_LINKLOCAL(&sin6->sin6_addr)) {
- sin6->sin6_scope_id =
- ntohs(*(u_int16_t *)&sin6->sin6_addr.s6_addr[2]);
- sin6->sin6_addr.s6_addr[2] = sin6->sin6_addr.s6_addr[3] = 0;
- }
-#endif
-}
-#endif
-
-void
-DefineSelf (int fd)
-{
-#ifndef HAS_GETIFADDRS
- char *cp, *cplim;
-# ifdef USE_SIOCGLIFCONF
- struct sockaddr_storage buf[16];
- struct lifconf ifc;
- register struct lifreq *ifr;
-# ifdef SIOCGLIFNUM
- struct lifnum ifn;
-# endif
-# else /* !USE_SIOCGLIFCONF */
- char buf[2048];
- struct ifconf ifc;
- register struct ifreq *ifr;
-# endif
- void * bufptr = buf;
-#else /* HAS_GETIFADDRS */
- struct ifaddrs * ifap, *ifr;
-#endif
- int len;
- unsigned char * addr;
- int family;
- register HOST *host;
-
-#ifndef HAS_GETIFADDRS
-
- len = sizeof(buf);
-
-#ifdef USE_SIOCGLIFCONF
-
-#ifdef SIOCGLIFNUM
- ifn.lifn_family = AF_UNSPEC;
- ifn.lifn_flags = 0;
- if (ioctl (fd, SIOCGLIFNUM, (char *) &ifn) < 0)
- Error ("Getting interface count");
- if (len < (ifn.lifn_count * sizeof(struct lifreq))) {
- len = ifn.lifn_count * sizeof(struct lifreq);
- bufptr = malloc(len);
- }
-#endif
-
- ifc.lifc_family = AF_UNSPEC;
- ifc.lifc_flags = 0;
- ifc.lifc_len = len;
- ifc.lifc_buf = bufptr;
-
-#define IFC_IOCTL_REQ SIOCGLIFCONF
-#define IFC_IFC_REQ ifc.lifc_req
-#define IFC_IFC_LEN ifc.lifc_len
-#define IFR_IFR_ADDR ifr->lifr_addr
-#define IFR_IFR_NAME ifr->lifr_name
-
-#else /* Use SIOCGIFCONF */
- ifc.ifc_len = len;
- ifc.ifc_buf = bufptr;
-
-#define IFC_IOCTL_REQ SIOCGIFCONF
-#define IFC_IFC_REQ ifc.ifc_req
-#define IFC_IFC_LEN ifc.ifc_len
-#define IFR_IFR_ADDR ifr->ifr_addr
-#define IFR_IFR_NAME ifr->ifr_name
-#endif
-
- if (ifioctl (fd, IFC_IOCTL_REQ, (pointer) &ifc) < 0)
- Error ("Getting interface configuration (4)");
-
- cplim = (char *) IFC_IFC_REQ + IFC_IFC_LEN;
-
- for (cp = (char *) IFC_IFC_REQ; cp < cplim; cp += ifr_size (ifr))
- {
- ifr = (ifr_type *) cp;
- len = ifraddr_size (IFR_IFR_ADDR);
- family = ConvertAddr ((struct sockaddr *) &IFR_IFR_ADDR,
- &len, (pointer *)&addr);
- if (family == -1 || family == FamilyLocal)
- continue;
-#if defined(IPv6) && defined(AF_INET6)
- if (family == FamilyInternet6)
- in6_fillscopeid((struct sockaddr_in6 *)&IFR_IFR_ADDR);
-#endif
- for (host = selfhosts;
- host && !addrEqual (family, addr, len, host);
- host = host->next)
- ;
- if (host)
- continue;
- MakeHost(host,len)
- if (host)
- {
- host->family = family;
- host->len = len;
- acopy(addr, host->addr, len);
- host->next = selfhosts;
- selfhosts = host;
- }
-#ifdef XDMCP
- {
-#ifdef USE_SIOCGLIFCONF
- struct sockaddr_storage broad_addr;
-#else
- struct sockaddr broad_addr;
-#endif
-
- /*
- * If this isn't an Internet Address, don't register it.
- */
- if (family != FamilyInternet
-#if defined(IPv6) && defined(AF_INET6)
- && family != FamilyInternet6
-#endif
- )
- continue;
-
- /*
- * ignore 'localhost' entries as they're not useful
- * on the other end of the wire
- */
- if (family == FamilyInternet &&
- addr[0] == 127 && addr[1] == 0 &&
- addr[2] == 0 && addr[3] == 1)
- continue;
-#if defined(IPv6) && defined(AF_INET6)
- else if (family == FamilyInternet6 &&
- IN6_IS_ADDR_LOOPBACK((struct in6_addr *)addr))
- continue;
-#endif
-
- /*
- * Ignore '0.0.0.0' entries as they are
- * returned by some OSes for unconfigured NICs but they are
- * not useful on the other end of the wire.
- */
- if (len == 4 &&
- addr[0] == 0 && addr[1] == 0 &&
- addr[2] == 0 && addr[3] == 0)
- continue;
-
- XdmcpRegisterConnection (family, (char *)addr, len);
-
-#if defined(IPv6) && defined(AF_INET6)
- /* IPv6 doesn't support broadcasting, so we drop out here */
- if (family == FamilyInternet6)
- continue;
-#endif
-
- broad_addr = IFR_IFR_ADDR;
-
- ((struct sockaddr_in *) &broad_addr)->sin_addr.s_addr =
- htonl (INADDR_BROADCAST);
-#if defined(USE_SIOCGLIFCONF) && defined(SIOCGLIFBRDADDR)
- {
- struct lifreq broad_req;
-
- broad_req = *ifr;
- if (ioctl (fd, SIOCGLIFFLAGS, (char *) &broad_req) != -1 &&
- (broad_req.lifr_flags & IFF_BROADCAST) &&
- (broad_req.lifr_flags & IFF_UP)
- )
- {
- broad_req = *ifr;
- if (ioctl (fd, SIOCGLIFBRDADDR, &broad_req) != -1)
- broad_addr = broad_req.lifr_broadaddr;
- else
- continue;
- }
- else
- continue;
- }
-
-#elif defined(SIOCGIFBRDADDR)
- {
- struct ifreq broad_req;
-
- broad_req = *ifr;
- if (ifioctl (fd, SIOCGIFFLAGS, (pointer) &broad_req) != -1 &&
- (broad_req.ifr_flags & IFF_BROADCAST) &&
- (broad_req.ifr_flags & IFF_UP)
- )
- {
- broad_req = *ifr;
- if (ifioctl (fd, SIOCGIFBRDADDR, (pointer) &broad_req) != -1)
- broad_addr = broad_req.ifr_addr;
- else
- continue;
- }
- else
- continue;
- }
-#endif /* SIOCGIFBRDADDR */
- XdmcpRegisterBroadcastAddress ((struct sockaddr_in *) &broad_addr);
- }
-#endif /* XDMCP */
- }
- if (bufptr != buf)
- free(bufptr);
-#else /* HAS_GETIFADDRS */
- if (getifaddrs(&ifap) < 0) {
- ErrorF("Warning: getifaddrs returns %s\n", strerror(errno));
- return;
- }
- for (ifr = ifap; ifr != NULL; ifr = ifr->ifa_next) {
- if (!ifr->ifa_addr)
- continue;
- len = sizeof(*(ifr->ifa_addr));
- family = ConvertAddr((struct sockaddr *) ifr->ifa_addr, &len,
- (pointer *)&addr);
- if (family == -1 || family == FamilyLocal)
- continue;
-#if defined(IPv6) && defined(AF_INET6)
- if (family == FamilyInternet6)
- in6_fillscopeid((struct sockaddr_in6 *)ifr->ifa_addr);
-#endif
-
- for (host = selfhosts;
- host != NULL && !addrEqual(family, addr, len, host);
- host = host->next)
- ;
- if (host != NULL)
- continue;
- MakeHost(host, len);
- if (host != NULL) {
- host->family = family;
- host->len = len;
- acopy(addr, host->addr, len);
- host->next = selfhosts;
- selfhosts = host;
- }
-#ifdef XDMCP
- {
- /*
- * If this isn't an Internet Address, don't register it.
- */
- if (family != FamilyInternet
-#if defined(IPv6) && defined(AF_INET6)
- && family != FamilyInternet6
-#endif
- )
- continue;
-
- /*
- * ignore 'localhost' entries as they're not useful
- * on the other end of the wire
- */
- if (ifr->ifa_flags & IFF_LOOPBACK)
- continue;
-
- if (family == FamilyInternet &&
- addr[0] == 127 && addr[1] == 0 &&
- addr[2] == 0 && addr[3] == 1)
- continue;
-
- /*
- * Ignore '0.0.0.0' entries as they are
- * returned by some OSes for unconfigured NICs but they are
- * not useful on the other end of the wire.
- */
- if (len == 4 &&
- addr[0] == 0 && addr[1] == 0 &&
- addr[2] == 0 && addr[3] == 0)
- continue;
-#if defined(IPv6) && defined(AF_INET6)
- else if (family == FamilyInternet6 &&
- IN6_IS_ADDR_LOOPBACK((struct in6_addr *)addr))
- continue;
-#endif
- XdmcpRegisterConnection(family, (char *)addr, len);
-#if defined(IPv6) && defined(AF_INET6)
- if (family == FamilyInternet6)
- /* IPv6 doesn't support broadcasting, so we drop out here */
- continue;
-#endif
- if ((ifr->ifa_flags & IFF_BROADCAST) &&
- (ifr->ifa_flags & IFF_UP) &&
- ifr->ifa_broadaddr)
- XdmcpRegisterBroadcastAddress(
- (struct sockaddr_in *) ifr->ifa_broadaddr);
- else
- continue;
- }
-#endif /* XDMCP */
-
- } /* for */
- freeifaddrs(ifap);
-#endif /* HAS_GETIFADDRS */
-
- /*
- * add something of FamilyLocalHost
- */
- for (host = selfhosts;
- host && !addrEqual(FamilyLocalHost, "", 0, host);
- host = host->next);
- if (!host)
- {
- MakeHost(host, 0);
- if (host)
- {
- host->family = FamilyLocalHost;
- host->len = 0;
- acopy("", host->addr, 0);
- host->next = selfhosts;
- selfhosts = host;
- }
- }
-}
-#endif /* hpux && !HAS_IFREQ */
-
-#ifdef XDMCP
-void
-AugmentSelf(pointer from, int len)
-{
- int family;
- pointer addr;
- register HOST *host;
-
- family = ConvertAddr(from, &len, (pointer *)&addr);
- if (family == -1 || family == FamilyLocal)
- return;
- for (host = selfhosts; host; host = host->next)
- {
- if (addrEqual(family, addr, len, host))
- return;
- }
- MakeHost(host,len)
- if (!host)
- return;
- host->family = family;
- host->len = len;
- acopy(addr, host->addr, len);
- host->next = selfhosts;
- selfhosts = host;
-}
-#endif
-
-void
-AddLocalHosts (void)
-{
- HOST *self;
-
- for (self = selfhosts; self; self = self->next)
- /* Fix for XFree86 bug #156: pass addingLocal = TRUE to
- * NewHost to tell that we are adding the default local
- * host entries and not to flag the entries as being
- * explicitely requested */
- (void) NewHost (self->family, self->addr, self->len, TRUE);
-}
-
-/* Reset access control list to initial hosts */
-void
-ResetHosts (char *display)
-{
- register HOST *host;
- char lhostname[120], ohostname[120];
- char *hostname = ohostname;
- char fname[PATH_MAX + 1];
- int fnamelen;
- FILE *fd;
- char *ptr;
- int i, hostlen;
-#if (defined(TCPCONN) || defined(STREAMSCONN) ) && \
- (!defined(IPv6) || !defined(AF_INET6))
- union {
- struct sockaddr sa;
-#if defined(TCPCONN) || defined(STREAMSCONN)
- struct sockaddr_in in;
-#endif /* TCPCONN || STREAMSCONN */
- } saddr;
-#endif
- int family = 0;
- pointer addr;
- int len;
-
- siTypesInitialize();
- AccessEnabled = defeatAccessControl ? FALSE : DEFAULT_ACCESS_CONTROL;
- LocalHostEnabled = FALSE;
- while ((host = validhosts) != 0)
- {
- validhosts = host->next;
- FreeHost (host);
- }
-
-#if defined WIN32 && defined __MINGW32__
-#define ETC_HOST_PREFIX "X"
-#else
-#define ETC_HOST_PREFIX "/etc/X"
-#endif
-#define ETC_HOST_SUFFIX ".hosts"
- fnamelen = strlen(ETC_HOST_PREFIX) + strlen(ETC_HOST_SUFFIX) +
- strlen(display) + 1;
- if (fnamelen > sizeof(fname))
- FatalError("Display name `%s' is too long\n", display);
- snprintf(fname, sizeof(fname), ETC_HOST_PREFIX "%s" ETC_HOST_SUFFIX,
- display);
-
- if ((fd = fopen (fname, "r")) != 0)
- {
- while (fgets (ohostname, sizeof (ohostname), fd))
- {
- family = FamilyWild;
- if (*ohostname == '#')
- continue;
- if ((ptr = strchr(ohostname, '\n')) != 0)
- *ptr = 0;
- hostlen = strlen(ohostname) + 1;
- for (i = 0; i < hostlen; i++)
- lhostname[i] = tolower(ohostname[i]);
- hostname = ohostname;
- if (!strncmp("local:", lhostname, 6))
- {
- family = FamilyLocalHost;
- NewHost(family, "", 0, FALSE);
- LocalHostRequested = TRUE; /* Fix for XFree86 bug #156 */
- }
-#if defined(TCPCONN) || defined(STREAMSCONN)
- else if (!strncmp("inet:", lhostname, 5))
- {
- family = FamilyInternet;
- hostname = ohostname + 5;
- }
-#if defined(IPv6) && defined(AF_INET6)
- else if (!strncmp("inet6:", lhostname, 6))
- {
- family = FamilyInternet6;
- hostname = ohostname + 6;
- }
-#endif
-#endif
-#ifdef SECURE_RPC
- else if (!strncmp("nis:", lhostname, 4))
- {
- family = FamilyNetname;
- hostname = ohostname + 4;
- }
-#endif
- else if (!strncmp("si:", lhostname, 3))
- {
- family = FamilyServerInterpreted;
- hostname = ohostname + 3;
- hostlen -= 3;
- }
-
-
- if (family == FamilyServerInterpreted)
- {
- len = siCheckAddr(hostname, hostlen);
- if (len >= 0) {
- NewHost(family, hostname, len, FALSE);
- }
- }
- else
-#ifdef SECURE_RPC
- if ((family == FamilyNetname) || (strchr(hostname, '@')))
- {
- SecureRPCInit ();
- (void) NewHost (FamilyNetname, hostname, strlen (hostname), FALSE);
- }
- else
-#endif /* SECURE_RPC */
-#if defined(TCPCONN) || defined(STREAMSCONN)
- {
-#if defined(IPv6) && defined(AF_INET6)
- if ( (family == FamilyInternet) || (family == FamilyInternet6) ||
- (family == FamilyWild) )
- {
- struct addrinfo *addresses;
- struct addrinfo *a;
- int f;
-
- if (getaddrinfo(hostname, NULL, NULL, &addresses) == 0) {
- for (a = addresses ; a != NULL ; a = a->ai_next) {
- len = a->ai_addrlen;
- f = ConvertAddr(a->ai_addr,&len,(pointer *)&addr);
- if ( (family == f) ||
- ((family == FamilyWild) && (f != -1)) ) {
- NewHost(f, addr, len, FALSE);
- }
- }
- freeaddrinfo(addresses);
- }
- }
-#else
-#ifdef XTHREADS_NEEDS_BYNAMEPARAMS
- _Xgethostbynameparams hparams;
-#endif
- register struct hostent *hp;
-
- /* host name */
- if ((family == FamilyInternet &&
- ((hp = _XGethostbyname(hostname, hparams)) != 0)) ||
- ((hp = _XGethostbyname(hostname, hparams)) != 0))
- {
- saddr.sa.sa_family = hp->h_addrtype;
- len = sizeof(saddr.sa);
- if ((family = ConvertAddr (&saddr.sa, &len, (pointer *)&addr)) != -1)
- {
-#ifdef h_addr /* new 4.3bsd version of gethostent */
- char **list;
-
- /* iterate over the addresses */
- for (list = hp->h_addr_list; *list; list++)
- (void) NewHost (family, (pointer)*list, len, FALSE);
-#else
- (void) NewHost (family, (pointer)hp->h_addr, len, FALSE);
-#endif
- }
- }
-#endif /* IPv6 */
- }
-#endif /* TCPCONN || STREAMSCONN */
- family = FamilyWild;
- }
- fclose (fd);
- }
-}
-
-/* Is client on the local host */
-Bool LocalClient(ClientPtr client)
-{
- int alen, family, notused;
- Xtransaddr *from = NULL;
- pointer addr;
- register HOST *host;
-
- if (!client->osPrivate)
- return FALSE;
- if (!((OsCommPtr)client->osPrivate)->trans_conn)
- return FALSE;
-
- if (!_XSERVTransGetPeerAddr (((OsCommPtr)client->osPrivate)->trans_conn,
- &notused, &alen, &from))
- {
- family = ConvertAddr ((struct sockaddr *) from,
- &alen, (pointer *)&addr);
- if (family == -1)
- {
- free(from);
- return FALSE;
- }
- if (family == FamilyLocal)
- {
- free(from);
- return TRUE;
- }
- for (host = selfhosts; host; host = host->next)
- {
- if (addrEqual (family, addr, alen, host))
- return TRUE;
- }
- free(from);
- }
- return FALSE;
-}
-
-/*
- * Return the uid and gid of a connected local client
- *
- * Used by XShm to test access rights to shared memory segments
- */
-int
-LocalClientCred(ClientPtr client, int *pUid, int *pGid)
-{
- LocalClientCredRec *lcc;
- int ret = GetLocalClientCreds(client, &lcc);
-
- if (ret == 0) {
-#ifdef HAVE_GETZONEID /* only local if in the same zone */
- if ((lcc->fieldsSet & LCC_ZID_SET) && (lcc->zoneid != getzoneid())) {
- FreeLocalClientCreds(lcc);
- return -1;
- }
-#endif
- if ((lcc->fieldsSet & LCC_UID_SET) && (pUid != NULL))
- *pUid = lcc->euid;
- if ((lcc->fieldsSet & LCC_GID_SET) && (pGid != NULL))
- *pGid = lcc->egid;
- FreeLocalClientCreds(lcc);
- }
- return ret;
-}
-
-/*
- * Return the uid and all gids of a connected local client
- * Allocates a LocalClientCredRec - caller must call FreeLocalClientCreds
- *
- * Used by localuser & localgroup ServerInterpreted access control forms below
- * Used by AuthAudit to log who local connections came from
- */
-int
-GetLocalClientCreds(ClientPtr client, LocalClientCredRec **lccp)
-{
-#if defined(HAS_GETPEEREID) || defined(HAS_GETPEERUCRED) || defined(SO_PEERCRED)
- int fd;
- XtransConnInfo ci;
- LocalClientCredRec *lcc;
-#ifdef HAS_GETPEEREID
- uid_t uid;
- gid_t gid;
-#elif defined(HAS_GETPEERUCRED)
- ucred_t *peercred = NULL;
- const gid_t *gids;
-#elif defined(SO_PEERCRED)
- struct ucred peercred;
- socklen_t so_len = sizeof(peercred);
-#endif
-
- if (client == NULL)
- return -1;
- ci = ((OsCommPtr)client->osPrivate)->trans_conn;
-#if !(defined(sun) && defined(HAS_GETPEERUCRED))
- /* Most implementations can only determine peer credentials for Unix
- * domain sockets - Solaris getpeerucred can work with a bit more, so
- * we just let it tell us if the connection type is supported or not
- */
- if (!_XSERVTransIsLocal(ci)) {
- return -1;
- }
-#endif
-
- *lccp = calloc(1, sizeof(LocalClientCredRec));
- if (*lccp == NULL)
- return -1;
- lcc = *lccp;
-
- fd = _XSERVTransGetConnectionNumber(ci);
-#ifdef HAS_GETPEEREID
- if (getpeereid(fd, &uid, &gid) == -1) {
- FreeLocalClientCreds(lcc);
- return -1;
- }
- lcc->euid = uid;
- lcc->egid = gid;
- lcc->fieldsSet = LCC_UID_SET | LCC_GID_SET;
- return 0;
-#elif defined(HAS_GETPEERUCRED)
- if (getpeerucred(fd, &peercred) < 0) {
- FreeLocalClientCreds(lcc);
- return -1;
- }
- lcc->euid = ucred_geteuid(peercred);
- if (lcc->euid != -1)
- lcc->fieldsSet |= LCC_UID_SET;
- lcc->egid = ucred_getegid(peercred);
- if (lcc->egid != -1)
- lcc->fieldsSet |= LCC_GID_SET;
- lcc->pid = ucred_getpid(peercred);
- if (lcc->pid != -1)
- lcc->fieldsSet |= LCC_PID_SET;
-#ifdef HAVE_GETZONEID
- lcc->zoneid = ucred_getzoneid(peercred);
- if (lcc->zoneid != -1)
- lcc->fieldsSet |= LCC_ZID_SET;
-#endif
- lcc->nSuppGids = ucred_getgroups(peercred, &gids);
- if (lcc->nSuppGids > 0) {
- lcc->pSuppGids = calloc(lcc->nSuppGids, sizeof(int));
- if (lcc->pSuppGids == NULL) {
- lcc->nSuppGids = 0;
- } else {
- int i;
- for (i = 0 ; i < lcc->nSuppGids; i++) {
- (lcc->pSuppGids)[i] = (int) gids[i];
- }
- }
- } else {
- lcc->nSuppGids = 0;
- }
- ucred_free(peercred);
- return 0;
-#elif defined(SO_PEERCRED)
- if (getsockopt(fd, SOL_SOCKET, SO_PEERCRED, &peercred, &so_len) == -1) {
- FreeLocalClientCreds(lcc);
- return -1;
- }
- lcc->euid = peercred.uid;
- lcc->egid = peercred.gid;
- lcc->pid = peercred.pid;
- lcc->fieldsSet = LCC_UID_SET | LCC_GID_SET | LCC_PID_SET;
- return 0;
-#endif
-#else
- /* No system call available to get the credentials of the peer */
-#define NO_LOCAL_CLIENT_CRED
- return -1;
-#endif
-}
-
-void
-FreeLocalClientCreds(LocalClientCredRec *lcc)
-{
- if (lcc != NULL) {
- if (lcc->nSuppGids > 0) {
- free(lcc->pSuppGids);
- }
- free(lcc);
- }
-}
-
-static int
-AuthorizedClient(ClientPtr client)
-{
- int rc;
-
- if (!client || defeatAccessControl)
- return Success;
-
- /* untrusted clients can't change host access */
- rc = XaceHook(XACE_SERVER_ACCESS, client, DixManageAccess);
- if (rc != Success)
- return rc;
-
- return LocalClient(client) ? Success : BadAccess;
-}
-
-/* Add a host to the access control list. This is the external interface
- * called from the dispatcher */
-
-int
-AddHost (ClientPtr client,
- int family,
- unsigned length, /* of bytes in pAddr */
- const void * pAddr)
-{
- int rc, len;
-
- rc = AuthorizedClient(client);
- if (rc != Success)
- return rc;
- switch (family) {
- case FamilyLocalHost:
- len = length;
- LocalHostEnabled = TRUE;
- break;
-#ifdef SECURE_RPC
- case FamilyNetname:
- len = length;
- SecureRPCInit ();
- break;
-#endif
- case FamilyInternet:
-#if defined(IPv6) && defined(AF_INET6)
- case FamilyInternet6:
-#endif
- case FamilyDECnet:
- case FamilyChaos:
- case FamilyServerInterpreted:
- if ((len = CheckAddr (family, pAddr, length)) < 0)
- {
- client->errorValue = length;
- return BadValue;
- }
- break;
- case FamilyLocal:
- default:
- client->errorValue = family;
- return BadValue;
- }
- if (NewHost (family, pAddr, len, FALSE))
- return Success;
- return BadAlloc;
-}
-
-Bool
-ForEachHostInFamily (int family,
- Bool (*func)(
- unsigned char * /* addr */,
- short /* len */,
- pointer /* closure */),
- pointer closure)
-{
- HOST *host;
-
- for (host = validhosts; host; host = host->next)
- if (family == host->family && func (host->addr, host->len, closure))
- return TRUE;
- return FALSE;
-}
-
-/* Add a host to the access control list. This is the internal interface
- * called when starting or resetting the server */
-static Bool
-NewHost (int family,
- const void * addr,
- int len,
- int addingLocalHosts)
-{
- register HOST *host;
-
- for (host = validhosts; host; host = host->next)
- {
- if (addrEqual (family, addr, len, host))
- return TRUE;
- }
- if (!addingLocalHosts) { /* Fix for XFree86 bug #156 */
- for (host = selfhosts; host; host = host->next) {
- if (addrEqual (family, addr, len, host)) {
- host->requested = TRUE;
- break;
- }
- }
- }
- MakeHost(host,len)
- if (!host)
- return FALSE;
- host->family = family;
- host->len = len;
- acopy(addr, host->addr, len);
- host->next = validhosts;
- validhosts = host;
- return TRUE;
-}
-
-/* Remove a host from the access control list */
-
-int
-RemoveHost (
- ClientPtr client,
- int family,
- unsigned length, /* of bytes in pAddr */
- pointer pAddr)
-{
- int rc, len;
- register HOST *host, **prev;
-
- rc = AuthorizedClient(client);
- if (rc != Success)
- return rc;
- switch (family) {
- case FamilyLocalHost:
- len = length;
- LocalHostEnabled = FALSE;
- break;
-#ifdef SECURE_RPC
- case FamilyNetname:
- len = length;
- break;
-#endif
- case FamilyInternet:
-#if defined(IPv6) && defined(AF_INET6)
- case FamilyInternet6:
-#endif
- case FamilyDECnet:
- case FamilyChaos:
- case FamilyServerInterpreted:
- if ((len = CheckAddr (family, pAddr, length)) < 0)
- {
- client->errorValue = length;
- return BadValue;
- }
- break;
- case FamilyLocal:
- default:
- client->errorValue = family;
- return BadValue;
- }
- for (prev = &validhosts;
- (host = *prev) && (!addrEqual (family, pAddr, len, host));
- prev = &host->next)
- ;
- if (host)
- {
- *prev = host->next;
- FreeHost (host);
- }
- return Success;
-}
-
-/* Get all hosts in the access control list */
-int
-GetHosts (
- pointer *data,
- int *pnHosts,
- int *pLen,
- BOOL *pEnabled)
-{
- int len;
- register int n = 0;
- register unsigned char *ptr;
- register HOST *host;
- int nHosts = 0;
-
- *pEnabled = AccessEnabled ? EnableAccess : DisableAccess;
- for (host = validhosts; host; host = host->next)
- {
- nHosts++;
- n += pad_to_int32(host->len) + sizeof(xHostEntry);
- }
- if (n)
- {
- *data = ptr = malloc(n);
- if (!ptr)
- {
- return BadAlloc;
- }
- for (host = validhosts; host; host = host->next)
- {
- len = host->len;
- ((xHostEntry *)ptr)->family = host->family;
- ((xHostEntry *)ptr)->length = len;
- ptr += sizeof(xHostEntry);
- acopy (host->addr, ptr, len);
- ptr += pad_to_int32(len);
- }
- } else {
- *data = NULL;
- }
- *pnHosts = nHosts;
- *pLen = n;
- return Success;
-}
-
-/* Check for valid address family and length, and return address length. */
-
-/*ARGSUSED*/
-static int
-CheckAddr (
- int family,
- const void * pAddr,
- unsigned length)
-{
- int len;
-
- switch (family)
- {
-#if defined(TCPCONN) || defined(STREAMSCONN)
- case FamilyInternet:
- if (length == sizeof (struct in_addr))
- len = length;
- else
- len = -1;
- break;
-#if defined(IPv6) && defined(AF_INET6)
- case FamilyInternet6:
- if (length == sizeof (struct in6_addr))
- len = length;
- else
- len = -1;
- break;
-#endif
-#endif
- case FamilyServerInterpreted:
- len = siCheckAddr(pAddr, length);
- break;
- default:
- len = -1;
- }
- return len;
-}
-
-/* Check if a host is not in the access control list.
- * Returns 1 if host is invalid, 0 if we've found it. */
-
-int
-InvalidHost (
- register struct sockaddr *saddr,
- int len,
- ClientPtr client)
-{
- int family;
- pointer addr;
- register HOST *selfhost, *host;
-
- if (!AccessEnabled) /* just let them in */
- return 0;
- family = ConvertAddr (saddr, &len, (pointer *)&addr);
- if (family == -1)
- return 1;
- if (family == FamilyLocal)
- {
- if (!LocalHostEnabled)
- {
- /*
- * check to see if any local address is enabled. This
- * implicitly enables local connections.
- */
- for (selfhost = selfhosts; selfhost; selfhost=selfhost->next)
- {
- for (host = validhosts; host; host=host->next)
- {
- if (addrEqual (selfhost->family, selfhost->addr,
- selfhost->len, host))
- return 0;
- }
- }
- } else
- return 0;
- }
- for (host = validhosts; host; host = host->next)
- {
- if ((host->family == FamilyServerInterpreted)) {
- if (siAddrMatch (family, addr, len, host, client)) {
- return 0;
- }
- } else {
- if (addrEqual (family, addr, len, host))
- return 0;
- }
-
- }
- return 1;
-}
-
-static int
-ConvertAddr (
- register struct sockaddr *saddr,
- int *len,
- pointer *addr)
-{
- if (*len == 0)
- return FamilyLocal;
- switch (saddr->sa_family)
- {
- case AF_UNSPEC:
-#if defined(UNIXCONN) || defined(LOCALCONN)
- case AF_UNIX:
-#endif
- return FamilyLocal;
-#if defined(TCPCONN) || defined(STREAMSCONN)
- case AF_INET:
-#ifdef WIN32
- if (16777343 == *(long*)&((struct sockaddr_in *) saddr)->sin_addr)
- return FamilyLocal;
-#endif
- *len = sizeof (struct in_addr);
- *addr = (pointer) &(((struct sockaddr_in *) saddr)->sin_addr);
- return FamilyInternet;
-#if defined(IPv6) && defined(AF_INET6)
- case AF_INET6:
- {
- struct sockaddr_in6 *saddr6 = (struct sockaddr_in6 *) saddr;
- if (IN6_IS_ADDR_V4MAPPED(&(saddr6->sin6_addr))) {
- *len = sizeof (struct in_addr);
- *addr = (pointer) &(saddr6->sin6_addr.s6_addr[12]);
- return FamilyInternet;
- } else {
- *len = sizeof (struct in6_addr);
- *addr = (pointer) &(saddr6->sin6_addr);
- return FamilyInternet6;
- }
- }
-#endif
-#endif
- default:
- return -1;
- }
-}
-
-int
-ChangeAccessControl(
- ClientPtr client,
- int fEnabled)
-{
- int rc = AuthorizedClient(client);
- if (rc != Success)
- return rc;
- AccessEnabled = fEnabled;
- return Success;
-}
-
-/* returns FALSE if xhost + in effect, else TRUE */
-int
-GetAccessControl(void)
-{
- return AccessEnabled;
-}
-
-/*****************************************************************************
- * FamilyServerInterpreted host entry implementation
- *
- * Supports an extensible system of host types which the server can interpret
- * See the IPv6 extensions to the X11 protocol spec for the definition.
- *
- * Currently supported schemes:
- *
- * hostname - hostname as defined in IETF RFC 2396
- * ipv6 - IPv6 literal address as defined in IETF RFC's 3513 and <TBD>
- *
- * See xc/doc/specs/SIAddresses for formal definitions of each type.
- */
-
-/* These definitions and the siTypeAdd function could be exported in the
- * future to enable loading additional host types, but that was not done for
- * the initial implementation.
- */
-typedef Bool (*siAddrMatchFunc)(int family, pointer addr, int len,
- const char *siAddr, int siAddrlen, ClientPtr client, void *siTypePriv);
-typedef int (*siCheckAddrFunc)(const char *addrString, int length,
- void *siTypePriv);
-
-struct siType {
- struct siType * next;
- const char * typeName;
- siAddrMatchFunc addrMatch;
- siCheckAddrFunc checkAddr;
- void * typePriv; /* Private data for type routines */
-};
-
-static struct siType *siTypeList;
-
-static int
-siTypeAdd(const char *typeName, siAddrMatchFunc addrMatch,
- siCheckAddrFunc checkAddr, void *typePriv)
-{
- struct siType *s, *p;
-
- if ((typeName == NULL) || (addrMatch == NULL) || (checkAddr == NULL))
- return BadValue;
-
- for (s = siTypeList, p = NULL; s != NULL ; p = s, s = s->next) {
- if (strcmp(typeName, s->typeName) == 0) {
- s->addrMatch = addrMatch;
- s->checkAddr = checkAddr;
- s->typePriv = typePriv;
- return Success;
- }
- }
-
- s = malloc(sizeof(struct siType));
- if (s == NULL)
- return BadAlloc;
-
- if (p == NULL)
- siTypeList = s;
- else
- p->next = s;
-
- s->next = NULL;
- s->typeName = typeName;
- s->addrMatch = addrMatch;
- s->checkAddr = checkAddr;
- s->typePriv = typePriv;
- return Success;
-}
-
-/* Checks to see if a host matches a server-interpreted host entry */
-static Bool
-siAddrMatch(int family, pointer addr, int len, HOST *host, ClientPtr client)
-{
- Bool matches = FALSE;
- struct siType *s;
- const char *valueString;
- int addrlen;
-
- valueString = (const char *) memchr(host->addr, '\0', host->len);
- if (valueString != NULL) {
- for (s = siTypeList; s != NULL ; s = s->next) {
- if (strcmp((char *) host->addr, s->typeName) == 0) {
- addrlen = host->len - (strlen((char *)host->addr) + 1);
- matches = s->addrMatch(family, addr, len,
- valueString + 1, addrlen, client, s->typePriv);
- break;
- }
- }
-#ifdef FAMILY_SI_DEBUG
- ErrorF(
- "Xserver: siAddrMatch(): type = %s, value = %*.*s -- %s\n",
- host->addr, addrlen, addrlen, valueString + 1,
- (matches) ? "accepted" : "rejected");
-#endif
- }
- return matches;
-}
-
-static int
-siCheckAddr(const char *addrString, int length)
-{
- const char *valueString;
- int addrlen, typelen;
- int len = -1;
- struct siType *s;
-
- /* Make sure there is a \0 byte inside the specified length
- to separate the address type from the address value. */
- valueString = (const char *) memchr(addrString, '\0', length);
- if (valueString != NULL) {
- /* Make sure the first string is a recognized address type,
- * and the second string is a valid address of that type.
- */
- typelen = strlen(addrString) + 1;
- addrlen = length - typelen;
-
- for (s = siTypeList; s != NULL ; s = s->next) {
- if (strcmp(addrString, s->typeName) == 0) {
- len = s->checkAddr(valueString + 1, addrlen, s->typePriv);
- if (len >= 0) {
- len += typelen;
- }
- break;
- }
- }
-#ifdef FAMILY_SI_DEBUG
- {
- const char *resultMsg;
-
- if (s == NULL) {
- resultMsg = "type not registered";
- } else {
- if (len == -1)
- resultMsg = "rejected";
- else
- resultMsg = "accepted";
- }
-
- ErrorF("Xserver: siCheckAddr(): type = %s, value = %*.*s, len = %d -- %s\n",
- addrString, addrlen, addrlen, valueString + 1, len, resultMsg);
- }
-#endif
- }
- return len;
-}
-
-
-/***
- * Hostname server-interpreted host type
- *
- * Stored as hostname string, explicitly defined to be resolved ONLY
- * at access check time, to allow for hosts with dynamic addresses
- * but static hostnames, such as found in some DHCP & mobile setups.
- *
- * Hostname must conform to IETF RFC 2396 sec. 3.2.2, which defines it as:
- * hostname = *( domainlabel "." ) toplabel [ "." ]
- * domainlabel = alphanum | alphanum *( alphanum | "-" ) alphanum
- * toplabel = alpha | alpha *( alphanum | "-" ) alphanum
- */
-
-#ifdef NI_MAXHOST
-# define SI_HOSTNAME_MAXLEN NI_MAXHOST
-#else
-# ifdef MAXHOSTNAMELEN
-# define SI_HOSTNAME_MAXLEN MAXHOSTNAMELEN
-# else
-# define SI_HOSTNAME_MAXLEN 256
-# endif
-#endif
-
-static Bool
-siHostnameAddrMatch(int family, pointer addr, int len,
- const char *siAddr, int siAddrLen, ClientPtr client, void *typePriv)
-{
- Bool res = FALSE;
-
-/* Currently only supports checking against IPv4 & IPv6 connections, but
- * support for other address families, such as DECnet, could be added if
- * desired.
- */
-#if defined(IPv6) && defined(AF_INET6)
- if ((family == FamilyInternet) || (family == FamilyInternet6)) {
- char hostname[SI_HOSTNAME_MAXLEN];
- struct addrinfo *addresses;
- struct addrinfo *a;
- int f, hostaddrlen;
- pointer hostaddr;
-
- if (siAddrLen >= sizeof(hostname))
- return FALSE;
-
- strncpy(hostname, siAddr, siAddrLen);
- hostname[siAddrLen] = '\0';
-
- if (getaddrinfo(hostname, NULL, NULL, &addresses) == 0) {
- for (a = addresses ; a != NULL ; a = a->ai_next) {
- hostaddrlen = a->ai_addrlen;
- f = ConvertAddr(a->ai_addr,&hostaddrlen,&hostaddr);
- if ((f == family) && (len == hostaddrlen) &&
- (acmp (addr, hostaddr, len) == 0) ) {
- res = TRUE;
- break;
- }
- }
- freeaddrinfo(addresses);
- }
- }
-#else /* IPv6 not supported, use gethostbyname instead for IPv4 */
- if (family == FamilyInternet) {
- register struct hostent *hp;
-#ifdef XTHREADS_NEEDS_BYNAMEPARAMS
- _Xgethostbynameparams hparams;
-#endif
- char hostname[SI_HOSTNAME_MAXLEN];
- int f, hostaddrlen;
- pointer hostaddr;
- const char **addrlist;
-
- if (siAddrLen >= sizeof(hostname))
- return FALSE;
-
- strncpy(hostname, siAddr, siAddrLen);
- hostname[siAddrLen] = '\0';
-
- if ((hp = _XGethostbyname(hostname, hparams)) != NULL) {
-#ifdef h_addr /* new 4.3bsd version of gethostent */
- /* iterate over the addresses */
- for (addrlist = hp->h_addr_list; *addrlist; addrlist++)
-#else
- addrlist = &hp->h_addr;
-#endif
- {
- struct sockaddr_in sin;
-
- sin.sin_family = hp->h_addrtype;
- acopy ( *addrlist, &(sin.sin_addr), hp->h_length);
- hostaddrlen = sizeof(sin);
- f = ConvertAddr ((struct sockaddr *)&sin,
- &hostaddrlen, &hostaddr);
- if ((f == family) && (len == hostaddrlen) &&
- (acmp (addr, hostaddr, len) == 0) ) {
- res = TRUE;
- break;
- }
- }
- }
- }
-#endif
- return res;
-}
-
-
-static int
-siHostnameCheckAddr(const char *valueString, int length, void *typePriv)
-{
- /* Check conformance of hostname to RFC 2396 sec. 3.2.2 definition.
- * We do not use ctype functions here to avoid locale-specific
- * character sets. Hostnames must be pure ASCII.
- */
- int len = length;
- int i;
- Bool dotAllowed = FALSE;
- Bool dashAllowed = FALSE;
-
- if ((length <= 0) || (length >= SI_HOSTNAME_MAXLEN)) {
- len = -1;
- } else {
- for (i = 0; i < length; i++) {
- char c = valueString[i];
-
- if (c == 0x2E) { /* '.' */
- if (dotAllowed == FALSE) {
- len = -1;
- break;
- } else {
- dotAllowed = FALSE;
- dashAllowed = FALSE;
- }
- } else if (c == 0x2D) { /* '-' */
- if (dashAllowed == FALSE) {
- len = -1;
- break;
- } else {
- dotAllowed = FALSE;
- }
- } else if (((c >= 0x30) && (c <= 0x3A)) /* 0-9 */ ||
- ((c >= 0x61) && (c <= 0x7A)) /* a-z */ ||
- ((c >= 0x41) && (c <= 0x5A)) /* A-Z */) {
- dotAllowed = TRUE;
- dashAllowed = TRUE;
- } else { /* Invalid character */
- len = -1;
- break;
- }
- }
- }
- return len;
-}
-
-#if defined(IPv6) && defined(AF_INET6)
-/***
- * "ipv6" server interpreted type
- *
- * Currently supports only IPv6 literal address as specified in IETF RFC 3513
- *
- * Once draft-ietf-ipv6-scoping-arch-00.txt becomes an RFC, support will be
- * added for the scoped address format it specifies.
- */
-
-/* Maximum length of an IPv6 address string - increase when adding support
- * for scoped address qualifiers. Includes room for trailing NUL byte.
- */
-#define SI_IPv6_MAXLEN INET6_ADDRSTRLEN
-
-static Bool
-siIPv6AddrMatch(int family, pointer addr, int len,
- const char *siAddr, int siAddrlen, ClientPtr client, void *typePriv)
-{
- struct in6_addr addr6;
- char addrbuf[SI_IPv6_MAXLEN];
-
- if ((family != FamilyInternet6) || (len != sizeof(addr6)))
- return FALSE;
-
- memcpy(addrbuf, siAddr, siAddrlen);
- addrbuf[siAddrlen] = '\0';
-
- if (inet_pton(AF_INET6, addrbuf, &addr6) != 1) {
- perror("inet_pton");
- return FALSE;
- }
-
- if (memcmp(addr, &addr6, len) == 0) {
- return TRUE;
- } else {
- return FALSE;
- }
-}
-
-static int
-siIPv6CheckAddr(const char *addrString, int length, void *typePriv)
-{
- int len;
-
- /* Minimum length is 3 (smallest legal address is "::1") */
- if (length < 3) {
- /* Address is too short! */
- len = -1;
- } else if (length >= SI_IPv6_MAXLEN) {
- /* Address is too long! */
- len = -1;
- } else {
- /* Assume inet_pton is sufficient validation */
- struct in6_addr addr6;
- char addrbuf[SI_IPv6_MAXLEN];
-
- memcpy(addrbuf, addrString, length);
- addrbuf[length] = '\0';
-
- if (inet_pton(AF_INET6, addrbuf, &addr6) != 1) {
- perror("inet_pton");
- len = -1;
- } else {
- len = length;
- }
- }
- return len;
-}
-#endif /* IPv6 */
-
-#if !defined(NO_LOCAL_CLIENT_CRED)
-/***
- * "localuser" & "localgroup" server interpreted types
- *
- * Allows local connections from a given local user or group
- */
-
-#include <pwd.h>
-#include <grp.h>
-
-#define LOCAL_USER 1
-#define LOCAL_GROUP 2
-
-typedef struct {
- int credType;
-} siLocalCredPrivRec, *siLocalCredPrivPtr;
-
-static siLocalCredPrivRec siLocalUserPriv = { LOCAL_USER };
-static siLocalCredPrivRec siLocalGroupPriv = { LOCAL_GROUP };
-
-static Bool
-siLocalCredGetId(const char *addr, int len, siLocalCredPrivPtr lcPriv, int *id)
-{
- Bool parsedOK = FALSE;
- char *addrbuf = malloc(len + 1);
-
- if (addrbuf == NULL) {
- return FALSE;
- }
-
- memcpy(addrbuf, addr, len);
- addrbuf[len] = '\0';
-
- if (addr[0] == '#') { /* numeric id */
- char *cp;
- errno = 0;
- *id = strtol(addrbuf + 1, &cp, 0);
- if ((errno == 0) && (cp != (addrbuf+1))) {
- parsedOK = TRUE;
- }
- } else { /* non-numeric name */
- if (lcPriv->credType == LOCAL_USER) {
- struct passwd *pw = getpwnam(addrbuf);
-
- if (pw != NULL) {
- *id = (int) pw->pw_uid;
- parsedOK = TRUE;
- }
- } else { /* group */
- struct group *gr = getgrnam(addrbuf);
-
- if (gr != NULL) {
- *id = (int) gr->gr_gid;
- parsedOK = TRUE;
- }
- }
- }
-
- free(addrbuf);
- return parsedOK;
-}
-
-static Bool
-siLocalCredAddrMatch(int family, pointer addr, int len,
- const char *siAddr, int siAddrlen, ClientPtr client, void *typePriv)
-{
- int siAddrId;
- LocalClientCredRec *lcc;
- siLocalCredPrivPtr lcPriv = (siLocalCredPrivPtr) typePriv;
-
- if (GetLocalClientCreds(client, &lcc) == -1) {
- return FALSE;
- }
-
-#ifdef HAVE_GETZONEID /* Ensure process is in the same zone */
- if ((lcc->fieldsSet & LCC_ZID_SET) && (lcc->zoneid != getzoneid())) {
- FreeLocalClientCreds(lcc);
- return FALSE;
- }
-#endif
-
- if (siLocalCredGetId(siAddr, siAddrlen, lcPriv, &siAddrId) == FALSE) {
- FreeLocalClientCreds(lcc);
- return FALSE;
- }
-
- if (lcPriv->credType == LOCAL_USER) {
- if ((lcc->fieldsSet & LCC_UID_SET) && (lcc->euid == siAddrId)) {
- FreeLocalClientCreds(lcc);
- return TRUE;
- }
- } else {
- if ((lcc->fieldsSet & LCC_GID_SET) && (lcc->egid == siAddrId)) {
- FreeLocalClientCreds(lcc);
- return TRUE;
- }
- if (lcc->pSuppGids != NULL) {
- int i;
-
- for (i = 0 ; i < lcc->nSuppGids; i++) {
- if (lcc->pSuppGids[i] == siAddrId) {
- FreeLocalClientCreds(lcc);
- return TRUE;
- }
- }
- }
- }
- FreeLocalClientCreds(lcc);
- return FALSE;
-}
-
-static int
-siLocalCredCheckAddr(const char *addrString, int length, void *typePriv)
-{
- int len = length;
- int id;
-
- if (siLocalCredGetId(addrString, length,
- (siLocalCredPrivPtr)typePriv, &id) == FALSE) {
- len = -1;
- }
- return len;
-}
-#endif /* localuser */
-
-static void
-siTypesInitialize(void)
-{
- siTypeAdd("hostname", siHostnameAddrMatch, siHostnameCheckAddr, NULL);
-#if defined(IPv6) && defined(AF_INET6)
- siTypeAdd("ipv6", siIPv6AddrMatch, siIPv6CheckAddr, NULL);
-#endif
-#if !defined(NO_LOCAL_CLIENT_CRED)
- siTypeAdd("localuser", siLocalCredAddrMatch, siLocalCredCheckAddr,
- &siLocalUserPriv);
- siTypeAdd("localgroup", siLocalCredAddrMatch, siLocalCredCheckAddr,
- &siLocalGroupPriv);
-#endif
-}
+/***********************************************************
+
+Copyright 1987, 1998 The Open Group
+
+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, and/or sell copies of the Software, and to permit persons
+to whom the Software is furnished to do so, provided that the above
+copyright notice(s) and this permission notice appear in all copies of
+the Software and that both the above copyright notice(s) and this
+permission notice appear in supporting documentation.
+
+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
+OF THIRD PARTY RIGHTS. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+HOLDERS INCLUDED IN THIS NOTICE BE LIABLE FOR ANY CLAIM, OR 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.
+
+Except as contained in this notice, the name of a copyright holder
+shall not be used in advertising or otherwise to promote the sale, use
+or other dealings in this Software without prior written authorization
+of the copyright holder.
+
+X Window System is a trademark of 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.
+
+******************************************************************/
+
+/*
+ * Copyright (c) 2004, 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.
+ */
+
+#ifdef HAVE_DIX_CONFIG_H
+#include <dix-config.h>
+#endif
+
+#ifdef WIN32
+#include <X11/Xwinsock.h>
+#endif
+
+#include <stdio.h>
+#include <stdlib.h>
+#define XSERV_t
+#define TRANS_SERVER
+#define TRANS_REOPEN
+#include <X11/Xtrans/Xtrans.h>
+#include <X11/Xauth.h>
+#include <X11/X.h>
+#include <X11/Xproto.h>
+#include "misc.h"
+#include "site.h"
+#include <errno.h>
+#include <sys/types.h>
+#ifndef WIN32
+#include <sys/socket.h>
+#include <sys/ioctl.h>
+#include <ctype.h>
+
+#if defined(TCPCONN) || defined(STREAMSCONN)
+#include <netinet/in.h>
+#endif /* TCPCONN || STREAMSCONN */
+
+#ifdef HAS_GETPEERUCRED
+# include <ucred.h>
+# ifdef sun
+# include <zone.h>
+# endif
+#endif
+
+#if defined(SVR4) || (defined(SYSV) && defined(__i386__)) || defined(__GNU__)
+# include <sys/utsname.h>
+#endif
+#if defined(SYSV) && defined(__i386__)
+# include <sys/stream.h>
+#endif
+#ifdef __GNU__
+#undef SIOCGIFCONF
+#include <netdb.h>
+#else /*!__GNU__*/
+# include <net/if.h>
+#endif /*__GNU__ */
+
+#ifdef SVR4
+#include <sys/sockio.h>
+#include <sys/stropts.h>
+#endif
+
+#include <netdb.h>
+
+#ifdef CSRG_BASED
+#include <sys/param.h>
+#if (BSD >= 199103)
+#define VARIABLE_IFREQ
+#endif
+#endif
+
+#ifdef BSD44SOCKETS
+#ifndef VARIABLE_IFREQ
+#define VARIABLE_IFREQ
+#endif
+#endif
+
+#ifdef HAS_GETIFADDRS
+#include <ifaddrs.h>
+#endif
+
+/* Solaris provides an extended interface SIOCGLIFCONF. Other systems
+ * may have this as well, but the code has only been tested on Solaris
+ * so far, so we only enable it there. Other platforms may be added as
+ * needed.
+ *
+ * Test for Solaris commented out -- TSI @ UQV 2003.06.13
+ */
+#ifdef SIOCGLIFCONF
+/* #if defined(sun) */
+#define USE_SIOCGLIFCONF
+/* #endif */
+#endif
+
+#endif /* WIN32 */
+
+#ifndef PATH_MAX
+#include <sys/param.h>
+#ifndef PATH_MAX
+#ifdef MAXPATHLEN
+#define PATH_MAX MAXPATHLEN
+#else
+#define PATH_MAX 1024
+#endif
+#endif
+#endif
+
+
+#define X_INCLUDE_NETDB_H
+#include <X11/Xos_r.h>
+
+#include "dixstruct.h"
+#include "osdep.h"
+
+#include "xace.h"
+
+#ifndef PATH_MAX
+#ifdef MAXPATHLEN
+#define PATH_MAX MAXPATHLEN
+#else
+#define PATH_MAX 1024
+#endif
+#endif
+
+Bool defeatAccessControl = FALSE;
+
+#define acmp(a1, a2, len) memcmp((char *)(a1), (char *)(a2), len)
+#define acopy(a1, a2, len) memmove((char *)(a2), (char *)(a1), len)
+#define addrEqual(fam, address, length, host) \
+ ((fam) == (host)->family &&\
+ (length) == (host)->len &&\
+ !acmp (address, (host)->addr, length))
+
+static int ConvertAddr(struct sockaddr * /*saddr*/,
+ int * /*len*/,
+ pointer * /*addr*/);
+
+static int CheckAddr(int /*family*/,
+ const void * /*pAddr*/,
+ unsigned /*length*/);
+
+static Bool NewHost(int /*family*/,
+ const void * /*addr*/,
+ int /*len*/,
+ int /* addingLocalHosts */);
+
+/* XFree86 bug #156: To keep track of which hosts were explicitly requested in
+ /etc/X<display>.hosts, we've added a requested field to the HOST struct,
+ and a LocalHostRequested variable. These default to FALSE, but are set
+ to TRUE in ResetHosts when reading in /etc/X<display>.hosts. They are
+ checked in DisableLocalHost(), which is called to disable the default
+ local host entries when stronger authentication is turned on. */
+
+typedef struct _host {
+ short family;
+ short len;
+ unsigned char *addr;
+ struct _host *next;
+ int requested;
+} HOST;
+
+#define MakeHost(h,l) (h)=malloc(sizeof *(h)+(l));\
+ if (h) { \
+ (h)->addr=(unsigned char *) ((h) + 1);\
+ (h)->requested = FALSE; \
+ }
+#define FreeHost(h) free(h)
+static HOST *selfhosts = NULL;
+static HOST *validhosts = NULL;
+static int AccessEnabled = DEFAULT_ACCESS_CONTROL;
+static int LocalHostEnabled = FALSE;
+static int LocalHostRequested = FALSE;
+static int UsingXdmcp = FALSE;
+
+/* FamilyServerInterpreted implementation */
+static Bool siAddrMatch(int family, pointer addr, int len, HOST *host,
+ ClientPtr client);
+static int siCheckAddr(const char *addrString, int length);
+static void siTypesInitialize(void);
+
+/*
+ * called when authorization is not enabled to add the
+ * local host to the access list
+ */
+
+void
+EnableLocalHost (void)
+{
+ if (!UsingXdmcp)
+ {
+ LocalHostEnabled = TRUE;
+ AddLocalHosts ();
+ }
+}
+
+/*
+ * called when authorization is enabled to keep us secure
+ */
+void
+DisableLocalHost (void)
+{
+ HOST *self;
+
+ if (!LocalHostRequested) /* Fix for XFree86 bug #156 */
+ LocalHostEnabled = FALSE;
+ for (self = selfhosts; self; self = self->next) {
+ if (!self->requested) /* Fix for XFree86 bug #156 */
+ (void) RemoveHost ((ClientPtr)NULL, self->family, self->len, (pointer)self->addr);
+ }
+}
+
+/*
+ * called at init time when XDMCP will be used; xdmcp always
+ * adds local hosts manually when needed
+ */
+
+void
+AccessUsingXdmcp (void)
+{
+ UsingXdmcp = TRUE;
+ LocalHostEnabled = FALSE;
+}
+
+
+#if defined(SVR4) && !defined(sun) && defined(SIOCGIFCONF) && !defined(USE_SIOCGLIFCONF)
+
+/* Deal with different SIOCGIFCONF ioctl semantics on these OSs */
+
+static int
+ifioctl (int fd, int cmd, char *arg)
+{
+ struct strioctl ioc;
+ int ret;
+
+ memset((char *) &ioc, 0, sizeof(ioc));
+ ioc.ic_cmd = cmd;
+ ioc.ic_timout = 0;
+ if (cmd == SIOCGIFCONF)
+ {
+ ioc.ic_len = ((struct ifconf *) arg)->ifc_len;
+ ioc.ic_dp = ((struct ifconf *) arg)->ifc_buf;
+ }
+ else
+ {
+ ioc.ic_len = sizeof(struct ifreq);
+ ioc.ic_dp = arg;
+ }
+ ret = ioctl(fd, I_STR, (char *) &ioc);
+ if (ret >= 0 && cmd == SIOCGIFCONF)
+#ifdef SVR4
+ ((struct ifconf *) arg)->ifc_len = ioc.ic_len;
+#endif
+ return ret;
+}
+#else
+#define ifioctl ioctl
+#endif
+
+/*
+ * DefineSelf (fd):
+ *
+ * Define this host for access control. Find all the hosts the OS knows about
+ * for this fd and add them to the selfhosts list.
+ */
+
+#if !defined(SIOCGIFCONF)
+void
+DefineSelf (int fd)
+{
+#if !defined(TCPCONN) && !defined(STREAMSCONN) && !defined(UNIXCONN)
+ return;
+#else
+ register int n;
+ int len;
+ caddr_t addr;
+ int family;
+ register HOST *host;
+
+#ifndef WIN32
+ struct utsname name;
+#else
+ struct {
+ char nodename[512];
+ } name;
+#endif
+
+ register struct hostent *hp;
+
+ union {
+ struct sockaddr sa;
+ struct sockaddr_in in;
+#if defined(IPv6) && defined(AF_INET6)
+ struct sockaddr_in6 in6;
+#endif
+ } saddr;
+
+ struct sockaddr_in *inetaddr;
+ struct sockaddr_in6 *inet6addr;
+ struct sockaddr_in broad_addr;
+#ifdef XTHREADS_NEEDS_BYNAMEPARAMS
+ _Xgethostbynameparams hparams;
+#endif
+
+ /* Why not use gethostname()? Well, at least on my system, I've had to
+ * make an ugly kernel patch to get a name longer than 8 characters, and
+ * uname() lets me access to the whole string (it smashes release, you
+ * see), whereas gethostname() kindly truncates it for me.
+ */
+#ifndef WIN32
+ uname(&name);
+#else
+ gethostname(name.nodename, sizeof(name.nodename));
+#endif
+
+ hp = _XGethostbyname(name.nodename, hparams);
+ if (hp != NULL)
+ {
+ #ifdef h_addr
+ #define hp_addr *list
+ char **list;
+
+ /* iterate over the addresses */
+ for (list = hp->h_addr_list; *list; list++)
+ #else
+ #define hp_addr hp->h_addr
+ #endif
+ {
+ saddr.sa.sa_family = hp->h_addrtype;
+ switch (hp->h_addrtype) {
+ case AF_INET:
+ inetaddr = (struct sockaddr_in *) (&(saddr.sa));
+ acopy ( hp_addr, &(inetaddr->sin_addr), hp->h_length);
+ len = sizeof(saddr.sa);
+ break;
+#if defined(IPv6) && defined(AF_INET6)
+ case AF_INET6:
+ inet6addr = (struct sockaddr_in6 *) (&(saddr.sa));
+ acopy ( hp_addr, &(inet6addr->sin6_addr), hp->h_length);
+ len = sizeof(saddr.in6);
+ break;
+#endif
+ default:
+ goto DefineLocalHost;
+ }
+ family = ConvertAddr ( &(saddr.sa), &len, (pointer *)&addr);
+ if ( family != -1 && family != FamilyLocal )
+ {
+ for (host = selfhosts;
+ host && !addrEqual (family, addr, len, host);
+ host = host->next) ;
+ if (!host)
+ {
+ /* add this host to the host list. */
+ MakeHost(host,len)
+ if (host)
+ {
+ host->family = family;
+ host->len = len;
+ acopy ( addr, host->addr, len);
+ host->next = selfhosts;
+ selfhosts = host;
+ }
+ #ifdef XDMCP
+ /*
+ * If this is an Internet Address, but not the localhost
+ * address (127.0.0.1), nor the bogus address (0.0.0.0),
+ * register it.
+ */
+ if (family == FamilyInternet &&
+ !(len == 4 &&
+ ((addr[0] == 127) ||
+ (addr[0] == 0 && addr[1] == 0 &&
+ addr[2] == 0 && addr[3] == 0)))
+ )
+ {
+ XdmcpRegisterConnection (family, (char *)addr, len);
+ broad_addr = *inetaddr;
+ ((struct sockaddr_in *) &broad_addr)->sin_addr.s_addr =
+ htonl (INADDR_BROADCAST);
+ XdmcpRegisterBroadcastAddress ((struct sockaddr_in *)
+ &broad_addr);
+ }
+ #if defined(IPv6) && defined(AF_INET6)
+ else if (family == FamilyInternet6 &&
+ !(IN6_IS_ADDR_LOOPBACK((struct in6_addr *)addr)))
+ {
+ XdmcpRegisterConnection (family, (char *)addr, len);
+ }
+ #endif
+
+ #endif /* XDMCP */
+ }
+ }
+ }
+ }
+ /*
+ * now add a host of family FamilyLocalHost...
+ */
+DefineLocalHost:
+ for (host = selfhosts;
+ host && !addrEqual(FamilyLocalHost, "", 0, host);
+ host = host->next);
+ if (!host)
+ {
+ MakeHost(host, 0);
+ if (host)
+ {
+ host->family = FamilyLocalHost;
+ host->len = 0;
+ acopy("", host->addr, 0);
+ host->next = selfhosts;
+ selfhosts = host;
+ }
+ }
+#endif /* !TCPCONN && !STREAMSCONN && !UNIXCONN */
+}
+
+#else
+
+#ifdef USE_SIOCGLIFCONF
+#define ifr_type struct lifreq
+#else
+#define ifr_type struct ifreq
+#endif
+
+#ifdef VARIABLE_IFREQ
+#define ifr_size(p) (sizeof (struct ifreq) + \
+ (p->ifr_addr.sa_len > sizeof (p->ifr_addr) ? \
+ p->ifr_addr.sa_len - sizeof (p->ifr_addr) : 0))
+#define ifraddr_size(a) (a.sa_len)
+#else
+#define ifr_size(p) (sizeof (ifr_type))
+#define ifraddr_size(a) (sizeof (a))
+#endif
+
+#if defined(IPv6) && defined(AF_INET6)
+#include <arpa/inet.h>
+#endif
+
+#if defined(IPv6) && defined(AF_INET6)
+static void
+in6_fillscopeid(struct sockaddr_in6 *sin6)
+{
+#if defined(__KAME__)
+ if (IN6_IS_ADDR_LINKLOCAL(&sin6->sin6_addr)) {
+ sin6->sin6_scope_id =
+ ntohs(*(u_int16_t *)&sin6->sin6_addr.s6_addr[2]);
+ sin6->sin6_addr.s6_addr[2] = sin6->sin6_addr.s6_addr[3] = 0;
+ }
+#endif
+}
+#endif
+
+void
+DefineSelf (int fd)
+{
+#ifndef HAS_GETIFADDRS
+ char *cp, *cplim;
+# ifdef USE_SIOCGLIFCONF
+ struct sockaddr_storage buf[16];
+ struct lifconf ifc;
+ register struct lifreq *ifr;
+# ifdef SIOCGLIFNUM
+ struct lifnum ifn;
+# endif
+# else /* !USE_SIOCGLIFCONF */
+ char buf[2048];
+ struct ifconf ifc;
+ register struct ifreq *ifr;
+# endif
+ void * bufptr = buf;
+#else /* HAS_GETIFADDRS */
+ struct ifaddrs * ifap, *ifr;
+#endif
+ int len;
+ unsigned char * addr;
+ int family;
+ register HOST *host;
+
+#ifndef HAS_GETIFADDRS
+
+ len = sizeof(buf);
+
+#ifdef USE_SIOCGLIFCONF
+
+#ifdef SIOCGLIFNUM
+ ifn.lifn_family = AF_UNSPEC;
+ ifn.lifn_flags = 0;
+ if (ioctl (fd, SIOCGLIFNUM, (char *) &ifn) < 0)
+ Error ("Getting interface count");
+ if (len < (ifn.lifn_count * sizeof(struct lifreq))) {
+ len = ifn.lifn_count * sizeof(struct lifreq);
+ bufptr = malloc(len);
+ }
+#endif
+
+ ifc.lifc_family = AF_UNSPEC;
+ ifc.lifc_flags = 0;
+ ifc.lifc_len = len;
+ ifc.lifc_buf = bufptr;
+
+#define IFC_IOCTL_REQ SIOCGLIFCONF
+#define IFC_IFC_REQ ifc.lifc_req
+#define IFC_IFC_LEN ifc.lifc_len
+#define IFR_IFR_ADDR ifr->lifr_addr
+#define IFR_IFR_NAME ifr->lifr_name
+
+#else /* Use SIOCGIFCONF */
+ ifc.ifc_len = len;
+ ifc.ifc_buf = bufptr;
+
+#define IFC_IOCTL_REQ SIOCGIFCONF
+#define IFC_IFC_REQ ifc.ifc_req
+#define IFC_IFC_LEN ifc.ifc_len
+#define IFR_IFR_ADDR ifr->ifr_addr
+#define IFR_IFR_NAME ifr->ifr_name
+#endif
+
+ if (ifioctl (fd, IFC_IOCTL_REQ, (pointer) &ifc) < 0)
+ Error ("Getting interface configuration (4)");
+
+ cplim = (char *) IFC_IFC_REQ + IFC_IFC_LEN;
+
+ for (cp = (char *) IFC_IFC_REQ; cp < cplim; cp += ifr_size (ifr))
+ {
+ ifr = (ifr_type *) cp;
+ len = ifraddr_size (IFR_IFR_ADDR);
+ family = ConvertAddr ((struct sockaddr *) &IFR_IFR_ADDR,
+ &len, (pointer *)&addr);
+ if (family == -1 || family == FamilyLocal)
+ continue;
+#if defined(IPv6) && defined(AF_INET6)
+ if (family == FamilyInternet6)
+ in6_fillscopeid((struct sockaddr_in6 *)&IFR_IFR_ADDR);
+#endif
+ for (host = selfhosts;
+ host && !addrEqual (family, addr, len, host);
+ host = host->next)
+ ;
+ if (host)
+ continue;
+ MakeHost(host,len)
+ if (host)
+ {
+ host->family = family;
+ host->len = len;
+ acopy(addr, host->addr, len);
+ host->next = selfhosts;
+ selfhosts = host;
+ }
+#ifdef XDMCP
+ {
+#ifdef USE_SIOCGLIFCONF
+ struct sockaddr_storage broad_addr;
+#else
+ struct sockaddr broad_addr;
+#endif
+
+ /*
+ * If this isn't an Internet Address, don't register it.
+ */
+ if (family != FamilyInternet
+#if defined(IPv6) && defined(AF_INET6)
+ && family != FamilyInternet6
+#endif
+ )
+ continue;
+
+ /*
+ * ignore 'localhost' entries as they're not useful
+ * on the other end of the wire
+ */
+ if (family == FamilyInternet &&
+ addr[0] == 127 && addr[1] == 0 &&
+ addr[2] == 0 && addr[3] == 1)
+ continue;
+#if defined(IPv6) && defined(AF_INET6)
+ else if (family == FamilyInternet6 &&
+ IN6_IS_ADDR_LOOPBACK((struct in6_addr *)addr))
+ continue;
+#endif
+
+ /*
+ * Ignore '0.0.0.0' entries as they are
+ * returned by some OSes for unconfigured NICs but they are
+ * not useful on the other end of the wire.
+ */
+ if (len == 4 &&
+ addr[0] == 0 && addr[1] == 0 &&
+ addr[2] == 0 && addr[3] == 0)
+ continue;
+
+ XdmcpRegisterConnection (family, (char *)addr, len);
+
+#if defined(IPv6) && defined(AF_INET6)
+ /* IPv6 doesn't support broadcasting, so we drop out here */
+ if (family == FamilyInternet6)
+ continue;
+#endif
+
+ broad_addr = IFR_IFR_ADDR;
+
+ ((struct sockaddr_in *) &broad_addr)->sin_addr.s_addr =
+ htonl (INADDR_BROADCAST);
+#if defined(USE_SIOCGLIFCONF) && defined(SIOCGLIFBRDADDR)
+ {
+ struct lifreq broad_req;
+
+ broad_req = *ifr;
+ if (ioctl (fd, SIOCGLIFFLAGS, (char *) &broad_req) != -1 &&
+ (broad_req.lifr_flags & IFF_BROADCAST) &&
+ (broad_req.lifr_flags & IFF_UP)
+ )
+ {
+ broad_req = *ifr;
+ if (ioctl (fd, SIOCGLIFBRDADDR, &broad_req) != -1)
+ broad_addr = broad_req.lifr_broadaddr;
+ else
+ continue;
+ }
+ else
+ continue;
+ }
+
+#elif defined(SIOCGIFBRDADDR)
+ {
+ struct ifreq broad_req;
+
+ broad_req = *ifr;
+ if (ifioctl (fd, SIOCGIFFLAGS, (pointer) &broad_req) != -1 &&
+ (broad_req.ifr_flags & IFF_BROADCAST) &&
+ (broad_req.ifr_flags & IFF_UP)
+ )
+ {
+ broad_req = *ifr;
+ if (ifioctl (fd, SIOCGIFBRDADDR, (pointer) &broad_req) != -1)
+ broad_addr = broad_req.ifr_addr;
+ else
+ continue;
+ }
+ else
+ continue;
+ }
+#endif /* SIOCGIFBRDADDR */
+ XdmcpRegisterBroadcastAddress ((struct sockaddr_in *) &broad_addr);
+ }
+#endif /* XDMCP */
+ }
+ if (bufptr != buf)
+ free(bufptr);
+#else /* HAS_GETIFADDRS */
+ if (getifaddrs(&ifap) < 0) {
+ ErrorF("Warning: getifaddrs returns %s\n", strerror(errno));
+ return;
+ }
+ for (ifr = ifap; ifr != NULL; ifr = ifr->ifa_next) {
+ if (!ifr->ifa_addr)
+ continue;
+ len = sizeof(*(ifr->ifa_addr));
+ family = ConvertAddr((struct sockaddr *) ifr->ifa_addr, &len,
+ (pointer *)&addr);
+ if (family == -1 || family == FamilyLocal)
+ continue;
+#if defined(IPv6) && defined(AF_INET6)
+ if (family == FamilyInternet6)
+ in6_fillscopeid((struct sockaddr_in6 *)ifr->ifa_addr);
+#endif
+
+ for (host = selfhosts;
+ host != NULL && !addrEqual(family, addr, len, host);
+ host = host->next)
+ ;
+ if (host != NULL)
+ continue;
+ MakeHost(host, len);
+ if (host != NULL) {
+ host->family = family;
+ host->len = len;
+ acopy(addr, host->addr, len);
+ host->next = selfhosts;
+ selfhosts = host;
+ }
+#ifdef XDMCP
+ {
+ /*
+ * If this isn't an Internet Address, don't register it.
+ */
+ if (family != FamilyInternet
+#if defined(IPv6) && defined(AF_INET6)
+ && family != FamilyInternet6
+#endif
+ )
+ continue;
+
+ /*
+ * ignore 'localhost' entries as they're not useful
+ * on the other end of the wire
+ */
+ if (ifr->ifa_flags & IFF_LOOPBACK)
+ continue;
+
+ if (family == FamilyInternet &&
+ addr[0] == 127 && addr[1] == 0 &&
+ addr[2] == 0 && addr[3] == 1)
+ continue;
+
+ /*
+ * Ignore '0.0.0.0' entries as they are
+ * returned by some OSes for unconfigured NICs but they are
+ * not useful on the other end of the wire.
+ */
+ if (len == 4 &&
+ addr[0] == 0 && addr[1] == 0 &&
+ addr[2] == 0 && addr[3] == 0)
+ continue;
+#if defined(IPv6) && defined(AF_INET6)
+ else if (family == FamilyInternet6 &&
+ IN6_IS_ADDR_LOOPBACK((struct in6_addr *)addr))
+ continue;
+#endif
+ XdmcpRegisterConnection(family, (char *)addr, len);
+#if defined(IPv6) && defined(AF_INET6)
+ if (family == FamilyInternet6)
+ /* IPv6 doesn't support broadcasting, so we drop out here */
+ continue;
+#endif
+ if ((ifr->ifa_flags & IFF_BROADCAST) &&
+ (ifr->ifa_flags & IFF_UP) &&
+ ifr->ifa_broadaddr)
+ XdmcpRegisterBroadcastAddress(
+ (struct sockaddr_in *) ifr->ifa_broadaddr);
+ else
+ continue;
+ }
+#endif /* XDMCP */
+
+ } /* for */
+ freeifaddrs(ifap);
+#endif /* HAS_GETIFADDRS */
+
+ /*
+ * add something of FamilyLocalHost
+ */
+ for (host = selfhosts;
+ host && !addrEqual(FamilyLocalHost, "", 0, host);
+ host = host->next);
+ if (!host)
+ {
+ MakeHost(host, 0);
+ if (host)
+ {
+ host->family = FamilyLocalHost;
+ host->len = 0;
+ acopy("", host->addr, 0);
+ host->next = selfhosts;
+ selfhosts = host;
+ }
+ }
+}
+#endif /* hpux && !HAS_IFREQ */
+
+#ifdef XDMCP
+void
+AugmentSelf(pointer from, int len)
+{
+ int family;
+ pointer addr;
+ register HOST *host;
+
+ family = ConvertAddr(from, &len, (pointer *)&addr);
+ if (family == -1 || family == FamilyLocal)
+ return;
+ for (host = selfhosts; host; host = host->next)
+ {
+ if (addrEqual(family, addr, len, host))
+ return;
+ }
+ MakeHost(host,len)
+ if (!host)
+ return;
+ host->family = family;
+ host->len = len;
+ acopy(addr, host->addr, len);
+ host->next = selfhosts;
+ selfhosts = host;
+}
+#endif
+
+void
+AddLocalHosts (void)
+{
+ HOST *self;
+
+ for (self = selfhosts; self; self = self->next)
+ /* Fix for XFree86 bug #156: pass addingLocal = TRUE to
+ * NewHost to tell that we are adding the default local
+ * host entries and not to flag the entries as being
+ * explicitely requested */
+ (void) NewHost (self->family, self->addr, self->len, TRUE);
+}
+
+/* Reset access control list to initial hosts */
+void
+ResetHosts (char *display)
+{
+ register HOST *host;
+ char lhostname[120], ohostname[120];
+ char *hostname = ohostname;
+ char fname[PATH_MAX + 1];
+ int fnamelen;
+ FILE *fd;
+ char *ptr;
+ int i, hostlen;
+#if (defined(TCPCONN) || defined(STREAMSCONN) ) && \
+ (!defined(IPv6) || !defined(AF_INET6))
+ union {
+ struct sockaddr sa;
+#if defined(TCPCONN) || defined(STREAMSCONN)
+ struct sockaddr_in in;
+#endif /* TCPCONN || STREAMSCONN */
+ } saddr;
+#endif
+ int family = 0;
+ pointer addr;
+ int len;
+
+ siTypesInitialize();
+ AccessEnabled = defeatAccessControl ? FALSE : DEFAULT_ACCESS_CONTROL;
+ LocalHostEnabled = FALSE;
+ while ((host = validhosts) != 0)
+ {
+ validhosts = host->next;
+ FreeHost (host);
+ }
+
+#if defined WIN32 && defined __MINGW32__
+#define ETC_HOST_PREFIX "X"
+#else
+#define ETC_HOST_PREFIX "/etc/X"
+#endif
+#define ETC_HOST_SUFFIX ".hosts"
+ fnamelen = strlen(ETC_HOST_PREFIX) + strlen(ETC_HOST_SUFFIX) +
+ strlen(display) + 1;
+ if (fnamelen > sizeof(fname))
+ FatalError("Display name `%s' is too long\n", display);
+ snprintf(fname, sizeof(fname), ETC_HOST_PREFIX "%s" ETC_HOST_SUFFIX,
+ display);
+
+ if ((fd = fopen (fname, "r")) != 0)
+ {
+ while (fgets (ohostname, sizeof (ohostname), fd))
+ {
+ family = FamilyWild;
+ if (*ohostname == '#')
+ continue;
+ if ((ptr = strchr(ohostname, '\n')) != 0)
+ *ptr = 0;
+ hostlen = strlen(ohostname) + 1;
+ for (i = 0; i < hostlen; i++)
+ lhostname[i] = tolower(ohostname[i]);
+ hostname = ohostname;
+ if (!strncmp("local:", lhostname, 6))
+ {
+ family = FamilyLocalHost;
+ NewHost(family, "", 0, FALSE);
+ LocalHostRequested = TRUE; /* Fix for XFree86 bug #156 */
+ }
+#if defined(TCPCONN) || defined(STREAMSCONN)
+ else if (!strncmp("inet:", lhostname, 5))
+ {
+ family = FamilyInternet;
+ hostname = ohostname + 5;
+ }
+#if defined(IPv6) && defined(AF_INET6)
+ else if (!strncmp("inet6:", lhostname, 6))
+ {
+ family = FamilyInternet6;
+ hostname = ohostname + 6;
+ }
+#endif
+#endif
+#ifdef SECURE_RPC
+ else if (!strncmp("nis:", lhostname, 4))
+ {
+ family = FamilyNetname;
+ hostname = ohostname + 4;
+ }
+#endif
+ else if (!strncmp("si:", lhostname, 3))
+ {
+ family = FamilyServerInterpreted;
+ hostname = ohostname + 3;
+ hostlen -= 3;
+ }
+
+
+ if (family == FamilyServerInterpreted)
+ {
+ len = siCheckAddr(hostname, hostlen);
+ if (len >= 0) {
+ NewHost(family, hostname, len, FALSE);
+ }
+ }
+ else
+#ifdef SECURE_RPC
+ if ((family == FamilyNetname) || (strchr(hostname, '@')))
+ {
+ SecureRPCInit ();
+ (void) NewHost (FamilyNetname, hostname, strlen (hostname), FALSE);
+ }
+ else
+#endif /* SECURE_RPC */
+#if defined(TCPCONN) || defined(STREAMSCONN)
+ {
+#if defined(IPv6) && defined(AF_INET6)
+ if ( (family == FamilyInternet) || (family == FamilyInternet6) ||
+ (family == FamilyWild) )
+ {
+ struct addrinfo *addresses;
+ struct addrinfo *a;
+ int f;
+
+ if (getaddrinfo(hostname, NULL, NULL, &addresses) == 0) {
+ for (a = addresses ; a != NULL ; a = a->ai_next) {
+ len = a->ai_addrlen;
+ f = ConvertAddr(a->ai_addr,&len,(pointer *)&addr);
+ if ( (family == f) ||
+ ((family == FamilyWild) && (f != -1)) ) {
+ NewHost(f, addr, len, FALSE);
+ }
+ }
+ freeaddrinfo(addresses);
+ }
+ }
+#else
+#ifdef XTHREADS_NEEDS_BYNAMEPARAMS
+ _Xgethostbynameparams hparams;
+#endif
+ register struct hostent *hp;
+
+ /* host name */
+ if ((family == FamilyInternet &&
+ ((hp = _XGethostbyname(hostname, hparams)) != 0)) ||
+ ((hp = _XGethostbyname(hostname, hparams)) != 0))
+ {
+ saddr.sa.sa_family = hp->h_addrtype;
+ len = sizeof(saddr.sa);
+ if ((family = ConvertAddr (&saddr.sa, &len, (pointer *)&addr)) != -1)
+ {
+#ifdef h_addr /* new 4.3bsd version of gethostent */
+ char **list;
+
+ /* iterate over the addresses */
+ for (list = hp->h_addr_list; *list; list++)
+ (void) NewHost (family, (pointer)*list, len, FALSE);
+#else
+ (void) NewHost (family, (pointer)hp->h_addr, len, FALSE);
+#endif
+ }
+ }
+#endif /* IPv6 */
+ }
+#endif /* TCPCONN || STREAMSCONN */
+ family = FamilyWild;
+ }
+ fclose (fd);
+ }
+}
+
+/* Is client on the local host */
+Bool LocalClient(ClientPtr client)
+{
+ int alen, family, notused;
+ Xtransaddr *from = NULL;
+ pointer addr;
+ register HOST *host;
+
+ if (!client->osPrivate)
+ return FALSE;
+ if (!((OsCommPtr)client->osPrivate)->trans_conn)
+ return FALSE;
+
+ if (!_XSERVTransGetPeerAddr (((OsCommPtr)client->osPrivate)->trans_conn,
+ &notused, &alen, &from))
+ {
+ family = ConvertAddr ((struct sockaddr *) from,
+ &alen, (pointer *)&addr);
+ if (family == -1)
+ {
+ free(from);
+ return FALSE;
+ }
+ if (family == FamilyLocal)
+ {
+ free(from);
+ return TRUE;
+ }
+ for (host = selfhosts; host; host = host->next)
+ {
+ if (addrEqual (family, addr, alen, host))
+ return TRUE;
+ }
+ free(from);
+ }
+ return FALSE;
+}
+
+/*
+ * Return the uid and gid of a connected local client
+ *
+ * Used by XShm to test access rights to shared memory segments
+ */
+int
+LocalClientCred(ClientPtr client, int *pUid, int *pGid)
+{
+ LocalClientCredRec *lcc;
+ int ret = GetLocalClientCreds(client, &lcc);
+
+ if (ret == 0) {
+#ifdef HAVE_GETZONEID /* only local if in the same zone */
+ if ((lcc->fieldsSet & LCC_ZID_SET) && (lcc->zoneid != getzoneid())) {
+ FreeLocalClientCreds(lcc);
+ return -1;
+ }
+#endif
+ if ((lcc->fieldsSet & LCC_UID_SET) && (pUid != NULL))
+ *pUid = lcc->euid;
+ if ((lcc->fieldsSet & LCC_GID_SET) && (pGid != NULL))
+ *pGid = lcc->egid;
+ FreeLocalClientCreds(lcc);
+ }
+ return ret;
+}
+
+/*
+ * Return the uid and all gids of a connected local client
+ * Allocates a LocalClientCredRec - caller must call FreeLocalClientCreds
+ *
+ * Used by localuser & localgroup ServerInterpreted access control forms below
+ * Used by AuthAudit to log who local connections came from
+ */
+int
+GetLocalClientCreds(ClientPtr client, LocalClientCredRec **lccp)
+{
+#if defined(HAS_GETPEEREID) || defined(HAS_GETPEERUCRED) || defined(SO_PEERCRED)
+ int fd;
+ XtransConnInfo ci;
+ LocalClientCredRec *lcc;
+#ifdef HAS_GETPEEREID
+ uid_t uid;
+ gid_t gid;
+#elif defined(HAS_GETPEERUCRED)
+ ucred_t *peercred = NULL;
+ const gid_t *gids;
+#elif defined(SO_PEERCRED)
+ struct ucred peercred;
+ socklen_t so_len = sizeof(peercred);
+#endif
+
+ if (client == NULL)
+ return -1;
+ ci = ((OsCommPtr)client->osPrivate)->trans_conn;
+#if !(defined(sun) && defined(HAS_GETPEERUCRED))
+ /* Most implementations can only determine peer credentials for Unix
+ * domain sockets - Solaris getpeerucred can work with a bit more, so
+ * we just let it tell us if the connection type is supported or not
+ */
+ if (!_XSERVTransIsLocal(ci)) {
+ return -1;
+ }
+#endif
+
+ *lccp = calloc(1, sizeof(LocalClientCredRec));
+ if (*lccp == NULL)
+ return -1;
+ lcc = *lccp;
+
+ fd = _XSERVTransGetConnectionNumber(ci);
+#ifdef HAS_GETPEEREID
+ if (getpeereid(fd, &uid, &gid) == -1) {
+ FreeLocalClientCreds(lcc);
+ return -1;
+ }
+ lcc->euid = uid;
+ lcc->egid = gid;
+ lcc->fieldsSet = LCC_UID_SET | LCC_GID_SET;
+ return 0;
+#elif defined(HAS_GETPEERUCRED)
+ if (getpeerucred(fd, &peercred) < 0) {
+ FreeLocalClientCreds(lcc);
+ return -1;
+ }
+ lcc->euid = ucred_geteuid(peercred);
+ if (lcc->euid != -1)
+ lcc->fieldsSet |= LCC_UID_SET;
+ lcc->egid = ucred_getegid(peercred);
+ if (lcc->egid != -1)
+ lcc->fieldsSet |= LCC_GID_SET;
+ lcc->pid = ucred_getpid(peercred);
+ if (lcc->pid != -1)
+ lcc->fieldsSet |= LCC_PID_SET;
+#ifdef HAVE_GETZONEID
+ lcc->zoneid = ucred_getzoneid(peercred);
+ if (lcc->zoneid != -1)
+ lcc->fieldsSet |= LCC_ZID_SET;
+#endif
+ lcc->nSuppGids = ucred_getgroups(peercred, &gids);
+ if (lcc->nSuppGids > 0) {
+ lcc->pSuppGids = calloc(lcc->nSuppGids, sizeof(int));
+ if (lcc->pSuppGids == NULL) {
+ lcc->nSuppGids = 0;
+ } else {
+ int i;
+ for (i = 0 ; i < lcc->nSuppGids; i++) {
+ (lcc->pSuppGids)[i] = (int) gids[i];
+ }
+ }
+ } else {
+ lcc->nSuppGids = 0;
+ }
+ ucred_free(peercred);
+ return 0;
+#elif defined(SO_PEERCRED)
+ if (getsockopt(fd, SOL_SOCKET, SO_PEERCRED, &peercred, &so_len) == -1) {
+ FreeLocalClientCreds(lcc);
+ return -1;
+ }
+ lcc->euid = peercred.uid;
+ lcc->egid = peercred.gid;
+ lcc->pid = peercred.pid;
+ lcc->fieldsSet = LCC_UID_SET | LCC_GID_SET | LCC_PID_SET;
+ return 0;
+#endif
+#else
+ /* No system call available to get the credentials of the peer */
+#define NO_LOCAL_CLIENT_CRED
+ return -1;
+#endif
+}
+
+void
+FreeLocalClientCreds(LocalClientCredRec *lcc)
+{
+ if (lcc != NULL) {
+ if (lcc->nSuppGids > 0) {
+ free(lcc->pSuppGids);
+ }
+ free(lcc);
+ }
+}
+
+static int
+AuthorizedClient(ClientPtr client)
+{
+ int rc;
+
+ if (!client || defeatAccessControl)
+ return Success;
+
+ /* untrusted clients can't change host access */
+ rc = XaceHook(XACE_SERVER_ACCESS, client, DixManageAccess);
+ if (rc != Success)
+ return rc;
+
+ return LocalClient(client) ? Success : BadAccess;
+}
+
+/* Add a host to the access control list. This is the external interface
+ * called from the dispatcher */
+
+int
+AddHost (ClientPtr client,
+ int family,
+ unsigned length, /* of bytes in pAddr */
+ const void * pAddr)
+{
+ int rc, len;
+
+ rc = AuthorizedClient(client);
+ if (rc != Success)
+ return rc;
+ switch (family) {
+ case FamilyLocalHost:
+ len = length;
+ LocalHostEnabled = TRUE;
+ break;
+#ifdef SECURE_RPC
+ case FamilyNetname:
+ len = length;
+ SecureRPCInit ();
+ break;
+#endif
+ case FamilyInternet:
+#if defined(IPv6) && defined(AF_INET6)
+ case FamilyInternet6:
+#endif
+ case FamilyDECnet:
+ case FamilyChaos:
+ case FamilyServerInterpreted:
+ if ((len = CheckAddr (family, pAddr, length)) < 0)
+ {
+ client->errorValue = length;
+ return BadValue;
+ }
+ break;
+ case FamilyLocal:
+ default:
+ client->errorValue = family;
+ return BadValue;
+ }
+ if (NewHost (family, pAddr, len, FALSE))
+ return Success;
+ return BadAlloc;
+}
+
+Bool
+ForEachHostInFamily (int family,
+ Bool (*func)(
+ unsigned char * /* addr */,
+ short /* len */,
+ pointer /* closure */),
+ pointer closure)
+{
+ HOST *host;
+
+ for (host = validhosts; host; host = host->next)
+ if (family == host->family && func (host->addr, host->len, closure))
+ return TRUE;
+ return FALSE;
+}
+
+/* Add a host to the access control list. This is the internal interface
+ * called when starting or resetting the server */
+static Bool
+NewHost (int family,
+ const void * addr,
+ int len,
+ int addingLocalHosts)
+{
+ register HOST *host;
+
+ for (host = validhosts; host; host = host->next)
+ {
+ if (addrEqual (family, addr, len, host))
+ return TRUE;
+ }
+ if (!addingLocalHosts) { /* Fix for XFree86 bug #156 */
+ for (host = selfhosts; host; host = host->next) {
+ if (addrEqual (family, addr, len, host)) {
+ host->requested = TRUE;
+ break;
+ }
+ }
+ }
+ MakeHost(host,len)
+ if (!host)
+ return FALSE;
+ host->family = family;
+ host->len = len;
+ acopy(addr, host->addr, len);
+ host->next = validhosts;
+ validhosts = host;
+ return TRUE;
+}
+
+/* Remove a host from the access control list */
+
+int
+RemoveHost (
+ ClientPtr client,
+ int family,
+ unsigned length, /* of bytes in pAddr */
+ pointer pAddr)
+{
+ int rc, len;
+ register HOST *host, **prev;
+
+ rc = AuthorizedClient(client);
+ if (rc != Success)
+ return rc;
+ switch (family) {
+ case FamilyLocalHost:
+ len = length;
+ LocalHostEnabled = FALSE;
+ break;
+#ifdef SECURE_RPC
+ case FamilyNetname:
+ len = length;
+ break;
+#endif
+ case FamilyInternet:
+#if defined(IPv6) && defined(AF_INET6)
+ case FamilyInternet6:
+#endif
+ case FamilyDECnet:
+ case FamilyChaos:
+ case FamilyServerInterpreted:
+ if ((len = CheckAddr (family, pAddr, length)) < 0)
+ {
+ client->errorValue = length;
+ return BadValue;
+ }
+ break;
+ case FamilyLocal:
+ default:
+ client->errorValue = family;
+ return BadValue;
+ }
+ for (prev = &validhosts;
+ (host = *prev) && (!addrEqual (family, pAddr, len, host));
+ prev = &host->next)
+ ;
+ if (host)
+ {
+ *prev = host->next;
+ FreeHost (host);
+ }
+ return Success;
+}
+
+/* Get all hosts in the access control list */
+int
+GetHosts (
+ pointer *data,
+ int *pnHosts,
+ int *pLen,
+ BOOL *pEnabled)
+{
+ int len;
+ register int n = 0;
+ register unsigned char *ptr;
+ register HOST *host;
+ int nHosts = 0;
+
+ *pEnabled = AccessEnabled ? EnableAccess : DisableAccess;
+ for (host = validhosts; host; host = host->next)
+ {
+ nHosts++;
+ n += pad_to_int32(host->len) + sizeof(xHostEntry);
+ }
+ if (n)
+ {
+ *data = ptr = malloc(n);
+ if (!ptr)
+ {
+ return BadAlloc;
+ }
+ for (host = validhosts; host; host = host->next)
+ {
+ len = host->len;
+ ((xHostEntry *)ptr)->family = host->family;
+ ((xHostEntry *)ptr)->length = len;
+ ptr += sizeof(xHostEntry);
+ acopy (host->addr, ptr, len);
+ ptr += pad_to_int32(len);
+ }
+ } else {
+ *data = NULL;
+ }
+ *pnHosts = nHosts;
+ *pLen = n;
+ return Success;
+}
+
+/* Check for valid address family and length, and return address length. */
+
+/*ARGSUSED*/
+static int
+CheckAddr (
+ int family,
+ const void * pAddr,
+ unsigned length)
+{
+ int len;
+
+ switch (family)
+ {
+#if defined(TCPCONN) || defined(STREAMSCONN)
+ case FamilyInternet:
+ if (length == sizeof (struct in_addr))
+ len = length;
+ else
+ len = -1;
+ break;
+#if defined(IPv6) && defined(AF_INET6)
+ case FamilyInternet6:
+ if (length == sizeof (struct in6_addr))
+ len = length;
+ else
+ len = -1;
+ break;
+#endif
+#endif
+ case FamilyServerInterpreted:
+ len = siCheckAddr(pAddr, length);
+ break;
+ default:
+ len = -1;
+ }
+ return len;
+}
+
+/* Check if a host is not in the access control list.
+ * Returns 1 if host is invalid, 0 if we've found it. */
+
+int
+InvalidHost (
+ register struct sockaddr *saddr,
+ int len,
+ ClientPtr client)
+{
+ int family;
+ pointer addr;
+ register HOST *selfhost, *host;
+
+ if (!AccessEnabled) /* just let them in */
+ return 0;
+ family = ConvertAddr (saddr, &len, (pointer *)&addr);
+ if (family == -1)
+ return 1;
+ if (family == FamilyLocal)
+ {
+ if (!LocalHostEnabled)
+ {
+ /*
+ * check to see if any local address is enabled. This
+ * implicitly enables local connections.
+ */
+ for (selfhost = selfhosts; selfhost; selfhost=selfhost->next)
+ {
+ for (host = validhosts; host; host=host->next)
+ {
+ if (addrEqual (selfhost->family, selfhost->addr,
+ selfhost->len, host))
+ return 0;
+ }
+ }
+ } else
+ return 0;
+ }
+ for (host = validhosts; host; host = host->next)
+ {
+ if ((host->family == FamilyServerInterpreted)) {
+ if (siAddrMatch (family, addr, len, host, client)) {
+ return 0;
+ }
+ } else {
+ if (addrEqual (family, addr, len, host))
+ return 0;
+ }
+
+ }
+ return 1;
+}
+
+static int
+ConvertAddr (
+ register struct sockaddr *saddr,
+ int *len,
+ pointer *addr)
+{
+ if (*len == 0)
+ return FamilyLocal;
+ switch (saddr->sa_family)
+ {
+ case AF_UNSPEC:
+#if defined(UNIXCONN) || defined(LOCALCONN)
+ case AF_UNIX:
+#endif
+ return FamilyLocal;
+#if defined(TCPCONN) || defined(STREAMSCONN)
+ case AF_INET:
+#ifdef WIN32
+ if (16777343 == *(long*)&((struct sockaddr_in *) saddr)->sin_addr)
+ return FamilyLocal;
+#endif
+ *len = sizeof (struct in_addr);
+ *addr = (pointer) &(((struct sockaddr_in *) saddr)->sin_addr);
+ return FamilyInternet;
+#if defined(IPv6) && defined(AF_INET6)
+ case AF_INET6:
+ {
+ struct sockaddr_in6 *saddr6 = (struct sockaddr_in6 *) saddr;
+ if (IN6_IS_ADDR_V4MAPPED(&(saddr6->sin6_addr))) {
+ *len = sizeof (struct in_addr);
+ *addr = (pointer) &(saddr6->sin6_addr.s6_addr[12]);
+ return FamilyInternet;
+ } else {
+ *len = sizeof (struct in6_addr);
+ *addr = (pointer) &(saddr6->sin6_addr);
+ return FamilyInternet6;
+ }
+ }
+#endif
+#endif
+ default:
+ return -1;
+ }
+}
+
+int
+ChangeAccessControl(
+ ClientPtr client,
+ int fEnabled)
+{
+ int rc = AuthorizedClient(client);
+ if (rc != Success)
+ return rc;
+ AccessEnabled = fEnabled;
+ return Success;
+}
+
+/* returns FALSE if xhost + in effect, else TRUE */
+int
+GetAccessControl(void)
+{
+ return AccessEnabled;
+}
+
+/*****************************************************************************
+ * FamilyServerInterpreted host entry implementation
+ *
+ * Supports an extensible system of host types which the server can interpret
+ * See the IPv6 extensions to the X11 protocol spec for the definition.
+ *
+ * Currently supported schemes:
+ *
+ * hostname - hostname as defined in IETF RFC 2396
+ * ipv6 - IPv6 literal address as defined in IETF RFC's 3513 and <TBD>
+ *
+ * See xc/doc/specs/SIAddresses for formal definitions of each type.
+ */
+
+/* These definitions and the siTypeAdd function could be exported in the
+ * future to enable loading additional host types, but that was not done for
+ * the initial implementation.
+ */
+typedef Bool (*siAddrMatchFunc)(int family, pointer addr, int len,
+ const char *siAddr, int siAddrlen, ClientPtr client, void *siTypePriv);
+typedef int (*siCheckAddrFunc)(const char *addrString, int length,
+ void *siTypePriv);
+
+struct siType {
+ struct siType * next;
+ const char * typeName;
+ siAddrMatchFunc addrMatch;
+ siCheckAddrFunc checkAddr;
+ void * typePriv; /* Private data for type routines */
+};
+
+static struct siType *siTypeList;
+
+static int
+siTypeAdd(const char *typeName, siAddrMatchFunc addrMatch,
+ siCheckAddrFunc checkAddr, void *typePriv)
+{
+ struct siType *s, *p;
+
+ if ((typeName == NULL) || (addrMatch == NULL) || (checkAddr == NULL))
+ return BadValue;
+
+ for (s = siTypeList, p = NULL; s != NULL ; p = s, s = s->next) {
+ if (strcmp(typeName, s->typeName) == 0) {
+ s->addrMatch = addrMatch;
+ s->checkAddr = checkAddr;
+ s->typePriv = typePriv;
+ return Success;
+ }
+ }
+
+ s = malloc(sizeof(struct siType));
+ if (s == NULL)
+ return BadAlloc;
+
+ if (p == NULL)
+ siTypeList = s;
+ else
+ p->next = s;
+
+ s->next = NULL;
+ s->typeName = typeName;
+ s->addrMatch = addrMatch;
+ s->checkAddr = checkAddr;
+ s->typePriv = typePriv;
+ return Success;
+}
+
+/* Checks to see if a host matches a server-interpreted host entry */
+static Bool
+siAddrMatch(int family, pointer addr, int len, HOST *host, ClientPtr client)
+{
+ Bool matches = FALSE;
+ struct siType *s;
+ const char *valueString;
+ int addrlen;
+
+ valueString = (const char *) memchr(host->addr, '\0', host->len);
+ if (valueString != NULL) {
+ for (s = siTypeList; s != NULL ; s = s->next) {
+ if (strcmp((char *) host->addr, s->typeName) == 0) {
+ addrlen = host->len - (strlen((char *)host->addr) + 1);
+ matches = s->addrMatch(family, addr, len,
+ valueString + 1, addrlen, client, s->typePriv);
+ break;
+ }
+ }
+#ifdef FAMILY_SI_DEBUG
+ ErrorF(
+ "Xserver: siAddrMatch(): type = %s, value = %*.*s -- %s\n",
+ host->addr, addrlen, addrlen, valueString + 1,
+ (matches) ? "accepted" : "rejected");
+#endif
+ }
+ return matches;
+}
+
+static int
+siCheckAddr(const char *addrString, int length)
+{
+ const char *valueString;
+ int addrlen, typelen;
+ int len = -1;
+ struct siType *s;
+
+ /* Make sure there is a \0 byte inside the specified length
+ to separate the address type from the address value. */
+ valueString = (const char *) memchr(addrString, '\0', length);
+ if (valueString != NULL) {
+ /* Make sure the first string is a recognized address type,
+ * and the second string is a valid address of that type.
+ */
+ typelen = strlen(addrString) + 1;
+ addrlen = length - typelen;
+
+ for (s = siTypeList; s != NULL ; s = s->next) {
+ if (strcmp(addrString, s->typeName) == 0) {
+ len = s->checkAddr(valueString + 1, addrlen, s->typePriv);
+ if (len >= 0) {
+ len += typelen;
+ }
+ break;
+ }
+ }
+#ifdef FAMILY_SI_DEBUG
+ {
+ const char *resultMsg;
+
+ if (s == NULL) {
+ resultMsg = "type not registered";
+ } else {
+ if (len == -1)
+ resultMsg = "rejected";
+ else
+ resultMsg = "accepted";
+ }
+
+ ErrorF("Xserver: siCheckAddr(): type = %s, value = %*.*s, len = %d -- %s\n",
+ addrString, addrlen, addrlen, valueString + 1, len, resultMsg);
+ }
+#endif
+ }
+ return len;
+}
+
+
+/***
+ * Hostname server-interpreted host type
+ *
+ * Stored as hostname string, explicitly defined to be resolved ONLY
+ * at access check time, to allow for hosts with dynamic addresses
+ * but static hostnames, such as found in some DHCP & mobile setups.
+ *
+ * Hostname must conform to IETF RFC 2396 sec. 3.2.2, which defines it as:
+ * hostname = *( domainlabel "." ) toplabel [ "." ]
+ * domainlabel = alphanum | alphanum *( alphanum | "-" ) alphanum
+ * toplabel = alpha | alpha *( alphanum | "-" ) alphanum
+ */
+
+#ifdef NI_MAXHOST
+# define SI_HOSTNAME_MAXLEN NI_MAXHOST
+#else
+# ifdef MAXHOSTNAMELEN
+# define SI_HOSTNAME_MAXLEN MAXHOSTNAMELEN
+# else
+# define SI_HOSTNAME_MAXLEN 256
+# endif
+#endif
+
+static Bool
+siHostnameAddrMatch(int family, pointer addr, int len,
+ const char *siAddr, int siAddrLen, ClientPtr client, void *typePriv)
+{
+ Bool res = FALSE;
+
+/* Currently only supports checking against IPv4 & IPv6 connections, but
+ * support for other address families, such as DECnet, could be added if
+ * desired.
+ */
+#if defined(IPv6) && defined(AF_INET6)
+ if ((family == FamilyInternet) || (family == FamilyInternet6)) {
+ char hostname[SI_HOSTNAME_MAXLEN];
+ struct addrinfo *addresses;
+ struct addrinfo *a;
+ int f, hostaddrlen;
+ pointer hostaddr;
+
+ if (siAddrLen >= sizeof(hostname))
+ return FALSE;
+
+ strncpy(hostname, siAddr, siAddrLen);
+ hostname[siAddrLen] = '\0';
+
+ if (getaddrinfo(hostname, NULL, NULL, &addresses) == 0) {
+ for (a = addresses ; a != NULL ; a = a->ai_next) {
+ hostaddrlen = a->ai_addrlen;
+ f = ConvertAddr(a->ai_addr,&hostaddrlen,&hostaddr);
+ if ((f == family) && (len == hostaddrlen) &&
+ (acmp (addr, hostaddr, len) == 0) ) {
+ res = TRUE;
+ break;
+ }
+ }
+ freeaddrinfo(addresses);
+ }
+ }
+#else /* IPv6 not supported, use gethostbyname instead for IPv4 */
+ if (family == FamilyInternet) {
+ register struct hostent *hp;
+#ifdef XTHREADS_NEEDS_BYNAMEPARAMS
+ _Xgethostbynameparams hparams;
+#endif
+ char hostname[SI_HOSTNAME_MAXLEN];
+ int f, hostaddrlen;
+ pointer hostaddr;
+ const char **addrlist;
+
+ if (siAddrLen >= sizeof(hostname))
+ return FALSE;
+
+ strncpy(hostname, siAddr, siAddrLen);
+ hostname[siAddrLen] = '\0';
+
+ if ((hp = _XGethostbyname(hostname, hparams)) != NULL) {
+#ifdef h_addr /* new 4.3bsd version of gethostent */
+ /* iterate over the addresses */
+ for (addrlist = hp->h_addr_list; *addrlist; addrlist++)
+#else
+ addrlist = &hp->h_addr;
+#endif
+ {
+ struct sockaddr_in sin;
+
+ sin.sin_family = hp->h_addrtype;
+ acopy ( *addrlist, &(sin.sin_addr), hp->h_length);
+ hostaddrlen = sizeof(sin);
+ f = ConvertAddr ((struct sockaddr *)&sin,
+ &hostaddrlen, &hostaddr);
+ if ((f == family) && (len == hostaddrlen) &&
+ (acmp (addr, hostaddr, len) == 0) ) {
+ res = TRUE;
+ break;
+ }
+ }
+ }
+ }
+#endif
+ return res;
+}
+
+
+static int
+siHostnameCheckAddr(const char *valueString, int length, void *typePriv)
+{
+ /* Check conformance of hostname to RFC 2396 sec. 3.2.2 definition.
+ * We do not use ctype functions here to avoid locale-specific
+ * character sets. Hostnames must be pure ASCII.
+ */
+ int len = length;
+ int i;
+ Bool dotAllowed = FALSE;
+ Bool dashAllowed = FALSE;
+
+ if ((length <= 0) || (length >= SI_HOSTNAME_MAXLEN)) {
+ len = -1;
+ } else {
+ for (i = 0; i < length; i++) {
+ char c = valueString[i];
+
+ if (c == 0x2E) { /* '.' */
+ if (dotAllowed == FALSE) {
+ len = -1;
+ break;
+ } else {
+ dotAllowed = FALSE;
+ dashAllowed = FALSE;
+ }
+ } else if (c == 0x2D) { /* '-' */
+ if (dashAllowed == FALSE) {
+ len = -1;
+ break;
+ } else {
+ dotAllowed = FALSE;
+ }
+ } else if (((c >= 0x30) && (c <= 0x3A)) /* 0-9 */ ||
+ ((c >= 0x61) && (c <= 0x7A)) /* a-z */ ||
+ ((c >= 0x41) && (c <= 0x5A)) /* A-Z */) {
+ dotAllowed = TRUE;
+ dashAllowed = TRUE;
+ } else { /* Invalid character */
+ len = -1;
+ break;
+ }
+ }
+ }
+ return len;
+}
+
+#if defined(IPv6) && defined(AF_INET6)
+/***
+ * "ipv6" server interpreted type
+ *
+ * Currently supports only IPv6 literal address as specified in IETF RFC 3513
+ *
+ * Once draft-ietf-ipv6-scoping-arch-00.txt becomes an RFC, support will be
+ * added for the scoped address format it specifies.
+ */
+
+/* Maximum length of an IPv6 address string - increase when adding support
+ * for scoped address qualifiers. Includes room for trailing NUL byte.
+ */
+#define SI_IPv6_MAXLEN INET6_ADDRSTRLEN
+
+static Bool
+siIPv6AddrMatch(int family, pointer addr, int len,
+ const char *siAddr, int siAddrlen, ClientPtr client, void *typePriv)
+{
+ struct in6_addr addr6;
+ char addrbuf[SI_IPv6_MAXLEN];
+
+ if ((family != FamilyInternet6) || (len != sizeof(addr6)))
+ return FALSE;
+
+ memcpy(addrbuf, siAddr, siAddrlen);
+ addrbuf[siAddrlen] = '\0';
+
+ if (inet_pton(AF_INET6, addrbuf, &addr6) != 1) {
+ perror("inet_pton");
+ return FALSE;
+ }
+
+ if (memcmp(addr, &addr6, len) == 0) {
+ return TRUE;
+ } else {
+ return FALSE;
+ }
+}
+
+static int
+siIPv6CheckAddr(const char *addrString, int length, void *typePriv)
+{
+ int len;
+
+ /* Minimum length is 3 (smallest legal address is "::1") */
+ if (length < 3) {
+ /* Address is too short! */
+ len = -1;
+ } else if (length >= SI_IPv6_MAXLEN) {
+ /* Address is too long! */
+ len = -1;
+ } else {
+ /* Assume inet_pton is sufficient validation */
+ struct in6_addr addr6;
+ char addrbuf[SI_IPv6_MAXLEN];
+
+ memcpy(addrbuf, addrString, length);
+ addrbuf[length] = '\0';
+
+ if (inet_pton(AF_INET6, addrbuf, &addr6) != 1) {
+ perror("inet_pton");
+ len = -1;
+ } else {
+ len = length;
+ }
+ }
+ return len;
+}
+#endif /* IPv6 */
+
+#if !defined(NO_LOCAL_CLIENT_CRED)
+/***
+ * "localuser" & "localgroup" server interpreted types
+ *
+ * Allows local connections from a given local user or group
+ */
+
+#include <pwd.h>
+#include <grp.h>
+
+#define LOCAL_USER 1
+#define LOCAL_GROUP 2
+
+typedef struct {
+ int credType;
+} siLocalCredPrivRec, *siLocalCredPrivPtr;
+
+static siLocalCredPrivRec siLocalUserPriv = { LOCAL_USER };
+static siLocalCredPrivRec siLocalGroupPriv = { LOCAL_GROUP };
+
+static Bool
+siLocalCredGetId(const char *addr, int len, siLocalCredPrivPtr lcPriv, int *id)
+{
+ Bool parsedOK = FALSE;
+ char *addrbuf = malloc(len + 1);
+
+ if (addrbuf == NULL) {
+ return FALSE;
+ }
+
+ memcpy(addrbuf, addr, len);
+ addrbuf[len] = '\0';
+
+ if (addr[0] == '#') { /* numeric id */
+ char *cp;
+ errno = 0;
+ *id = strtol(addrbuf + 1, &cp, 0);
+ if ((errno == 0) && (cp != (addrbuf+1))) {
+ parsedOK = TRUE;
+ }
+ } else { /* non-numeric name */
+ if (lcPriv->credType == LOCAL_USER) {
+ struct passwd *pw = getpwnam(addrbuf);
+
+ if (pw != NULL) {
+ *id = (int) pw->pw_uid;
+ parsedOK = TRUE;
+ }
+ } else { /* group */
+ struct group *gr = getgrnam(addrbuf);
+
+ if (gr != NULL) {
+ *id = (int) gr->gr_gid;
+ parsedOK = TRUE;
+ }
+ }
+ }
+
+ free(addrbuf);
+ return parsedOK;
+}
+
+static Bool
+siLocalCredAddrMatch(int family, pointer addr, int len,
+ const char *siAddr, int siAddrlen, ClientPtr client, void *typePriv)
+{
+ int siAddrId;
+ LocalClientCredRec *lcc;
+ siLocalCredPrivPtr lcPriv = (siLocalCredPrivPtr) typePriv;
+
+ if (GetLocalClientCreds(client, &lcc) == -1) {
+ return FALSE;
+ }
+
+#ifdef HAVE_GETZONEID /* Ensure process is in the same zone */
+ if ((lcc->fieldsSet & LCC_ZID_SET) && (lcc->zoneid != getzoneid())) {
+ FreeLocalClientCreds(lcc);
+ return FALSE;
+ }
+#endif
+
+ if (siLocalCredGetId(siAddr, siAddrlen, lcPriv, &siAddrId) == FALSE) {
+ FreeLocalClientCreds(lcc);
+ return FALSE;
+ }
+
+ if (lcPriv->credType == LOCAL_USER) {
+ if ((lcc->fieldsSet & LCC_UID_SET) && (lcc->euid == siAddrId)) {
+ FreeLocalClientCreds(lcc);
+ return TRUE;
+ }
+ } else {
+ if ((lcc->fieldsSet & LCC_GID_SET) && (lcc->egid == siAddrId)) {
+ FreeLocalClientCreds(lcc);
+ return TRUE;
+ }
+ if (lcc->pSuppGids != NULL) {
+ int i;
+
+ for (i = 0 ; i < lcc->nSuppGids; i++) {
+ if (lcc->pSuppGids[i] == siAddrId) {
+ FreeLocalClientCreds(lcc);
+ return TRUE;
+ }
+ }
+ }
+ }
+ FreeLocalClientCreds(lcc);
+ return FALSE;
+}
+
+static int
+siLocalCredCheckAddr(const char *addrString, int length, void *typePriv)
+{
+ int len = length;
+ int id;
+
+ if (siLocalCredGetId(addrString, length,
+ (siLocalCredPrivPtr)typePriv, &id) == FALSE) {
+ len = -1;
+ }
+ return len;
+}
+#endif /* localuser */
+
+static void
+siTypesInitialize(void)
+{
+ siTypeAdd("hostname", siHostnameAddrMatch, siHostnameCheckAddr, NULL);
+#if defined(IPv6) && defined(AF_INET6)
+ siTypeAdd("ipv6", siIPv6AddrMatch, siIPv6CheckAddr, NULL);
+#endif
+#if !defined(NO_LOCAL_CLIENT_CRED)
+ siTypeAdd("localuser", siLocalCredAddrMatch, siLocalCredCheckAddr,
+ &siLocalUserPriv);
+ siTypeAdd("localgroup", siLocalCredAddrMatch, siLocalCredCheckAddr,
+ &siLocalGroupPriv);
+#endif
+}
diff --git a/xorg-server/os/osinit.c b/xorg-server/os/osinit.c
index 6ecf0821c..f27a5b8f3 100644
--- a/xorg-server/os/osinit.c
+++ b/xorg-server/os/osinit.c
@@ -1,321 +1,318 @@
-/***********************************************************
-
-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.
-
-******************************************************************/
-
-#ifdef HAVE_DIX_CONFIG_H
-#include <dix-config.h>
-#endif
-
-#include <stdio.h>
-#include <X11/X.h>
-#include "os.h"
-#include "osdep.h"
-#include <X11/Xos.h>
-#include <signal.h>
-#include <errno.h>
-#ifdef HAVE_DLFCN_H
-# include <dlfcn.h>
-#endif
-#ifdef HAVE_BACKTRACE
-#include <execinfo.h>
-#endif
-
-
-#include "dixstruct.h"
-
-#ifndef PATH_MAX
-#ifdef MAXPATHLEN
-#define PATH_MAX MAXPATHLEN
-#else
-#define PATH_MAX 1024
-#endif
-#endif
-
-#if defined(__SCO__)
-#include <sys/wait.h>
-#endif
-
-#if !defined(SYSV) && !defined(WIN32)
-#include <sys/resource.h>
-#endif
-
-#ifndef ADMPATH
-#define ADMPATH "/usr/adm/X%smsgs"
-#endif
-
-extern char *display;
-#ifdef RLIMIT_DATA
-int limitDataSpace = -1;
-#endif
-#ifdef RLIMIT_STACK
-int limitStackSpace = -1;
-#endif
-#ifdef RLIMIT_NOFILE
-int limitNoFile = -1;
-#endif
-
-static OsSigWrapperPtr OsSigWrapper = NULL;
-
-OsSigWrapperPtr
-OsRegisterSigWrapper(OsSigWrapperPtr newSigWrapper)
-{
- OsSigWrapperPtr oldSigWrapper = OsSigWrapper;
-
- OsSigWrapper = newSigWrapper;
-
- return oldSigWrapper;
-}
-
-/*
- * OsSigHandler --
- * Catch unexpected signals and exit or continue cleanly.
- */
-static void
-#ifdef SA_SIGINFO
-OsSigHandler(int signo, siginfo_t *sip, void *unused)
-#else
-OsSigHandler(int signo)
-#endif
-{
-#ifdef RTLD_DI_SETSIGNAL
- const char *dlerr = dlerror();
-
- if (dlerr) {
- LogMessage(X_ERROR, "Dynamic loader error: %s\n", dlerr);
- }
-#endif /* RTLD_DI_SETSIGNAL */
-
- if (OsSigWrapper != NULL) {
- if (OsSigWrapper(signo) == 0) {
- /* ddx handled signal and wants us to continue */
- return;
- }
- }
-
- /* log, cleanup, and abort */
- xorg_backtrace();
-
-#ifdef SA_SIGINFO
- if (sip->si_code == SI_USER) {
- ErrorF("Recieved signal %d sent by process %ld, uid %ld\n",
- signo, (long) sip->si_pid, (long) sip->si_uid);
- } else {
- switch (signo) {
- case SIGSEGV:
- case SIGBUS:
- case SIGILL:
- case SIGFPE:
- ErrorF("%s at address %p\n", strsignal(signo), sip->si_addr);
- }
- }
-#endif
-
- FatalError("Caught signal %d (%s). Server aborting\n",
- signo, strsignal(signo));
-}
-
-void
-OsInit(void)
-{
- static Bool been_here = FALSE;
- static char* devnull = "/dev/null";
- char fname[PATH_MAX];
-
- if (!been_here) {
-#ifndef _MSC_VER
- struct sigaction act, oact;
- int i;
- int siglist[] = { SIGSEGV, SIGQUIT, SIGILL, SIGFPE, SIGBUS,
- SIGSYS,
- SIGXCPU,
- SIGXFSZ,
-#ifdef SIGEMT
- SIGEMT,
-#endif
- 0 /* must be last */ };
- sigemptyset(&act.sa_mask);
-#ifdef SA_SIGINFO
- act.sa_sigaction = OsSigHandler;
- act.sa_flags = SA_SIGINFO;
-#else
- act.sa_handler = OsSigHandler;
- act.sa_flags = 0;
-#endif
- for (i = 0; siglist[i] != 0; i++) {
- if (sigaction(siglist[i], &act, &oact)) {
- ErrorF("failed to install signal handler for signal %d: %s\n",
- siglist[i], strerror(errno));
- }
- }
-#ifdef HAVE_BACKTRACE
- /*
- * initialize the backtracer, since the ctor calls dlopen(), which
- * calls malloc(), which isn't signal-safe.
- */
- do {
- void *array;
- backtrace(&array, 1);
- } while (0);
-#endif
-
-#ifdef RTLD_DI_SETSIGNAL
- /* Tell runtime linker to send a signal we can catch instead of SIGKILL
- * for failures to load libraries/modules at runtime so we can clean up
- * after ourselves.
- */
- int failure_signal = SIGQUIT;
- dlinfo(RTLD_SELF, RTLD_DI_SETSIGNAL, &failure_signal);
-#endif
-#endif
-#if !defined(__SCO__) && !defined(__CYGWIN__) && !defined(__UNIXWARE__)
- fclose(stdin);
- fclose(stdout);
-#endif
- /*
- * If a write of zero bytes to stderr returns non-zero, i.e. -1,
- * then writing to stderr failed, and we'll write somewhere else
- * instead. (Apparently this never happens in the Real World.)
- */
- if (write (2, fname, 0) == -1)
- {
- FILE *err;
-
- if (strlen (display) + strlen (ADMPATH) + 1 < sizeof fname)
- sprintf (fname, ADMPATH, display);
- else
- strcpy (fname, devnull);
- /*
- * uses stdio to avoid os dependencies here,
- * a real os would use
- * open (fname, O_WRONLY|O_APPEND|O_CREAT, 0666)
- */
- if (!(err = fopen (fname, "a+")))
- err = fopen (devnull, "w");
- if (err && (fileno(err) != 2)) {
- dup2 (fileno (err), 2);
- fclose (err);
- }
-#if defined(SYSV) || defined(SVR4) || defined(WIN32) || defined(__CYGWIN__)
- {
- static char buf[BUFSIZ];
- setvbuf (stderr, buf, _IOLBF, BUFSIZ);
- }
-#else
- setlinebuf(stderr);
-#endif
- }
-
-#ifndef _MSC_VER
- if (getpgrp () == 0)
- setpgid (0, 0);
-#endif
-
-#ifdef RLIMIT_DATA
- if (limitDataSpace >= 0)
- {
- struct rlimit rlim;
-
- if (!getrlimit(RLIMIT_DATA, &rlim))
- {
- if ((limitDataSpace > 0) && (limitDataSpace < rlim.rlim_max))
- rlim.rlim_cur = limitDataSpace;
- else
- rlim.rlim_cur = rlim.rlim_max;
- (void)setrlimit(RLIMIT_DATA, &rlim);
- }
- }
-#endif
-#ifdef RLIMIT_STACK
- if (limitStackSpace >= 0)
- {
- struct rlimit rlim;
-
- if (!getrlimit(RLIMIT_STACK, &rlim))
- {
- if ((limitStackSpace > 0) && (limitStackSpace < rlim.rlim_max))
- rlim.rlim_cur = limitStackSpace;
- else
- rlim.rlim_cur = rlim.rlim_max;
- (void)setrlimit(RLIMIT_STACK, &rlim);
- }
- }
-#endif
-#ifdef RLIMIT_NOFILE
- if (limitNoFile >= 0)
- {
- struct rlimit rlim;
-
- if (!getrlimit(RLIMIT_NOFILE, &rlim))
- {
- if ((limitNoFile > 0) && (limitNoFile < rlim.rlim_max))
- rlim.rlim_cur = limitNoFile;
- else
- rlim.rlim_cur = rlim.rlim_max;
- (void)setrlimit(RLIMIT_NOFILE, &rlim);
- }
- }
-#endif
- LockServer();
- been_here = TRUE;
- }
- TimerInit();
- OsVendorInit();
- /*
- * No log file by default. OsVendorInit() should call LogInit() with the
- * log file name if logging to a file is desired.
- */
- LogInit(NULL, NULL);
- SmartScheduleInit ();
-}
-
-void
-OsCleanup(Bool terminating)
-{
- if (terminating)
- {
- UnlockServer();
- }
-}
+/***********************************************************
+
+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.
+
+******************************************************************/
+
+#ifdef HAVE_DIX_CONFIG_H
+#include <dix-config.h>
+#endif
+
+#include <stdio.h>
+#include <X11/X.h>
+#include "os.h"
+#include "osdep.h"
+#include <X11/Xos.h>
+#include <signal.h>
+#include <errno.h>
+#ifdef HAVE_DLFCN_H
+# include <dlfcn.h>
+#endif
+#ifdef HAVE_BACKTRACE
+#include <execinfo.h>
+#endif
+
+
+#include "dixstruct.h"
+
+#ifndef PATH_MAX
+#ifdef MAXPATHLEN
+#define PATH_MAX MAXPATHLEN
+#else
+#define PATH_MAX 1024
+#endif
+#endif
+
+
+#if !defined(SYSV) && !defined(WIN32)
+#include <sys/resource.h>
+#endif
+
+#ifndef ADMPATH
+#define ADMPATH "/usr/adm/X%smsgs"
+#endif
+
+extern char *display;
+#ifdef RLIMIT_DATA
+int limitDataSpace = -1;
+#endif
+#ifdef RLIMIT_STACK
+int limitStackSpace = -1;
+#endif
+#ifdef RLIMIT_NOFILE
+int limitNoFile = -1;
+#endif
+
+static OsSigWrapperPtr OsSigWrapper = NULL;
+
+OsSigWrapperPtr
+OsRegisterSigWrapper(OsSigWrapperPtr newSigWrapper)
+{
+ OsSigWrapperPtr oldSigWrapper = OsSigWrapper;
+
+ OsSigWrapper = newSigWrapper;
+
+ return oldSigWrapper;
+}
+
+/*
+ * OsSigHandler --
+ * Catch unexpected signals and exit or continue cleanly.
+ */
+static void
+#ifdef SA_SIGINFO
+OsSigHandler(int signo, siginfo_t *sip, void *unused)
+#else
+OsSigHandler(int signo)
+#endif
+{
+#ifdef RTLD_DI_SETSIGNAL
+ const char *dlerr = dlerror();
+
+ if (dlerr) {
+ LogMessage(X_ERROR, "Dynamic loader error: %s\n", dlerr);
+ }
+#endif /* RTLD_DI_SETSIGNAL */
+
+ if (OsSigWrapper != NULL) {
+ if (OsSigWrapper(signo) == 0) {
+ /* ddx handled signal and wants us to continue */
+ return;
+ }
+ }
+
+ /* log, cleanup, and abort */
+ xorg_backtrace();
+
+#ifdef SA_SIGINFO
+ if (sip->si_code == SI_USER) {
+ ErrorF("Recieved signal %d sent by process %ld, uid %ld\n",
+ signo, (long) sip->si_pid, (long) sip->si_uid);
+ } else {
+ switch (signo) {
+ case SIGSEGV:
+ case SIGBUS:
+ case SIGILL:
+ case SIGFPE:
+ ErrorF("%s at address %p\n", strsignal(signo), sip->si_addr);
+ }
+ }
+#endif
+
+ FatalError("Caught signal %d (%s). Server aborting\n",
+ signo, strsignal(signo));
+}
+
+void
+OsInit(void)
+{
+ static Bool been_here = FALSE;
+ static char* devnull = "/dev/null";
+ char fname[PATH_MAX];
+
+ if (!been_here) {
+#ifndef _MSC_VER
+ struct sigaction act, oact;
+ int i;
+ int siglist[] = { SIGSEGV, SIGQUIT, SIGILL, SIGFPE, SIGBUS,
+ SIGSYS,
+ SIGXCPU,
+ SIGXFSZ,
+#ifdef SIGEMT
+ SIGEMT,
+#endif
+ 0 /* must be last */ };
+ sigemptyset(&act.sa_mask);
+#ifdef SA_SIGINFO
+ act.sa_sigaction = OsSigHandler;
+ act.sa_flags = SA_SIGINFO;
+#else
+ act.sa_handler = OsSigHandler;
+ act.sa_flags = 0;
+#endif
+ for (i = 0; siglist[i] != 0; i++) {
+ if (sigaction(siglist[i], &act, &oact)) {
+ ErrorF("failed to install signal handler for signal %d: %s\n",
+ siglist[i], strerror(errno));
+ }
+ }
+#ifdef HAVE_BACKTRACE
+ /*
+ * initialize the backtracer, since the ctor calls dlopen(), which
+ * calls malloc(), which isn't signal-safe.
+ */
+ do {
+ void *array;
+ backtrace(&array, 1);
+ } while (0);
+#endif
+
+#ifdef RTLD_DI_SETSIGNAL
+ /* Tell runtime linker to send a signal we can catch instead of SIGKILL
+ * for failures to load libraries/modules at runtime so we can clean up
+ * after ourselves.
+ */
+ int failure_signal = SIGQUIT;
+ dlinfo(RTLD_SELF, RTLD_DI_SETSIGNAL, &failure_signal);
+#endif
+#endif
+#if !defined(__CYGWIN__)
+ fclose(stdin);
+ fclose(stdout);
+#endif
+ /*
+ * If a write of zero bytes to stderr returns non-zero, i.e. -1,
+ * then writing to stderr failed, and we'll write somewhere else
+ * instead. (Apparently this never happens in the Real World.)
+ */
+ if (write (2, fname, 0) == -1)
+ {
+ FILE *err;
+
+ if (strlen (display) + strlen (ADMPATH) + 1 < sizeof fname)
+ sprintf (fname, ADMPATH, display);
+ else
+ strcpy (fname, devnull);
+ /*
+ * uses stdio to avoid os dependencies here,
+ * a real os would use
+ * open (fname, O_WRONLY|O_APPEND|O_CREAT, 0666)
+ */
+ if (!(err = fopen (fname, "a+")))
+ err = fopen (devnull, "w");
+ if (err && (fileno(err) != 2)) {
+ dup2 (fileno (err), 2);
+ fclose (err);
+ }
+#if defined(SYSV) || defined(SVR4) || defined(WIN32) || defined(__CYGWIN__)
+ {
+ static char buf[BUFSIZ];
+ setvbuf (stderr, buf, _IOLBF, BUFSIZ);
+ }
+#else
+ setlinebuf(stderr);
+#endif
+ }
+
+#ifndef _MSC_VER
+ if (getpgrp () == 0)
+ setpgid (0, 0);
+#endif
+
+#ifdef RLIMIT_DATA
+ if (limitDataSpace >= 0)
+ {
+ struct rlimit rlim;
+
+ if (!getrlimit(RLIMIT_DATA, &rlim))
+ {
+ if ((limitDataSpace > 0) && (limitDataSpace < rlim.rlim_max))
+ rlim.rlim_cur = limitDataSpace;
+ else
+ rlim.rlim_cur = rlim.rlim_max;
+ (void)setrlimit(RLIMIT_DATA, &rlim);
+ }
+ }
+#endif
+#ifdef RLIMIT_STACK
+ if (limitStackSpace >= 0)
+ {
+ struct rlimit rlim;
+
+ if (!getrlimit(RLIMIT_STACK, &rlim))
+ {
+ if ((limitStackSpace > 0) && (limitStackSpace < rlim.rlim_max))
+ rlim.rlim_cur = limitStackSpace;
+ else
+ rlim.rlim_cur = rlim.rlim_max;
+ (void)setrlimit(RLIMIT_STACK, &rlim);
+ }
+ }
+#endif
+#ifdef RLIMIT_NOFILE
+ if (limitNoFile >= 0)
+ {
+ struct rlimit rlim;
+
+ if (!getrlimit(RLIMIT_NOFILE, &rlim))
+ {
+ if ((limitNoFile > 0) && (limitNoFile < rlim.rlim_max))
+ rlim.rlim_cur = limitNoFile;
+ else
+ rlim.rlim_cur = rlim.rlim_max;
+ (void)setrlimit(RLIMIT_NOFILE, &rlim);
+ }
+ }
+#endif
+ LockServer();
+ been_here = TRUE;
+ }
+ TimerInit();
+ OsVendorInit();
+ /*
+ * No log file by default. OsVendorInit() should call LogInit() with the
+ * log file name if logging to a file is desired.
+ */
+ LogInit(NULL, NULL);
+ SmartScheduleInit ();
+}
+
+void
+OsCleanup(Bool terminating)
+{
+ if (terminating)
+ {
+ UnlockServer();
+ }
+}
diff --git a/xorg-server/os/xprintf.c b/xorg-server/os/xprintf.c
index ed2fa3d3b..cc5a9b355 100644
--- a/xorg-server/os/xprintf.c
+++ b/xorg-server/os/xprintf.c
@@ -1,233 +1,233 @@
-/**
- * @file
- *
- * @section DESCRIPTION
- *
- * These functions provide a portable implementation of the common (but not
- * yet universal) asprintf & vasprintf routines to allocate a buffer big
- * enough to sprintf the arguments to. The XNF variants terminate the server
- * if the allocation fails.
- */
-/*
- * Copyright (c) 2004 Alexander Gottwald
- *
- * 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 ABOVE LISTED COPYRIGHT HOLDER(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(s) of the above copyright
- * holders shall not be used in advertising or otherwise to promote the sale,
- * use or other dealings in this Software without prior written authorization.
- */
-/*
- * Copyright (c) 2010, 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.
- */
-
-#ifdef HAVE_DIX_CONFIG_H
-#include <dix-config.h>
-#endif
-
-#include <X11/Xos.h>
-#include "os.h"
-#include <stdarg.h>
-#include <stdio.h>
-
-#ifdef asprintf
-# undef asprintf
-#endif
-#ifdef vasprintf
-# undef vasprintf
-#endif
-
-#ifndef va_copy
-# ifdef __va_copy
-# define va_copy __va_copy
-# else
-# ifndef _MSC_VER
-# error "no working va_copy was found"
-# endif
-# endif
-#endif
-
-/**
- * Varargs sprintf that allocates a string buffer the right size for
- * the pattern & data provided and prints the requested data to it.
- *
- * @param ret Pointer to which the newly allocated buffer is written
- * (contents undefined on error)
- * @param format printf style format string
- * @param va variable argument list
- * @return size of allocated buffer, or -1 on error.
- */
-int
-Xvasprintf(char **ret, const char * _X_RESTRICT_KYWD format, va_list va)
-{
-#ifdef HAVE_VASPRINTF
- return vasprintf(ret, format, va);
-#else
- int size;
-
-#ifdef _MSC_VER
- size = vsnprintf(NULL, 0, format, va);
-#else
- va_list va2;
-
- va_copy(va2, va);
- size = vsnprintf(NULL, 0, format, va2);
- va_end(va2);
-#endif
-
- *ret = malloc(size + 1);
- if (*ret == NULL)
- return -1;
-
- vsnprintf(*ret, size + 1, format, va);
- (*ret)[size] = 0;
- return size;
-#endif
-}
-
-#ifndef HAVE_VASPRINTF
-# define vasprintf Xvasprintf
-#endif
-
-/**
- * sprintf that allocates a string buffer the right size for
- * the pattern & data provided and prints the requested data to it.
- *
- * @param ret Pointer to which the newly allocated buffer is written
- * (contents undefined on error)
- * @param format printf style format string
- * @param ... arguments for specified format
- * @return size of allocated buffer, or -1 on error.
- */
-int
-Xasprintf(char ** ret, const char * _X_RESTRICT_KYWD format, ...)
-{
- int size;
- va_list va;
- va_start(va, format);
- size = vasprintf(ret, format, va);
- va_end(va);
- return size;
-}
-
-/**
- * Varargs sprintf that allocates a string buffer the right size for
- * the pattern & data provided and prints the requested data to it.
- * On failure, issues a FatalError message and aborts the server.
- *
- * @param ret Pointer to which the newly allocated buffer is written
- * (contents undefined on error)
- * @param format printf style format string
- * @param va variable argument list
- * @return size of allocated buffer
- */
-int
-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");
- }
- return size;
-}
-
-/**
- * sprintf that allocates a string buffer the right size for
- * the pattern & data provided and prints the requested data to it.
- * On failure, issues a FatalError message and aborts the server.
- *
- * @param ret Pointer to which the newly allocated buffer is written
- * (contents undefined on error)
- * @param format printf style format string
- * @param ... arguments for specified format
- * @return size of allocated buffer
- */
-int
-XNFasprintf(char ** ret, const char * _X_RESTRICT_KYWD format, ...)
-{
- int size;
- va_list va;
- va_start(va, format);
- size = XNFvasprintf(ret, format, va);
- va_end(va);
- return size;
-}
-
-/* Old api, now deprecated, may be removed in the future */
-char *
-Xvprintf(const char *format, va_list va)
-{
- char *ret;
-
- if (vasprintf(&ret, format, va) == -1)
- ret = NULL;
-
- return ret;
-}
-
-char *Xprintf(const char *format, ...)
-{
- char *ret;
- va_list va;
- va_start(va, format);
- if (vasprintf(&ret, format, va) == -1)
- ret = NULL;
- va_end(va);
- return ret;
-}
-
-char *
-XNFvprintf(const char *format, va_list va)
-{
- char *ret;
-
- XNFvasprintf(&ret, format, va);
-
- return ret;
-}
-
-char *XNFprintf(const char *format, ...)
-{
- char *ret;
- va_list va;
- va_start(va, format);
- XNFvasprintf(&ret, format, va);
- va_end(va);
- return ret;
-}
+/**
+ * @file
+ *
+ * @section DESCRIPTION
+ *
+ * These functions provide a portable implementation of the common (but not
+ * yet universal) asprintf & vasprintf routines to allocate a buffer big
+ * enough to sprintf the arguments to. The XNF variants terminate the server
+ * if the allocation fails.
+ */
+/*
+ * Copyright (c) 2004 Alexander Gottwald
+ *
+ * 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 ABOVE LISTED COPYRIGHT HOLDER(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(s) of the above copyright
+ * holders shall not be used in advertising or otherwise to promote the sale,
+ * use or other dealings in this Software without prior written authorization.
+ */
+/*
+ * Copyright (c) 2010, 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.
+ */
+
+#ifdef HAVE_DIX_CONFIG_H
+#include <dix-config.h>
+#endif
+
+#include <X11/Xos.h>
+#include "os.h"
+#include <stdarg.h>
+#include <stdio.h>
+
+#ifdef asprintf
+# undef asprintf
+#endif
+#ifdef vasprintf
+# undef vasprintf
+#endif
+
+#ifndef va_copy
+# ifdef __va_copy
+# define va_copy __va_copy
+# else
+# ifndef _MSC_VER
+# error "no working va_copy was found"
+# endif
+# endif
+#endif
+
+/**
+ * Varargs sprintf that allocates a string buffer the right size for
+ * the pattern & data provided and prints the requested data to it.
+ *
+ * @param ret Pointer to which the newly allocated buffer is written
+ * (contents undefined on error)
+ * @param format printf style format string
+ * @param va variable argument list
+ * @return size of allocated buffer, or -1 on error.
+ */
+int
+Xvasprintf(char **ret, const char * _X_RESTRICT_KYWD format, va_list va)
+{
+#ifdef HAVE_VASPRINTF
+ return vasprintf(ret, format, va);
+#else
+ int size;
+
+#ifdef _MSC_VER
+ size = vsnprintf(NULL, 0, format, va);
+#else
+ va_list va2;
+
+ va_copy(va2, va);
+ size = vsnprintf(NULL, 0, format, va2);
+ va_end(va2);
+#endif
+
+ *ret = malloc(size + 1);
+ if (*ret == NULL)
+ return -1;
+
+ vsnprintf(*ret, size + 1, format, va);
+ (*ret)[size] = 0;
+ return size;
+#endif
+}
+
+#ifndef HAVE_VASPRINTF
+# define vasprintf Xvasprintf
+#endif
+
+/**
+ * sprintf that allocates a string buffer the right size for
+ * the pattern & data provided and prints the requested data to it.
+ *
+ * @param ret Pointer to which the newly allocated buffer is written
+ * (contents undefined on error)
+ * @param format printf style format string
+ * @param ... arguments for specified format
+ * @return size of allocated buffer, or -1 on error.
+ */
+int
+Xasprintf(char ** ret, const char * _X_RESTRICT_KYWD format, ...)
+{
+ int size;
+ va_list va;
+ va_start(va, format);
+ size = vasprintf(ret, format, va);
+ va_end(va);
+ return size;
+}
+
+/**
+ * Varargs sprintf that allocates a string buffer the right size for
+ * the pattern & data provided and prints the requested data to it.
+ * On failure, issues a FatalError message and aborts the server.
+ *
+ * @param ret Pointer to which the newly allocated buffer is written
+ * (contents undefined on error)
+ * @param format printf style format string
+ * @param va variable argument list
+ * @return size of allocated buffer
+ */
+int
+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");
+ }
+ return size;
+}
+
+/**
+ * sprintf that allocates a string buffer the right size for
+ * the pattern & data provided and prints the requested data to it.
+ * On failure, issues a FatalError message and aborts the server.
+ *
+ * @param ret Pointer to which the newly allocated buffer is written
+ * (contents undefined on error)
+ * @param format printf style format string
+ * @param ... arguments for specified format
+ * @return size of allocated buffer
+ */
+int
+XNFasprintf(char ** ret, const char * _X_RESTRICT_KYWD format, ...)
+{
+ int size;
+ va_list va;
+ va_start(va, format);
+ size = XNFvasprintf(ret, format, va);
+ va_end(va);
+ return size;
+}
+
+/* Old api, now deprecated, may be removed in the future */
+char *
+Xvprintf(const char *format, va_list va)
+{
+ char *ret;
+
+ if (vasprintf(&ret, format, va) == -1)
+ ret = NULL;
+
+ return ret;
+}
+
+char *Xprintf(const char *format, ...)
+{
+ char *ret;
+ va_list va;
+ va_start(va, format);
+ if (vasprintf(&ret, format, va) == -1)
+ ret = NULL;
+ va_end(va);
+ return ret;
+}
+
+char *
+XNFvprintf(const char *format, va_list va)
+{
+ char *ret;
+
+ XNFvasprintf(&ret, format, va);
+
+ return ret;
+}
+
+char *XNFprintf(const char *format, ...)
+{
+ char *ret;
+ va_list va;
+ va_start(va, format);
+ XNFvasprintf(&ret, format, va);
+ va_end(va);
+ return ret;
+}
diff --git a/xorg-server/randr/rrscreen.c b/xorg-server/randr/rrscreen.c
index 996ca3234..973991e20 100644
--- a/xorg-server/randr/rrscreen.c
+++ b/xorg-server/randr/rrscreen.c
@@ -1,1030 +1,1042 @@
-/*
- * Copyright © 2006 Keith Packard
- *
- * 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 the copyright holders not be used in advertising or
- * publicity pertaining to distribution of the software without specific,
- * written prior permission. The copyright holders make no representations
- * about the suitability of this software for any purpose. It is provided "as
- * is" without express or implied warranty.
- *
- * THE COPYRIGHT HOLDERS DISCLAIM ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
- * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
- * EVENT SHALL THE COPYRIGHT HOLDERS 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.
- */
-
-#include "randrstr.h"
-
-static const int padlength[4] = {0, 3, 2, 1};
-/* From render.h */
-#ifndef SubPixelUnknown
-#define SubPixelUnknown 0
-#endif
-
-
-static CARD16
-RR10CurrentSizeID (ScreenPtr pScreen);
-
-/*
- * Edit connection information block so that new clients
- * see the current screen size on connect
- */
-static void
-RREditConnectionInfo (ScreenPtr pScreen)
-{
- xConnSetup *connSetup;
- char *vendor;
- xPixmapFormat *formats;
- xWindowRoot *root;
- xDepth *depth;
- xVisualType *visual;
- int screen = 0;
- int d;
-
- connSetup = (xConnSetup *) ConnectionInfo;
- vendor = (char *) connSetup + sizeof (xConnSetup);
- formats = (xPixmapFormat *) ((char *) vendor +
- connSetup->nbytesVendor +
- padlength[connSetup->nbytesVendor & 3]);
- root = (xWindowRoot *) ((char *) formats +
- sizeof (xPixmapFormat) * screenInfo.numPixmapFormats);
- while (screen != pScreen->myNum)
- {
- depth = (xDepth *) ((char *) root +
- sizeof (xWindowRoot));
- for (d = 0; d < root->nDepths; d++)
- {
- visual = (xVisualType *) ((char *) depth +
- sizeof (xDepth));
- depth = (xDepth *) ((char *) visual +
- depth->nVisuals * sizeof (xVisualType));
- }
- root = (xWindowRoot *) ((char *) depth);
- screen++;
- }
- root->pixWidth = pScreen->width;
- root->pixHeight = pScreen->height;
- root->mmWidth = pScreen->mmWidth;
- root->mmHeight = pScreen->mmHeight;
-}
-
-void
-RRSendConfigNotify (ScreenPtr pScreen)
-{
- WindowPtr pWin = pScreen->root;
- xEvent event;
-
- event.u.u.type = ConfigureNotify;
- event.u.configureNotify.window = pWin->drawable.id;
- event.u.configureNotify.aboveSibling = None;
- event.u.configureNotify.x = 0;
- event.u.configureNotify.y = 0;
-
- /* XXX xinerama stuff ? */
-
- event.u.configureNotify.width = pWin->drawable.width;
- event.u.configureNotify.height = pWin->drawable.height;
- event.u.configureNotify.borderWidth = wBorderWidth (pWin);
- event.u.configureNotify.override = pWin->overrideRedirect;
- DeliverEvents(pWin, &event, 1, NullWindow);
-}
-
-void
-RRDeliverScreenEvent (ClientPtr client, WindowPtr pWin, ScreenPtr pScreen)
-{
- rrScrPriv (pScreen);
- xRRScreenChangeNotifyEvent se;
- RRCrtcPtr crtc = pScrPriv->numCrtcs ? pScrPriv->crtcs[0] : NULL;
- WindowPtr pRoot = pScreen->root;
-
- se.type = RRScreenChangeNotify + RREventBase;
- se.rotation = (CARD8) (crtc ? crtc->rotation : RR_Rotate_0);
- se.timestamp = pScrPriv->lastSetTime.milliseconds;
- se.configTimestamp = pScrPriv->lastConfigTime.milliseconds;
- se.root = pRoot->drawable.id;
- se.window = pWin->drawable.id;
- se.subpixelOrder = PictureGetSubpixelOrder (pScreen);
-
- se.sizeID = RR10CurrentSizeID (pScreen);
-
- if (se.rotation & (RR_Rotate_90 | RR_Rotate_270)) {
- se.widthInPixels = pScreen->height;
- se.heightInPixels = pScreen->width;
- se.widthInMillimeters = pScreen->mmHeight;
- se.heightInMillimeters = pScreen->mmWidth;
- } else {
- se.widthInPixels = pScreen->width;
- se.heightInPixels = pScreen->height;
- se.widthInMillimeters = pScreen->mmWidth;
- se.heightInMillimeters = pScreen->mmHeight;
- }
-
- WriteEventsToClient (client, 1, (xEvent *) &se);
-}
-
-/*
- * Notify the extension that the screen size has been changed.
- * The driver is responsible for calling this whenever it has changed
- * the size of the screen
- */
-void
-RRScreenSizeNotify (ScreenPtr pScreen)
-{
- rrScrPriv(pScreen);
- /*
- * Deliver ConfigureNotify events when root changes
- * pixel size
- */
- if (pScrPriv->width == pScreen->width &&
- pScrPriv->height == pScreen->height &&
- pScrPriv->mmWidth == pScreen->mmWidth &&
- pScrPriv->mmHeight == pScreen->mmHeight)
- return;
-
- pScrPriv->width = pScreen->width;
- pScrPriv->height = pScreen->height;
- pScrPriv->mmWidth = pScreen->mmWidth;
- pScrPriv->mmHeight = pScreen->mmHeight;
- pScrPriv->changed = TRUE;
-/* pScrPriv->sizeChanged = TRUE; */
-
- RRTellChanged (pScreen);
- RRSendConfigNotify (pScreen);
- RREditConnectionInfo (pScreen);
-
- RRPointerScreenConfigured (pScreen);
- /*
- * Fix pointer bounds and location
- */
- ScreenRestructured (pScreen);
-}
-
-/*
- * Request that the screen be resized
- */
-Bool
-RRScreenSizeSet (ScreenPtr pScreen,
- CARD16 width,
- CARD16 height,
- CARD16 pixWidth,
- CARD16 pixHeight,
- CARD32 mmWidth,
- CARD32 mmHeight)
-{
- rrScrPriv(pScreen);
-
-#if RANDR_12_INTERFACE
- if (pScrPriv->rrScreenSetSize)
- {
- return (*pScrPriv->rrScreenSetSize) (pScreen,
- width, height,
- pixWidth, pixHeight,
- mmWidth, mmHeight);
- }
-#endif
-#if RANDR_10_INTERFACE
- if (pScrPriv->rrSetConfig)
- {
- return TRUE; /* can't set size separately */
- }
-#endif
- return FALSE;
-}
-
-/*
- * Compute an RRScreenConfig from the current screen information
- */
-void
-RRScreenCurrentConfig(ScreenPtr screen,
- RRScreenConfigPtr screen_config)
-{
- PixmapPtr screen_pixmap = screen->GetScreenPixmap(screen);
- WindowPtr root = screen->root;
-
- screen_config->screen_pixmap_width = screen_pixmap->drawable.width;
- screen_config->screen_pixmap_height = screen_pixmap->drawable.height;
- screen_config->screen_width = root->drawable.width;
- screen_config->screen_height = root->drawable.height;
- screen_config->mm_width = screen->mmWidth;
- screen_config->mm_height = screen->mmHeight;
-}
-
-/*
- * Retrieve valid screen size range
- */
-int
-ProcRRGetScreenSizeRange (ClientPtr client)
-{
- REQUEST(xRRGetScreenSizeRangeReq);
- xRRGetScreenSizeRangeReply rep;
- WindowPtr pWin;
- ScreenPtr pScreen;
- rrScrPrivPtr pScrPriv;
- int rc;
-
- REQUEST_SIZE_MATCH(xRRGetScreenInfoReq);
- rc = dixLookupWindow(&pWin, stuff->window, client, DixGetAttrAccess);
- if (rc != Success)
- return rc;
-
- pScreen = pWin->drawable.pScreen;
- pScrPriv = rrGetScrPriv(pScreen);
-
- rep.type = X_Reply;
- rep.pad = 0;
- rep.sequenceNumber = client->sequence;
- rep.length = 0;
-
- if (pScrPriv)
- {
- if (!RRGetInfo (pScreen, FALSE))
- return BadAlloc;
- rep.minWidth = pScrPriv->minWidth;
- rep.minHeight = pScrPriv->minHeight;
- rep.maxWidth = pScrPriv->maxWidth;
- rep.maxHeight = pScrPriv->maxHeight;
- }
- else
- {
- rep.maxWidth = rep.minWidth = pScreen->width;
- rep.maxHeight = rep.minHeight = pScreen->height;
- }
- if (client->swapped)
- {
- int n;
-
- swaps(&rep.sequenceNumber, n);
- swapl(&rep.length, n);
- swaps(&rep.minWidth, n);
- swaps(&rep.minHeight, n);
- swaps(&rep.maxWidth, n);
- swaps(&rep.maxHeight, n);
- }
- WriteToClient(client, sizeof(xRRGetScreenSizeRangeReply), (char *)&rep);
- return Success;
-}
-
-int
-ProcRRSetScreenSize (ClientPtr client)
-{
- REQUEST(xRRSetScreenSizeReq);
- WindowPtr pWin;
- ScreenPtr pScreen;
- rrScrPrivPtr pScrPriv;
- int i, rc;
-
- REQUEST_SIZE_MATCH(xRRSetScreenSizeReq);
- rc = dixLookupWindow(&pWin, stuff->window, client, DixGetAttrAccess);
- if (rc != Success)
- return rc;
-
- pScreen = pWin->drawable.pScreen;
- pScrPriv = rrGetScrPriv(pScreen);
- if (stuff->width < pScrPriv->minWidth || pScrPriv->maxWidth < stuff->width)
- {
- client->errorValue = stuff->width;
- return BadValue;
- }
- if (stuff->height < pScrPriv->minHeight ||
- pScrPriv->maxHeight < stuff->height)
- {
- client->errorValue = stuff->height;
- return BadValue;
- }
- for (i = 0; i < pScrPriv->numCrtcs; i++)
- {
- RRCrtcPtr crtc = pScrPriv->crtcs[i];
- RRModePtr mode = crtc->mode;
- if (mode)
- {
- int source_width = mode->mode.width;
- int source_height = mode->mode.height;
- Rotation rotation = crtc->rotation;
-
- if (rotation == RR_Rotate_90 || rotation == RR_Rotate_270)
- {
- source_width = mode->mode.height;
- source_height = mode->mode.width;
- }
-
- if (crtc->x + source_width > stuff->width ||
- crtc->y + source_height > stuff->height)
- return BadMatch;
- }
- }
- if (stuff->widthInMillimeters == 0 || stuff->heightInMillimeters == 0)
- {
- client->errorValue = 0;
- return BadValue;
- }
- if (!RRScreenSizeSet (pScreen,
- stuff->width, stuff->height,
- stuff->width, stuff->height,
- stuff->widthInMillimeters,
- stuff->heightInMillimeters))
- {
- return BadMatch;
- }
- return Success;
-}
-
-static int
-rrGetScreenResources(ClientPtr client, Bool query)
-{
- REQUEST(xRRGetScreenResourcesReq);
- xRRGetScreenResourcesReply rep;
- WindowPtr pWin;
- ScreenPtr pScreen;
- rrScrPrivPtr pScrPriv;
- CARD8 *extra;
- unsigned long extraLen;
- int i, n, rc, has_primary = 0;
- RRCrtc *crtcs;
- RROutput *outputs;
- xRRModeInfo *modeinfos;
- CARD8 *names;
-
- REQUEST_SIZE_MATCH(xRRGetScreenResourcesReq);
- rc = dixLookupWindow(&pWin, stuff->window, client, DixGetAttrAccess);
- if (rc != Success)
- return rc;
-
- pScreen = pWin->drawable.pScreen;
- pScrPriv = rrGetScrPriv(pScreen);
- rep.pad = 0;
-
- if (query && pScrPriv)
- if (!RRGetInfo (pScreen, query))
- return BadAlloc;
-
- if (!pScrPriv)
- {
- rep.type = X_Reply;
- rep.sequenceNumber = client->sequence;
- rep.length = 0;
- rep.timestamp = currentTime.milliseconds;
- rep.configTimestamp = currentTime.milliseconds;
- rep.nCrtcs = 0;
- rep.nOutputs = 0;
- rep.nModes = 0;
- rep.nbytesNames = 0;
- extra = NULL;
- extraLen = 0;
- }
- else
- {
- RRModePtr *modes;
- int num_modes;
-
- modes = RRModesForScreen (pScreen, &num_modes);
- if (!modes)
- return BadAlloc;
-
- rep.type = X_Reply;
- rep.sequenceNumber = client->sequence;
- rep.length = 0;
- rep.timestamp = pScrPriv->lastSetTime.milliseconds;
- rep.configTimestamp = pScrPriv->lastConfigTime.milliseconds;
- rep.nCrtcs = pScrPriv->numCrtcs;
- rep.nOutputs = pScrPriv->numOutputs;
- rep.nModes = num_modes;
- rep.nbytesNames = 0;
-
- for (i = 0; i < num_modes; i++)
- rep.nbytesNames += modes[i]->mode.nameLength;
-
- rep.length = (pScrPriv->numCrtcs +
- pScrPriv->numOutputs +
- num_modes * bytes_to_int32(SIZEOF(xRRModeInfo)) +
- bytes_to_int32(rep.nbytesNames));
-
- extraLen = rep.length << 2;
- if (extraLen)
- {
- extra = malloc(extraLen);
- if (!extra)
- {
- free(modes);
- return BadAlloc;
- }
- }
- else
- extra = NULL;
-
- crtcs = (RRCrtc *) extra;
- outputs = (RROutput *) (crtcs + pScrPriv->numCrtcs);
- modeinfos = (xRRModeInfo *) (outputs + pScrPriv->numOutputs);
- names = (CARD8 *) (modeinfos + num_modes);
-
- if (pScrPriv->primaryOutput && pScrPriv->primaryOutput->crtc)
- {
- has_primary = 1;
- crtcs[0] = pScrPriv->primaryOutput->crtc->id;
- if (client->swapped)
- swapl (&crtcs[0], n);
- }
-
- for (i = 0; i < pScrPriv->numCrtcs; i++)
- {
- if (has_primary &&
- pScrPriv->primaryOutput->crtc == pScrPriv->crtcs[i])
- {
- has_primary = 0;
- continue;
- }
- crtcs[i + has_primary] = pScrPriv->crtcs[i]->id;
- if (client->swapped)
- swapl (&crtcs[i + has_primary], n);
- }
-
- for (i = 0; i < pScrPriv->numOutputs; i++)
- {
- outputs[i] = pScrPriv->outputs[i]->id;
- if (client->swapped)
- swapl (&outputs[i], n);
- }
-
- for (i = 0; i < num_modes; i++)
- {
- RRModePtr mode = modes[i];
- modeinfos[i] = mode->mode;
- if (client->swapped)
- {
- swapl (&modeinfos[i].id, n);
- swaps (&modeinfos[i].width, n);
- swaps (&modeinfos[i].height, n);
- swapl (&modeinfos[i].dotClock, n);
- swaps (&modeinfos[i].hSyncStart, n);
- swaps (&modeinfos[i].hSyncEnd, n);
- swaps (&modeinfos[i].hTotal, n);
- swaps (&modeinfos[i].hSkew, n);
- swaps (&modeinfos[i].vSyncStart, n);
- swaps (&modeinfos[i].vSyncEnd, n);
- swaps (&modeinfos[i].vTotal, n);
- swaps (&modeinfos[i].nameLength, n);
- swapl (&modeinfos[i].modeFlags, n);
- }
- memcpy (names, mode->name,
- mode->mode.nameLength);
- names += mode->mode.nameLength;
- }
- free(modes);
- assert (bytes_to_int32((char *) names - (char *) extra) == rep.length);
- }
-
- if (client->swapped) {
- swaps(&rep.sequenceNumber, n);
- swapl(&rep.length, n);
- swapl(&rep.timestamp, n);
- swapl(&rep.configTimestamp, n);
- swaps(&rep.nCrtcs, n);
- swaps(&rep.nOutputs, n);
- swaps(&rep.nModes, n);
- swaps(&rep.nbytesNames, n);
- }
- WriteToClient(client, sizeof(xRRGetScreenResourcesReply), (char *)&rep);
- if (extraLen)
- {
- WriteToClient (client, extraLen, (char *) extra);
- free(extra);
- }
- return Success;
-}
-
-int
-ProcRRGetScreenResources (ClientPtr client)
-{
- return rrGetScreenResources(client, TRUE);
-}
-
-int
-ProcRRGetScreenResourcesCurrent (ClientPtr client)
-{
- return rrGetScreenResources(client, FALSE);
-}
-
-typedef struct _RR10Data {
- RRScreenSizePtr sizes;
- int nsize;
- int nrefresh;
- int size;
- CARD16 refresh;
-} RR10DataRec, *RR10DataPtr;
-
-/*
- * Convert 1.2 monitor data into 1.0 screen data
- */
-static RR10DataPtr
-RR10GetData (ScreenPtr pScreen, RROutputPtr output)
-{
- RR10DataPtr data;
- RRScreenSizePtr size;
- int nmode = output->numModes + output->numUserModes;
- int o, os, l, r;
- RRScreenRatePtr refresh;
- CARD16 vRefresh;
- RRModePtr mode;
- Bool *used;
-
- /* Make sure there is plenty of space for any combination */
- data = malloc (sizeof (RR10DataRec) +
- sizeof (RRScreenSize) * nmode +
- sizeof (RRScreenRate) * nmode +
- sizeof (Bool) * nmode);
- if (!data)
- return NULL;
- size = (RRScreenSizePtr) (data + 1);
- refresh = (RRScreenRatePtr) (size + nmode);
- used = (Bool *) (refresh + nmode);
- memset (used, '\0', sizeof (Bool) * nmode);
- data->sizes = size;
- data->nsize = 0;
- data->nrefresh = 0;
- data->size = 0;
- data->refresh = 0;
-
- /*
- * find modes not yet listed
- */
- for (o = 0; o < output->numModes + output->numUserModes; o++)
- {
- if (used[o]) continue;
-
- if (o < output->numModes)
- mode = output->modes[o];
- else
- mode = output->userModes[o - output->numModes];
-
- l = data->nsize;
- size[l].id = data->nsize;
- size[l].width = mode->mode.width;
- size[l].height = mode->mode.height;
- if (output->mmWidth && output->mmHeight) {
- size[l].mmWidth = output->mmWidth;
- size[l].mmHeight = output->mmHeight;
- } else {
- size[l].mmWidth = pScreen->mmWidth;
- size[l].mmHeight = pScreen->mmHeight;
- }
- size[l].nRates = 0;
- size[l].pRates = &refresh[data->nrefresh];
- data->nsize++;
-
- /*
- * Find all modes with matching size
- */
- for (os = o; os < output->numModes + output->numUserModes; os++)
- {
- if (os < output->numModes)
- mode = output->modes[os];
- else
- mode = output->userModes[os - output->numModes];
- if (mode->mode.width == size[l].width &&
- mode->mode.height == size[l].height)
- {
- vRefresh = RRVerticalRefresh (&mode->mode);
- used[os] = TRUE;
-
- for (r = 0; r < size[l].nRates; r++)
- if (vRefresh == size[l].pRates[r].rate)
- break;
- if (r == size[l].nRates)
- {
- size[l].pRates[r].rate = vRefresh;
- size[l].pRates[r].mode = mode;
- size[l].nRates++;
- data->nrefresh++;
- }
- if (mode == output->crtc->mode)
- {
- data->size = l;
- data->refresh = vRefresh;
- }
- }
- }
- }
- return data;
-}
-
-int
-ProcRRGetScreenInfo (ClientPtr client)
-{
- REQUEST(xRRGetScreenInfoReq);
- xRRGetScreenInfoReply rep;
- WindowPtr pWin;
- int n, rc;
- ScreenPtr pScreen;
- rrScrPrivPtr pScrPriv;
- CARD8 *extra;
- unsigned long extraLen;
- RROutputPtr output;
-
- REQUEST_SIZE_MATCH(xRRGetScreenInfoReq);
- rc = dixLookupWindow(&pWin, stuff->window, client, DixGetAttrAccess);
- if (rc != Success)
- return rc;
-
- pScreen = pWin->drawable.pScreen;
- pScrPriv = rrGetScrPriv(pScreen);
- rep.pad = 0;
-
- if (pScrPriv)
- if (!RRGetInfo (pScreen, TRUE))
- return BadAlloc;
-
- output = RRFirstOutput (pScreen);
-
- if (!pScrPriv || !output)
- {
- rep.type = X_Reply;
- rep.setOfRotations = RR_Rotate_0;
- rep.sequenceNumber = client->sequence;
- rep.length = 0;
- rep.root = pWin->drawable.pScreen->root->drawable.id;
- rep.timestamp = currentTime.milliseconds;
- rep.configTimestamp = currentTime.milliseconds;
- rep.nSizes = 0;
- rep.sizeID = 0;
- rep.rotation = RR_Rotate_0;
- rep.rate = 0;
- rep.nrateEnts = 0;
- extra = 0;
- extraLen = 0;
- }
- else
- {
- int i, j;
- xScreenSizes *size;
- CARD16 *rates;
- CARD8 *data8;
- Bool has_rate = RRClientKnowsRates (client);
- RR10DataPtr pData;
- RRScreenSizePtr pSize;
-
- pData = RR10GetData (pScreen, output);
- if (!pData)
- return BadAlloc;
-
- rep.type = X_Reply;
- rep.setOfRotations = output->crtc->rotations;
- rep.sequenceNumber = client->sequence;
- rep.length = 0;
- rep.root = pWin->drawable.pScreen->root->drawable.id;
- rep.timestamp = pScrPriv->lastSetTime.milliseconds;
- rep.configTimestamp = pScrPriv->lastConfigTime.milliseconds;
- rep.rotation = output->crtc->rotation;
- rep.nSizes = pData->nsize;
- rep.nrateEnts = pData->nrefresh + pData->nsize;
- rep.sizeID = pData->size;
- rep.rate = pData->refresh;
-
- extraLen = rep.nSizes * sizeof (xScreenSizes);
- if (has_rate)
- extraLen += rep.nrateEnts * sizeof (CARD16);
-
- if (extraLen)
- {
- extra = (CARD8 *) malloc(extraLen);
- if (!extra)
- {
- free(pData);
- return BadAlloc;
- }
- }
- else
- extra = NULL;
-
- /*
- * First comes the size information
- */
- size = (xScreenSizes *) extra;
- rates = (CARD16 *) (size + rep.nSizes);
- for (i = 0; i < pData->nsize; i++)
- {
- pSize = &pData->sizes[i];
- size->widthInPixels = pSize->width;
- size->heightInPixels = pSize->height;
- size->widthInMillimeters = pSize->mmWidth;
- size->heightInMillimeters = pSize->mmHeight;
- if (client->swapped)
- {
- swaps (&size->widthInPixels, n);
- swaps (&size->heightInPixels, n);
- swaps (&size->widthInMillimeters, n);
- swaps (&size->heightInMillimeters, n);
- }
- size++;
- if (has_rate)
- {
- *rates = pSize->nRates;
- if (client->swapped)
- {
- swaps (rates, n);
- }
- rates++;
- for (j = 0; j < pSize->nRates; j++)
- {
- *rates = pSize->pRates[j].rate;
- if (client->swapped)
- {
- swaps (rates, n);
- }
- rates++;
- }
- }
- }
- free(pData);
-
- data8 = (CARD8 *) rates;
-
- if (data8 - (CARD8 *) extra != extraLen)
- FatalError ("RRGetScreenInfo bad extra len %ld != %ld\n",
- (unsigned long)(data8 - (CARD8 *) extra), extraLen);
- rep.length = bytes_to_int32(extraLen);
- }
- if (client->swapped) {
- swaps(&rep.sequenceNumber, n);
- swapl(&rep.length, n);
- swapl(&rep.timestamp, n);
- swaps(&rep.rotation, n);
- swaps(&rep.nSizes, n);
- swaps(&rep.sizeID, n);
- swaps(&rep.rate, n);
- swaps(&rep.nrateEnts, n);
- }
- WriteToClient(client, sizeof(xRRGetScreenInfoReply), (char *)&rep);
- if (extraLen)
- {
- WriteToClient (client, extraLen, (char *) extra);
- free(extra);
- }
- return Success;
-}
-
-int
-ProcRRSetScreenConfig (ClientPtr client)
-{
- REQUEST(xRRSetScreenConfigReq);
- xRRSetScreenConfigReply rep;
- DrawablePtr pDraw;
- int n, rc;
- ScreenPtr pScreen;
- rrScrPrivPtr pScrPriv;
- TimeStamp time;
- int i;
- Rotation rotation;
- int rate;
- Bool has_rate;
- RROutputPtr output;
- RRCrtcPtr crtc;
- RRModePtr mode;
- RR10DataPtr pData = NULL;
- RRScreenSizePtr pSize;
- int width, height;
-
- UpdateCurrentTime ();
-
- if (RRClientKnowsRates (client))
- {
- REQUEST_SIZE_MATCH (xRRSetScreenConfigReq);
- has_rate = TRUE;
- }
- else
- {
- REQUEST_SIZE_MATCH (xRR1_0SetScreenConfigReq);
- has_rate = FALSE;
- }
-
- rc = dixLookupDrawable(&pDraw, stuff->drawable, client, 0, DixWriteAccess);
- if (rc != Success) {
- client->errorValue = stuff->drawable;
- return rc;
- }
-
- pScreen = pDraw->pScreen;
-
- pScrPriv = rrGetScrPriv(pScreen);
-
- time = ClientTimeToServerTime(stuff->timestamp);
-
- if (!pScrPriv)
- {
- time = currentTime;
- rep.status = RRSetConfigFailed;
- goto sendReply;
- }
- if (!RRGetInfo (pScreen, FALSE))
- return BadAlloc;
-
- output = RRFirstOutput (pScreen);
- if (!output)
- {
- time = currentTime;
- rep.status = RRSetConfigFailed;
- goto sendReply;
- }
-
- crtc = output->crtc;
-
- /*
- * If the client's config timestamp is not the same as the last config
- * timestamp, then the config information isn't up-to-date and
- * can't even be validated.
- *
- * Note that the client only knows about the milliseconds part of the
- * timestamp, so using CompareTimeStamps here would cause randr to suddenly
- * stop working after several hours have passed (freedesktop bug #6502).
- */
- if (stuff->configTimestamp != pScrPriv->lastConfigTime.milliseconds)
- {
- rep.status = RRSetConfigInvalidConfigTime;
- goto sendReply;
- }
-
- pData = RR10GetData (pScreen, output);
- if (!pData)
- return BadAlloc;
-
- if (stuff->sizeID >= pData->nsize)
- {
- /*
- * Invalid size ID
- */
- client->errorValue = stuff->sizeID;
- free(pData);
- return BadValue;
- }
- pSize = &pData->sizes[stuff->sizeID];
-
- /*
- * Validate requested rotation
- */
- rotation = (Rotation) stuff->rotation;
-
- /* test the rotation bits only! */
- switch (rotation & 0xf) {
- case RR_Rotate_0:
- case RR_Rotate_90:
- case RR_Rotate_180:
- case RR_Rotate_270:
- break;
- default:
- /*
- * Invalid rotation
- */
- client->errorValue = stuff->rotation;
- free(pData);
- return BadValue;
- }
-
- if ((~crtc->rotations) & rotation)
- {
- /*
- * requested rotation or reflection not supported by screen
- */
- client->errorValue = stuff->rotation;
- free(pData);
- return BadMatch;
- }
-
- /*
- * Validate requested refresh
- */
- if (has_rate)
- rate = (int) stuff->rate;
- else
- rate = 0;
-
- if (rate)
- {
- for (i = 0; i < pSize->nRates; i++)
- {
- if (pSize->pRates[i].rate == rate)
- break;
- }
- if (i == pSize->nRates)
- {
- /*
- * Invalid rate
- */
- client->errorValue = rate;
- free(pData);
- return BadValue;
- }
- mode = pSize->pRates[i].mode;
- }
- else
- mode = pSize->pRates[0].mode;
-
- /*
- * Make sure the requested set-time is not older than
- * the last set-time
- */
- if (CompareTimeStamps (time, pScrPriv->lastSetTime) < 0)
- {
- rep.status = RRSetConfigInvalidTime;
- goto sendReply;
- }
-
- /*
- * If the screen size is changing, adjust all of the other outputs
- * to fit the new size, mirroring as much as possible
- */
- width = mode->mode.width;
- height = mode->mode.height;
- if (rotation & (RR_Rotate_90|RR_Rotate_270))
- {
- width = mode->mode.height;
- height = mode->mode.width;
- }
- if (width != pScreen->width || height != pScreen->height)
- {
- int c;
-
- for (c = 0; c < pScrPriv->numCrtcs; c++)
- {
- if (!RRCrtcSet (pScrPriv->crtcs[c], NULL, 0, 0, RR_Rotate_0,
- 0, NULL, NULL))
- {
- rep.status = RRSetConfigFailed;
- /* XXX recover from failure */
- goto sendReply;
- }
- }
- if (!RRScreenSizeSet (pScreen, width, height, width, height,
- pScreen->mmWidth, pScreen->mmHeight))
- {
- rep.status = RRSetConfigFailed;
- /* XXX recover from failure */
- goto sendReply;
- }
- }
-
- if (!RRCrtcSet (crtc, mode, 0, 0, stuff->rotation, 1, &output, NULL))
- rep.status = RRSetConfigFailed;
- else {
- pScrPriv->lastSetTime = time;
- rep.status = RRSetConfigSuccess;
- }
-
- /*
- * XXX Configure other crtcs to mirror as much as possible
- */
-
-sendReply:
-
- free(pData);
-
- rep.type = X_Reply;
- /* rep.status has already been filled in */
- rep.length = 0;
- rep.sequenceNumber = client->sequence;
-
- rep.newTimestamp = pScrPriv->lastSetTime.milliseconds;
- rep.newConfigTimestamp = pScrPriv->lastConfigTime.milliseconds;
- rep.root = pDraw->pScreen->root->drawable.id;
-
- if (client->swapped)
- {
- swaps(&rep.sequenceNumber, n);
- swapl(&rep.length, n);
- swapl(&rep.newTimestamp, n);
- swapl(&rep.newConfigTimestamp, n);
- swapl(&rep.root, n);
- }
- WriteToClient(client, sizeof(xRRSetScreenConfigReply), (char *)&rep);
-
- return Success;
-}
-
-static CARD16
-RR10CurrentSizeID (ScreenPtr pScreen)
-{
- CARD16 sizeID = 0xffff;
- RROutputPtr output = RRFirstOutput (pScreen);
-
- if (output)
- {
- RR10DataPtr data = RR10GetData (pScreen, output);
- if (data)
- {
- int i;
- for (i = 0; i < data->nsize; i++)
- if (data->sizes[i].width == pScreen->width &&
- data->sizes[i].height == pScreen->height)
- {
- sizeID = (CARD16) i;
- break;
- }
- free(data);
- }
- }
- return sizeID;
-}
+/*
+ * Copyright © 2006 Keith Packard
+ *
+ * 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 the copyright holders not be used in advertising or
+ * publicity pertaining to distribution of the software without specific,
+ * written prior permission. The copyright holders make no representations
+ * about the suitability of this software for any purpose. It is provided "as
+ * is" without express or implied warranty.
+ *
+ * THE COPYRIGHT HOLDERS DISCLAIM ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
+ * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
+ * EVENT SHALL THE COPYRIGHT HOLDERS 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.
+ */
+
+#include "randrstr.h"
+
+static const int padlength[4] = {0, 3, 2, 1};
+/* From render.h */
+#ifndef SubPixelUnknown
+#define SubPixelUnknown 0
+#endif
+
+
+static CARD16
+RR10CurrentSizeID (ScreenPtr pScreen);
+
+/*
+ * Edit connection information block so that new clients
+ * see the current screen size on connect
+ */
+static void
+RREditConnectionInfo (ScreenPtr pScreen)
+{
+ xConnSetup *connSetup;
+ char *vendor;
+ xPixmapFormat *formats;
+ xWindowRoot *root;
+ xDepth *depth;
+ xVisualType *visual;
+ int screen = 0;
+ int d;
+
+ connSetup = (xConnSetup *) ConnectionInfo;
+ vendor = (char *) connSetup + sizeof (xConnSetup);
+ formats = (xPixmapFormat *) ((char *) vendor +
+ connSetup->nbytesVendor +
+ padlength[connSetup->nbytesVendor & 3]);
+ root = (xWindowRoot *) ((char *) formats +
+ sizeof (xPixmapFormat) * screenInfo.numPixmapFormats);
+ while (screen != pScreen->myNum)
+ {
+ depth = (xDepth *) ((char *) root +
+ sizeof (xWindowRoot));
+ for (d = 0; d < root->nDepths; d++)
+ {
+ visual = (xVisualType *) ((char *) depth +
+ sizeof (xDepth));
+ depth = (xDepth *) ((char *) visual +
+ depth->nVisuals * sizeof (xVisualType));
+ }
+ root = (xWindowRoot *) ((char *) depth);
+ screen++;
+ }
+ root->pixWidth = pScreen->width;
+ root->pixHeight = pScreen->height;
+ root->mmWidth = pScreen->mmWidth;
+ root->mmHeight = pScreen->mmHeight;
+}
+
+void
+RRSendConfigNotify (ScreenPtr pScreen)
+{
+ WindowPtr pWin = pScreen->root;
+ xEvent event;
+
+ event.u.u.type = ConfigureNotify;
+ event.u.configureNotify.window = pWin->drawable.id;
+ event.u.configureNotify.aboveSibling = None;
+ event.u.configureNotify.x = 0;
+ event.u.configureNotify.y = 0;
+
+ /* XXX xinerama stuff ? */
+
+ event.u.configureNotify.width = pWin->drawable.width;
+ event.u.configureNotify.height = pWin->drawable.height;
+ event.u.configureNotify.borderWidth = wBorderWidth (pWin);
+ event.u.configureNotify.override = pWin->overrideRedirect;
+ DeliverEvents(pWin, &event, 1, NullWindow);
+}
+
+void
+RRDeliverScreenEvent (ClientPtr client, WindowPtr pWin, ScreenPtr pScreen)
+{
+ rrScrPriv (pScreen);
+ xRRScreenChangeNotifyEvent se;
+ RRCrtcPtr crtc = pScrPriv->numCrtcs ? pScrPriv->crtcs[0] : NULL;
+ WindowPtr pRoot = pScreen->root;
+
+ se.type = RRScreenChangeNotify + RREventBase;
+ se.rotation = (CARD8) (crtc ? crtc->rotation : RR_Rotate_0);
+ se.timestamp = pScrPriv->lastSetTime.milliseconds;
+ se.configTimestamp = pScrPriv->lastConfigTime.milliseconds;
+ se.root = pRoot->drawable.id;
+ se.window = pWin->drawable.id;
+ se.subpixelOrder = PictureGetSubpixelOrder (pScreen);
+
+ se.sizeID = RR10CurrentSizeID (pScreen);
+
+ if (se.rotation & (RR_Rotate_90 | RR_Rotate_270)) {
+ se.widthInPixels = pScreen->height;
+ se.heightInPixels = pScreen->width;
+ se.widthInMillimeters = pScreen->mmHeight;
+ se.heightInMillimeters = pScreen->mmWidth;
+ } else {
+ se.widthInPixels = pScreen->width;
+ se.heightInPixels = pScreen->height;
+ se.widthInMillimeters = pScreen->mmWidth;
+ se.heightInMillimeters = pScreen->mmHeight;
+ }
+
+ WriteEventsToClient (client, 1, (xEvent *) &se);
+}
+
+/*
+ * Notify the extension that the screen size has been changed.
+ * The driver is responsible for calling this whenever it has changed
+ * the size of the screen
+ */
+void
+RRScreenSizeNotify (ScreenPtr pScreen)
+{
+ rrScrPriv(pScreen);
+ /*
+ * Deliver ConfigureNotify events when root changes
+ * pixel size
+ */
+ if (pScrPriv->width == pScreen->width &&
+ pScrPriv->height == pScreen->height &&
+ pScrPriv->mmWidth == pScreen->mmWidth &&
+ pScrPriv->mmHeight == pScreen->mmHeight)
+ return;
+
+ pScrPriv->width = pScreen->width;
+ pScrPriv->height = pScreen->height;
+ pScrPriv->mmWidth = pScreen->mmWidth;
+ pScrPriv->mmHeight = pScreen->mmHeight;
+ pScrPriv->changed = TRUE;
+/* pScrPriv->sizeChanged = TRUE; */
+
+ RRTellChanged (pScreen);
+ RRSendConfigNotify (pScreen);
+ RREditConnectionInfo (pScreen);
+
+ RRPointerScreenConfigured (pScreen);
+ /*
+ * Fix pointer bounds and location
+ */
+ ScreenRestructured (pScreen);
+}
+
+/*
+ * Request that the screen be resized
+ */
+Bool
+RRScreenSizeSet (ScreenPtr pScreen,
+ CARD16 width,
+ CARD16 height,
+ CARD16 pixWidth,
+ CARD16 pixHeight,
+ CARD32 mmWidth,
+ CARD32 mmHeight)
+{
+ rrScrPriv(pScreen);
+
+#if RANDR_12_INTERFACE
+ if (pScrPriv->rrScreenSetSize)
+ {
+ return (*pScrPriv->rrScreenSetSize) (pScreen,
+ width, height,
+ pixWidth, pixHeight,
+ mmWidth, mmHeight);
+ }
+#endif
+#if RANDR_10_INTERFACE
+ if (pScrPriv->rrSetConfig)
+ {
+ return TRUE; /* can't set size separately */
+ }
+#endif
+ return FALSE;
+}
+
+/*
+ * Compute an RRScreenConfig from the current screen information
+ */
+void
+RRScreenCurrentConfig(ScreenPtr screen,
+ RRScreenConfigPtr screen_config)
+{
+ PixmapPtr screen_pixmap = screen->GetScreenPixmap(screen);
+ WindowPtr root = screen->root;
+
+ screen_config->screen_pixmap_width = screen_pixmap->drawable.width;
+ screen_config->screen_pixmap_height = screen_pixmap->drawable.height;
+ screen_config->screen_width = root->drawable.width;
+ screen_config->screen_height = root->drawable.height;
+ screen_config->mm_width = screen->mmWidth;
+ screen_config->mm_height = screen->mmHeight;
+}
+
+/*
+ * Retrieve valid screen size range
+ */
+int
+ProcRRGetScreenSizeRange (ClientPtr client)
+{
+ REQUEST(xRRGetScreenSizeRangeReq);
+ xRRGetScreenSizeRangeReply rep;
+ WindowPtr pWin;
+ ScreenPtr pScreen;
+ rrScrPrivPtr pScrPriv;
+ int rc;
+
+ REQUEST_SIZE_MATCH(xRRGetScreenInfoReq);
+ rc = dixLookupWindow(&pWin, stuff->window, client, DixGetAttrAccess);
+ if (rc != Success)
+ return rc;
+
+ pScreen = pWin->drawable.pScreen;
+ pScrPriv = rrGetScrPriv(pScreen);
+
+ rep.type = X_Reply;
+ rep.pad = 0;
+ rep.sequenceNumber = client->sequence;
+ rep.length = 0;
+
+ if (pScrPriv)
+ {
+ if (!RRGetInfo (pScreen, FALSE))
+ return BadAlloc;
+ rep.minWidth = pScrPriv->minWidth;
+ rep.minHeight = pScrPriv->minHeight;
+ rep.maxWidth = pScrPriv->maxWidth;
+ rep.maxHeight = pScrPriv->maxHeight;
+ }
+ else
+ {
+ rep.maxWidth = rep.minWidth = pScreen->width;
+ rep.maxHeight = rep.minHeight = pScreen->height;
+ }
+ if (client->swapped)
+ {
+ int n;
+
+ swaps(&rep.sequenceNumber, n);
+ swapl(&rep.length, n);
+ swaps(&rep.minWidth, n);
+ swaps(&rep.minHeight, n);
+ swaps(&rep.maxWidth, n);
+ swaps(&rep.maxHeight, n);
+ }
+ WriteToClient(client, sizeof(xRRGetScreenSizeRangeReply), (char *)&rep);
+ return Success;
+}
+
+int
+ProcRRSetScreenSize (ClientPtr client)
+{
+ REQUEST(xRRSetScreenSizeReq);
+ WindowPtr pWin;
+ ScreenPtr pScreen;
+ rrScrPrivPtr pScrPriv;
+ int i, rc;
+
+ REQUEST_SIZE_MATCH(xRRSetScreenSizeReq);
+ rc = dixLookupWindow(&pWin, stuff->window, client, DixGetAttrAccess);
+ if (rc != Success)
+ return rc;
+
+ pScreen = pWin->drawable.pScreen;
+ pScrPriv = rrGetScrPriv(pScreen);
+ if (stuff->width < pScrPriv->minWidth || pScrPriv->maxWidth < stuff->width)
+ {
+ client->errorValue = stuff->width;
+ return BadValue;
+ }
+ if (stuff->height < pScrPriv->minHeight ||
+ pScrPriv->maxHeight < stuff->height)
+ {
+ client->errorValue = stuff->height;
+ return BadValue;
+ }
+ for (i = 0; i < pScrPriv->numCrtcs; i++)
+ {
+ RRCrtcPtr crtc = pScrPriv->crtcs[i];
+ RRModePtr mode = crtc->mode;
+ if (mode)
+ {
+ int source_width = mode->mode.width;
+ int source_height = mode->mode.height;
+ Rotation rotation = crtc->rotation;
+
+ if (rotation == RR_Rotate_90 || rotation == RR_Rotate_270)
+ {
+ source_width = mode->mode.height;
+ source_height = mode->mode.width;
+ }
+
+ if (crtc->x + source_width > stuff->width ||
+ crtc->y + source_height > stuff->height)
+ return BadMatch;
+ }
+ }
+ if (stuff->widthInMillimeters == 0 || stuff->heightInMillimeters == 0)
+ {
+ client->errorValue = 0;
+ return BadValue;
+ }
+ if (!RRScreenSizeSet (pScreen,
+ stuff->width, stuff->height,
+ stuff->width, stuff->height,
+ stuff->widthInMillimeters,
+ stuff->heightInMillimeters))
+ {
+ return BadMatch;
+ }
+ return Success;
+}
+
+static int
+rrGetScreenResources(ClientPtr client, Bool query)
+{
+ REQUEST(xRRGetScreenResourcesReq);
+ xRRGetScreenResourcesReply rep;
+ WindowPtr pWin;
+ ScreenPtr pScreen;
+ rrScrPrivPtr pScrPriv;
+ CARD8 *extra;
+ unsigned long extraLen;
+ int i, n, rc, has_primary = 0;
+ RRCrtc *crtcs;
+ RROutput *outputs;
+ xRRModeInfo *modeinfos;
+ CARD8 *names;
+
+ REQUEST_SIZE_MATCH(xRRGetScreenResourcesReq);
+ rc = dixLookupWindow(&pWin, stuff->window, client, DixGetAttrAccess);
+ if (rc != Success)
+ return rc;
+
+ pScreen = pWin->drawable.pScreen;
+ pScrPriv = rrGetScrPriv(pScreen);
+ rep.pad = 0;
+
+ if (query && pScrPriv)
+ if (!RRGetInfo (pScreen, query))
+ return BadAlloc;
+
+ if (!pScrPriv)
+ {
+ rep.type = X_Reply;
+ rep.sequenceNumber = client->sequence;
+ rep.length = 0;
+ rep.timestamp = currentTime.milliseconds;
+ rep.configTimestamp = currentTime.milliseconds;
+ rep.nCrtcs = 0;
+ rep.nOutputs = 0;
+ rep.nModes = 0;
+ rep.nbytesNames = 0;
+ extra = NULL;
+ extraLen = 0;
+ }
+ else
+ {
+ RRModePtr *modes;
+ int num_modes;
+
+ modes = RRModesForScreen (pScreen, &num_modes);
+ if (!modes)
+ return BadAlloc;
+
+ rep.type = X_Reply;
+ rep.sequenceNumber = client->sequence;
+ rep.length = 0;
+ rep.timestamp = pScrPriv->lastSetTime.milliseconds;
+ rep.configTimestamp = pScrPriv->lastConfigTime.milliseconds;
+ rep.nCrtcs = pScrPriv->numCrtcs;
+ rep.nOutputs = pScrPriv->numOutputs;
+ rep.nModes = num_modes;
+ rep.nbytesNames = 0;
+
+ for (i = 0; i < num_modes; i++)
+ rep.nbytesNames += modes[i]->mode.nameLength;
+
+ rep.length = (pScrPriv->numCrtcs +
+ pScrPriv->numOutputs +
+ num_modes * bytes_to_int32(SIZEOF(xRRModeInfo)) +
+ bytes_to_int32(rep.nbytesNames));
+
+ extraLen = rep.length << 2;
+ if (extraLen)
+ {
+ extra = malloc(extraLen);
+ if (!extra)
+ {
+ free(modes);
+ return BadAlloc;
+ }
+ }
+ else
+ extra = NULL;
+
+ crtcs = (RRCrtc *) extra;
+ outputs = (RROutput *) (crtcs + pScrPriv->numCrtcs);
+ modeinfos = (xRRModeInfo *) (outputs + pScrPriv->numOutputs);
+ names = (CARD8 *) (modeinfos + num_modes);
+
+ if (pScrPriv->primaryOutput && pScrPriv->primaryOutput->crtc)
+ {
+ has_primary = 1;
+ crtcs[0] = pScrPriv->primaryOutput->crtc->id;
+ if (client->swapped)
+ swapl (&crtcs[0], n);
+ }
+
+ for (i = 0; i < pScrPriv->numCrtcs; i++)
+ {
+ if (has_primary &&
+ pScrPriv->primaryOutput->crtc == pScrPriv->crtcs[i])
+ {
+ has_primary = 0;
+ continue;
+ }
+ crtcs[i + has_primary] = pScrPriv->crtcs[i]->id;
+ if (client->swapped)
+ swapl (&crtcs[i + has_primary], n);
+ }
+
+ for (i = 0; i < pScrPriv->numOutputs; i++)
+ {
+ outputs[i] = pScrPriv->outputs[i]->id;
+ if (client->swapped)
+ swapl (&outputs[i], n);
+ }
+
+ for (i = 0; i < num_modes; i++)
+ {
+ RRModePtr mode = modes[i];
+ modeinfos[i] = mode->mode;
+ if (client->swapped)
+ {
+ swapl (&modeinfos[i].id, n);
+ swaps (&modeinfos[i].width, n);
+ swaps (&modeinfos[i].height, n);
+ swapl (&modeinfos[i].dotClock, n);
+ swaps (&modeinfos[i].hSyncStart, n);
+ swaps (&modeinfos[i].hSyncEnd, n);
+ swaps (&modeinfos[i].hTotal, n);
+ swaps (&modeinfos[i].hSkew, n);
+ swaps (&modeinfos[i].vSyncStart, n);
+ swaps (&modeinfos[i].vSyncEnd, n);
+ swaps (&modeinfos[i].vTotal, n);
+ swaps (&modeinfos[i].nameLength, n);
+ swapl (&modeinfos[i].modeFlags, n);
+ }
+ memcpy (names, mode->name,
+ mode->mode.nameLength);
+ names += mode->mode.nameLength;
+ }
+ free(modes);
+ assert (bytes_to_int32((char *) names - (char *) extra) == rep.length);
+ }
+
+ if (client->swapped) {
+ swaps(&rep.sequenceNumber, n);
+ swapl(&rep.length, n);
+ swapl(&rep.timestamp, n);
+ swapl(&rep.configTimestamp, n);
+ swaps(&rep.nCrtcs, n);
+ swaps(&rep.nOutputs, n);
+ swaps(&rep.nModes, n);
+ swaps(&rep.nbytesNames, n);
+ }
+ WriteToClient(client, sizeof(xRRGetScreenResourcesReply), (char *)&rep);
+ if (extraLen)
+ {
+ WriteToClient (client, extraLen, (char *) extra);
+ free(extra);
+ }
+ return Success;
+}
+
+int
+ProcRRGetScreenResources (ClientPtr client)
+{
+ return rrGetScreenResources(client, TRUE);
+}
+
+int
+ProcRRGetScreenResourcesCurrent (ClientPtr client)
+{
+ return rrGetScreenResources(client, FALSE);
+}
+
+typedef struct _RR10Data {
+ RRScreenSizePtr sizes;
+ int nsize;
+ int nrefresh;
+ int size;
+ CARD16 refresh;
+} RR10DataRec, *RR10DataPtr;
+
+/*
+ * Convert 1.2 monitor data into 1.0 screen data
+ */
+static RR10DataPtr
+RR10GetData (ScreenPtr pScreen, RROutputPtr output)
+{
+ RR10DataPtr data;
+ RRScreenSizePtr size;
+ int nmode = output->numModes + output->numUserModes;
+ int o, os, l, r;
+ RRScreenRatePtr refresh;
+ CARD16 vRefresh;
+ RRModePtr mode;
+ Bool *used;
+
+ /* Make sure there is plenty of space for any combination */
+ data = malloc (sizeof (RR10DataRec) +
+ sizeof (RRScreenSize) * nmode +
+ sizeof (RRScreenRate) * nmode +
+ sizeof (Bool) * nmode);
+ if (!data)
+ return NULL;
+ size = (RRScreenSizePtr) (data + 1);
+ refresh = (RRScreenRatePtr) (size + nmode);
+ used = (Bool *) (refresh + nmode);
+ memset (used, '\0', sizeof (Bool) * nmode);
+ data->sizes = size;
+ data->nsize = 0;
+ data->nrefresh = 0;
+ data->size = 0;
+ data->refresh = 0;
+
+ /*
+ * find modes not yet listed
+ */
+ for (o = 0; o < output->numModes + output->numUserModes; o++)
+ {
+ if (used[o]) continue;
+
+ if (o < output->numModes)
+ mode = output->modes[o];
+ else
+ mode = output->userModes[o - output->numModes];
+
+ l = data->nsize;
+ size[l].id = data->nsize;
+ size[l].width = mode->mode.width;
+ size[l].height = mode->mode.height;
+ if (output->mmWidth && output->mmHeight) {
+ size[l].mmWidth = output->mmWidth;
+ size[l].mmHeight = output->mmHeight;
+ } else {
+ size[l].mmWidth = pScreen->mmWidth;
+ size[l].mmHeight = pScreen->mmHeight;
+ }
+ size[l].nRates = 0;
+ size[l].pRates = &refresh[data->nrefresh];
+ data->nsize++;
+
+ /*
+ * Find all modes with matching size
+ */
+ for (os = o; os < output->numModes + output->numUserModes; os++)
+ {
+ if (os < output->numModes)
+ mode = output->modes[os];
+ else
+ mode = output->userModes[os - output->numModes];
+ if (mode->mode.width == size[l].width &&
+ mode->mode.height == size[l].height)
+ {
+ vRefresh = RRVerticalRefresh (&mode->mode);
+ used[os] = TRUE;
+
+ for (r = 0; r < size[l].nRates; r++)
+ if (vRefresh == size[l].pRates[r].rate)
+ break;
+ if (r == size[l].nRates)
+ {
+ size[l].pRates[r].rate = vRefresh;
+ size[l].pRates[r].mode = mode;
+ size[l].nRates++;
+ data->nrefresh++;
+ }
+ if (mode == output->crtc->mode)
+ {
+ data->size = l;
+ data->refresh = vRefresh;
+ }
+ }
+ }
+ }
+ return data;
+}
+
+int
+ProcRRGetScreenInfo (ClientPtr client)
+{
+ REQUEST(xRRGetScreenInfoReq);
+ xRRGetScreenInfoReply rep;
+ WindowPtr pWin;
+ int n, rc;
+ ScreenPtr pScreen;
+ rrScrPrivPtr pScrPriv;
+ CARD8 *extra;
+ unsigned long extraLen;
+ RROutputPtr output;
+
+ REQUEST_SIZE_MATCH(xRRGetScreenInfoReq);
+ rc = dixLookupWindow(&pWin, stuff->window, client, DixGetAttrAccess);
+ if (rc != Success)
+ return rc;
+
+ pScreen = pWin->drawable.pScreen;
+ pScrPriv = rrGetScrPriv(pScreen);
+ rep.pad = 0;
+
+ if (pScrPriv)
+ if (!RRGetInfo (pScreen, TRUE))
+ return BadAlloc;
+
+ output = RRFirstOutput (pScreen);
+
+ if (!pScrPriv || !output)
+ {
+ rep.type = X_Reply;
+ rep.setOfRotations = RR_Rotate_0;
+ rep.sequenceNumber = client->sequence;
+ rep.length = 0;
+ rep.root = pWin->drawable.pScreen->root->drawable.id;
+ rep.timestamp = currentTime.milliseconds;
+ rep.configTimestamp = currentTime.milliseconds;
+ rep.nSizes = 0;
+ rep.sizeID = 0;
+ rep.rotation = RR_Rotate_0;
+ rep.rate = 0;
+ rep.nrateEnts = 0;
+ extra = 0;
+ extraLen = 0;
+ }
+ else
+ {
+ int i, j;
+ xScreenSizes *size;
+ CARD16 *rates;
+ CARD8 *data8;
+ Bool has_rate = RRClientKnowsRates (client);
+ RR10DataPtr pData;
+ RRScreenSizePtr pSize;
+
+ pData = RR10GetData (pScreen, output);
+ if (!pData)
+ return BadAlloc;
+
+ rep.type = X_Reply;
+ rep.setOfRotations = output->crtc->rotations;
+ rep.sequenceNumber = client->sequence;
+ rep.length = 0;
+ rep.root = pWin->drawable.pScreen->root->drawable.id;
+ rep.timestamp = pScrPriv->lastSetTime.milliseconds;
+ rep.configTimestamp = pScrPriv->lastConfigTime.milliseconds;
+ rep.rotation = output->crtc->rotation;
+ rep.nSizes = pData->nsize;
+ rep.nrateEnts = pData->nrefresh + pData->nsize;
+ rep.sizeID = pData->size;
+ rep.rate = pData->refresh;
+
+ extraLen = rep.nSizes * sizeof (xScreenSizes);
+ if (has_rate)
+ extraLen += rep.nrateEnts * sizeof (CARD16);
+
+ if (extraLen)
+ {
+ extra = (CARD8 *) malloc(extraLen);
+ if (!extra)
+ {
+ free(pData);
+ return BadAlloc;
+ }
+ }
+ else
+ extra = NULL;
+
+ /*
+ * First comes the size information
+ */
+ size = (xScreenSizes *) extra;
+ rates = (CARD16 *) (size + rep.nSizes);
+ for (i = 0; i < pData->nsize; i++)
+ {
+ pSize = &pData->sizes[i];
+ size->widthInPixels = pSize->width;
+ size->heightInPixels = pSize->height;
+ size->widthInMillimeters = pSize->mmWidth;
+ size->heightInMillimeters = pSize->mmHeight;
+ if (client->swapped)
+ {
+ swaps (&size->widthInPixels, n);
+ swaps (&size->heightInPixels, n);
+ swaps (&size->widthInMillimeters, n);
+ swaps (&size->heightInMillimeters, n);
+ }
+ size++;
+ if (has_rate)
+ {
+ *rates = pSize->nRates;
+ if (client->swapped)
+ {
+ swaps (rates, n);
+ }
+ rates++;
+ for (j = 0; j < pSize->nRates; j++)
+ {
+ *rates = pSize->pRates[j].rate;
+ if (client->swapped)
+ {
+ swaps (rates, n);
+ }
+ rates++;
+ }
+ }
+ }
+ free(pData);
+
+ data8 = (CARD8 *) rates;
+
+ if (data8 - (CARD8 *) extra != extraLen)
+ FatalError ("RRGetScreenInfo bad extra len %ld != %ld\n",
+ (unsigned long)(data8 - (CARD8 *) extra), extraLen);
+ rep.length = bytes_to_int32(extraLen);
+ }
+ if (client->swapped) {
+ swaps(&rep.sequenceNumber, n);
+ swapl(&rep.length, n);
+ swapl(&rep.timestamp, n);
+ swaps(&rep.rotation, n);
+ swaps(&rep.nSizes, n);
+ swaps(&rep.sizeID, n);
+ swaps(&rep.rate, n);
+ swaps(&rep.nrateEnts, n);
+ }
+ WriteToClient(client, sizeof(xRRGetScreenInfoReply), (char *)&rep);
+ if (extraLen)
+ {
+ WriteToClient (client, extraLen, (char *) extra);
+ free(extra);
+ }
+ return Success;
+}
+
+int
+ProcRRSetScreenConfig (ClientPtr client)
+{
+ REQUEST(xRRSetScreenConfigReq);
+ xRRSetScreenConfigReply rep;
+ DrawablePtr pDraw;
+ int n, rc;
+ ScreenPtr pScreen;
+ rrScrPrivPtr pScrPriv;
+ TimeStamp time;
+ int i;
+ Rotation rotation;
+ int rate;
+ Bool has_rate;
+ RROutputPtr output;
+ RRCrtcPtr crtc;
+ RRModePtr mode;
+ RR10DataPtr pData = NULL;
+ RRScreenSizePtr pSize;
+ int width, height;
+
+ UpdateCurrentTime ();
+
+ if (RRClientKnowsRates (client))
+ {
+ REQUEST_SIZE_MATCH (xRRSetScreenConfigReq);
+ has_rate = TRUE;
+ }
+ else
+ {
+ REQUEST_SIZE_MATCH (xRR1_0SetScreenConfigReq);
+ has_rate = FALSE;
+ }
+
+ rc = dixLookupDrawable(&pDraw, stuff->drawable, client, 0, DixWriteAccess);
+ if (rc != Success) {
+ client->errorValue = stuff->drawable;
+ return rc;
+ }
+
+ pScreen = pDraw->pScreen;
+
+ pScrPriv = rrGetScrPriv(pScreen);
+
+ time = ClientTimeToServerTime(stuff->timestamp);
+
+ if (!pScrPriv)
+ {
+ time = currentTime;
+ rep.status = RRSetConfigFailed;
+ goto sendReply;
+ }
+ if (!RRGetInfo (pScreen, FALSE))
+ return BadAlloc;
+
+ output = RRFirstOutput (pScreen);
+ if (!output)
+ {
+ time = currentTime;
+ rep.status = RRSetConfigFailed;
+ goto sendReply;
+ }
+
+ crtc = output->crtc;
+
+ /*
+ * If the client's config timestamp is not the same as the last config
+ * timestamp, then the config information isn't up-to-date and
+ * can't even be validated.
+ *
+ * Note that the client only knows about the milliseconds part of the
+ * timestamp, so using CompareTimeStamps here would cause randr to suddenly
+ * stop working after several hours have passed (freedesktop bug #6502).
+ */
+ if (stuff->configTimestamp != pScrPriv->lastConfigTime.milliseconds)
+ {
+ rep.status = RRSetConfigInvalidConfigTime;
+ goto sendReply;
+ }
+
+ pData = RR10GetData (pScreen, output);
+ if (!pData)
+ return BadAlloc;
+
+ if (stuff->sizeID >= pData->nsize)
+ {
+ /*
+ * Invalid size ID
+ */
+ client->errorValue = stuff->sizeID;
+ free(pData);
+ return BadValue;
+ }
+ pSize = &pData->sizes[stuff->sizeID];
+
+ /*
+ * Validate requested rotation
+ */
+ rotation = (Rotation) stuff->rotation;
+
+ /* test the rotation bits only! */
+ switch (rotation & 0xf) {
+ case RR_Rotate_0:
+ case RR_Rotate_90:
+ case RR_Rotate_180:
+ case RR_Rotate_270:
+ break;
+ default:
+ /*
+ * Invalid rotation
+ */
+ client->errorValue = stuff->rotation;
+ free(pData);
+ return BadValue;
+ }
+
+ if ((~crtc->rotations) & rotation)
+ {
+ /*
+ * requested rotation or reflection not supported by screen
+ */
+ client->errorValue = stuff->rotation;
+ free(pData);
+ return BadMatch;
+ }
+
+ /*
+ * Validate requested refresh
+ */
+ if (has_rate)
+ rate = (int) stuff->rate;
+ else
+ rate = 0;
+
+ if (rate)
+ {
+ for (i = 0; i < pSize->nRates; i++)
+ {
+ if (pSize->pRates[i].rate == rate)
+ break;
+ }
+ if (i == pSize->nRates)
+ {
+ /*
+ * Invalid rate
+ */
+ client->errorValue = rate;
+ free(pData);
+ return BadValue;
+ }
+ mode = pSize->pRates[i].mode;
+ }
+ else
+ mode = pSize->pRates[0].mode;
+
+ /*
+ * Make sure the requested set-time is not older than
+ * the last set-time
+ */
+ if (CompareTimeStamps (time, pScrPriv->lastSetTime) < 0)
+ {
+ rep.status = RRSetConfigInvalidTime;
+ goto sendReply;
+ }
+
+ /*
+ * If the screen size is changing, adjust all of the other outputs
+ * to fit the new size, mirroring as much as possible
+ */
+ width = mode->mode.width;
+ height = mode->mode.height;
+ if (rotation & (RR_Rotate_90|RR_Rotate_270))
+ {
+ width = mode->mode.height;
+ height = mode->mode.width;
+ }
+
+ if (width < pScrPriv->minWidth || pScrPriv->maxWidth < width) {
+ client->errorValue = width;
+ free(pData);
+ return BadValue;
+ }
+ if (height < pScrPriv->minHeight || pScrPriv->maxHeight < height) {
+ client->errorValue = height;
+ free(pData);
+ return BadValue;
+ }
+
+ if (width != pScreen->width || height != pScreen->height)
+ {
+ int c;
+
+ for (c = 0; c < pScrPriv->numCrtcs; c++)
+ {
+ if (!RRCrtcSet (pScrPriv->crtcs[c], NULL, 0, 0, RR_Rotate_0,
+ 0, NULL, NULL))
+ {
+ rep.status = RRSetConfigFailed;
+ /* XXX recover from failure */
+ goto sendReply;
+ }
+ }
+ if (!RRScreenSizeSet (pScreen, width, height, width, height,
+ pScreen->mmWidth, pScreen->mmHeight))
+ {
+ rep.status = RRSetConfigFailed;
+ /* XXX recover from failure */
+ goto sendReply;
+ }
+ }
+
+ if (!RRCrtcSet (crtc, mode, 0, 0, stuff->rotation, 1, &output, NULL))
+ rep.status = RRSetConfigFailed;
+ else {
+ pScrPriv->lastSetTime = time;
+ rep.status = RRSetConfigSuccess;
+ }
+
+ /*
+ * XXX Configure other crtcs to mirror as much as possible
+ */
+
+sendReply:
+
+ free(pData);
+
+ rep.type = X_Reply;
+ /* rep.status has already been filled in */
+ rep.length = 0;
+ rep.sequenceNumber = client->sequence;
+
+ rep.newTimestamp = pScrPriv->lastSetTime.milliseconds;
+ rep.newConfigTimestamp = pScrPriv->lastConfigTime.milliseconds;
+ rep.root = pDraw->pScreen->root->drawable.id;
+
+ if (client->swapped)
+ {
+ swaps(&rep.sequenceNumber, n);
+ swapl(&rep.length, n);
+ swapl(&rep.newTimestamp, n);
+ swapl(&rep.newConfigTimestamp, n);
+ swapl(&rep.root, n);
+ }
+ WriteToClient(client, sizeof(xRRSetScreenConfigReply), (char *)&rep);
+
+ return Success;
+}
+
+static CARD16
+RR10CurrentSizeID (ScreenPtr pScreen)
+{
+ CARD16 sizeID = 0xffff;
+ RROutputPtr output = RRFirstOutput (pScreen);
+
+ if (output)
+ {
+ RR10DataPtr data = RR10GetData (pScreen, output);
+ if (data)
+ {
+ int i;
+ for (i = 0; i < data->nsize; i++)
+ if (data->sizes[i].width == pScreen->width &&
+ data->sizes[i].height == pScreen->height)
+ {
+ sizeID = (CARD16) i;
+ break;
+ }
+ free(data);
+ }
+ }
+ return sizeID;
+}
diff --git a/xorg-server/xkeyboard-config/rules/base.xml.in b/xorg-server/xkeyboard-config/rules/base.xml.in
index d9faa2d87..8d472719b 100644
--- a/xorg-server/xkeyboard-config/rules/base.xml.in
+++ b/xorg-server/xkeyboard-config/rules/base.xml.in
@@ -1,5726 +1,5736 @@
-<?xml version="1.0" encoding="utf-8"?>
-<!DOCTYPE xkbConfigRegistry SYSTEM "xkb.dtd">
-<xkbConfigRegistry>
- <modelList>
- <model>
- <configItem>
- <name>pc101</name>
- <_description>Generic 101-key PC</_description>
- <vendor>Generic</vendor>
- </configItem>
- </model>
- <model>
- <configItem>
- <name>pc102</name>
- <_description>Generic 102-key (Intl) PC</_description>
- <vendor>Generic</vendor>
- </configItem>
- </model>
- <model>
- <configItem>
- <name>pc104</name>
- <_description>Generic 104-key PC</_description>
- <vendor>Generic</vendor>
- </configItem>
- </model>
- <model>
- <configItem>
- <name>pc105</name>
- <_description>Generic 105-key (Intl) PC</_description>
- <vendor>Generic</vendor>
- </configItem>
- </model>
- <model>
- <configItem>
- <name>dell101</name>
- <_description>Dell 101-key PC</_description>
- <vendor>Dell</vendor>
- </configItem>
- </model>
- <model>
- <configItem>
- <name>latitude</name>
- <_description>Dell Latitude series laptop</_description>
- <vendor>Dell</vendor>
- </configItem>
- </model>
- <model>
- <configItem>
- <name>dellm65</name>
- <_description>Dell Precision M65</_description>
- <vendor>Dell</vendor>
- </configItem>
- </model>
- <model>
- <configItem>
- <name>everex</name>
- <_description>Everex STEPnote</_description>
- <vendor>Everex</vendor>
- </configItem>
- </model>
- <model>
- <configItem>
- <name>flexpro</name>
- <_description>Keytronic FlexPro</_description>
- <vendor>Keytronic</vendor>
- </configItem>
- </model>
- <model>
- <configItem>
- <name>microsoft</name>
- <_description>Microsoft Natural</_description>
- <vendor>Microsoft Inc.</vendor>
- </configItem>
- </model>
- <model>
- <configItem>
- <name>omnikey101</name>
- <_description>Northgate OmniKey 101</_description>
- <vendor>Northgate</vendor>
- </configItem>
- </model>
- <model>
- <configItem>
- <name>winbook</name>
- <_description>Winbook Model XP5</_description>
- <vendor>Generic</vendor>
- </configItem>
- </model>
- <model>
- <configItem>
- <name>pc98</name>
- <_description>PC-98xx Series</_description>
- <vendor>Generic</vendor>
- </configItem>
- </model>
- <model>
- <configItem>
- <name>a4techKB21</name>
- <_description>A4Tech KB-21</_description>
- <vendor>A4Tech</vendor>
- </configItem>
- </model>
- <model>
- <configItem>
- <name>a4techKBS8</name>
- <_description>A4Tech KBS-8</_description>
- <vendor>A4Tech</vendor>
- </configItem>
- </model>
- <model>
- <configItem>
- <name>a4_rfkb23</name>
- <_description>A4Tech Wireless Desktop RFKB-23</_description>
- <vendor>A4Tech</vendor>
- </configItem>
- </model>
- <model>
- <configItem>
- <name>airkey</name>
- <_description>Acer AirKey V</_description>
- <vendor>Acer</vendor>
- </configItem>
- </model>
- <model>
- <configItem>
- <name>azonaRF2300</name>
- <_description>Azona RF2300 wireless Internet Keyboard</_description>
- <vendor>Azona</vendor>
- </configItem>
- </model>
- <model>
- <configItem>
- <name>scorpius</name>
- <_description>Advance Scorpius KI</_description>
- <vendor>Scorpius</vendor>
- </configItem>
- </model>
- <model>
- <configItem>
- <name>brother</name>
- <_description>Brother Internet Keyboard</_description>
- <vendor>Brother</vendor>
- </configItem>
- </model>
- <model>
- <configItem>
- <name>btc5113rf</name>
- <_description>BTC 5113RF Multimedia</_description>
- <vendor>BTC</vendor>
- </configItem>
- </model>
- <model>
- <configItem>
- <name>btc5126t</name>
- <_description>BTC 5126T</_description>
- <vendor>BTC</vendor>
- </configItem>
- </model>
- <model>
- <configItem>
- <name>btc6301urf</name>
- <_description>BTC 6301URF</_description>
- <vendor>BTC</vendor>
- </configItem>
- </model>
- <model>
- <configItem>
- <name>btc9000</name>
- <_description>BTC 9000</_description>
- <vendor>BTC</vendor>
- </configItem>
- </model>
- <model>
- <configItem>
- <name>btc9000a</name>
- <_description>BTC 9000A</_description>
- <vendor>BTC</vendor>
- </configItem>
- </model>
- <model>
- <configItem>
- <name>btc9001ah</name>
- <_description>BTC 9001AH</_description>
- <vendor>BTC</vendor>
- </configItem>
- </model>
- <model>
- <configItem>
- <name>btc5090</name>
- <_description>BTC 5090</_description>
- <vendor>BTC</vendor>
- </configItem>
- </model>
- <model>
- <configItem>
- <name>btc9019u</name>
- <_description>BTC 9019U</_description>
- <vendor>BTC</vendor>
- </configItem>
- </model>
- <model>
- <configItem>
- <name>btc9116u</name>
- <_description>BTC 9116U Mini Wireless Internet and Gaming</_description>
- </configItem>
- </model>
- <model>
- <configItem>
- <name>cherryblue</name>
- <_description>Cherry Blue Line CyBo@rd</_description>
- </configItem>
- </model>
- <model>
- <configItem>
- <name>cherryblueb</name>
- <_description>Cherry CyMotion Master XPress</_description>
- <vendor>Cherry</vendor>
- </configItem>
- </model>
- <model>
- <configItem>
- <name>cherrybluea</name>
- <_description>Cherry Blue Line CyBo@rd (alternate option)</_description>
- <vendor>Cherry</vendor>
- </configItem>
- </model>
- <model>
- <configItem>
- <name>cherrycyboard</name>
- <_description>Cherry CyBo@rd USB-Hub</_description>
- <vendor>Cherry</vendor>
- </configItem>
- </model>
- <model>
- <configItem>
- <name>cherrycmexpert</name>
- <_description>Cherry CyMotion Expert</_description>
- <vendor>Cherry</vendor>
- </configItem>
- </model>
- <model>
- <configItem>
- <name>cherrybunlim</name>
- <_description>Cherry B.UNLIMITED</_description>
- <vendor>Cherry</vendor>
- </configItem>
- </model>
- <model>
- <configItem>
- <name>chicony</name>
- <_description>Chicony Internet Keyboard</_description>
- <vendor>Chicony</vendor>
- </configItem>
- </model>
- <model>
- <configItem>
- <name>chicony0108</name>
- <_description>Chicony KU-0108</_description>
- <vendor>Chicony</vendor>
- </configItem>
- </model>
- <model>
- <configItem>
- <name>chicony0420</name>
- <_description>Chicony KU-0420</_description>
- <vendor>Chicony</vendor>
- </configItem>
- </model>
- <model>
- <configItem>
- <name>chicony9885</name>
- <_description>Chicony KB-9885</_description>
- <vendor>Chicony</vendor>
- </configItem>
- </model>
- <model>
- <configItem>
- <name>compaqeak8</name>
- <_description>Compaq Easy Access Keyboard</_description>
- <vendor>Compaq</vendor>
- </configItem>
- </model>
- <model>
- <configItem>
- <name>compaqik7</name>
- <_description>Compaq Internet Keyboard (7 keys)</_description>
- <vendor>Compaq</vendor>
- </configItem>
- </model>
- <model>
- <configItem>
- <name>compaqik13</name>
- <_description>Compaq Internet Keyboard (13 keys)</_description>
- <vendor>Compaq</vendor>
- </configItem>
- </model>
- <model>
- <configItem>
- <name>compaqik18</name>
- <_description>Compaq Internet Keyboard (18 keys)</_description>
- <vendor>Compaq</vendor>
- </configItem>
- </model>
- <model>
- <configItem>
- <name>cymotionlinux</name>
- <_description>Cherry CyMotion Master Linux</_description>
- <vendor>Cherry</vendor>
- </configItem>
- </model>
- <model>
- <configItem>
- <name>armada</name>
- <_description>Laptop/notebook Compaq (eg. Armada) Laptop Keyboard</_description>
- <vendor>Compaq</vendor>
- </configItem>
- </model>
- <model>
- <configItem>
- <name>presario</name>
- <_description>Laptop/notebook Compaq (eg. Presario) Internet Keyboard</_description>
- <vendor>Compaq</vendor>
- </configItem>
- </model>
- <model>
- <configItem>
- <name>ipaq</name>
- <_description>Compaq iPaq Keyboard</_description>
- <vendor>Compaq</vendor>
- </configItem>
- </model>
- <model>
- <configItem>
- <name>dell</name>
- <_description>Dell</_description>
- <vendor>Dell</vendor>
- </configItem>
- </model>
- <model>
- <configItem>
- <name>dellsk8125</name>
- <_description>Dell SK-8125</_description>
- <vendor>Dell</vendor>
- </configItem>
- </model>
- <model>
- <configItem>
- <name>dellsk8135</name>
- <_description>Dell SK-8135</_description>
- <vendor>Dell</vendor>
- </configItem>
- </model>
- <model>
- <configItem>
- <name>dellusbmm</name>
- <_description>Dell USB Multimedia Keyboard</_description>
- <vendor>Dell</vendor>
- </configItem>
- </model>
- <model>
- <configItem>
- <name>inspiron</name>
- <_description>Dell Laptop/notebook Inspiron 6xxx/8xxx</_description>
- <vendor>Dell</vendor>
- </configItem>
- </model>
- <model>
- <configItem>
- <name>precision_m</name>
- <_description>Dell Laptop/notebook Precision M series</_description>
- <vendor>Dell</vendor>
- </configItem>
- </model>
- <model>
- <configItem>
- <name>dexxa</name>
- <_description>Dexxa Wireless Desktop Keyboard</_description>
- <vendor>Dexxa</vendor>
- </configItem>
- </model>
- <model>
- <configItem>
- <name>diamond</name>
- <_description>Diamond 9801 / 9802 series</_description>
- <vendor>Diamond</vendor>
- </configItem>
- </model>
- <model>
- <configItem>
- <name>dtk2000</name>
- <_description>DTK2000</_description>
- </configItem>
- </model>
- <model>
- <configItem>
- <name>ennyah_dkb1008</name>
- <_description>Ennyah DKB-1008</_description>
- <vendor>Ennyah</vendor>
- </configItem>
- </model>
- <model>
- <configItem>
- <name>fscaa1667g</name>
- <_description>Fujitsu-Siemens Computers AMILO laptop</_description>
- <vendor>Fujitsu-Siemens</vendor>
- </configItem>
- </model>
- <model>
- <configItem>
- <name>genius</name>
- <_description>Genius Comfy KB-16M / Genius MM Keyboard KWD-910</_description>
- <vendor>Genius</vendor>
- </configItem>
- </model>
- <model>
- <configItem>
- <name>geniuscomfy</name>
- <_description>Genius Comfy KB-12e</_description>
- <vendor>Genius</vendor>
- </configItem>
- </model>
- <model>
- <configItem>
- <name>geniuscomfy2</name>
- <_description>Genius Comfy KB-21e-Scroll</_description>
- <vendor>Genius</vendor>
- </configItem>
- </model>
- <model>
- <configItem>
- <name>geniuskb19e</name>
- <_description>Genius KB-19e NB</_description>
- <vendor>Genius</vendor>
- </configItem>
- </model>
- <model>
- <configItem>
- <name>geniuskkb2050hs</name>
- <_description>Genius KKB-2050HS</_description>
- <vendor>Genius</vendor>
- </configItem>
- </model>
- <model>
- <configItem>
- <name>gyration</name>
- <_description>Gyration</_description>
- <vendor>Gyration</vendor>
- </configItem>
- </model>
- <model>
- <configItem>
- <name>htcdream</name>
- <_description>HTC Dream</_description>
- <vendor>HTC</vendor>
- </configItem>
- </model>
- <model>
- <configItem>
- <name>kinesis</name>
- <_description>Kinesis</_description>
- <vendor>Kinesis</vendor>
- </configItem>
- </model>
- <model>
- <configItem>
- <name>logitech_base</name>
- <_description>Logitech Generic Keyboard</_description>
- <vendor>Logitech</vendor>
- </configItem>
- </model>
- <model>
- <configItem>
- <name>logitech_g15</name>
- <_description>Logitech G15 extra keys via G15daemon</_description>
- <vendor>Logitech</vendor>
- </configItem>
- </model>
- <model>
- <configItem>
- <name>hpi6</name>
- <_description>Hewlett-Packard Internet Keyboard</_description>
- <vendor>Hewlett-Packard</vendor>
- </configItem>
- </model>
- <model>
- <configItem>
- <name>hp250x</name>
- <_description>Hewlett-Packard SK-250x Multimedia Keyboard</_description>
- <vendor>Hewlett-Packard</vendor>
- </configItem>
- </model>
- <model>
- <configItem>
- <name>hpxe3gc</name>
- <_description>Hewlett-Packard Omnibook XE3 GC</_description>
- <vendor>Hewlett-Packard</vendor>
- </configItem>
- </model>
- <model>
- <configItem>
- <name>hpxe3gf</name>
- <_description>Hewlett-Packard Omnibook XE3 GF</_description>
- <vendor>Hewlett-Packard</vendor>
- </configItem>
- </model>
- <model>
- <configItem>
- <name>hpxt1000</name>
- <_description>Hewlett-Packard Omnibook XT1000</_description>
- <vendor>Hewlett-Packard</vendor>
- </configItem>
- </model>
- <model>
- <configItem>
- <name>hpdv5</name>
- <_description>Hewlett-Packard Pavilion dv5</_description>
- <vendor>Hewlett-Packard</vendor>
- </configItem>
- </model>
- <model>
- <configItem>
- <name>hpzt11xx</name>
- <_description>Hewlett-Packard Pavilion ZT11xx</_description>
- <vendor>Hewlett-Packard</vendor>
- </configItem>
- </model>
- <model>
- <configItem>
- <name>hp500fa</name>
- <_description>Hewlett-Packard Omnibook 500 FA</_description>
- <vendor>Hewlett-Packard</vendor>
- </configItem>
- </model>
- <model>
- <configItem>
- <name>hp5xx</name>
- <_description>Hewlett-Packard Omnibook 5xx</_description>
- <vendor>Hewlett-Packard</vendor>
- </configItem>
- </model>
- <model>
- <configItem>
- <name>hpnx9020</name>
- <_description>Hewlett-Packard nx9020</_description>
- <vendor>Hewlett-Packard</vendor>
- </configItem>
- </model>
- <model>
- <configItem>
- <name>hp6000</name>
- <_description>Hewlett-Packard Omnibook 6000/6100</_description>
- <vendor>Hewlett-Packard</vendor>
- </configItem>
- </model>
- <model>
- <configItem>
- <name>honeywell_euroboard</name>
- <_description>Honeywell Euroboard</_description>
- <vendor>Hewlett-Packard</vendor>
- </configItem>
- </model>
- <model>
- <configItem>
- <name>hpmini110</name>
- <_description>Hewlett-Packard Mini 110 Notebook</_description>
- <vendor>Hewlett-Packard</vendor>
- </configItem>
- </model>
- <model>
- <configItem>
- <name>rapidaccess</name>
- <_description>IBM Rapid Access</_description>
- <vendor>Lenovo (previously IBM)</vendor>
- </configItem>
- </model>
- <model>
- <configItem>
- <name>rapidaccess2</name>
- <_description>IBM Rapid Access II</_description>
- <vendor>Lenovo (previously IBM)</vendor>
- </configItem>
- </model>
- <model>
- <configItem>
- <name>thinkpad</name>
- <_description>IBM ThinkPad 560Z/600/600E/A22E</_description>
- <vendor>Lenovo (previously IBM)</vendor>
- </configItem>
- </model>
- <model>
- <configItem>
- <name>thinkpad60</name>
- <_description>IBM ThinkPad R60/T60/R61/T61</_description>
- <vendor>Lenovo (previously IBM)</vendor>
- </configItem>
- </model>
- <model>
- <configItem>
- <name>thinkpadz60</name>
- <_description>IBM ThinkPad Z60m/Z60t/Z61m/Z61t</_description>
- <vendor>Lenovo (previously IBM)</vendor>
- </configItem>
- </model>
- <model>
- <configItem>
- <name>ibm_spacesaver</name>
- <_description>IBM Space Saver</_description>
- <vendor>Lenovo (previously IBM)</vendor>
- </configItem>
- </model>
- <model>
- <configItem>
- <name>logiaccess</name>
- <_description>Logitech Access Keyboard</_description>
- <vendor>Logitech</vendor>
- </configItem>
- </model>
- <model>
- <configItem>
- <name>logiclx300</name>
- <_description>Logitech Cordless Desktop LX-300</_description>
- <vendor>Logitech</vendor>
- </configItem>
- </model>
- <model>
- <configItem>
- <name>logii350</name>
- <_description>Logitech Internet 350 Keyboard</_description>
- <vendor>Logitech</vendor>
- </configItem>
- </model>
- <model>
- <configItem>
- <name>logimel</name>
- <_description>Logitech Media Elite Keyboard</_description>
- <vendor>Logitech</vendor>
- </configItem>
- </model>
- <model>
- <configItem>
- <name>logicd</name>
- <_description>Logitech Cordless Desktop</_description>
- <vendor>Logitech</vendor>
- </configItem>
- </model>
- <model>
- <configItem>
- <name>logicd_it</name>
- <_description>Logitech Cordless Desktop iTouch</_description>
- <vendor>Logitech</vendor>
- </configItem>
- </model>
- <model>
- <configItem>
- <name>logicd_nav</name>
- <_description>Logitech Cordless Desktop Navigator</_description>
- <vendor>Logitech</vendor>
- </configItem>
- </model>
- <model>
- <configItem>
- <name>logicd_opt</name>
- <_description>Logitech Cordless Desktop Optical</_description>
- <vendor>Logitech</vendor>
- </configItem>
- </model>
- <model>
- <configItem>
- <name>logicda</name>
- <_description>Logitech Cordless Desktop (alternate option)</_description>
- <vendor>Logitech</vendor>
- </configItem>
- </model>
- <model>
- <configItem>
- <name>logicdpa2</name>
- <_description>Logitech Cordless Desktop Pro (alternate option 2)</_description>
- <vendor>Logitech</vendor>
- </configItem>
- </model>
- <model>
- <configItem>
- <name>logicfn</name>
- <_description>Logitech Cordless Freedom/Desktop Navigator</_description>
- <vendor>Logitech</vendor>
- </configItem>
- </model>
- <model>
- <configItem>
- <name>logicdn</name>
- <_description>Logitech Cordless Desktop Navigator</_description>
- <vendor>Logitech</vendor>
- </configItem>
- </model>
- <model>
- <configItem>
- <name>logiitc</name>
- <_description>Logitech iTouch Cordless Keyboard (model Y-RB6)</_description>
- <vendor>Logitech</vendor>
- </configItem>
- </model>
- <model>
- <configItem>
- <name>logiik</name>
- <_description>Logitech Internet Keyboard</_description>
- <vendor>Logitech</vendor>
- </configItem>
- </model>
- <model>
- <configItem>
- <name>itouch</name>
- <_description>Logitech iTouch</_description>
- <vendor>Logitech</vendor>
- </configItem>
- </model>
- <model>
- <configItem>
- <name>logicink</name>
- <_description>Logitech Internet Navigator Keyboard</_description>
- <vendor>Logitech</vendor>
- </configItem>
- </model>
- <model>
- <configItem>
- <name>logiex110</name>
- <_description>Logitech Cordless Desktop EX110</_description>
- <vendor>Logitech</vendor>
- </configItem>
- </model>
- <model>
- <configItem>
- <name>logiinkse</name>
- <_description>Logitech iTouch Internet Navigator Keyboard SE</_description>
- <vendor>Logitech</vendor>
- </configItem>
- </model>
- <model>
- <configItem>
- <name>logiinkseusb</name>
- <_description>Logitech iTouch Internet Navigator Keyboard SE (USB)</_description>
- <vendor>Logitech</vendor>
- </configItem>
- </model>
- <model>
- <configItem>
- <name>logiultrax</name>
- <_description>Logitech Ultra-X Keyboard</_description>
- <vendor>Logitech</vendor>
- </configItem>
- </model>
- <model>
- <configItem>
- <name>logiultraxc</name>
- <_description>Logitech Ultra-X Cordless Media Desktop Keyboard</_description>
- <vendor>Logitech</vendor>
- </configItem>
- </model>
- <model>
- <configItem>
- <name>logidinovo</name>
- <_description>Logitech diNovo Keyboard</_description>
- <vendor>Logitech</vendor>
- </configItem>
- </model>
- <model>
- <configItem>
- <name>logidinovoedge</name>
- <_description>Logitech diNovo Edge Keyboard</_description>
- <vendor>Logitech</vendor>
- </configItem>
- </model>
- <model>
- <configItem>
- <name>mx1998</name>
- <_description>Memorex MX1998</_description>
- <vendor>Memorex</vendor>
- </configItem>
- </model>
- <model>
- <configItem>
- <name>mx2500</name>
- <_description>Memorex MX2500 EZ-Access Keyboard</_description>
- <vendor>Memorex</vendor>
- </configItem>
- </model>
- <model>
- <configItem>
- <name>mx2750</name>
- <_description>Memorex MX2750</_description>
- <vendor>Memorex</vendor>
- </configItem>
- </model>
- <model>
- <configItem>
- <name>microsoft7000</name>
- <_description>Microsoft Natural Wireless Ergonomic Keyboard 7000</_description>
- <vendor>Microsoft Inc.</vendor>
- </configItem>
- </model>
- <model>
- <configItem>
- <name>microsoftinet</name>
- <_description>Microsoft Internet Keyboard</_description>
- <vendor>Microsoft Inc.</vendor>
- </configItem>
- </model>
- <model>
- <configItem>
- <name>microsoftpro</name>
- <_description>Microsoft Natural Keyboard Pro / Microsoft Internet Keyboard Pro</_description>
- <vendor>Microsoft Inc.</vendor>
- </configItem>
- </model>
- <model>
- <configItem>
- <name>microsoftprousb</name>
- <_description>Microsoft Natural Keyboard Pro USB / Microsoft Internet Keyboard Pro</_description>
- <vendor>Microsoft Inc.</vendor>
- </configItem>
- </model>
- <model>
- <configItem>
- <name>microsoftprooem</name>
- <_description>Microsoft Natural Keyboard Pro OEM</_description>
- <vendor>Microsoft Inc.</vendor>
- </configItem>
- </model>
- <model>
- <configItem>
- <name>vsonku306</name>
- <_description>ViewSonic KU-306 Internet Keyboard</_description>
- <vendor>ViewSonic</vendor>
- </configItem>
- </model>
- <model>
- <configItem>
- <name>microsoftprose</name>
- <_description>Microsoft Internet Keyboard Pro, Swedish</_description>
- <vendor>Microsoft Inc.</vendor>
- </configItem>
- </model>
- <model>
- <configItem>
- <name>microsoftoffice</name>
- <_description>Microsoft Office Keyboard</_description>
- <vendor>Microsoft Inc.</vendor>
- </configItem>
- </model>
- <model>
- <configItem>
- <name>microsoftmult</name>
- <_description>Microsoft Wireless Multimedia Keyboard 1.0A</_description>
- <vendor>Microsoft Inc.</vendor>
- </configItem>
- </model>
- <model>
- <configItem>
- <name>microsoftelite</name>
- <_description>Microsoft Natural Keyboard Elite</_description>
- <vendor>Microsoft Inc.</vendor>
- </configItem>
- </model>
- <model>
- <configItem>
- <name>microsoftccurve2k</name>
- <_description>Microsoft Comfort Curve Keyboard 2000</_description>
- <vendor>Microsoft Inc.</vendor>
- </configItem>
- </model>
- <model>
- <configItem>
- <name>oretec</name>
- <_description>Ortek MCK-800 MM/Internet keyboard</_description>
- <vendor>Ortek</vendor>
- </configItem>
- </model>
- <model>
- <configItem>
- <name>propeller</name>
- <_description>Propeller Voyager (KTEZ-1000)</_description>
- <vendor>KeyTronic</vendor>
- </configItem>
- </model>
- <model>
- <configItem>
- <name>qtronix</name>
- <_description>QTronix Scorpius 98N+</_description>
- <vendor>QTronix</vendor>
- </configItem>
- </model>
- <model>
- <configItem>
- <name>samsung4500</name>
- <_description>Samsung SDM 4500P</_description>
- <vendor>Samsung</vendor>
- </configItem>
- </model>
- <model>
- <configItem>
- <name>samsung4510</name>
- <_description>Samsung SDM 4510P</_description>
- <vendor>Samsung</vendor>
- </configItem>
- </model>
- <model>
- <configItem>
- <name>sanwaskbkg3</name>
- <description>Sanwa Supply SKB-KG3</description>
- <vendor>Sanwa Supply Inc.</vendor>
- </configItem>
- </model>
- <model>
- <configItem>
- <name>sk1300</name>
- <_description>SK-1300</_description>
- <vendor>NEC</vendor>
- </configItem>
- </model>
- <model>
- <configItem>
- <name>sk2500</name>
- <_description>SK-2500</_description>
- <vendor>NEC</vendor>
- </configItem>
- </model>
- <model>
- <configItem>
- <name>sk6200</name>
- <_description>SK-6200</_description>
- <vendor>NEC</vendor>
- </configItem>
- </model>
- <model>
- <configItem>
- <name>sk7100</name>
- <_description>SK-7100</_description>
- <vendor>NEC</vendor>
- </configItem>
- </model>
- <model>
- <configItem>
- <name>sp_inet</name>
- <_description>Super Power Multimedia Keyboard</_description>
- <vendor>Generic</vendor>
- </configItem>
- </model>
- <model>
- <configItem>
- <name>sven</name>
- <_description>SVEN Ergonomic 2500</_description>
- <vendor>SVEN</vendor>
- </configItem>
- </model>
- <model>
- <configItem>
- <name>sven303</name>
- <_description>SVEN Slim 303</_description>
- <vendor>SVEN</vendor>
- </configItem>
- </model>
- <model>
- <configItem>
- <name>symplon</name>
- <_description>Symplon PaceBook (tablet PC)</_description>
- <vendor>Symplon</vendor>
- </configItem>
- </model>
- <model>
- <configItem>
- <name>toshiba_s3000</name>
- <_description>Toshiba Satellite S3000</_description>
- <vendor>Toshiba</vendor>
- </configItem>
- </model>
- <model>
- <configItem>
- <name>trust</name>
- <_description>Trust Wireless Keyboard Classic</_description>
- <vendor>Trust</vendor>
- </configItem>
- </model>
- <model>
- <configItem>
- <name>trustda</name>
- <_description>Trust Direct Access Keyboard</_description>
- <vendor>Trust</vendor>
- </configItem>
- </model>
- <model>
- <configItem>
- <name>trust_slimline</name>
- <_description>Trust Slimline</_description>
- <vendor>Trust</vendor>
- </configItem>
- </model>
- <model>
- <configItem>
- <name>tm2020</name>
- <_description>TypeMatrix EZ-Reach 2020</_description>
- <vendor>TypeMatrix</vendor>
- </configItem>
- </model>
- <model>
- <configItem>
- <name>tm2030PS2</name>
- <_description>TypeMatrix EZ-Reach 2030 PS2</_description>
- <vendor>TypeMatrix</vendor>
- </configItem>
- </model>
- <model>
- <configItem>
- <name>tm2030USB</name>
- <_description>TypeMatrix EZ-Reach 2030 USB</_description>
- <vendor>TypeMatrix</vendor>
- </configItem>
- </model>
- <model>
- <configItem>
- <name>tm2030USB-102</name>
- <_description>TypeMatrix EZ-Reach 2030 USB (102/105:EU mode)</_description>
- <vendor>TypeMatrix</vendor>
- </configItem>
- </model>
- <model>
- <configItem>
- <name>tm2030USB-106</name>
- <_description>TypeMatrix EZ-Reach 2030 USB (106:JP mode)</_description>
- <vendor>TypeMatrix</vendor>
- </configItem>
- </model>
- <model>
- <configItem>
- <name>yahoo</name>
- <_description>Yahoo! Internet Keyboard</_description>
- <vendor>Yahoo!</vendor>
- </configItem>
- </model>
- <model>
- <configItem>
- <name>macbook78</name>
- <_description>MacBook/MacBook Pro</_description>
- <vendor>Apple</vendor>
- </configItem>
- </model>
- <model>
- <configItem>
- <name>macbook79</name>
- <_description>MacBook/MacBook Pro (Intl)</_description>
- <vendor>Apple</vendor>
- </configItem>
- </model>
- <model>
- <configItem>
- <name>macintosh</name>
- <_description>Macintosh</_description>
- <vendor>Apple</vendor>
- </configItem>
- </model>
- <model>
- <configItem>
- <name>macintosh_old</name>
- <_description>Macintosh Old</_description>
- <vendor>Apple</vendor>
- </configItem>
- </model>
- <model>
- <configItem>
- <name>macintosh_hhk</name>
- <_description>Happy Hacking Keyboard for Mac</_description>
- <vendor>Fujitsu</vendor>
- </configItem>
- </model>
- <model>
- <configItem>
- <name>acer_c300</name>
- <_description>Acer C300</_description>
- <vendor>Acer</vendor>
- </configItem>
- </model>
- <model>
- <configItem>
- <name>acer_ferrari4k</name>
- <_description>Acer Ferrari 4000</_description>
- <vendor>Acer</vendor>
- </configItem>
- </model>
- <model>
- <configItem>
- <name>acer_laptop</name>
- <_description>Acer Laptop</_description>
- <vendor>Acer</vendor>
- </configItem>
- </model>
- <model>
- <configItem>
- <name>asus_laptop</name>
- <_description>Asus Laptop</_description>
- <vendor>Asus</vendor>
- </configItem>
- </model>
- <model>
- <configItem>
- <name>apple</name>
- <_description>Apple</_description>
- <vendor>Apple</vendor>
- </configItem>
- </model>
- <model>
- <configItem>
- <name>apple_laptop</name>
- <_description>Apple Laptop</_description>
- <vendor>Apple</vendor>
- </configItem>
- </model>
- <model>
- <configItem>
- <name>applealu_ansi</name>
- <_description>Apple Aluminium Keyboard (ANSI)</_description>
- <vendor>Apple</vendor>
- </configItem>
- </model>
- <model>
- <configItem>
- <name>applealu_iso</name>
- <_description>Apple Aluminium Keyboard (ISO)</_description>
- <vendor>Apple</vendor>
- </configItem>
- </model>
- <model>
- <configItem>
- <name>applealu_jis</name>
- <_description>Apple Aluminium Keyboard (JIS)</_description>
- <vendor>Apple</vendor>
- </configItem>
- </model>
- <model>
- <configItem>
- <name>silvercrest</name>
- <_description>SILVERCREST Multimedia Wireless Keyboard</_description>
- <vendor>Silvercrest</vendor>
- </configItem>
- </model>
- <model>
- <configItem>
- <name>emachines</name>
- <_description>Laptop/notebook eMachines m68xx</_description>
- <vendor>eMachines</vendor>
- </configItem>
- </model>
- <model>
- <configItem>
- <name>benqx</name>
- <_description>BenQ X-Touch</_description>
- <vendor>BenQ</vendor>
- </configItem>
- </model>
- <model>
- <configItem>
- <name>benqx730</name>
- <_description>BenQ X-Touch 730</_description>
- <vendor>BenQ</vendor>
- </configItem>
- </model>
- <model>
- <configItem>
- <name>benqx800</name>
- <_description>BenQ X-Touch 800</_description>
- <vendor>BenQ</vendor>
- </configItem>
- </model>
- <model>
- <configItem>
- <name>hhk</name>
- <_description>Happy Hacking Keyboard</_description>
- <vendor>Fujitsu</vendor>
- </configItem>
- </model>
- <model>
- <configItem>
- <name>classmate</name>
- <_description>Classmate PC</_description>
- <vendor>Intel</vendor>
- </configItem>
- </model>
- <model>
- <configItem>
- <name>olpc</name>
- <_description>OLPC</_description>
- <vendor>OLPC</vendor>
- </configItem>
- </model>
- <model>
- <configItem>
- <name>sun6</name>
- <_description>Sun Type 5/6</_description>
- <vendor>Sun Microsystems</vendor>
- </configItem>
- </model>
- <model>
- <configItem>
- <name>targa_v811</name>
- <_description>Targa Visionary 811</_description>
- <vendor>Targa</vendor>
- </configItem>
- </model>
- <model>
- <configItem>
- <name>unitekkb1925</name>
- <_description>Unitek KB-1925</_description>
- <vendor>Unitek Group</vendor>
- </configItem>
- </model>
- <model>
- <configItem>
- <name>compalfl90</name>
- <_description>FL90</_description>
- <vendor>Compal Electronics Inc.</vendor>
- </configItem>
- </model>
- <model>
- <configItem>
- <name>creativedw7000</name>
- <_description>Creative Desktop Wireless 7000</_description>
- <vendor>Creative</vendor>
- </configItem>
- </model>
- <model>
- <configItem>
- <name>htcdream</name>
- <_description>Htc Dream phone</_description>
- <vendor>htc</vendor>
- </configItem>
- </model>
- </modelList>
- <layoutList>
- <layout>
- <configItem>
- <name>us</name>
- <_shortDescription>USA</_shortDescription>
- <_description>USA</_description>
- <languageList><iso639Id>eng</iso639Id></languageList>
- </configItem>
- <variantList>
- <variant>
- <configItem>
- <name>chr</name>
- <_description>Cherokee</_description>
- <languageList><iso639Id>chr</iso639Id></languageList>
- </configItem>
- </variant>
- <variant>
- <configItem>
- <name>euro</name>
- <_description>With EuroSign on 5</_description>
- </configItem>
- </variant>
- <variant>
- <configItem>
- <name>intl</name>
- <_description>International (with dead keys)</_description>
- </configItem>
- </variant>
- <variant>
- <configItem>
- <name>alt-intl</name>
- <_description>Alternative international</_description>
- </configItem>
- </variant>
- <variant>
- <configItem>
- <name>colemak</name>
- <_description>Colemak</_description>
- </configItem>
- </variant>
- <variant>
- <configItem>
- <name>dvorak</name>
- <_description>Dvorak</_description>
- </configItem>
- </variant>
- <variant>
- <configItem>
- <name>dvorak-intl</name>
- <_description>Dvorak international (with dead keys)</_description>
- </configItem>
- </variant>
- <variant>
- <configItem>
- <name>dvorak-alt-intl</name>
- <_description>Dvorak alternative international (no dead keys)</_description>
- </configItem>
- </variant>
- <variant>
- <configItem>
- <name>dvorak-l</name>
- <_description>Left handed Dvorak</_description>
- </configItem>
- </variant>
- <variant>
- <configItem>
- <name>dvorak-r</name>
- <_description>Right handed Dvorak</_description>
- </configItem>
- </variant>
- <variant>
- <configItem>
- <name>dvorak-classic</name>
- <_description>Classic Dvorak</_description>
- </configItem>
- </variant>
- <variant>
- <configItem>
- <name>dvp</name>
- <_description>Programmer Dvorak</_description>
- </configItem>
- </variant>
- <variant>
- <configItem>
- <name>rus</name>
- <_description>Russian phonetic</_description>
- <languageList><iso639Id>rus</iso639Id></languageList>
- </configItem>
- </variant>
- <variant>
- <configItem>
- <name>mac</name>
- <_description>Macintosh</_description>
- </configItem>
- </variant>
- <variant>
- <configItem>
- <name>altgr-intl</name>
- <_description>International (AltGr dead keys)</_description>
- <languageList><iso639Id>eng</iso639Id>
- <iso639Id>fra</iso639Id>
- <iso639Id>ger</iso639Id></languageList>
- </configItem>
- </variant>
- <variant>
- <configItem>
- <name>olpc2</name>
- <_description>Layout toggle on multiply/divide key</_description>
- </configItem>
- </variant>
- <variant>
- <configItem>
- <name>srp</name>
- <_description>Serbian</_description>
- <languageList><iso639Id>eng</iso639Id>
- <iso639Id>srp</iso639Id> </languageList>
- </configItem>
- </variant>
- </variantList>
- </layout>
- <layout>
- <configItem>
- <name>ad</name>
- <_shortDescription>And</_shortDescription>
- <_description>Andorra</_description>
- <languageList><iso639Id>cat</iso639Id></languageList>
- </configItem>
- <variantList/>
- </layout>
- <layout>
- <configItem>
- <name>af</name>
- <_shortDescription>Afg</_shortDescription>
- <_description>Afghanistan</_description>
- </configItem>
- <variantList>
- <variant>
- <configItem>
- <name>ps</name>
- <_description>Pashto</_description>
- <languageList><iso639Id>pus</iso639Id></languageList>
- </configItem>
- </variant>
- <variant>
- <configItem>
- <name>uz</name>
- <_description>Southern Uzbek</_description>
- <languageList><iso639Id>uzb</iso639Id></languageList>
- </configItem>
- </variant>
- <variant>
- <configItem>
- <name>olpc-ps</name>
- <_description>OLPC Pashto</_description>
- <languageList><iso639Id>pus</iso639Id></languageList>
- </configItem>
- </variant>
- <variant>
- <configItem>
- <name>olpc-fa</name>
- <_description>OLPC Dari</_description>
- <!-- No ISO code in ISO639-2, only draft ISO693-3 -->
- </configItem>
- </variant>
- <variant>
- <configItem>
- <name>olpc-uz</name>
- <_description>OLPC Southern Uzbek</_description>
- <languageList><iso639Id>uzb</iso639Id></languageList>
- </configItem>
- </variant>
- </variantList>
- </layout>
- <layout>
- <configItem>
- <name>ara</name>
- <_shortDescription>Ara</_shortDescription>
- <_description>Arabic</_description>
- <countryList>
- <iso3166Id>AE</iso3166Id>
- <iso3166Id>BH</iso3166Id>
- <iso3166Id>DZ</iso3166Id>
- <iso3166Id>EG</iso3166Id>
- <iso3166Id>EH</iso3166Id>
- <iso3166Id>JO</iso3166Id>
- <iso3166Id>KW</iso3166Id>
- <iso3166Id>LB</iso3166Id>
- <iso3166Id>LY</iso3166Id>
- <iso3166Id>MA</iso3166Id>
- <iso3166Id>MR</iso3166Id>
- <iso3166Id>OM</iso3166Id>
- <iso3166Id>PS</iso3166Id>
- <iso3166Id>QA</iso3166Id>
- <iso3166Id>SA</iso3166Id>
- <iso3166Id>SD</iso3166Id>
- <iso3166Id>SY</iso3166Id>
- <iso3166Id>TN</iso3166Id>
- <iso3166Id>YE</iso3166Id>
- </countryList>
- <languageList><iso639Id>ara</iso639Id></languageList>
- </configItem>
- <variantList>
- <variant>
- <configItem>
- <name>azerty</name>
- <_description>azerty</_description>
- </configItem>
- </variant>
- <variant>
- <configItem>
- <name>azerty_digits</name>
- <_description>azerty/digits</_description>
- </configItem>
- </variant>
- <variant>
- <configItem>
- <name>digits</name>
- <_description>digits</_description>
- </configItem>
- </variant>
- <variant>
- <configItem>
- <name>qwerty</name>
- <_description>qwerty</_description>
- </configItem>
- </variant>
- <variant>
- <configItem>
- <name>qwerty_digits</name>
- <_description>qwerty/digits</_description>
- </configItem>
- </variant>
- <variant>
- <configItem>
- <name>buckwalter</name>
- <_description>Buckwalter</_description>
- </configItem>
- </variant>
- </variantList>
- </layout>
- <layout>
- <configItem>
- <name>al</name>
- <_shortDescription>Alb</_shortDescription>
- <_description>Albania</_description>
- <languageList><iso639Id>alb</iso639Id></languageList>
- </configItem>
- <variantList/>
- </layout>
- <layout>
- <configItem>
- <name>am</name>
- <_shortDescription>Arm</_shortDescription>
- <_description>Armenia</_description>
- <languageList><iso639Id>hye</iso639Id></languageList>
- </configItem>
- <variantList>
- <variant>
- <configItem>
- <name>phonetic</name>
- <_description>Phonetic</_description>
- </configItem>
- </variant>
- <variant>
- <configItem>
- <name>phonetic-alt</name>
- <_description>Alternative Phonetic</_description>
- </configItem>
- </variant>
- <variant>
- <configItem>
- <name>eastern</name>
- <_description>Eastern</_description>
- </configItem>
- </variant>
- <variant>
- <configItem>
- <name>western</name>
- <_description>Western</_description>
- </configItem>
- </variant>
- <variant>
- <configItem>
- <name>eastern-alt</name>
- <_description>Alternative Eastern</_description>
- </configItem>
- </variant>
- </variantList>
- </layout>
- <layout>
- <configItem>
- <name>at</name>
- <_shortDescription>Aut</_shortDescription>
- <_description>Austria</_description>
- <languageList><iso639Id>ger</iso639Id></languageList>
- </configItem>
- <variantList>
- <variant>
- <configItem>
- <name>nodeadkeys</name>
- <_description>Eliminate dead keys</_description>
- </configItem>
- </variant>
- <variant>
- <configItem>
- <name>sundeadkeys</name>
- <_description>Sun dead keys</_description>
- </configItem>
- </variant>
- <variant>
- <configItem>
- <name>mac</name>
- <_description>Macintosh</_description>
- </configItem>
- </variant>
- </variantList>
- </layout>
- <layout>
- <configItem>
- <name>az</name>
- <_shortDescription>Aze</_shortDescription>
- <_description>Azerbaijan</_description>
- <languageList><iso639Id>aze</iso639Id></languageList>
- </configItem>
- <variantList>
- <variant>
- <configItem>
- <name>cyrillic</name>
- <_description>Cyrillic</_description>
- </configItem>
- </variant>
- </variantList>
- </layout>
- <layout>
- <configItem>
- <name>by</name>
- <_shortDescription>Blr</_shortDescription>
- <_description>Belarus</_description>
- <languageList><iso639Id>bel</iso639Id></languageList>
- </configItem>
- <variantList>
- <variant>
- <configItem>
- <name>legacy</name>
- <_description>Legacy</_description>
- </configItem>
- </variant>
- <variant>
- <configItem>
- <name>latin</name>
- <_description>Latin</_description>
- </configItem>
- </variant>
- </variantList>
- </layout>
- <layout>
- <configItem>
- <name>be</name>
- <_shortDescription>Bel</_shortDescription>
- <_description>Belgium</_description>
- <languageList><iso639Id>ger</iso639Id>
- <iso639Id>nld</iso639Id>
- <iso639Id>fra</iso639Id></languageList>
- </configItem>
- <variantList>
- <variant>
- <configItem>
- <name>oss</name>
- <_description>Alternative</_description>
- </configItem>
- </variant>
- <variant>
- <configItem>
- <name>oss_latin9</name>
- <_description>Alternative, latin-9 only</_description>
- </configItem>
- </variant>
- <variant>
- <configItem>
- <name>oss_sundeadkeys</name>
- <_description>Alternative, Sun dead keys</_description>
- </configItem>
- </variant>
- <variant>
- <configItem>
- <name>iso-alternate</name>
- <_description>ISO Alternate</_description>
- </configItem>
- </variant>
- <variant>
- <configItem>
- <name>nodeadkeys</name>
- <_description>Eliminate dead keys</_description>
- </configItem>
- </variant>
- <variant>
- <configItem>
- <name>sundeadkeys</name>
- <_description>Sun dead keys</_description>
- </configItem>
- </variant>
- <variant>
- <configItem>
- <name>wang</name>
- <_description>Wang model 724 azerty</_description>
- </configItem>
- </variant>
- </variantList>
- </layout>
- <layout>
- <configItem>
- <name>bd</name>
- <_shortDescription>Bgd</_shortDescription>
- <_description>Bangladesh</_description>
- <languageList><iso639Id>ben</iso639Id></languageList>
- </configItem>
- <variantList>
- <variant>
- <configItem>
- <name>probhat</name>
- <_description>Probhat</_description>
- </configItem>
- </variant>
- </variantList>
- </layout>
- <layout>
- <configItem>
- <name>in</name>
- <_shortDescription>Ind</_shortDescription>
- <_description>India</_description>
- </configItem>
- <variantList>
- <variant>
- <configItem>
- <name>ben</name>
- <_description>Bengali</_description>
- <languageList><iso639Id>ben</iso639Id></languageList>
- </configItem>
- </variant>
- <variant>
- <configItem>
- <name>ben_probhat</name>
- <_description>Bengali Probhat</_description>
- <languageList><iso639Id>ben</iso639Id></languageList>
- </configItem>
- </variant>
- <variant>
- <configItem>
- <name>guj</name>
- <_description>Gujarati</_description>
- <languageList><iso639Id>guj</iso639Id></languageList>
- </configItem>
- </variant>
- <variant>
- <configItem>
- <name>guru</name>
- <_description>Gurmukhi</_description>
- <languageList><iso639Id>pan</iso639Id></languageList>
- </configItem>
- </variant>
- <variant>
- <configItem>
- <name>jhelum</name>
- <_description>Gurmukhi Jhelum</_description>
- <languageList><iso639Id>pan</iso639Id></languageList>
- </configItem>
- </variant>
- <variant>
- <configItem>
- <name>kan</name>
- <_description>Kannada</_description>
- <languageList><iso639Id>kan</iso639Id></languageList>
- </configItem>
- </variant>
- <variant>
- <configItem>
- <name>mal</name>
- <_description>Malayalam</_description>
- <languageList><iso639Id>mal</iso639Id></languageList>
- </configItem>
- </variant>
- <variant>
- <configItem>
- <name>mal_lalitha</name>
- <_description>Malayalam Lalitha</_description>
- <languageList><iso639Id>mal</iso639Id></languageList>
- </configItem>
- </variant>
- <variant>
- <configItem>
- <name>ori</name>
- <_description>Oriya</_description>
- <languageList><iso639Id>ori</iso639Id></languageList>
- </configItem>
- </variant>
- <variant>
- <configItem>
- <name>tam_unicode</name>
- <_description>Tamil Unicode</_description>
- <languageList><iso639Id>tam</iso639Id></languageList>
- </configItem>
- </variant>
- <variant>
- <configItem>
- <name>tam_keyboard_with_numerals</name>
- <_description>Tamil Keyboard with Numerals</_description>
- <languageList><iso639Id>tam</iso639Id></languageList>
- </configItem>
- </variant>
- <variant>
- <configItem>
- <name>tam_TAB</name>
- <_description>Tamil TAB Typewriter</_description>
- <languageList><iso639Id>tam</iso639Id></languageList>
- </configItem>
- </variant>
- <variant>
- <configItem>
- <name>tam_TSCII</name>
- <_description>Tamil TSCII Typewriter</_description>
- <languageList><iso639Id>tam</iso639Id></languageList>
- </configItem>
- </variant>
- <variant>
- <configItem>
- <name>tam</name>
- <_description>Tamil</_description>
- <languageList><iso639Id>tam</iso639Id></languageList>
- </configItem>
- </variant>
- <variant>
- <configItem>
- <name>tel</name>
- <_description>Telugu</_description>
- <languageList><iso639Id>tel</iso639Id></languageList>
- </configItem>
- </variant>
- <variant>
- <configItem>
- <name>urd-phonetic</name>
- <_description>Urdu, Phonetic</_description>
- <languageList><iso639Id>urd</iso639Id></languageList>
- </configItem>
- </variant>
- <variant>
- <configItem>
- <name>urd-phonetic3</name>
- <_description>Urdu, Alternative phonetic</_description>
- <languageList><iso639Id>urd</iso639Id></languageList>
- </configItem>
- </variant>
- <variant>
- <configItem>
- <name>urd-winkeys</name>
- <_description>Urdu, Winkeys</_description>
- <languageList><iso639Id>urd</iso639Id></languageList>
- </configItem>
- </variant>
- <variant>
- <configItem>
- <name>bolnagri</name>
- <_description>Hindi Bolnagri</_description>
- <languageList><iso639Id>hin</iso639Id></languageList>
- </configItem>
- </variant>
- <variant>
- <configItem>
- <name>hin-wx</name>
- <_description>Hindi Wx</_description>
- <languageList><iso639Id>hin</iso639Id></languageList>
- </configItem>
- </variant>
- <variant>
- <configItem>
- <name>eng</name>
- <_description>English with RupeeSign</_description>
- <languageList><iso639Id>eng</iso639Id></languageList>
- </configItem>
- </variant>
- </variantList>
- </layout>
- <layout>
- <configItem>
- <name>ba</name>
- <_shortDescription>Bih</_shortDescription>
- <_description>Bosnia and Herzegovina</_description>
- <languageList><iso639Id>bos</iso639Id></languageList>
- </configItem>
- <variantList>
- <variant>
- <configItem>
- <name>alternatequotes</name>
- <_description> Use guillemets for quotes</_description>
- </configItem>
- </variant>
- <variant>
- <configItem>
- <name>unicode</name>
- <_description>Use Bosnian digraphs</_description>
- </configItem>
- </variant>
- <variant>
- <configItem>
- <name>unicodeus</name>
- <_description>US keyboard with Bosnian digraphs</_description>
- </configItem>
- </variant>
- <variant>
- <configItem>
- <name>us</name>
- <_description>US keyboard with Bosnian letters</_description>
- </configItem>
- </variant>
- </variantList>
- </layout>
- <layout>
- <configItem>
- <name>br</name>
- <_shortDescription>Bra</_shortDescription>
- <_description>Brazil</_description>
- <languageList><iso639Id>por</iso639Id></languageList>
- </configItem>
- <variantList>
- <variant>
- <configItem>
- <name>nodeadkeys</name>
- <_description>Eliminate dead keys</_description>
- </configItem>
- </variant>
- <variant>
- <configItem>
- <name>dvorak</name>
- <_description>Dvorak</_description>
- </configItem>
- </variant>
- <variant>
- <configItem>
- <name>nativo</name>
- <_description>Nativo</_description>
- </configItem>
- </variant>
- <variant>
- <configItem>
- <name>nativo-us</name>
- <_description>Nativo for USA keyboards</_description>
- </configItem>
- </variant>
- <variant>
- <configItem>
- <name>nativo-epo</name>
- <_description>Nativo for Esperanto</_description>
- <languageList><iso639Id>epo</iso639Id></languageList>
- </configItem>
- </variant>
- </variantList>
- </layout>
- <layout>
- <configItem>
- <name>bg</name>
- <_shortDescription>Bgr</_shortDescription>
- <_description>Bulgaria</_description>
- <languageList><iso639Id>bul</iso639Id></languageList>
- </configItem>
- <variantList>
- <variant>
- <configItem>
- <name>phonetic</name>
- <_description>Traditional phonetic</_description>
- </configItem>
- </variant>
- </variantList>
- <variantList>
- <variant>
- <configItem>
- <name>bas_phonetic</name>
- <_description>New phonetic</_description>
- </configItem>
- </variant>
- </variantList>
- </layout>
- <layout>
- <configItem>
- <name>ma</name>
- <_description>Morocco</_description>
- </configItem>
- <variantList>
- <variant>
- <configItem>
- <name>french</name>
- <_description>French</_description>
- <languageList><iso639Id>fra</iso639Id></languageList>
- </configItem>
- </variant>
- <variant>
- <configItem>
- <name>tifinagh</name>
- <_description>Tifinagh</_description>
- <languageList><iso639Id>ber</iso639Id></languageList>
- </configItem>
- </variant>
- <variant>
- <configItem>
- <name>tifinagh-alt</name>
- <_description>Tifinagh alternative</_description>
- <languageList><iso639Id>ber</iso639Id></languageList>
- </configItem>
- </variant>
- <variant>
- <configItem>
- <name>tifinagh-alt-phonetic</name>
- <_description>Tifinagh alternative phonetic</_description>
- <languageList><iso639Id>ber</iso639Id></languageList>
- </configItem>
- </variant>
- <variant>
- <configItem>
- <name>tifinagh-extended</name>
- <_description>Tifinagh extended</_description>
- <languageList><iso639Id>ber</iso639Id></languageList>
- </configItem>
- </variant>
- <variant>
- <configItem>
- <name>tifinagh-phonetic</name>
- <_description>Tifinagh phonetic</_description>
- <languageList><iso639Id>ber</iso639Id></languageList>
- </configItem>
- </variant>
- <variant>
- <configItem>
- <name>tifinagh-extended-phonetic</name>
- <_description>Tifinagh extended phonetic</_description>
- <languageList><iso639Id>ber</iso639Id></languageList>
- </configItem>
- </variant>
- </variantList>
- </layout>
- <layout>
- <configItem>
- <name>mm</name>
- <_shortDescription>Mmr</_shortDescription>
- <_description>Myanmar</_description>
- <languageList><iso639Id>mya</iso639Id></languageList>
- </configItem>
- <variantList/>
- </layout>
- <layout>
- <configItem>
- <name>ca</name>
- <_shortDescription>Can</_shortDescription>
- <_description>Canada</_description>
- <languageList><iso639Id>fra</iso639Id></languageList>
- </configItem>
- <variantList>
- <variant>
- <configItem>
- <name>fr-dvorak</name>
- <_description>French Dvorak</_description>
- </configItem>
- </variant>
- <variant>
- <configItem>
- <name>fr-legacy</name>
- <_description>French (legacy)</_description>
- </configItem>
- </variant>
- <variant>
- <configItem>
- <name>multix</name>
- <_description>Multilingual</_description>
- </configItem>
- </variant>
- <variant>
- <configItem>
- <name>multi</name>
- <_description>Multilingual, first part</_description>
- </configItem>
- </variant>
- <variant>
- <configItem>
- <name>multi-2gr</name>
- <_description>Multilingual, second part</_description>
- </configItem>
- </variant>
- <variant>
- <configItem>
- <name>ike</name>
- <_description>Inuktitut</_description>
- <languageList><iso639Id>iku</iso639Id></languageList>
- </configItem>
- </variant>
- <variant>
- <configItem>
- <name>shs</name>
- <_description>Secwepemctsin</_description>
- <!-- No ISO code in ISO639-2, only draft ISO693-3 -->
- </configItem>
- </variant>
- <variant>
- <configItem>
- <name>kut</name>
- <_description>Ktunaxa</_description>
- </configItem>
- </variant>
- <variant>
- <configItem>
- <name>eng</name>
- <_description>English</_description>
- <languageList><iso639Id>eng</iso639Id></languageList>
- </configItem>
- </variant>
- </variantList>
- </layout>
- <layout>
- <configItem>
- <name>cd</name>
- <_shortDescription>COD</_shortDescription>
- <_description>Congo, Democratic Republic of the</_description>
- <languageList><iso639Id>fra</iso639Id></languageList>
- </configItem>
- <variantList/>
- </layout>
- <layout>
- <configItem>
- <name>cn</name>
- <_shortDescription>Chn</_shortDescription>
- <_description>China</_description>
- <languageList><iso639Id>chi</iso639Id></languageList>
- </configItem>
- <variantList>
- <variant>
- <configItem>
- <name>tib</name>
- <_description>Tibetan</_description>
- <languageList><iso639Id>tib</iso639Id></languageList>
- </configItem>
- </variant>
- <variant>
- <configItem>
- <name>tib_asciinum</name>
- <_description>Tibetan (with ASCII numerals)</_description>
- <languageList><iso639Id>tib</iso639Id></languageList>
- </configItem>
- </variant>
- </variantList>
- </layout>
- <layout>
- <configItem>
- <name>hr</name>
- <_shortDescription>Hrv</_shortDescription>
- <_description>Croatia</_description>
- <languageList><iso639Id>scr</iso639Id></languageList>
- </configItem>
- <variantList>
- <variant>
- <configItem>
- <name>alternatequotes</name>
- <_description>Use guillemets for quotes</_description>
- </configItem>
- </variant>
- <variant>
- <configItem>
- <name>unicode</name>
- <_description>Use Croatian digraphs</_description>
- </configItem>
- </variant>
- <variant>
- <configItem>
- <name>unicodeus</name>
- <_description>US keyboard with Croatian digraphs</_description>
- </configItem>
- </variant>
- <variant>
- <configItem>
- <name>us</name>
- <_description>US keyboard with Croatian letters</_description>
- </configItem>
- </variant>
- </variantList>
- </layout>
- <layout>
- <configItem>
- <name>cz</name>
- <_shortDescription>Cze</_shortDescription>
- <_description>Czechia</_description>
- <languageList><iso639Id>cze</iso639Id></languageList>
- </configItem>
- <variantList>
- <variant>
- <configItem>
- <name>bksl</name>
- <_description>With &lt;\|&gt; key</_description>
- </configItem>
- </variant>
- <variant>
- <configItem>
- <name>qwerty</name>
- <_description>qwerty</_description>
- </configItem>
- </variant>
- <variant>
- <configItem>
- <name>qwerty_bksl</name>
- <_description>qwerty, extended Backslash</_description>
- </configItem>
- </variant>
- <variant>
- <configItem>
- <name>ucw</name>
- <_description>UCW layout (accented letters only)</_description>
- </configItem>
- </variant>
- <variant>
- <configItem>
- <name>dvorak-ucw</name>
- <_description>US Dvorak with CZ UCW support</_description>
- </configItem>
- </variant>
- </variantList>
- </layout>
- <layout>
- <configItem>
- <name>dk</name>
- <_shortDescription>Dnk</_shortDescription>
- <_description>Denmark</_description>
- <languageList><iso639Id>dan</iso639Id></languageList>
- </configItem>
- <variantList>
- <variant>
- <configItem>
- <name>nodeadkeys</name>
- <_description>Eliminate dead keys</_description>
- </configItem>
- </variant>
- <variant>
- <configItem>
- <name>mac</name>
- <_description>Macintosh</_description>
- </configItem>
- </variant>
- <variant>
- <configItem>
- <name>mac_nodeadkeys</name>
- <_description>Macintosh, eliminate dead keys</_description>
- </configItem>
- </variant>
- <variant>
- <configItem>
- <name>dvorak</name>
- <_description>Dvorak</_description>
- </configItem>
- </variant>
- </variantList>
- </layout>
- <layout>
- <configItem>
- <name>nl</name>
- <_shortDescription>Nld</_shortDescription>
- <_description>Netherlands</_description>
- <languageList><iso639Id>nld</iso639Id></languageList>
- </configItem>
- <variantList>
- <variant>
- <configItem>
- <name>sundeadkeys</name>
- <_description>Sun dead keys</_description>
- </configItem>
- </variant>
- <variant>
- <configItem>
- <name>mac</name>
- <_description>Macintosh</_description>
- </configItem>
- </variant>
- <variant>
- <configItem>
- <name>std</name>
- <_description>Standard</_description>
- </configItem>
- </variant>
- </variantList>
- </layout>
- <layout>
- <configItem>
- <name>bt</name>
- <_shortDescription>Btn</_shortDescription>
- <_description>Bhutan</_description>
- <languageList><iso639Id>dzo</iso639Id></languageList>
- </configItem>
- </layout>
- <layout>
- <configItem>
- <name>ee</name>
- <_shortDescription>Est</_shortDescription>
- <_description>Estonia</_description>
- <languageList><iso639Id>est</iso639Id></languageList>
- </configItem>
- <variantList>
- <variant>
- <configItem>
- <name>nodeadkeys</name>
- <_description>Eliminate dead keys</_description>
- </configItem>
- </variant>
- <variant>
- <configItem>
- <name>dvorak</name>
- <_description>Dvorak</_description>
- </configItem>
- </variant>
- <variant>
- <configItem>
- <name>us</name>
- <_description>US keyboard with Estonian letters</_description>
- </configItem>
- </variant>
- </variantList>
- </layout>
- <layout>
- <configItem>
- <name>ir</name>
- <_shortDescription>Irn</_shortDescription>
- <_description>Iran</_description>
- <languageList><iso639Id>per</iso639Id></languageList>
- </configItem>
- <variantList>
- <variant>
- <configItem>
- <name>pes_keypad</name>
- <_description>Persian, with Persian Keypad</_description>
- </configItem>
- </variant>
- <variant>
- <configItem>
- <name>ku</name>
- <_description>Kurdish, Latin Q</_description>
- <languageList><iso639Id>kur</iso639Id></languageList>
- </configItem>
- </variant>
- <variant>
- <configItem>
- <name>ku_f</name>
- <_description>Kurdish, (F)</_description>
- <languageList><iso639Id>kur</iso639Id></languageList>
- </configItem>
- </variant>
- <variant>
- <configItem>
- <name>ku_alt</name>
- <_description>Kurdish, Latin Alt-Q</_description>
- <languageList><iso639Id>kur</iso639Id></languageList>
- </configItem>
- </variant>
- <variant>
- <configItem>
- <name>ku_ara</name>
- <_description>Kurdish, Arabic-Latin</_description>
- <languageList><iso639Id>kur</iso639Id></languageList>
- </configItem>
- </variant>
- </variantList>
- </layout>
- <layout>
- <configItem>
- <name>iq</name>
- <_shortDescription>Irq</_shortDescription>
- <_description>Iraq</_description>
- <languageList><iso639Id>ara</iso639Id>
- <iso639Id>kur</iso639Id></languageList>
- </configItem>
- <variantList>
- <variant>
- <configItem>
- <name>ku</name>
- <_description>Kurdish, Latin Q</_description>
- <languageList><iso639Id>kur</iso639Id></languageList>
- </configItem>
- </variant>
- <variant>
- <configItem>
- <name>ku_f</name>
- <_description>Kurdish, (F)</_description>
- <languageList><iso639Id>kur</iso639Id></languageList>
- </configItem>
- </variant>
- <variant>
- <configItem>
- <name>ku_alt</name>
- <_description>Kurdish, Latin Alt-Q</_description>
- <languageList><iso639Id>kur</iso639Id></languageList>
- </configItem>
- </variant>
- <variant>
- <configItem>
- <name>ku_ara</name>
- <_description>Kurdish, Arabic-Latin</_description>
- <languageList><iso639Id>kur</iso639Id></languageList>
- </configItem>
- </variant>
- </variantList>
- </layout>
- <layout>
- <configItem>
- <name>fo</name>
- <_shortDescription>Fro</_shortDescription>
- <_description>Faroe Islands</_description>
- <languageList><iso639Id>fao</iso639Id></languageList>
- </configItem>
- <variantList>
- <variant>
- <configItem>
- <name>nodeadkeys</name>
- <_description>Eliminate dead keys</_description>
- </configItem>
- </variant>
- </variantList>
- </layout>
- <layout>
- <configItem>
- <name>fi</name>
- <_shortDescription>Fin</_shortDescription>
- <_description>Finland</_description>
- <languageList><iso639Id>fin</iso639Id></languageList>
- </configItem>
- <variantList>
- <variant>
- <configItem>
- <name>classic</name>
- <_description>Classic</_description>
- </configItem>
- </variant>
- <variant>
- <configItem>
- <name>nodeadkeys</name>
- <_description>Classic, eliminate dead keys</_description>
- </configItem>
- </variant>
- <variant>
- <configItem>
- <name>smi</name>
- <_description>Northern Saami</_description>
- <languageList><iso639Id>smi</iso639Id>
- <iso639Id>sme</iso639Id></languageList>
- </configItem>
- </variant>
- <variant>
- <configItem>
- <name>mac</name>
- <_description>Macintosh</_description>
- </configItem>
- </variant>
- </variantList>
- </layout>
- <layout>
- <configItem>
- <name>fr</name>
- <_shortDescription>Fra</_shortDescription>
- <_description>France</_description>
- <languageList><iso639Id>fra</iso639Id></languageList>
- </configItem>
- <variantList>
- <variant>
- <configItem>
- <name>nodeadkeys</name>
- <_description>Eliminate dead keys</_description>
- </configItem>
- </variant>
- <variant>
- <configItem>
- <name>sundeadkeys</name>
- <_description>Sun dead keys</_description>
- </configItem>
- </variant>
- <variant>
- <configItem>
- <name>oss</name>
- <_description>Alternative</_description>
- </configItem>
- </variant>
- <variant>
- <configItem>
- <name>oss_latin9</name>
- <_description>Alternative, latin-9 only</_description>
- </configItem>
- </variant>
- <variant>
- <configItem>
- <name>oss_nodeadkeys</name>
- <_description>Alternative, eliminate dead keys</_description>
- </configItem>
- </variant>
- <variant>
- <configItem>
- <name>oss_sundeadkeys</name>
- <_description>Alternative, Sun dead keys</_description>
- </configItem>
- </variant>
- <variant>
- <configItem>
- <name>latin9</name>
- <_description>(Legacy) Alternative</_description>
- </configItem>
- </variant>
- <variant>
- <configItem>
- <name>latin9_nodeadkeys</name>
- <_description>(Legacy) Alternative, eliminate dead keys</_description>
- </configItem>
- </variant>
- <variant>
- <configItem>
- <name>latin9_sundeadkeys</name>
- <_description>(Legacy) Alternative, Sun dead keys</_description>
- </configItem>
- </variant>
- <variant>
- <configItem>
- <name>bepo</name>
- <_description>Bepo, ergonomic, Dvorak way</_description>
- </configItem>
- </variant>
- <variant>
- <configItem>
- <name>bepo_latin9</name>
- <_description>Bepo, ergonomic, Dvorak way, latin-9 only</_description>
- </configItem>
- </variant>
- <variant>
- <configItem>
- <name>dvorak</name>
- <_description>Dvorak</_description>
- </configItem>
- </variant>
- <variant>
- <configItem>
- <name>mac</name>
- <_description>Macintosh</_description>
- </configItem>
- </variant>
- <variant>
- <configItem>
- <name>bre</name>
- <_description>Breton</_description>
- </configItem>
- </variant>
- <variant>
- <configItem>
- <name>oci</name>
- <_description>Occitan</_description>
- <languageList><iso639Id>oci</iso639Id></languageList>
- </configItem>
- </variant>
- <variant>
- <configItem>
- <name>geo</name>
- <_description>Georgian AZERTY Tskapo</_description>
- <languageList><iso639Id>geo</iso639Id></languageList>
- </configItem>
- </variant>
- </variantList>
- </layout>
- <layout>
- <configItem>
- <name>gh</name>
- <_shortDescription>Gha</_shortDescription>
- <_description>Ghana</_description>
- <languageList><iso639Id>eng</iso639Id></languageList>
- </configItem>
- <variantList>
- <variant>
- <configItem>
- <name>generic</name>
- <_description>Multilingual</_description>
- </configItem>
- </variant>
- <variant>
- <configItem>
- <name>akan</name>
- <_description>Akan</_description>
- <languageList><iso639Id>aka</iso639Id></languageList>
- </configItem>
- </variant>
- <variant>
- <configItem>
- <name>ewe</name>
- <_description>Ewe</_description>
- <languageList><iso639Id>ewe</iso639Id></languageList>
- </configItem>
- </variant>
- <variant>
- <configItem>
- <name>fula</name>
- <_description>Fula</_description>
- <languageList><iso639Id>ful</iso639Id></languageList>
- </configItem>
- </variant>
- <variant>
- <configItem>
- <name>ga</name>
- <_description>Ga</_description>
- <languageList><iso639Id>gaa</iso639Id></languageList>
- </configItem>
- </variant>
- <variant>
- <configItem>
- <name>hausa</name>
- <_description>Hausa</_description>
- <languageList><iso639Id>hau</iso639Id></languageList>
- </configItem>
- </variant>
- <variant>
- <configItem>
- <name>avn</name>
- <_description>Avatime</_description>
- <languageList><iso639Id>avn</iso639Id></languageList>
- </configItem>
- </variant>
- <variant>
- <configItem>
- <name>gillbt</name>
- <_description>GILLBT</_description>
- </configItem>
- </variant>
- </variantList>
- </layout>
- <layout>
- <configItem>
- <name>gn</name>
- <_shortDescription>Gin</_shortDescription>
- <_description>Guinea</_description>
- <languageList><iso639Id>fra</iso639Id></languageList>
- </configItem>
- <variantList/>
- </layout>
- <layout>
- <configItem>
- <name>ge</name>
- <_shortDescription>Geo</_shortDescription>
- <_description>Georgia</_description>
- <languageList><iso639Id>geo</iso639Id></languageList>
- </configItem>
- <variantList>
- <variant>
- <configItem>
- <name>ergonomic</name>
- <_description>Ergonomic</_description>
- </configItem>
- </variant>
- <variant>
- <configItem>
- <name>mess</name>
- <_description>MESS</_description>
- </configItem>
- </variant>
- <variant>
- <configItem>
- <name>ru</name>
- <_description>Russian</_description>
- <languageList><iso639Id>rus</iso639Id></languageList>
- </configItem>
- </variant>
- <variant>
- <configItem>
- <name>os</name>
- <_description>Ossetian</_description>
- <languageList><iso639Id>oss</iso639Id></languageList>
- </configItem>
- </variant>
- </variantList>
- </layout>
- <layout>
- <configItem>
- <name>de</name>
- <_shortDescription>Deu</_shortDescription>
- <_description>Germany</_description>
- <languageList><iso639Id>ger</iso639Id></languageList>
- </configItem>
- <variantList>
- <variant>
- <configItem>
- <name>deadacute</name>
- <_description>Dead acute</_description>
- </configItem>
- </variant>
- <variant>
- <configItem>
- <name>deadgraveacute</name>
- <_description>Dead grave acute</_description>
- </configItem>
- </variant>
- <variant>
- <configItem>
- <name>nodeadkeys</name>
- <_description>Eliminate dead keys</_description>
- </configItem>
- </variant>
- <variant>
- <configItem>
- <name>ro</name>
- <_description>Romanian keyboard with German letters</_description>
- </configItem>
- </variant>
- <variant>
- <configItem>
- <name>ro_nodeadkeys</name>
- <_description>Romanian keyboard with German letters, eliminate dead keys</_description>
- </configItem>
- </variant>
- <variant>
- <configItem>
- <name>dvorak</name>
- <_description>Dvorak</_description>
- </configItem>
- </variant>
- <variant>
- <configItem>
- <name>sundeadkeys</name>
- <_description>Sun dead keys</_description>
- </configItem>
- </variant>
- <variant>
- <configItem>
- <name>neo</name>
- <_description>Neo 2</_description>
- </configItem>
- </variant>
- <variant>
- <configItem>
- <name>mac</name>
- <_description>Macintosh</_description>
- </configItem>
- </variant>
- <variant>
- <configItem>
- <name>mac_nodeadkeys</name>
- <_description>Macintosh, eliminate dead keys</_description>
- </configItem>
- </variant>
- <variant>
- <configItem>
- <name>dsb</name>
- <_description>Lower Sorbian</_description>
- <languageList><iso639Id>dsb</iso639Id></languageList>
- </configItem>
- </variant>
- <variant>
- <configItem>
- <name>dsb_qwertz</name>
- <_description>Lower Sorbian (qwertz)</_description>
- <languageList><iso639Id>dsb</iso639Id></languageList>
- </configItem>
- </variant>
- <variant>
- <configItem>
- <name>qwerty</name>
- <_description>qwerty</_description>
- </configItem>
- </variant>
- <variant>
- <configItem>
- <name>ru</name>
- <_description>Russian phonetic</_description>
- <languageList><iso639Id>rus</iso639Id></languageList>
- </configItem>
- </variant>
- </variantList>
- </layout>
- <layout>
- <configItem>
- <name>gr</name>
- <_shortDescription>Grc</_shortDescription>
- <_description>Greece</_description>
- <languageList><iso639Id>gre</iso639Id></languageList>
- </configItem>
- <variantList>
- <variant>
- <configItem>
- <name>simple</name>
- <_description>Simple</_description>
- </configItem>
- </variant>
- <variant>
- <configItem>
- <name>extended</name>
- <_description>Extended</_description>
- </configItem>
- </variant>
- <variant>
- <configItem>
- <name>nodeadkeys</name>
- <_description>Eliminate dead keys</_description>
- </configItem>
- </variant>
- <variant>
- <configItem>
- <name>polytonic</name>
- <_description>Polytonic</_description>
- </configItem>
- </variant>
- </variantList>
- </layout>
- <layout>
- <configItem>
- <name>hu</name>
- <_shortDescription>Hun</_shortDescription>
- <_description>Hungary</_description>
- <languageList><iso639Id>hun</iso639Id></languageList>
- </configItem>
- <variantList>
- <variant>
- <configItem>
- <name>standard</name>
- <_description>Standard</_description>
- </configItem>
- </variant>
- <variant>
- <configItem>
- <name>nodeadkeys</name>
- <_description>Eliminate dead keys</_description>
- </configItem>
- </variant>
- <variant>
- <configItem>
- <name>qwerty</name>
- <_description>qwerty</_description>
- </configItem>
- </variant>
-
- <!-- 101 keys -->
- <variant>
- <configItem>
- <name>101_qwertz_comma_dead</name>
- <_description>101/qwertz/comma/Dead keys</_description>
- </configItem>
- </variant>
- <variant>
- <configItem>
- <name>101_qwertz_comma_nodead</name>
- <_description>101/qwertz/comma/Eliminate dead keys</_description>
- </configItem>
- </variant>
- <variant>
- <configItem>
- <name>101_qwertz_dot_dead</name>
- <_description>101/qwertz/dot/Dead keys</_description>
- </configItem>
- </variant>
- <variant>
- <configItem>
- <name>101_qwertz_dot_nodead</name>
- <_description>101/qwertz/dot/Eliminate dead keys</_description>
- </configItem>
- </variant>
- <variant>
- <configItem>
- <name>101_qwerty_comma_dead</name>
- <_description>101/qwerty/comma/Dead keys</_description>
- </configItem>
- </variant>
- <variant>
- <configItem>
- <name>101_qwerty_comma_nodead</name>
- <_description>101/qwerty/comma/Eliminate dead keys</_description>
- </configItem>
- </variant>
- <variant>
- <configItem>
- <name>101_qwerty_dot_dead</name>
- <_description>101/qwerty/dot/Dead keys</_description>
- </configItem>
- </variant>
- <variant>
- <configItem>
- <name>101_qwerty_dot_nodead</name>
- <_description>101/qwerty/dot/Eliminate dead keys</_description>
- </configItem>
- </variant>
-
-
- <!-- 102 keys -->
- <variant>
- <configItem>
- <name>102_qwertz_comma_dead</name>
- <_description>102/qwertz/comma/Dead keys</_description>
- </configItem>
- </variant>
- <variant>
- <configItem>
- <name>102_qwertz_comma_nodead</name>
- <_description>102/qwertz/comma/Eliminate dead keys</_description>
- </configItem>
- </variant>
- <variant>
- <configItem>
- <name>102_qwertz_dot_dead</name>
- <_description>102/qwertz/dot/Dead keys</_description>
- </configItem>
- </variant>
- <variant>
- <configItem>
- <name>102_qwertz_dot_nodead</name>
- <_description>102/qwertz/dot/Eliminate dead keys</_description>
- </configItem>
- </variant>
- <variant>
- <configItem>
- <name>102_qwerty_comma_dead</name>
- <_description>102/qwerty/comma/Dead keys</_description>
- </configItem>
- </variant>
- <variant>
- <configItem>
- <name>102_qwerty_comma_nodead</name>
- <_description>102/qwerty/comma/Eliminate dead keys</_description>
- </configItem>
- </variant>
- <variant>
- <configItem>
- <name>102_qwerty_dot_dead</name>
- <_description>102/qwerty/dot/Dead keys</_description>
- </configItem>
- </variant>
- <variant>
- <configItem>
- <name>102_qwerty_dot_nodead</name>
- <_description>102/qwerty/dot/Eliminate dead keys</_description>
- </configItem>
- </variant>
- </variantList>
- </layout>
- <layout>
- <configItem>
- <name>is</name>
- <_shortDescription>Isl</_shortDescription>
- <_description>Iceland</_description>
- <languageList><iso639Id>ice</iso639Id></languageList>
- </configItem>
- <variantList>
- <variant>
- <configItem>
- <name>Sundeadkeys</name>
- <_description>Sun dead keys</_description>
- </configItem>
- </variant>
- <variant>
- <configItem>
- <name>nodeadkeys</name>
- <_description>Eliminate dead keys</_description>
- </configItem>
- </variant>
- <variant>
- <configItem>
- <name>mac</name>
- <_description>Macintosh</_description>
- </configItem>
- </variant>
- <variant>
- <configItem>
- <name>dvorak</name>
- <_description>Dvorak</_description>
- </configItem>
- </variant>
- </variantList>
- </layout>
- <layout>
- <configItem>
- <name>il</name>
- <_shortDescription>Isr</_shortDescription>
- <_description>Israel</_description>
- <languageList><iso639Id>heb</iso639Id></languageList>
- </configItem>
- <variantList>
- <variant>
- <configItem>
- <name>lyx</name>
- <_description>lyx</_description>
- </configItem>
- </variant>
- <variant>
- <configItem>
- <name>phonetic</name>
- <_description>Phonetic</_description>
- </configItem>
- </variant>
- <variant>
- <configItem>
- <name>biblical</name>
- <_description>Biblical Hebrew (Tiro)</_description>
- </configItem>
- </variant>
- </variantList>
- </layout>
- <layout>
- <configItem>
- <name>it</name>
- <_shortDescription>Ita</_shortDescription>
- <_description>Italy</_description>
- <languageList><iso639Id>ita</iso639Id></languageList>
- </configItem>
- <variantList>
- <variant>
- <configItem>
- <name>nodeadkeys</name>
- <_description>Eliminate dead keys</_description>
- </configItem>
- </variant>
- <variant>
- <configItem>
- <name>mac</name>
- <_description>Macintosh</_description>
- </configItem>
- </variant>
- <variant>
- <configItem>
- <name>us</name>
- <_description>US keyboard with Italian letters</_description>
- </configItem>
- </variant>
- <variant>
- <configItem>
- <name>geo</name>
- <_description>Georgian</_description>
- <languageList><iso639Id>geo</iso639Id></languageList>
- </configItem>
- </variant>
- </variantList>
- </layout>
- <layout>
- <configItem>
- <name>jp</name>
- <_shortDescription>Jpn</_shortDescription>
- <_description>Japan</_description>
- <languageList><iso639Id>jpn</iso639Id></languageList>
- </configItem>
- <variantList>
- <variant>
- <configItem>
- <name>kana</name>
- <_description>Kana</_description>
- </configItem>
- </variant>
- <variant>
- <configItem>
- <name>kana86</name>
- <_description>Kana 86</_description>
- </configItem>
- </variant>
- <variant>
- <configItem>
- <name>OADG109A</name>
- <_description>OADG 109A</_description>
- </configItem>
- </variant>
- <variant>
- <configItem>
- <name>mac</name>
- <_description>Macintosh</_description>
- </configItem>
- </variant>
- </variantList>
- </layout>
- <layout>
- <configItem>
- <name>kg</name>
- <_shortDescription>Kgz</_shortDescription>
- <_description>Kyrgyzstan</_description>
- <languageList><iso639Id>kir</iso639Id></languageList>
- </configItem>
- <variantList>
- <variant>
- <configItem>
- <name>phonetic</name>
- <_description>Phonetic</_description>
- </configItem>
- </variant>
- </variantList>
- </layout>
- <layout>
- <configItem>
- <name>kh</name>
- <_shortDescription>Khm</_shortDescription>
- <_description>Cambodia</_description>
- <languageList><iso639Id>khm</iso639Id></languageList>
- </configItem>
- <variantList/>
- </layout>
- <layout>
- <configItem>
- <name>kz</name>
- <_shortDescription>Kaz</_shortDescription>
- <_description>Kazakhstan</_description>
- <languageList><iso639Id>kaz</iso639Id></languageList>
- </configItem>
- <variantList>
- <variant>
- <configItem>
- <name>ruskaz</name>
- <_description>Russian with Kazakh</_description>
- <languageList><iso639Id>kaz</iso639Id>
- <iso639Id>rus</iso639Id></languageList>
- </configItem>
- </variant>
- <variant>
- <configItem>
- <name>kazrus</name>
- <_description>Kazakh with Russian</_description>
- <languageList><iso639Id>kaz</iso639Id>
- <iso639Id>rus</iso639Id></languageList>
- </configItem>
- </variant>
- </variantList>
- </layout>
- <layout>
- <configItem>
- <name>la</name>
- <_shortDescription>Lao</_shortDescription>
- <_description>Laos</_description>
- <languageList><iso639Id>lao</iso639Id></languageList>
- </configItem>
- <variantList/>
- </layout>
- <layout>
- <configItem>
- <name>latam</name>
- <_shortDescription>LAm</_shortDescription>
- <_description>Latin American</_description>
- <countryList>
- <iso3166Id>AR</iso3166Id>
- <iso3166Id>BO</iso3166Id>
- <iso3166Id>CL</iso3166Id>
- <iso3166Id>CO</iso3166Id>
- <iso3166Id>CR</iso3166Id>
- <iso3166Id>CU</iso3166Id>
- <iso3166Id>DO</iso3166Id>
- <iso3166Id>EC</iso3166Id>
- <iso3166Id>GT</iso3166Id>
- <iso3166Id>HN</iso3166Id>
- <iso3166Id>HT</iso3166Id>
- <iso3166Id>MX</iso3166Id>
- <iso3166Id>NI</iso3166Id>
- <iso3166Id>PA</iso3166Id>
- <iso3166Id>PE</iso3166Id>
- <iso3166Id>PR</iso3166Id>
- <iso3166Id>PY</iso3166Id>
- <iso3166Id>SV</iso3166Id>
- <iso3166Id>US</iso3166Id>
- <iso3166Id>UY</iso3166Id>
- <iso3166Id>VE</iso3166Id>
- </countryList>
- <languageList><iso639Id>spa</iso639Id></languageList>
- </configItem>
- <variantList>
- <variant>
- <configItem>
- <name>nodeadkeys</name>
- <_description>Eliminate dead keys</_description>
- </configItem>
- </variant>
- <variant>
- <configItem>
- <name>deadtilde</name>
- <_description>Include dead tilde</_description>
- </configItem>
- </variant>
- <variant>
- <configItem>
- <name>sundeadkeys</name>
- <_description>Sun dead keys</_description>
- </configItem>
- </variant>
- </variantList>
- </layout>
- <layout>
- <configItem>
- <name>lt</name>
- <_shortDescription>Ltu</_shortDescription>
- <_description>Lithuania</_description>
- <languageList><iso639Id>lit</iso639Id></languageList>
- </configItem>
- <variantList>
- <variant>
- <configItem>
- <name>std</name>
- <_description>Standard</_description>
- </configItem>
- </variant>
- <variant>
- <configItem>
- <name>us</name>
- <_description>US keyboard with Lithuanian letters</_description>
- </configItem>
- </variant>
- <variant>
- <configItem>
- <name>ibm</name>
- <_description>IBM (LST 1205-92)</_description>
- </configItem>
- </variant>
- <variant>
- <configItem>
- <name>lekp</name>
- <_description>LEKP</_description>
- </configItem>
- </variant>
- <variant>
- <configItem>
- <name>lekpa</name>
- <_description>LEKPa</_description>
- </configItem>
- </variant>
- </variantList>
- </layout>
- <layout>
- <configItem>
- <name>lv</name>
- <_shortDescription>Lva</_shortDescription>
- <_description>Latvia</_description>
- <languageList><iso639Id>lav</iso639Id></languageList>
- </configItem>
- <variantList>
- <variant>
- <configItem>
- <name>apostrophe</name>
- <_description>Apostrophe (') variant</_description>
- </configItem>
- </variant>
- <variant>
- <configItem>
- <name>tilde</name>
- <_description>Tilde (~) variant</_description>
- </configItem>
- </variant>
- <variant>
- <configItem>
- <name>fkey</name>
- <_description>F-letter (F) variant</_description>
- </configItem>
- </variant>
- </variantList>
- </layout>
- <layout>
- <configItem>
- <name>mao</name>
- <_shortDescription>Mao</_shortDescription>
- <_description>Maori</_description>
- <languageList><iso639Id>mao</iso639Id></languageList>
- </configItem>
- <variantList/>
- </layout>
- <layout>
- <configItem>
- <name>me</name>
- <_shortDescription>MNE</_shortDescription>
- <_description>Montenegro</_description>
- <languageList><iso639Id>srp</iso639Id></languageList>
- </configItem>
- <variantList>
- <variant>
- <configItem>
- <name>cyrillic</name>
- <_description>Cyrillic</_description>
- </configItem>
- </variant>
- <variant>
- <configItem>
- <name>cyrillicyz</name>
- <_description>Cyrillic, Z and ZHE swapped</_description>
- </configItem>
- </variant>
- <variant>
- <configItem>
- <name>latinunicode</name>
- <_description>Latin unicode</_description>
- </configItem>
- </variant>
- <variant>
- <configItem>
- <name>latinyz</name>
- <_description>Latin qwerty</_description>
- </configItem>
- </variant>
- <variant>
- <configItem>
- <name>latinunicodeyz</name>
- <_description>Latin unicode qwerty</_description>
- </configItem>
- </variant>
- <variant>
- <configItem>
- <name>cyrillicalternatequotes</name>
- <_description>Cyrillic with guillemets</_description>
- </configItem>
- </variant>
- <variant>
- <configItem>
- <name>latinalternatequotes</name>
- <_description>Latin with guillemets</_description>
- </configItem>
- </variant>
- </variantList>
- </layout>
- <layout>
- <configItem>
- <name>mk</name>
- <_shortDescription>Mkd</_shortDescription>
- <_description>Macedonia</_description>
- <languageList><iso639Id>mkd</iso639Id></languageList>
- </configItem>
- <variantList>
- <variant>
- <configItem>
- <name>nodeadkeys</name>
- <_description>Eliminate dead keys</_description>
- </configItem>
- </variant>
- </variantList>
- </layout>
- <layout>
- <configItem>
- <name>mt</name>
- <_shortDescription>Mlt</_shortDescription>
- <_description>Malta</_description>
- <languageList><iso639Id>mlt</iso639Id></languageList>
- </configItem>
- <variantList>
- <variant>
- <configItem>
- <name>us</name>
- <_description>Maltese keyboard with US layout</_description>
- </configItem>
- </variant>
- </variantList>
- </layout>
- <layout>
- <configItem>
- <name>mn</name>
- <_shortDescription>Mng</_shortDescription>
- <_description>Mongolia</_description>
- <languageList><iso639Id>mng</iso639Id></languageList>
- </configItem>
- <variantList/>
- </layout>
- <layout>
- <configItem>
- <name>no</name>
- <_shortDescription>Nor</_shortDescription>
- <_description>Norway</_description>
- <languageList><iso639Id>nor</iso639Id></languageList>
- </configItem>
- <variantList>
- <variant>
- <configItem>
- <name>nodeadkeys</name>
- <_description>Eliminate dead keys</_description>
- </configItem>
- </variant>
- <variant>
- <configItem>
- <name>dvorak</name>
- <_description>Dvorak</_description>
- </configItem>
- </variant>
- <variant>
- <configItem>
- <name>smi</name>
- <_description>Northern Saami</_description>
- <languageList><iso639Id>sme</iso639Id></languageList>
- </configItem>
- </variant>
- <variant>
- <configItem>
- <name>smi_nodeadkeys</name>
- <_description>Northern Saami, eliminate dead keys</_description>
- <languageList><iso639Id>sme</iso639Id></languageList>
- </configItem>
- </variant>
- <variant>
- <configItem>
- <name>mac</name>
- <_description>Macintosh</_description>
- </configItem>
- </variant>
- <variant>
- <configItem>
- <name>mac_nodeadkeys</name>
- <_description>Macintosh, eliminate dead keys</_description>
- </configItem>
- </variant>
- </variantList>
- </layout>
- <layout>
- <configItem>
- <name>pl</name>
- <_shortDescription>Pol</_shortDescription>
- <_description>Poland</_description>
- <languageList><iso639Id>pol</iso639Id></languageList>
- </configItem>
- <variantList>
- <variant>
- <configItem>
- <name>qwertz</name>
- <_description>qwertz</_description>
- </configItem>
- </variant>
- <variant>
- <configItem>
- <name>dvorak</name>
- <_description>Dvorak</_description>
- </configItem>
- </variant>
- <variant>
- <configItem>
- <name>dvorak_quotes</name>
- <_description>Dvorak, Polish quotes on quotemark key</_description>
- </configItem>
- </variant>
- <variant>
- <configItem>
- <name>dvorak_altquotes</name>
- <_description>Dvorak, Polish quotes on key 1</_description>
- </configItem>
- </variant>
- <variant>
- <configItem>
- <name>csb</name>
- <_description>Kashubian</_description>
- <languageList><iso639Id>csb</iso639Id></languageList>
- </configItem>
- </variant>
- <variant>
- <configItem>
- <name>ru_phonetic_dvorak</name>
- <_description>Russian phonetic Dvorak</_description>
- <languageList><iso639Id>rus</iso639Id></languageList>
- </configItem>
- </variant>
- <variant>
- <configItem>
- <name>dvp</name>
- <_description>Programmer Dvorak</_description>
- </configItem>
- </variant>
- </variantList>
- </layout>
- <layout>
- <configItem>
- <name>pt</name>
- <_shortDescription>Prt</_shortDescription>
- <_description>Portugal</_description>
- <languageList><iso639Id>por</iso639Id></languageList>
- </configItem>
- <variantList>
- <variant>
- <configItem>
- <name>nodeadkeys</name>
- <_description>Eliminate dead keys</_description>
- </configItem>
- </variant>
- <variant>
- <configItem>
- <name>sundeadkeys</name>
- <_description>Sun dead keys</_description>
- </configItem>
- </variant>
- <variant>
- <configItem>
- <name>mac</name>
- <_description>Macintosh</_description>
- </configItem>
- </variant>
- <variant>
- <configItem>
- <name>mac_nodeadkeys</name>
- <_description>Macintosh, eliminate dead keys</_description>
- </configItem>
- </variant>
- <variant>
- <configItem>
- <name>mac_sundeadkeys</name>
- <_description>Macintosh, Sun dead keys</_description>
- </configItem>
- </variant>
- <variant>
- <configItem>
- <name>nativo</name>
- <_description>Nativo</_description>
- </configItem>
- </variant>
- <variant>
- <configItem>
- <name>nativo-us</name>
- <_description>Nativo for USA keyboards</_description>
- </configItem>
- </variant>
- <variant>
- <configItem>
- <name>nativo-epo</name>
- <_description>Nativo for Esperanto</_description>
- <languageList><iso639Id>epo</iso639Id></languageList>
- </configItem>
- </variant>
- </variantList>
- </layout>
- <layout>
- <configItem>
- <name>ro</name>
- <_shortDescription>Rou</_shortDescription>
- <_description>Romania</_description>
- <languageList><iso639Id>rum</iso639Id></languageList>
- </configItem>
- <variantList>
- <variant>
- <configItem>
- <name>cedilla</name>
- <_description>Cedilla</_description>
- </configItem>
- </variant>
- <variant>
- <configItem>
- <name>std</name>
- <_description>Standard</_description>
- </configItem>
- </variant>
- <variant>
- <configItem>
- <name>std_cedilla</name>
- <_description>Standard (Cedilla)</_description>
- </configItem>
- </variant>
- <variant>
- <configItem>
- <name>winkeys</name>
- <_description>Winkeys</_description>
- </configItem>
- </variant>
- <variant>
- <configItem>
- <name>crh_f</name>
- <_description>Crimean Tatar (Turkish F)</_description>
- <languageList><iso639Id>crh</iso639Id></languageList>
- </configItem>
- </variant>
- <variant>
- <configItem>
- <name>crh_alt</name>
- <_description>Crimean Tatar (Turkish Alt-Q)</_description>
- <languageList><iso639Id>crh</iso639Id></languageList>
- </configItem>
- </variant>
- <variant>
- <configItem>
- <name>crh_dobruca1</name>
- <_description>Crimean Tatar (Dobruca-1 Q)</_description>
- <languageList><iso639Id>crh</iso639Id></languageList>
- </configItem>
- </variant>
- <variant>
- <configItem>
- <name>crh_dobruca2</name>
- <_description>Crimean Tatar (Dobruca-2 Q)</_description>
- <languageList><iso639Id>crh</iso639Id></languageList>
- </configItem>
- </variant>
- </variantList>
- </layout>
- <layout>
- <configItem>
- <name>ru</name>
- <_shortDescription>Rus</_shortDescription>
- <_description>Russia</_description>
- <languageList><iso639Id>rus</iso639Id></languageList>
- </configItem>
- <variantList>
- <variant>
- <configItem>
- <name>phonetic</name>
- <_description>Phonetic</_description>
- </configItem>
- </variant>
- <variant>
- <configItem>
- <name>phonetic_winkeys</name>
- <_description>Phonetic Winkeys</_description>
- </configItem>
- </variant>
- <variant>
- <configItem>
- <name>typewriter</name>
- <_description>Typewriter</_description>
- </configItem>
- </variant>
- <variant>
- <configItem>
- <name>legacy</name>
- <_description>Legacy</_description>
- </configItem>
- </variant>
- <variant>
- <configItem>
- <name>typewriter-legacy</name>
- <_description>Typewriter, legacy</_description>
- </configItem>
- </variant>
- <variant>
- <configItem>
- <name>tt</name>
- <_description>Tatar</_description>
- <languageList><iso639Id>tat</iso639Id></languageList>
- </configItem>
- </variant>
- <variant>
- <configItem>
- <name>os_legacy</name>
- <_description>Ossetian, legacy</_description>
- <languageList><iso639Id>oss</iso639Id></languageList>
- </configItem>
- </variant>
- <variant>
- <configItem>
- <name>os_winkeys</name>
- <_description>Ossetian, Winkeys</_description>
- <languageList><iso639Id>oss</iso639Id></languageList>
- </configItem>
- </variant>
- <variant>
- <configItem>
- <name>cv</name>
- <_description>Chuvash</_description>
- <languageList><iso639Id>chv</iso639Id></languageList>
- </configItem>
- </variant>
- <variant>
- <configItem>
- <name>cv_latin</name>
- <_description>Chuvash Latin</_description>
- <languageList><iso639Id>chv</iso639Id></languageList>
- </configItem>
- </variant>
- <variant>
- <configItem>
- <name>udm</name>
- <_description>Udmurt</_description>
- <languageList><iso639Id>udm</iso639Id></languageList>
- </configItem>
- </variant>
- <variant>
- <configItem>
- <name>kom</name>
- <_description>Komi</_description>
- <languageList><iso639Id>kom</iso639Id></languageList>
- </configItem>
- </variant>
- <variant>
- <configItem>
- <name>sah</name>
- <_description>Yakut</_description>
- <languageList><iso639Id>sah</iso639Id></languageList>
- </configItem>
- </variant>
- <variant>
- <configItem>
- <name>xal</name>
- <_description>Kalmyk</_description>
- <languageList><iso639Id>xal</iso639Id></languageList>
- </configItem>
- </variant>
- <variant>
- <configItem>
- <name>dos</name>
- <_description>DOS</_description>
- </configItem>
- </variant>
- <variant>
- <configItem>
- <name>srp</name>
- <_description>Serbian</_description>
- <languageList><iso639Id>rus</iso639Id>
- <iso639Id>srp</iso639Id></languageList>
- </configItem>
- </variant>
- <variant>
- <configItem>
- <name>bak</name>
- <_description>Bashkirian</_description>
- <languageList><iso639Id>bak</iso639Id></languageList>
- </configItem>
- </variant>
- </variantList>
- </layout>
- <layout>
- <configItem>
- <name>rs</name>
- <_shortDescription>SRB</_shortDescription>
- <_description>Serbia</_description>
- <languageList><iso639Id>srp</iso639Id></languageList>
- </configItem>
- <variantList>
- <variant>
- <configItem>
- <name>yz</name>
- <_description>Z and ZHE swapped</_description>
- </configItem>
- </variant>
- <variant>
- <configItem>
- <name>latin</name>
- <_description>Latin</_description>
- </configItem>
- </variant>
- <variant>
- <configItem>
- <name>latinunicode</name>
- <_description>Latin Unicode</_description>
- </configItem>
- </variant>
- <variant>
- <configItem>
- <name>latinyz</name>
- <_description>Latin qwerty</_description>
- </configItem>
- </variant>
- <variant>
- <configItem>
- <name>latinunicodeyz</name>
- <_description>Latin Unicode qwerty</_description>
- </configItem>
- </variant>
- <variant>
- <configItem>
- <name>alternatequotes</name>
- <_description>With guillemets</_description>
- </configItem>
- </variant>
- <variant>
- <configItem>
- <name>latinalternatequotes</name>
- <_description>Latin with guillemets</_description>
- </configItem>
- </variant>
- <variant>
- <configItem>
- <name>rue</name>
- <_description>Pannonian Rusyn Homophonic</_description>
- <languageList><iso639Id>rue</iso639Id></languageList>
- </configItem>
- </variant>
- </variantList>
- </layout>
- <layout>
- <configItem>
- <name>si</name>
- <_shortDescription>Svn</_shortDescription>
- <_description>Slovenia</_description>
- <languageList><iso639Id>slv</iso639Id></languageList>
- </configItem>
- <variantList>
- <variant>
- <configItem>
- <name>alternatequotes</name>
- <_description>Use guillemets for quotes</_description>
- </configItem>
- </variant>
- <variant>
- <configItem>
- <name>us</name>
- <_description>US keyboard with Slovenian letters</_description>
- </configItem>
- </variant>
- </variantList>
- </layout>
- <layout>
- <configItem>
- <name>sk</name>
- <_shortDescription>Svk</_shortDescription>
- <_description>Slovakia</_description>
- <languageList><iso639Id>slo</iso639Id></languageList>
- </configItem>
- <variantList>
- <variant>
- <configItem>
- <name>bksl</name>
- <_description>Extended Backslash</_description>
- </configItem>
- </variant>
- <variant>
- <configItem>
- <name>qwerty</name>
- <_description>qwerty</_description>
- </configItem>
- </variant>
- <variant>
- <configItem>
- <name>qwerty_bksl</name>
- <_description>qwerty, extended Backslash</_description>
- </configItem>
- </variant>
- </variantList>
- </layout>
- <layout>
- <configItem>
- <name>es</name>
- <_shortDescription>Esp</_shortDescription>
- <_description>Spain</_description>
- <languageList><iso639Id>spa</iso639Id></languageList>
- </configItem>
- <variantList>
- <variant>
- <configItem>
- <name>nodeadkeys</name>
- <_description>Eliminate dead keys</_description>
- </configItem>
- </variant>
- <variant>
- <configItem>
- <name>deadtilde</name>
- <_description>Include dead tilde</_description>
- </configItem>
- </variant>
- <variant>
- <configItem>
- <name>sundeadkeys</name>
- <_description>Sun dead keys</_description>
- </configItem>
- </variant>
- <variant>
- <configItem>
- <name>dvorak</name>
- <_description>Dvorak</_description>
- </configItem>
- </variant>
- <variant>
- <configItem>
- <name>ast</name>
- <_description>Asturian variant with bottom-dot H and bottom-dot L</_description>
- <languageList><iso639Id>ast</iso639Id></languageList>
- </configItem>
- </variant>
- <variant>
- <configItem>
- <name>cat</name>
- <_description>Catalan variant with middle-dot L</_description>
- <languageList><iso639Id>cat</iso639Id></languageList>
- </configItem>
- </variant>
- <variant>
- <configItem>
- <name>mac</name>
- <_description>Macintosh</_description>
- </configItem>
- </variant>
- </variantList>
- </layout>
- <layout>
- <configItem>
- <name>se</name>
- <_shortDescription>Swe</_shortDescription>
- <_description>Sweden</_description>
- <languageList><iso639Id>swe</iso639Id></languageList>
- </configItem>
- <variantList>
- <variant>
- <configItem>
- <name>nodeadkeys</name>
- <_description>Eliminate dead keys</_description>
- </configItem>
- </variant>
- <variant>
- <configItem>
- <name>dvorak</name>
- <_description>Dvorak</_description>
- </configItem>
- </variant>
- <variant>
- <configItem>
- <name>rus</name>
- <_description>Russian phonetic</_description>
- <languageList><iso639Id>rus</iso639Id></languageList>
- </configItem>
- </variant>
- <variant>
- <configItem>
- <name>rus_nodeadkeys</name>
- <_description>Russian phonetic, eliminate dead keys</_description>
- <languageList><iso639Id>rus</iso639Id></languageList>
- </configItem>
- </variant>
- <variant>
- <configItem>
- <name>smi</name>
- <_description>Northern Saami</_description>
- <languageList><iso639Id>sme</iso639Id></languageList>
- </configItem>
- </variant>
- <variant>
- <configItem>
- <name>mac</name>
- <_description>Macintosh</_description>
- </configItem>
- </variant>
- <variant>
- <configItem>
- <name>svdvorak</name>
- <_description>Svdvorak</_description>
- </configItem>
- </variant>
- </variantList>
- </layout>
- <layout>
- <configItem>
- <name>ch</name>
- <_shortDescription>Che</_shortDescription>
- <_description>Switzerland</_description>
- <languageList><iso639Id>ger</iso639Id>
- <iso639Id>gsw</iso639Id></languageList>
- </configItem>
- <variantList>
- <variant>
- <configItem>
- <name>legacy</name>
- <_description>Legacy</_description>
- </configItem>
- </variant>
- <variant>
- <configItem>
- <name>de_nodeadkeys</name>
- <_description>German, eliminate dead keys</_description>
- </configItem>
- </variant>
- <variant>
- <configItem>
- <name>de_sundeadkeys</name>
- <_description>German, Sun dead keys</_description>
- </configItem>
- </variant>
- <variant>
- <configItem>
- <name>fr</name>
- <_description>French</_description>
- <languageList><iso639Id>fra</iso639Id></languageList>
- </configItem>
- </variant>
- <variant>
- <configItem>
- <name>fr_nodeadkeys</name>
- <_description>French, eliminate dead keys</_description>
- <languageList><iso639Id>fra</iso639Id></languageList>
- </configItem>
- </variant>
- <variant>
- <configItem>
- <name>fr_sundeadkeys</name>
- <_description>French, Sun dead keys</_description>
- <languageList><iso639Id>fra</iso639Id></languageList>
- </configItem>
- </variant>
- <variant>
- <configItem>
- <name>fr_mac</name>
- <_description>French (Macintosh)</_description>
- <languageList><iso639Id>fra</iso639Id></languageList>
- </configItem>
- </variant>
- <variant>
- <configItem>
- <name>de_mac</name>
- <_description>German (Macintosh)</_description>
- </configItem>
- </variant>
- </variantList>
- </layout>
- <layout>
- <configItem>
- <name>sy</name>
- <_shortDescription>Syr</_shortDescription>
- <_description>Syria</_description>
- <languageList><iso639Id>syr</iso639Id></languageList>
- </configItem>
- <variantList>
- <variant>
- <configItem>
- <name>syc</name>
- <_description>Syriac</_description>
- </configItem>
- </variant>
- <variant>
- <configItem>
- <name>syc_phonetic</name>
- <_description>Syriac phonetic</_description>
- </configItem>
- </variant>
- <variant>
- <configItem>
- <name>ku</name>
- <_description>Kurdish, Latin Q</_description>
- <languageList><iso639Id>kur</iso639Id></languageList>
- </configItem>
- </variant>
- <variant>
- <configItem>
- <name>ku_f</name>
- <_description>Kurdish, (F)</_description>
- <languageList><iso639Id>kur</iso639Id></languageList>
- </configItem>
- </variant>
- <variant>
- <configItem>
- <name>ku_alt</name>
- <_description>Kurdish, Latin Alt-Q</_description>
- <languageList><iso639Id>kur</iso639Id></languageList>
- </configItem>
- </variant>
- </variantList>
- </layout>
- <layout>
- <configItem>
- <name>tj</name>
- <_shortDescription>Tjk</_shortDescription>
- <_description>Tajikistan</_description>
- <languageList><iso639Id>tgk</iso639Id></languageList>
- </configItem>
- <variantList>
- <variant>
- <configItem>
- <name>legacy</name>
- <_description>Legacy</_description>
- </configItem>
- </variant>
- </variantList>
- </layout>
- <layout>
- <configItem>
- <name>lk</name>
- <_shortDescription>Lka</_shortDescription>
- <_description>Sri Lanka</_description>
- <languageList><iso639Id>sin</iso639Id></languageList>
- </configItem>
- <variantList>
- <variant>
- <configItem>
- <name>tam_unicode</name>
- <_description>Tamil Unicode</_description>
- <languageList><iso639Id>tam</iso639Id></languageList>
- </configItem>
- </variant>
- <variant>
- <configItem>
- <name>tam_TAB</name>
- <_description>Tamil TAB Typewriter</_description>
- <languageList><iso639Id>tam</iso639Id></languageList>
- </configItem>
- </variant>
- </variantList>
- </layout>
- <layout>
- <configItem>
- <name>th</name>
- <_shortDescription>Tha</_shortDescription>
- <_description>Thailand</_description>
- <languageList><iso639Id>tha</iso639Id></languageList>
- </configItem>
- <variantList>
- <variant>
- <configItem>
- <name>tis</name>
- <_description>TIS-820.2538</_description>
- </configItem>
- </variant>
- <variant>
- <configItem>
- <name>pat</name>
- <_description>Pattachote</_description>
- </configItem>
- </variant>
- </variantList>
- </layout>
- <layout>
- <configItem>
- <name>tr</name>
- <_shortDescription>Tur</_shortDescription>
- <_description>Turkey</_description>
- <languageList><iso639Id>tur</iso639Id></languageList>
- </configItem>
- <variantList>
- <variant>
- <configItem>
- <name>f</name>
- <_description>(F)</_description>
- </configItem>
- </variant>
- <variant>
- <configItem>
- <name>alt</name>
- <_description>Alt-Q</_description>
- </configItem>
- </variant>
- <variant>
- <configItem>
- <name>sundeadkeys</name>
- <_description>Sun dead keys</_description>
- </configItem>
- </variant>
- <variant>
- <configItem>
- <name>ku</name>
- <_description>Kurdish, Latin Q</_description>
- <languageList><iso639Id>kur</iso639Id></languageList>
- </configItem>
- </variant>
- <variant>
- <configItem>
- <name>ku_f</name>
- <_description>Kurdish, (F)</_description>
- <languageList><iso639Id>kur</iso639Id></languageList>
- </configItem>
- </variant>
- <variant>
- <configItem>
- <name>ku_alt</name>
- <_description>Kurdish, Latin Alt-Q</_description>
- <languageList><iso639Id>kur</iso639Id></languageList>
- </configItem>
- </variant>
- <variant>
- <configItem>
- <name>intl</name>
- <_description>International (with dead keys)</_description>
- </configItem>
- </variant>
- <variant>
- <configItem>
- <name>crh</name>
- <_description>Crimean Tatar (Turkish Q)</_description>
- <languageList><iso639Id>crh</iso639Id></languageList>
- </configItem>
- </variant>
- <variant>
- <configItem>
- <name>crh_f</name>
- <_description>Crimean Tatar (Turkish F)</_description>
- <languageList><iso639Id>crh</iso639Id></languageList>
- </configItem>
- </variant>
- <variant>
- <configItem>
- <name>crh_alt</name>
- <_description>Crimean Tatar (Turkish Alt-Q)</_description>
- <languageList><iso639Id>crh</iso639Id></languageList>
- </configItem>
- </variant>
- </variantList>
- </layout>
- <layout>
- <configItem>
- <name>ua</name>
- <_shortDescription>Ukr</_shortDescription>
- <_description>Ukraine</_description>
- <languageList><iso639Id>ukr</iso639Id></languageList>
- </configItem>
- <variantList>
- <variant>
- <configItem>
- <name>phonetic</name>
- <_description>Phonetic</_description>
- </configItem>
- </variant>
- <variant>
- <configItem>
- <name>typewriter</name>
- <_description>Typewriter</_description>
- </configItem>
- </variant>
- <variant>
- <configItem>
- <name>winkeys</name>
- <_description>Winkeys</_description>
- </configItem>
- </variant>
- <variant>
- <configItem>
- <name>legacy</name>
- <_description>Legacy</_description>
- </configItem>
- </variant>
- <variant>
- <configItem>
- <name>rstu</name>
-<!-- RSTU 2019-91 -->
- <_description>Standard RSTU</_description>
- </configItem>
- </variant>
- <variant>
- <configItem>
- <name>rstu_ru</name>
-<!-- RSTU 2019-91 -->
- <_description>Standard RSTU on Russian layout</_description>
- </configItem>
- </variant>
- <variant>
- <configItem>
- <name>homophonic</name>
- <_description>Homophonic</_description>
- </configItem>
- </variant>
- <variant>
- <configItem>
- <name>crh</name>
- <_description>Crimean Tatar (Turkish Q)</_description>
- <languageList><iso639Id>crh</iso639Id></languageList>
- </configItem>
- </variant>
- <variant>
- <configItem>
- <name>crh_f</name>
- <_description>Crimean Tatar (Turkish F)</_description>
- <languageList><iso639Id>crh</iso639Id></languageList>
- </configItem>
- </variant>
- <variant>
- <configItem>
- <name>crh_alt</name>
- <_description>Crimean Tatar (Turkish Alt-Q)</_description>
- <languageList><iso639Id>crh</iso639Id></languageList>
- </configItem>
- </variant>
- </variantList>
- </layout>
- <layout>
- <configItem>
- <name>gb</name>
- <_shortDescription>GBr</_shortDescription>
- <_description>United Kingdom</_description>
- <languageList><iso639Id>eng</iso639Id></languageList>
- </configItem>
- <variantList>
- <variant>
- <configItem>
- <name>extd</name>
- <_description>Extended - Winkeys</_description>
- </configItem>
- </variant>
- <variant>
- <configItem>
- <name>intl</name>
- <_description>International (with dead keys)</_description>
- </configItem>
- </variant>
- <variant>
- <configItem>
- <name>dvorak</name>
- <_description>Dvorak</_description>
- </configItem>
- </variant>
- <variant>
- <configItem>
- <name>dvorakukp</name>
- <_description>Dvorak (UK Punctuation)</_description>
- </configItem>
- </variant>
- <variant>
- <configItem>
- <name>mac</name>
- <_description>Macintosh</_description>
- </configItem>
- </variant>
- <variant>
- <configItem>
- <name>mac_intl</name>
- <_description>Macintosh (International)</_description>
- </configItem>
- </variant>
- <variant>
- <configItem>
- <name>colemak</name>
- <_description>Colemak</_description>
- </configItem>
- </variant>
- </variantList>
- </layout>
- <layout>
- <configItem>
- <name>uz</name>
- <_shortDescription>Uzb</_shortDescription>
- <_description>Uzbekistan</_description>
- <languageList><iso639Id>uzb</iso639Id></languageList>
- </configItem>
- <variantList>
- <variant>
- <configItem>
- <name>latin</name>
- <_description>Latin</_description>
- </configItem>
- </variant>
- <variant>
- <configItem>
- <name>crh</name>
- <_description>Crimean Tatar (Turkish Q)</_description>
- <languageList><iso639Id>crh</iso639Id></languageList>
- </configItem>
- </variant>
- <variant>
- <configItem>
- <name>crh_f</name>
- <_description>Crimean Tatar (Turkish F)</_description>
- <languageList><iso639Id>crh</iso639Id></languageList>
- </configItem>
- </variant>
- <variant>
- <configItem>
- <name>crh_alt</name>
- <_description>Crimean Tatar (Turkish Alt-Q)</_description>
- <languageList><iso639Id>crh</iso639Id></languageList>
- </configItem>
- </variant>
- </variantList>
- </layout>
- <layout>
- <configItem>
- <name>vn</name>
- <_shortDescription>Vnm</_shortDescription>
- <_description>Vietnam</_description>
- <languageList><iso639Id>vie</iso639Id></languageList>
- </configItem>
- <variantList/>
- </layout>
- <layout>
- <configItem>
- <name>kr</name>
- <_shortDescription>Kor</_shortDescription>
- <_description>Korea, Republic of</_description>
- <languageList><iso639Id>kor</iso639Id></languageList>
- </configItem>
- <variantList>
- <variant>
- <configItem>
- <name>kr104</name>
- <_description>101/104 key Compatible</_description>
- </configItem>
- </variant>
- </variantList>
- </layout>
- <layout>
- <configItem>
- <name>nec_vndr/jp</name>
- <_shortDescription>Jpn</_shortDescription>
- <_description>Japan (PC-98xx Series)</_description>
- <countryList><iso3166Id>JP</iso3166Id></countryList>
- <languageList><iso639Id>jpn</iso639Id></languageList>
- </configItem>
- <variantList/>
- </layout>
- <layout>
- <configItem>
- <name>ie</name>
- <_shortDescription>Irl</_shortDescription>
- <_description>Ireland</_description>
- <languageList><iso639Id>eng</iso639Id></languageList>
- </configItem>
- <variantList>
- <variant>
- <configItem>
- <name>CloGaelach</name>
- <_description>CloGaelach</_description>
- <languageList><iso639Id>gla</iso639Id></languageList>
- </configItem>
- </variant>
- <variant>
- <configItem>
- <name>UnicodeExpert</name>
- <_description>UnicodeExpert</_description>
- </configItem>
- </variant>
- <variant>
- <configItem>
- <name>ogam</name>
- <_description>Ogham</_description>
- <!-- No ISO code in ISO639 -->
- </configItem>
- </variant>
- <variant>
- <configItem>
- <name>ogam_is434</name>
- <_description>Ogham IS434</_description>
- <!-- No ISO code in ISO639 -->
- </configItem>
- </variant>
- </variantList>
- </layout>
- <layout>
- <configItem>
- <name>pk</name>
- <_shortDescription>Pak</_shortDescription>
- <_description>Pakistan</_description>
- <languageList><iso639Id>urd</iso639Id></languageList>
- </configItem>
- <variantList>
- <variant>
- <configItem>
- <name>urd-crulp</name>
- <_description>CRULP</_description>
- <languageList><iso639Id>urd</iso639Id></languageList>
- </configItem>
- </variant>
- <variant>
- <configItem>
- <name>urd-nla</name>
- <_description>NLA</_description>
- <languageList><iso639Id>urd</iso639Id></languageList>
- </configItem>
- </variant>
- <variant>
- <configItem>
- <name>ara</name>
- <_description>Arabic</_description>
- <languageList><iso639Id>ara</iso639Id></languageList>
- </configItem>
- </variant>
- <variant>
- <configItem>
- <name>snd</name>
- <_description>Sindhi</_description>
- <languageList><iso639Id>sd</iso639Id></languageList>
- </configItem>
- </variant>
- </variantList>
- </layout>
- <layout>
- <configItem>
- <name>mv</name>
- <_shortDescription>Mdv</_shortDescription>
- <_description>Maldives</_description>
- <languageList><iso639Id>div</iso639Id></languageList>
- </configItem>
- <variantList/>
- </layout>
- <layout>
- <configItem>
- <name>za</name>
- <_shortDescription>Zaf</_shortDescription>
- <_description>South Africa</_description>
- <languageList><iso639Id>eng</iso639Id></languageList>
- </configItem>
- </layout>
- <layout>
- <configItem>
- <name>epo</name>
- <_shortDescription>Epo</_shortDescription>
- <_description>Esperanto</_description>
- <languageList><iso639Id>epo</iso639Id></languageList>
- </configItem>
- <variantList>
- <variant>
- <configItem>
- <name>legacy</name>
- <_description>displaced semicolon and quote (obsolete)</_description>
- </configItem>
- </variant>
- </variantList>
- </layout>
- <layout>
- <configItem>
- <name>np</name>
- <_shortDescription>Npl</_shortDescription>
- <_description>Nepal</_description>
- <languageList><iso639Id>nep</iso639Id></languageList>
- </configItem>
- </layout>
- <layout>
- <configItem>
- <name>ng</name>
- <_shortDescription>Nga</_shortDescription>
- <_description>Nigeria</_description>
- <languageList><iso639Id>eng</iso639Id></languageList>
- </configItem>
- <variantList>
- <variant>
- <configItem>
- <name>igbo</name>
- <_description>Igbo</_description>
- <languageList><iso639Id>ibo</iso639Id></languageList>
- </configItem>
- </variant>
- <variant>
- <configItem>
- <name>yoruba</name>
- <_description>Yoruba</_description>
- <languageList><iso639Id>yor</iso639Id></languageList>
- </configItem>
- </variant>
- <variant>
- <configItem>
- <name>hausa</name>
- <_description>Hausa</_description>
- <languageList><iso639Id>hau</iso639Id></languageList>
- </configItem>
- </variant>
- </variantList>
- </layout>
- <layout>
- <configItem>
- <name>et</name>
- <_shortDescription>Eth</_shortDescription>
- <_description>Ethiopia</_description>
- <languageList><iso639Id>amh</iso639Id></languageList>
- </configItem>
- <variantList/>
- </layout>
- <layout>
- <configItem>
- <name>sn</name>
- <_shortDescription>Sen</_shortDescription>
- <_description>Senegal</_description>
- <languageList><iso639Id>wol</iso639Id></languageList>
- </configItem>
- <variantList/>
- </layout>
- <layout>
- <configItem>
- <name>brai</name>
- <_shortDescription>Brl</_shortDescription>
- <_description>Braille</_description>
- </configItem>
- <variantList>
- <variant>
- <configItem>
- <name>left_hand</name>
- <_description>Left hand</_description>
- </configItem>
- </variant>
- <variant>
- <configItem>
- <name>right_hand</name>
- <_description>Right hand</_description>
- </configItem>
- </variant>
- </variantList>
- </layout>
- <layout>
- <configItem>
- <name>tm</name>
- <_shortDescription>Tkm</_shortDescription>
- <_description>Turkmenistan</_description>
- <languageList><iso639Id>tuk</iso639Id></languageList>
- </configItem>
- <variantList>
- <variant>
- <configItem>
- <name>alt</name>
- <_description>Alt-Q</_description>
- </configItem>
- </variant>
- </variantList>
- </layout>
- <layout>
- <configItem>
- <name>ml</name>
- <_shortDescription>Mli</_shortDescription>
- <_description>Mali</_description>
- <languageList><iso639Id>bam</iso639Id></languageList>
- </configItem>
- <variantList>
- <variant>
- <configItem>
- <name>fr-oss</name>
- <_description>Français (France Alternative)</_description>
- </configItem>
- </variant>
- <variant>
- <configItem>
- <name>us-mac</name>
- <_description>English (USA Macintosh)</_description>
- </configItem>
- </variant>
- <variant>
- <configItem>
- <name>us-intl</name>
- <_description>English (USA International)</_description>
- </configItem>
- </variant>
- </variantList>
- </layout>
- <layout>
- <configItem>
- <name>tz</name>
- <_shortDescription>Tza</_shortDescription>
- <_description>Tanzania</_description>
- <languageList><iso639Id>swa</iso639Id></languageList>
- </configItem>
- </layout>
- <layout>
- <configItem>
- <name>ke</name>
- <_shortDescription>Ken</_shortDescription>
- <_description>Kenya</_description>
- <languageList><iso639Id>swa</iso639Id></languageList>
- </configItem>
- <variantList>
- <variant>
- <configItem>
- <name>kik</name>
- <_description>Kikuyu</_description>
- <languageList><iso639Id>kik</iso639Id></languageList>
- </configItem>
- </variant>
- </variantList>
- </layout>
- <layout>
- <configItem>
- <name>bw</name>
- <_shortDescription>Bwa</_shortDescription>
- <_description>Botswana</_description>
- <languageList><iso639Id>tsn</iso639Id></languageList>
- </configItem>
- </layout>
- <layout>
- <configItem>
- <name>ph</name>
- <_shortDescription>Phi</_shortDescription>
- <_description>Philippines</_description>
- <languageList><iso639Id>eng</iso639Id>
- <iso639Id>bik</iso639Id>
- <iso639Id>ceb</iso639Id>
- <iso639Id>fil</iso639Id>
- <iso639Id>hil</iso639Id>
- <iso639Id>ilo</iso639Id>
- <iso639Id>pam</iso639Id>
- <iso639Id>pag</iso639Id>
- <iso639Id>phi</iso639Id>
- <iso639Id>tgl</iso639Id>
- <iso639Id>war</iso639Id></languageList>
- </configItem>
- <variantList>
- <variant>
- <configItem>
- <name>qwerty-bay</name>
- <_description>QWERTY (Baybayin)</_description>
- <languageList><iso639Id>bik</iso639Id>
- <iso639Id>ceb</iso639Id>
- <iso639Id>fil</iso639Id>
- <iso639Id>hil</iso639Id>
- <iso639Id>ilo</iso639Id>
- <iso639Id>pam</iso639Id>
- <iso639Id>pag</iso639Id>
- <iso639Id>phi</iso639Id>
- <iso639Id>tgl</iso639Id>
- <iso639Id>war</iso639Id></languageList>
- </configItem>
- </variant>
- <variant>
- <configItem>
- <name>capewell-dvorak</name>
- <_description>Capewell-Dvorak (Latin)</_description>
- </configItem>
- </variant>
- <variant>
- <configItem>
- <name>capewell-dvorak-bay</name>
- <_description>Capewell-Dvorak (Baybayin)</_description>
- <languageList><iso639Id>bik</iso639Id>
- <iso639Id>ceb</iso639Id>
- <iso639Id>fil</iso639Id>
- <iso639Id>hil</iso639Id>
- <iso639Id>ilo</iso639Id>
- <iso639Id>pam</iso639Id>
- <iso639Id>pag</iso639Id>
- <iso639Id>phi</iso639Id>
- <iso639Id>tgl</iso639Id>
- <iso639Id>war</iso639Id></languageList>
- </configItem>
- </variant>
- <variant>
- <configItem>
- <name>capewell-qwerf2k6</name>
- <_description>Capewell-QWERF 2006 (Latin)</_description>
- </configItem>
- </variant>
- <variant>
- <configItem>
- <name>capewell-qwerf2k6-bay</name>
- <_description>Capewell-QWERF 2006 (Baybayin)</_description>
- <languageList><iso639Id>bik</iso639Id>
- <iso639Id>ceb</iso639Id>
- <iso639Id>fil</iso639Id>
- <iso639Id>hil</iso639Id>
- <iso639Id>ilo</iso639Id>
- <iso639Id>pam</iso639Id>
- <iso639Id>pag</iso639Id>
- <iso639Id>phi</iso639Id>
- <iso639Id>tgl</iso639Id>
- <iso639Id>war</iso639Id></languageList>
- </configItem>
- </variant>
- <variant>
- <configItem>
- <name>colemak</name>
- <_description>Colemak (Latin)</_description>
- </configItem>
- </variant>
- <variant>
- <configItem>
- <name>colemak-bay</name>
- <_description>Colemak (Baybayin)</_description>
- <languageList><iso639Id>bik</iso639Id>
- <iso639Id>ceb</iso639Id>
- <iso639Id>fil</iso639Id>
- <iso639Id>hil</iso639Id>
- <iso639Id>ilo</iso639Id>
- <iso639Id>pam</iso639Id>
- <iso639Id>pag</iso639Id>
- <iso639Id>phi</iso639Id>
- <iso639Id>tgl</iso639Id>
- <iso639Id>war</iso639Id></languageList>
- </configItem>
- </variant>
- <variant>
- <configItem>
- <name>dvorak</name>
- <_description>Dvorak (Latin)</_description>
- </configItem>
- </variant>
- <variant>
- <configItem>
- <name>dvorak-bay</name>
- <_description>Dvorak (Baybayin)</_description>
- <languageList><iso639Id>bik</iso639Id>
- <iso639Id>ceb</iso639Id>
- <iso639Id>fil</iso639Id>
- <iso639Id>hil</iso639Id>
- <iso639Id>ilo</iso639Id>
- <iso639Id>pam</iso639Id>
- <iso639Id>pag</iso639Id>
- <iso639Id>phi</iso639Id>
- <iso639Id>tgl</iso639Id>
- <iso639Id>war</iso639Id></languageList>
- </configItem>
- </variant>
- </variantList>
- </layout>
- </layoutList>
- <optionList>
- <group allowMultipleSelection="true">
- <!-- The key combination used to switch between groups -->
- <configItem>
- <name>grp</name>
- <_description>Key(s) to change layout</_description>
- </configItem>
- <option>
- <configItem>
- <name>grp:switch</name>
- <_description>Right Alt (while pressed)</_description>
- </configItem>
- </option>
- <option>
- <configItem>
- <name>grp:lswitch</name>
- <_description>Left Alt (while pressed)</_description>
- </configItem>
- </option>
- <option>
- <configItem>
- <name>grp:lwin_switch</name>
- <_description>Left Win (while pressed)</_description>
- </configItem>
- </option>
- <option>
- <configItem>
- <name>grp:rwin_switch</name>
- <_description>Right Win (while pressed)</_description>
- </configItem>
- </option>
- <option>
- <configItem>
- <name>grp:win_switch</name>
- <_description>Any Win key (while pressed)</_description>
- </configItem>
- </option>
- <option>
- <configItem>
- <name>grp:caps_switch</name>
- <_description>Caps Lock (while pressed), Alt+Caps Lock does the original capslock action</_description>
- </configItem>
- </option>
- <option>
- <configItem>
- <name>grp:rctrl_switch</name>
- <_description>Right Ctrl (while pressed)</_description>
- </configItem>
- </option>
- <option>
- <configItem>
- <name>grp:toggle</name>
- <_description>Right Alt</_description>
- </configItem>
- </option>
- <option>
- <configItem>
- <name>grp:lalt_toggle</name>
- <_description>Left Alt</_description>
- </configItem>
- </option>
- <option>
- <configItem>
- <name>grp:caps_toggle</name>
- <_description>Caps Lock</_description>
- </configItem>
- </option>
- <option>
- <configItem>
- <name>grp:shift_caps_toggle</name>
- <_description>Shift+Caps Lock</_description>
- </configItem>
- </option>
- <option>
- <configItem>
- <name>grp:shift_caps_switch</name>
- <_description>Caps Lock (to first layout), Shift+Caps Lock (to last layout)</_description>
- </configItem>
- </option>
- <option>
- <configItem>
- <name>grp:win_menu_switch</name>
- <_description>Left Win (to first layout), Right Win/Menu (to last layout)</_description>
- </configItem>
- </option>
- <option>
- <configItem>
- <name>grp:lctrl_rctrl_switch</name>
- <_description>Left Ctrl (to first layout), Right Ctrl (to last layout)</_description>
- </configItem>
- </option>
- <option>
- <configItem>
- <name>grp:alt_caps_toggle</name>
- <_description>Alt+Caps Lock</_description>
- </configItem>
- </option>
- <option>
- <configItem>
- <name>grp:shifts_toggle</name>
- <_description>Both Shift keys together</_description>
- </configItem>
- </option>
- <option>
- <configItem>
- <name>grp:alts_toggle</name>
- <_description>Both Alt keys together</_description>
- </configItem>
- </option>
- <option>
- <configItem>
- <name>grp:ctrls_toggle</name>
- <_description>Both Ctrl keys together</_description>
- </configItem>
- </option>
- <option>
- <configItem>
- <name>grp:ctrl_shift_toggle</name>
- <_description>Ctrl+Shift</_description>
- </configItem>
- </option>
- <option>
- <configItem>
- <name>grp:lctrl_lshift_toggle</name>
- <_description>Left Ctrl+Left Shift</_description>
- </configItem>
- </option>
- <option>
- <configItem>
- <name>grp:rctrl_rshift_toggle</name>
- <_description>Right Ctrl+Right Shift</_description>
- </configItem>
- </option>
- <option>
- <configItem>
- <name>grp:ctrl_alt_toggle</name>
- <_description>Alt+Ctrl</_description>
- </configItem>
- </option>
- <option>
- <configItem>
- <name>grp:alt_shift_toggle</name>
- <_description>Alt+Shift</_description>
- </configItem>
- </option>
- <option>
- <configItem>
- <name>grp:alt_space_toggle</name>
- <_description>Alt+Space</_description>
- </configItem>
- </option>
- <option>
- <configItem>
- <name>grp:menu_toggle</name>
- <_description>Menu</_description>
- </configItem>
- </option>
- <option>
- <configItem>
- <name>grp:lwin_toggle</name>
- <_description>Left Win</_description>
- </configItem>
- </option>
- <option>
- <configItem>
- <name>grp:rwin_toggle</name>
- <_description>Right Win</_description>
- </configItem>
- </option>
- <option>
- <configItem>
- <name>grp:lshift_toggle</name>
- <_description>Left Shift</_description>
- </configItem>
- </option>
- <option>
- <configItem>
- <name>grp:rshift_toggle</name>
- <_description>Right Shift</_description>
- </configItem>
- </option>
- <option>
- <configItem>
- <name>grp:lctrl_toggle</name>
- <_description>Left Ctrl</_description>
- </configItem>
- </option>
- <option>
- <configItem>
- <name>grp:rctrl_toggle</name>
- <_description>Right Ctrl</_description>
- </configItem>
- </option>
- <option>
- <configItem>
- <name>grp:sclk_toggle</name>
- <_description>Scroll Lock</_description>
- </configItem>
- </option>
- </group>
- <group allowMultipleSelection="true">
- <!-- The key combination used to choose the 3rd (and 4th, together with Shift)
- level of symbols -->
- <configItem>
- <name>lv3</name>
- <_description>Key to choose 3rd level</_description>
- </configItem>
- <option>
- <configItem>
- <name>lv3:switch</name>
- <_description>Right Ctrl</_description>
- </configItem>
- </option>
- <option>
- <configItem>
- <name>lv3:menu_switch</name>
- <_description>Menu</_description>
- </configItem>
- </option>
- <option>
- <configItem>
- <name>lv3:win_switch</name>
- <_description>Any Win key</_description>
- </configItem>
- </option>
- <option>
- <configItem>
- <name>lv3:lwin_switch</name>
- <_description>Left Win</_description>
- </configItem>
- </option>
- <option>
- <configItem>
- <name>lv3:rwin_switch</name>
- <_description>Right Win</_description>
- </configItem>
- </option>
- <option>
- <configItem>
- <name>lv3:alt_switch</name>
- <_description>Any Alt key</_description>
- </configItem>
- </option>
- <option>
- <configItem>
- <name>lv3:lalt_switch</name>
- <_description>Left Alt</_description>
- </configItem>
- </option>
- <option>
- <configItem>
- <name>lv3:ralt_switch</name>
- <_description>Right Alt</_description>
- </configItem>
- </option>
- <option>
- <configItem>
- <name>lv3:ralt_switch_multikey</name>
- <_description>Right Alt, Shift+Right Alt key is Multi_Key</_description>
- </configItem>
- </option>
- <option>
- <configItem>
- <name>lv3:ralt_alt</name>
- <_description>Right Alt key never chooses 3rd level</_description>
- </configItem>
- </option>
- <option>
- <configItem>
- <name>lv3:enter_switch</name>
- <_description>Enter on keypad</_description>
- </configItem>
- </option>
- <option>
- <configItem>
- <name>lv3:caps_switch</name>
- <_description>Caps Lock</_description>
- </configItem>
- </option>
- <option>
- <configItem>
- <name>lv3:bksl_switch</name>
- <_description>Backslash</_description>
- </configItem>
- </option>
- <option>
- <configItem>
- <name>lv3:lsgt_switch</name>
- <description>&lt;Less/Greater&gt;</description>
- </configItem>
- </option>
- <option>
- <configItem>
- <name>lv3:caps_switch_latch</name>
- <description>Caps Lock (chooses 3rd level, latches when pressed together with another 3rd-level-chooser)</description>
- </configItem>
- </option>
- <option>
- <configItem>
- <name>lv3:bksl_switch_latch</name>
- <description>Backslash chooses 3rd level, latches when pressed together with another 3rd-level-chooser)</description>
- </configItem>
- </option>
- <option>
- <configItem>
- <name>lv3:lsgt_switch_latch</name>
- <description>&lt;Less/Greater&gt; (chooses 3rd level, latches when pressed together with another 3rd-level-chooser)</description>
- </configItem>
- </option>
- </group>
- <group allowMultipleSelection="true">
- <!-- Tweaking the position of the "Ctrl" key -->
- <configItem>
- <name>ctrl</name>
- <_description>Ctrl key position</_description>
- </configItem>
- <option>
- <configItem>
- <name>ctrl:nocaps</name>
- <_description>Make Caps Lock an additional Ctrl</_description>
- </configItem>
- </option>
- <option>
- <configItem>
- <name>ctrl:lctrl_meta</name>
- <_description>Meta on Left Ctrl</_description>
- </configItem>
- </option>
- <option>
- <configItem>
- <name>ctrl:swapcaps</name>
- <_description>Swap Ctrl and Caps Lock</_description>
- </configItem>
- </option>
- <option>
- <configItem>
- <name>ctrl:ctrl_ac</name>
- <_description>At left of 'A'</_description>
- </configItem>
- </option>
- <option>
- <configItem>
- <name>ctrl:ctrl_aa</name>
- <_description>At bottom left</_description>
- </configItem>
- </option>
- <option>
- <configItem>
- <name>ctrl:ctrl_ra</name>
- <_description>Right Ctrl as Right Alt</_description>
- </configItem>
- </option>
- <option>
- <configItem>
- <name>ctrl:ctrl_menu</name>
- <description>Right Ctrl is mapped to Menu</description>
- </configItem>
- </option>
- </group>
- <group allowMultipleSelection="true">
- <!-- Using startard LEDs to indicate the alternative (not first) group(s) -->
- <configItem>
- <name>grp_led</name>
- <_description>Use keyboard LED to show alternative layout</_description>
- </configItem>
- <option>
- <configItem>
- <name>grp_led:num</name>
- <_description>Num Lock</_description>
- </configItem>
- </option>
- <option>
- <configItem>
- <name>grp_led:caps</name>
- <_description>Caps Lock</_description>
- </configItem>
- </option>
- <option>
- <configItem>
- <name>grp_led:scroll</name>
- <_description>Scroll Lock</_description>
- </configItem>
- </option>
- </group>
- <group allowMultipleSelection="false">
- <!-- Select a keypad type -->
- <configItem>
- <name>keypad</name>
- <_description>Numeric keypad layout selection</_description>
- </configItem>
- <option>
- <configItem>
- <name>keypad:legacy</name>
- <_description>Legacy</_description>
- </configItem>
- </option>
- <option>
- <configItem>
- <name>keypad:oss</name>
- <_description>Unicode additions (arrows and math operators)</_description>
- </configItem>
- </option>
- <option>
- <configItem>
- <name>keypad:future</name>
- <_description>Unicode additions (arrows and math operators). Math operators on default level</_description>
- </configItem>
- </option>
- <option>
- <configItem>
- <name>keypad:legacy_wang</name>
- <_description>Legacy Wang 724</_description>
- </configItem>
- </option>
- <option>
- <configItem>
- <name>keypad:oss_wang</name>
- <_description>Wang 724 keypad with unicode additions (arrows and math operators)</_description>
- </configItem>
- </option>
- <option>
- <configItem>
- <name>keypad:future_wang</name>
- <_description>Wang 724 keypad with unicode additions (arrows and math operators). Math operators on default level</_description>
- </configItem>
- </option>
- <option>
- <configItem>
- <name>keypad:hex</name>
- <_description>Hexadecimal</_description>
- </configItem>
- </option>
- <option>
- <configItem>
- <name>keypad:atm</name>
- <_description>ATM/phone-style</_description>
- </configItem>
- </option>
- </group>
- <!-- This option should override the KPDL key defined in keypad; I hope it's declared in the right place -->
- <group allowMultipleSelection="false">
- <!-- Select a keypad KPDL variant -->
- <configItem>
- <name>kpdl</name>
- <_description>Numeric keypad delete key behaviour</_description>
- </configItem>
- <option>
- <configItem>
- <!-- Actually, with KP_DECIMAL, as the old keypad(dot) -->
- <name>kpdl:dot</name>
- <_description>Legacy key with dot</_description>
- </configItem>
- </option>
- <option>
- <configItem>
- <name>kpdl:comma</name>
- <!-- Actually, with KP_SEPARATOR, as the old keypad(comma) -->
- <_description>Legacy key with comma</_description>
- </configItem>
- </option>
- <option>
- <configItem>
- <name>kpdl:dotoss</name>
- <_description>Four-level key with dot</_description>
- </configItem>
- </option>
- <option>
- <configItem>
- <name>kpdl:dotoss_latin9</name>
- <_description>Four-level key with dot, latin-9 restriction</_description>
- </configItem>
- </option>
- <option>
- <configItem>
- <name>kpdl:commaoss</name>
- <_description>Four-level key with comma</_description>
- </configItem>
- </option>
- <option>
- <configItem>
- <name>kpdl:momayyezoss</name>
- <_description>Four-level key with momayyez</_description>
- </configItem>
- </option>
- <option>
- <configItem>
- <name>kpdl:kposs</name>
- <!-- This assumes the KP_ abstract symbols are actually useful for some apps
- The description needs to be rewritten -->
- <_description>Four-level key with abstract separators</_description>
- </configItem>
- </option>
- <option>
- <configItem>
- <name>kpdl:semi</name>
- <_description>Semi-colon on third level</_description>
- </configItem>
- </option>
- </group>
- <group allowMultipleSelection="false">
- <!-- Caps Lock tweaks.
- "Internal" capitalization means capitalization using some internal tables.
- Otherwise "as Shift" - means using next group. -->
- <configItem>
- <name>caps</name>
- <_description>Caps Lock key behavior</_description>
- </configItem>
- <option>
- <configItem>
- <name>caps:internal</name>
- <_description>Caps Lock uses internal capitalization. Shift "pauses" Caps Lock</_description>
- </configItem>
- </option>
- <option>
- <configItem>
- <name>caps:internal_nocancel</name>
- <_description>Caps Lock uses internal capitalization. Shift doesn't affect Caps Lock</_description>
- </configItem>
- </option>
- <option>
- <configItem>
- <name>caps:shift</name>
- <_description>Caps Lock acts as Shift with locking. Shift "pauses" Caps Lock</_description>
- </configItem>
- </option>
- <option>
- <configItem>
- <name>caps:shift_nocancel</name>
- <_description>Caps Lock acts as Shift with locking. Shift doesn't affect Caps Lock</_description>
- </configItem>
- </option>
- <option>
- <configItem>
- <name>caps:capslock</name>
- <_description>Caps Lock toggles normal capitalization of alphabetic characters</_description>
- </configItem>
- </option>
- <option>
- <configItem>
- <name>caps:numlock</name>
- <_description>Make Caps Lock an additional Num Lock</_description>
- </configItem>
- </option>
- <option>
- <configItem>
- <name>caps:swapescape</name>
- <_description>Swap ESC and Caps Lock</_description>
- </configItem>
- </option>
- <option>
- <configItem>
- <name>caps:escape</name>
- <_description>Make Caps Lock an additional ESC</_description>
- </configItem>
- </option>
- <option>
- <configItem>
- <name>caps:backspace</name>
- <_description>Make Caps Lock an additional Backspace</_description>
- </configItem>
- </option>
- <option>
- <configItem>
- <name>caps:super</name>
- <_description>Make Caps Lock an additional Super</_description>
- </configItem>
- </option>
- <option>
- <configItem>
- <name>caps:hyper</name>
- <_description>Make Caps Lock an additional Hyper</_description>
- </configItem>
- </option>
- <option>
- <configItem>
- <name>caps:shiftlock</name>
- <_description>Caps Lock toggles Shift so all keys are affected</_description>
- </configItem>
- </option>
- <option>
- <configItem>
- <name>caps:none</name>
- <_description>Caps Lock is disabled</_description>
- </configItem>
- </option>
- </group>
- <group allowMultipleSelection="false">
- <!-- Using special PC keys (Win, Menu) to work as standard X keys (Super, Hyper, etc.) -->
- <configItem>
- <name>altwin</name>
- <_description>Alt/Win key behavior</_description>
- </configItem>
- <option>
- <configItem>
- <name>altwin:menu</name>
- <_description>Add the standard behavior to Menu key</_description>
- </configItem>
- </option>
- <option>
- <configItem>
- <name>altwin:meta_alt</name>
- <_description>Alt and Meta are on Alt keys</_description>
- </configItem>
- </option>
- <option>
- <configItem>
- <name>altwin:ctrl_win</name>
- <_description>Control is mapped to Win keys (and the usual Ctrl keys)</_description>
- </configItem>
- </option>
- <option>
- <configItem>
- <name>altwin:ctrl_alt_win</name>
- <_description>Control is mapped to Alt keys, Alt is mapped to Win keys</_description>
- </configItem>
- </option>
- <option>
- <configItem>
- <name>altwin:meta_win</name>
- <_description>Meta is mapped to Win keys</_description>
- </configItem>
- </option>
- <option>
- <configItem>
- <name>altwin:left_meta_win</name>
- <_description>Meta is mapped to Left Win</_description>
- </configItem>
- </option>
- <option>
- <configItem>
- <name>altwin:hyper_win</name>
- <_description>Hyper is mapped to Win-keys</_description>
- </configItem>
- </option>
- <option>
- <configItem>
- <name>altwin:alt_super_win</name>
- <_description>Alt is mapped to Right Win, Super to Menu</_description>
- </configItem>
- </option>
- <option>
- <configItem>
- <name>altwin:swap_lalt_lwin</name>
- <_description>Left Alt is swapped with Left Win</_description>
- </configItem>
- </option>
- </group>
- <group allowMultipleSelection="true">
- <!-- Tweaking the position of the "Compose" key: mapping to existing PC keys -->
- <configItem>
- <name>Compose key</name>
- <_description>Compose key position</_description>
- </configItem>
- <option>
- <configItem>
- <name>compose:ralt</name>
- <_description>Right Alt</_description>
- </configItem>
- </option>
- <option>
- <configItem>
- <name>compose:lwin</name>
- <_description>Left Win</_description>
- </configItem>
- </option>
- <option>
- <configItem>
- <name>compose:rwin</name>
- <_description>Right Win</_description>
- </configItem>
- </option>
- <option>
- <configItem>
- <name>compose:menu</name>
- <_description>Menu</_description>
- </configItem>
- </option>
- <option>
- <configItem>
- <name>compose:lctrl</name>
- <_description>Left Ctrl</_description>
- </configItem>
- </option>
- <option>
- <configItem>
- <name>compose:rctrl</name>
- <_description>Right Ctrl</_description>
- </configItem>
- </option>
- <option>
- <configItem>
- <name>compose:caps</name>
- <_description>Caps Lock</_description>
- </configItem>
- </option>
- <option>
- <configItem>
- <name>compose:102</name>
- <_description>&lt;Less/Greater&gt;</_description>
- </configItem>
- </option>
- <option>
- <configItem>
- <name>compose:paus</name>
- <_description>Pause</_description>
- </configItem>
- </option>
- <option>
- <configItem>
- <name>compose:prsc</name>
- <_description>PrtSc</_description>
- </configItem>
- </option>
- <option>
- <configItem>
- <name>compose:sclk</name>
- <_description>Scroll Lock</_description>
- </configItem>
- </option>
- </group>
- <group allowMultipleSelection="true">
- <configItem>
- <name>compat</name>
- <_description>Miscellaneous compatibility options</_description>
- </configItem>
- <option>
- <configItem>
- <name>numpad:pc</name>
- <_description>Default numeric keypad keys</_description>
- </configItem>
- </option>
- <option>
- <configItem>
- <name>numpad:mac</name>
- <_description>Numeric keypad keys work as with Mac</_description>
- </configItem>
- </option>
- <option>
- <configItem>
- <name>numpad:microsoft</name>
- <_description>Shift with numeric keypad keys works as in MS Windows</_description>
- </configItem>
- </option>
- <option>
- <configItem>
- <name>numpad:shift3</name>
- <_description>Shift does not cancel Num Lock, chooses 3rd level instead</_description>
- </configItem>
- </option>
- <option>
- <configItem>
- <name>srvrkeys:none</name>
- <_description>Special keys (Ctrl+Alt+&lt;key&gt;) handled in a server</_description>
- </configItem>
- </option>
- <option>
- <configItem>
- <name>apple:alupckeys</name>
- <_description>Apple Aluminium Keyboard: emulate PC keys (Print, Scroll Lock, Pause, Num Lock)</_description>
- </configItem>
- </option>
- <option>
- <configItem>
- <name>shift:breaks_caps</name>
- <_description>Shift cancels Caps Lock</_description>
- </configItem>
- </option>
- <option>
- <configItem>
- <name>misc:typo</name>
- <_description>Enable extra typographic characters</_description>
- </configItem>
- </option>
- <option>
- <configItem>
- <name>shift:both_capslock</name>
- <_description>Both Shift-Keys together toggle Caps Lock</_description>
- </configItem>
- </option>
- <option>
- <configItem>
- <name>shift:both_capslock_cancel</name>
- <description>Both Shift-Keys together activate Caps Lock, one Shift-Key deactivates</description>
- </configItem>
- </option>
- <option>
- <configItem>
- <name>shift:both_shiftlock</name>
- <description>Both Shift-Keys together toggle ShiftLock</description>
- </configItem>
- </option>
- <option>
- <configItem>
- <name>keypad:pointerkeys</name>
- <_description>Toggle PointerKeys with Shift + NumLock.</_description>
- </configItem>
- </option>
- </group>
- <group allowMultipleSelection="true">
- <!-- Special shortcuts for the Euro character -->
- <configItem>
- <name>eurosign</name>
- <_description>Adding currency signs to certain keys</_description>
- </configItem>
- <option>
- <configItem>
- <name>eurosign:e</name>
- <_description>Euro on E</_description>
- </configItem>
- </option>
- <option>
- <configItem>
- <name>eurosign:2</name>
- <_description>Euro on 2</_description>
- </configItem>
- </option>
- <option>
- <configItem>
- <name>eurosign:4</name>
- <_description>Euro on 4</_description>
- </configItem>
- </option>
- <option>
- <configItem>
- <name>eurosign:5</name>
- <_description>Euro on 5</_description>
- </configItem>
- </option>
- <option>
- <configItem>
- <name>rupeesign:4</name>
- <_description>Rupee on 4</_description>
- </configItem>
- </option>
- </group>
- <group allowMultipleSelection="true">
- <configItem>
- <name>lv5</name>
- <_description>Key to choose 5th level</_description>
- </configItem>
- <option>
- <configItem>
- <name>lv5:lsgt_switch_lock</name>
- <_description>&lt;Less/Greater&gt; chooses 5th level, locks when pressed together with another 5th-level-chooser</_description>
- </configItem>
- </option>
- <option>
- <configItem>
- <name>lv5:ralt_switch_lock</name>
- <_description>Right Alt chooses 5th level, locks when pressed together with another 5th-level-chooser</_description>
- </configItem>
- </option>
- <option>
- <configItem>
- <name>lv5:lwin_switch_lock</name>
- <_description>Left Win chooses 5th level, locks when pressed together with another 5th-level-chooser</_description>
- </configItem>
- </option>
- <option>
- <configItem>
- <name>lv5:rwin_switch_lock</name>
- <_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>
- <_description>&lt;Less/Greater&gt; chooses 5th level, locks when pressed together with another 5th-level-chooser, one press releases the lock</_description>
- </configItem>
- </option>
- <option>
- <configItem>
- <name>lv5:ralt_switch_lock_cancel</name>
- <_description>Right Alt chooses 5th level, locks when pressed together with another 5th-level-chooser, one press releases the lock</_description>
- </configItem>
- </option>
- <option>
- <configItem>
- <name>lv5:lwin_switch_lock_cancel</name>
- <_description>Left Win chooses 5th level, locks when pressed together with another 5th-level-chooser, one press releases the lock</_description>
- </configItem>
- </option>
- <option>
- <configItem>
- <name>lv5:rwin_switch_lock_cancel</name>
- <_description>Right Win chooses 5th level, locks when pressed together with another 5th-level-chooser, one press releases the lock</_description>
- </configItem>
- </option>
- <option>
- <configItem>
- <name>lv5:lsgt_switch_lock_cancel</name>
- <description>&lt;Less/Greater&gt; chooses 5th level and activates level5-Lock when pressed together with another 5th-level-chooser, one press releases the lock</description>
- </configItem>
- </option>
- <option>
- <configItem>
- <name>lv5:ralt_switch_lock_cancel</name>
- <description>Right Alt chooses 5th level and activates level5-Lock when pressed together with another 5th-level-chooser, one press releases the lock</description>
- </configItem>
- </option>
- </group>
- <group allowMultipleSelection="false">
- <!-- Let space output NBSP, NNBSP, ZWNJ, and ZWJ for the desired level -->
- <configItem>
- <name>nbsp</name>
- <_description>Using space key to input non-breakable space character</_description>
- </configItem>
- <option>
- <configItem>
- <name>nbsp:none</name>
- <_description>Usual space at any level</_description>
- </configItem>
- </option>
- <option>
- <configItem>
- <name>nbsp:level2</name>
- <_description>Non-breakable space character at second level</_description>
- </configItem>
- </option>
- <option>
- <configItem>
- <name>nbsp:level3</name>
- <_description>Non-breakable space character at third level</_description>
- </configItem>
- </option>
- <option>
- <configItem>
- <name>nbsp:level3s</name>
- <_description>Non-breakable space character at third level, nothing at fourth level</_description>
- </configItem>
- </option>
- <option>
- <configItem>
- <name>nbsp:level3n</name>
- <_description>Non-breakable space character at third level, thin non-breakable space character at fourth level</_description>
- </configItem>
- </option>
- <option>
- <configItem>
- <name>nbsp:level4</name>
- <_description>Non-breakable space character at fourth level</_description>
- </configItem>
- </option>
- <option>
- <configItem>
- <name>nbsp:level4n</name>
- <_description>Non-breakable space character at fourth level, thin non-breakable space character at sixth level</_description>
- </configItem>
- </option>
- <option>
- <configItem>
- <name>nbsp:level4nl</name>
- <_description>Non-breakable space character at fourth level, thin non-breakable space character at sixth level (via Ctrl+Shift)</_description>
- </configItem>
- </option>
- <option>
- <configItem>
- <name>nbsp:zwnj2</name>
- <_description>Zero-width non-joiner character at second level</_description>
- </configItem>
- </option>
- <option>
- <configItem>
- <name>nbsp:zwnj2zwj3</name>
- <_description>Zero-width non-joiner character at second level, zero-width joiner character at third level</_description>
- </configItem>
- </option>
- <option>
- <configItem>
- <name>nbsp:zwnj2zwj3nb4</name>
- <_description>Zero-width non-joiner character at second level, zero-width joiner character at third level, non-breakable space character at fourth level</_description>
- </configItem>
- </option>
- <option>
- <configItem>
- <name>nbsp:zwnj2nb3</name>
- <_description>Zero-width non-joiner character at second level, non-breakable space character at third level</_description>
- </configItem>
- </option>
- <option>
- <configItem>
- <name>nbsp:zwnj2nb3s</name>
- <_description>Zero-width non-joiner character at second level, non-breakable space character at third level, nothing at fourth level</_description>
- </configItem>
- </option>
- <option>
- <configItem>
- <name>nbsp:zwnj2nb3zwj4</name>
- <_description>Zero-width non-joiner character at second level, non-breakable space character at third level, zero-width joiner at fourth level</_description>
- </configItem>
- </option>
- <option>
- <configItem>
- <name>nbsp:zwnj2nb3nnb4</name>
- <_description>Zero-width non-joiner character at second level, non-breakable space character at third level, thin non-breakable space at fourth level</_description>
- </configItem>
- </option>
- <option>
- <configItem>
- <name>nbsp:zwnj3zwj4</name>
- <_description>Zero-width non-joiner character at third level, zero-width joiner at fourth level</_description>
- </configItem>
- </option>
- </group>
- <group allowMultipleSelection="true">
- <configItem>
- <name>japan</name>
- <_description>Japanese keyboard options</_description>
- </configItem>
- <option>
- <configItem>
- <name>japan:kana_lock</name>
- <_description>Kana Lock key is locking</_description>
- </configItem>
- </option>
- <option>
- <configItem>
- <name>japan:nicola_f_bs</name>
- <_description>NICOLA-F style Backspace</_description>
- </configItem>
- </option>
- </group>
- <group allowMultipleSelection="false">
- <configItem>
- <name>esperanto</name>
- <_description>Adding Esperanto circumflexes (supersigno)</_description>
- </configItem>
- <option>
- <configItem>
- <name>esperanto:qwerty</name>
- <_description>To the corresponding key in a Qwerty keyboard.</_description>
- </configItem>
- </option>
- <option>
- <configItem>
- <name>esperanto:dvorak</name>
- <_description>To the corresponding key in a Dvorak keyboard.</_description>
- </configItem>
- </option>
- </group>
- <group allowMultipleSelection="true">
- <configItem>
- <name>terminate</name>
- <_description>Key sequence to kill the X server</_description>
- </configItem>
- <option>
- <configItem>
- <name>terminate:ctrl_alt_bksp</name>
- <_description>Control + Alt + Backspace</_description>
- </configItem>
- </option>
- </group>
- </optionList>
-</xkbConfigRegistry>
+<?xml version="1.0" encoding="utf-8"?>
+<!DOCTYPE xkbConfigRegistry SYSTEM "xkb.dtd">
+<xkbConfigRegistry>
+ <modelList>
+ <model>
+ <configItem>
+ <name>pc101</name>
+ <_description>Generic 101-key PC</_description>
+ <vendor>Generic</vendor>
+ </configItem>
+ </model>
+ <model>
+ <configItem>
+ <name>pc102</name>
+ <_description>Generic 102-key (Intl) PC</_description>
+ <vendor>Generic</vendor>
+ </configItem>
+ </model>
+ <model>
+ <configItem>
+ <name>pc104</name>
+ <_description>Generic 104-key PC</_description>
+ <vendor>Generic</vendor>
+ </configItem>
+ </model>
+ <model>
+ <configItem>
+ <name>pc105</name>
+ <_description>Generic 105-key (Intl) PC</_description>
+ <vendor>Generic</vendor>
+ </configItem>
+ </model>
+ <model>
+ <configItem>
+ <name>dell101</name>
+ <_description>Dell 101-key PC</_description>
+ <vendor>Dell</vendor>
+ </configItem>
+ </model>
+ <model>
+ <configItem>
+ <name>latitude</name>
+ <_description>Dell Latitude series laptop</_description>
+ <vendor>Dell</vendor>
+ </configItem>
+ </model>
+ <model>
+ <configItem>
+ <name>dellm65</name>
+ <_description>Dell Precision M65</_description>
+ <vendor>Dell</vendor>
+ </configItem>
+ </model>
+ <model>
+ <configItem>
+ <name>everex</name>
+ <_description>Everex STEPnote</_description>
+ <vendor>Everex</vendor>
+ </configItem>
+ </model>
+ <model>
+ <configItem>
+ <name>flexpro</name>
+ <_description>Keytronic FlexPro</_description>
+ <vendor>Keytronic</vendor>
+ </configItem>
+ </model>
+ <model>
+ <configItem>
+ <name>microsoft</name>
+ <_description>Microsoft Natural</_description>
+ <vendor>Microsoft Inc.</vendor>
+ </configItem>
+ </model>
+ <model>
+ <configItem>
+ <name>omnikey101</name>
+ <_description>Northgate OmniKey 101</_description>
+ <vendor>Northgate</vendor>
+ </configItem>
+ </model>
+ <model>
+ <configItem>
+ <name>winbook</name>
+ <_description>Winbook Model XP5</_description>
+ <vendor>Generic</vendor>
+ </configItem>
+ </model>
+ <model>
+ <configItem>
+ <name>pc98</name>
+ <_description>PC-98xx Series</_description>
+ <vendor>Generic</vendor>
+ </configItem>
+ </model>
+ <model>
+ <configItem>
+ <name>a4techKB21</name>
+ <_description>A4Tech KB-21</_description>
+ <vendor>A4Tech</vendor>
+ </configItem>
+ </model>
+ <model>
+ <configItem>
+ <name>a4techKBS8</name>
+ <_description>A4Tech KBS-8</_description>
+ <vendor>A4Tech</vendor>
+ </configItem>
+ </model>
+ <model>
+ <configItem>
+ <name>a4_rfkb23</name>
+ <_description>A4Tech Wireless Desktop RFKB-23</_description>
+ <vendor>A4Tech</vendor>
+ </configItem>
+ </model>
+ <model>
+ <configItem>
+ <name>airkey</name>
+ <_description>Acer AirKey V</_description>
+ <vendor>Acer</vendor>
+ </configItem>
+ </model>
+ <model>
+ <configItem>
+ <name>azonaRF2300</name>
+ <_description>Azona RF2300 wireless Internet Keyboard</_description>
+ <vendor>Azona</vendor>
+ </configItem>
+ </model>
+ <model>
+ <configItem>
+ <name>scorpius</name>
+ <_description>Advance Scorpius KI</_description>
+ <vendor>Scorpius</vendor>
+ </configItem>
+ </model>
+ <model>
+ <configItem>
+ <name>brother</name>
+ <_description>Brother Internet Keyboard</_description>
+ <vendor>Brother</vendor>
+ </configItem>
+ </model>
+ <model>
+ <configItem>
+ <name>btc5113rf</name>
+ <_description>BTC 5113RF Multimedia</_description>
+ <vendor>BTC</vendor>
+ </configItem>
+ </model>
+ <model>
+ <configItem>
+ <name>btc5126t</name>
+ <_description>BTC 5126T</_description>
+ <vendor>BTC</vendor>
+ </configItem>
+ </model>
+ <model>
+ <configItem>
+ <name>btc6301urf</name>
+ <_description>BTC 6301URF</_description>
+ <vendor>BTC</vendor>
+ </configItem>
+ </model>
+ <model>
+ <configItem>
+ <name>btc9000</name>
+ <_description>BTC 9000</_description>
+ <vendor>BTC</vendor>
+ </configItem>
+ </model>
+ <model>
+ <configItem>
+ <name>btc9000a</name>
+ <_description>BTC 9000A</_description>
+ <vendor>BTC</vendor>
+ </configItem>
+ </model>
+ <model>
+ <configItem>
+ <name>btc9001ah</name>
+ <_description>BTC 9001AH</_description>
+ <vendor>BTC</vendor>
+ </configItem>
+ </model>
+ <model>
+ <configItem>
+ <name>btc5090</name>
+ <_description>BTC 5090</_description>
+ <vendor>BTC</vendor>
+ </configItem>
+ </model>
+ <model>
+ <configItem>
+ <name>btc9019u</name>
+ <_description>BTC 9019U</_description>
+ <vendor>BTC</vendor>
+ </configItem>
+ </model>
+ <model>
+ <configItem>
+ <name>btc9116u</name>
+ <_description>BTC 9116U Mini Wireless Internet and Gaming</_description>
+ </configItem>
+ </model>
+ <model>
+ <configItem>
+ <name>cherryblue</name>
+ <_description>Cherry Blue Line CyBo@rd</_description>
+ </configItem>
+ </model>
+ <model>
+ <configItem>
+ <name>cherryblueb</name>
+ <_description>Cherry CyMotion Master XPress</_description>
+ <vendor>Cherry</vendor>
+ </configItem>
+ </model>
+ <model>
+ <configItem>
+ <name>cherrybluea</name>
+ <_description>Cherry Blue Line CyBo@rd (alternate option)</_description>
+ <vendor>Cherry</vendor>
+ </configItem>
+ </model>
+ <model>
+ <configItem>
+ <name>cherrycyboard</name>
+ <_description>Cherry CyBo@rd USB-Hub</_description>
+ <vendor>Cherry</vendor>
+ </configItem>
+ </model>
+ <model>
+ <configItem>
+ <name>cherrycmexpert</name>
+ <_description>Cherry CyMotion Expert</_description>
+ <vendor>Cherry</vendor>
+ </configItem>
+ </model>
+ <model>
+ <configItem>
+ <name>cherrybunlim</name>
+ <_description>Cherry B.UNLIMITED</_description>
+ <vendor>Cherry</vendor>
+ </configItem>
+ </model>
+ <model>
+ <configItem>
+ <name>chicony</name>
+ <_description>Chicony Internet Keyboard</_description>
+ <vendor>Chicony</vendor>
+ </configItem>
+ </model>
+ <model>
+ <configItem>
+ <name>chicony0108</name>
+ <_description>Chicony KU-0108</_description>
+ <vendor>Chicony</vendor>
+ </configItem>
+ </model>
+ <model>
+ <configItem>
+ <name>chicony0420</name>
+ <_description>Chicony KU-0420</_description>
+ <vendor>Chicony</vendor>
+ </configItem>
+ </model>
+ <model>
+ <configItem>
+ <name>chicony9885</name>
+ <_description>Chicony KB-9885</_description>
+ <vendor>Chicony</vendor>
+ </configItem>
+ </model>
+ <model>
+ <configItem>
+ <name>compaqeak8</name>
+ <_description>Compaq Easy Access Keyboard</_description>
+ <vendor>Compaq</vendor>
+ </configItem>
+ </model>
+ <model>
+ <configItem>
+ <name>compaqik7</name>
+ <_description>Compaq Internet Keyboard (7 keys)</_description>
+ <vendor>Compaq</vendor>
+ </configItem>
+ </model>
+ <model>
+ <configItem>
+ <name>compaqik13</name>
+ <_description>Compaq Internet Keyboard (13 keys)</_description>
+ <vendor>Compaq</vendor>
+ </configItem>
+ </model>
+ <model>
+ <configItem>
+ <name>compaqik18</name>
+ <_description>Compaq Internet Keyboard (18 keys)</_description>
+ <vendor>Compaq</vendor>
+ </configItem>
+ </model>
+ <model>
+ <configItem>
+ <name>cymotionlinux</name>
+ <_description>Cherry CyMotion Master Linux</_description>
+ <vendor>Cherry</vendor>
+ </configItem>
+ </model>
+ <model>
+ <configItem>
+ <name>armada</name>
+ <_description>Laptop/notebook Compaq (eg. Armada) Laptop Keyboard</_description>
+ <vendor>Compaq</vendor>
+ </configItem>
+ </model>
+ <model>
+ <configItem>
+ <name>presario</name>
+ <_description>Laptop/notebook Compaq (eg. Presario) Internet Keyboard</_description>
+ <vendor>Compaq</vendor>
+ </configItem>
+ </model>
+ <model>
+ <configItem>
+ <name>ipaq</name>
+ <_description>Compaq iPaq Keyboard</_description>
+ <vendor>Compaq</vendor>
+ </configItem>
+ </model>
+ <model>
+ <configItem>
+ <name>dell</name>
+ <_description>Dell</_description>
+ <vendor>Dell</vendor>
+ </configItem>
+ </model>
+ <model>
+ <configItem>
+ <name>dellsk8125</name>
+ <_description>Dell SK-8125</_description>
+ <vendor>Dell</vendor>
+ </configItem>
+ </model>
+ <model>
+ <configItem>
+ <name>dellsk8135</name>
+ <_description>Dell SK-8135</_description>
+ <vendor>Dell</vendor>
+ </configItem>
+ </model>
+ <model>
+ <configItem>
+ <name>dellusbmm</name>
+ <_description>Dell USB Multimedia Keyboard</_description>
+ <vendor>Dell</vendor>
+ </configItem>
+ </model>
+ <model>
+ <configItem>
+ <name>inspiron</name>
+ <_description>Dell Laptop/notebook Inspiron 6xxx/8xxx</_description>
+ <vendor>Dell</vendor>
+ </configItem>
+ </model>
+ <model>
+ <configItem>
+ <name>precision_m</name>
+ <_description>Dell Laptop/notebook Precision M series</_description>
+ <vendor>Dell</vendor>
+ </configItem>
+ </model>
+ <model>
+ <configItem>
+ <name>dexxa</name>
+ <_description>Dexxa Wireless Desktop Keyboard</_description>
+ <vendor>Dexxa</vendor>
+ </configItem>
+ </model>
+ <model>
+ <configItem>
+ <name>diamond</name>
+ <_description>Diamond 9801 / 9802 series</_description>
+ <vendor>Diamond</vendor>
+ </configItem>
+ </model>
+ <model>
+ <configItem>
+ <name>dtk2000</name>
+ <_description>DTK2000</_description>
+ </configItem>
+ </model>
+ <model>
+ <configItem>
+ <name>ennyah_dkb1008</name>
+ <_description>Ennyah DKB-1008</_description>
+ <vendor>Ennyah</vendor>
+ </configItem>
+ </model>
+ <model>
+ <configItem>
+ <name>fscaa1667g</name>
+ <_description>Fujitsu-Siemens Computers AMILO laptop</_description>
+ <vendor>Fujitsu-Siemens</vendor>
+ </configItem>
+ </model>
+ <model>
+ <configItem>
+ <name>genius</name>
+ <_description>Genius Comfy KB-16M / Genius MM Keyboard KWD-910</_description>
+ <vendor>Genius</vendor>
+ </configItem>
+ </model>
+ <model>
+ <configItem>
+ <name>geniuscomfy</name>
+ <_description>Genius Comfy KB-12e</_description>
+ <vendor>Genius</vendor>
+ </configItem>
+ </model>
+ <model>
+ <configItem>
+ <name>geniuscomfy2</name>
+ <_description>Genius Comfy KB-21e-Scroll</_description>
+ <vendor>Genius</vendor>
+ </configItem>
+ </model>
+ <model>
+ <configItem>
+ <name>geniuskb19e</name>
+ <_description>Genius KB-19e NB</_description>
+ <vendor>Genius</vendor>
+ </configItem>
+ </model>
+ <model>
+ <configItem>
+ <name>geniuskkb2050hs</name>
+ <_description>Genius KKB-2050HS</_description>
+ <vendor>Genius</vendor>
+ </configItem>
+ </model>
+ <model>
+ <configItem>
+ <name>gyration</name>
+ <_description>Gyration</_description>
+ <vendor>Gyration</vendor>
+ </configItem>
+ </model>
+ <model>
+ <configItem>
+ <name>htcdream</name>
+ <_description>HTC Dream</_description>
+ <vendor>HTC</vendor>
+ </configItem>
+ </model>
+ <model>
+ <configItem>
+ <name>kinesis</name>
+ <_description>Kinesis</_description>
+ <vendor>Kinesis</vendor>
+ </configItem>
+ </model>
+ <model>
+ <configItem>
+ <name>logitech_base</name>
+ <_description>Logitech Generic Keyboard</_description>
+ <vendor>Logitech</vendor>
+ </configItem>
+ </model>
+ <model>
+ <configItem>
+ <name>logitech_g15</name>
+ <_description>Logitech G15 extra keys via G15daemon</_description>
+ <vendor>Logitech</vendor>
+ </configItem>
+ </model>
+ <model>
+ <configItem>
+ <name>hpi6</name>
+ <_description>Hewlett-Packard Internet Keyboard</_description>
+ <vendor>Hewlett-Packard</vendor>
+ </configItem>
+ </model>
+ <model>
+ <configItem>
+ <name>hp250x</name>
+ <_description>Hewlett-Packard SK-250x Multimedia Keyboard</_description>
+ <vendor>Hewlett-Packard</vendor>
+ </configItem>
+ </model>
+ <model>
+ <configItem>
+ <name>hpxe3gc</name>
+ <_description>Hewlett-Packard Omnibook XE3 GC</_description>
+ <vendor>Hewlett-Packard</vendor>
+ </configItem>
+ </model>
+ <model>
+ <configItem>
+ <name>hpxe3gf</name>
+ <_description>Hewlett-Packard Omnibook XE3 GF</_description>
+ <vendor>Hewlett-Packard</vendor>
+ </configItem>
+ </model>
+ <model>
+ <configItem>
+ <name>hpxt1000</name>
+ <_description>Hewlett-Packard Omnibook XT1000</_description>
+ <vendor>Hewlett-Packard</vendor>
+ </configItem>
+ </model>
+ <model>
+ <configItem>
+ <name>hpdv5</name>
+ <_description>Hewlett-Packard Pavilion dv5</_description>
+ <vendor>Hewlett-Packard</vendor>
+ </configItem>
+ </model>
+ <model>
+ <configItem>
+ <name>hpzt11xx</name>
+ <_description>Hewlett-Packard Pavilion ZT11xx</_description>
+ <vendor>Hewlett-Packard</vendor>
+ </configItem>
+ </model>
+ <model>
+ <configItem>
+ <name>hp500fa</name>
+ <_description>Hewlett-Packard Omnibook 500 FA</_description>
+ <vendor>Hewlett-Packard</vendor>
+ </configItem>
+ </model>
+ <model>
+ <configItem>
+ <name>hp5xx</name>
+ <_description>Hewlett-Packard Omnibook 5xx</_description>
+ <vendor>Hewlett-Packard</vendor>
+ </configItem>
+ </model>
+ <model>
+ <configItem>
+ <name>hpnx9020</name>
+ <_description>Hewlett-Packard nx9020</_description>
+ <vendor>Hewlett-Packard</vendor>
+ </configItem>
+ </model>
+ <model>
+ <configItem>
+ <name>hp6000</name>
+ <_description>Hewlett-Packard Omnibook 6000/6100</_description>
+ <vendor>Hewlett-Packard</vendor>
+ </configItem>
+ </model>
+ <model>
+ <configItem>
+ <name>honeywell_euroboard</name>
+ <_description>Honeywell Euroboard</_description>
+ <vendor>Hewlett-Packard</vendor>
+ </configItem>
+ </model>
+ <model>
+ <configItem>
+ <name>hpmini110</name>
+ <_description>Hewlett-Packard Mini 110 Notebook</_description>
+ <vendor>Hewlett-Packard</vendor>
+ </configItem>
+ </model>
+ <model>
+ <configItem>
+ <name>rapidaccess</name>
+ <_description>IBM Rapid Access</_description>
+ <vendor>Lenovo (previously IBM)</vendor>
+ </configItem>
+ </model>
+ <model>
+ <configItem>
+ <name>rapidaccess2</name>
+ <_description>IBM Rapid Access II</_description>
+ <vendor>Lenovo (previously IBM)</vendor>
+ </configItem>
+ </model>
+ <model>
+ <configItem>
+ <name>thinkpad</name>
+ <_description>IBM ThinkPad 560Z/600/600E/A22E</_description>
+ <vendor>Lenovo (previously IBM)</vendor>
+ </configItem>
+ </model>
+ <model>
+ <configItem>
+ <name>thinkpad60</name>
+ <_description>IBM ThinkPad R60/T60/R61/T61</_description>
+ <vendor>Lenovo (previously IBM)</vendor>
+ </configItem>
+ </model>
+ <model>
+ <configItem>
+ <name>thinkpadz60</name>
+ <_description>IBM ThinkPad Z60m/Z60t/Z61m/Z61t</_description>
+ <vendor>Lenovo (previously IBM)</vendor>
+ </configItem>
+ </model>
+ <model>
+ <configItem>
+ <name>ibm_spacesaver</name>
+ <_description>IBM Space Saver</_description>
+ <vendor>Lenovo (previously IBM)</vendor>
+ </configItem>
+ </model>
+ <model>
+ <configItem>
+ <name>logiaccess</name>
+ <_description>Logitech Access Keyboard</_description>
+ <vendor>Logitech</vendor>
+ </configItem>
+ </model>
+ <model>
+ <configItem>
+ <name>logiclx300</name>
+ <_description>Logitech Cordless Desktop LX-300</_description>
+ <vendor>Logitech</vendor>
+ </configItem>
+ </model>
+ <model>
+ <configItem>
+ <name>logii350</name>
+ <_description>Logitech Internet 350 Keyboard</_description>
+ <vendor>Logitech</vendor>
+ </configItem>
+ </model>
+ <model>
+ <configItem>
+ <name>logimel</name>
+ <_description>Logitech Media Elite Keyboard</_description>
+ <vendor>Logitech</vendor>
+ </configItem>
+ </model>
+ <model>
+ <configItem>
+ <name>logicd</name>
+ <_description>Logitech Cordless Desktop</_description>
+ <vendor>Logitech</vendor>
+ </configItem>
+ </model>
+ <model>
+ <configItem>
+ <name>logicd_it</name>
+ <_description>Logitech Cordless Desktop iTouch</_description>
+ <vendor>Logitech</vendor>
+ </configItem>
+ </model>
+ <model>
+ <configItem>
+ <name>logicd_nav</name>
+ <_description>Logitech Cordless Desktop Navigator</_description>
+ <vendor>Logitech</vendor>
+ </configItem>
+ </model>
+ <model>
+ <configItem>
+ <name>logicd_opt</name>
+ <_description>Logitech Cordless Desktop Optical</_description>
+ <vendor>Logitech</vendor>
+ </configItem>
+ </model>
+ <model>
+ <configItem>
+ <name>logicda</name>
+ <_description>Logitech Cordless Desktop (alternate option)</_description>
+ <vendor>Logitech</vendor>
+ </configItem>
+ </model>
+ <model>
+ <configItem>
+ <name>logicdpa2</name>
+ <_description>Logitech Cordless Desktop Pro (alternate option 2)</_description>
+ <vendor>Logitech</vendor>
+ </configItem>
+ </model>
+ <model>
+ <configItem>
+ <name>logicfn</name>
+ <_description>Logitech Cordless Freedom/Desktop Navigator</_description>
+ <vendor>Logitech</vendor>
+ </configItem>
+ </model>
+ <model>
+ <configItem>
+ <name>logicdn</name>
+ <_description>Logitech Cordless Desktop Navigator</_description>
+ <vendor>Logitech</vendor>
+ </configItem>
+ </model>
+ <model>
+ <configItem>
+ <name>logiitc</name>
+ <_description>Logitech iTouch Cordless Keyboard (model Y-RB6)</_description>
+ <vendor>Logitech</vendor>
+ </configItem>
+ </model>
+ <model>
+ <configItem>
+ <name>logiik</name>
+ <_description>Logitech Internet Keyboard</_description>
+ <vendor>Logitech</vendor>
+ </configItem>
+ </model>
+ <model>
+ <configItem>
+ <name>itouch</name>
+ <_description>Logitech iTouch</_description>
+ <vendor>Logitech</vendor>
+ </configItem>
+ </model>
+ <model>
+ <configItem>
+ <name>logicink</name>
+ <_description>Logitech Internet Navigator Keyboard</_description>
+ <vendor>Logitech</vendor>
+ </configItem>
+ </model>
+ <model>
+ <configItem>
+ <name>logiex110</name>
+ <_description>Logitech Cordless Desktop EX110</_description>
+ <vendor>Logitech</vendor>
+ </configItem>
+ </model>
+ <model>
+ <configItem>
+ <name>logiinkse</name>
+ <_description>Logitech iTouch Internet Navigator Keyboard SE</_description>
+ <vendor>Logitech</vendor>
+ </configItem>
+ </model>
+ <model>
+ <configItem>
+ <name>logiinkseusb</name>
+ <_description>Logitech iTouch Internet Navigator Keyboard SE (USB)</_description>
+ <vendor>Logitech</vendor>
+ </configItem>
+ </model>
+ <model>
+ <configItem>
+ <name>logiultrax</name>
+ <_description>Logitech Ultra-X Keyboard</_description>
+ <vendor>Logitech</vendor>
+ </configItem>
+ </model>
+ <model>
+ <configItem>
+ <name>logiultraxc</name>
+ <_description>Logitech Ultra-X Cordless Media Desktop Keyboard</_description>
+ <vendor>Logitech</vendor>
+ </configItem>
+ </model>
+ <model>
+ <configItem>
+ <name>logidinovo</name>
+ <_description>Logitech diNovo Keyboard</_description>
+ <vendor>Logitech</vendor>
+ </configItem>
+ </model>
+ <model>
+ <configItem>
+ <name>logidinovoedge</name>
+ <_description>Logitech diNovo Edge Keyboard</_description>
+ <vendor>Logitech</vendor>
+ </configItem>
+ </model>
+ <model>
+ <configItem>
+ <name>mx1998</name>
+ <_description>Memorex MX1998</_description>
+ <vendor>Memorex</vendor>
+ </configItem>
+ </model>
+ <model>
+ <configItem>
+ <name>mx2500</name>
+ <_description>Memorex MX2500 EZ-Access Keyboard</_description>
+ <vendor>Memorex</vendor>
+ </configItem>
+ </model>
+ <model>
+ <configItem>
+ <name>mx2750</name>
+ <_description>Memorex MX2750</_description>
+ <vendor>Memorex</vendor>
+ </configItem>
+ </model>
+ <model>
+ <configItem>
+ <name>microsoft7000</name>
+ <_description>Microsoft Natural Wireless Ergonomic Keyboard 7000</_description>
+ <vendor>Microsoft Inc.</vendor>
+ </configItem>
+ </model>
+ <model>
+ <configItem>
+ <name>microsoftinet</name>
+ <_description>Microsoft Internet Keyboard</_description>
+ <vendor>Microsoft Inc.</vendor>
+ </configItem>
+ </model>
+ <model>
+ <configItem>
+ <name>microsoftpro</name>
+ <_description>Microsoft Natural Keyboard Pro / Microsoft Internet Keyboard Pro</_description>
+ <vendor>Microsoft Inc.</vendor>
+ </configItem>
+ </model>
+ <model>
+ <configItem>
+ <name>microsoftprousb</name>
+ <_description>Microsoft Natural Keyboard Pro USB / Microsoft Internet Keyboard Pro</_description>
+ <vendor>Microsoft Inc.</vendor>
+ </configItem>
+ </model>
+ <model>
+ <configItem>
+ <name>microsoftprooem</name>
+ <_description>Microsoft Natural Keyboard Pro OEM</_description>
+ <vendor>Microsoft Inc.</vendor>
+ </configItem>
+ </model>
+ <model>
+ <configItem>
+ <name>vsonku306</name>
+ <_description>ViewSonic KU-306 Internet Keyboard</_description>
+ <vendor>ViewSonic</vendor>
+ </configItem>
+ </model>
+ <model>
+ <configItem>
+ <name>microsoftprose</name>
+ <_description>Microsoft Internet Keyboard Pro, Swedish</_description>
+ <vendor>Microsoft Inc.</vendor>
+ </configItem>
+ </model>
+ <model>
+ <configItem>
+ <name>microsoftoffice</name>
+ <_description>Microsoft Office Keyboard</_description>
+ <vendor>Microsoft Inc.</vendor>
+ </configItem>
+ </model>
+ <model>
+ <configItem>
+ <name>microsoftmult</name>
+ <_description>Microsoft Wireless Multimedia Keyboard 1.0A</_description>
+ <vendor>Microsoft Inc.</vendor>
+ </configItem>
+ </model>
+ <model>
+ <configItem>
+ <name>microsoftelite</name>
+ <_description>Microsoft Natural Keyboard Elite</_description>
+ <vendor>Microsoft Inc.</vendor>
+ </configItem>
+ </model>
+ <model>
+ <configItem>
+ <name>microsoftccurve2k</name>
+ <_description>Microsoft Comfort Curve Keyboard 2000</_description>
+ <vendor>Microsoft Inc.</vendor>
+ </configItem>
+ </model>
+ <model>
+ <configItem>
+ <name>oretec</name>
+ <_description>Ortek MCK-800 MM/Internet keyboard</_description>
+ <vendor>Ortek</vendor>
+ </configItem>
+ </model>
+ <model>
+ <configItem>
+ <name>propeller</name>
+ <_description>Propeller Voyager (KTEZ-1000)</_description>
+ <vendor>KeyTronic</vendor>
+ </configItem>
+ </model>
+ <model>
+ <configItem>
+ <name>qtronix</name>
+ <_description>QTronix Scorpius 98N+</_description>
+ <vendor>QTronix</vendor>
+ </configItem>
+ </model>
+ <model>
+ <configItem>
+ <name>samsung4500</name>
+ <_description>Samsung SDM 4500P</_description>
+ <vendor>Samsung</vendor>
+ </configItem>
+ </model>
+ <model>
+ <configItem>
+ <name>samsung4510</name>
+ <_description>Samsung SDM 4510P</_description>
+ <vendor>Samsung</vendor>
+ </configItem>
+ </model>
+ <model>
+ <configItem>
+ <name>sanwaskbkg3</name>
+ <description>Sanwa Supply SKB-KG3</description>
+ <vendor>Sanwa Supply Inc.</vendor>
+ </configItem>
+ </model>
+ <model>
+ <configItem>
+ <name>sk1300</name>
+ <_description>SK-1300</_description>
+ <vendor>NEC</vendor>
+ </configItem>
+ </model>
+ <model>
+ <configItem>
+ <name>sk2500</name>
+ <_description>SK-2500</_description>
+ <vendor>NEC</vendor>
+ </configItem>
+ </model>
+ <model>
+ <configItem>
+ <name>sk6200</name>
+ <_description>SK-6200</_description>
+ <vendor>NEC</vendor>
+ </configItem>
+ </model>
+ <model>
+ <configItem>
+ <name>sk7100</name>
+ <_description>SK-7100</_description>
+ <vendor>NEC</vendor>
+ </configItem>
+ </model>
+ <model>
+ <configItem>
+ <name>sp_inet</name>
+ <_description>Super Power Multimedia Keyboard</_description>
+ <vendor>Generic</vendor>
+ </configItem>
+ </model>
+ <model>
+ <configItem>
+ <name>sven</name>
+ <_description>SVEN Ergonomic 2500</_description>
+ <vendor>SVEN</vendor>
+ </configItem>
+ </model>
+ <model>
+ <configItem>
+ <name>sven303</name>
+ <_description>SVEN Slim 303</_description>
+ <vendor>SVEN</vendor>
+ </configItem>
+ </model>
+ <model>
+ <configItem>
+ <name>symplon</name>
+ <_description>Symplon PaceBook (tablet PC)</_description>
+ <vendor>Symplon</vendor>
+ </configItem>
+ </model>
+ <model>
+ <configItem>
+ <name>toshiba_s3000</name>
+ <_description>Toshiba Satellite S3000</_description>
+ <vendor>Toshiba</vendor>
+ </configItem>
+ </model>
+ <model>
+ <configItem>
+ <name>trust</name>
+ <_description>Trust Wireless Keyboard Classic</_description>
+ <vendor>Trust</vendor>
+ </configItem>
+ </model>
+ <model>
+ <configItem>
+ <name>trustda</name>
+ <_description>Trust Direct Access Keyboard</_description>
+ <vendor>Trust</vendor>
+ </configItem>
+ </model>
+ <model>
+ <configItem>
+ <name>trust_slimline</name>
+ <_description>Trust Slimline</_description>
+ <vendor>Trust</vendor>
+ </configItem>
+ </model>
+ <model>
+ <configItem>
+ <name>tm2020</name>
+ <_description>TypeMatrix EZ-Reach 2020</_description>
+ <vendor>TypeMatrix</vendor>
+ </configItem>
+ </model>
+ <model>
+ <configItem>
+ <name>tm2030PS2</name>
+ <_description>TypeMatrix EZ-Reach 2030 PS2</_description>
+ <vendor>TypeMatrix</vendor>
+ </configItem>
+ </model>
+ <model>
+ <configItem>
+ <name>tm2030USB</name>
+ <_description>TypeMatrix EZ-Reach 2030 USB</_description>
+ <vendor>TypeMatrix</vendor>
+ </configItem>
+ </model>
+ <model>
+ <configItem>
+ <name>tm2030USB-102</name>
+ <_description>TypeMatrix EZ-Reach 2030 USB (102/105:EU mode)</_description>
+ <vendor>TypeMatrix</vendor>
+ </configItem>
+ </model>
+ <model>
+ <configItem>
+ <name>tm2030USB-106</name>
+ <_description>TypeMatrix EZ-Reach 2030 USB (106:JP mode)</_description>
+ <vendor>TypeMatrix</vendor>
+ </configItem>
+ </model>
+ <model>
+ <configItem>
+ <name>yahoo</name>
+ <_description>Yahoo! Internet Keyboard</_description>
+ <vendor>Yahoo!</vendor>
+ </configItem>
+ </model>
+ <model>
+ <configItem>
+ <name>macbook78</name>
+ <_description>MacBook/MacBook Pro</_description>
+ <vendor>Apple</vendor>
+ </configItem>
+ </model>
+ <model>
+ <configItem>
+ <name>macbook79</name>
+ <_description>MacBook/MacBook Pro (Intl)</_description>
+ <vendor>Apple</vendor>
+ </configItem>
+ </model>
+ <model>
+ <configItem>
+ <name>macintosh</name>
+ <_description>Macintosh</_description>
+ <vendor>Apple</vendor>
+ </configItem>
+ </model>
+ <model>
+ <configItem>
+ <name>macintosh_old</name>
+ <_description>Macintosh Old</_description>
+ <vendor>Apple</vendor>
+ </configItem>
+ </model>
+ <model>
+ <configItem>
+ <name>macintosh_hhk</name>
+ <_description>Happy Hacking Keyboard for Mac</_description>
+ <vendor>Fujitsu</vendor>
+ </configItem>
+ </model>
+ <model>
+ <configItem>
+ <name>acer_c300</name>
+ <_description>Acer C300</_description>
+ <vendor>Acer</vendor>
+ </configItem>
+ </model>
+ <model>
+ <configItem>
+ <name>acer_ferrari4k</name>
+ <_description>Acer Ferrari 4000</_description>
+ <vendor>Acer</vendor>
+ </configItem>
+ </model>
+ <model>
+ <configItem>
+ <name>acer_laptop</name>
+ <_description>Acer Laptop</_description>
+ <vendor>Acer</vendor>
+ </configItem>
+ </model>
+ <model>
+ <configItem>
+ <name>asus_laptop</name>
+ <_description>Asus Laptop</_description>
+ <vendor>Asus</vendor>
+ </configItem>
+ </model>
+ <model>
+ <configItem>
+ <name>apple</name>
+ <_description>Apple</_description>
+ <vendor>Apple</vendor>
+ </configItem>
+ </model>
+ <model>
+ <configItem>
+ <name>apple_laptop</name>
+ <_description>Apple Laptop</_description>
+ <vendor>Apple</vendor>
+ </configItem>
+ </model>
+ <model>
+ <configItem>
+ <name>applealu_ansi</name>
+ <_description>Apple Aluminium Keyboard (ANSI)</_description>
+ <vendor>Apple</vendor>
+ </configItem>
+ </model>
+ <model>
+ <configItem>
+ <name>applealu_iso</name>
+ <_description>Apple Aluminium Keyboard (ISO)</_description>
+ <vendor>Apple</vendor>
+ </configItem>
+ </model>
+ <model>
+ <configItem>
+ <name>applealu_jis</name>
+ <_description>Apple Aluminium Keyboard (JIS)</_description>
+ <vendor>Apple</vendor>
+ </configItem>
+ </model>
+ <model>
+ <configItem>
+ <name>silvercrest</name>
+ <_description>SILVERCREST Multimedia Wireless Keyboard</_description>
+ <vendor>Silvercrest</vendor>
+ </configItem>
+ </model>
+ <model>
+ <configItem>
+ <name>emachines</name>
+ <_description>Laptop/notebook eMachines m68xx</_description>
+ <vendor>eMachines</vendor>
+ </configItem>
+ </model>
+ <model>
+ <configItem>
+ <name>benqx</name>
+ <_description>BenQ X-Touch</_description>
+ <vendor>BenQ</vendor>
+ </configItem>
+ </model>
+ <model>
+ <configItem>
+ <name>benqx730</name>
+ <_description>BenQ X-Touch 730</_description>
+ <vendor>BenQ</vendor>
+ </configItem>
+ </model>
+ <model>
+ <configItem>
+ <name>benqx800</name>
+ <_description>BenQ X-Touch 800</_description>
+ <vendor>BenQ</vendor>
+ </configItem>
+ </model>
+ <model>
+ <configItem>
+ <name>hhk</name>
+ <_description>Happy Hacking Keyboard</_description>
+ <vendor>Fujitsu</vendor>
+ </configItem>
+ </model>
+ <model>
+ <configItem>
+ <name>classmate</name>
+ <_description>Classmate PC</_description>
+ <vendor>Intel</vendor>
+ </configItem>
+ </model>
+ <model>
+ <configItem>
+ <name>olpc</name>
+ <_description>OLPC</_description>
+ <vendor>OLPC</vendor>
+ </configItem>
+ </model>
+ <model>
+ <configItem>
+ <name>sun6</name>
+ <_description>Sun Type 5/6</_description>
+ <vendor>Sun Microsystems</vendor>
+ </configItem>
+ </model>
+ <model>
+ <configItem>
+ <name>targa_v811</name>
+ <_description>Targa Visionary 811</_description>
+ <vendor>Targa</vendor>
+ </configItem>
+ </model>
+ <model>
+ <configItem>
+ <name>unitekkb1925</name>
+ <_description>Unitek KB-1925</_description>
+ <vendor>Unitek Group</vendor>
+ </configItem>
+ </model>
+ <model>
+ <configItem>
+ <name>compalfl90</name>
+ <_description>FL90</_description>
+ <vendor>Compal Electronics Inc.</vendor>
+ </configItem>
+ </model>
+ <model>
+ <configItem>
+ <name>creativedw7000</name>
+ <_description>Creative Desktop Wireless 7000</_description>
+ <vendor>Creative</vendor>
+ </configItem>
+ </model>
+ <model>
+ <configItem>
+ <name>htcdream</name>
+ <_description>Htc Dream phone</_description>
+ <vendor>htc</vendor>
+ </configItem>
+ </model>
+ </modelList>
+ <layoutList>
+ <layout>
+ <configItem>
+ <name>us</name>
+ <_shortDescription>USA</_shortDescription>
+ <_description>USA</_description>
+ <languageList><iso639Id>eng</iso639Id></languageList>
+ </configItem>
+ <variantList>
+ <variant>
+ <configItem>
+ <name>chr</name>
+ <_description>Cherokee</_description>
+ <languageList><iso639Id>chr</iso639Id></languageList>
+ </configItem>
+ </variant>
+ <variant>
+ <configItem>
+ <name>euro</name>
+ <_description>With EuroSign on 5</_description>
+ </configItem>
+ </variant>
+ <variant>
+ <configItem>
+ <name>intl</name>
+ <_description>International (with dead keys)</_description>
+ </configItem>
+ </variant>
+ <variant>
+ <configItem>
+ <name>alt-intl</name>
+ <_description>Alternative international</_description>
+ </configItem>
+ </variant>
+ <variant>
+ <configItem>
+ <name>colemak</name>
+ <_description>Colemak</_description>
+ </configItem>
+ </variant>
+ <variant>
+ <configItem>
+ <name>dvorak</name>
+ <_description>Dvorak</_description>
+ </configItem>
+ </variant>
+ <variant>
+ <configItem>
+ <name>dvorak-intl</name>
+ <_description>Dvorak international (with dead keys)</_description>
+ </configItem>
+ </variant>
+ <variant>
+ <configItem>
+ <name>dvorak-alt-intl</name>
+ <_description>Dvorak alternative international (no dead keys)</_description>
+ </configItem>
+ </variant>
+ <variant>
+ <configItem>
+ <name>dvorak-l</name>
+ <_description>Left handed Dvorak</_description>
+ </configItem>
+ </variant>
+ <variant>
+ <configItem>
+ <name>dvorak-r</name>
+ <_description>Right handed Dvorak</_description>
+ </configItem>
+ </variant>
+ <variant>
+ <configItem>
+ <name>dvorak-classic</name>
+ <_description>Classic Dvorak</_description>
+ </configItem>
+ </variant>
+ <variant>
+ <configItem>
+ <name>dvp</name>
+ <_description>Programmer Dvorak</_description>
+ </configItem>
+ </variant>
+ <variant>
+ <configItem>
+ <name>rus</name>
+ <_description>Russian phonetic</_description>
+ <languageList><iso639Id>rus</iso639Id></languageList>
+ </configItem>
+ </variant>
+ <variant>
+ <configItem>
+ <name>mac</name>
+ <_description>Macintosh</_description>
+ </configItem>
+ </variant>
+ <variant>
+ <configItem>
+ <name>altgr-intl</name>
+ <_description>International (AltGr dead keys)</_description>
+ <languageList><iso639Id>eng</iso639Id>
+ <iso639Id>fra</iso639Id>
+ <iso639Id>ger</iso639Id></languageList>
+ </configItem>
+ </variant>
+ <variant>
+ <configItem>
+ <name>olpc2</name>
+ <_description>Layout toggle on multiply/divide key</_description>
+ </configItem>
+ </variant>
+ <variant>
+ <configItem>
+ <name>hbs</name>
+ <_description>Serbo-Croatian</_description>
+ <languageList><iso639Id>eng</iso639Id>
+ <iso639Id>bos</iso639Id>
+ <iso639Id>hbs</iso639Id>
+ <iso639Id>hrv</iso639Id>
+ <iso639Id>srp</iso639Id> </languageList>
+ </configItem>
+ </variant>
+ </variantList>
+ </layout>
+ <layout>
+ <configItem>
+ <name>ad</name>
+ <_shortDescription>And</_shortDescription>
+ <_description>Andorra</_description>
+ <languageList><iso639Id>cat</iso639Id></languageList>
+ </configItem>
+ <variantList/>
+ </layout>
+ <layout>
+ <configItem>
+ <name>af</name>
+ <_shortDescription>Afg</_shortDescription>
+ <_description>Afghanistan</_description>
+ </configItem>
+ <variantList>
+ <variant>
+ <configItem>
+ <name>ps</name>
+ <_description>Pashto</_description>
+ <languageList><iso639Id>pus</iso639Id></languageList>
+ </configItem>
+ </variant>
+ <variant>
+ <configItem>
+ <name>uz</name>
+ <_description>Southern Uzbek</_description>
+ <languageList><iso639Id>uzb</iso639Id></languageList>
+ </configItem>
+ </variant>
+ <variant>
+ <configItem>
+ <name>olpc-ps</name>
+ <_description>OLPC Pashto</_description>
+ <languageList><iso639Id>pus</iso639Id></languageList>
+ </configItem>
+ </variant>
+ <variant>
+ <configItem>
+ <name>olpc-fa</name>
+ <_description>OLPC Dari</_description>
+ <!-- No ISO code in ISO639-2, only draft ISO693-3 -->
+ </configItem>
+ </variant>
+ <variant>
+ <configItem>
+ <name>olpc-uz</name>
+ <_description>OLPC Southern Uzbek</_description>
+ <languageList><iso639Id>uzb</iso639Id></languageList>
+ </configItem>
+ </variant>
+ </variantList>
+ </layout>
+ <layout>
+ <configItem>
+ <name>ara</name>
+ <_shortDescription>Ara</_shortDescription>
+ <_description>Arabic</_description>
+ <countryList>
+ <iso3166Id>AE</iso3166Id>
+ <iso3166Id>BH</iso3166Id>
+ <iso3166Id>DZ</iso3166Id>
+ <iso3166Id>EG</iso3166Id>
+ <iso3166Id>EH</iso3166Id>
+ <iso3166Id>JO</iso3166Id>
+ <iso3166Id>KW</iso3166Id>
+ <iso3166Id>LB</iso3166Id>
+ <iso3166Id>LY</iso3166Id>
+ <iso3166Id>MA</iso3166Id>
+ <iso3166Id>MR</iso3166Id>
+ <iso3166Id>OM</iso3166Id>
+ <iso3166Id>PS</iso3166Id>
+ <iso3166Id>QA</iso3166Id>
+ <iso3166Id>SA</iso3166Id>
+ <iso3166Id>SD</iso3166Id>
+ <iso3166Id>SY</iso3166Id>
+ <iso3166Id>TN</iso3166Id>
+ <iso3166Id>YE</iso3166Id>
+ </countryList>
+ <languageList><iso639Id>ara</iso639Id></languageList>
+ </configItem>
+ <variantList>
+ <variant>
+ <configItem>
+ <name>azerty</name>
+ <_description>azerty</_description>
+ </configItem>
+ </variant>
+ <variant>
+ <configItem>
+ <name>azerty_digits</name>
+ <_description>azerty/digits</_description>
+ </configItem>
+ </variant>
+ <variant>
+ <configItem>
+ <name>digits</name>
+ <_description>digits</_description>
+ </configItem>
+ </variant>
+ <variant>
+ <configItem>
+ <name>qwerty</name>
+ <_description>qwerty</_description>
+ </configItem>
+ </variant>
+ <variant>
+ <configItem>
+ <name>qwerty_digits</name>
+ <_description>qwerty/digits</_description>
+ </configItem>
+ </variant>
+ <variant>
+ <configItem>
+ <name>buckwalter</name>
+ <_description>Buckwalter</_description>
+ </configItem>
+ </variant>
+ </variantList>
+ </layout>
+ <layout>
+ <configItem>
+ <name>al</name>
+ <_shortDescription>Alb</_shortDescription>
+ <_description>Albania</_description>
+ <languageList><iso639Id>alb</iso639Id></languageList>
+ </configItem>
+ <variantList/>
+ </layout>
+ <layout>
+ <configItem>
+ <name>am</name>
+ <_shortDescription>Arm</_shortDescription>
+ <_description>Armenia</_description>
+ <languageList><iso639Id>hye</iso639Id></languageList>
+ </configItem>
+ <variantList>
+ <variant>
+ <configItem>
+ <name>phonetic</name>
+ <_description>Phonetic</_description>
+ </configItem>
+ </variant>
+ <variant>
+ <configItem>
+ <name>phonetic-alt</name>
+ <_description>Alternative Phonetic</_description>
+ </configItem>
+ </variant>
+ <variant>
+ <configItem>
+ <name>eastern</name>
+ <_description>Eastern</_description>
+ </configItem>
+ </variant>
+ <variant>
+ <configItem>
+ <name>western</name>
+ <_description>Western</_description>
+ </configItem>
+ </variant>
+ <variant>
+ <configItem>
+ <name>eastern-alt</name>
+ <_description>Alternative Eastern</_description>
+ </configItem>
+ </variant>
+ </variantList>
+ </layout>
+ <layout>
+ <configItem>
+ <name>at</name>
+ <_shortDescription>Aut</_shortDescription>
+ <_description>Austria</_description>
+ <languageList><iso639Id>ger</iso639Id></languageList>
+ </configItem>
+ <variantList>
+ <variant>
+ <configItem>
+ <name>nodeadkeys</name>
+ <_description>Eliminate dead keys</_description>
+ </configItem>
+ </variant>
+ <variant>
+ <configItem>
+ <name>sundeadkeys</name>
+ <_description>Sun dead keys</_description>
+ </configItem>
+ </variant>
+ <variant>
+ <configItem>
+ <name>mac</name>
+ <_description>Macintosh</_description>
+ </configItem>
+ </variant>
+ </variantList>
+ </layout>
+ <layout>
+ <configItem>
+ <name>az</name>
+ <_shortDescription>Aze</_shortDescription>
+ <_description>Azerbaijan</_description>
+ <languageList><iso639Id>aze</iso639Id></languageList>
+ </configItem>
+ <variantList>
+ <variant>
+ <configItem>
+ <name>cyrillic</name>
+ <_description>Cyrillic</_description>
+ </configItem>
+ </variant>
+ </variantList>
+ </layout>
+ <layout>
+ <configItem>
+ <name>by</name>
+ <_shortDescription>Blr</_shortDescription>
+ <_description>Belarus</_description>
+ <languageList><iso639Id>bel</iso639Id></languageList>
+ </configItem>
+ <variantList>
+ <variant>
+ <configItem>
+ <name>legacy</name>
+ <_description>Legacy</_description>
+ </configItem>
+ </variant>
+ <variant>
+ <configItem>
+ <name>latin</name>
+ <_description>Latin</_description>
+ </configItem>
+ </variant>
+ </variantList>
+ </layout>
+ <layout>
+ <configItem>
+ <name>be</name>
+ <_shortDescription>Bel</_shortDescription>
+ <_description>Belgium</_description>
+ <languageList><iso639Id>ger</iso639Id>
+ <iso639Id>nld</iso639Id>
+ <iso639Id>fra</iso639Id></languageList>
+ </configItem>
+ <variantList>
+ <variant>
+ <configItem>
+ <name>oss</name>
+ <_description>Alternative</_description>
+ </configItem>
+ </variant>
+ <variant>
+ <configItem>
+ <name>oss_latin9</name>
+ <_description>Alternative, latin-9 only</_description>
+ </configItem>
+ </variant>
+ <variant>
+ <configItem>
+ <name>oss_sundeadkeys</name>
+ <_description>Alternative, Sun dead keys</_description>
+ </configItem>
+ </variant>
+ <variant>
+ <configItem>
+ <name>iso-alternate</name>
+ <_description>ISO Alternate</_description>
+ </configItem>
+ </variant>
+ <variant>
+ <configItem>
+ <name>nodeadkeys</name>
+ <_description>Eliminate dead keys</_description>
+ </configItem>
+ </variant>
+ <variant>
+ <configItem>
+ <name>sundeadkeys</name>
+ <_description>Sun dead keys</_description>
+ </configItem>
+ </variant>
+ <variant>
+ <configItem>
+ <name>wang</name>
+ <_description>Wang model 724 azerty</_description>
+ </configItem>
+ </variant>
+ </variantList>
+ </layout>
+ <layout>
+ <configItem>
+ <name>bd</name>
+ <_shortDescription>Bgd</_shortDescription>
+ <_description>Bangladesh</_description>
+ <languageList><iso639Id>ben</iso639Id></languageList>
+ </configItem>
+ <variantList>
+ <variant>
+ <configItem>
+ <name>probhat</name>
+ <_description>Probhat</_description>
+ </configItem>
+ </variant>
+ </variantList>
+ </layout>
+ <layout>
+ <configItem>
+ <name>in</name>
+ <_shortDescription>Ind</_shortDescription>
+ <_description>India</_description>
+ </configItem>
+ <variantList>
+ <variant>
+ <configItem>
+ <name>ben</name>
+ <_description>Bengali</_description>
+ <languageList><iso639Id>ben</iso639Id></languageList>
+ </configItem>
+ </variant>
+ <variant>
+ <configItem>
+ <name>ben_probhat</name>
+ <_description>Bengali Probhat</_description>
+ <languageList><iso639Id>ben</iso639Id></languageList>
+ </configItem>
+ </variant>
+ <variant>
+ <configItem>
+ <name>guj</name>
+ <_description>Gujarati</_description>
+ <languageList><iso639Id>guj</iso639Id></languageList>
+ </configItem>
+ </variant>
+ <variant>
+ <configItem>
+ <name>guru</name>
+ <_description>Gurmukhi</_description>
+ <languageList><iso639Id>pan</iso639Id></languageList>
+ </configItem>
+ </variant>
+ <variant>
+ <configItem>
+ <name>jhelum</name>
+ <_description>Gurmukhi Jhelum</_description>
+ <languageList><iso639Id>pan</iso639Id></languageList>
+ </configItem>
+ </variant>
+ <variant>
+ <configItem>
+ <name>kan</name>
+ <_description>Kannada</_description>
+ <languageList><iso639Id>kan</iso639Id></languageList>
+ </configItem>
+ </variant>
+ <variant>
+ <configItem>
+ <name>mal</name>
+ <_description>Malayalam</_description>
+ <languageList><iso639Id>mal</iso639Id></languageList>
+ </configItem>
+ </variant>
+ <variant>
+ <configItem>
+ <name>mal_lalitha</name>
+ <_description>Malayalam Lalitha</_description>
+ <languageList><iso639Id>mal</iso639Id></languageList>
+ </configItem>
+ </variant>
+ <variant>
+ <configItem>
+ <name>ori</name>
+ <_description>Oriya</_description>
+ <languageList><iso639Id>ori</iso639Id></languageList>
+ </configItem>
+ </variant>
+ <variant>
+ <configItem>
+ <name>tam_unicode</name>
+ <_description>Tamil Unicode</_description>
+ <languageList><iso639Id>tam</iso639Id></languageList>
+ </configItem>
+ </variant>
+ <variant>
+ <configItem>
+ <name>tam_keyboard_with_numerals</name>
+ <_description>Tamil Keyboard with Numerals</_description>
+ <languageList><iso639Id>tam</iso639Id></languageList>
+ </configItem>
+ </variant>
+ <variant>
+ <configItem>
+ <name>tam_TAB</name>
+ <_description>Tamil TAB Typewriter</_description>
+ <languageList><iso639Id>tam</iso639Id></languageList>
+ </configItem>
+ </variant>
+ <variant>
+ <configItem>
+ <name>tam_TSCII</name>
+ <_description>Tamil TSCII Typewriter</_description>
+ <languageList><iso639Id>tam</iso639Id></languageList>
+ </configItem>
+ </variant>
+ <variant>
+ <configItem>
+ <name>tam</name>
+ <_description>Tamil</_description>
+ <languageList><iso639Id>tam</iso639Id></languageList>
+ </configItem>
+ </variant>
+ <variant>
+ <configItem>
+ <name>tel</name>
+ <_description>Telugu</_description>
+ <languageList><iso639Id>tel</iso639Id></languageList>
+ </configItem>
+ </variant>
+ <variant>
+ <configItem>
+ <name>urd-phonetic</name>
+ <_description>Urdu, Phonetic</_description>
+ <languageList><iso639Id>urd</iso639Id></languageList>
+ </configItem>
+ </variant>
+ <variant>
+ <configItem>
+ <name>urd-phonetic3</name>
+ <_description>Urdu, Alternative phonetic</_description>
+ <languageList><iso639Id>urd</iso639Id></languageList>
+ </configItem>
+ </variant>
+ <variant>
+ <configItem>
+ <name>urd-winkeys</name>
+ <_description>Urdu, Winkeys</_description>
+ <languageList><iso639Id>urd</iso639Id></languageList>
+ </configItem>
+ </variant>
+ <variant>
+ <configItem>
+ <name>bolnagri</name>
+ <_description>Hindi Bolnagri</_description>
+ <languageList><iso639Id>hin</iso639Id></languageList>
+ </configItem>
+ </variant>
+ <variant>
+ <configItem>
+ <name>hin-wx</name>
+ <_description>Hindi Wx</_description>
+ <languageList><iso639Id>hin</iso639Id></languageList>
+ </configItem>
+ </variant>
+ <variant>
+ <configItem>
+ <name>eng</name>
+ <_description>English with RupeeSign</_description>
+ <languageList><iso639Id>eng</iso639Id></languageList>
+ </configItem>
+ </variant>
+ </variantList>
+ </layout>
+ <layout>
+ <configItem>
+ <name>ba</name>
+ <_shortDescription>Bih</_shortDescription>
+ <_description>Bosnia and Herzegovina</_description>
+ <languageList><iso639Id>bos</iso639Id></languageList>
+ </configItem>
+ <variantList>
+ <variant>
+ <configItem>
+ <name>alternatequotes</name>
+ <_description> Use guillemets for quotes</_description>
+ </configItem>
+ </variant>
+ <variant>
+ <configItem>
+ <name>unicode</name>
+ <_description>Use Bosnian digraphs</_description>
+ </configItem>
+ </variant>
+ <variant>
+ <configItem>
+ <name>unicodeus</name>
+ <_description>US keyboard with Bosnian digraphs</_description>
+ </configItem>
+ </variant>
+ <variant>
+ <configItem>
+ <name>us</name>
+ <_description>US keyboard with Bosnian letters</_description>
+ </configItem>
+ </variant>
+ </variantList>
+ </layout>
+ <layout>
+ <configItem>
+ <name>br</name>
+ <_shortDescription>Bra</_shortDescription>
+ <_description>Brazil</_description>
+ <languageList><iso639Id>por</iso639Id></languageList>
+ </configItem>
+ <variantList>
+ <variant>
+ <configItem>
+ <name>nodeadkeys</name>
+ <_description>Eliminate dead keys</_description>
+ </configItem>
+ </variant>
+ <variant>
+ <configItem>
+ <name>dvorak</name>
+ <_description>Dvorak</_description>
+ </configItem>
+ </variant>
+ <variant>
+ <configItem>
+ <name>nativo</name>
+ <_description>Nativo</_description>
+ </configItem>
+ </variant>
+ <variant>
+ <configItem>
+ <name>nativo-us</name>
+ <_description>Nativo for USA keyboards</_description>
+ </configItem>
+ </variant>
+ <variant>
+ <configItem>
+ <name>nativo-epo</name>
+ <_description>Nativo for Esperanto</_description>
+ <languageList><iso639Id>epo</iso639Id></languageList>
+ </configItem>
+ </variant>
+ </variantList>
+ </layout>
+ <layout>
+ <configItem>
+ <name>bg</name>
+ <_shortDescription>Bgr</_shortDescription>
+ <_description>Bulgaria</_description>
+ <languageList><iso639Id>bul</iso639Id></languageList>
+ </configItem>
+ <variantList>
+ <variant>
+ <configItem>
+ <name>phonetic</name>
+ <_description>Traditional phonetic</_description>
+ </configItem>
+ </variant>
+ </variantList>
+ <variantList>
+ <variant>
+ <configItem>
+ <name>bas_phonetic</name>
+ <_description>New phonetic</_description>
+ </configItem>
+ </variant>
+ </variantList>
+ </layout>
+ <layout>
+ <configItem>
+ <name>ma</name>
+ <_description>Morocco</_description>
+ </configItem>
+ <variantList>
+ <variant>
+ <configItem>
+ <name>french</name>
+ <_description>French</_description>
+ <languageList><iso639Id>fra</iso639Id></languageList>
+ </configItem>
+ </variant>
+ <variant>
+ <configItem>
+ <name>tifinagh</name>
+ <_description>Tifinagh</_description>
+ <languageList><iso639Id>ber</iso639Id></languageList>
+ </configItem>
+ </variant>
+ <variant>
+ <configItem>
+ <name>tifinagh-alt</name>
+ <_description>Tifinagh alternative</_description>
+ <languageList><iso639Id>ber</iso639Id></languageList>
+ </configItem>
+ </variant>
+ <variant>
+ <configItem>
+ <name>tifinagh-alt-phonetic</name>
+ <_description>Tifinagh alternative phonetic</_description>
+ <languageList><iso639Id>ber</iso639Id></languageList>
+ </configItem>
+ </variant>
+ <variant>
+ <configItem>
+ <name>tifinagh-extended</name>
+ <_description>Tifinagh extended</_description>
+ <languageList><iso639Id>ber</iso639Id></languageList>
+ </configItem>
+ </variant>
+ <variant>
+ <configItem>
+ <name>tifinagh-phonetic</name>
+ <_description>Tifinagh phonetic</_description>
+ <languageList><iso639Id>ber</iso639Id></languageList>
+ </configItem>
+ </variant>
+ <variant>
+ <configItem>
+ <name>tifinagh-extended-phonetic</name>
+ <_description>Tifinagh extended phonetic</_description>
+ <languageList><iso639Id>ber</iso639Id></languageList>
+ </configItem>
+ </variant>
+ </variantList>
+ </layout>
+ <layout>
+ <configItem>
+ <name>mm</name>
+ <_shortDescription>Mmr</_shortDescription>
+ <_description>Myanmar</_description>
+ <languageList><iso639Id>mya</iso639Id></languageList>
+ </configItem>
+ <variantList/>
+ </layout>
+ <layout>
+ <configItem>
+ <name>ca</name>
+ <_shortDescription>Can</_shortDescription>
+ <_description>Canada</_description>
+ <languageList><iso639Id>fra</iso639Id></languageList>
+ </configItem>
+ <variantList>
+ <variant>
+ <configItem>
+ <name>fr-dvorak</name>
+ <_description>French Dvorak</_description>
+ </configItem>
+ </variant>
+ <variant>
+ <configItem>
+ <name>fr-legacy</name>
+ <_description>French (legacy)</_description>
+ </configItem>
+ </variant>
+ <variant>
+ <configItem>
+ <name>multix</name>
+ <_description>Multilingual</_description>
+ </configItem>
+ </variant>
+ <variant>
+ <configItem>
+ <name>multi</name>
+ <_description>Multilingual, first part</_description>
+ </configItem>
+ </variant>
+ <variant>
+ <configItem>
+ <name>multi-2gr</name>
+ <_description>Multilingual, second part</_description>
+ </configItem>
+ </variant>
+ <variant>
+ <configItem>
+ <name>ike</name>
+ <_description>Inuktitut</_description>
+ <languageList><iso639Id>iku</iso639Id></languageList>
+ </configItem>
+ </variant>
+ <variant>
+ <configItem>
+ <name>shs</name>
+ <_description>Secwepemctsin</_description>
+ <!-- No ISO code in ISO639-2, only draft ISO693-3 -->
+ </configItem>
+ </variant>
+ <variant>
+ <configItem>
+ <name>kut</name>
+ <_description>Ktunaxa</_description>
+ </configItem>
+ </variant>
+ <variant>
+ <configItem>
+ <name>eng</name>
+ <_description>English</_description>
+ <languageList><iso639Id>eng</iso639Id></languageList>
+ </configItem>
+ </variant>
+ </variantList>
+ </layout>
+ <layout>
+ <configItem>
+ <name>cd</name>
+ <_shortDescription>COD</_shortDescription>
+ <_description>Congo, Democratic Republic of the</_description>
+ <languageList><iso639Id>fra</iso639Id></languageList>
+ </configItem>
+ <variantList/>
+ </layout>
+ <layout>
+ <configItem>
+ <name>cn</name>
+ <_shortDescription>Chn</_shortDescription>
+ <_description>China</_description>
+ <languageList><iso639Id>chi</iso639Id></languageList>
+ </configItem>
+ <variantList>
+ <variant>
+ <configItem>
+ <name>tib</name>
+ <_description>Tibetan</_description>
+ <languageList><iso639Id>tib</iso639Id></languageList>
+ </configItem>
+ </variant>
+ <variant>
+ <configItem>
+ <name>tib_asciinum</name>
+ <_description>Tibetan (with ASCII numerals)</_description>
+ <languageList><iso639Id>tib</iso639Id></languageList>
+ </configItem>
+ </variant>
+ </variantList>
+ </layout>
+ <layout>
+ <configItem>
+ <name>hr</name>
+ <_shortDescription>Hrv</_shortDescription>
+ <_description>Croatia</_description>
+ <languageList><iso639Id>scr</iso639Id></languageList>
+ </configItem>
+ <variantList>
+ <variant>
+ <configItem>
+ <name>alternatequotes</name>
+ <_description>Use guillemets for quotes</_description>
+ </configItem>
+ </variant>
+ <variant>
+ <configItem>
+ <name>unicode</name>
+ <_description>Use Croatian digraphs</_description>
+ </configItem>
+ </variant>
+ <variant>
+ <configItem>
+ <name>unicodeus</name>
+ <_description>US keyboard with Croatian digraphs</_description>
+ </configItem>
+ </variant>
+ <variant>
+ <configItem>
+ <name>us</name>
+ <_description>US keyboard with Croatian letters</_description>
+ </configItem>
+ </variant>
+ </variantList>
+ </layout>
+ <layout>
+ <configItem>
+ <name>cz</name>
+ <_shortDescription>Cze</_shortDescription>
+ <_description>Czechia</_description>
+ <languageList><iso639Id>cze</iso639Id></languageList>
+ </configItem>
+ <variantList>
+ <variant>
+ <configItem>
+ <name>bksl</name>
+ <_description>With &lt;\|&gt; key</_description>
+ </configItem>
+ </variant>
+ <variant>
+ <configItem>
+ <name>qwerty</name>
+ <_description>qwerty</_description>
+ </configItem>
+ </variant>
+ <variant>
+ <configItem>
+ <name>qwerty_bksl</name>
+ <_description>qwerty, extended Backslash</_description>
+ </configItem>
+ </variant>
+ <variant>
+ <configItem>
+ <name>ucw</name>
+ <_description>UCW layout (accented letters only)</_description>
+ </configItem>
+ </variant>
+ <variant>
+ <configItem>
+ <name>dvorak-ucw</name>
+ <_description>US Dvorak with CZ UCW support</_description>
+ </configItem>
+ </variant>
+ </variantList>
+ </layout>
+ <layout>
+ <configItem>
+ <name>dk</name>
+ <_shortDescription>Dnk</_shortDescription>
+ <_description>Denmark</_description>
+ <languageList><iso639Id>dan</iso639Id></languageList>
+ </configItem>
+ <variantList>
+ <variant>
+ <configItem>
+ <name>nodeadkeys</name>
+ <_description>Eliminate dead keys</_description>
+ </configItem>
+ </variant>
+ <variant>
+ <configItem>
+ <name>mac</name>
+ <_description>Macintosh</_description>
+ </configItem>
+ </variant>
+ <variant>
+ <configItem>
+ <name>mac_nodeadkeys</name>
+ <_description>Macintosh, eliminate dead keys</_description>
+ </configItem>
+ </variant>
+ <variant>
+ <configItem>
+ <name>dvorak</name>
+ <_description>Dvorak</_description>
+ </configItem>
+ </variant>
+ </variantList>
+ </layout>
+ <layout>
+ <configItem>
+ <name>nl</name>
+ <_shortDescription>Nld</_shortDescription>
+ <_description>Netherlands</_description>
+ <languageList><iso639Id>nld</iso639Id></languageList>
+ </configItem>
+ <variantList>
+ <variant>
+ <configItem>
+ <name>sundeadkeys</name>
+ <_description>Sun dead keys</_description>
+ </configItem>
+ </variant>
+ <variant>
+ <configItem>
+ <name>mac</name>
+ <_description>Macintosh</_description>
+ </configItem>
+ </variant>
+ <variant>
+ <configItem>
+ <name>std</name>
+ <_description>Standard</_description>
+ </configItem>
+ </variant>
+ </variantList>
+ </layout>
+ <layout>
+ <configItem>
+ <name>bt</name>
+ <_shortDescription>Btn</_shortDescription>
+ <_description>Bhutan</_description>
+ <languageList><iso639Id>dzo</iso639Id></languageList>
+ </configItem>
+ </layout>
+ <layout>
+ <configItem>
+ <name>ee</name>
+ <_shortDescription>Est</_shortDescription>
+ <_description>Estonia</_description>
+ <languageList><iso639Id>est</iso639Id></languageList>
+ </configItem>
+ <variantList>
+ <variant>
+ <configItem>
+ <name>nodeadkeys</name>
+ <_description>Eliminate dead keys</_description>
+ </configItem>
+ </variant>
+ <variant>
+ <configItem>
+ <name>dvorak</name>
+ <_description>Dvorak</_description>
+ </configItem>
+ </variant>
+ <variant>
+ <configItem>
+ <name>us</name>
+ <_description>US keyboard with Estonian letters</_description>
+ </configItem>
+ </variant>
+ </variantList>
+ </layout>
+ <layout>
+ <configItem>
+ <name>ir</name>
+ <_shortDescription>Irn</_shortDescription>
+ <_description>Iran</_description>
+ <languageList><iso639Id>per</iso639Id></languageList>
+ </configItem>
+ <variantList>
+ <variant>
+ <configItem>
+ <name>pes_keypad</name>
+ <_description>Persian, with Persian Keypad</_description>
+ </configItem>
+ </variant>
+ <variant>
+ <configItem>
+ <name>ku</name>
+ <_description>Kurdish, Latin Q</_description>
+ <languageList><iso639Id>kur</iso639Id></languageList>
+ </configItem>
+ </variant>
+ <variant>
+ <configItem>
+ <name>ku_f</name>
+ <_description>Kurdish, (F)</_description>
+ <languageList><iso639Id>kur</iso639Id></languageList>
+ </configItem>
+ </variant>
+ <variant>
+ <configItem>
+ <name>ku_alt</name>
+ <_description>Kurdish, Latin Alt-Q</_description>
+ <languageList><iso639Id>kur</iso639Id></languageList>
+ </configItem>
+ </variant>
+ <variant>
+ <configItem>
+ <name>ku_ara</name>
+ <_description>Kurdish, Arabic-Latin</_description>
+ <languageList><iso639Id>kur</iso639Id></languageList>
+ </configItem>
+ </variant>
+ </variantList>
+ </layout>
+ <layout>
+ <configItem>
+ <name>iq</name>
+ <_shortDescription>Irq</_shortDescription>
+ <_description>Iraq</_description>
+ <languageList><iso639Id>ara</iso639Id>
+ <iso639Id>kur</iso639Id></languageList>
+ </configItem>
+ <variantList>
+ <variant>
+ <configItem>
+ <name>ku</name>
+ <_description>Kurdish, Latin Q</_description>
+ <languageList><iso639Id>kur</iso639Id></languageList>
+ </configItem>
+ </variant>
+ <variant>
+ <configItem>
+ <name>ku_f</name>
+ <_description>Kurdish, (F)</_description>
+ <languageList><iso639Id>kur</iso639Id></languageList>
+ </configItem>
+ </variant>
+ <variant>
+ <configItem>
+ <name>ku_alt</name>
+ <_description>Kurdish, Latin Alt-Q</_description>
+ <languageList><iso639Id>kur</iso639Id></languageList>
+ </configItem>
+ </variant>
+ <variant>
+ <configItem>
+ <name>ku_ara</name>
+ <_description>Kurdish, Arabic-Latin</_description>
+ <languageList><iso639Id>kur</iso639Id></languageList>
+ </configItem>
+ </variant>
+ </variantList>
+ </layout>
+ <layout>
+ <configItem>
+ <name>fo</name>
+ <_shortDescription>Fro</_shortDescription>
+ <_description>Faroe Islands</_description>
+ <languageList><iso639Id>fao</iso639Id></languageList>
+ </configItem>
+ <variantList>
+ <variant>
+ <configItem>
+ <name>nodeadkeys</name>
+ <_description>Eliminate dead keys</_description>
+ </configItem>
+ </variant>
+ </variantList>
+ </layout>
+ <layout>
+ <configItem>
+ <name>fi</name>
+ <_shortDescription>Fin</_shortDescription>
+ <_description>Finland</_description>
+ <languageList><iso639Id>fin</iso639Id></languageList>
+ </configItem>
+ <variantList>
+ <variant>
+ <configItem>
+ <name>classic</name>
+ <_description>Classic</_description>
+ </configItem>
+ </variant>
+ <variant>
+ <configItem>
+ <name>nodeadkeys</name>
+ <_description>Classic, eliminate dead keys</_description>
+ </configItem>
+ </variant>
+ <variant>
+ <configItem>
+ <name>smi</name>
+ <_description>Northern Saami</_description>
+ <languageList><iso639Id>smi</iso639Id>
+ <iso639Id>sme</iso639Id></languageList>
+ </configItem>
+ </variant>
+ <variant>
+ <configItem>
+ <name>mac</name>
+ <_description>Macintosh</_description>
+ </configItem>
+ </variant>
+ </variantList>
+ </layout>
+ <layout>
+ <configItem>
+ <name>fr</name>
+ <_shortDescription>Fra</_shortDescription>
+ <_description>France</_description>
+ <languageList><iso639Id>fra</iso639Id></languageList>
+ </configItem>
+ <variantList>
+ <variant>
+ <configItem>
+ <name>nodeadkeys</name>
+ <_description>Eliminate dead keys</_description>
+ </configItem>
+ </variant>
+ <variant>
+ <configItem>
+ <name>sundeadkeys</name>
+ <_description>Sun dead keys</_description>
+ </configItem>
+ </variant>
+ <variant>
+ <configItem>
+ <name>oss</name>
+ <_description>Alternative</_description>
+ </configItem>
+ </variant>
+ <variant>
+ <configItem>
+ <name>oss_latin9</name>
+ <_description>Alternative, latin-9 only</_description>
+ </configItem>
+ </variant>
+ <variant>
+ <configItem>
+ <name>oss_nodeadkeys</name>
+ <_description>Alternative, eliminate dead keys</_description>
+ </configItem>
+ </variant>
+ <variant>
+ <configItem>
+ <name>oss_sundeadkeys</name>
+ <_description>Alternative, Sun dead keys</_description>
+ </configItem>
+ </variant>
+ <variant>
+ <configItem>
+ <name>latin9</name>
+ <_description>(Legacy) Alternative</_description>
+ </configItem>
+ </variant>
+ <variant>
+ <configItem>
+ <name>latin9_nodeadkeys</name>
+ <_description>(Legacy) Alternative, eliminate dead keys</_description>
+ </configItem>
+ </variant>
+ <variant>
+ <configItem>
+ <name>latin9_sundeadkeys</name>
+ <_description>(Legacy) Alternative, Sun dead keys</_description>
+ </configItem>
+ </variant>
+ <variant>
+ <configItem>
+ <name>bepo</name>
+ <_description>Bepo, ergonomic, Dvorak way</_description>
+ </configItem>
+ </variant>
+ <variant>
+ <configItem>
+ <name>bepo_latin9</name>
+ <_description>Bepo, ergonomic, Dvorak way, latin-9 only</_description>
+ </configItem>
+ </variant>
+ <variant>
+ <configItem>
+ <name>dvorak</name>
+ <_description>Dvorak</_description>
+ </configItem>
+ </variant>
+ <variant>
+ <configItem>
+ <name>mac</name>
+ <_description>Macintosh</_description>
+ </configItem>
+ </variant>
+ <variant>
+ <configItem>
+ <name>bre</name>
+ <_description>Breton</_description>
+ </configItem>
+ </variant>
+ <variant>
+ <configItem>
+ <name>oci</name>
+ <_description>Occitan</_description>
+ <languageList><iso639Id>oci</iso639Id></languageList>
+ </configItem>
+ </variant>
+ <variant>
+ <configItem>
+ <name>geo</name>
+ <_description>Georgian AZERTY Tskapo</_description>
+ <languageList><iso639Id>geo</iso639Id></languageList>
+ </configItem>
+ </variant>
+ </variantList>
+ </layout>
+ <layout>
+ <configItem>
+ <name>gh</name>
+ <_shortDescription>Gha</_shortDescription>
+ <_description>Ghana</_description>
+ <languageList><iso639Id>eng</iso639Id></languageList>
+ </configItem>
+ <variantList>
+ <variant>
+ <configItem>
+ <name>generic</name>
+ <_description>Multilingual</_description>
+ </configItem>
+ </variant>
+ <variant>
+ <configItem>
+ <name>akan</name>
+ <_description>Akan</_description>
+ <languageList><iso639Id>aka</iso639Id></languageList>
+ </configItem>
+ </variant>
+ <variant>
+ <configItem>
+ <name>ewe</name>
+ <_description>Ewe</_description>
+ <languageList><iso639Id>ewe</iso639Id></languageList>
+ </configItem>
+ </variant>
+ <variant>
+ <configItem>
+ <name>fula</name>
+ <_description>Fula</_description>
+ <languageList><iso639Id>ful</iso639Id></languageList>
+ </configItem>
+ </variant>
+ <variant>
+ <configItem>
+ <name>ga</name>
+ <_description>Ga</_description>
+ <languageList><iso639Id>gaa</iso639Id></languageList>
+ </configItem>
+ </variant>
+ <variant>
+ <configItem>
+ <name>hausa</name>
+ <_description>Hausa</_description>
+ <languageList><iso639Id>hau</iso639Id></languageList>
+ </configItem>
+ </variant>
+ <variant>
+ <configItem>
+ <name>avn</name>
+ <_description>Avatime</_description>
+ <languageList><iso639Id>avn</iso639Id></languageList>
+ </configItem>
+ </variant>
+ <variant>
+ <configItem>
+ <name>gillbt</name>
+ <_description>GILLBT</_description>
+ </configItem>
+ </variant>
+ </variantList>
+ </layout>
+ <layout>
+ <configItem>
+ <name>gn</name>
+ <_shortDescription>Gin</_shortDescription>
+ <_description>Guinea</_description>
+ <languageList><iso639Id>fra</iso639Id></languageList>
+ </configItem>
+ <variantList/>
+ </layout>
+ <layout>
+ <configItem>
+ <name>ge</name>
+ <_shortDescription>Geo</_shortDescription>
+ <_description>Georgia</_description>
+ <languageList><iso639Id>geo</iso639Id></languageList>
+ </configItem>
+ <variantList>
+ <variant>
+ <configItem>
+ <name>ergonomic</name>
+ <_description>Ergonomic</_description>
+ </configItem>
+ </variant>
+ <variant>
+ <configItem>
+ <name>mess</name>
+ <_description>MESS</_description>
+ </configItem>
+ </variant>
+ <variant>
+ <configItem>
+ <name>ru</name>
+ <_description>Russian</_description>
+ <languageList><iso639Id>rus</iso639Id></languageList>
+ </configItem>
+ </variant>
+ <variant>
+ <configItem>
+ <name>os</name>
+ <_description>Ossetian</_description>
+ <languageList><iso639Id>oss</iso639Id></languageList>
+ </configItem>
+ </variant>
+ </variantList>
+ </layout>
+ <layout>
+ <configItem>
+ <name>de</name>
+ <_shortDescription>Deu</_shortDescription>
+ <_description>Germany</_description>
+ <languageList><iso639Id>ger</iso639Id></languageList>
+ </configItem>
+ <variantList>
+ <variant>
+ <configItem>
+ <name>deadacute</name>
+ <_description>Dead acute</_description>
+ </configItem>
+ </variant>
+ <variant>
+ <configItem>
+ <name>deadgraveacute</name>
+ <_description>Dead grave acute</_description>
+ </configItem>
+ </variant>
+ <variant>
+ <configItem>
+ <name>nodeadkeys</name>
+ <_description>Eliminate dead keys</_description>
+ </configItem>
+ </variant>
+ <variant>
+ <configItem>
+ <name>ro</name>
+ <_description>Romanian keyboard with German letters</_description>
+ </configItem>
+ </variant>
+ <variant>
+ <configItem>
+ <name>ro_nodeadkeys</name>
+ <_description>Romanian keyboard with German letters, eliminate dead keys</_description>
+ </configItem>
+ </variant>
+ <variant>
+ <configItem>
+ <name>dvorak</name>
+ <_description>Dvorak</_description>
+ </configItem>
+ </variant>
+ <variant>
+ <configItem>
+ <name>sundeadkeys</name>
+ <_description>Sun dead keys</_description>
+ </configItem>
+ </variant>
+ <variant>
+ <configItem>
+ <name>neo</name>
+ <_description>Neo 2</_description>
+ </configItem>
+ </variant>
+ <variant>
+ <configItem>
+ <name>mac</name>
+ <_description>Macintosh</_description>
+ </configItem>
+ </variant>
+ <variant>
+ <configItem>
+ <name>mac_nodeadkeys</name>
+ <_description>Macintosh, eliminate dead keys</_description>
+ </configItem>
+ </variant>
+ <variant>
+ <configItem>
+ <name>dsb</name>
+ <_description>Lower Sorbian</_description>
+ <languageList><iso639Id>dsb</iso639Id></languageList>
+ </configItem>
+ </variant>
+ <variant>
+ <configItem>
+ <name>dsb_qwertz</name>
+ <_description>Lower Sorbian (qwertz)</_description>
+ <languageList><iso639Id>dsb</iso639Id></languageList>
+ </configItem>
+ </variant>
+ <variant>
+ <configItem>
+ <name>qwerty</name>
+ <_description>qwerty</_description>
+ </configItem>
+ </variant>
+ <variant>
+ <configItem>
+ <name>ru</name>
+ <_description>Russian phonetic</_description>
+ <languageList><iso639Id>rus</iso639Id></languageList>
+ </configItem>
+ </variant>
+ </variantList>
+ </layout>
+ <layout>
+ <configItem>
+ <name>gr</name>
+ <_shortDescription>Grc</_shortDescription>
+ <_description>Greece</_description>
+ <languageList><iso639Id>gre</iso639Id></languageList>
+ </configItem>
+ <variantList>
+ <variant>
+ <configItem>
+ <name>simple</name>
+ <_description>Simple</_description>
+ </configItem>
+ </variant>
+ <variant>
+ <configItem>
+ <name>extended</name>
+ <_description>Extended</_description>
+ </configItem>
+ </variant>
+ <variant>
+ <configItem>
+ <name>nodeadkeys</name>
+ <_description>Eliminate dead keys</_description>
+ </configItem>
+ </variant>
+ <variant>
+ <configItem>
+ <name>polytonic</name>
+ <_description>Polytonic</_description>
+ </configItem>
+ </variant>
+ </variantList>
+ </layout>
+ <layout>
+ <configItem>
+ <name>hu</name>
+ <_shortDescription>Hun</_shortDescription>
+ <_description>Hungary</_description>
+ <languageList><iso639Id>hun</iso639Id></languageList>
+ </configItem>
+ <variantList>
+ <variant>
+ <configItem>
+ <name>standard</name>
+ <_description>Standard</_description>
+ </configItem>
+ </variant>
+ <variant>
+ <configItem>
+ <name>nodeadkeys</name>
+ <_description>Eliminate dead keys</_description>
+ </configItem>
+ </variant>
+ <variant>
+ <configItem>
+ <name>qwerty</name>
+ <_description>qwerty</_description>
+ </configItem>
+ </variant>
+
+ <!-- 101 keys -->
+ <variant>
+ <configItem>
+ <name>101_qwertz_comma_dead</name>
+ <_description>101/qwertz/comma/Dead keys</_description>
+ </configItem>
+ </variant>
+ <variant>
+ <configItem>
+ <name>101_qwertz_comma_nodead</name>
+ <_description>101/qwertz/comma/Eliminate dead keys</_description>
+ </configItem>
+ </variant>
+ <variant>
+ <configItem>
+ <name>101_qwertz_dot_dead</name>
+ <_description>101/qwertz/dot/Dead keys</_description>
+ </configItem>
+ </variant>
+ <variant>
+ <configItem>
+ <name>101_qwertz_dot_nodead</name>
+ <_description>101/qwertz/dot/Eliminate dead keys</_description>
+ </configItem>
+ </variant>
+ <variant>
+ <configItem>
+ <name>101_qwerty_comma_dead</name>
+ <_description>101/qwerty/comma/Dead keys</_description>
+ </configItem>
+ </variant>
+ <variant>
+ <configItem>
+ <name>101_qwerty_comma_nodead</name>
+ <_description>101/qwerty/comma/Eliminate dead keys</_description>
+ </configItem>
+ </variant>
+ <variant>
+ <configItem>
+ <name>101_qwerty_dot_dead</name>
+ <_description>101/qwerty/dot/Dead keys</_description>
+ </configItem>
+ </variant>
+ <variant>
+ <configItem>
+ <name>101_qwerty_dot_nodead</name>
+ <_description>101/qwerty/dot/Eliminate dead keys</_description>
+ </configItem>
+ </variant>
+
+
+ <!-- 102 keys -->
+ <variant>
+ <configItem>
+ <name>102_qwertz_comma_dead</name>
+ <_description>102/qwertz/comma/Dead keys</_description>
+ </configItem>
+ </variant>
+ <variant>
+ <configItem>
+ <name>102_qwertz_comma_nodead</name>
+ <_description>102/qwertz/comma/Eliminate dead keys</_description>
+ </configItem>
+ </variant>
+ <variant>
+ <configItem>
+ <name>102_qwertz_dot_dead</name>
+ <_description>102/qwertz/dot/Dead keys</_description>
+ </configItem>
+ </variant>
+ <variant>
+ <configItem>
+ <name>102_qwertz_dot_nodead</name>
+ <_description>102/qwertz/dot/Eliminate dead keys</_description>
+ </configItem>
+ </variant>
+ <variant>
+ <configItem>
+ <name>102_qwerty_comma_dead</name>
+ <_description>102/qwerty/comma/Dead keys</_description>
+ </configItem>
+ </variant>
+ <variant>
+ <configItem>
+ <name>102_qwerty_comma_nodead</name>
+ <_description>102/qwerty/comma/Eliminate dead keys</_description>
+ </configItem>
+ </variant>
+ <variant>
+ <configItem>
+ <name>102_qwerty_dot_dead</name>
+ <_description>102/qwerty/dot/Dead keys</_description>
+ </configItem>
+ </variant>
+ <variant>
+ <configItem>
+ <name>102_qwerty_dot_nodead</name>
+ <_description>102/qwerty/dot/Eliminate dead keys</_description>
+ </configItem>
+ </variant>
+ </variantList>
+ </layout>
+ <layout>
+ <configItem>
+ <name>is</name>
+ <_shortDescription>Isl</_shortDescription>
+ <_description>Iceland</_description>
+ <languageList><iso639Id>ice</iso639Id></languageList>
+ </configItem>
+ <variantList>
+ <variant>
+ <configItem>
+ <name>Sundeadkeys</name>
+ <_description>Sun dead keys</_description>
+ </configItem>
+ </variant>
+ <variant>
+ <configItem>
+ <name>nodeadkeys</name>
+ <_description>Eliminate dead keys</_description>
+ </configItem>
+ </variant>
+ <variant>
+ <configItem>
+ <name>mac</name>
+ <_description>Macintosh</_description>
+ </configItem>
+ </variant>
+ <variant>
+ <configItem>
+ <name>dvorak</name>
+ <_description>Dvorak</_description>
+ </configItem>
+ </variant>
+ </variantList>
+ </layout>
+ <layout>
+ <configItem>
+ <name>il</name>
+ <_shortDescription>Isr</_shortDescription>
+ <_description>Israel</_description>
+ <languageList><iso639Id>heb</iso639Id></languageList>
+ </configItem>
+ <variantList>
+ <variant>
+ <configItem>
+ <name>lyx</name>
+ <_description>lyx</_description>
+ </configItem>
+ </variant>
+ <variant>
+ <configItem>
+ <name>phonetic</name>
+ <_description>Phonetic</_description>
+ </configItem>
+ </variant>
+ <variant>
+ <configItem>
+ <name>biblical</name>
+ <_description>Biblical Hebrew (Tiro)</_description>
+ </configItem>
+ </variant>
+ </variantList>
+ </layout>
+ <layout>
+ <configItem>
+ <name>it</name>
+ <_shortDescription>Ita</_shortDescription>
+ <_description>Italy</_description>
+ <languageList><iso639Id>ita</iso639Id></languageList>
+ </configItem>
+ <variantList>
+ <variant>
+ <configItem>
+ <name>nodeadkeys</name>
+ <_description>Eliminate dead keys</_description>
+ </configItem>
+ </variant>
+ <variant>
+ <configItem>
+ <name>mac</name>
+ <_description>Macintosh</_description>
+ </configItem>
+ </variant>
+ <variant>
+ <configItem>
+ <name>us</name>
+ <_description>US keyboard with Italian letters</_description>
+ </configItem>
+ </variant>
+ <variant>
+ <configItem>
+ <name>geo</name>
+ <_description>Georgian</_description>
+ <languageList><iso639Id>geo</iso639Id></languageList>
+ </configItem>
+ </variant>
+ </variantList>
+ </layout>
+ <layout>
+ <configItem>
+ <name>jp</name>
+ <_shortDescription>Jpn</_shortDescription>
+ <_description>Japan</_description>
+ <languageList><iso639Id>jpn</iso639Id></languageList>
+ </configItem>
+ <variantList>
+ <variant>
+ <configItem>
+ <name>kana</name>
+ <_description>Kana</_description>
+ </configItem>
+ </variant>
+ <variant>
+ <configItem>
+ <name>kana86</name>
+ <_description>Kana 86</_description>
+ </configItem>
+ </variant>
+ <variant>
+ <configItem>
+ <name>OADG109A</name>
+ <_description>OADG 109A</_description>
+ </configItem>
+ </variant>
+ <variant>
+ <configItem>
+ <name>mac</name>
+ <_description>Macintosh</_description>
+ </configItem>
+ </variant>
+ </variantList>
+ </layout>
+ <layout>
+ <configItem>
+ <name>kg</name>
+ <_shortDescription>Kgz</_shortDescription>
+ <_description>Kyrgyzstan</_description>
+ <languageList><iso639Id>kir</iso639Id></languageList>
+ </configItem>
+ <variantList>
+ <variant>
+ <configItem>
+ <name>phonetic</name>
+ <_description>Phonetic</_description>
+ </configItem>
+ </variant>
+ </variantList>
+ </layout>
+ <layout>
+ <configItem>
+ <name>kh</name>
+ <_shortDescription>Khm</_shortDescription>
+ <_description>Cambodia</_description>
+ <languageList><iso639Id>khm</iso639Id></languageList>
+ </configItem>
+ <variantList/>
+ </layout>
+ <layout>
+ <configItem>
+ <name>kz</name>
+ <_shortDescription>Kaz</_shortDescription>
+ <_description>Kazakhstan</_description>
+ <languageList><iso639Id>kaz</iso639Id></languageList>
+ </configItem>
+ <variantList>
+ <variant>
+ <configItem>
+ <name>ruskaz</name>
+ <_description>Russian with Kazakh</_description>
+ <languageList><iso639Id>kaz</iso639Id>
+ <iso639Id>rus</iso639Id></languageList>
+ </configItem>
+ </variant>
+ <variant>
+ <configItem>
+ <name>kazrus</name>
+ <_description>Kazakh with Russian</_description>
+ <languageList><iso639Id>kaz</iso639Id>
+ <iso639Id>rus</iso639Id></languageList>
+ </configItem>
+ </variant>
+ </variantList>
+ </layout>
+ <layout>
+ <configItem>
+ <name>la</name>
+ <_shortDescription>Lao</_shortDescription>
+ <_description>Laos</_description>
+ <languageList><iso639Id>lao</iso639Id></languageList>
+ </configItem>
+ <variantList/>
+ </layout>
+ <layout>
+ <configItem>
+ <name>latam</name>
+ <_shortDescription>LAm</_shortDescription>
+ <_description>Latin American</_description>
+ <countryList>
+ <iso3166Id>AR</iso3166Id>
+ <iso3166Id>BO</iso3166Id>
+ <iso3166Id>CL</iso3166Id>
+ <iso3166Id>CO</iso3166Id>
+ <iso3166Id>CR</iso3166Id>
+ <iso3166Id>CU</iso3166Id>
+ <iso3166Id>DO</iso3166Id>
+ <iso3166Id>EC</iso3166Id>
+ <iso3166Id>GT</iso3166Id>
+ <iso3166Id>HN</iso3166Id>
+ <iso3166Id>HT</iso3166Id>
+ <iso3166Id>MX</iso3166Id>
+ <iso3166Id>NI</iso3166Id>
+ <iso3166Id>PA</iso3166Id>
+ <iso3166Id>PE</iso3166Id>
+ <iso3166Id>PR</iso3166Id>
+ <iso3166Id>PY</iso3166Id>
+ <iso3166Id>SV</iso3166Id>
+ <iso3166Id>US</iso3166Id>
+ <iso3166Id>UY</iso3166Id>
+ <iso3166Id>VE</iso3166Id>
+ </countryList>
+ <languageList><iso639Id>spa</iso639Id></languageList>
+ </configItem>
+ <variantList>
+ <variant>
+ <configItem>
+ <name>nodeadkeys</name>
+ <_description>Eliminate dead keys</_description>
+ </configItem>
+ </variant>
+ <variant>
+ <configItem>
+ <name>deadtilde</name>
+ <_description>Include dead tilde</_description>
+ </configItem>
+ </variant>
+ <variant>
+ <configItem>
+ <name>sundeadkeys</name>
+ <_description>Sun dead keys</_description>
+ </configItem>
+ </variant>
+ </variantList>
+ </layout>
+ <layout>
+ <configItem>
+ <name>lt</name>
+ <_shortDescription>Ltu</_shortDescription>
+ <_description>Lithuania</_description>
+ <languageList><iso639Id>lit</iso639Id></languageList>
+ </configItem>
+ <variantList>
+ <variant>
+ <configItem>
+ <name>std</name>
+ <_description>Standard</_description>
+ </configItem>
+ </variant>
+ <variant>
+ <configItem>
+ <name>us</name>
+ <_description>US keyboard with Lithuanian letters</_description>
+ </configItem>
+ </variant>
+ <variant>
+ <configItem>
+ <name>ibm</name>
+ <_description>IBM (LST 1205-92)</_description>
+ </configItem>
+ </variant>
+ <variant>
+ <configItem>
+ <name>lekp</name>
+ <_description>LEKP</_description>
+ </configItem>
+ </variant>
+ <variant>
+ <configItem>
+ <name>lekpa</name>
+ <_description>LEKPa</_description>
+ </configItem>
+ </variant>
+ </variantList>
+ </layout>
+ <layout>
+ <configItem>
+ <name>lv</name>
+ <_shortDescription>Lva</_shortDescription>
+ <_description>Latvia</_description>
+ <languageList><iso639Id>lav</iso639Id></languageList>
+ </configItem>
+ <variantList>
+ <variant>
+ <configItem>
+ <name>apostrophe</name>
+ <_description>Apostrophe (') variant</_description>
+ </configItem>
+ </variant>
+ <variant>
+ <configItem>
+ <name>tilde</name>
+ <_description>Tilde (~) variant</_description>
+ </configItem>
+ </variant>
+ <variant>
+ <configItem>
+ <name>fkey</name>
+ <_description>F-letter (F) variant</_description>
+ </configItem>
+ </variant>
+ </variantList>
+ </layout>
+ <layout>
+ <configItem>
+ <name>mao</name>
+ <_shortDescription>Mao</_shortDescription>
+ <_description>Maori</_description>
+ <languageList><iso639Id>mao</iso639Id></languageList>
+ </configItem>
+ <variantList/>
+ </layout>
+ <layout>
+ <configItem>
+ <name>me</name>
+ <_shortDescription>MNE</_shortDescription>
+ <_description>Montenegro</_description>
+ <languageList><iso639Id>srp</iso639Id></languageList>
+ </configItem>
+ <variantList>
+ <variant>
+ <configItem>
+ <name>cyrillic</name>
+ <_description>Cyrillic</_description>
+ </configItem>
+ </variant>
+ <variant>
+ <configItem>
+ <name>cyrillicyz</name>
+ <_description>Cyrillic, Z and ZHE swapped</_description>
+ </configItem>
+ </variant>
+ <variant>
+ <configItem>
+ <name>latinunicode</name>
+ <_description>Latin unicode</_description>
+ </configItem>
+ </variant>
+ <variant>
+ <configItem>
+ <name>latinyz</name>
+ <_description>Latin qwerty</_description>
+ </configItem>
+ </variant>
+ <variant>
+ <configItem>
+ <name>latinunicodeyz</name>
+ <_description>Latin unicode qwerty</_description>
+ </configItem>
+ </variant>
+ <variant>
+ <configItem>
+ <name>cyrillicalternatequotes</name>
+ <_description>Cyrillic with guillemets</_description>
+ </configItem>
+ </variant>
+ <variant>
+ <configItem>
+ <name>latinalternatequotes</name>
+ <_description>Latin with guillemets</_description>
+ </configItem>
+ </variant>
+ </variantList>
+ </layout>
+ <layout>
+ <configItem>
+ <name>mk</name>
+ <_shortDescription>Mkd</_shortDescription>
+ <_description>Macedonia</_description>
+ <languageList><iso639Id>mkd</iso639Id></languageList>
+ </configItem>
+ <variantList>
+ <variant>
+ <configItem>
+ <name>nodeadkeys</name>
+ <_description>Eliminate dead keys</_description>
+ </configItem>
+ </variant>
+ </variantList>
+ </layout>
+ <layout>
+ <configItem>
+ <name>mt</name>
+ <_shortDescription>Mlt</_shortDescription>
+ <_description>Malta</_description>
+ <languageList><iso639Id>mlt</iso639Id></languageList>
+ </configItem>
+ <variantList>
+ <variant>
+ <configItem>
+ <name>us</name>
+ <_description>Maltese keyboard with US layout</_description>
+ </configItem>
+ </variant>
+ </variantList>
+ </layout>
+ <layout>
+ <configItem>
+ <name>mn</name>
+ <_shortDescription>Mng</_shortDescription>
+ <_description>Mongolia</_description>
+ <languageList><iso639Id>mng</iso639Id></languageList>
+ </configItem>
+ <variantList/>
+ </layout>
+ <layout>
+ <configItem>
+ <name>no</name>
+ <_shortDescription>Nor</_shortDescription>
+ <_description>Norway</_description>
+ <languageList><iso639Id>nor</iso639Id></languageList>
+ </configItem>
+ <variantList>
+ <variant>
+ <configItem>
+ <name>nodeadkeys</name>
+ <_description>Eliminate dead keys</_description>
+ </configItem>
+ </variant>
+ <variant>
+ <configItem>
+ <name>dvorak</name>
+ <_description>Dvorak</_description>
+ </configItem>
+ </variant>
+ <variant>
+ <configItem>
+ <name>smi</name>
+ <_description>Northern Saami</_description>
+ <languageList><iso639Id>sme</iso639Id></languageList>
+ </configItem>
+ </variant>
+ <variant>
+ <configItem>
+ <name>smi_nodeadkeys</name>
+ <_description>Northern Saami, eliminate dead keys</_description>
+ <languageList><iso639Id>sme</iso639Id></languageList>
+ </configItem>
+ </variant>
+ <variant>
+ <configItem>
+ <name>mac</name>
+ <_description>Macintosh</_description>
+ </configItem>
+ </variant>
+ <variant>
+ <configItem>
+ <name>mac_nodeadkeys</name>
+ <_description>Macintosh, eliminate dead keys</_description>
+ </configItem>
+ </variant>
+ </variantList>
+ </layout>
+ <layout>
+ <configItem>
+ <name>pl</name>
+ <_shortDescription>Pol</_shortDescription>
+ <_description>Poland</_description>
+ <languageList><iso639Id>pol</iso639Id></languageList>
+ </configItem>
+ <variantList>
+ <variant>
+ <configItem>
+ <name>qwertz</name>
+ <_description>qwertz</_description>
+ </configItem>
+ </variant>
+ <variant>
+ <configItem>
+ <name>dvorak</name>
+ <_description>Dvorak</_description>
+ </configItem>
+ </variant>
+ <variant>
+ <configItem>
+ <name>dvorak_quotes</name>
+ <_description>Dvorak, Polish quotes on quotemark key</_description>
+ </configItem>
+ </variant>
+ <variant>
+ <configItem>
+ <name>dvorak_altquotes</name>
+ <_description>Dvorak, Polish quotes on key 1</_description>
+ </configItem>
+ </variant>
+ <variant>
+ <configItem>
+ <name>csb</name>
+ <_description>Kashubian</_description>
+ <languageList><iso639Id>csb</iso639Id></languageList>
+ </configItem>
+ </variant>
+ <variant>
+ <configItem>
+ <name>ru_phonetic_dvorak</name>
+ <_description>Russian phonetic Dvorak</_description>
+ <languageList><iso639Id>rus</iso639Id></languageList>
+ </configItem>
+ </variant>
+ <variant>
+ <configItem>
+ <name>dvp</name>
+ <_description>Programmer Dvorak</_description>
+ </configItem>
+ </variant>
+ </variantList>
+ </layout>
+ <layout>
+ <configItem>
+ <name>pt</name>
+ <_shortDescription>Prt</_shortDescription>
+ <_description>Portugal</_description>
+ <languageList><iso639Id>por</iso639Id></languageList>
+ </configItem>
+ <variantList>
+ <variant>
+ <configItem>
+ <name>nodeadkeys</name>
+ <_description>Eliminate dead keys</_description>
+ </configItem>
+ </variant>
+ <variant>
+ <configItem>
+ <name>sundeadkeys</name>
+ <_description>Sun dead keys</_description>
+ </configItem>
+ </variant>
+ <variant>
+ <configItem>
+ <name>mac</name>
+ <_description>Macintosh</_description>
+ </configItem>
+ </variant>
+ <variant>
+ <configItem>
+ <name>mac_nodeadkeys</name>
+ <_description>Macintosh, eliminate dead keys</_description>
+ </configItem>
+ </variant>
+ <variant>
+ <configItem>
+ <name>mac_sundeadkeys</name>
+ <_description>Macintosh, Sun dead keys</_description>
+ </configItem>
+ </variant>
+ <variant>
+ <configItem>
+ <name>nativo</name>
+ <_description>Nativo</_description>
+ </configItem>
+ </variant>
+ <variant>
+ <configItem>
+ <name>nativo-us</name>
+ <_description>Nativo for USA keyboards</_description>
+ </configItem>
+ </variant>
+ <variant>
+ <configItem>
+ <name>nativo-epo</name>
+ <_description>Nativo for Esperanto</_description>
+ <languageList><iso639Id>epo</iso639Id></languageList>
+ </configItem>
+ </variant>
+ </variantList>
+ </layout>
+ <layout>
+ <configItem>
+ <name>ro</name>
+ <_shortDescription>Rou</_shortDescription>
+ <_description>Romania</_description>
+ <languageList><iso639Id>rum</iso639Id></languageList>
+ </configItem>
+ <variantList>
+ <variant>
+ <configItem>
+ <name>cedilla</name>
+ <_description>Cedilla</_description>
+ </configItem>
+ </variant>
+ <variant>
+ <configItem>
+ <name>std</name>
+ <_description>Standard</_description>
+ </configItem>
+ </variant>
+ <variant>
+ <configItem>
+ <name>std_cedilla</name>
+ <_description>Standard (Cedilla)</_description>
+ </configItem>
+ </variant>
+ <variant>
+ <configItem>
+ <name>winkeys</name>
+ <_description>Winkeys</_description>
+ </configItem>
+ </variant>
+ <variant>
+ <configItem>
+ <name>crh_f</name>
+ <_description>Crimean Tatar (Turkish F)</_description>
+ <languageList><iso639Id>crh</iso639Id></languageList>
+ </configItem>
+ </variant>
+ <variant>
+ <configItem>
+ <name>crh_alt</name>
+ <_description>Crimean Tatar (Turkish Alt-Q)</_description>
+ <languageList><iso639Id>crh</iso639Id></languageList>
+ </configItem>
+ </variant>
+ <variant>
+ <configItem>
+ <name>crh_dobruca1</name>
+ <_description>Crimean Tatar (Dobruca-1 Q)</_description>
+ <languageList><iso639Id>crh</iso639Id></languageList>
+ </configItem>
+ </variant>
+ <variant>
+ <configItem>
+ <name>crh_dobruca2</name>
+ <_description>Crimean Tatar (Dobruca-2 Q)</_description>
+ <languageList><iso639Id>crh</iso639Id></languageList>
+ </configItem>
+ </variant>
+ </variantList>
+ </layout>
+ <layout>
+ <configItem>
+ <name>ru</name>
+ <_shortDescription>Rus</_shortDescription>
+ <_description>Russia</_description>
+ <languageList><iso639Id>rus</iso639Id></languageList>
+ </configItem>
+ <variantList>
+ <variant>
+ <configItem>
+ <name>phonetic</name>
+ <_description>Phonetic</_description>
+ </configItem>
+ </variant>
+ <variant>
+ <configItem>
+ <name>phonetic_winkeys</name>
+ <_description>Phonetic Winkeys</_description>
+ </configItem>
+ </variant>
+ <variant>
+ <configItem>
+ <name>typewriter</name>
+ <_description>Typewriter</_description>
+ </configItem>
+ </variant>
+ <variant>
+ <configItem>
+ <name>legacy</name>
+ <_description>Legacy</_description>
+ </configItem>
+ </variant>
+ <variant>
+ <configItem>
+ <name>typewriter-legacy</name>
+ <_description>Typewriter, legacy</_description>
+ </configItem>
+ </variant>
+ <variant>
+ <configItem>
+ <name>tt</name>
+ <_description>Tatar</_description>
+ <languageList><iso639Id>tat</iso639Id></languageList>
+ </configItem>
+ </variant>
+ <variant>
+ <configItem>
+ <name>os_legacy</name>
+ <_description>Ossetian, legacy</_description>
+ <languageList><iso639Id>oss</iso639Id></languageList>
+ </configItem>
+ </variant>
+ <variant>
+ <configItem>
+ <name>os_winkeys</name>
+ <_description>Ossetian, Winkeys</_description>
+ <languageList><iso639Id>oss</iso639Id></languageList>
+ </configItem>
+ </variant>
+ <variant>
+ <configItem>
+ <name>cv</name>
+ <_description>Chuvash</_description>
+ <languageList><iso639Id>chv</iso639Id></languageList>
+ </configItem>
+ </variant>
+ <variant>
+ <configItem>
+ <name>cv_latin</name>
+ <_description>Chuvash Latin</_description>
+ <languageList><iso639Id>chv</iso639Id></languageList>
+ </configItem>
+ </variant>
+ <variant>
+ <configItem>
+ <name>udm</name>
+ <_description>Udmurt</_description>
+ <languageList><iso639Id>udm</iso639Id></languageList>
+ </configItem>
+ </variant>
+ <variant>
+ <configItem>
+ <name>kom</name>
+ <_description>Komi</_description>
+ <languageList><iso639Id>kom</iso639Id></languageList>
+ </configItem>
+ </variant>
+ <variant>
+ <configItem>
+ <name>sah</name>
+ <_description>Yakut</_description>
+ <languageList><iso639Id>sah</iso639Id></languageList>
+ </configItem>
+ </variant>
+ <variant>
+ <configItem>
+ <name>xal</name>
+ <_description>Kalmyk</_description>
+ <languageList><iso639Id>xal</iso639Id></languageList>
+ </configItem>
+ </variant>
+ <variant>
+ <configItem>
+ <name>dos</name>
+ <_description>DOS</_description>
+ </configItem>
+ </variant>
+ <variant>
+ <configItem>
+ <name>srp</name>
+ <_description>Serbian</_description>
+ <languageList><iso639Id>rus</iso639Id>
+ <iso639Id>srp</iso639Id></languageList>
+ </configItem>
+ </variant>
+ <variant>
+ <configItem>
+ <name>bak</name>
+ <_description>Bashkirian</_description>
+ <languageList><iso639Id>bak</iso639Id></languageList>
+ </configItem>
+ </variant>
+ <variant>
+ <configItem>
+ <name>chm</name>
+ <_description>Mari</_description>
+ <languageList><iso639Id>chm</iso639Id></languageList>
+ </configItem>
+ </variant>
+ </variantList>
+ </layout>
+ <layout>
+ <configItem>
+ <name>rs</name>
+ <_shortDescription>SRB</_shortDescription>
+ <_description>Serbia</_description>
+ <languageList><iso639Id>srp</iso639Id></languageList>
+ </configItem>
+ <variantList>
+ <variant>
+ <configItem>
+ <name>yz</name>
+ <_description>Z and ZHE swapped</_description>
+ </configItem>
+ </variant>
+ <variant>
+ <configItem>
+ <name>latin</name>
+ <_description>Latin</_description>
+ </configItem>
+ </variant>
+ <variant>
+ <configItem>
+ <name>latinunicode</name>
+ <_description>Latin Unicode</_description>
+ </configItem>
+ </variant>
+ <variant>
+ <configItem>
+ <name>latinyz</name>
+ <_description>Latin qwerty</_description>
+ </configItem>
+ </variant>
+ <variant>
+ <configItem>
+ <name>latinunicodeyz</name>
+ <_description>Latin Unicode qwerty</_description>
+ </configItem>
+ </variant>
+ <variant>
+ <configItem>
+ <name>alternatequotes</name>
+ <_description>With guillemets</_description>
+ </configItem>
+ </variant>
+ <variant>
+ <configItem>
+ <name>latinalternatequotes</name>
+ <_description>Latin with guillemets</_description>
+ </configItem>
+ </variant>
+ <variant>
+ <configItem>
+ <name>rue</name>
+ <_description>Pannonian Rusyn Homophonic</_description>
+ <languageList><iso639Id>rue</iso639Id></languageList>
+ </configItem>
+ </variant>
+ </variantList>
+ </layout>
+ <layout>
+ <configItem>
+ <name>si</name>
+ <_shortDescription>Svn</_shortDescription>
+ <_description>Slovenia</_description>
+ <languageList><iso639Id>slv</iso639Id></languageList>
+ </configItem>
+ <variantList>
+ <variant>
+ <configItem>
+ <name>alternatequotes</name>
+ <_description>Use guillemets for quotes</_description>
+ </configItem>
+ </variant>
+ <variant>
+ <configItem>
+ <name>us</name>
+ <_description>US keyboard with Slovenian letters</_description>
+ </configItem>
+ </variant>
+ </variantList>
+ </layout>
+ <layout>
+ <configItem>
+ <name>sk</name>
+ <_shortDescription>Svk</_shortDescription>
+ <_description>Slovakia</_description>
+ <languageList><iso639Id>slo</iso639Id></languageList>
+ </configItem>
+ <variantList>
+ <variant>
+ <configItem>
+ <name>bksl</name>
+ <_description>Extended Backslash</_description>
+ </configItem>
+ </variant>
+ <variant>
+ <configItem>
+ <name>qwerty</name>
+ <_description>qwerty</_description>
+ </configItem>
+ </variant>
+ <variant>
+ <configItem>
+ <name>qwerty_bksl</name>
+ <_description>qwerty, extended Backslash</_description>
+ </configItem>
+ </variant>
+ </variantList>
+ </layout>
+ <layout>
+ <configItem>
+ <name>es</name>
+ <_shortDescription>Esp</_shortDescription>
+ <_description>Spain</_description>
+ <languageList><iso639Id>spa</iso639Id></languageList>
+ </configItem>
+ <variantList>
+ <variant>
+ <configItem>
+ <name>nodeadkeys</name>
+ <_description>Eliminate dead keys</_description>
+ </configItem>
+ </variant>
+ <variant>
+ <configItem>
+ <name>deadtilde</name>
+ <_description>Include dead tilde</_description>
+ </configItem>
+ </variant>
+ <variant>
+ <configItem>
+ <name>sundeadkeys</name>
+ <_description>Sun dead keys</_description>
+ </configItem>
+ </variant>
+ <variant>
+ <configItem>
+ <name>dvorak</name>
+ <_description>Dvorak</_description>
+ </configItem>
+ </variant>
+ <variant>
+ <configItem>
+ <name>ast</name>
+ <_description>Asturian variant with bottom-dot H and bottom-dot L</_description>
+ <languageList><iso639Id>ast</iso639Id></languageList>
+ </configItem>
+ </variant>
+ <variant>
+ <configItem>
+ <name>cat</name>
+ <_description>Catalan variant with middle-dot L</_description>
+ <languageList><iso639Id>cat</iso639Id></languageList>
+ </configItem>
+ </variant>
+ <variant>
+ <configItem>
+ <name>mac</name>
+ <_description>Macintosh</_description>
+ </configItem>
+ </variant>
+ </variantList>
+ </layout>
+ <layout>
+ <configItem>
+ <name>se</name>
+ <_shortDescription>Swe</_shortDescription>
+ <_description>Sweden</_description>
+ <languageList><iso639Id>swe</iso639Id></languageList>
+ </configItem>
+ <variantList>
+ <variant>
+ <configItem>
+ <name>nodeadkeys</name>
+ <_description>Eliminate dead keys</_description>
+ </configItem>
+ </variant>
+ <variant>
+ <configItem>
+ <name>dvorak</name>
+ <_description>Dvorak</_description>
+ </configItem>
+ </variant>
+ <variant>
+ <configItem>
+ <name>rus</name>
+ <_description>Russian phonetic</_description>
+ <languageList><iso639Id>rus</iso639Id></languageList>
+ </configItem>
+ </variant>
+ <variant>
+ <configItem>
+ <name>rus_nodeadkeys</name>
+ <_description>Russian phonetic, eliminate dead keys</_description>
+ <languageList><iso639Id>rus</iso639Id></languageList>
+ </configItem>
+ </variant>
+ <variant>
+ <configItem>
+ <name>smi</name>
+ <_description>Northern Saami</_description>
+ <languageList><iso639Id>sme</iso639Id></languageList>
+ </configItem>
+ </variant>
+ <variant>
+ <configItem>
+ <name>mac</name>
+ <_description>Macintosh</_description>
+ </configItem>
+ </variant>
+ <variant>
+ <configItem>
+ <name>svdvorak</name>
+ <_description>Svdvorak</_description>
+ </configItem>
+ </variant>
+ </variantList>
+ </layout>
+ <layout>
+ <configItem>
+ <name>ch</name>
+ <_shortDescription>Che</_shortDescription>
+ <_description>Switzerland</_description>
+ <languageList><iso639Id>ger</iso639Id>
+ <iso639Id>gsw</iso639Id></languageList>
+ </configItem>
+ <variantList>
+ <variant>
+ <configItem>
+ <name>legacy</name>
+ <_description>Legacy</_description>
+ </configItem>
+ </variant>
+ <variant>
+ <configItem>
+ <name>de_nodeadkeys</name>
+ <_description>German, eliminate dead keys</_description>
+ </configItem>
+ </variant>
+ <variant>
+ <configItem>
+ <name>de_sundeadkeys</name>
+ <_description>German, Sun dead keys</_description>
+ </configItem>
+ </variant>
+ <variant>
+ <configItem>
+ <name>fr</name>
+ <_description>French</_description>
+ <languageList><iso639Id>fra</iso639Id></languageList>
+ </configItem>
+ </variant>
+ <variant>
+ <configItem>
+ <name>fr_nodeadkeys</name>
+ <_description>French, eliminate dead keys</_description>
+ <languageList><iso639Id>fra</iso639Id></languageList>
+ </configItem>
+ </variant>
+ <variant>
+ <configItem>
+ <name>fr_sundeadkeys</name>
+ <_description>French, Sun dead keys</_description>
+ <languageList><iso639Id>fra</iso639Id></languageList>
+ </configItem>
+ </variant>
+ <variant>
+ <configItem>
+ <name>fr_mac</name>
+ <_description>French (Macintosh)</_description>
+ <languageList><iso639Id>fra</iso639Id></languageList>
+ </configItem>
+ </variant>
+ <variant>
+ <configItem>
+ <name>de_mac</name>
+ <_description>German (Macintosh)</_description>
+ </configItem>
+ </variant>
+ </variantList>
+ </layout>
+ <layout>
+ <configItem>
+ <name>sy</name>
+ <_shortDescription>Syr</_shortDescription>
+ <_description>Syria</_description>
+ <languageList><iso639Id>syr</iso639Id></languageList>
+ </configItem>
+ <variantList>
+ <variant>
+ <configItem>
+ <name>syc</name>
+ <_description>Syriac</_description>
+ </configItem>
+ </variant>
+ <variant>
+ <configItem>
+ <name>syc_phonetic</name>
+ <_description>Syriac phonetic</_description>
+ </configItem>
+ </variant>
+ <variant>
+ <configItem>
+ <name>ku</name>
+ <_description>Kurdish, Latin Q</_description>
+ <languageList><iso639Id>kur</iso639Id></languageList>
+ </configItem>
+ </variant>
+ <variant>
+ <configItem>
+ <name>ku_f</name>
+ <_description>Kurdish, (F)</_description>
+ <languageList><iso639Id>kur</iso639Id></languageList>
+ </configItem>
+ </variant>
+ <variant>
+ <configItem>
+ <name>ku_alt</name>
+ <_description>Kurdish, Latin Alt-Q</_description>
+ <languageList><iso639Id>kur</iso639Id></languageList>
+ </configItem>
+ </variant>
+ </variantList>
+ </layout>
+ <layout>
+ <configItem>
+ <name>tj</name>
+ <_shortDescription>Tjk</_shortDescription>
+ <_description>Tajikistan</_description>
+ <languageList><iso639Id>tgk</iso639Id></languageList>
+ </configItem>
+ <variantList>
+ <variant>
+ <configItem>
+ <name>legacy</name>
+ <_description>Legacy</_description>
+ </configItem>
+ </variant>
+ </variantList>
+ </layout>
+ <layout>
+ <configItem>
+ <name>lk</name>
+ <_shortDescription>Lka</_shortDescription>
+ <_description>Sri Lanka</_description>
+ <languageList><iso639Id>sin</iso639Id></languageList>
+ </configItem>
+ <variantList>
+ <variant>
+ <configItem>
+ <name>tam_unicode</name>
+ <_description>Tamil Unicode</_description>
+ <languageList><iso639Id>tam</iso639Id></languageList>
+ </configItem>
+ </variant>
+ <variant>
+ <configItem>
+ <name>tam_TAB</name>
+ <_description>Tamil TAB Typewriter</_description>
+ <languageList><iso639Id>tam</iso639Id></languageList>
+ </configItem>
+ </variant>
+ </variantList>
+ </layout>
+ <layout>
+ <configItem>
+ <name>th</name>
+ <_shortDescription>Tha</_shortDescription>
+ <_description>Thailand</_description>
+ <languageList><iso639Id>tha</iso639Id></languageList>
+ </configItem>
+ <variantList>
+ <variant>
+ <configItem>
+ <name>tis</name>
+ <_description>TIS-820.2538</_description>
+ </configItem>
+ </variant>
+ <variant>
+ <configItem>
+ <name>pat</name>
+ <_description>Pattachote</_description>
+ </configItem>
+ </variant>
+ </variantList>
+ </layout>
+ <layout>
+ <configItem>
+ <name>tr</name>
+ <_shortDescription>Tur</_shortDescription>
+ <_description>Turkey</_description>
+ <languageList><iso639Id>tur</iso639Id></languageList>
+ </configItem>
+ <variantList>
+ <variant>
+ <configItem>
+ <name>f</name>
+ <_description>(F)</_description>
+ </configItem>
+ </variant>
+ <variant>
+ <configItem>
+ <name>alt</name>
+ <_description>Alt-Q</_description>
+ </configItem>
+ </variant>
+ <variant>
+ <configItem>
+ <name>sundeadkeys</name>
+ <_description>Sun dead keys</_description>
+ </configItem>
+ </variant>
+ <variant>
+ <configItem>
+ <name>ku</name>
+ <_description>Kurdish, Latin Q</_description>
+ <languageList><iso639Id>kur</iso639Id></languageList>
+ </configItem>
+ </variant>
+ <variant>
+ <configItem>
+ <name>ku_f</name>
+ <_description>Kurdish, (F)</_description>
+ <languageList><iso639Id>kur</iso639Id></languageList>
+ </configItem>
+ </variant>
+ <variant>
+ <configItem>
+ <name>ku_alt</name>
+ <_description>Kurdish, Latin Alt-Q</_description>
+ <languageList><iso639Id>kur</iso639Id></languageList>
+ </configItem>
+ </variant>
+ <variant>
+ <configItem>
+ <name>intl</name>
+ <_description>International (with dead keys)</_description>
+ </configItem>
+ </variant>
+ <variant>
+ <configItem>
+ <name>crh</name>
+ <_description>Crimean Tatar (Turkish Q)</_description>
+ <languageList><iso639Id>crh</iso639Id></languageList>
+ </configItem>
+ </variant>
+ <variant>
+ <configItem>
+ <name>crh_f</name>
+ <_description>Crimean Tatar (Turkish F)</_description>
+ <languageList><iso639Id>crh</iso639Id></languageList>
+ </configItem>
+ </variant>
+ <variant>
+ <configItem>
+ <name>crh_alt</name>
+ <_description>Crimean Tatar (Turkish Alt-Q)</_description>
+ <languageList><iso639Id>crh</iso639Id></languageList>
+ </configItem>
+ </variant>
+ </variantList>
+ </layout>
+ <layout>
+ <configItem>
+ <name>ua</name>
+ <_shortDescription>Ukr</_shortDescription>
+ <_description>Ukraine</_description>
+ <languageList><iso639Id>ukr</iso639Id></languageList>
+ </configItem>
+ <variantList>
+ <variant>
+ <configItem>
+ <name>phonetic</name>
+ <_description>Phonetic</_description>
+ </configItem>
+ </variant>
+ <variant>
+ <configItem>
+ <name>typewriter</name>
+ <_description>Typewriter</_description>
+ </configItem>
+ </variant>
+ <variant>
+ <configItem>
+ <name>winkeys</name>
+ <_description>Winkeys</_description>
+ </configItem>
+ </variant>
+ <variant>
+ <configItem>
+ <name>legacy</name>
+ <_description>Legacy</_description>
+ </configItem>
+ </variant>
+ <variant>
+ <configItem>
+ <name>rstu</name>
+<!-- RSTU 2019-91 -->
+ <_description>Standard RSTU</_description>
+ </configItem>
+ </variant>
+ <variant>
+ <configItem>
+ <name>rstu_ru</name>
+<!-- RSTU 2019-91 -->
+ <_description>Standard RSTU on Russian layout</_description>
+ </configItem>
+ </variant>
+ <variant>
+ <configItem>
+ <name>homophonic</name>
+ <_description>Homophonic</_description>
+ </configItem>
+ </variant>
+ <variant>
+ <configItem>
+ <name>crh</name>
+ <_description>Crimean Tatar (Turkish Q)</_description>
+ <languageList><iso639Id>crh</iso639Id></languageList>
+ </configItem>
+ </variant>
+ <variant>
+ <configItem>
+ <name>crh_f</name>
+ <_description>Crimean Tatar (Turkish F)</_description>
+ <languageList><iso639Id>crh</iso639Id></languageList>
+ </configItem>
+ </variant>
+ <variant>
+ <configItem>
+ <name>crh_alt</name>
+ <_description>Crimean Tatar (Turkish Alt-Q)</_description>
+ <languageList><iso639Id>crh</iso639Id></languageList>
+ </configItem>
+ </variant>
+ </variantList>
+ </layout>
+ <layout>
+ <configItem>
+ <name>gb</name>
+ <_shortDescription>GBr</_shortDescription>
+ <_description>United Kingdom</_description>
+ <languageList><iso639Id>eng</iso639Id></languageList>
+ </configItem>
+ <variantList>
+ <variant>
+ <configItem>
+ <name>extd</name>
+ <_description>Extended - Winkeys</_description>
+ </configItem>
+ </variant>
+ <variant>
+ <configItem>
+ <name>intl</name>
+ <_description>International (with dead keys)</_description>
+ </configItem>
+ </variant>
+ <variant>
+ <configItem>
+ <name>dvorak</name>
+ <_description>Dvorak</_description>
+ </configItem>
+ </variant>
+ <variant>
+ <configItem>
+ <name>dvorakukp</name>
+ <_description>Dvorak (UK Punctuation)</_description>
+ </configItem>
+ </variant>
+ <variant>
+ <configItem>
+ <name>mac</name>
+ <_description>Macintosh</_description>
+ </configItem>
+ </variant>
+ <variant>
+ <configItem>
+ <name>mac_intl</name>
+ <_description>Macintosh (International)</_description>
+ </configItem>
+ </variant>
+ <variant>
+ <configItem>
+ <name>colemak</name>
+ <_description>Colemak</_description>
+ </configItem>
+ </variant>
+ </variantList>
+ </layout>
+ <layout>
+ <configItem>
+ <name>uz</name>
+ <_shortDescription>Uzb</_shortDescription>
+ <_description>Uzbekistan</_description>
+ <languageList><iso639Id>uzb</iso639Id></languageList>
+ </configItem>
+ <variantList>
+ <variant>
+ <configItem>
+ <name>latin</name>
+ <_description>Latin</_description>
+ </configItem>
+ </variant>
+ <variant>
+ <configItem>
+ <name>crh</name>
+ <_description>Crimean Tatar (Turkish Q)</_description>
+ <languageList><iso639Id>crh</iso639Id></languageList>
+ </configItem>
+ </variant>
+ <variant>
+ <configItem>
+ <name>crh_f</name>
+ <_description>Crimean Tatar (Turkish F)</_description>
+ <languageList><iso639Id>crh</iso639Id></languageList>
+ </configItem>
+ </variant>
+ <variant>
+ <configItem>
+ <name>crh_alt</name>
+ <_description>Crimean Tatar (Turkish Alt-Q)</_description>
+ <languageList><iso639Id>crh</iso639Id></languageList>
+ </configItem>
+ </variant>
+ </variantList>
+ </layout>
+ <layout>
+ <configItem>
+ <name>vn</name>
+ <_shortDescription>Vnm</_shortDescription>
+ <_description>Vietnam</_description>
+ <languageList><iso639Id>vie</iso639Id></languageList>
+ </configItem>
+ <variantList/>
+ </layout>
+ <layout>
+ <configItem>
+ <name>kr</name>
+ <_shortDescription>Kor</_shortDescription>
+ <_description>Korea, Republic of</_description>
+ <languageList><iso639Id>kor</iso639Id></languageList>
+ </configItem>
+ <variantList>
+ <variant>
+ <configItem>
+ <name>kr104</name>
+ <_description>101/104 key Compatible</_description>
+ </configItem>
+ </variant>
+ </variantList>
+ </layout>
+ <layout>
+ <configItem>
+ <name>nec_vndr/jp</name>
+ <_shortDescription>Jpn</_shortDescription>
+ <_description>Japan (PC-98xx Series)</_description>
+ <countryList><iso3166Id>JP</iso3166Id></countryList>
+ <languageList><iso639Id>jpn</iso639Id></languageList>
+ </configItem>
+ <variantList/>
+ </layout>
+ <layout>
+ <configItem>
+ <name>ie</name>
+ <_shortDescription>Irl</_shortDescription>
+ <_description>Ireland</_description>
+ <languageList><iso639Id>eng</iso639Id></languageList>
+ </configItem>
+ <variantList>
+ <variant>
+ <configItem>
+ <name>CloGaelach</name>
+ <_description>CloGaelach</_description>
+ <languageList><iso639Id>gla</iso639Id></languageList>
+ </configItem>
+ </variant>
+ <variant>
+ <configItem>
+ <name>UnicodeExpert</name>
+ <_description>UnicodeExpert</_description>
+ </configItem>
+ </variant>
+ <variant>
+ <configItem>
+ <name>ogam</name>
+ <_description>Ogham</_description>
+ <!-- No ISO code in ISO639 -->
+ </configItem>
+ </variant>
+ <variant>
+ <configItem>
+ <name>ogam_is434</name>
+ <_description>Ogham IS434</_description>
+ <!-- No ISO code in ISO639 -->
+ </configItem>
+ </variant>
+ </variantList>
+ </layout>
+ <layout>
+ <configItem>
+ <name>pk</name>
+ <_shortDescription>Pak</_shortDescription>
+ <_description>Pakistan</_description>
+ <languageList><iso639Id>urd</iso639Id></languageList>
+ </configItem>
+ <variantList>
+ <variant>
+ <configItem>
+ <name>urd-crulp</name>
+ <_description>CRULP</_description>
+ <languageList><iso639Id>urd</iso639Id></languageList>
+ </configItem>
+ </variant>
+ <variant>
+ <configItem>
+ <name>urd-nla</name>
+ <_description>NLA</_description>
+ <languageList><iso639Id>urd</iso639Id></languageList>
+ </configItem>
+ </variant>
+ <variant>
+ <configItem>
+ <name>ara</name>
+ <_description>Arabic</_description>
+ <languageList><iso639Id>ara</iso639Id></languageList>
+ </configItem>
+ </variant>
+ <variant>
+ <configItem>
+ <name>snd</name>
+ <_description>Sindhi</_description>
+ <languageList><iso639Id>sd</iso639Id></languageList>
+ </configItem>
+ </variant>
+ </variantList>
+ </layout>
+ <layout>
+ <configItem>
+ <name>mv</name>
+ <_shortDescription>Mdv</_shortDescription>
+ <_description>Maldives</_description>
+ <languageList><iso639Id>div</iso639Id></languageList>
+ </configItem>
+ <variantList/>
+ </layout>
+ <layout>
+ <configItem>
+ <name>za</name>
+ <_shortDescription>Zaf</_shortDescription>
+ <_description>South Africa</_description>
+ <languageList><iso639Id>eng</iso639Id></languageList>
+ </configItem>
+ </layout>
+ <layout>
+ <configItem>
+ <name>epo</name>
+ <_shortDescription>Epo</_shortDescription>
+ <_description>Esperanto</_description>
+ <languageList><iso639Id>epo</iso639Id></languageList>
+ </configItem>
+ <variantList>
+ <variant>
+ <configItem>
+ <name>legacy</name>
+ <_description>displaced semicolon and quote (obsolete)</_description>
+ </configItem>
+ </variant>
+ </variantList>
+ </layout>
+ <layout>
+ <configItem>
+ <name>np</name>
+ <_shortDescription>Npl</_shortDescription>
+ <_description>Nepal</_description>
+ <languageList><iso639Id>nep</iso639Id></languageList>
+ </configItem>
+ </layout>
+ <layout>
+ <configItem>
+ <name>ng</name>
+ <_shortDescription>Nga</_shortDescription>
+ <_description>Nigeria</_description>
+ <languageList><iso639Id>eng</iso639Id></languageList>
+ </configItem>
+ <variantList>
+ <variant>
+ <configItem>
+ <name>igbo</name>
+ <_description>Igbo</_description>
+ <languageList><iso639Id>ibo</iso639Id></languageList>
+ </configItem>
+ </variant>
+ <variant>
+ <configItem>
+ <name>yoruba</name>
+ <_description>Yoruba</_description>
+ <languageList><iso639Id>yor</iso639Id></languageList>
+ </configItem>
+ </variant>
+ <variant>
+ <configItem>
+ <name>hausa</name>
+ <_description>Hausa</_description>
+ <languageList><iso639Id>hau</iso639Id></languageList>
+ </configItem>
+ </variant>
+ </variantList>
+ </layout>
+ <layout>
+ <configItem>
+ <name>et</name>
+ <_shortDescription>Eth</_shortDescription>
+ <_description>Ethiopia</_description>
+ <languageList><iso639Id>amh</iso639Id></languageList>
+ </configItem>
+ <variantList/>
+ </layout>
+ <layout>
+ <configItem>
+ <name>sn</name>
+ <_shortDescription>Sen</_shortDescription>
+ <_description>Senegal</_description>
+ <languageList><iso639Id>wol</iso639Id></languageList>
+ </configItem>
+ <variantList/>
+ </layout>
+ <layout>
+ <configItem>
+ <name>brai</name>
+ <_shortDescription>Brl</_shortDescription>
+ <_description>Braille</_description>
+ </configItem>
+ <variantList>
+ <variant>
+ <configItem>
+ <name>left_hand</name>
+ <_description>Left hand</_description>
+ </configItem>
+ </variant>
+ <variant>
+ <configItem>
+ <name>right_hand</name>
+ <_description>Right hand</_description>
+ </configItem>
+ </variant>
+ </variantList>
+ </layout>
+ <layout>
+ <configItem>
+ <name>tm</name>
+ <_shortDescription>Tkm</_shortDescription>
+ <_description>Turkmenistan</_description>
+ <languageList><iso639Id>tuk</iso639Id></languageList>
+ </configItem>
+ <variantList>
+ <variant>
+ <configItem>
+ <name>alt</name>
+ <_description>Alt-Q</_description>
+ </configItem>
+ </variant>
+ </variantList>
+ </layout>
+ <layout>
+ <configItem>
+ <name>ml</name>
+ <_shortDescription>Mli</_shortDescription>
+ <_description>Mali</_description>
+ <languageList><iso639Id>bam</iso639Id></languageList>
+ </configItem>
+ <variantList>
+ <variant>
+ <configItem>
+ <name>fr-oss</name>
+ <_description>Français (France Alternative)</_description>
+ </configItem>
+ </variant>
+ <variant>
+ <configItem>
+ <name>us-mac</name>
+ <_description>English (USA Macintosh)</_description>
+ </configItem>
+ </variant>
+ <variant>
+ <configItem>
+ <name>us-intl</name>
+ <_description>English (USA International)</_description>
+ </configItem>
+ </variant>
+ </variantList>
+ </layout>
+ <layout>
+ <configItem>
+ <name>tz</name>
+ <_shortDescription>Tza</_shortDescription>
+ <_description>Tanzania</_description>
+ <languageList><iso639Id>swa</iso639Id></languageList>
+ </configItem>
+ </layout>
+ <layout>
+ <configItem>
+ <name>ke</name>
+ <_shortDescription>Ken</_shortDescription>
+ <_description>Kenya</_description>
+ <languageList><iso639Id>swa</iso639Id></languageList>
+ </configItem>
+ <variantList>
+ <variant>
+ <configItem>
+ <name>kik</name>
+ <_description>Kikuyu</_description>
+ <languageList><iso639Id>kik</iso639Id></languageList>
+ </configItem>
+ </variant>
+ </variantList>
+ </layout>
+ <layout>
+ <configItem>
+ <name>bw</name>
+ <_shortDescription>Bwa</_shortDescription>
+ <_description>Botswana</_description>
+ <languageList><iso639Id>tsn</iso639Id></languageList>
+ </configItem>
+ </layout>
+ <layout>
+ <configItem>
+ <name>ph</name>
+ <_shortDescription>Phi</_shortDescription>
+ <_description>Philippines</_description>
+ <languageList><iso639Id>eng</iso639Id>
+ <iso639Id>bik</iso639Id>
+ <iso639Id>ceb</iso639Id>
+ <iso639Id>fil</iso639Id>
+ <iso639Id>hil</iso639Id>
+ <iso639Id>ilo</iso639Id>
+ <iso639Id>pam</iso639Id>
+ <iso639Id>pag</iso639Id>
+ <iso639Id>phi</iso639Id>
+ <iso639Id>tgl</iso639Id>
+ <iso639Id>war</iso639Id></languageList>
+ </configItem>
+ <variantList>
+ <variant>
+ <configItem>
+ <name>qwerty-bay</name>
+ <_description>QWERTY (Baybayin)</_description>
+ <languageList><iso639Id>bik</iso639Id>
+ <iso639Id>ceb</iso639Id>
+ <iso639Id>fil</iso639Id>
+ <iso639Id>hil</iso639Id>
+ <iso639Id>ilo</iso639Id>
+ <iso639Id>pam</iso639Id>
+ <iso639Id>pag</iso639Id>
+ <iso639Id>phi</iso639Id>
+ <iso639Id>tgl</iso639Id>
+ <iso639Id>war</iso639Id></languageList>
+ </configItem>
+ </variant>
+ <variant>
+ <configItem>
+ <name>capewell-dvorak</name>
+ <_description>Capewell-Dvorak (Latin)</_description>
+ </configItem>
+ </variant>
+ <variant>
+ <configItem>
+ <name>capewell-dvorak-bay</name>
+ <_description>Capewell-Dvorak (Baybayin)</_description>
+ <languageList><iso639Id>bik</iso639Id>
+ <iso639Id>ceb</iso639Id>
+ <iso639Id>fil</iso639Id>
+ <iso639Id>hil</iso639Id>
+ <iso639Id>ilo</iso639Id>
+ <iso639Id>pam</iso639Id>
+ <iso639Id>pag</iso639Id>
+ <iso639Id>phi</iso639Id>
+ <iso639Id>tgl</iso639Id>
+ <iso639Id>war</iso639Id></languageList>
+ </configItem>
+ </variant>
+ <variant>
+ <configItem>
+ <name>capewell-qwerf2k6</name>
+ <_description>Capewell-QWERF 2006 (Latin)</_description>
+ </configItem>
+ </variant>
+ <variant>
+ <configItem>
+ <name>capewell-qwerf2k6-bay</name>
+ <_description>Capewell-QWERF 2006 (Baybayin)</_description>
+ <languageList><iso639Id>bik</iso639Id>
+ <iso639Id>ceb</iso639Id>
+ <iso639Id>fil</iso639Id>
+ <iso639Id>hil</iso639Id>
+ <iso639Id>ilo</iso639Id>
+ <iso639Id>pam</iso639Id>
+ <iso639Id>pag</iso639Id>
+ <iso639Id>phi</iso639Id>
+ <iso639Id>tgl</iso639Id>
+ <iso639Id>war</iso639Id></languageList>
+ </configItem>
+ </variant>
+ <variant>
+ <configItem>
+ <name>colemak</name>
+ <_description>Colemak (Latin)</_description>
+ </configItem>
+ </variant>
+ <variant>
+ <configItem>
+ <name>colemak-bay</name>
+ <_description>Colemak (Baybayin)</_description>
+ <languageList><iso639Id>bik</iso639Id>
+ <iso639Id>ceb</iso639Id>
+ <iso639Id>fil</iso639Id>
+ <iso639Id>hil</iso639Id>
+ <iso639Id>ilo</iso639Id>
+ <iso639Id>pam</iso639Id>
+ <iso639Id>pag</iso639Id>
+ <iso639Id>phi</iso639Id>
+ <iso639Id>tgl</iso639Id>
+ <iso639Id>war</iso639Id></languageList>
+ </configItem>
+ </variant>
+ <variant>
+ <configItem>
+ <name>dvorak</name>
+ <_description>Dvorak (Latin)</_description>
+ </configItem>
+ </variant>
+ <variant>
+ <configItem>
+ <name>dvorak-bay</name>
+ <_description>Dvorak (Baybayin)</_description>
+ <languageList><iso639Id>bik</iso639Id>
+ <iso639Id>ceb</iso639Id>
+ <iso639Id>fil</iso639Id>
+ <iso639Id>hil</iso639Id>
+ <iso639Id>ilo</iso639Id>
+ <iso639Id>pam</iso639Id>
+ <iso639Id>pag</iso639Id>
+ <iso639Id>phi</iso639Id>
+ <iso639Id>tgl</iso639Id>
+ <iso639Id>war</iso639Id></languageList>
+ </configItem>
+ </variant>
+ </variantList>
+ </layout>
+ </layoutList>
+ <optionList>
+ <group allowMultipleSelection="true">
+ <!-- The key combination used to switch between groups -->
+ <configItem>
+ <name>grp</name>
+ <_description>Key(s) to change layout</_description>
+ </configItem>
+ <option>
+ <configItem>
+ <name>grp:switch</name>
+ <_description>Right Alt (while pressed)</_description>
+ </configItem>
+ </option>
+ <option>
+ <configItem>
+ <name>grp:lswitch</name>
+ <_description>Left Alt (while pressed)</_description>
+ </configItem>
+ </option>
+ <option>
+ <configItem>
+ <name>grp:lwin_switch</name>
+ <_description>Left Win (while pressed)</_description>
+ </configItem>
+ </option>
+ <option>
+ <configItem>
+ <name>grp:rwin_switch</name>
+ <_description>Right Win (while pressed)</_description>
+ </configItem>
+ </option>
+ <option>
+ <configItem>
+ <name>grp:win_switch</name>
+ <_description>Any Win key (while pressed)</_description>
+ </configItem>
+ </option>
+ <option>
+ <configItem>
+ <name>grp:caps_switch</name>
+ <_description>Caps Lock (while pressed), Alt+Caps Lock does the original capslock action</_description>
+ </configItem>
+ </option>
+ <option>
+ <configItem>
+ <name>grp:rctrl_switch</name>
+ <_description>Right Ctrl (while pressed)</_description>
+ </configItem>
+ </option>
+ <option>
+ <configItem>
+ <name>grp:toggle</name>
+ <_description>Right Alt</_description>
+ </configItem>
+ </option>
+ <option>
+ <configItem>
+ <name>grp:lalt_toggle</name>
+ <_description>Left Alt</_description>
+ </configItem>
+ </option>
+ <option>
+ <configItem>
+ <name>grp:caps_toggle</name>
+ <_description>Caps Lock</_description>
+ </configItem>
+ </option>
+ <option>
+ <configItem>
+ <name>grp:shift_caps_toggle</name>
+ <_description>Shift+Caps Lock</_description>
+ </configItem>
+ </option>
+ <option>
+ <configItem>
+ <name>grp:shift_caps_switch</name>
+ <_description>Caps Lock (to first layout), Shift+Caps Lock (to last layout)</_description>
+ </configItem>
+ </option>
+ <option>
+ <configItem>
+ <name>grp:win_menu_switch</name>
+ <_description>Left Win (to first layout), Right Win/Menu (to last layout)</_description>
+ </configItem>
+ </option>
+ <option>
+ <configItem>
+ <name>grp:lctrl_rctrl_switch</name>
+ <_description>Left Ctrl (to first layout), Right Ctrl (to last layout)</_description>
+ </configItem>
+ </option>
+ <option>
+ <configItem>
+ <name>grp:alt_caps_toggle</name>
+ <_description>Alt+Caps Lock</_description>
+ </configItem>
+ </option>
+ <option>
+ <configItem>
+ <name>grp:shifts_toggle</name>
+ <_description>Both Shift keys together</_description>
+ </configItem>
+ </option>
+ <option>
+ <configItem>
+ <name>grp:alts_toggle</name>
+ <_description>Both Alt keys together</_description>
+ </configItem>
+ </option>
+ <option>
+ <configItem>
+ <name>grp:ctrls_toggle</name>
+ <_description>Both Ctrl keys together</_description>
+ </configItem>
+ </option>
+ <option>
+ <configItem>
+ <name>grp:ctrl_shift_toggle</name>
+ <_description>Ctrl+Shift</_description>
+ </configItem>
+ </option>
+ <option>
+ <configItem>
+ <name>grp:lctrl_lshift_toggle</name>
+ <_description>Left Ctrl+Left Shift</_description>
+ </configItem>
+ </option>
+ <option>
+ <configItem>
+ <name>grp:rctrl_rshift_toggle</name>
+ <_description>Right Ctrl+Right Shift</_description>
+ </configItem>
+ </option>
+ <option>
+ <configItem>
+ <name>grp:ctrl_alt_toggle</name>
+ <_description>Alt+Ctrl</_description>
+ </configItem>
+ </option>
+ <option>
+ <configItem>
+ <name>grp:alt_shift_toggle</name>
+ <_description>Alt+Shift</_description>
+ </configItem>
+ </option>
+ <option>
+ <configItem>
+ <name>grp:alt_space_toggle</name>
+ <_description>Alt+Space</_description>
+ </configItem>
+ </option>
+ <option>
+ <configItem>
+ <name>grp:menu_toggle</name>
+ <_description>Menu</_description>
+ </configItem>
+ </option>
+ <option>
+ <configItem>
+ <name>grp:lwin_toggle</name>
+ <_description>Left Win</_description>
+ </configItem>
+ </option>
+ <option>
+ <configItem>
+ <name>grp:rwin_toggle</name>
+ <_description>Right Win</_description>
+ </configItem>
+ </option>
+ <option>
+ <configItem>
+ <name>grp:lshift_toggle</name>
+ <_description>Left Shift</_description>
+ </configItem>
+ </option>
+ <option>
+ <configItem>
+ <name>grp:rshift_toggle</name>
+ <_description>Right Shift</_description>
+ </configItem>
+ </option>
+ <option>
+ <configItem>
+ <name>grp:lctrl_toggle</name>
+ <_description>Left Ctrl</_description>
+ </configItem>
+ </option>
+ <option>
+ <configItem>
+ <name>grp:rctrl_toggle</name>
+ <_description>Right Ctrl</_description>
+ </configItem>
+ </option>
+ <option>
+ <configItem>
+ <name>grp:sclk_toggle</name>
+ <_description>Scroll Lock</_description>
+ </configItem>
+ </option>
+ </group>
+ <group allowMultipleSelection="true">
+ <!-- The key combination used to choose the 3rd (and 4th, together with Shift)
+ level of symbols -->
+ <configItem>
+ <name>lv3</name>
+ <_description>Key to choose 3rd level</_description>
+ </configItem>
+ <option>
+ <configItem>
+ <name>lv3:switch</name>
+ <_description>Right Ctrl</_description>
+ </configItem>
+ </option>
+ <option>
+ <configItem>
+ <name>lv3:menu_switch</name>
+ <_description>Menu</_description>
+ </configItem>
+ </option>
+ <option>
+ <configItem>
+ <name>lv3:win_switch</name>
+ <_description>Any Win key</_description>
+ </configItem>
+ </option>
+ <option>
+ <configItem>
+ <name>lv3:lwin_switch</name>
+ <_description>Left Win</_description>
+ </configItem>
+ </option>
+ <option>
+ <configItem>
+ <name>lv3:rwin_switch</name>
+ <_description>Right Win</_description>
+ </configItem>
+ </option>
+ <option>
+ <configItem>
+ <name>lv3:alt_switch</name>
+ <_description>Any Alt key</_description>
+ </configItem>
+ </option>
+ <option>
+ <configItem>
+ <name>lv3:lalt_switch</name>
+ <_description>Left Alt</_description>
+ </configItem>
+ </option>
+ <option>
+ <configItem>
+ <name>lv3:ralt_switch</name>
+ <_description>Right Alt</_description>
+ </configItem>
+ </option>
+ <option>
+ <configItem>
+ <name>lv3:ralt_switch_multikey</name>
+ <_description>Right Alt, Shift+Right Alt key is Multi_Key</_description>
+ </configItem>
+ </option>
+ <option>
+ <configItem>
+ <name>lv3:ralt_alt</name>
+ <_description>Right Alt key never chooses 3rd level</_description>
+ </configItem>
+ </option>
+ <option>
+ <configItem>
+ <name>lv3:enter_switch</name>
+ <_description>Enter on keypad</_description>
+ </configItem>
+ </option>
+ <option>
+ <configItem>
+ <name>lv3:caps_switch</name>
+ <_description>Caps Lock</_description>
+ </configItem>
+ </option>
+ <option>
+ <configItem>
+ <name>lv3:bksl_switch</name>
+ <_description>Backslash</_description>
+ </configItem>
+ </option>
+ <option>
+ <configItem>
+ <name>lv3:lsgt_switch</name>
+ <description>&lt;Less/Greater&gt;</description>
+ </configItem>
+ </option>
+ <option>
+ <configItem>
+ <name>lv3:caps_switch_latch</name>
+ <description>Caps Lock (chooses 3rd level, latches when pressed together with another 3rd-level-chooser)</description>
+ </configItem>
+ </option>
+ <option>
+ <configItem>
+ <name>lv3:bksl_switch_latch</name>
+ <description>Backslash chooses 3rd level, latches when pressed together with another 3rd-level-chooser)</description>
+ </configItem>
+ </option>
+ <option>
+ <configItem>
+ <name>lv3:lsgt_switch_latch</name>
+ <description>&lt;Less/Greater&gt; (chooses 3rd level, latches when pressed together with another 3rd-level-chooser)</description>
+ </configItem>
+ </option>
+ </group>
+ <group allowMultipleSelection="true">
+ <!-- Tweaking the position of the "Ctrl" key -->
+ <configItem>
+ <name>ctrl</name>
+ <_description>Ctrl key position</_description>
+ </configItem>
+ <option>
+ <configItem>
+ <name>ctrl:nocaps</name>
+ <_description>Make Caps Lock an additional Ctrl</_description>
+ </configItem>
+ </option>
+ <option>
+ <configItem>
+ <name>ctrl:lctrl_meta</name>
+ <_description>Meta on Left Ctrl</_description>
+ </configItem>
+ </option>
+ <option>
+ <configItem>
+ <name>ctrl:swapcaps</name>
+ <_description>Swap Ctrl and Caps Lock</_description>
+ </configItem>
+ </option>
+ <option>
+ <configItem>
+ <name>ctrl:ctrl_ac</name>
+ <_description>At left of 'A'</_description>
+ </configItem>
+ </option>
+ <option>
+ <configItem>
+ <name>ctrl:ctrl_aa</name>
+ <_description>At bottom left</_description>
+ </configItem>
+ </option>
+ <option>
+ <configItem>
+ <name>ctrl:ctrl_ra</name>
+ <_description>Right Ctrl as Right Alt</_description>
+ </configItem>
+ </option>
+ <option>
+ <configItem>
+ <name>ctrl:ctrl_menu</name>
+ <description>Right Ctrl is mapped to Menu</description>
+ </configItem>
+ </option>
+ </group>
+ <group allowMultipleSelection="true">
+ <!-- Using startard LEDs to indicate the alternative (not first) group(s) -->
+ <configItem>
+ <name>grp_led</name>
+ <_description>Use keyboard LED to show alternative layout</_description>
+ </configItem>
+ <option>
+ <configItem>
+ <name>grp_led:num</name>
+ <_description>Num Lock</_description>
+ </configItem>
+ </option>
+ <option>
+ <configItem>
+ <name>grp_led:caps</name>
+ <_description>Caps Lock</_description>
+ </configItem>
+ </option>
+ <option>
+ <configItem>
+ <name>grp_led:scroll</name>
+ <_description>Scroll Lock</_description>
+ </configItem>
+ </option>
+ </group>
+ <group allowMultipleSelection="false">
+ <!-- Select a keypad type -->
+ <configItem>
+ <name>keypad</name>
+ <_description>Numeric keypad layout selection</_description>
+ </configItem>
+ <option>
+ <configItem>
+ <name>keypad:legacy</name>
+ <_description>Legacy</_description>
+ </configItem>
+ </option>
+ <option>
+ <configItem>
+ <name>keypad:oss</name>
+ <_description>Unicode additions (arrows and math operators)</_description>
+ </configItem>
+ </option>
+ <option>
+ <configItem>
+ <name>keypad:future</name>
+ <_description>Unicode additions (arrows and math operators). Math operators on default level</_description>
+ </configItem>
+ </option>
+ <option>
+ <configItem>
+ <name>keypad:legacy_wang</name>
+ <_description>Legacy Wang 724</_description>
+ </configItem>
+ </option>
+ <option>
+ <configItem>
+ <name>keypad:oss_wang</name>
+ <_description>Wang 724 keypad with unicode additions (arrows and math operators)</_description>
+ </configItem>
+ </option>
+ <option>
+ <configItem>
+ <name>keypad:future_wang</name>
+ <_description>Wang 724 keypad with unicode additions (arrows and math operators). Math operators on default level</_description>
+ </configItem>
+ </option>
+ <option>
+ <configItem>
+ <name>keypad:hex</name>
+ <_description>Hexadecimal</_description>
+ </configItem>
+ </option>
+ <option>
+ <configItem>
+ <name>keypad:atm</name>
+ <_description>ATM/phone-style</_description>
+ </configItem>
+ </option>
+ </group>
+ <!-- This option should override the KPDL key defined in keypad; I hope it's declared in the right place -->
+ <group allowMultipleSelection="false">
+ <!-- Select a keypad KPDL variant -->
+ <configItem>
+ <name>kpdl</name>
+ <_description>Numeric keypad delete key behaviour</_description>
+ </configItem>
+ <option>
+ <configItem>
+ <!-- Actually, with KP_DECIMAL, as the old keypad(dot) -->
+ <name>kpdl:dot</name>
+ <_description>Legacy key with dot</_description>
+ </configItem>
+ </option>
+ <option>
+ <configItem>
+ <name>kpdl:comma</name>
+ <!-- Actually, with KP_SEPARATOR, as the old keypad(comma) -->
+ <_description>Legacy key with comma</_description>
+ </configItem>
+ </option>
+ <option>
+ <configItem>
+ <name>kpdl:dotoss</name>
+ <_description>Four-level key with dot</_description>
+ </configItem>
+ </option>
+ <option>
+ <configItem>
+ <name>kpdl:dotoss_latin9</name>
+ <_description>Four-level key with dot, latin-9 restriction</_description>
+ </configItem>
+ </option>
+ <option>
+ <configItem>
+ <name>kpdl:commaoss</name>
+ <_description>Four-level key with comma</_description>
+ </configItem>
+ </option>
+ <option>
+ <configItem>
+ <name>kpdl:momayyezoss</name>
+ <_description>Four-level key with momayyez</_description>
+ </configItem>
+ </option>
+ <option>
+ <configItem>
+ <name>kpdl:kposs</name>
+ <!-- This assumes the KP_ abstract symbols are actually useful for some apps
+ The description needs to be rewritten -->
+ <_description>Four-level key with abstract separators</_description>
+ </configItem>
+ </option>
+ <option>
+ <configItem>
+ <name>kpdl:semi</name>
+ <_description>Semi-colon on third level</_description>
+ </configItem>
+ </option>
+ </group>
+ <group allowMultipleSelection="false">
+ <!-- Caps Lock tweaks.
+ "Internal" capitalization means capitalization using some internal tables.
+ Otherwise "as Shift" - means using next group. -->
+ <configItem>
+ <name>caps</name>
+ <_description>Caps Lock key behavior</_description>
+ </configItem>
+ <option>
+ <configItem>
+ <name>caps:internal</name>
+ <_description>Caps Lock uses internal capitalization. Shift "pauses" Caps Lock</_description>
+ </configItem>
+ </option>
+ <option>
+ <configItem>
+ <name>caps:internal_nocancel</name>
+ <_description>Caps Lock uses internal capitalization. Shift doesn't affect Caps Lock</_description>
+ </configItem>
+ </option>
+ <option>
+ <configItem>
+ <name>caps:shift</name>
+ <_description>Caps Lock acts as Shift with locking. Shift "pauses" Caps Lock</_description>
+ </configItem>
+ </option>
+ <option>
+ <configItem>
+ <name>caps:shift_nocancel</name>
+ <_description>Caps Lock acts as Shift with locking. Shift doesn't affect Caps Lock</_description>
+ </configItem>
+ </option>
+ <option>
+ <configItem>
+ <name>caps:capslock</name>
+ <_description>Caps Lock toggles normal capitalization of alphabetic characters</_description>
+ </configItem>
+ </option>
+ <option>
+ <configItem>
+ <name>caps:numlock</name>
+ <_description>Make Caps Lock an additional Num Lock</_description>
+ </configItem>
+ </option>
+ <option>
+ <configItem>
+ <name>caps:swapescape</name>
+ <_description>Swap ESC and Caps Lock</_description>
+ </configItem>
+ </option>
+ <option>
+ <configItem>
+ <name>caps:escape</name>
+ <_description>Make Caps Lock an additional ESC</_description>
+ </configItem>
+ </option>
+ <option>
+ <configItem>
+ <name>caps:backspace</name>
+ <_description>Make Caps Lock an additional Backspace</_description>
+ </configItem>
+ </option>
+ <option>
+ <configItem>
+ <name>caps:super</name>
+ <_description>Make Caps Lock an additional Super</_description>
+ </configItem>
+ </option>
+ <option>
+ <configItem>
+ <name>caps:hyper</name>
+ <_description>Make Caps Lock an additional Hyper</_description>
+ </configItem>
+ </option>
+ <option>
+ <configItem>
+ <name>caps:shiftlock</name>
+ <_description>Caps Lock toggles Shift so all keys are affected</_description>
+ </configItem>
+ </option>
+ <option>
+ <configItem>
+ <name>caps:none</name>
+ <_description>Caps Lock is disabled</_description>
+ </configItem>
+ </option>
+ </group>
+ <group allowMultipleSelection="false">
+ <!-- Using special PC keys (Win, Menu) to work as standard X keys (Super, Hyper, etc.) -->
+ <configItem>
+ <name>altwin</name>
+ <_description>Alt/Win key behavior</_description>
+ </configItem>
+ <option>
+ <configItem>
+ <name>altwin:menu</name>
+ <_description>Add the standard behavior to Menu key</_description>
+ </configItem>
+ </option>
+ <option>
+ <configItem>
+ <name>altwin:meta_alt</name>
+ <_description>Alt and Meta are on Alt keys</_description>
+ </configItem>
+ </option>
+ <option>
+ <configItem>
+ <name>altwin:ctrl_win</name>
+ <_description>Control is mapped to Win keys (and the usual Ctrl keys)</_description>
+ </configItem>
+ </option>
+ <option>
+ <configItem>
+ <name>altwin:ctrl_alt_win</name>
+ <_description>Control is mapped to Alt keys, Alt is mapped to Win keys</_description>
+ </configItem>
+ </option>
+ <option>
+ <configItem>
+ <name>altwin:meta_win</name>
+ <_description>Meta is mapped to Win keys</_description>
+ </configItem>
+ </option>
+ <option>
+ <configItem>
+ <name>altwin:left_meta_win</name>
+ <_description>Meta is mapped to Left Win</_description>
+ </configItem>
+ </option>
+ <option>
+ <configItem>
+ <name>altwin:hyper_win</name>
+ <_description>Hyper is mapped to Win-keys</_description>
+ </configItem>
+ </option>
+ <option>
+ <configItem>
+ <name>altwin:alt_super_win</name>
+ <_description>Alt is mapped to Right Win, Super to Menu</_description>
+ </configItem>
+ </option>
+ <option>
+ <configItem>
+ <name>altwin:swap_lalt_lwin</name>
+ <_description>Left Alt is swapped with Left Win</_description>
+ </configItem>
+ </option>
+ </group>
+ <group allowMultipleSelection="true">
+ <!-- Tweaking the position of the "Compose" key: mapping to existing PC keys -->
+ <configItem>
+ <name>Compose key</name>
+ <_description>Compose key position</_description>
+ </configItem>
+ <option>
+ <configItem>
+ <name>compose:ralt</name>
+ <_description>Right Alt</_description>
+ </configItem>
+ </option>
+ <option>
+ <configItem>
+ <name>compose:lwin</name>
+ <_description>Left Win</_description>
+ </configItem>
+ </option>
+ <option>
+ <configItem>
+ <name>compose:rwin</name>
+ <_description>Right Win</_description>
+ </configItem>
+ </option>
+ <option>
+ <configItem>
+ <name>compose:menu</name>
+ <_description>Menu</_description>
+ </configItem>
+ </option>
+ <option>
+ <configItem>
+ <name>compose:lctrl</name>
+ <_description>Left Ctrl</_description>
+ </configItem>
+ </option>
+ <option>
+ <configItem>
+ <name>compose:rctrl</name>
+ <_description>Right Ctrl</_description>
+ </configItem>
+ </option>
+ <option>
+ <configItem>
+ <name>compose:caps</name>
+ <_description>Caps Lock</_description>
+ </configItem>
+ </option>
+ <option>
+ <configItem>
+ <name>compose:102</name>
+ <_description>&lt;Less/Greater&gt;</_description>
+ </configItem>
+ </option>
+ <option>
+ <configItem>
+ <name>compose:paus</name>
+ <_description>Pause</_description>
+ </configItem>
+ </option>
+ <option>
+ <configItem>
+ <name>compose:prsc</name>
+ <_description>PrtSc</_description>
+ </configItem>
+ </option>
+ <option>
+ <configItem>
+ <name>compose:sclk</name>
+ <_description>Scroll Lock</_description>
+ </configItem>
+ </option>
+ </group>
+ <group allowMultipleSelection="true">
+ <configItem>
+ <name>compat</name>
+ <_description>Miscellaneous compatibility options</_description>
+ </configItem>
+ <option>
+ <configItem>
+ <name>numpad:pc</name>
+ <_description>Default numeric keypad keys</_description>
+ </configItem>
+ </option>
+ <option>
+ <configItem>
+ <name>numpad:mac</name>
+ <_description>Numeric keypad keys work as with Mac</_description>
+ </configItem>
+ </option>
+ <option>
+ <configItem>
+ <name>numpad:microsoft</name>
+ <_description>Shift with numeric keypad keys works as in MS Windows</_description>
+ </configItem>
+ </option>
+ <option>
+ <configItem>
+ <name>numpad:shift3</name>
+ <_description>Shift does not cancel Num Lock, chooses 3rd level instead</_description>
+ </configItem>
+ </option>
+ <option>
+ <configItem>
+ <name>srvrkeys:none</name>
+ <_description>Special keys (Ctrl+Alt+&lt;key&gt;) handled in a server</_description>
+ </configItem>
+ </option>
+ <option>
+ <configItem>
+ <name>apple:alupckeys</name>
+ <_description>Apple Aluminium Keyboard: emulate PC keys (Print, Scroll Lock, Pause, Num Lock)</_description>
+ </configItem>
+ </option>
+ <option>
+ <configItem>
+ <name>shift:breaks_caps</name>
+ <_description>Shift cancels Caps Lock</_description>
+ </configItem>
+ </option>
+ <option>
+ <configItem>
+ <name>misc:typo</name>
+ <_description>Enable extra typographic characters</_description>
+ </configItem>
+ </option>
+ <option>
+ <configItem>
+ <name>shift:both_capslock</name>
+ <_description>Both Shift-Keys together toggle Caps Lock</_description>
+ </configItem>
+ </option>
+ <option>
+ <configItem>
+ <name>shift:both_capslock_cancel</name>
+ <description>Both Shift-Keys together activate Caps Lock, one Shift-Key deactivates</description>
+ </configItem>
+ </option>
+ <option>
+ <configItem>
+ <name>shift:both_shiftlock</name>
+ <description>Both Shift-Keys together toggle ShiftLock</description>
+ </configItem>
+ </option>
+ <option>
+ <configItem>
+ <name>keypad:pointerkeys</name>
+ <_description>Toggle PointerKeys with Shift + NumLock.</_description>
+ </configItem>
+ </option>
+ </group>
+ <group allowMultipleSelection="true">
+ <!-- Special shortcuts for the Euro character -->
+ <configItem>
+ <name>eurosign</name>
+ <_description>Adding currency signs to certain keys</_description>
+ </configItem>
+ <option>
+ <configItem>
+ <name>eurosign:e</name>
+ <_description>Euro on E</_description>
+ </configItem>
+ </option>
+ <option>
+ <configItem>
+ <name>eurosign:2</name>
+ <_description>Euro on 2</_description>
+ </configItem>
+ </option>
+ <option>
+ <configItem>
+ <name>eurosign:4</name>
+ <_description>Euro on 4</_description>
+ </configItem>
+ </option>
+ <option>
+ <configItem>
+ <name>eurosign:5</name>
+ <_description>Euro on 5</_description>
+ </configItem>
+ </option>
+ <option>
+ <configItem>
+ <name>rupeesign:4</name>
+ <_description>Rupee on 4</_description>
+ </configItem>
+ </option>
+ </group>
+ <group allowMultipleSelection="true">
+ <configItem>
+ <name>lv5</name>
+ <_description>Key to choose 5th level</_description>
+ </configItem>
+ <option>
+ <configItem>
+ <name>lv5:lsgt_switch_lock</name>
+ <_description>&lt;Less/Greater&gt; chooses 5th level, locks when pressed together with another 5th-level-chooser</_description>
+ </configItem>
+ </option>
+ <option>
+ <configItem>
+ <name>lv5:ralt_switch_lock</name>
+ <_description>Right Alt chooses 5th level, locks when pressed together with another 5th-level-chooser</_description>
+ </configItem>
+ </option>
+ <option>
+ <configItem>
+ <name>lv5:lwin_switch_lock</name>
+ <_description>Left Win chooses 5th level, locks when pressed together with another 5th-level-chooser</_description>
+ </configItem>
+ </option>
+ <option>
+ <configItem>
+ <name>lv5:rwin_switch_lock</name>
+ <_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>
+ <_description>&lt;Less/Greater&gt; chooses 5th level, locks when pressed together with another 5th-level-chooser, one press releases the lock</_description>
+ </configItem>
+ </option>
+ <option>
+ <configItem>
+ <name>lv5:ralt_switch_lock_cancel</name>
+ <_description>Right Alt chooses 5th level, locks when pressed together with another 5th-level-chooser, one press releases the lock</_description>
+ </configItem>
+ </option>
+ <option>
+ <configItem>
+ <name>lv5:lwin_switch_lock_cancel</name>
+ <_description>Left Win chooses 5th level, locks when pressed together with another 5th-level-chooser, one press releases the lock</_description>
+ </configItem>
+ </option>
+ <option>
+ <configItem>
+ <name>lv5:rwin_switch_lock_cancel</name>
+ <_description>Right Win chooses 5th level, locks when pressed together with another 5th-level-chooser, one press releases the lock</_description>
+ </configItem>
+ </option>
+ <option>
+ <configItem>
+ <name>lv5:lsgt_switch_lock_cancel</name>
+ <description>&lt;Less/Greater&gt; chooses 5th level and activates level5-Lock when pressed together with another 5th-level-chooser, one press releases the lock</description>
+ </configItem>
+ </option>
+ <option>
+ <configItem>
+ <name>lv5:ralt_switch_lock_cancel</name>
+ <description>Right Alt chooses 5th level and activates level5-Lock when pressed together with another 5th-level-chooser, one press releases the lock</description>
+ </configItem>
+ </option>
+ </group>
+ <group allowMultipleSelection="false">
+ <!-- Let space output NBSP, NNBSP, ZWNJ, and ZWJ for the desired level -->
+ <configItem>
+ <name>nbsp</name>
+ <_description>Using space key to input non-breakable space character</_description>
+ </configItem>
+ <option>
+ <configItem>
+ <name>nbsp:none</name>
+ <_description>Usual space at any level</_description>
+ </configItem>
+ </option>
+ <option>
+ <configItem>
+ <name>nbsp:level2</name>
+ <_description>Non-breakable space character at second level</_description>
+ </configItem>
+ </option>
+ <option>
+ <configItem>
+ <name>nbsp:level3</name>
+ <_description>Non-breakable space character at third level</_description>
+ </configItem>
+ </option>
+ <option>
+ <configItem>
+ <name>nbsp:level3s</name>
+ <_description>Non-breakable space character at third level, nothing at fourth level</_description>
+ </configItem>
+ </option>
+ <option>
+ <configItem>
+ <name>nbsp:level3n</name>
+ <_description>Non-breakable space character at third level, thin non-breakable space character at fourth level</_description>
+ </configItem>
+ </option>
+ <option>
+ <configItem>
+ <name>nbsp:level4</name>
+ <_description>Non-breakable space character at fourth level</_description>
+ </configItem>
+ </option>
+ <option>
+ <configItem>
+ <name>nbsp:level4n</name>
+ <_description>Non-breakable space character at fourth level, thin non-breakable space character at sixth level</_description>
+ </configItem>
+ </option>
+ <option>
+ <configItem>
+ <name>nbsp:level4nl</name>
+ <_description>Non-breakable space character at fourth level, thin non-breakable space character at sixth level (via Ctrl+Shift)</_description>
+ </configItem>
+ </option>
+ <option>
+ <configItem>
+ <name>nbsp:zwnj2</name>
+ <_description>Zero-width non-joiner character at second level</_description>
+ </configItem>
+ </option>
+ <option>
+ <configItem>
+ <name>nbsp:zwnj2zwj3</name>
+ <_description>Zero-width non-joiner character at second level, zero-width joiner character at third level</_description>
+ </configItem>
+ </option>
+ <option>
+ <configItem>
+ <name>nbsp:zwnj2zwj3nb4</name>
+ <_description>Zero-width non-joiner character at second level, zero-width joiner character at third level, non-breakable space character at fourth level</_description>
+ </configItem>
+ </option>
+ <option>
+ <configItem>
+ <name>nbsp:zwnj2nb3</name>
+ <_description>Zero-width non-joiner character at second level, non-breakable space character at third level</_description>
+ </configItem>
+ </option>
+ <option>
+ <configItem>
+ <name>nbsp:zwnj2nb3s</name>
+ <_description>Zero-width non-joiner character at second level, non-breakable space character at third level, nothing at fourth level</_description>
+ </configItem>
+ </option>
+ <option>
+ <configItem>
+ <name>nbsp:zwnj2nb3zwj4</name>
+ <_description>Zero-width non-joiner character at second level, non-breakable space character at third level, zero-width joiner at fourth level</_description>
+ </configItem>
+ </option>
+ <option>
+ <configItem>
+ <name>nbsp:zwnj2nb3nnb4</name>
+ <_description>Zero-width non-joiner character at second level, non-breakable space character at third level, thin non-breakable space at fourth level</_description>
+ </configItem>
+ </option>
+ <option>
+ <configItem>
+ <name>nbsp:zwnj3zwj4</name>
+ <_description>Zero-width non-joiner character at third level, zero-width joiner at fourth level</_description>
+ </configItem>
+ </option>
+ </group>
+ <group allowMultipleSelection="true">
+ <configItem>
+ <name>japan</name>
+ <_description>Japanese keyboard options</_description>
+ </configItem>
+ <option>
+ <configItem>
+ <name>japan:kana_lock</name>
+ <_description>Kana Lock key is locking</_description>
+ </configItem>
+ </option>
+ <option>
+ <configItem>
+ <name>japan:nicola_f_bs</name>
+ <_description>NICOLA-F style Backspace</_description>
+ </configItem>
+ </option>
+ </group>
+ <group allowMultipleSelection="false">
+ <configItem>
+ <name>esperanto</name>
+ <_description>Adding Esperanto circumflexes (supersigno)</_description>
+ </configItem>
+ <option>
+ <configItem>
+ <name>esperanto:qwerty</name>
+ <_description>To the corresponding key in a Qwerty keyboard.</_description>
+ </configItem>
+ </option>
+ <option>
+ <configItem>
+ <name>esperanto:dvorak</name>
+ <_description>To the corresponding key in a Dvorak keyboard.</_description>
+ </configItem>
+ </option>
+ </group>
+ <group allowMultipleSelection="true">
+ <configItem>
+ <name>terminate</name>
+ <_description>Key sequence to kill the X server</_description>
+ </configItem>
+ <option>
+ <configItem>
+ <name>terminate:ctrl_alt_bksp</name>
+ <_description>Control + Alt + Backspace</_description>
+ </configItem>
+ </option>
+ </group>
+ </optionList>
+</xkbConfigRegistry>
diff --git a/xorg-server/xkeyboard-config/symbols/fi b/xorg-server/xkeyboard-config/symbols/fi
index 78dd91934..9d0f6247e 100644
--- a/xorg-server/xkeyboard-config/symbols/fi
+++ b/xorg-server/xkeyboard-config/symbols/fi
@@ -1,207 +1,208 @@
-//
-// $XKeyboardConfig$
-//
-// X keyboard maps for Finland
-//
-// SFS 5966 / Kotoistus keymap created by Troy Korjuslommi
-// Classic keymap based on traditional by Marko Myllynen
-// Eliminate deadkeys alternative sent by Linus Torvalds
-//
-
-//
-// Missing from X11/keysymdef.h as of 2010-05-13
-//
-// U2030 # PER MILLE SIGN
-// U0292 # LATIN SMALL LETTER EZH
-// U01B7 # LATIN CAPITAL LETTER EZH
-//
-
-partial alphanumeric_keys default
-xkb_symbols "kotoistus" {
-
- // Official keymap for Finland based on SFS 5966 standard
- //
- // This keymap implements all the functionality of Annex 1
- // of the standard and additionally defines the following to
- // allow entering these characters with keyboars without LSGT.
- //
- // AE08+4, U+003C : LESS-THAN SIGN (less)
- // AE09+4, U+003E : GREATER-THAN SIGN (greater)
- // AD08+4, U+007C : VERTICAL LINE (bar)
- //
- // Annex 3 of the standard is implemented in fi_FI.UTF-8/Compose
-
- name[Group1]="Finland";
-
- key <TLDE> { [ section, onehalf, dead_stroke, NoSymbol ] };
- key <AE01> { [ 1, exclam, NoSymbol, exclamdown ] };
- key <AE02> { [ 2, quotedbl, at, rightdoublequotemark ] };
- key <AE03> { [ 3, numbersign, sterling, guillemotright ] };
- key <AE04> { [ 4, currency, dollar, guillemotleft ] };
- key <AE05> { [ 5, percent, U2030, leftdoublequotemark ] };
- key <AE06> { [ 6, ampersand, singlelowquotemark, doublelowquotemark ] };
- key <AE07> { [ 7, slash, braceleft, NoSymbol ] };
- key <AE08> { [ 8, parenleft, bracketleft, less ] };
- key <AE09> { [ 9, parenright, bracketright, greater ] };
- key <AE10> { [ 0, equal, braceright, degree ] };
- key <AE11> { [ plus, question, backslash, questiondown ] };
- key <AE12> { [ dead_acute, dead_grave, dead_cedilla, dead_ogonek ] };
-
- key <AD01> { [ q, Q, q, Q ] };
- key <AD02> { [ w, W, w, W ] };
- key <AD03> { [ e, E, EuroSign, NoSymbol ] };
- key <AD04> { [ r, R, r, R ] };
- key <AD05> { [ t, T, thorn, THORN ] };
- key <AD06> { [ y, Y, y, Y ] };
- key <AD07> { [ u, U, u, U ] };
- key <AD08> { [ i, I, idotless, bar ] };
- key <AD09> { [ o, O, oe, OE ] };
- key <AD10> { [ p, P, dead_horn, dead_hook ] };
- key <AD11> { [ aring, Aring, dead_doubleacute, dead_abovering ] };
- key <AD12> { [ dead_diaeresis, dead_circumflex, dead_tilde, dead_macron ] };
-
- key <AC01> { [ a, A, schwa, SCHWA ] };
- key <AC02> { [ s, S, ssharp, NoSymbol ] };
- key <AC03> { [ d, D, eth, ETH ] };
- key <AC04> { [ f, F, f, F ] };
- key <AC05> { [ g, G, g, G ] };
- key <AC06> { [ h, H, h, H ] };
- key <AC07> { [ j, J, j, J ] };
- key <AC08> { [ k, K, kra, NoSymbol ] };
- key <AC09> { [ l, L, dead_stroke, NoSymbol ] };
- key <AC10> { [ odiaeresis, Odiaeresis, oslash, Oslash ] };
- key <AC11> { [ adiaeresis, Adiaeresis, ae, AE ] };
- key <BKSL> { [ apostrophe, asterisk, dead_caron, dead_breve ] };
-
- key <LSGT> { [ less, greater, bar, NoSymbol ] };
- key <AB01> { [ z, Z, U0292, U01B7 ] };
- key <AB02> { [ x, X, multiply, periodcentered ] };
- key <AB03> { [ c, C, c, C ] };
- key <AB04> { [ v, V, v, V ] };
- key <AB05> { [ b, B, b, B ] };
- key <AB06> { [ n, N, eng, ENG ] };
- key <AB07> { [ m, M, mu, emdash ] };
- key <AB08> { [ comma, semicolon, rightsinglequotemark, leftsinglequotemark ] };
- key <AB09> { [ period, colon, dead_belowdot, dead_abovedot ] };
- key <AB10> { [ minus, underscore, endash, dead_belowcomma ] };
-
- include "nbsp(level3)"
- include "kpdl(comma)"
- include "level3(ralt_switch)"
- include "compose(rwin)"
-};
-
-partial alphanumeric_keys
-xkb_symbols "classic" {
-
- include "fi(fi)"
-
- name[Group1]="Finland - Classic";
-};
-
-partial alphanumeric_keys hidden
-xkb_symbols "fi" {
-
- // Classic Finnish keyboard layout with dead keys support
- // and all ISO-8859-1 and ISO-8859-15 characters available
-
- key <TLDE> { [ section, onehalf, onequarter, threequarters ] };
- key <AE01> { [ 1, exclam, exclamdown, onesuperior ] };
- key <AE02> { [ 2, quotedbl, at, twosuperior ] };
- key <AE03> { [ 3, numbersign, sterling, threesuperior ] };
- key <AE04> { [ 4, currency, dollar, cent ] };
- key <AE05> { [ 5, percent, EuroSign, masculine ] };
- key <AE06> { [ 6, ampersand, yen, ordfeminine ] };
- key <AE07> { [ 7, slash, braceleft, plusminus ] };
- key <AE08> { [ 8, parenleft, bracketleft, guillemotleft ] };
- key <AE09> { [ 9, parenright, bracketright, guillemotright ] };
- key <AE10> { [ 0, equal, braceright, degree ] };
- key <AE11> { [ plus, question, backslash, questiondown ] };
- key <AE12> { [ dead_acute, dead_grave, dead_cedilla, dead_ogonek ] };
-
- key <AD01> { [ q, Q, q, Q ] };
- key <AD02> { [ w, W, w, W ] };
- key <AD03> { [ e, E, EuroSign, cent ] };
- key <AD04> { [ r, R, registered, NoSymbol ] };
- key <AD05> { [ t, T, thorn, THORN ] };
- key <AD06> { [ y, Y, y, Y ] };
- key <AD07> { [ u, U, u, U ] };
- key <AD08> { [ i, I, idotless, bar ] };
- key <AD09> { [ o, O, o, O ] };
- key <AD10> { [ p, P, paragraph, NoSymbol ] };
- key <AD11> { [ aring, Aring, oe, OE ] };
- key <AD12> { [ dead_diaeresis, dead_circumflex, dead_tilde, dead_caron ] };
-
- key <AC01> { [ a, A, schwa, SCHWA ] };
- key <AC02> { [ s, S, scaron, Scaron ] };
- key <AC03> { [ d, D, eth, ETH ] };
- key <AC04> { [ f, F, f, F ] };
- key <AC05> { [ g, G, eng, ENG ] };
- key <AC06> { [ h, H, h, H ] };
- key <AC07> { [ j, J, j, J ] };
- key <AC08> { [ k, K, kra, NoSymbol ] };
- key <AC09> { [ l, L, dead_stroke, NoSymbol ] };
- key <AC10> { [ odiaeresis, Odiaeresis, oslash, Oslash ] };
- key <AC11> { [ adiaeresis, Adiaeresis, ae, AE ] };
- key <BKSL> { [ apostrophe, asterisk, dead_caron, dead_breve ] };
-
- key <LSGT> { [ less, greater, bar, brokenbar ] };
- key <AB01> { [ z, Z, zcaron, Zcaron ] };
- key <AB02> { [ x, X, multiply, division ] };
- key <AB03> { [ c, C, copyright, cent ] };
- key <AB04> { [ v, V, v, V ] };
- key <AB05> { [ b, B, ssharp, NoSymbol ] };
- key <AB06> { [ n, N, ntilde, Ntilde ] };
- key <AB07> { [ m, M, mu, NoSymbol ] };
- key <AB08> { [ comma, semicolon, dead_cedilla, dead_ogonek ] };
- key <AB09> { [ period, colon, periodcentered, notsign ] };
- key <AB10> { [ minus, underscore, hyphen, dead_macron ] };
-
- include "nbsp(level4)"
- include "kpdl(comma)"
- include "level3(ralt_switch)"
- include "compose(rwin)"
-};
-
-partial alphanumeric_keys
-xkb_symbols "nodeadkeys" {
-
- // Classic Finnish keyboard layout without dead keys
-
- include "fi(fi)"
-
- name[Group1]="Finland - Classic, eliminate dead keys";
-
- key <AE12> { [ acute, grave, cedilla, ogonek ] };
- key <AD12> { [ diaeresis, asciicircum, asciitilde, caron ] };
- key <AC09> { [ l, L, l, L ] };
- key <BKSL> { [ apostrophe, asterisk, caron, breve ] };
- key <AB08> { [ comma, semicolon, cedilla, ogonek ] };
- key <AB10> { [ minus, underscore, hyphen, macron ] };
-};
-
-partial alphanumeric_keys
-xkb_symbols "smi" {
-
- // Describes the differences between a Norwegian Northern Sami
- // (keyboard with dead key support) and a Swedish/Finnish Sami
- // keyboard according to the specs at:
- // http://www.hum.uit.no/a/trond/se-lat9-sefi-keys.html
-
- include "no(smi)"
-
- name[Group1]="Finland - Northern Saami";
-
- key <AC10> { [ odiaeresis, Odiaeresis, oslash, Oslash ] };
- key <AC11> { [ adiaeresis, Adiaeresis, ae, AE ] };
-};
-
-partial alphanumeric_keys
-xkb_symbols "mac" {
-
- // Macintosh keyboard for Finland based on Swedish(Macintosh) keyboard
-
- include "se(mac)"
-
- name[Group1]="Finland - Macintosh";
-};
+//
+// $XKeyboardConfig$
+//
+// X keyboard maps for Finland
+//
+// SFS 5966 / Kotoistus keymap created by Troy Korjuslommi
+// Classic keymap based on traditional by Marko Myllynen
+// Eliminate deadkeys alternative sent by Linus Torvalds
+//
+
+//
+// Missing from X11/keysymdef.h as of 2010-05-13
+//
+// U2030 # PER MILLE SIGN
+// U0292 # LATIN SMALL LETTER EZH
+// U01B7 # LATIN CAPITAL LETTER EZH
+//
+
+partial alphanumeric_keys default
+xkb_symbols "kotoistus" {
+
+ // Official keymap for Finland based on SFS 5966 standard
+ //
+ // This keymap implements all the functionality of Annex 1
+ // of the standard and additionally defines the following to
+ // allow entering these characters with keyboars without LSGT.
+ //
+ // AE08+4, U+003C : LESS-THAN SIGN (less)
+ // AE09+4, U+003E : GREATER-THAN SIGN (greater)
+ // AD08+4, U+007C : VERTICAL LINE (bar)
+ //
+ // Annex 3 of the standard is implemented in fi_FI.UTF-8/Compose
+
+ name[Group1]="Finland";
+
+ key <TLDE> { [ section, onehalf, dead_stroke, NoSymbol ] };
+ key <AE01> { [ 1, exclam, NoSymbol, exclamdown ] };
+ key <AE02> { [ 2, quotedbl, at, rightdoublequotemark ] };
+ key <AE03> { [ 3, numbersign, sterling, guillemotright ] };
+ key <AE04> { [ 4, currency, dollar, guillemotleft ] };
+ key <AE05> { [ 5, percent, U2030, leftdoublequotemark ] };
+ key <AE06> { [ 6, ampersand, singlelowquotemark, doublelowquotemark ] };
+ key <AE07> { [ 7, slash, braceleft, NoSymbol ] };
+ key <AE08> { [ 8, parenleft, bracketleft, less ] };
+ key <AE09> { [ 9, parenright, bracketright, greater ] };
+ key <AE10> { [ 0, equal, braceright, degree ] };
+ key <AE11> { [ plus, question, backslash, questiondown ] };
+ key <AE12> { [ dead_acute, dead_grave, dead_cedilla, dead_ogonek ] };
+
+ key <AD01> { [ q, Q, q, Q ] };
+ key <AD02> { [ w, W, w, W ] };
+ key <AD03> { [ e, E, EuroSign, NoSymbol ] };
+ key <AD04> { [ r, R, r, R ] };
+ key <AD05> { [ t, T, thorn, THORN ] };
+ key <AD06> { [ y, Y, y, Y ] };
+ key <AD07> { [ u, U, u, U ] };
+ key <AD08> { [ i, I, idotless, bar ] };
+ key <AD09> { [ o, O, oe, OE ] };
+ key <AD10> { [ p, P, dead_horn, dead_hook ] };
+ key <AD11> { [ aring, Aring, dead_doubleacute, dead_abovering ] };
+ key <AD12> { [ dead_diaeresis, dead_circumflex, dead_tilde, dead_macron ] };
+
+ key <AC01> { [ a, A, schwa, SCHWA ] };
+ key <AC02> { [ s, S, ssharp, NoSymbol ] };
+ key <AC03> { [ d, D, eth, ETH ] };
+ key <AC04> { [ f, F, f, F ] };
+ key <AC05> { [ g, G, g, G ] };
+ key <AC06> { [ h, H, h, H ] };
+ key <AC07> { [ j, J, j, J ] };
+ key <AC08> { [ k, K, kra, NoSymbol ] };
+ key <AC09> { [ l, L, dead_stroke, NoSymbol ] };
+ key <AC10> { [ odiaeresis, Odiaeresis, oslash, Oslash ] };
+ key <AC11> { [ adiaeresis, Adiaeresis, ae, AE ] };
+ key <BKSL> { [ apostrophe, asterisk, dead_caron, dead_breve ] };
+
+ key <LSGT> { [ less, greater, bar, NoSymbol ] };
+ key <AB01> { [ z, Z, U0292, U01B7 ] };
+ key <AB02> { [ x, X, multiply, periodcentered ] };
+ key <AB03> { [ c, C, c, C ] };
+ key <AB04> { [ v, V, v, V ] };
+ key <AB05> { [ b, B, b, B ] };
+ key <AB06> { [ n, N, eng, ENG ] };
+ key <AB07> { [ m, M, mu, emdash ] };
+ key <AB08> { [ comma, semicolon, rightsinglequotemark, leftsinglequotemark ] };
+ key <AB09> { [ period, colon, dead_belowdot, dead_abovedot ] };
+ key <AB10> { [ minus, underscore, endash, dead_belowcomma ] };
+
+ include "nbsp(level4)"
+ include "nbsp(level3)"
+ include "kpdl(comma)"
+ include "level3(ralt_switch)"
+ include "compose(rwin)"
+};
+
+partial alphanumeric_keys
+xkb_symbols "classic" {
+
+ include "fi(fi)"
+
+ name[Group1]="Finland - Classic";
+};
+
+partial alphanumeric_keys hidden
+xkb_symbols "fi" {
+
+ // Classic Finnish keyboard layout with dead keys support
+ // and all ISO-8859-1 and ISO-8859-15 characters available
+
+ key <TLDE> { [ section, onehalf, onequarter, threequarters ] };
+ key <AE01> { [ 1, exclam, exclamdown, onesuperior ] };
+ key <AE02> { [ 2, quotedbl, at, twosuperior ] };
+ key <AE03> { [ 3, numbersign, sterling, threesuperior ] };
+ key <AE04> { [ 4, currency, dollar, cent ] };
+ key <AE05> { [ 5, percent, EuroSign, masculine ] };
+ key <AE06> { [ 6, ampersand, yen, ordfeminine ] };
+ key <AE07> { [ 7, slash, braceleft, plusminus ] };
+ key <AE08> { [ 8, parenleft, bracketleft, guillemotleft ] };
+ key <AE09> { [ 9, parenright, bracketright, guillemotright ] };
+ key <AE10> { [ 0, equal, braceright, degree ] };
+ key <AE11> { [ plus, question, backslash, questiondown ] };
+ key <AE12> { [ dead_acute, dead_grave, dead_cedilla, dead_ogonek ] };
+
+ key <AD01> { [ q, Q, q, Q ] };
+ key <AD02> { [ w, W, w, W ] };
+ key <AD03> { [ e, E, EuroSign, cent ] };
+ key <AD04> { [ r, R, registered, NoSymbol ] };
+ key <AD05> { [ t, T, thorn, THORN ] };
+ key <AD06> { [ y, Y, y, Y ] };
+ key <AD07> { [ u, U, u, U ] };
+ key <AD08> { [ i, I, idotless, bar ] };
+ key <AD09> { [ o, O, o, O ] };
+ key <AD10> { [ p, P, paragraph, NoSymbol ] };
+ key <AD11> { [ aring, Aring, oe, OE ] };
+ key <AD12> { [ dead_diaeresis, dead_circumflex, dead_tilde, dead_caron ] };
+
+ key <AC01> { [ a, A, schwa, SCHWA ] };
+ key <AC02> { [ s, S, scaron, Scaron ] };
+ key <AC03> { [ d, D, eth, ETH ] };
+ key <AC04> { [ f, F, f, F ] };
+ key <AC05> { [ g, G, eng, ENG ] };
+ key <AC06> { [ h, H, h, H ] };
+ key <AC07> { [ j, J, j, J ] };
+ key <AC08> { [ k, K, kra, NoSymbol ] };
+ key <AC09> { [ l, L, dead_stroke, NoSymbol ] };
+ key <AC10> { [ odiaeresis, Odiaeresis, oslash, Oslash ] };
+ key <AC11> { [ adiaeresis, Adiaeresis, ae, AE ] };
+ key <BKSL> { [ apostrophe, asterisk, dead_caron, dead_breve ] };
+
+ key <LSGT> { [ less, greater, bar, brokenbar ] };
+ key <AB01> { [ z, Z, zcaron, Zcaron ] };
+ key <AB02> { [ x, X, multiply, division ] };
+ key <AB03> { [ c, C, copyright, cent ] };
+ key <AB04> { [ v, V, v, V ] };
+ key <AB05> { [ b, B, ssharp, NoSymbol ] };
+ key <AB06> { [ n, N, ntilde, Ntilde ] };
+ key <AB07> { [ m, M, mu, NoSymbol ] };
+ key <AB08> { [ comma, semicolon, dead_cedilla, dead_ogonek ] };
+ key <AB09> { [ period, colon, periodcentered, notsign ] };
+ key <AB10> { [ minus, underscore, hyphen, dead_macron ] };
+
+ include "nbsp(level4)"
+ include "kpdl(comma)"
+ include "level3(ralt_switch)"
+ include "compose(rwin)"
+};
+
+partial alphanumeric_keys
+xkb_symbols "nodeadkeys" {
+
+ // Classic Finnish keyboard layout without dead keys
+
+ include "fi(fi)"
+
+ name[Group1]="Finland - Classic, eliminate dead keys";
+
+ key <AE12> { [ acute, grave, cedilla, ogonek ] };
+ key <AD12> { [ diaeresis, asciicircum, asciitilde, caron ] };
+ key <AC09> { [ l, L, l, L ] };
+ key <BKSL> { [ apostrophe, asterisk, caron, breve ] };
+ key <AB08> { [ comma, semicolon, cedilla, ogonek ] };
+ key <AB10> { [ minus, underscore, hyphen, macron ] };
+};
+
+partial alphanumeric_keys
+xkb_symbols "smi" {
+
+ // Describes the differences between a Norwegian Northern Sami
+ // (keyboard with dead key support) and a Swedish/Finnish Sami
+ // keyboard according to the specs at:
+ // http://www.hum.uit.no/a/trond/se-lat9-sefi-keys.html
+
+ include "no(smi)"
+
+ name[Group1]="Finland - Northern Saami";
+
+ key <AC10> { [ odiaeresis, Odiaeresis, oslash, Oslash ] };
+ key <AC11> { [ adiaeresis, Adiaeresis, ae, AE ] };
+};
+
+partial alphanumeric_keys
+xkb_symbols "mac" {
+
+ // Macintosh keyboard for Finland based on Swedish(Macintosh) keyboard
+
+ include "se(mac)"
+
+ name[Group1]="Finland - Macintosh";
+};
diff --git a/xorg-server/xkeyboard-config/symbols/ru b/xorg-server/xkeyboard-config/symbols/ru
index 0e059afad..b95d6d57e 100644
--- a/xorg-server/xkeyboard-config/symbols/ru
+++ b/xorg-server/xkeyboard-config/symbols/ru
@@ -1,510 +1,531 @@
-// $XKeyboardConfig$
-
-// based on
-// russian standard keyboard
-// AEN <aen@logic.ru>
-// 2001/12/23 by Leon Kanter <leon@blackcatlinux.com>
-// 2005/12/09 Valery Inozemtsev <shrek@altlinux.ru>
-//
-// $XFree86: xc/programs/xkbcomp/symbols/ru,v 1.3 2003/02/15 22:27:05 dawes Exp $
-
-// Windows layout
-partial default alphanumeric_keys
-xkb_symbols "winkeys" {
- include "ru(common)"
-
- name[Group1]= "Russia";
-
- key <AE03> { [ 3, numerosign ] };
- key <AE04> { [ 4, semicolon ] };
- key <AE05> { [ 5, percent ] };
- key <AE06> { [ 6, colon ] };
- key <AE07> { [ 7, question ] };
- key <AE08> { [ 8, asterisk ] };
-
- key <AB10> { [ period, comma ] };
- key <BKSL> { [ backslash, slash ] };
-};
-
-partial hidden alphanumeric_keys
-xkb_symbols "common" {
-
- key <AE01> { [ 1, exclam ] };
- key <AE02> { [ 2, quotedbl ] };
- key <AE03> { [ 3, numbersign ] };
- key <AE04> { [ 4, asterisk ] };
- key <AE05> { [ 5, colon ] };
- key <AE06> { [ 6, comma ] };
- key <AE07> { [ 7, period ] };
- key <AE08> { [ 8, semicolon ] };
- key <AE09> { [ 9, parenleft ] };
- key <AE10> { [ 0, parenright ] };
- key <AE11> { [ minus, underscore ] };
- key <AE12> { [ equal, plus ] };
- key <BKSL> { [ backslash, bar ] };
- key <AB10> { [ slash, question ] };
- key <LSGT> { [ slash, bar ] };
-
- key <TLDE> { [ Cyrillic_io, Cyrillic_IO ] };
- key <AD01> { [ Cyrillic_shorti, Cyrillic_SHORTI ] };
- key <AD02> { [ Cyrillic_tse, Cyrillic_TSE ] };
- key <AD03> { [ Cyrillic_u, Cyrillic_U ] };
- key <AD04> { [ Cyrillic_ka, Cyrillic_KA ] };
- key <AD05> { [ Cyrillic_ie, Cyrillic_IE ] };
- key <AD06> { [ Cyrillic_en, Cyrillic_EN ] };
- key <AD07> { [ Cyrillic_ghe, Cyrillic_GHE ] };
- key <AD08> { [ Cyrillic_sha, Cyrillic_SHA ] };
- key <AD09> { [ Cyrillic_shcha, Cyrillic_SHCHA ] };
- key <AD10> { [ Cyrillic_ze, Cyrillic_ZE ] };
- key <AD11> { [ Cyrillic_ha, Cyrillic_HA ] };
- key <AD12> { [Cyrillic_hardsign,Cyrillic_HARDSIGN ] };
- key <AC01> { [ Cyrillic_ef, Cyrillic_EF ] };
- key <AC02> { [ Cyrillic_yeru, Cyrillic_YERU ] };
- key <AC03> { [ Cyrillic_ve, Cyrillic_VE ] };
- key <AC04> { [ Cyrillic_a, Cyrillic_A ] };
- key <AC05> { [ Cyrillic_pe, Cyrillic_PE ] };
- key <AC06> { [ Cyrillic_er, Cyrillic_ER ] };
- key <AC07> { [ Cyrillic_o, Cyrillic_O ] };
- key <AC08> { [ Cyrillic_el, Cyrillic_EL ] };
- key <AC09> { [ Cyrillic_de, Cyrillic_DE ] };
- key <AC10> { [ Cyrillic_zhe, Cyrillic_ZHE ] };
- key <AC11> { [ Cyrillic_e, Cyrillic_E ] };
- key <AB01> { [ Cyrillic_ya, Cyrillic_YA ] };
- key <AB02> { [ Cyrillic_che, Cyrillic_CHE ] };
- key <AB03> { [ Cyrillic_es, Cyrillic_ES ] };
- key <AB04> { [ Cyrillic_em, Cyrillic_EM ] };
- key <AB05> { [ Cyrillic_i, Cyrillic_I ] };
- key <AB06> { [ Cyrillic_te, Cyrillic_TE ] };
- key <AB07> { [Cyrillic_softsign,Cyrillic_SOFTSIGN ] };
- key <AB08> { [ Cyrillic_be, Cyrillic_BE ] };
- key <AB09> { [ Cyrillic_yu, Cyrillic_YU ] };
-
- key.type[group1]="TWO_LEVEL";
-
- include "kpdl(comma)"
-};
-
-partial alphanumeric_keys
-xkb_symbols "legacy" {
- include "ru(common)"
-
- name[Group1]= "Russia - Legacy";
-};
-
-partial alphanumeric_keys
-xkb_symbols "olpc" {
-
- include "ru(common)"
-
- key <TLDE> { [ 0x01000451, 0x01000401, grave ] }; // Ñ‘, Ð
- key <AE03> { [ 3, numbersign, 0x01002116 ] }; // â„–
- key <AE04> { [ 4, dollar, semicolon ] };
- key <AE06> { [ 6, asciicircum, colon ] };
- key <AE07> { [ 7, ampersand ] };
- key <AE09> { [ 9, parenleft, acute ] };
- key <AC12> { [ backslash, bar, slash ] };
-
- include "group(olpc)"
-};
-
-partial alphanumeric_keys
-xkb_symbols "typewriter" {
- include "ru(common)"
- name[Group1]= "Russia - Typewriter";
- key <TLDE> { [ bar, plus ] };
- key <AE01> { [ numerosign, 1 ] };
- key <AE02> { [ minus, 2 ] };
- key <AE03> { [ slash, 3 ] };
- key <AE04> { [ quotedbl, 4 ] };
- key <AE05> { [ colon, 5 ] };
- key <AE06> { [ comma, 6 ] };
- key <AE07> { [ period, 7 ] };
- key <AE08> { [ underscore, 8 ] };
- key <AE09> { [ question, 9 ] };
- key <AE10> { [ percent, 0 ] };
- key <AE11> { [ exclam, equal ] };
- key <AE12> { [ semicolon, backslash ] };
-
- key <BKSL> { [ parenright, parenleft ] };
-
- key <AD12> { [Cyrillic_hardsign,Cyrillic_HARDSIGN ] };
- key <AB10> { [ Cyrillic_io, Cyrillic_IO ] };
-};
-
-partial alphanumeric_keys
-xkb_symbols "typewriter-legacy" {
- include "ru(common)"
- name[Group1]= "Russia - Typewriter, legacy";
- key <TLDE> { [ apostrophe, quotedbl ] };
- key <AE01> { [ exclam, 1 ] };
- key <AE02> { [ numerosign, 2 ] };
- key <AE03> { [ slash, 3 ] };
- key <AE04> { [ semicolon, 4 ] };
- key <AE05> { [ colon, 5 ] };
- key <AE06> { [ comma, 6 ] };
- key <AE07> { [ period, 7 ] };
- key <AE08> { [ underscore, 8 ] };
- key <AE09> { [ question, 9 ] };
- key <AE10> { [ percent, 0 ] };
- key <BKSL> { [ parenleft, parenright ] };
-
- key <AD12> { [Cyrillic_hardsign,Cyrillic_HARDSIGN ] };
- key <AB10> { [ Cyrillic_io, Cyrillic_IO ] };
-};
-
-partial alphanumeric_keys
-xkb_symbols "phonetic" {
-
- name[Group1]= "Russia - Phonetic";
-
- key <AE01> { [ 1, exclam ] };
- key <AE02> { [ 2, at ] };
- key <AE03> { [ 3, Cyrillic_io ] };
- key <AE04> { [ 4, Cyrillic_IO ] };
- key <AE05> { [ 5, Cyrillic_hardsign ] };
- key <AE06> { [ 6, Cyrillic_HARDSIGN ] };
- key <AE07> { [ 7, ampersand ] };
- key <AE08> { [ 8, asterisk ] };
- key <AE09> { [ 9, parenleft ] };
- key <AE10> { [ 0, parenright ] };
- key <AE11> { [ minus, underscore ] };
-
- key <AB09> { [ period, greater ] };
- key <AB10> { [ slash, question ] };
- key <AB08> { [ comma, less ] };
- key <AC10> { [ semicolon, colon ] };
- key <AC11> { [ apostrophe, quotedbl ] };
- key <LSGT> { [ bar, brokenbar ] };
-
- key <TLDE> { [ Cyrillic_yu, Cyrillic_YU ] };
- key <LatQ> { [ Cyrillic_ya, Cyrillic_YA ] };
- key <LatZ> { [ Cyrillic_ze, Cyrillic_ZE ] };
- key <LatS> { [ Cyrillic_es, Cyrillic_ES ] };
- key <LatA> { [ Cyrillic_a, Cyrillic_A ] };
- key <LatW> { [ Cyrillic_ve, Cyrillic_VE ] };
- key <LatC> { [ Cyrillic_tse, Cyrillic_TSE ] };
- key <LatX> { [Cyrillic_softsign,Cyrillic_SOFTSIGN ] };
- key <LatD> { [ Cyrillic_de, Cyrillic_DE ] };
- key <LatE> { [ Cyrillic_ie, Cyrillic_IE ] };
- key <LatV> { [ Cyrillic_zhe, Cyrillic_ZHE ] };
- key <LatF> { [ Cyrillic_ef, Cyrillic_EF ] };
- key <LatT> { [ Cyrillic_te, Cyrillic_TE ] };
- key <LatR> { [ Cyrillic_er, Cyrillic_ER ] };
- key <LatN> { [ Cyrillic_en, Cyrillic_EN ] };
- key <LatB> { [ Cyrillic_be, Cyrillic_BE ] };
- key <LatH> { [ Cyrillic_ha, Cyrillic_HA ] };
- key <LatG> { [ Cyrillic_ghe, Cyrillic_GHE ] };
- key <LatY> { [ Cyrillic_yeru, Cyrillic_YERU ] };
- key <LatM> { [ Cyrillic_em, Cyrillic_EM ] };
- key <LatJ> { [ Cyrillic_shorti, Cyrillic_SHORTI ] };
- key <LatU> { [ Cyrillic_u, Cyrillic_U ] };
- key <LatK> { [ Cyrillic_ka, Cyrillic_KA ] };
- key <LatI> { [ Cyrillic_i, Cyrillic_I ] };
- key <LatO> { [ Cyrillic_o, Cyrillic_O ] };
- key <LatL> { [ Cyrillic_el, Cyrillic_EL ] };
- key <LatP> { [ Cyrillic_pe, Cyrillic_PE ] };
-
- key <AD11> { [ Cyrillic_sha, Cyrillic_SHA ] };
- key <AE12> { [ Cyrillic_che, Cyrillic_CHE ] };
- key <AD12> { [ Cyrillic_shcha, Cyrillic_SHCHA ] };
- key <BKSL> { [ Cyrillic_e, Cyrillic_E ] };
-};
-
-partial alphanumeric_keys
-xkb_symbols "phonetic_winkeys" {
-
- include "ru(phonetic)"
- name[Group1]= "Russia - Phonetic Winkeys";
-
- key <LatX> { [ Cyrillic_ha, Cyrillic_HA ] };
- key <LatH> { [ Cyrillic_che, Cyrillic_CHE ] };
- key <AE12> { [ Cyrillic_softsign, Cyrillic_softsign ] };
-
-};
-
-partial alphanumeric_keys
-xkb_symbols "tt" {
- include "ru(winkeys)"
- name[Group1]= "Russia - Tatar";
-
- key.type[group1]="FOUR_LEVEL";
-
- key <TLDE> { [ 0x010004bb, 0x010004ba,
- Cyrillic_io, Cyrillic_IO ] };
- key <AD02> { [ 0x010004e9, 0x010004e8,
- Cyrillic_tse, Cyrillic_TSE ] };
- key <AD09> { [ 0x010004d9, 0x010004d8,
- Cyrillic_shcha, Cyrillic_SHCHA ] };
- key <AD12> { [ 0x010004af, 0x010004ae,
- Cyrillic_hardsign,Cyrillic_HARDSIGN ] };
- key <AC10> { [ 0x010004a3, 0x010004a2,
- Cyrillic_zhe, Cyrillic_ZHE ] };
- key <AB07> { [ 0x01000497, 0x01000496,
- Cyrillic_softsign,Cyrillic_SOFTSIGN ] };
-
- include "level3(ralt_switch)"
-
-};
-
-partial alphanumeric_keys
-xkb_symbols "os_legacy" {
- include "ru(common)"
-
- name[Group1]= "Russia - Ossetian, legacy";
-
- key <TLDE> { [ Cyrillic_e, Cyrillic_E ] };
- key <AC07> { [ Cyrillic_o, Cyrillic_O, Cyrillic_io, Cyrillic_IO ] };
- key <AC11> { [ 0x010004D5, 0x010004D4 ] };
-};
-
-partial alphanumeric_keys
-xkb_symbols "os_winkeys" {
- include "ru(winkeys)"
-
- name[Group1]= "Russia - Ossetian, Winkeys";
-
- key <TLDE> { [ Cyrillic_e, Cyrillic_E ] };
- key <AC07> { [ Cyrillic_o, Cyrillic_O, Cyrillic_io, Cyrillic_IO ] };
- key <AC11> { [ 0x010004D5, 0x010004D4 ] };
-};
-
-partial alphanumeric_keys
-xkb_symbols "cv" {
- include "ru(winkeys)"
-
- name[Group1]= "Russia - Chuvash";
-
- key.type[group1]="FOUR_LEVEL";
-
- key <AD03> { [ Cyrillic_u, Cyrillic_U,
- 0x010004f3, 0x010004f2 ] };
- key <AD05> { [ Cyrillic_ie, Cyrillic_IE,
- 0x01000115, 0x01000114 ] };
- key <AC04> { [ Cyrillic_a, Cyrillic_A,
- abreve, Abreve ] };
- key <AB03> { [ Cyrillic_es, Cyrillic_ES,
- ccedilla, Ccedilla ] };
-
- include "level3(ralt_switch)"
-};
-
-partial alphanumeric_keys
-xkb_symbols "udm" {
- include "ru(winkeys)"
-
- name[Group1]= "Russia - Udmurt";
-
- key.type[group1]="FOUR_LEVEL";
-
- key <AE01> { [ question, exclam, 1, 1 ] };
- key <AE02> { [ parenleft, quotedbl, 2, 2 ] };
- key <AE03> { [ parenright, numerosign, 3, 3 ] };
- key <AE04> { [ colon, semicolon, 4, 4 ] };
- key <AE05> { [ asterisk, percent, 5, 5 ] };
- key <AE06> { [ 0x010004dd, 0x010004dc, 6, 6 ] };
- key <AE07> { [ 0x010004e7, 0x010004e6, 7, 7 ] };
- key <AE08> { [ 0x010004f5, 0x010004f4, 8, 8 ] };
- key <AE09> { [ 0x010004e5, 0x010004e4, 9, 9 ] };
- key <AE10> { [ 0x010004df, 0x010004de, 0, 0 ] };
-
- include "level3(ralt_switch)"
-};
-
-partial alphanumeric_keys
-xkb_symbols "cv_latin" {
- include "us(alt-intl)"
-
- name[Group1]= "Russia - Chuvash Latin";
-
- key.type[group1]="FOUR_LEVEL";
-
- key <AD01> { [ q, Q, 0x01000161, 0x01000160 ] };
- key <AD02> { [ w, W, udiaeresis, Udiaeresis ] };
- key <AD03> { [ e, E, 0x01000115, 0x01000114 ] };
- key <AD07> { [ u, U, udiaeresis, Udiaeresis ] };
- key <AD08> { [ i, I, 0x0100012d, 0x0100012c ] };
- key <AD09> { [ o, O, odiaeresis, Odiaeresis ] };
- key <AC01> { [ a, A, abreve, Abreve ] };
- key <AC02> { [ s, S, scedilla, Scedilla ] };
- key <AC05> { [ g, G, gbreve, Gbreve ] };
- key <AC07> { [ j, J, 0x01000131, 0x01000130 ] };
- key <AB03> { [ c, C, ccedilla, Ccedilla ] };
-
- include "level3(ralt_switch)"
-
-};
-
-// Komi language layout
-// based on
-// russian standard keyboard
-// Vlad Shakhov <lumpen.intellectual@gmail.com>
-// Last Changes 2007/10/23 by Vlad Shakhov <lumpen.intellectual@gmail.com>
-
-partial alphanumeric_keys
-xkb_symbols "kom" {
-
- include "ru(winkeys)"
-
- name[Group1]= "Russia - Komi";
-
- key.type[group1]="FOUR_LEVEL_ALPHABETIC";
-
-// cyrilllic o with diaeresis
- key <AC07> { [ Cyrillic_o, Cyrillic_O,
- U04E7, U04E6 ] };
-
-// hard I as additional key for soft Cyrillic_I
- key <AB05> { [ Cyrillic_i, Cyrillic_I,
- Ukrainian_i, Ukrainian_I ] };
-
- include "level3(ralt_switch)"
-};
-
-// Yakut language layout
-// 2008/04/23 Yakov Aleksandrov <bertjickty@yandex.ru>
-// 2008/04/23 Anatoliy Zhozhikov <jav@sitc.ru>
-// 2008/04/23 Aleksandr Varlamov
-partial alphanumeric_keys
-xkb_symbols "sah" {
-
- include "ru(winkeys)"
-
- name[Group1]= "Russia - Yakut";
-
- key.type[group1]="FOUR_LEVEL_ALPHABETIC";
-
- key <TLDE> { [ Cyrillic_io, Cyrillic_IO,
- U04EB, U04EA ] };
- key <AD01> { [ Cyrillic_shorti, Cyrillic_SHORTI,
- U048B, U048A ] };
- key <AD03> { [ Cyrillic_u, Cyrillic_U,
- Cyrillic_u_straight, Cyrillic_U_straight ] };
- key <AD04> { [ Cyrillic_ka, Cyrillic_KA,
- U04C4, U04C3 ] };
- key <AD06> { [ Cyrillic_en, Cyrillic_EN,
- U04A5, U04A4 ] };
- key <AD07> { [ Cyrillic_ghe, Cyrillic_GHE,
- U0495, U0494 ] };
- key <AD10> { [ Cyrillic_ze, Cyrillic_ZE,
- U04E1, U04E0 ] };
- key <AD11> { [ Cyrillic_ha, Cyrillic_HA,
- Cyrillic_shha, Cyrillic_SHHA ] };
- key <AC07> { [ Cyrillic_o, Cyrillic_O,
- Cyrillic_o_bar, Cyrillic_O_bar ] };
- key <AC10> { [ Cyrillic_zhe, Cyrillic_ZHE,
- U0461, U0460 ] };
- key <AB02> { [ Cyrillic_che, Cyrillic_CHE,
- Cyrillic_u_macron, Cyrillic_U_macron ] };
- key <AB04> { [ Cyrillic_em, Cyrillic_EM,
- U04C8, U04C7 ] };
- key <AB05> { [ Cyrillic_i, Cyrillic_I,
- Cyrillic_i_macron, Cyrillic_I_macron ] };
-
- include "level3(ralt_switch)"
-};
-
-
-//Kalmyk language layout
-//based on the Kalmyk language layout: http://soft.oyrat.org/
-//Nikolay Korneev <halmg@oyrat.org>
-//Toli Miron <mirontoli@gmail.com>
-
-partial alphanumeric_keys
-xkb_symbols "xal" {
- include "ru(winkeys)"
-
- name[Group1]= "Russia - Kalmyk";
-
- key.type[group1]="FOUR_LEVEL";
-
- key <AE01> { [ question, exclam, 1 ] };
- key <AE02> { [ numerosign, quotedbl, 2 ] };
- key <AE03> { [ Cyrillic_u_straight, Cyrillic_U_straight, 3 ] };
- key <AE04> { [ Cyrillic_schwa, Cyrillic_SCHWA, 4 ] };
- key <AE05> { [ asterisk, percent, 5 ] };
- key <AE06> { [ Cyrillic_en_descender, Cyrillic_EN_descender, 6 ] };
- key <AE07> { [ Cyrillic_o_bar, Cyrillic_O_bar, 7 ] };
- key <AE08> { [ Cyrillic_shha, Cyrillic_SHHA, 8 ] };
- key <AE09> { [ Cyrillic_zhe_descender, Cyrillic_ZHE_descender, 9 ] };
- key <AE10> { [ semicolon, colon, 0 ] };
-
- key <TLDE> { [ parenleft, parenright, Cyrillic_io, Cyrillic_IO ] };
-
- key <AD02> { [ Cyrillic_tse, Cyrillic_TSE, dollar ] };
- key <AD03> { [ Cyrillic_u, Cyrillic_U, EuroSign ] };
- key <AD04> { [ Cyrillic_ka, Cyrillic_KA, registered ] };
- key <AD05> { [ Cyrillic_ie, Cyrillic_IE, trademark ] };
- key <AD11> { [ Cyrillic_ha, Cyrillic_HA, bracketleft ] };
- key <AD12> { [ Cyrillic_hardsign, Cyrillic_HARDSIGN, bracketright ] };
- key <AC11> { [ Cyrillic_e, Cyrillic_E, apostrophe ] };
- key <AB03> { [ Cyrillic_es, Cyrillic_ES, copyright ] };
- key <AB08> { [ Cyrillic_be, Cyrillic_BE, less ] };
- key <AB09> { [ Cyrillic_yu, Cyrillic_YU, greater ] };
-
- include "level3(ralt_switch)"
-};
-
-partial alphanumeric_keys
-xkb_symbols "dos" {
-
- include "ru(common)"
-
- name[Group1]= "Russia - DOS";
-
- key <TLDE> { [ parenright, parenleft ] };
- key <AE04> { [ 4, currency ] };
- key <AE09> { [ 9, question ] };
- key <AE10> { [ 0, percent ] };
-
- key <AB10> { [ Cyrillic_io, Cyrillic_IO ] };
-};
-
-partial alphanumeric_keys
-xkb_symbols "bak" {
- include "ru(winkeys)"
-
- name[Group1]= "Russia - Bashkirian";
- key.type[group1]="FOUR_LEVEL";
-
- key <TLDE> { [ 0x010004d9, 0x010004d8, Cyrillic_io, Cyrillic_IO ] };
- key <AE01> { [ exclam, quotedbl, 1, 1 ] };
- key <AE02> { [ 0x010004e9, 0x010004e8, 2, 2 ] };
- key <AE03> { [ 0x010004a1, 0x010004a0, 3, 3 ] };
- key <AE04> { [ 0x01000493, 0x01000492, 4, 4 ] };
- key <AE05> { [ 0x010004ab, 0x010004aa, 5, 5 ] };
- key <AE06> { [ colon, semicolon, 6, 6 ] };
- key <AE07> { [ 0x01000499, 0x01000498, 7, 7 ] };
- key <AE08> { [ 0x010004bb, 0x010004ba, 8, 8 ] };
- key <AE09> { [ question, parenleft, 9, 9 ] };
- key <AE10> { [ numerosign, parenright, 0, 0 ] };
- key <AE11> { [ minus, percent, minus, underscore ]};
- key <AE12> { [ 0x010004af, 0x010004ae, equal, plus ]};
- key <BKSL> { [ 0x010004a3, 0x010004a2, backslash, slash ]};
-
- include "level3(ralt_switch)"
-};
-
-// Serbian charecters added as third level symbols to Russian keyboard layout.
-
-partial alphanumeric_keys
-xkb_symbols "srp" {
- include "ru(common)"
- include "level3(ralt_switch)"
-
- name[Group1]= "Russia - Serbian";
-
- key <AE03> { [ 3, numerosign ] };
- key <AE04> { [ 4, semicolon ] };
- key <AE05> { [ 5, percent ] };
- key <AE06> { [ 6, colon ] };
- key <AE07> { [ 7, question ] };
- key <AE08> { [ 8, asterisk ] };
- key <AB10> { [ period, comma ] };
- key <BKSL> { [ backslash, slash ] };
- key <AD01> { [ Cyrillic_shorti, Cyrillic_SHORTI, U458, U408 ] };
- key <AD06> { [ Cyrillic_en, Cyrillic_EN, U45A, U40A ] };
- key <AC08> { [ Cyrillic_el, Cyrillic_EL, U459, U409 ] };
- key <AC09> { [ Cyrillic_de, Cyrillic_DE, U45F, U40F ] };
- key <AC10> { [ Cyrillic_zhe, Cyrillic_ZHE, U452, U402 ] };
- key <AB02> { [ Cyrillic_che, Cyrillic_CHE, U45B, U40B ] };
-};
+// $XKeyboardConfig$
+
+// based on
+// russian standard keyboard
+// AEN <aen@logic.ru>
+// 2001/12/23 by Leon Kanter <leon@blackcatlinux.com>
+// 2005/12/09 Valery Inozemtsev <shrek@altlinux.ru>
+//
+// $XFree86: xc/programs/xkbcomp/symbols/ru,v 1.3 2003/02/15 22:27:05 dawes Exp $
+
+// Windows layout
+partial default alphanumeric_keys
+xkb_symbols "winkeys" {
+ include "ru(common)"
+
+ name[Group1]= "Russia";
+
+ key <AE03> { [ 3, numerosign ] };
+ key <AE04> { [ 4, semicolon ] };
+ key <AE05> { [ 5, percent ] };
+ key <AE06> { [ 6, colon ] };
+ key <AE07> { [ 7, question ] };
+ key <AE08> { [ 8, asterisk ] };
+
+ key <AB10> { [ period, comma ] };
+ key <BKSL> { [ backslash, slash ] };
+};
+
+partial hidden alphanumeric_keys
+xkb_symbols "common" {
+
+ key <AE01> { [ 1, exclam ] };
+ key <AE02> { [ 2, quotedbl ] };
+ key <AE03> { [ 3, numbersign ] };
+ key <AE04> { [ 4, asterisk ] };
+ key <AE05> { [ 5, colon ] };
+ key <AE06> { [ 6, comma ] };
+ key <AE07> { [ 7, period ] };
+ key <AE08> { [ 8, semicolon ] };
+ key <AE09> { [ 9, parenleft ] };
+ key <AE10> { [ 0, parenright ] };
+ key <AE11> { [ minus, underscore ] };
+ key <AE12> { [ equal, plus ] };
+ key <BKSL> { [ backslash, bar ] };
+ key <AB10> { [ slash, question ] };
+ key <LSGT> { [ slash, bar ] };
+
+ key <TLDE> { [ Cyrillic_io, Cyrillic_IO ] };
+ key <AD01> { [ Cyrillic_shorti, Cyrillic_SHORTI ] };
+ key <AD02> { [ Cyrillic_tse, Cyrillic_TSE ] };
+ key <AD03> { [ Cyrillic_u, Cyrillic_U ] };
+ key <AD04> { [ Cyrillic_ka, Cyrillic_KA ] };
+ key <AD05> { [ Cyrillic_ie, Cyrillic_IE ] };
+ key <AD06> { [ Cyrillic_en, Cyrillic_EN ] };
+ key <AD07> { [ Cyrillic_ghe, Cyrillic_GHE ] };
+ key <AD08> { [ Cyrillic_sha, Cyrillic_SHA ] };
+ key <AD09> { [ Cyrillic_shcha, Cyrillic_SHCHA ] };
+ key <AD10> { [ Cyrillic_ze, Cyrillic_ZE ] };
+ key <AD11> { [ Cyrillic_ha, Cyrillic_HA ] };
+ key <AD12> { [Cyrillic_hardsign,Cyrillic_HARDSIGN ] };
+ key <AC01> { [ Cyrillic_ef, Cyrillic_EF ] };
+ key <AC02> { [ Cyrillic_yeru, Cyrillic_YERU ] };
+ key <AC03> { [ Cyrillic_ve, Cyrillic_VE ] };
+ key <AC04> { [ Cyrillic_a, Cyrillic_A ] };
+ key <AC05> { [ Cyrillic_pe, Cyrillic_PE ] };
+ key <AC06> { [ Cyrillic_er, Cyrillic_ER ] };
+ key <AC07> { [ Cyrillic_o, Cyrillic_O ] };
+ key <AC08> { [ Cyrillic_el, Cyrillic_EL ] };
+ key <AC09> { [ Cyrillic_de, Cyrillic_DE ] };
+ key <AC10> { [ Cyrillic_zhe, Cyrillic_ZHE ] };
+ key <AC11> { [ Cyrillic_e, Cyrillic_E ] };
+ key <AB01> { [ Cyrillic_ya, Cyrillic_YA ] };
+ key <AB02> { [ Cyrillic_che, Cyrillic_CHE ] };
+ key <AB03> { [ Cyrillic_es, Cyrillic_ES ] };
+ key <AB04> { [ Cyrillic_em, Cyrillic_EM ] };
+ key <AB05> { [ Cyrillic_i, Cyrillic_I ] };
+ key <AB06> { [ Cyrillic_te, Cyrillic_TE ] };
+ key <AB07> { [Cyrillic_softsign,Cyrillic_SOFTSIGN ] };
+ key <AB08> { [ Cyrillic_be, Cyrillic_BE ] };
+ key <AB09> { [ Cyrillic_yu, Cyrillic_YU ] };
+
+ key.type[group1]="TWO_LEVEL";
+
+ include "kpdl(comma)"
+};
+
+partial alphanumeric_keys
+xkb_symbols "legacy" {
+ include "ru(common)"
+
+ name[Group1]= "Russia - Legacy";
+};
+
+partial alphanumeric_keys
+xkb_symbols "olpc" {
+
+ include "ru(common)"
+
+ key <TLDE> { [ 0x01000451, 0x01000401, grave ] }; // Ñ‘, Ð
+ key <AE03> { [ 3, numbersign, 0x01002116 ] }; // â„–
+ key <AE04> { [ 4, dollar, semicolon ] };
+ key <AE06> { [ 6, asciicircum, colon ] };
+ key <AE07> { [ 7, ampersand ] };
+ key <AE09> { [ 9, parenleft, acute ] };
+ key <AC12> { [ backslash, bar, slash ] };
+
+ include "group(olpc)"
+};
+
+partial alphanumeric_keys
+xkb_symbols "typewriter" {
+ include "ru(common)"
+ name[Group1]= "Russia - Typewriter";
+ key <TLDE> { [ bar, plus ] };
+ key <AE01> { [ numerosign, 1 ] };
+ key <AE02> { [ minus, 2 ] };
+ key <AE03> { [ slash, 3 ] };
+ key <AE04> { [ quotedbl, 4 ] };
+ key <AE05> { [ colon, 5 ] };
+ key <AE06> { [ comma, 6 ] };
+ key <AE07> { [ period, 7 ] };
+ key <AE08> { [ underscore, 8 ] };
+ key <AE09> { [ question, 9 ] };
+ key <AE10> { [ percent, 0 ] };
+ key <AE11> { [ exclam, equal ] };
+ key <AE12> { [ semicolon, backslash ] };
+
+ key <BKSL> { [ parenright, parenleft ] };
+
+ key <AD12> { [Cyrillic_hardsign,Cyrillic_HARDSIGN ] };
+ key <AB10> { [ Cyrillic_io, Cyrillic_IO ] };
+};
+
+partial alphanumeric_keys
+xkb_symbols "typewriter-legacy" {
+ include "ru(common)"
+ name[Group1]= "Russia - Typewriter, legacy";
+ key <TLDE> { [ apostrophe, quotedbl ] };
+ key <AE01> { [ exclam, 1 ] };
+ key <AE02> { [ numerosign, 2 ] };
+ key <AE03> { [ slash, 3 ] };
+ key <AE04> { [ semicolon, 4 ] };
+ key <AE05> { [ colon, 5 ] };
+ key <AE06> { [ comma, 6 ] };
+ key <AE07> { [ period, 7 ] };
+ key <AE08> { [ underscore, 8 ] };
+ key <AE09> { [ question, 9 ] };
+ key <AE10> { [ percent, 0 ] };
+ key <BKSL> { [ parenleft, parenright ] };
+
+ key <AD12> { [Cyrillic_hardsign,Cyrillic_HARDSIGN ] };
+ key <AB10> { [ Cyrillic_io, Cyrillic_IO ] };
+};
+
+partial alphanumeric_keys
+xkb_symbols "phonetic" {
+
+ name[Group1]= "Russia - Phonetic";
+
+ key <AE01> { [ 1, exclam ] };
+ key <AE02> { [ 2, at ] };
+ key <AE03> { [ 3, Cyrillic_io ] };
+ key <AE04> { [ 4, Cyrillic_IO ] };
+ key <AE05> { [ 5, Cyrillic_hardsign ] };
+ key <AE06> { [ 6, Cyrillic_HARDSIGN ] };
+ key <AE07> { [ 7, ampersand ] };
+ key <AE08> { [ 8, asterisk ] };
+ key <AE09> { [ 9, parenleft ] };
+ key <AE10> { [ 0, parenright ] };
+ key <AE11> { [ minus, underscore ] };
+
+ key <AB09> { [ period, greater ] };
+ key <AB10> { [ slash, question ] };
+ key <AB08> { [ comma, less ] };
+ key <AC10> { [ semicolon, colon ] };
+ key <AC11> { [ apostrophe, quotedbl ] };
+ key <LSGT> { [ bar, brokenbar ] };
+
+ key <TLDE> { [ Cyrillic_yu, Cyrillic_YU ] };
+ key <LatQ> { [ Cyrillic_ya, Cyrillic_YA ] };
+ key <LatZ> { [ Cyrillic_ze, Cyrillic_ZE ] };
+ key <LatS> { [ Cyrillic_es, Cyrillic_ES ] };
+ key <LatA> { [ Cyrillic_a, Cyrillic_A ] };
+ key <LatW> { [ Cyrillic_ve, Cyrillic_VE ] };
+ key <LatC> { [ Cyrillic_tse, Cyrillic_TSE ] };
+ key <LatX> { [Cyrillic_softsign,Cyrillic_SOFTSIGN ] };
+ key <LatD> { [ Cyrillic_de, Cyrillic_DE ] };
+ key <LatE> { [ Cyrillic_ie, Cyrillic_IE ] };
+ key <LatV> { [ Cyrillic_zhe, Cyrillic_ZHE ] };
+ key <LatF> { [ Cyrillic_ef, Cyrillic_EF ] };
+ key <LatT> { [ Cyrillic_te, Cyrillic_TE ] };
+ key <LatR> { [ Cyrillic_er, Cyrillic_ER ] };
+ key <LatN> { [ Cyrillic_en, Cyrillic_EN ] };
+ key <LatB> { [ Cyrillic_be, Cyrillic_BE ] };
+ key <LatH> { [ Cyrillic_ha, Cyrillic_HA ] };
+ key <LatG> { [ Cyrillic_ghe, Cyrillic_GHE ] };
+ key <LatY> { [ Cyrillic_yeru, Cyrillic_YERU ] };
+ key <LatM> { [ Cyrillic_em, Cyrillic_EM ] };
+ key <LatJ> { [ Cyrillic_shorti, Cyrillic_SHORTI ] };
+ key <LatU> { [ Cyrillic_u, Cyrillic_U ] };
+ key <LatK> { [ Cyrillic_ka, Cyrillic_KA ] };
+ key <LatI> { [ Cyrillic_i, Cyrillic_I ] };
+ key <LatO> { [ Cyrillic_o, Cyrillic_O ] };
+ key <LatL> { [ Cyrillic_el, Cyrillic_EL ] };
+ key <LatP> { [ Cyrillic_pe, Cyrillic_PE ] };
+
+ key <AD11> { [ Cyrillic_sha, Cyrillic_SHA ] };
+ key <AE12> { [ Cyrillic_che, Cyrillic_CHE ] };
+ key <AD12> { [ Cyrillic_shcha, Cyrillic_SHCHA ] };
+ key <BKSL> { [ Cyrillic_e, Cyrillic_E ] };
+};
+
+partial alphanumeric_keys
+xkb_symbols "phonetic_winkeys" {
+
+ include "ru(phonetic)"
+ name[Group1]= "Russia - Phonetic Winkeys";
+
+ key <LatX> { [ Cyrillic_ha, Cyrillic_HA ] };
+ key <LatH> { [ Cyrillic_che, Cyrillic_CHE ] };
+ key <AE12> { [ Cyrillic_softsign, Cyrillic_softsign ] };
+
+};
+
+partial alphanumeric_keys
+xkb_symbols "tt" {
+ include "ru(winkeys)"
+ name[Group1]= "Russia - Tatar";
+
+ key.type[group1]="FOUR_LEVEL";
+
+ key <TLDE> { [ 0x010004bb, 0x010004ba,
+ Cyrillic_io, Cyrillic_IO ] };
+ key <AD02> { [ 0x010004e9, 0x010004e8,
+ Cyrillic_tse, Cyrillic_TSE ] };
+ key <AD09> { [ 0x010004d9, 0x010004d8,
+ Cyrillic_shcha, Cyrillic_SHCHA ] };
+ key <AD12> { [ 0x010004af, 0x010004ae,
+ Cyrillic_hardsign,Cyrillic_HARDSIGN ] };
+ key <AC10> { [ 0x010004a3, 0x010004a2,
+ Cyrillic_zhe, Cyrillic_ZHE ] };
+ key <AB07> { [ 0x01000497, 0x01000496,
+ Cyrillic_softsign,Cyrillic_SOFTSIGN ] };
+
+ include "level3(ralt_switch)"
+
+};
+
+partial alphanumeric_keys
+xkb_symbols "os_legacy" {
+ include "ru(common)"
+
+ name[Group1]= "Russia - Ossetian, legacy";
+
+ key <TLDE> { [ Cyrillic_e, Cyrillic_E ] };
+ key <AC07> { [ Cyrillic_o, Cyrillic_O, Cyrillic_io, Cyrillic_IO ] };
+ key <AC11> { [ 0x010004D5, 0x010004D4 ] };
+};
+
+partial alphanumeric_keys
+xkb_symbols "os_winkeys" {
+ include "ru(winkeys)"
+
+ name[Group1]= "Russia - Ossetian, Winkeys";
+
+ key <TLDE> { [ Cyrillic_e, Cyrillic_E ] };
+ key <AC07> { [ Cyrillic_o, Cyrillic_O, Cyrillic_io, Cyrillic_IO ] };
+ key <AC11> { [ 0x010004D5, 0x010004D4 ] };
+};
+
+partial alphanumeric_keys
+xkb_symbols "cv" {
+ include "ru(winkeys)"
+
+ name[Group1]= "Russia - Chuvash";
+
+ key.type[group1]="FOUR_LEVEL";
+
+ key <AD03> { [ Cyrillic_u, Cyrillic_U,
+ 0x010004f3, 0x010004f2 ] };
+ key <AD05> { [ Cyrillic_ie, Cyrillic_IE,
+ 0x01000115, 0x01000114 ] };
+ key <AC04> { [ Cyrillic_a, Cyrillic_A,
+ abreve, Abreve ] };
+ key <AB03> { [ Cyrillic_es, Cyrillic_ES,
+ ccedilla, Ccedilla ] };
+
+ include "level3(ralt_switch)"
+};
+
+partial alphanumeric_keys
+xkb_symbols "udm" {
+ include "ru(winkeys)"
+
+ name[Group1]= "Russia - Udmurt";
+
+ key.type[group1]="FOUR_LEVEL";
+
+ key <AE01> { [ question, exclam, 1, 1 ] };
+ key <AE02> { [ parenleft, quotedbl, 2, 2 ] };
+ key <AE03> { [ parenright, numerosign, 3, 3 ] };
+ key <AE04> { [ colon, semicolon, 4, 4 ] };
+ key <AE05> { [ asterisk, percent, 5, 5 ] };
+ key <AE06> { [ 0x010004dd, 0x010004dc, 6, 6 ] };
+ key <AE07> { [ 0x010004e7, 0x010004e6, 7, 7 ] };
+ key <AE08> { [ 0x010004f5, 0x010004f4, 8, 8 ] };
+ key <AE09> { [ 0x010004e5, 0x010004e4, 9, 9 ] };
+ key <AE10> { [ 0x010004df, 0x010004de, 0, 0 ] };
+
+ include "level3(ralt_switch)"
+};
+
+partial alphanumeric_keys
+xkb_symbols "cv_latin" {
+ include "us(alt-intl)"
+
+ name[Group1]= "Russia - Chuvash Latin";
+
+ key.type[group1]="FOUR_LEVEL";
+
+ key <AD01> { [ q, Q, 0x01000161, 0x01000160 ] };
+ key <AD02> { [ w, W, udiaeresis, Udiaeresis ] };
+ key <AD03> { [ e, E, 0x01000115, 0x01000114 ] };
+ key <AD07> { [ u, U, udiaeresis, Udiaeresis ] };
+ key <AD08> { [ i, I, 0x0100012d, 0x0100012c ] };
+ key <AD09> { [ o, O, odiaeresis, Odiaeresis ] };
+ key <AC01> { [ a, A, abreve, Abreve ] };
+ key <AC02> { [ s, S, scedilla, Scedilla ] };
+ key <AC05> { [ g, G, gbreve, Gbreve ] };
+ key <AC07> { [ j, J, 0x01000131, 0x01000130 ] };
+ key <AB03> { [ c, C, ccedilla, Ccedilla ] };
+
+ include "level3(ralt_switch)"
+
+};
+
+// Komi language layout
+// based on
+// russian standard keyboard
+// Vlad Shakhov <lumpen.intellectual@gmail.com>
+// Last Changes 2007/10/23 by Vlad Shakhov <lumpen.intellectual@gmail.com>
+
+partial alphanumeric_keys
+xkb_symbols "kom" {
+
+ include "ru(winkeys)"
+
+ name[Group1]= "Russia - Komi";
+
+ key.type[group1]="FOUR_LEVEL_ALPHABETIC";
+
+// cyrilllic o with diaeresis
+ key <AC07> { [ Cyrillic_o, Cyrillic_O,
+ U04E7, U04E6 ] };
+
+// hard I as additional key for soft Cyrillic_I
+ key <AB05> { [ Cyrillic_i, Cyrillic_I,
+ Ukrainian_i, Ukrainian_I ] };
+
+ include "level3(ralt_switch)"
+};
+
+// Yakut language layout
+// 2008/04/23 Yakov Aleksandrov <bertjickty@yandex.ru>
+// 2008/04/23 Anatoliy Zhozhikov <jav@sitc.ru>
+// 2008/04/23 Aleksandr Varlamov
+partial alphanumeric_keys
+xkb_symbols "sah" {
+
+ include "ru(winkeys)"
+
+ name[Group1]= "Russia - Yakut";
+
+ key.type[group1]="FOUR_LEVEL_ALPHABETIC";
+
+ key <TLDE> { [ Cyrillic_io, Cyrillic_IO,
+ U04EB, U04EA ] };
+ key <AD01> { [ Cyrillic_shorti, Cyrillic_SHORTI,
+ U048B, U048A ] };
+ key <AD03> { [ Cyrillic_u, Cyrillic_U,
+ Cyrillic_u_straight, Cyrillic_U_straight ] };
+ key <AD04> { [ Cyrillic_ka, Cyrillic_KA,
+ U04C4, U04C3 ] };
+ key <AD06> { [ Cyrillic_en, Cyrillic_EN,
+ U04A5, U04A4 ] };
+ key <AD07> { [ Cyrillic_ghe, Cyrillic_GHE,
+ U0495, U0494 ] };
+ key <AD10> { [ Cyrillic_ze, Cyrillic_ZE,
+ U04E1, U04E0 ] };
+ key <AD11> { [ Cyrillic_ha, Cyrillic_HA,
+ Cyrillic_shha, Cyrillic_SHHA ] };
+ key <AC07> { [ Cyrillic_o, Cyrillic_O,
+ Cyrillic_o_bar, Cyrillic_O_bar ] };
+ key <AC10> { [ Cyrillic_zhe, Cyrillic_ZHE,
+ U0461, U0460 ] };
+ key <AB02> { [ Cyrillic_che, Cyrillic_CHE,
+ Cyrillic_u_macron, Cyrillic_U_macron ] };
+ key <AB04> { [ Cyrillic_em, Cyrillic_EM,
+ U04C8, U04C7 ] };
+ key <AB05> { [ Cyrillic_i, Cyrillic_I,
+ Cyrillic_i_macron, Cyrillic_I_macron ] };
+
+ include "level3(ralt_switch)"
+};
+
+
+//Kalmyk language layout
+//based on the Kalmyk language layout: http://soft.oyrat.org/
+//Nikolay Korneev <halmg@oyrat.org>
+//Toli Miron <mirontoli@gmail.com>
+
+partial alphanumeric_keys
+xkb_symbols "xal" {
+ include "ru(winkeys)"
+
+ name[Group1]= "Russia - Kalmyk";
+
+ key.type[group1]="FOUR_LEVEL";
+
+ key <AE01> { [ question, exclam, 1 ] };
+ key <AE02> { [ numerosign, quotedbl, 2 ] };
+ key <AE03> { [ Cyrillic_u_straight, Cyrillic_U_straight, 3 ] };
+ key <AE04> { [ Cyrillic_schwa, Cyrillic_SCHWA, 4 ] };
+ key <AE05> { [ asterisk, percent, 5 ] };
+ key <AE06> { [ Cyrillic_en_descender, Cyrillic_EN_descender, 6 ] };
+ key <AE07> { [ Cyrillic_o_bar, Cyrillic_O_bar, 7 ] };
+ key <AE08> { [ Cyrillic_shha, Cyrillic_SHHA, 8 ] };
+ key <AE09> { [ Cyrillic_zhe_descender, Cyrillic_ZHE_descender, 9 ] };
+ key <AE10> { [ semicolon, colon, 0 ] };
+
+ key <TLDE> { [ parenleft, parenright, Cyrillic_io, Cyrillic_IO ] };
+
+ key <AD02> { [ Cyrillic_tse, Cyrillic_TSE, dollar ] };
+ key <AD03> { [ Cyrillic_u, Cyrillic_U, EuroSign ] };
+ key <AD04> { [ Cyrillic_ka, Cyrillic_KA, registered ] };
+ key <AD05> { [ Cyrillic_ie, Cyrillic_IE, trademark ] };
+ key <AD11> { [ Cyrillic_ha, Cyrillic_HA, bracketleft ] };
+ key <AD12> { [ Cyrillic_hardsign, Cyrillic_HARDSIGN, bracketright ] };
+ key <AC11> { [ Cyrillic_e, Cyrillic_E, apostrophe ] };
+ key <AB03> { [ Cyrillic_es, Cyrillic_ES, copyright ] };
+ key <AB08> { [ Cyrillic_be, Cyrillic_BE, less ] };
+ key <AB09> { [ Cyrillic_yu, Cyrillic_YU, greater ] };
+
+ include "level3(ralt_switch)"
+};
+
+partial alphanumeric_keys
+xkb_symbols "dos" {
+
+ include "ru(common)"
+
+ name[Group1]= "Russia - DOS";
+
+ key <TLDE> { [ parenright, parenleft ] };
+ key <AE04> { [ 4, currency ] };
+ key <AE09> { [ 9, question ] };
+ key <AE10> { [ 0, percent ] };
+
+ key <AB10> { [ Cyrillic_io, Cyrillic_IO ] };
+};
+
+partial alphanumeric_keys
+xkb_symbols "bak" {
+ include "ru(winkeys)"
+
+ name[Group1]= "Russia - Bashkirian";
+ key.type[group1]="FOUR_LEVEL";
+
+ key <TLDE> { [ 0x010004d9, 0x010004d8, Cyrillic_io, Cyrillic_IO ] };
+ key <AE01> { [ exclam, quotedbl, 1, 1 ] };
+ key <AE02> { [ 0x010004e9, 0x010004e8, 2, 2 ] };
+ key <AE03> { [ 0x010004a1, 0x010004a0, 3, 3 ] };
+ key <AE04> { [ 0x01000493, 0x01000492, 4, 4 ] };
+ key <AE05> { [ 0x010004ab, 0x010004aa, 5, 5 ] };
+ key <AE06> { [ colon, semicolon, 6, 6 ] };
+ key <AE07> { [ 0x01000499, 0x01000498, 7, 7 ] };
+ key <AE08> { [ 0x010004bb, 0x010004ba, 8, 8 ] };
+ key <AE09> { [ question, parenleft, 9, 9 ] };
+ key <AE10> { [ numerosign, parenright, 0, 0 ] };
+ key <AE11> { [ minus, percent, minus, underscore ]};
+ key <AE12> { [ 0x010004af, 0x010004ae, equal, plus ]};
+ key <BKSL> { [ 0x010004a3, 0x010004a2, backslash, slash ]};
+
+ include "level3(ralt_switch)"
+};
+
+// Serbian charecters added as third level symbols to Russian keyboard layout.
+
+partial alphanumeric_keys
+xkb_symbols "srp" {
+ include "ru(common)"
+ include "level3(ralt_switch)"
+
+ name[Group1]= "Russia - Serbian";
+
+ key <AE03> { [ 3, numerosign ] };
+ key <AE04> { [ 4, semicolon ] };
+ key <AE05> { [ 5, percent ] };
+ key <AE06> { [ 6, colon ] };
+ key <AE07> { [ 7, question ] };
+ key <AE08> { [ 8, asterisk ] };
+ key <AB10> { [ period, comma ] };
+ key <BKSL> { [ backslash, slash ] };
+ key <AD01> { [ Cyrillic_shorti, Cyrillic_SHORTI, U458, U408 ] };
+ key <AD06> { [ Cyrillic_en, Cyrillic_EN, U45A, U40A ] };
+ key <AC08> { [ Cyrillic_el, Cyrillic_EL, U459, U409 ] };
+ key <AC09> { [ Cyrillic_de, Cyrillic_DE, U45F, U40F ] };
+ key <AC10> { [ Cyrillic_zhe, Cyrillic_ZHE, U452, U402 ] };
+ key <AB02> { [ Cyrillic_che, Cyrillic_CHE, U45B, U40B ] };
+};
+
+// Mari language layout
+// based on Russian standard keyboard
+// http://www.marlamuter.ru/
+partial alphanumeric_keys
+xkb_symbols "chm" {
+ include "ru(common)"
+
+ name[Group1]= "Russia - Mari";
+
+ key.type[group1]="FOUR_LEVEL_ALPHABETIC";
+ key <AC04> { [ Cyrillic_a, Cyrillic_A, U04D3, U04D2 ] };
+ key <AD03> { [ Cyrillic_u, Cyrillic_U, U04F1, U04F0 ] };
+ key <AC02> { [ Cyrillic_ui, Cyrillic_UI, U04F9, U04F8 ] };
+ key <AD06> { [ Cyrillic_n, Cyrillic_N, U04A5, U04A4 ] };
+ key <AC11> { [ Cyrillic_e, Cyrillic_E, U04E9, U04E8 ] };
+ key <AC10> { [ Cyrillic_zh, Cyrillic_ZH, U04EB, U04EA ] };
+ key <AC01> { [ Cyrillic_f, Cyrillic_F, UF537, UF536 ] };
+
+ include "level3(ralt_switch)"
+};
diff --git a/xorg-server/xkeyboard-config/symbols/us b/xorg-server/xkeyboard-config/symbols/us
index 2d9523922..092fb747d 100644
--- a/xorg-server/xkeyboard-config/symbols/us
+++ b/xorg-server/xkeyboard-config/symbols/us
@@ -1,1194 +1,1196 @@
-// $XKeyboardConfig$
-
-//
-// $XdotOrg: xc/programs/xkbcomp/symbols/us,v 1.1.4.3 2004/03/05 13:41:33 eich Exp $
-// $XFree86: xc/programs/xkbcomp/symbols/us,v 1.6 2003/10/31 14:32:05 pascal Exp $
-
-default
-partial alphanumeric_keys modifier_keys
-xkb_symbols "basic" {
-
- name[Group1]= "USA";
-
- // Alphanumeric section
- key <TLDE> { [ grave, asciitilde ] };
- key <AE01> { [ 1, exclam ] };
- key <AE02> { [ 2, at ] };
- key <AE03> { [ 3, numbersign ] };
- key <AE04> { [ 4, dollar ] };
- key <AE05> { [ 5, percent ] };
- key <AE06> { [ 6, asciicircum ] };
- key <AE07> { [ 7, ampersand ] };
- key <AE08> { [ 8, asterisk ] };
- key <AE09> { [ 9, parenleft ] };
- key <AE10> { [ 0, parenright ] };
- key <AE11> { [ minus, underscore ] };
- key <AE12> { [ equal, plus ] };
-
- key <AD01> { [ q, Q ] };
- key <AD02> { [ w, W ] };
- key <AD03> { [ e, E ] };
- key <AD04> { [ r, R ] };
- key <AD05> { [ t, T ] };
- key <AD06> { [ y, Y ] };
- key <AD07> { [ u, U ] };
- key <AD08> { [ i, I ] };
- key <AD09> { [ o, O ] };
- key <AD10> { [ p, P ] };
- key <AD11> { [ bracketleft, braceleft ] };
- key <AD12> { [ bracketright, braceright ] };
-
- key <AC01> { [ a, A ] };
- key <AC02> { [ s, S ] };
- key <AC03> { [ d, D ] };
- key <AC04> { [ f, F ] };
- key <AC05> { [ g, G ] };
- key <AC06> { [ h, H ] };
- key <AC07> { [ j, J ] };
- key <AC08> { [ k, K ] };
- key <AC09> { [ l, L ] };
- key <AC10> { [ semicolon, colon ] };
- key <AC11> { [ apostrophe, quotedbl ] };
-
- key <AB01> { [ z, Z ] };
- key <AB02> { [ x, X ] };
- key <AB03> { [ c, C ] };
- key <AB04> { [ v, V ] };
- key <AB05> { [ b, B ] };
- key <AB06> { [ n, N ] };
- key <AB07> { [ m, M ] };
- key <AB08> { [ comma, less ] };
- key <AB09> { [ period, greater ] };
- key <AB10> { [ slash, question ] };
-
- key <BKSL> { [ backslash, bar ] };
- // End alphanumeric section
-};
-
-partial alphanumeric_keys
-xkb_symbols "euro" {
-
- name[Group1]= "USA - With EuroSign on 5";
-
- include "us(basic)"
-
- include "eurosign(5)"
-
- include "level3(ralt_switch)"
-};
-
-
-partial alphanumeric_keys
-xkb_symbols "intl" {
-
- name[Group1]= "USA - International (with dead keys)";
-
- include "us(basic)"
-
- // Alphanumeric section
- key <TLDE> { [dead_grave, dead_tilde, grave, asciitilde ] };
- key <AE01> { [ 1, exclam, exclamdown, onesuperior ] };
- key <AE02> { [ 2, at, twosuperior, dead_doubleacute ] };
- key <AE03> { [ 3, numbersign, threesuperior, dead_macron ] };
- key <AE04> { [ 4, dollar, currency, sterling ] };
- key <AE05> { [ 5, percent, EuroSign, dead_cedilla ] };
- key <AE06> { [ 6, dead_circumflex, onequarter, asciicircum ] };
- key <AE07> { [ 7, ampersand, onehalf, dead_horn ] };
- key <AE08> { [ 8, asterisk, threequarters, dead_ogonek ] };
- key <AE09> { [ 9, parenleft, leftsinglequotemark, dead_breve ] };
- key <AE10> { [ 0, parenright, rightsinglequotemark, dead_abovering ] };
- key <AE11> { [ minus, underscore, yen, dead_belowdot ] };
- key <AE12> { [ equal, plus, multiply, division ] };
-
- key <AD01> { [ q, Q, adiaeresis, Adiaeresis ] };
- key <AD02> { [ w, W, aring, Aring ] };
- key <AD03> { [ e, E, eacute, Eacute ] };
- key <AD04> { [ r, R, registered, registered ] };
- key <AD05> { [ t, T, thorn, THORN ] };
- key <AD06> { [ y, Y, udiaeresis, Udiaeresis ] };
- key <AD07> { [ u, U, uacute, Uacute ] };
- key <AD08> { [ i, I, iacute, Iacute ] };
- key <AD09> { [ o, O, oacute, Oacute ] };
- key <AD10> { [ p, P, odiaeresis, Odiaeresis ] };
- key <AD11> { [ bracketleft, braceleft, guillemotleft, leftdoublequotemark ] };
- key <AD12> { [bracketright, braceright, guillemotright, rightdoublequotemark ] };
-
- key <AC01> { [ a, A, aacute, Aacute ] };
- key <AC02> { [ s, S, ssharp, section ] };
- key <AC03> { [ d, D, eth, ETH ] };
- key <AC04> { [ f, F, f, F ] };
- key <AC05> { [ g, G, g, G ] };
- key <AC06> { [ h, H, h, H ] };
- key <AC07> { [ j, J, j, J ] };
- key <AC08> { [ k, K, oe, OE ] };
-
- key <AC09> { [ l, L, oslash, Ooblique ] };
- key <AC10> { [ semicolon, colon, paragraph, degree ] };
- key <AC11> { [dead_acute, dead_diaeresis, apostrophe, quotedbl ] };
-
- key <AB01> { [ z, Z, ae, AE ] };
- key <AB02> { [ x, X, x, X ] };
- key <AB03> { [ c, C, copyright, cent ] };
- key <AB04> { [ v, V, v, V ] };
- key <AB05> { [ b, B, b, B ] };
- key <AB06> { [ n, N, ntilde, Ntilde ] };
- key <AB07> { [ m, M, mu, mu ] };
- key <AB08> { [ comma, less, ccedilla, Ccedilla ] };
- key <AB09> { [ period, greater, dead_abovedot, dead_caron ] };
- key <AB10> { [ slash, question, questiondown, dead_hook ] };
- key <BKSL> { [ backslash, bar, notsign, brokenbar ] };
-
- include "level3(ralt_switch)"
-};
-
-// Based on symbols/us_intl keyboard map:
-// Dead-keys definition for a very simple US/ASCII layout.
-// by Conectiva (http://www.conectiva.com.br)
-// modified by Ricardo Y. Igarashi (iga@that.com.br)
-
-// Added the following deadkeys, to make it truly international:
-//
-// dead_macron: on AltGr-minus
-// dead_breve: on AltGr-parenleft
-// dead_abovedot: on AltGr-period
-// dead_abovering: on AltGr-0
-// dead_doubleacute: on AltGr-equal (as quotedbl is already used)
-// dead_caron: on AltGr-less (AltGr-shift-comma)
-// dead_cedilla: on AltGr-comma
-// dead_ogonek: on AltGr-semicolon
-// dead_belowdot: on AltGr-underscore (AltGr-shift-minus)
-// dead_hook: on AltGr-question
-// dead_horn: on AltGr-plus (AltGr-shift-equal)
-// dead_diaeresis: on AltGr-colon (Alt-shift-semicolon)
-//
-// those were already there:
-// dead_grave
-// dead_acute
-// dead_circumflex
-// dead_tilde
-// dead_diaeresis
-
-partial alphanumeric_keys
-xkb_symbols "alt-intl" {
-
- name[Group1]= "USA - Alternative international";
-
- include "us"
-
- key <TLDE> { [ dead_grave, dead_tilde, grave, asciitilde ] };
- key <AE05> { [ 5, percent, EuroSign ] };
- key <AE06> { [ 6, dead_circumflex, asciicircum, asciicircum ] };
- key <AE09> { [ 9, parenleft, leftsinglequotemark, dead_breve ] };
- key <AE10> { [ 0, parenright, rightsinglequotemark, dead_abovering ] };
- key <AE11> { [ minus, underscore, dead_macron, dead_belowdot ] };
- key <AE12> { [ equal, plus, dead_doubleacute, dead_horn ] };
-
- key <AD03> { [ e, E, EuroSign, cent ] };
-
- key <AC10> { [ semicolon, colon, dead_ogonek, dead_diaeresis ] };
- key <AC11> { [ dead_acute, dead_diaeresis, apostrophe, quotedbl ] };
-
- key <AB08> { [ comma, less, dead_cedilla, dead_caron ] };
- key <AB09> { [ period, greater, dead_abovedot, dead_circumflex ] };
- key <AB10> { [ slash, question, dead_hook, dead_hook ] };
-
- include "level3(ralt_switch)"
-};
-
-// based on a keyboard map from an 'xkb/symbols/dk' file
-//
-// $XFree86: xc/programs/xkbcomp/symbols/dvorak,v 1.5 2004/01/03 16:35:07 herrb Exp $
-
-partial alphanumeric_keys
-xkb_symbols "dvorak" {
-
- name[Group1]= "USA - Dvorak";
-
- // Alphanumeric section
-
- key <TLDE> { [ grave, asciitilde, dead_grave, dead_tilde ] };
-
- key <AE01> { [ 1, exclam ] };
- key <AE02> { [ 2, at ] };
- key <AE03> { [ 3, numbersign ] };
- key <AE04> { [ 4, dollar ] };
- key <AE05> { [ 5, percent ] };
- key <AE06> { [ 6, asciicircum, dead_circumflex, dead_circumflex ] };
- key <AE07> { [ 7, ampersand ] };
- key <AE08> { [ 8, asterisk ] };
- key <AE09> { [ 9, parenleft, dead_grave] };
- key <AE10> { [ 0, parenright ] };
- key <AE11> { [ bracketleft, braceleft ] };
- key <AE12> { [ bracketright, braceright, dead_tilde] };
-
- key <AD01> { [ apostrophe, quotedbl, dead_acute, dead_diaeresis ] };
- key <AD02> { [ comma, less, dead_cedilla, dead_caron ] };
- key <AD03> { [ period, greater, dead_abovedot, periodcentered ] };
- key <AD04> { [ p, P ] };
- key <AD05> { [ y, Y ] };
- key <AD06> { [ f, F ] };
- key <AD07> { [ g, G ] };
- key <AD08> { [ c, C ] };
- key <AD09> { [ r, R ] };
- key <AD10> { [ l, L ] };
- key <AD11> { [ slash, question ] };
- key <AD12> { [ equal, plus ] };
-
- key <AC01> { [ a, A ] };
- key <AC02> { [ o, O ] };
- key <AC03> { [ e, E ] };
- key <AC04> { [ u, U ] };
- key <AC05> { [ i, I ] };
- key <AC06> { [ d, D ] };
- key <AC07> { [ h, H ] };
- key <AC08> { [ t, T ] };
- key <AC09> { [ n, N ] };
- key <AC10> { [ s, S ] };
- key <AC11> { [ minus, underscore ] };
-
- key <AB01> { [ semicolon, colon, dead_ogonek, dead_doubleacute ] };
- key <AB02> { [ q, Q ] };
- key <AB03> { [ j, J ] };
- key <AB04> { [ k, K ] };
- key <AB05> { [ x, X ] };
- key <AB06> { [ b, B ] };
- key <AB07> { [ m, M ] };
- key <AB08> { [ w, W ] };
- key <AB09> { [ v, V ] };
- key <AB10> { [ z, Z ] };
-
- key <BKSL> { [ backslash, bar ] };
-};
-
-// Dvorak international with dead keys
-// Olivier Mehani (shtrom-xorg@ssji.net)
-// Reproduce the per-key mapping of us(intl) for the dvorak layout
-// aka "I just swapped my keys over"
-partial alphanumeric_keys
-xkb_symbols "dvorak-intl" {
-
- name[Group1]= "USA - Dvorak international (with dead keys)";
-
- include "us(dvorak)"
-
- key <TLDE> { [dead_grave, dead_tilde, grave, asciitilde ] };
-
- key <AE01> { [ 1, exclam, exclamdown, onesuperior ] };
- key <AE02> { [ 2, at, twosuperior, dead_doubleacute ] };
- key <AE03> { [ 3, numbersign, threesuperior, dead_macron ] };
- key <AE04> { [ 4, dollar, currency, sterling ] };
- key <AE05> { [ 5, percent, EuroSign, dead_cedilla ] };
- key <AE06> { [ 6, dead_circumflex, onequarter, asciicircum ] };
- key <AE07> { [ 7, ampersand, onehalf, dead_horn ] };
- key <AE08> { [ 8, asterisk, threequarters, dead_ogonek ] };
- key <AE09> { [ 9, parenleft, leftsinglequotemark, dead_breve ] };
- key <AE10> { [ 0, parenright, rightsinglequotemark, dead_abovering ] };
- key <AE11> { [ bracketleft, braceleft, guillemotleft, leftdoublequotemark ] };
- key <AE12> { [bracketright, braceright, guillemotright, rightdoublequotemark ] };
-
- key <AD01> { [dead_acute, dead_diaeresis, apostrophe, quotedbl ] };
- key <AD02> { [ comma, less, ccedilla, Ccedilla ] };
- key <AD03> { [ period, greater, dead_abovedot, dead_caron ] };
- key <AD04> { [ p, P, odiaeresis, Odiaeresis ] };
- key <AD05> { [ y, Y, udiaeresis, Udiaeresis ] };
- // key <AD06> { [ f, F ] };
- // key <AD07> { [ g, G ] };
- key <AD08> { [ c, C, copyright, cent ] };
- key <AD09> { [ r, R, registered, registered ] };
- key <AD10> { [ l, L, oslash, Ooblique ] };
- key <AD11> { [ slash, question, questiondown, dead_hook ] };
- // key <AD12> { [ equal, plus, multiply, division ] };
-
- key <AC01> { [ a, A, aacute, Aacute ] };
- key <AC02> { [ o, O, oacute, Oacute ] };
- key <AC03> { [ e, E, eacute, Eacute ] };
- key <AC04> { [ u, U, uacute, Uacute ] };
- key <AC05> { [ i, I, iacute, Iacute ] };
- key <AC06> { [ d, D, eth, ETH ] };
- // key <AC07> { [ h, H ] };
- key <AC08> { [ t, T, thorn, THORN ] };
- key <AC09> { [ n, N, ntilde, Ntilde ] };
- key <AC10> { [ s, S, ssharp, section ] };
- // key <AC11> { [ minus, underscore, yen, dead_belowdot ] };
-
- key <AB01> { [ semicolon, colon, paragraph, degree ] };
- key <AB02> { [ q, Q, adiaeresis, Adiaeresis ] };
- // key <AB03> { [ j, J ] };
- key <AB04> { [ k, K, oe, OE ] };
- // key <AB05> { [ x, X ] };
- // key <AB06> { [ b, B ] };
- key <AB07> { [ m, M, mu, mu ] };
- key <AB08> { [ w, W, aring, Aring ] };
- // key <AB09> { [ v, V ] };
- key <AB10> { [ z, Z, ae, AE ] };
-
- key <BKSL> { [ backslash, bar, notsign, brokenbar ] };
-
- include "level3(ralt_switch)"
-};
-
-// Dvorak international without dead keys
-// Stephane Magnenat (stephane at magnenat dot net, http://stephane.magnenat.net)
-// Based on information from http://www.poupinou.org/dvorak/index.html
-//
-// ` 1 2 3 4 5 6 7 8 9 0 [ ] \
-// €
-//
-// ' , . p y f g c r l / =
-// ä ê ë ü ç
-//
-// a o e u i d h t n s -
-// à ô é û î ß
-//
-// ; q j k x b m w v z
-// â ö è ù ï
-
-partial alphanumeric_keys
-xkb_symbols "dvorak-alt-intl" {
-
- name[Group1]= "USA - Dvorak alternative international (no dead keys)";
-
- include "us(dvorak)"
-
- key <AE04> { [ 4, dollar, EuroSign ] };
-
- key <AD02> { [ comma, less, adiaeresis, dead_caron ] };
- key <AD03> { [ period, greater, ecircumflex, periodcentered ] };
- key <AD04> { [ p, P, ediaeresis, dead_cedilla ] };
- key <AD05> { [ y, Y, udiaeresis ] };
- key <AD08> { [ c, C, ccedilla, dead_abovedot ] };
-
- key <AC01> { [ a, A, agrave ] };
- key <AC02> { [ o, O, ocircumflex ] };
- key <AC03> { [ e, E, eacute ] };
- key <AC04> { [ u, U, ucircumflex ] };
- key <AC05> { [ i, I, icircumflex ] };
- key <AC10> { [ s, S, ssharp ] };
-
- key <AB01> { [ semicolon, colon, acircumflex ] };
- key <AB02> { [ q, Q, odiaeresis, dead_ogonek ] };
- key <AB03> { [ j, J, egrave, dead_doubleacute ] };
- key <AB04> { [ k, K, ugrave ] };
- key <AB05> { [ x, X, idiaeresis ] };
-
- include "level3(ralt_switch)"
-};
-
-// Left and right handed dvorak layouts
-// by sqweek <sqweek@gmail.com> 2006-01-30
-// Based on the corresponding layouts in the console-tools package.
-partial alphanumeric_keys
-xkb_symbols "dvorak-l" {
-
- include "us(dvorak)"
- name[Group1]= "USA - Left handed Dvorak";
-
- key <AE01> { [ bracketleft, braceleft ] };
- key <AE02> { [ bracketright, braceright ] };
- key <AE03> { [ slash, question ] };
- key <AE04> { [ p, P ] };
- key <AE05> { [ f, F ] };
- key <AE06> { [ m, M ] };
- key <AE07> { [ l, L ] };
- key <AE08> { [ j, J ] };
- key <AE09> { [ 4, dollar ] };
- key <AE10> { [ 3, numbersign ] };
- key <AE11> { [ 2, at ] };
- key <AE12> { [ 1, exclam ] };
-
- key <AD01> { [ semicolon, colon ] };
- key <AD02> { [ q, Q ] };
- key <AD03> { [ b, B ] };
- key <AD04> { [ y, Y ] };
- key <AD05> { [ u, U ] };
- key <AD06> { [ r, R ] };
- key <AD07> { [ s, S ] };
- key <AD08> { [ o, O ] };
- key <AD09> { [ period, greater ] };
- key <AD10> { [ 6, asciicircum ] };
- key <AD11> { [ 5, percent ] };
- key <AD12> { [ equal, plus ] };
-
- key <AC01> { [ minus, underscore ] };
- key <AC02> { [ k, K ] };
- key <AC03> { [ c, C ] };
- key <AC04> { [ d, D ] };
- key <AC05> { [ t, T ] };
- key <AC06> { [ h, H ] };
- key <AC07> { [ e, E ] };
- key <AC08> { [ a, A ] };
- key <AC09> { [ z, Z ] };
- key <AC10> { [ 8, asterisk ] };
- key <AC11> { [ 7, ampersand ] };
-
- key <AB01> { [ apostrophe, quotedbl ] };
- key <AB02> { [ x, X ] };
- key <AB03> { [ g, G ] };
- key <AB04> { [ v, V ] };
- key <AB05> { [ w, W ] };
- key <AB06> { [ n, N ] };
- key <AB07> { [ i, I ] };
- key <AB08> { [ comma, less ] };
- key <AB09> { [ 0, parenright ] };
- key <AB10> { [ 9, parenleft ] };
-};
-
-partial alphanumeric_keys
-xkb_symbols "dvorak-r" {
-
- include "us(dvorak)"
- name[Group1]= "USA - Right handed Dvorak";
-
- key <AE01> { [ 1, exclam ] };
- key <AE02> { [ 2, at ] };
- key <AE03> { [ 3, numbersign ] };
- key <AE04> { [ 4, dollar ] };
- key <AE05> { [ j, J ] };
- key <AE06> { [ l, L ] };
- key <AE07> { [ m, M ] };
- key <AE08> { [ f, F ] };
- key <AE09> { [ p, P ] };
- key <AE10> { [ slash, question ] };
- key <AE11> { [ bracketleft, braceleft ] };
- key <AE12> { [ bracketright, braceright ] };
-
- key <AD01> { [ 5, percent ] };
- key <AD02> { [ 6, asciicircum ] };
- key <AD03> { [ q, Q ] };
- key <AD04> { [ period, greater ] };
- key <AD05> { [ o, O ] };
- key <AD06> { [ r, R ] };
- key <AD07> { [ s, S ] };
- key <AD08> { [ u, U ] };
- key <AD09> { [ y, Y ] };
- key <AD10> { [ b, B ] };
- key <AD11> { [ semicolon, colon ] };
- key <AD12> { [ equal, plus ] };
-
- key <AC01> { [ 7, ampersand ] };
- key <AC02> { [ 8, asterisk ] };
- key <AC03> { [ z, Z ] };
- key <AC04> { [ a, A ] };
- key <AC05> { [ e, E ] };
- key <AC06> { [ h, H ] };
- key <AC07> { [ t, T ] };
- key <AC08> { [ d, D ] };
- key <AC09> { [ c, C ] };
- key <AC10> { [ k, K ] };
- key <AC11> { [ minus, underscore ] };
-
- key <AB01> { [ 9, parenleft ] };
- key <AB02> { [ 0, parenright ] };
- key <AB03> { [ x, X ] };
- key <AB04> { [ comma, less ] };
- key <AB05> { [ i, I ] };
- key <AB06> { [ n, N ] };
- key <AB07> { [ w, W ] };
- key <AB08> { [ v, V ] };
- key <AB09> { [ g, G ] };
- key <AB10> { [ apostrophe, quotedbl ] };
-};
-
-// Classic dvorak layout
-// by Piter Punk <piterpk@terra.com.br> - 2006-07-06
-// Based on dvorak layout and e-mail from Russel L. Harris rlharris@oplink.net
-// on xorg list.
-partial alphanumeric_keys
-xkb_symbols "dvorak-classic" {
-
- name[Group1]= "USA - Classic Dvorak";
-
- // Alphanumeric section
-
- key <TLDE> { [ grave, asciitilde, dead_grave, dead_tilde ] };
-
- key <AE01> { [ bracketleft, braceleft ] };
- key <AE02> { [ 7, ampersand ] };
- key <AE03> { [ 5, percent ] };
- key <AE04> { [ 3, numbersign ] };
- key <AE05> { [ 1, exclam ] };
- key <AE06> { [ 9, parenleft, dead_grave] };
- key <AE07> { [ 0, parenright ] };
- key <AE08> { [ 2, at ] };
- key <AE09> { [ 4, dollar ] };
- key <AE10> { [ 6, asciicircum, dead_circumflex, dead_circumflex ] };
- key <AE11> { [ 8, asterisk ] };
- key <AE12> { [ bracketright, braceright, dead_tilde] };
-
- key <AD01> { [ slash, question ] };
- key <AD02> { [ comma, less, dead_cedilla, dead_caron ] };
- key <AD03> { [ period, greater, dead_abovedot, periodcentered ] };
- key <AD04> { [ p, P ] };
- key <AD05> { [ y, Y ] };
- key <AD06> { [ f, F ] };
- key <AD07> { [ g, G ] };
- key <AD08> { [ c, C ] };
- key <AD09> { [ r, R ] };
- key <AD10> { [ l, L ] };
- key <AD11> { [ apostrophe, quotedbl, dead_acute, dead_diaeresis ] };
- key <AD12> { [ equal, plus ] };
-
- key <AC01> { [ a, A ] };
- key <AC02> { [ o, O ] };
- key <AC03> { [ e, E ] };
- key <AC04> { [ u, U ] };
- key <AC05> { [ i, I ] };
- key <AC06> { [ d, D ] };
- key <AC07> { [ h, H ] };
- key <AC08> { [ t, T ] };
- key <AC09> { [ n, N ] };
- key <AC10> { [ s, S ] };
- key <AC11> { [ minus, underscore ] };
-
- key <AB01> { [ semicolon, colon, dead_ogonek, dead_doubleacute ] };
- key <AB02> { [ q, Q ] };
- key <AB03> { [ j, J ] };
- key <AB04> { [ k, K ] };
- key <AB05> { [ x, X ] };
- key <AB06> { [ b, B ] };
- key <AB07> { [ m, M ] };
- key <AB08> { [ w, W ] };
- key <AB09> { [ v, V ] };
- key <AB10> { [ z, Z ] };
- key <BKSL> { [ backslash, bar ] };
-};
-
-// Programmer Dvorak, by Roland Kaufmann <rlndkfmn at gmail dot com>
-// License: BSD, available at <http://www.kaufmann.no/roland/dvorak/license.html>
-// Main features: Numbers are in shift position (like French), symbols have been
-// placed in locations that give good hand-alternation and finger rolling with
-// symbols that usually follows, accented characters are possible for I18N.
-partial alphanumeric_keys
-xkb_symbols "dvp" {
- include "us(dvorak)"
-
- name[Group1] = "USA - Programmer Dvorak";
-
- // Unmodified Shift AltGr Shift+AltGr
- // symbols row, left side
- key <TLDE> { [ dollar, asciitilde, dead_tilde ] };
- key <AE01> { [ ampersand, percent ] };
- key <AE02> { [ bracketleft, 7, currency ], type[Group1] = "FOUR_LEVEL_ALPHABETIC" };
- key <AE03> { [ braceleft, 5, cent ], type[Group1] = "FOUR_LEVEL_ALPHABETIC" };
- key <AE04> { [ braceright, 3, yen ], type[Group1] = "FOUR_LEVEL_ALPHABETIC" };
- key <AE05> { [ parenleft, 1, EuroSign ], type[Group1] = "FOUR_LEVEL_ALPHABETIC" };
- key <AE06> { [ equal, 9, sterling ], type[Group1] = "FOUR_LEVEL_ALPHABETIC" };
-
- // symbols row, right side
- key <AE07> { [ asterisk, 0 ], type[Group1] = "FOUR_LEVEL_ALPHABETIC" };
- key <AE08> { [ parenright, 2, onehalf ], type[Group1] = "FOUR_LEVEL_ALPHABETIC" };
- key <AE09> { [ plus, 4 ], type[Group1] = "FOUR_LEVEL_ALPHABETIC" };
- key <AE10> { [ bracketright, 6 ], type[Group1] = "FOUR_LEVEL_ALPHABETIC" };
- key <AE11> { [ exclam, 8, exclamdown ], type[Group1] = "FOUR_LEVEL_ALPHABETIC" };
- key <AE12> { [ numbersign, grave, dead_grave ] };
- key <BKSP> { [ BackSpace ] };
-
- // upper row, left side
- key <AD01> { [ semicolon, colon, dead_diaeresis ] };
- key <AD02> { [ comma, less, guillemotleft ] };
- key <AD03> { [ period, greater, guillemotright ] };
- key <AD04> { [ p, P, paragraph, section ] };
- key <AD05> { [ y, Y, udiaeresis, Udiaeresis ] };
-
- // upper row, right side
- key <AD08> { [ c, C, ccedilla, Ccedilla ] };
- key <AD09> { [ r, R, registered, trademark ] };
- key <AD11> { [ slash, question, questiondown ] };
- key <AD12> { [ at, asciicircum, dead_circumflex, dead_caron ] };
-
- // home row, left side
- key <AC01> { [ a, A, aring, Aring ] };
- key <AC02> { [ o, O, oslash, Ooblique ] };
- key <AC03> { [ e, E, ae, AE ] };
- key <AC04> { [ u, U, eacute, Eacute ] };
-
- // home row, right side
- key <AC06> { [ d, D, eth, ETH ] };
- key <AC07> { [ h, H, dead_acute ] };
- key <AC08> { [ t, T, thorn, THORN ] };
- key <AC09> { [ n, N, ntilde, Ntilde ] };
- key <AC10> { [ s, S, ssharp ] };
- key <AC11> { [ minus, underscore, hyphen ], type[Group1] = "FOUR_LEVEL_ALPHABETIC" };
- key <BKSL> { [ backslash, bar ] };
-
- // lower row, left side
- key <AB01> { [ apostrophe, quotedbl, dead_acute ] };
-};
-
-// phonetic layout for Russian letters on an US keyboard
-// by Ivan Popov <pin@konvalo.org> 2005-07-17
-
-// level3 modifier is a shortcut to the "us" meaning of the keys where
-// we place cyrillic letters, handy for accessing the corresponding
-// punctuation marks.
-// It is important to have access to punctuation marks, and the rest of
-// alphabetical keys are added for being consequent so that the users
-// can expect the level3 modifier to give what the key label shows.
-
-partial alphanumeric_keys
-xkb_symbols "rus" {
-
- name[Group1]= "USA - Russian phonetic";
-
- include "us(basic)"
-
-key.type[group1]="FOUR_LEVEL_ALPHABETIC";
-
- key <LatA> { [ Cyrillic_a, Cyrillic_A ] };
- key <LatB> { [ Cyrillic_be, Cyrillic_BE ] };
- key <LatW> { [ Cyrillic_ve, Cyrillic_VE ] };
- key <LatG> { [ Cyrillic_ghe, Cyrillic_GHE ] };
- key <LatD> { [ Cyrillic_de, Cyrillic_DE ] };
- key <LatE> { [ Cyrillic_ie, Cyrillic_IE ] };
- key <TLDE> { [ Cyrillic_io, Cyrillic_IO, grave, asciitilde ] };
- key <LatV> { [ Cyrillic_zhe, Cyrillic_ZHE ] };
- key <LatZ> { [ Cyrillic_ze, Cyrillic_ZE ] };
- key <LatI> { [ Cyrillic_i, Cyrillic_I ] };
- key <LatJ> { [ Cyrillic_shorti, Cyrillic_SHORTI ] };
- key <LatK> { [ Cyrillic_ka, Cyrillic_KA ] };
- key <LatL> { [ Cyrillic_el, Cyrillic_EL ] };
- key <LatM> { [ Cyrillic_em, Cyrillic_EM ] };
- key <LatN> { [ Cyrillic_en, Cyrillic_EN ] };
- key <LatO> { [ Cyrillic_o, Cyrillic_O ] };
- key <LatP> { [ Cyrillic_pe, Cyrillic_PE ] };
- key <LatR> { [ Cyrillic_er, Cyrillic_ER ] };
- key <LatS> { [ Cyrillic_es, Cyrillic_ES ] };
- key <LatT> { [ Cyrillic_te, Cyrillic_TE ] };
- key <LatU> { [ Cyrillic_u, Cyrillic_U ] };
- key <LatF> { [ Cyrillic_ef, Cyrillic_EF ] };
- key <LatH> { [ Cyrillic_ha, Cyrillic_HA ] };
- key <LatC> { [ Cyrillic_tse, Cyrillic_TSE ] };
- key <AC10> { [ Cyrillic_che, Cyrillic_CHE, semicolon, colon ] };
- key <AD11> { [ Cyrillic_sha, Cyrillic_SHA, bracketleft, braceleft] };
- key <AD12> { [ Cyrillic_shcha, Cyrillic_SHCHA, bracketright, braceright ] };
- key <AE12> { [ Cyrillic_hardsign, Cyrillic_HARDSIGN, equal, plus ] };
- key <LatY> { [ Cyrillic_yeru, Cyrillic_YERU ] };
- key <LatX> { [ Cyrillic_softsign, Cyrillic_SOFTSIGN ] };
- key <BKSL> { [ Cyrillic_e, Cyrillic_E, backslash, bar ] };
- key <AC11> { [ Cyrillic_yu, Cyrillic_YU, apostrophe, quotedbl ] };
- key <LatQ> { [ Cyrillic_ya, Cyrillic_YA ] };
-
- include "level3(ralt_switch)"
-};
-
-partial alphanumeric_keys
-xkb_symbols "mac" {
-
- include "us(basic)"
- name[Group1]= "USA - Macintosh";
- key.type[group1]="FOUR_LEVEL";
-
- // Slightly improvised from http://homepage.mac.com/thgewecke/kblayout.jpg
- key <LSGT> { [ section, plusminus, section, plusminus ] };
- key <TLDE> { [ grave, asciitilde, dead_grave, dead_horn ] };
- key <AE01> { [ 1, exclam, exclamdown, U2044 ] };
- key <AE02> { [ 2, at, trademark, EuroSign ] };
- key <AE03> { [ 3, numbersign, sterling, U2039 ] };
- key <AE04> { [ 4, dollar, cent, U203A ] };
- key <AE05> { [ 5, percent, infinity, UFB01 ] };
- key <AE06> { [ 6,asciicircum, section, UFB02 ] };
- key <AE07> { [ 7, ampersand, paragraph, doubledagger ] };
- key <AE08> { [ 8, asterisk, enfilledcircbullet, degree ] };
- key <AE09> { [ 9, parenleft, ordfeminine, periodcentered ] };
- key <AE10> { [ 0, parenright, masculine,singlelowquotemark] };
- key <AE11> { [ minus, underscore, endash, emdash ] };
- key <AE12> { [ equal, plus, notequal, plusminus ] };
-
- key <AD01> { [ q, Q, oe, OE ] };
- key <AD02> { [ w, W, U2211,doublelowquotemark] };
- key <AD03> { [ e, E, dead_acute, acute ] };
- key <AD04> { [ r, R, registered, U2030 ] };
- key <AD05> { [ t, T, dagger, dead_caron ] };
- key <AD06> { [ y, Y, yen, onequarter ] };
- key <AD07> { [ u, U, dead_diaeresis, diaeresis ] };
- key <AD08> { [ i, I, dead_circumflex, U02C6 ] };
- key <AD09> { [ o, O, oslash, Ooblique ] };
- key <AD10> { [ p, P, Greek_pi, U220F ] };
- key <AD11> { [ bracketleft, braceleft, leftdoublequotemark, rightdoublequotemark ] };
- key <AD12> { [bracketright, braceright, leftsinglequotemark, rightsinglequotemark ] };
- key <BKSL> { [ backslash, bar, guillemotleft, guillemotright ] };
-
- key <AC01> { [ a, A, aring, Aring ] };
- key <AC02> { [ s, S, ssharp, dead_stroke ] };
- key <AC03> { [ d, D, partialderivative, eth ] };
- key <AC04> { [ f, F, function, dead_hook ] };
- key <AC05> { [ g, G, copyright, dead_doubleacute ] };
- key <AC06> { [ h, H, dead_abovedot, dead_belowdot ] };
- key <AC07> { [ j, J, U2206, onehalf ] };
- key <AC08> { [ k, K,dead_abovering, UF8FF ] };
-
- key <AC09> { [ l, L, notsign, THORN ] };
- key <AC10> { [ semicolon, colon, U2026, thorn ] };
- key <AC11> { [apostrophe, quotedbl, ae, AE ] };
-
- key <AB01> { [ z, Z, Greek_OMEGA, dead_cedilla ] };
- key <AB02> { [ x, X, U2248, dead_ogonek ] };
- // unclear whether "approxeq" is 2248 or 2245
- key <AB03> { [ c, C, ccedilla, Ccedilla ] };
- key <AB04> { [ v, V, squareroot, U25CA ] };
- key <AB05> { [ b, B, integral, idotless ] };
- key <AB06> { [ n, N, dead_tilde, U02DC ] };
- key <AB07> { [ m, M, mu, threequarters ] };
- key <AB08> { [ comma, less, lessthanequal, dead_macron ] };
- key <AB09> { [ period, greater, greaterthanequal, dead_breve ] };
- key <AB10> { [ slash, question, division, questiondown ] };
-
- include "level3(ralt_switch)"
-};
-
-// Colemak symbols for xkb on X.Org Server 7.x
-// 2006-01-01 Shai Coleman, http://colemak.com/ . Public domain.
-
-partial alphanumeric_keys
-xkb_symbols "colemak" {
- include "us"
- name[Group1]= "USA - Colemak";
-
- // Alphanumeric section
- key <TLDE> { [ grave, asciitilde, dead_tilde, asciitilde ] };
- key <AE01> { [ 1, exclam, exclamdown, onesuperior ] };
- key <AE02> { [ 2, at, masculine, twosuperior ] };
- key <AE03> { [ 3, numbersign, ordfeminine, threesuperior ] };
- key <AE04> { [ 4, dollar, cent, sterling ] };
- key <AE05> { [ 5, percent, EuroSign, yen ] };
- key <AE06> { [ 6, asciicircum, hstroke, Hstroke ] };
- key <AE07> { [ 7, ampersand, eth, ETH ] };
- key <AE08> { [ 8, asterisk, thorn, THORN ] };
- key <AE09> { [ 9, parenleft, leftsinglequotemark, leftdoublequotemark ] };
- key <AE10> { [ 0, parenright, rightsinglequotemark, rightdoublequotemark ] };
- key <AE11> { [ minus, underscore, endash, emdash ] };
- key <AE12> { [ equal, plus, multiply, division ] };
-
- key <AD01> { [ q, Q, adiaeresis, Adiaeresis ] };
- key <AD02> { [ w, W, aring, Aring ] };
- key <AD03> { [ f, F, atilde, Atilde ] };
- key <AD04> { [ p, P, oslash, Ooblique ] };
- key <AD05> { [ g, G, dead_ogonek, asciitilde ] };
- key <AD06> { [ j, J, dstroke, Dstroke ] };
- key <AD07> { [ l, L, lstroke, Lstroke ] };
- key <AD08> { [ u, U, uacute, Uacute ] };
- key <AD09> { [ y, Y, udiaeresis, Udiaeresis ] };
- key <AD10> { [ semicolon, colon, odiaeresis, Odiaeresis ] };
- key <AD11> { [ bracketleft, braceleft, guillemotleft, 0x1002039 ] };
- key <AD12> { [ bracketright, braceright, guillemotright, 0x100203a ] };
- key <BKSL> { [ backslash, bar, asciitilde, asciitilde ] };
-
- key <AC01> { [ a, A, aacute, Aacute ] };
- key <AC02> { [ r, R, dead_grave, asciitilde ] };
- key <AC03> { [ s, S, ssharp, asciitilde ] };
- key <AC04> { [ t, T, dead_acute, dead_doubleacute ] };
- key <AC05> { [ d, D, dead_diaeresis, asciitilde ] };
- key <AC06> { [ h, H, dead_caron, asciitilde ] };
- key <AC07> { [ n, N, ntilde, Ntilde ] };
- key <AC08> { [ e, E, eacute, Eacute ] };
- key <AC09> { [ i, I, iacute, Iacute ] };
- key <AC10> { [ o, O, oacute, Oacute ] };
- key <AC11> { [ apostrophe, quotedbl, otilde, Otilde ] };
-
- key <AB01> { [ z, Z, ae, AE ] };
- key <AB02> { [ x, X, dead_circumflex, asciitilde ] };
- key <AB03> { [ c, C, ccedilla, Ccedilla ] };
- key <AB04> { [ v, V, oe, OE ] };
- key <AB05> { [ b, B, dead_breve, asciitilde ] };
- key <AB06> { [ k, K, dead_abovering, asciitilde ] };
- key <AB07> { [ m, M, dead_macron, asciitilde ] };
- key <AB08> { [ comma, less, dead_cedilla, asciitilde ] };
- key <AB09> { [ period, greater, dead_abovedot, asciitilde ] };
- key <AB10> { [ slash, question, questiondown, asciitilde ] };
-
- key <CAPS> { [ BackSpace, BackSpace, BackSpace, BackSpace ] };
- key <LSGT> { [ minus, underscore, endash, emdash ] };
- key <SPCE> { [ space, space, space, nobreakspace ] };
-
- include "level3(ralt_switch)"
-};
-
-// I do NOT like dead-keys - the International keyboard as defined by Microsoft
-// doesn't fit my needs. Why use two keystrokes for all simple characters (eg '
-// and <space> generates a single ') just to have an é (eacute) in two strokes
-// as well? I type ' more often than é (eacute).
-//
-// This file works just like a regular keyboard, BUT has all dead-keys
-// accessible at level3 (through AltGr). An ë (ediaeresis) is now: AltGr+"
-// followed by an e. In other words, this keyboard is not international as long
-// as you leave the right Alt key alone.
-//
-// The original MS International keyboard was intended for Latin1 (iso8859-1).
-// With the introduction of iso8859-15, the (important) ligature oe (and OE)
-// became available. I added them next to ae. Because I write ediaeresis more
-// often than registered, I moved registered to be next to copyright and added
-// ediaeresis and idiaeresis. - Adriaan
-
-partial alphanumeric_keys
-xkb_symbols "altgr-intl" {
-
- name[Group1]= "USA - International (AltGr dead keys)";
-
- include "us(intl)"
-
-// five dead keys moved into level3:
-
- key <TLDE> { [ grave, asciitilde, dead_grave, dead_tilde ] };
- key <AC11> { [apostrophe,quotedbl, dead_acute, dead_diaeresis ] };
-
-// diversions from the MS Intl keyboard:
-
- key <AE01> { [ 1, exclam, onesuperior, exclamdown ] };
- key <AD04> { [ r, R, ediaeresis, Ediaeresis ] };
- key <AC07> { [ j, J, idiaeresis, Idiaeresis ] };
- key <AB02> { [ x, X, oe, OE ] };
- key <AB04> { [ v, V, registered, registered ] };
-
-// onequarter etc (not in iso8859-15) moved to get three unshifted deadkeys:
-
- key <AE06> { [ 6, asciicircum, dead_circumflex, onequarter ] };
- key <AE07> { [ 7, ampersand, dead_horn, onehalf ] };
- key <AE08> { [ 8, asterisk, dead_ogonek, threequarters ] };
-
- include "level3(ralt_switch)"
-};
-
-// Intel ClassmatePC Keyboard Layout
-// by Piter PUNK <piterpk@terra.com.br>
-//
-// The keyboard layouts below maps the us(basic), us(intl) and us(alt-intl)
-// to ClassmatePC keyboard. All layouts uses RCTL as level3(switch) since
-// the keyboard doesn't have AltGr key. The EuroSign is engraved at 5 key.
-
-// classmate - us(basic)
-partial alphanumeric_keys
-xkb_symbols "classmate" {
- include "us(basic)"
- name[Group1]= "USA - ClassmatePC";
-
- key <LSGT> { [ backslash, bar, backslash, bar ] };
-
- include "eurosign(5)"
- include "level3(switch)"
-};
-
-// classmate-intl - us(intl)
-// RCTL is generated by Fn+Alt, because that, when trying to access
-// the level3 symbols at 7,8,9,0,u,i,o,p,j,k,l,;,m,. and / we got
-// the keypad keycodes. The keypad is changed to make Fn+Alt+<KP_key>
-// generate the same symbol as the original key.
-partial alphanumeric_keys
-xkb_symbols "classmate-intl" {
- include "us(intl)"
- name[Group1]= "USA - ClassmatePC (International)";
- key.type[Group1]="FOUR_LEVEL";
-
- key <LSGT> { [ backslash, bar, backslash, bar ] };
-
- key <KP7> { [ KP_Home, KP_7,
- onehalf, dead_horn ] };
- key <KP8> { [ KP_Up, KP_8,
- threequarters, dead_ogonek ] };
- key <KP9> { [ KP_Prior, KP_9,
- leftsinglequotemark, dead_breve ] };
- key <KPMU> { [ KP_Multiply, KP_Multiply,
- rightsinglequotemark, dead_abovering ] };
-
- key <KP4> { [ KP_Left, KP_4,
- uacute, Uacute ] };
- key <KP5> { [ KP_Begin, KP_5,
- iacute, Iacute ] };
- key <KP6> { [ KP_Right, KP_6,
- oacute, Oacute ] };
- key <KPSU> { [ KP_Subtract, KP_Subtract,
- odiaeresis, Odiaeresis ] };
-
- key <KP2> { [ KP_Down, KP_2,
- oe, OE ] };
- key <KP3> { [ KP_Next, KP_3,
- oslash, Ooblique ] };
- key <KPAD> { [ KP_Add, KP_Add,
- paragraph, degree ] };
-
- key <KP0> { [ KP_Insert, KP_0,
- mu, mu ] };
- key <KPDL> { [ KP_Delete, KP_Decimal,
- dead_abovedot, dead_caron ] };
- key <KPDV> { [ KP_Divide, KP_Divide,
- questiondown, dead_hook ] };
-
- include "level3(switch)"
-};
-
-// classmate-alt-intl - us(alt-intl)
-// RCTL is generated by Fn+Alt, because that, when trying to access
-// the level3 symbols at 7,8,9,0,u,i,o,p,j,k,l,;,m,. and / we got
-// the keypad keycodes. The keypad is changed to make Fn+Alt+<KP_key>
-// generate the same symbol as the original key.
-partial alphanumeric_keys
-xkb_symbols "classmate-alt-intl" {
- include "us(alt-intl)"
- name[Group1]= "USA - ClassmatePC (Alternative international)";
- key.type[Group1]="FOUR_LEVEL";
-
- key <LSGT> { [ backslash, bar, backslash, bar ] };
-
- key <KPSU> { [ KP_Subtract, KP_Subtract ] };
-
- key <KP9> { [ KP_Prior, KP_9,
- leftsinglequotemark, dead_breve ] };
- key <KPMU> { [ KP_Multiply, KP_Multiply,
- rightsinglequotemark, dead_abovering ] };
-
- key <KPAD> { [ KP_Add, KP_Add,
- dead_ogonek, dead_diaeresis ] };
-
- key <KPDL> { [ KP_Delete, KP_Decimal,
- dead_abovedot, dead_circumflex ] };
- key <KPDV> { [ KP_Divide, KP_Divide,
- dead_hook, dead_hook ] };
-
- include "level3(switch)"
-};
-
-// classmate-altgr-intl - us(altgr-intl)
-// RCTL is generated by Fn+Alt, because that, when trying to access
-// the level3 symbols at 7,8,9,0,u,i,o,p,j,k,l,;,m,. and / we got
-// the keypad keycodes. The keypad is changed to make Fn+Alt+<KP_key>
-// generate the same symbol as the original key.
-partial alphanumeric_keys
-xkb_symbols "classmate-altgr-intl" {
- include "us(altgr-intl)"
- name[Group1]= "USA - ClassmatePC (International Fn+Alt dead-keys)";
- key.type[Group1]="FOUR_LEVEL";
-
- key <LSGT> { [ backslash, bar, backslash, bar ] };
-
- key <KP7> { [ KP_Home, KP_7,
- dead_horn, dead_horn ] };
- key <KP8> { [ KP_Up, KP_8,
- dead_ogonek, dead_ogonek ] };
- key <KP9> { [ KP_Prior, KP_9,
- leftsinglequotemark, dead_breve ] };
- key <KPMU> { [ KP_Multiply, KP_Multiply,
- rightsinglequotemark, dead_abovering ] };
-
- key <KP4> { [ KP_Left, KP_4,
- uacute, Uacute ] };
- key <KP5> { [ KP_Begin, KP_5,
- iacute, Iacute ] };
- key <KP6> { [ KP_Right, KP_6,
- oacute, Oacute ] };
- key <KPSU> { [ KP_Subtract, KP_Subtract,
- odiaeresis, Odiaeresis ] };
-
- key <KP1> { [ KP_End, KP_1,
- idiaeresis, Idiaeresis ] };
- key <KP2> { [ KP_Down, KP_2,
- oe, OE ] };
- key <KP3> { [ KP_Next, KP_3,
- oslash, Ooblique ] };
- key <KPAD> { [ KP_Add, KP_Add,
- paragraph, degree ] };
-
- key <KP0> { [ KP_Insert, KP_0,
- mu, mu ] };
- key <KPDL> { [ KP_Delete, KP_Decimal,
- dead_abovedot, dead_caron ] };
- key <KPDV> { [ KP_Divide, KP_Divide,
- questiondown, dead_hook ] };
-
- include "level3(switch)"
-};
-
-partial alphanumeric_keys
-xkb_symbols "olpc" {
-
- include "us(basic)"
- name[Group1]= "USA";
-
- // OLPC international US English keyboard layout.
- // It's a little different from the usual international layout.
- // See: http://wiki.laptop.org/go/Image:Keyboard_english.png
-
- key <TLDE> { [ grave, asciitilde, dead_grave, dead_tilde ] };
- key <AE01> { [ 1, exclam, exclamdown, exclamdown ] };
- key <AE02> { [ 2, at, notsign, notsign ] };
- key <AE03> { [ 3, numbersign, 0x1000300, 0x1000300 ] }; // combining grave
- key <AE04> { [ 4, dollar, 0x1000301, 0x1000301 ] }; // combining acute
- key <AE05> { [ 5, percent, 0x1000306, 0x1000306 ] }; // combining breve above
- key <AE06> { [ 6,asciicircum, 0x100030A, 0x100030A ] }; // combining ring above
- key <AE07> { [ 7, ampersand, 0x1000302, 0x1000302 ] }; // combining circumflex above
- key <AE08> { [ 8, asterisk, 0x100030C, 0x100030C ] }; // combining caron above
- key <AE09> { [ 9, parenleft, 0x1000307, 0x1000307 ] }; // combining dot above
- key <AE10> { [ 0, parenright, 0x1000308, 0x1000308 ] }; // combining diaeresis above
- key <AE11> { [ minus, underscore, 0x1000304, 0x1000304 ] }; // combining macron above
- key <AE12> { [ equal, plus, 0x1000303, 0x1000303 ] }; // combining tilde above
-
- key <AD01> { [ q, Q, Greek_omega, Greek_OMEGA ] };
- key <AD02> { [ w, W, oslash, Oslash ] };
- key <AD03> { [ e, E, oe, OE ] };
- key <AD04> { [ r, R, 0x1000327, 0x1000327 ] }; // combining cedilla
- key <AD05> { [ t, T, 0x100032E, 0x100032E ] }; // combining breve below
- key <AD06> { [ y, Y, 0x1000325, 0x1000325 ] }; // combining ring below
- key <AD07> { [ u, U, 0x100032D, 0x100032D ] }; // combining circumflex below
- key <AD08> { [ i, I, 0x100032C, 0x100032C ] }; // combining caron below
- key <AD09> { [ o, O, 0x1000323, 0x1000323 ] }; // combining dot below
- key <AD10> { [ p, P, 0x1000324, 0x1000324 ] }; // combining diaeresis below
- key <AD11> { [ bracketleft, braceleft, 0x1000331, 0x1000331 ] }; // combining macron below
- key <AD12> { [bracketright, braceright, 0x1000330, 0x1000330 ] }; // combining tilde below
-
- key <AC01> { [ a, A, ae, AE ] };
- key <AC02> { [ s, S, ssharp, 0x1001E9C ] }; // uppercase S sharp
- key <AC03> { [ d, D, eth, ETH ] };
- key <AC04> { [ f, F, thorn, THORN ] };
- key <AC06> { [ h, H, sterling, sterling ] };
- key <AC07> { [ j, J, EuroSign, EuroSign ] };
- key <AC10> { [ semicolon, colon, masculine, ordfeminine ] };
- key <AC11> { [ apostrophe, quotedbl, currency, currency ] };
- key <BKSL> { [ backslash, bar, section, section ] };
-
- key <AB03> { [ c, C, ccedilla, Ccedilla ] };
- key <AB06> { [ n, N, ntilde, Ntilde ] };
- key <AB07> { [ m, M, mu, mu ] };
- key <AB08> { [ comma, less, guillemotleft, guillemotleft ] };
- key <AB09> { [ period, greater, guillemotright, guillemotright ] };
- key <AB10> { [ slash, question, questiondown, questiondown ] };
-
- key <I219> { [ multiply, division, ISO_Next_Group, ISO_Prev_Group ] };
-
- include "level3(ralt_switch)"
-};
-
-partial alphanumeric_keys
-xkb_symbols "olpc2" {
- include "us(olpc)"
- name[Group1]= "USA - Layout toggle on multiply/divide key";
- include "group(olpc)"
-};
-
-// Based on Cherokee Nation Official Layout
-// http://www.cherokee.org/extras/downloads/font/Keyboard.htm
-
-partial alphanumeric_keys modifier_keys
-xkb_symbols "chr" {
-
- name[Group1]= "USA - Cherokee";
- key.type[group1]="ALPHABETIC";
-
- // Alphanumeric section
- key <TLDE> { [ grave, U13CA ] };
- key <AE01> { [ 1, U13B1 ] };
- key <AE02> { [ 2, U13C7 ] };
- key <AE03> { [ 3, U13E7 ] };
- key <AE04> { [ U13D9, U13B0 ] };
- key <AE05> { [ U13E6, U13B9 ] };
- key <AE06> { [ U13DC, U13DD ] };
- key <AE07> { [ U13CB, U13E1 ] };
- key <AE08> { [ U13D6, U13BA ] };
- key <AE09> { [ U13D2, parenleft ] };
- key <AE10> { [ U13C4, parenright ] };
- key <AE11> { [ U13BF, U13BC ] };
- key <AE12> { [ U13F3, U13BD ] };
-
- key <AD01> { [ U13AA, U13C6 ] };
- key <AD02> { [ U13B3, U13EB ] };
- key <AD03> { [ U13A1, U13E3 ] };
- key <AD04> { [ U13DB, U13CF ] };
- key <AD05> { [ U13D4, U13D8 ] };
- key <AD06> { [ U13EF, U13F2 ] };
- key <AD07> { [ U13A4, U13AD ] };
- key <AD08> { [ U13A2, U13F1 ] };
- key <AD09> { [ U13A3, U13EC ] };
- key <AD10> { [ U13C1, U13EA ] };
- key <AD11> { [ U13D5, U13D1 ] };
- key <AD12> { [ U13B6, U13E4 ] };
- key <BKSL> { [ U13E9, U13EE ] };
-
- key <AC01> { [ U13A0, U13CC ] };
- key <AC02> { [ U13CD, U13CE ] };
- key <AC03> { [ U13D7, U13D0 ] };
- key <AC04> { [ U13A9, U13C8 ] };
- key <AC05> { [ U13A6, U13E5 ] };
- key <AC06> { [ U13AF, U13B2 ] };
- key <AC07> { [ U13DA, U13AB ] };
- key <AC08> { [ U13B8, U13A7 ] };
- key <AC09> { [ U13B5, U13AE ] };
- key <AC10> { [ U13E8, U13E0 ] };
- key <AC11> { [ apostrophe, quotedbl ] };
-
- key <AB01> { [ U13AC, U13C3 ] };
- key <AB02> { [ U13F4, U13ED ] };
- key <AB03> { [ U13D3, U13DF ] };
- key <AB04> { [ U13A5, U13DE ] };
- key <AB05> { [ U13A8, U13F0 ] };
- key <AB06> { [ U13BE, U13BB ] };
- key <AB07> { [ U13C5, U13B7 ] };
- key <AB08> { [ comma, U13E2 ] };
- key <AB09> { [ period, U13B4 ] };
- key <AB10> { [ U13C2, U13C9 ] };
-
- // End alphanumeric section
-};
-
-// Serbian charecters added as third level symbols to US keyboard layout.
-
-partial alphanumeric_keys
-xkb_symbols "srp" {
-
- name[Group1]= "USA - Serbian";
-
- include "us"
-
- key <TLDE> { [ grave, asciitilde ] };
- key <AE06> { [ 6, dead_caron, asciicircum, asciicircum ] };
- key <AC09> { [ l, L, U1C9, U1C8 ] };
- key <AB06> { [ n, N, U1CC, U1CB ] };
- key <AB01> { [ z, Z, U1C6, U1C5 ] };
- key <AD03> { [ e, E, EuroSign, cent ] };
- key <AC03> { [ d, D, dstroke, Dstroke ] };
- key <AC11> { [ dead_acute, quotedbl, apostrophe, U315 ] };
- key <SPCE> { [ space, space, nobreakspace, nobreakspace ] };
-
- include "level3(ralt_switch)"
-};
-
-//based on http://upload.wikimedia.org/wikipedia/commons/1/18/T-Mobile_G1_launch_event_2.jpg
-partial alphanumeric_keys
-xkb_symbols "htcdream" {
- include "inet(htcdream)"
- name[Group1]= "USA - htcdream";
-
- //second row
- key <AD01> { [ q, Q, Tab, Tab ] };
- key <AD02> { [ w, W, grave, grave ] };
- key <AD03> { [ e, E, underscore, underscore ] };
- key <AD04> { [ r, R, sterling, sterling ] };
- key <AD05> { [ t, T, EuroSign, EuroSign ] };
- key <AD06> { [ y, Y, division, division ] };
- key <AD07> { [ u, U, multiply, multiply ] };
- key <AD08> { [ i, I, minus, minus ] };
- key <AD09> { [ o, O, plus, plus ] };
- key <AD10> { [ p, P, equal, equal ] };
-
- //third row
- key <AC01> { [ a, A, NoSymbol, NoSymbol ] };
- key <AC02> { [ s, S, bar, bar ] };
- key <AC03> { [ d ,D, backslash, backslash ] };
- key <AC04> { [ f, F, braceleft, braceleft ] };
- key <AC05> { [ g, G, braceright, braceright ] };
- key <AC06> { [ h, H, colon, colon ] };
- key <AC07> { [ j, J, semicolon, semicolon ] };
- key <AC08> { [ k, K, quotedbl, quotedbl ] };
- key <AC09> { [ l, L, apostrophe, apostrophe ] };
-
- //forth row
- key <AB01> { [ z, Z, NoSymbol, NoSymbol ] };
- key <AB02> { [ x, X, NoSymbol, NoSymbol ] };
- key <AB03> { [ c, C, NoSymbol, NoSymbol ] };
- key <AB04> { [ v, V, bracketleft, bracketleft ] };
- key <AB05> { [ b, B, bracketright, bracketright ] };
- key <AB06> { [ n, N, less, less ] };
- key <AB07> { [ m, M, greater, greater ] };
- key <AB08> { [ comma, comma, question, question ] };
-
- //fifth row
- key <FK15> { [ at, at, asciitilde, asciitilde ] };
-
- include "level3(alt_switch)"
-}; \ No newline at end of file
+// $XKeyboardConfig$
+
+//
+// $XdotOrg: xc/programs/xkbcomp/symbols/us,v 1.1.4.3 2004/03/05 13:41:33 eich Exp $
+// $XFree86: xc/programs/xkbcomp/symbols/us,v 1.6 2003/10/31 14:32:05 pascal Exp $
+
+default
+partial alphanumeric_keys modifier_keys
+xkb_symbols "basic" {
+
+ name[Group1]= "USA";
+
+ // Alphanumeric section
+ key <TLDE> { [ grave, asciitilde ] };
+ key <AE01> { [ 1, exclam ] };
+ key <AE02> { [ 2, at ] };
+ key <AE03> { [ 3, numbersign ] };
+ key <AE04> { [ 4, dollar ] };
+ key <AE05> { [ 5, percent ] };
+ key <AE06> { [ 6, asciicircum ] };
+ key <AE07> { [ 7, ampersand ] };
+ key <AE08> { [ 8, asterisk ] };
+ key <AE09> { [ 9, parenleft ] };
+ key <AE10> { [ 0, parenright ] };
+ key <AE11> { [ minus, underscore ] };
+ key <AE12> { [ equal, plus ] };
+
+ key <AD01> { [ q, Q ] };
+ key <AD02> { [ w, W ] };
+ key <AD03> { [ e, E ] };
+ key <AD04> { [ r, R ] };
+ key <AD05> { [ t, T ] };
+ key <AD06> { [ y, Y ] };
+ key <AD07> { [ u, U ] };
+ key <AD08> { [ i, I ] };
+ key <AD09> { [ o, O ] };
+ key <AD10> { [ p, P ] };
+ key <AD11> { [ bracketleft, braceleft ] };
+ key <AD12> { [ bracketright, braceright ] };
+
+ key <AC01> { [ a, A ] };
+ key <AC02> { [ s, S ] };
+ key <AC03> { [ d, D ] };
+ key <AC04> { [ f, F ] };
+ key <AC05> { [ g, G ] };
+ key <AC06> { [ h, H ] };
+ key <AC07> { [ j, J ] };
+ key <AC08> { [ k, K ] };
+ key <AC09> { [ l, L ] };
+ key <AC10> { [ semicolon, colon ] };
+ key <AC11> { [ apostrophe, quotedbl ] };
+
+ key <AB01> { [ z, Z ] };
+ key <AB02> { [ x, X ] };
+ key <AB03> { [ c, C ] };
+ key <AB04> { [ v, V ] };
+ key <AB05> { [ b, B ] };
+ key <AB06> { [ n, N ] };
+ key <AB07> { [ m, M ] };
+ key <AB08> { [ comma, less ] };
+ key <AB09> { [ period, greater ] };
+ key <AB10> { [ slash, question ] };
+
+ key <BKSL> { [ backslash, bar ] };
+ // End alphanumeric section
+};
+
+partial alphanumeric_keys
+xkb_symbols "euro" {
+
+ name[Group1]= "USA - With EuroSign on 5";
+
+ include "us(basic)"
+
+ include "eurosign(5)"
+
+ include "level3(ralt_switch)"
+};
+
+
+partial alphanumeric_keys
+xkb_symbols "intl" {
+
+ name[Group1]= "USA - International (with dead keys)";
+
+ include "us(basic)"
+
+ // Alphanumeric section
+ key <TLDE> { [dead_grave, dead_tilde, grave, asciitilde ] };
+ key <AE01> { [ 1, exclam, exclamdown, onesuperior ] };
+ key <AE02> { [ 2, at, twosuperior, dead_doubleacute ] };
+ key <AE03> { [ 3, numbersign, threesuperior, dead_macron ] };
+ key <AE04> { [ 4, dollar, currency, sterling ] };
+ key <AE05> { [ 5, percent, EuroSign, dead_cedilla ] };
+ key <AE06> { [ 6, dead_circumflex, onequarter, asciicircum ] };
+ key <AE07> { [ 7, ampersand, onehalf, dead_horn ] };
+ key <AE08> { [ 8, asterisk, threequarters, dead_ogonek ] };
+ key <AE09> { [ 9, parenleft, leftsinglequotemark, dead_breve ] };
+ key <AE10> { [ 0, parenright, rightsinglequotemark, dead_abovering ] };
+ key <AE11> { [ minus, underscore, yen, dead_belowdot ] };
+ key <AE12> { [ equal, plus, multiply, division ] };
+
+ key <AD01> { [ q, Q, adiaeresis, Adiaeresis ] };
+ key <AD02> { [ w, W, aring, Aring ] };
+ key <AD03> { [ e, E, eacute, Eacute ] };
+ key <AD04> { [ r, R, registered, registered ] };
+ key <AD05> { [ t, T, thorn, THORN ] };
+ key <AD06> { [ y, Y, udiaeresis, Udiaeresis ] };
+ key <AD07> { [ u, U, uacute, Uacute ] };
+ key <AD08> { [ i, I, iacute, Iacute ] };
+ key <AD09> { [ o, O, oacute, Oacute ] };
+ key <AD10> { [ p, P, odiaeresis, Odiaeresis ] };
+ key <AD11> { [ bracketleft, braceleft, guillemotleft, leftdoublequotemark ] };
+ key <AD12> { [bracketright, braceright, guillemotright, rightdoublequotemark ] };
+
+ key <AC01> { [ a, A, aacute, Aacute ] };
+ key <AC02> { [ s, S, ssharp, section ] };
+ key <AC03> { [ d, D, eth, ETH ] };
+ key <AC04> { [ f, F, f, F ] };
+ key <AC05> { [ g, G, g, G ] };
+ key <AC06> { [ h, H, h, H ] };
+ key <AC07> { [ j, J, j, J ] };
+ key <AC08> { [ k, K, oe, OE ] };
+
+ key <AC09> { [ l, L, oslash, Ooblique ] };
+ key <AC10> { [ semicolon, colon, paragraph, degree ] };
+ key <AC11> { [dead_acute, dead_diaeresis, apostrophe, quotedbl ] };
+
+ key <AB01> { [ z, Z, ae, AE ] };
+ key <AB02> { [ x, X, x, X ] };
+ key <AB03> { [ c, C, copyright, cent ] };
+ key <AB04> { [ v, V, v, V ] };
+ key <AB05> { [ b, B, b, B ] };
+ key <AB06> { [ n, N, ntilde, Ntilde ] };
+ key <AB07> { [ m, M, mu, mu ] };
+ key <AB08> { [ comma, less, ccedilla, Ccedilla ] };
+ key <AB09> { [ period, greater, dead_abovedot, dead_caron ] };
+ key <AB10> { [ slash, question, questiondown, dead_hook ] };
+ key <BKSL> { [ backslash, bar, notsign, brokenbar ] };
+
+ include "level3(ralt_switch)"
+};
+
+// Based on symbols/us_intl keyboard map:
+// Dead-keys definition for a very simple US/ASCII layout.
+// by Conectiva (http://www.conectiva.com.br)
+// modified by Ricardo Y. Igarashi (iga@that.com.br)
+
+// Added the following deadkeys, to make it truly international:
+//
+// dead_macron: on AltGr-minus
+// dead_breve: on AltGr-parenleft
+// dead_abovedot: on AltGr-period
+// dead_abovering: on AltGr-0
+// dead_doubleacute: on AltGr-equal (as quotedbl is already used)
+// dead_caron: on AltGr-less (AltGr-shift-comma)
+// dead_cedilla: on AltGr-comma
+// dead_ogonek: on AltGr-semicolon
+// dead_belowdot: on AltGr-underscore (AltGr-shift-minus)
+// dead_hook: on AltGr-question
+// dead_horn: on AltGr-plus (AltGr-shift-equal)
+// dead_diaeresis: on AltGr-colon (Alt-shift-semicolon)
+//
+// those were already there:
+// dead_grave
+// dead_acute
+// dead_circumflex
+// dead_tilde
+// dead_diaeresis
+
+partial alphanumeric_keys
+xkb_symbols "alt-intl" {
+
+ name[Group1]= "USA - Alternative international";
+
+ include "us"
+
+ key <TLDE> { [ dead_grave, dead_tilde, grave, asciitilde ] };
+ key <AE05> { [ 5, percent, EuroSign ] };
+ key <AE06> { [ 6, dead_circumflex, asciicircum, asciicircum ] };
+ key <AE09> { [ 9, parenleft, leftsinglequotemark, dead_breve ] };
+ key <AE10> { [ 0, parenright, rightsinglequotemark, dead_abovering ] };
+ key <AE11> { [ minus, underscore, dead_macron, dead_belowdot ] };
+ key <AE12> { [ equal, plus, dead_doubleacute, dead_horn ] };
+
+ key <AD03> { [ e, E, EuroSign, cent ] };
+
+ key <AC10> { [ semicolon, colon, dead_ogonek, dead_diaeresis ] };
+ key <AC11> { [ dead_acute, dead_diaeresis, apostrophe, quotedbl ] };
+
+ key <AB08> { [ comma, less, dead_cedilla, dead_caron ] };
+ key <AB09> { [ period, greater, dead_abovedot, dead_circumflex ] };
+ key <AB10> { [ slash, question, dead_hook, dead_hook ] };
+
+ include "level3(ralt_switch)"
+};
+
+// based on a keyboard map from an 'xkb/symbols/dk' file
+//
+// $XFree86: xc/programs/xkbcomp/symbols/dvorak,v 1.5 2004/01/03 16:35:07 herrb Exp $
+
+partial alphanumeric_keys
+xkb_symbols "dvorak" {
+
+ name[Group1]= "USA - Dvorak";
+
+ // Alphanumeric section
+
+ key <TLDE> { [ grave, asciitilde, dead_grave, dead_tilde ] };
+
+ key <AE01> { [ 1, exclam ] };
+ key <AE02> { [ 2, at ] };
+ key <AE03> { [ 3, numbersign ] };
+ key <AE04> { [ 4, dollar ] };
+ key <AE05> { [ 5, percent ] };
+ key <AE06> { [ 6, asciicircum, dead_circumflex, dead_circumflex ] };
+ key <AE07> { [ 7, ampersand ] };
+ key <AE08> { [ 8, asterisk ] };
+ key <AE09> { [ 9, parenleft, dead_grave] };
+ key <AE10> { [ 0, parenright ] };
+ key <AE11> { [ bracketleft, braceleft ] };
+ key <AE12> { [ bracketright, braceright, dead_tilde] };
+
+ key <AD01> { [ apostrophe, quotedbl, dead_acute, dead_diaeresis ] };
+ key <AD02> { [ comma, less, dead_cedilla, dead_caron ] };
+ key <AD03> { [ period, greater, dead_abovedot, periodcentered ] };
+ key <AD04> { [ p, P ] };
+ key <AD05> { [ y, Y ] };
+ key <AD06> { [ f, F ] };
+ key <AD07> { [ g, G ] };
+ key <AD08> { [ c, C ] };
+ key <AD09> { [ r, R ] };
+ key <AD10> { [ l, L ] };
+ key <AD11> { [ slash, question ] };
+ key <AD12> { [ equal, plus ] };
+
+ key <AC01> { [ a, A ] };
+ key <AC02> { [ o, O ] };
+ key <AC03> { [ e, E ] };
+ key <AC04> { [ u, U ] };
+ key <AC05> { [ i, I ] };
+ key <AC06> { [ d, D ] };
+ key <AC07> { [ h, H ] };
+ key <AC08> { [ t, T ] };
+ key <AC09> { [ n, N ] };
+ key <AC10> { [ s, S ] };
+ key <AC11> { [ minus, underscore ] };
+
+ key <AB01> { [ semicolon, colon, dead_ogonek, dead_doubleacute ] };
+ key <AB02> { [ q, Q ] };
+ key <AB03> { [ j, J ] };
+ key <AB04> { [ k, K ] };
+ key <AB05> { [ x, X ] };
+ key <AB06> { [ b, B ] };
+ key <AB07> { [ m, M ] };
+ key <AB08> { [ w, W ] };
+ key <AB09> { [ v, V ] };
+ key <AB10> { [ z, Z ] };
+
+ key <BKSL> { [ backslash, bar ] };
+};
+
+// Dvorak international with dead keys
+// Olivier Mehani (shtrom-xorg@ssji.net)
+// Reproduce the per-key mapping of us(intl) for the dvorak layout
+// aka "I just swapped my keys over"
+partial alphanumeric_keys
+xkb_symbols "dvorak-intl" {
+
+ name[Group1]= "USA - Dvorak international (with dead keys)";
+
+ include "us(dvorak)"
+
+ key <TLDE> { [dead_grave, dead_tilde, grave, asciitilde ] };
+
+ key <AE01> { [ 1, exclam, exclamdown, onesuperior ] };
+ key <AE02> { [ 2, at, twosuperior, dead_doubleacute ] };
+ key <AE03> { [ 3, numbersign, threesuperior, dead_macron ] };
+ key <AE04> { [ 4, dollar, currency, sterling ] };
+ key <AE05> { [ 5, percent, EuroSign, dead_cedilla ] };
+ key <AE06> { [ 6, dead_circumflex, onequarter, asciicircum ] };
+ key <AE07> { [ 7, ampersand, onehalf, dead_horn ] };
+ key <AE08> { [ 8, asterisk, threequarters, dead_ogonek ] };
+ key <AE09> { [ 9, parenleft, leftsinglequotemark, dead_breve ] };
+ key <AE10> { [ 0, parenright, rightsinglequotemark, dead_abovering ] };
+ key <AE11> { [ bracketleft, braceleft, guillemotleft, leftdoublequotemark ] };
+ key <AE12> { [bracketright, braceright, guillemotright, rightdoublequotemark ] };
+
+ key <AD01> { [dead_acute, dead_diaeresis, apostrophe, quotedbl ] };
+ key <AD02> { [ comma, less, ccedilla, Ccedilla ] };
+ key <AD03> { [ period, greater, dead_abovedot, dead_caron ] };
+ key <AD04> { [ p, P, odiaeresis, Odiaeresis ] };
+ key <AD05> { [ y, Y, udiaeresis, Udiaeresis ] };
+ // key <AD06> { [ f, F ] };
+ // key <AD07> { [ g, G ] };
+ key <AD08> { [ c, C, copyright, cent ] };
+ key <AD09> { [ r, R, registered, registered ] };
+ key <AD10> { [ l, L, oslash, Ooblique ] };
+ key <AD11> { [ slash, question, questiondown, dead_hook ] };
+ // key <AD12> { [ equal, plus, multiply, division ] };
+
+ key <AC01> { [ a, A, aacute, Aacute ] };
+ key <AC02> { [ o, O, oacute, Oacute ] };
+ key <AC03> { [ e, E, eacute, Eacute ] };
+ key <AC04> { [ u, U, uacute, Uacute ] };
+ key <AC05> { [ i, I, iacute, Iacute ] };
+ key <AC06> { [ d, D, eth, ETH ] };
+ // key <AC07> { [ h, H ] };
+ key <AC08> { [ t, T, thorn, THORN ] };
+ key <AC09> { [ n, N, ntilde, Ntilde ] };
+ key <AC10> { [ s, S, ssharp, section ] };
+ // key <AC11> { [ minus, underscore, yen, dead_belowdot ] };
+
+ key <AB01> { [ semicolon, colon, paragraph, degree ] };
+ key <AB02> { [ q, Q, adiaeresis, Adiaeresis ] };
+ // key <AB03> { [ j, J ] };
+ key <AB04> { [ k, K, oe, OE ] };
+ // key <AB05> { [ x, X ] };
+ // key <AB06> { [ b, B ] };
+ key <AB07> { [ m, M, mu, mu ] };
+ key <AB08> { [ w, W, aring, Aring ] };
+ // key <AB09> { [ v, V ] };
+ key <AB10> { [ z, Z, ae, AE ] };
+
+ key <BKSL> { [ backslash, bar, notsign, brokenbar ] };
+
+ include "level3(ralt_switch)"
+};
+
+// Dvorak international without dead keys
+// Stephane Magnenat (stephane at magnenat dot net, http://stephane.magnenat.net)
+// Based on information from http://www.poupinou.org/dvorak/index.html
+//
+// ` 1 2 3 4 5 6 7 8 9 0 [ ] \
+// €
+//
+// ' , . p y f g c r l / =
+// ä ê ë ü ç
+//
+// a o e u i d h t n s -
+// à ô é û î ß
+//
+// ; q j k x b m w v z
+// â ö è ù ï
+
+partial alphanumeric_keys
+xkb_symbols "dvorak-alt-intl" {
+
+ name[Group1]= "USA - Dvorak alternative international (no dead keys)";
+
+ include "us(dvorak)"
+
+ key <AE04> { [ 4, dollar, EuroSign ] };
+
+ key <AD02> { [ comma, less, adiaeresis, dead_caron ] };
+ key <AD03> { [ period, greater, ecircumflex, periodcentered ] };
+ key <AD04> { [ p, P, ediaeresis, dead_cedilla ] };
+ key <AD05> { [ y, Y, udiaeresis ] };
+ key <AD08> { [ c, C, ccedilla, dead_abovedot ] };
+
+ key <AC01> { [ a, A, agrave ] };
+ key <AC02> { [ o, O, ocircumflex ] };
+ key <AC03> { [ e, E, eacute ] };
+ key <AC04> { [ u, U, ucircumflex ] };
+ key <AC05> { [ i, I, icircumflex ] };
+ key <AC10> { [ s, S, ssharp ] };
+
+ key <AB01> { [ semicolon, colon, acircumflex ] };
+ key <AB02> { [ q, Q, odiaeresis, dead_ogonek ] };
+ key <AB03> { [ j, J, egrave, dead_doubleacute ] };
+ key <AB04> { [ k, K, ugrave ] };
+ key <AB05> { [ x, X, idiaeresis ] };
+
+ include "level3(ralt_switch)"
+};
+
+// Left and right handed dvorak layouts
+// by sqweek <sqweek@gmail.com> 2006-01-30
+// Based on the corresponding layouts in the console-tools package.
+partial alphanumeric_keys
+xkb_symbols "dvorak-l" {
+
+ include "us(dvorak)"
+ name[Group1]= "USA - Left handed Dvorak";
+
+ key <AE01> { [ bracketleft, braceleft ] };
+ key <AE02> { [ bracketright, braceright ] };
+ key <AE03> { [ slash, question ] };
+ key <AE04> { [ p, P ] };
+ key <AE05> { [ f, F ] };
+ key <AE06> { [ m, M ] };
+ key <AE07> { [ l, L ] };
+ key <AE08> { [ j, J ] };
+ key <AE09> { [ 4, dollar ] };
+ key <AE10> { [ 3, numbersign ] };
+ key <AE11> { [ 2, at ] };
+ key <AE12> { [ 1, exclam ] };
+
+ key <AD01> { [ semicolon, colon ] };
+ key <AD02> { [ q, Q ] };
+ key <AD03> { [ b, B ] };
+ key <AD04> { [ y, Y ] };
+ key <AD05> { [ u, U ] };
+ key <AD06> { [ r, R ] };
+ key <AD07> { [ s, S ] };
+ key <AD08> { [ o, O ] };
+ key <AD09> { [ period, greater ] };
+ key <AD10> { [ 6, asciicircum ] };
+ key <AD11> { [ 5, percent ] };
+ key <AD12> { [ equal, plus ] };
+
+ key <AC01> { [ minus, underscore ] };
+ key <AC02> { [ k, K ] };
+ key <AC03> { [ c, C ] };
+ key <AC04> { [ d, D ] };
+ key <AC05> { [ t, T ] };
+ key <AC06> { [ h, H ] };
+ key <AC07> { [ e, E ] };
+ key <AC08> { [ a, A ] };
+ key <AC09> { [ z, Z ] };
+ key <AC10> { [ 8, asterisk ] };
+ key <AC11> { [ 7, ampersand ] };
+
+ key <AB01> { [ apostrophe, quotedbl ] };
+ key <AB02> { [ x, X ] };
+ key <AB03> { [ g, G ] };
+ key <AB04> { [ v, V ] };
+ key <AB05> { [ w, W ] };
+ key <AB06> { [ n, N ] };
+ key <AB07> { [ i, I ] };
+ key <AB08> { [ comma, less ] };
+ key <AB09> { [ 0, parenright ] };
+ key <AB10> { [ 9, parenleft ] };
+};
+
+partial alphanumeric_keys
+xkb_symbols "dvorak-r" {
+
+ include "us(dvorak)"
+ name[Group1]= "USA - Right handed Dvorak";
+
+ key <AE01> { [ 1, exclam ] };
+ key <AE02> { [ 2, at ] };
+ key <AE03> { [ 3, numbersign ] };
+ key <AE04> { [ 4, dollar ] };
+ key <AE05> { [ j, J ] };
+ key <AE06> { [ l, L ] };
+ key <AE07> { [ m, M ] };
+ key <AE08> { [ f, F ] };
+ key <AE09> { [ p, P ] };
+ key <AE10> { [ slash, question ] };
+ key <AE11> { [ bracketleft, braceleft ] };
+ key <AE12> { [ bracketright, braceright ] };
+
+ key <AD01> { [ 5, percent ] };
+ key <AD02> { [ 6, asciicircum ] };
+ key <AD03> { [ q, Q ] };
+ key <AD04> { [ period, greater ] };
+ key <AD05> { [ o, O ] };
+ key <AD06> { [ r, R ] };
+ key <AD07> { [ s, S ] };
+ key <AD08> { [ u, U ] };
+ key <AD09> { [ y, Y ] };
+ key <AD10> { [ b, B ] };
+ key <AD11> { [ semicolon, colon ] };
+ key <AD12> { [ equal, plus ] };
+
+ key <AC01> { [ 7, ampersand ] };
+ key <AC02> { [ 8, asterisk ] };
+ key <AC03> { [ z, Z ] };
+ key <AC04> { [ a, A ] };
+ key <AC05> { [ e, E ] };
+ key <AC06> { [ h, H ] };
+ key <AC07> { [ t, T ] };
+ key <AC08> { [ d, D ] };
+ key <AC09> { [ c, C ] };
+ key <AC10> { [ k, K ] };
+ key <AC11> { [ minus, underscore ] };
+
+ key <AB01> { [ 9, parenleft ] };
+ key <AB02> { [ 0, parenright ] };
+ key <AB03> { [ x, X ] };
+ key <AB04> { [ comma, less ] };
+ key <AB05> { [ i, I ] };
+ key <AB06> { [ n, N ] };
+ key <AB07> { [ w, W ] };
+ key <AB08> { [ v, V ] };
+ key <AB09> { [ g, G ] };
+ key <AB10> { [ apostrophe, quotedbl ] };
+};
+
+// Classic dvorak layout
+// by Piter Punk <piterpk@terra.com.br> - 2006-07-06
+// Based on dvorak layout and e-mail from Russel L. Harris rlharris@oplink.net
+// on xorg list.
+partial alphanumeric_keys
+xkb_symbols "dvorak-classic" {
+
+ name[Group1]= "USA - Classic Dvorak";
+
+ // Alphanumeric section
+
+ key <TLDE> { [ grave, asciitilde, dead_grave, dead_tilde ] };
+
+ key <AE01> { [ bracketleft, braceleft ] };
+ key <AE02> { [ 7, ampersand ] };
+ key <AE03> { [ 5, percent ] };
+ key <AE04> { [ 3, numbersign ] };
+ key <AE05> { [ 1, exclam ] };
+ key <AE06> { [ 9, parenleft, dead_grave] };
+ key <AE07> { [ 0, parenright ] };
+ key <AE08> { [ 2, at ] };
+ key <AE09> { [ 4, dollar ] };
+ key <AE10> { [ 6, asciicircum, dead_circumflex, dead_circumflex ] };
+ key <AE11> { [ 8, asterisk ] };
+ key <AE12> { [ bracketright, braceright, dead_tilde] };
+
+ key <AD01> { [ slash, question ] };
+ key <AD02> { [ comma, less, dead_cedilla, dead_caron ] };
+ key <AD03> { [ period, greater, dead_abovedot, periodcentered ] };
+ key <AD04> { [ p, P ] };
+ key <AD05> { [ y, Y ] };
+ key <AD06> { [ f, F ] };
+ key <AD07> { [ g, G ] };
+ key <AD08> { [ c, C ] };
+ key <AD09> { [ r, R ] };
+ key <AD10> { [ l, L ] };
+ key <AD11> { [ apostrophe, quotedbl, dead_acute, dead_diaeresis ] };
+ key <AD12> { [ equal, plus ] };
+
+ key <AC01> { [ a, A ] };
+ key <AC02> { [ o, O ] };
+ key <AC03> { [ e, E ] };
+ key <AC04> { [ u, U ] };
+ key <AC05> { [ i, I ] };
+ key <AC06> { [ d, D ] };
+ key <AC07> { [ h, H ] };
+ key <AC08> { [ t, T ] };
+ key <AC09> { [ n, N ] };
+ key <AC10> { [ s, S ] };
+ key <AC11> { [ minus, underscore ] };
+
+ key <AB01> { [ semicolon, colon, dead_ogonek, dead_doubleacute ] };
+ key <AB02> { [ q, Q ] };
+ key <AB03> { [ j, J ] };
+ key <AB04> { [ k, K ] };
+ key <AB05> { [ x, X ] };
+ key <AB06> { [ b, B ] };
+ key <AB07> { [ m, M ] };
+ key <AB08> { [ w, W ] };
+ key <AB09> { [ v, V ] };
+ key <AB10> { [ z, Z ] };
+ key <BKSL> { [ backslash, bar ] };
+};
+
+// Programmer Dvorak, by Roland Kaufmann <rlndkfmn at gmail dot com>
+// License: BSD, available at <http://www.kaufmann.no/roland/dvorak/license.html>
+// Main features: Numbers are in shift position (like French), symbols have been
+// placed in locations that give good hand-alternation and finger rolling with
+// symbols that usually follows, accented characters are possible for I18N.
+partial alphanumeric_keys
+xkb_symbols "dvp" {
+ include "us(dvorak)"
+
+ name[Group1] = "USA - Programmer Dvorak";
+
+ // Unmodified Shift AltGr Shift+AltGr
+ // symbols row, left side
+ key <TLDE> { [ dollar, asciitilde, dead_tilde ] };
+ key <AE01> { [ ampersand, percent ] };
+ key <AE02> { [ bracketleft, 7, currency ], type[Group1] = "FOUR_LEVEL_ALPHABETIC" };
+ key <AE03> { [ braceleft, 5, cent ], type[Group1] = "FOUR_LEVEL_ALPHABETIC" };
+ key <AE04> { [ braceright, 3, yen ], type[Group1] = "FOUR_LEVEL_ALPHABETIC" };
+ key <AE05> { [ parenleft, 1, EuroSign ], type[Group1] = "FOUR_LEVEL_ALPHABETIC" };
+ key <AE06> { [ equal, 9, sterling ], type[Group1] = "FOUR_LEVEL_ALPHABETIC" };
+
+ // symbols row, right side
+ key <AE07> { [ asterisk, 0 ], type[Group1] = "FOUR_LEVEL_ALPHABETIC" };
+ key <AE08> { [ parenright, 2, onehalf ], type[Group1] = "FOUR_LEVEL_ALPHABETIC" };
+ key <AE09> { [ plus, 4 ], type[Group1] = "FOUR_LEVEL_ALPHABETIC" };
+ key <AE10> { [ bracketright, 6 ], type[Group1] = "FOUR_LEVEL_ALPHABETIC" };
+ key <AE11> { [ exclam, 8, exclamdown ], type[Group1] = "FOUR_LEVEL_ALPHABETIC" };
+ key <AE12> { [ numbersign, grave, dead_grave ] };
+ key <BKSP> { [ BackSpace ] };
+
+ // upper row, left side
+ key <AD01> { [ semicolon, colon, dead_diaeresis ] };
+ key <AD02> { [ comma, less, guillemotleft ] };
+ key <AD03> { [ period, greater, guillemotright ] };
+ key <AD04> { [ p, P, paragraph, section ] };
+ key <AD05> { [ y, Y, udiaeresis, Udiaeresis ] };
+
+ // upper row, right side
+ key <AD08> { [ c, C, ccedilla, Ccedilla ] };
+ key <AD09> { [ r, R, registered, trademark ] };
+ key <AD11> { [ slash, question, questiondown ] };
+ key <AD12> { [ at, asciicircum, dead_circumflex, dead_caron ] };
+
+ // home row, left side
+ key <AC01> { [ a, A, aring, Aring ] };
+ key <AC02> { [ o, O, oslash, Ooblique ] };
+ key <AC03> { [ e, E, ae, AE ] };
+ key <AC04> { [ u, U, eacute, Eacute ] };
+
+ // home row, right side
+ key <AC06> { [ d, D, eth, ETH ] };
+ key <AC07> { [ h, H, dead_acute ] };
+ key <AC08> { [ t, T, thorn, THORN ] };
+ key <AC09> { [ n, N, ntilde, Ntilde ] };
+ key <AC10> { [ s, S, ssharp ] };
+ key <AC11> { [ minus, underscore, hyphen ], type[Group1] = "FOUR_LEVEL_ALPHABETIC" };
+ key <BKSL> { [ backslash, bar ] };
+
+ // lower row, left side
+ key <AB01> { [ apostrophe, quotedbl, dead_acute ] };
+};
+
+// phonetic layout for Russian letters on an US keyboard
+// by Ivan Popov <pin@konvalo.org> 2005-07-17
+
+// level3 modifier is a shortcut to the "us" meaning of the keys where
+// we place cyrillic letters, handy for accessing the corresponding
+// punctuation marks.
+// It is important to have access to punctuation marks, and the rest of
+// alphabetical keys are added for being consequent so that the users
+// can expect the level3 modifier to give what the key label shows.
+
+partial alphanumeric_keys
+xkb_symbols "rus" {
+
+ name[Group1]= "USA - Russian phonetic";
+
+ include "us(basic)"
+
+key.type[group1]="FOUR_LEVEL_ALPHABETIC";
+
+ key <LatA> { [ Cyrillic_a, Cyrillic_A ] };
+ key <LatB> { [ Cyrillic_be, Cyrillic_BE ] };
+ key <LatW> { [ Cyrillic_ve, Cyrillic_VE ] };
+ key <LatG> { [ Cyrillic_ghe, Cyrillic_GHE ] };
+ key <LatD> { [ Cyrillic_de, Cyrillic_DE ] };
+ key <LatE> { [ Cyrillic_ie, Cyrillic_IE ] };
+ key <TLDE> { [ Cyrillic_io, Cyrillic_IO, grave, asciitilde ] };
+ key <LatV> { [ Cyrillic_zhe, Cyrillic_ZHE ] };
+ key <LatZ> { [ Cyrillic_ze, Cyrillic_ZE ] };
+ key <LatI> { [ Cyrillic_i, Cyrillic_I ] };
+ key <LatJ> { [ Cyrillic_shorti, Cyrillic_SHORTI ] };
+ key <LatK> { [ Cyrillic_ka, Cyrillic_KA ] };
+ key <LatL> { [ Cyrillic_el, Cyrillic_EL ] };
+ key <LatM> { [ Cyrillic_em, Cyrillic_EM ] };
+ key <LatN> { [ Cyrillic_en, Cyrillic_EN ] };
+ key <LatO> { [ Cyrillic_o, Cyrillic_O ] };
+ key <LatP> { [ Cyrillic_pe, Cyrillic_PE ] };
+ key <LatR> { [ Cyrillic_er, Cyrillic_ER ] };
+ key <LatS> { [ Cyrillic_es, Cyrillic_ES ] };
+ key <LatT> { [ Cyrillic_te, Cyrillic_TE ] };
+ key <LatU> { [ Cyrillic_u, Cyrillic_U ] };
+ key <LatF> { [ Cyrillic_ef, Cyrillic_EF ] };
+ key <LatH> { [ Cyrillic_ha, Cyrillic_HA ] };
+ key <LatC> { [ Cyrillic_tse, Cyrillic_TSE ] };
+ key <AC10> { [ Cyrillic_che, Cyrillic_CHE, semicolon, colon ] };
+ key <AD11> { [ Cyrillic_sha, Cyrillic_SHA, bracketleft, braceleft] };
+ key <AD12> { [ Cyrillic_shcha, Cyrillic_SHCHA, bracketright, braceright ] };
+ key <AE12> { [ Cyrillic_hardsign, Cyrillic_HARDSIGN, equal, plus ] };
+ key <LatY> { [ Cyrillic_yeru, Cyrillic_YERU ] };
+ key <LatX> { [ Cyrillic_softsign, Cyrillic_SOFTSIGN ] };
+ key <BKSL> { [ Cyrillic_e, Cyrillic_E, backslash, bar ] };
+ key <AC11> { [ Cyrillic_yu, Cyrillic_YU, apostrophe, quotedbl ] };
+ key <LatQ> { [ Cyrillic_ya, Cyrillic_YA ] };
+
+ include "level3(ralt_switch)"
+};
+
+partial alphanumeric_keys
+xkb_symbols "mac" {
+
+ include "us(basic)"
+ name[Group1]= "USA - Macintosh";
+ key.type[group1]="FOUR_LEVEL";
+
+ // Slightly improvised from http://homepage.mac.com/thgewecke/kblayout.jpg
+ key <LSGT> { [ section, plusminus, section, plusminus ] };
+ key <TLDE> { [ grave, asciitilde, dead_grave, dead_horn ] };
+ key <AE01> { [ 1, exclam, exclamdown, U2044 ] };
+ key <AE02> { [ 2, at, trademark, EuroSign ] };
+ key <AE03> { [ 3, numbersign, sterling, U2039 ] };
+ key <AE04> { [ 4, dollar, cent, U203A ] };
+ key <AE05> { [ 5, percent, infinity, UFB01 ] };
+ key <AE06> { [ 6,asciicircum, section, UFB02 ] };
+ key <AE07> { [ 7, ampersand, paragraph, doubledagger ] };
+ key <AE08> { [ 8, asterisk, enfilledcircbullet, degree ] };
+ key <AE09> { [ 9, parenleft, ordfeminine, periodcentered ] };
+ key <AE10> { [ 0, parenright, masculine,singlelowquotemark] };
+ key <AE11> { [ minus, underscore, endash, emdash ] };
+ key <AE12> { [ equal, plus, notequal, plusminus ] };
+
+ key <AD01> { [ q, Q, oe, OE ] };
+ key <AD02> { [ w, W, U2211,doublelowquotemark] };
+ key <AD03> { [ e, E, dead_acute, acute ] };
+ key <AD04> { [ r, R, registered, U2030 ] };
+ key <AD05> { [ t, T, dagger, dead_caron ] };
+ key <AD06> { [ y, Y, yen, onequarter ] };
+ key <AD07> { [ u, U, dead_diaeresis, diaeresis ] };
+ key <AD08> { [ i, I, dead_circumflex, U02C6 ] };
+ key <AD09> { [ o, O, oslash, Ooblique ] };
+ key <AD10> { [ p, P, Greek_pi, U220F ] };
+ key <AD11> { [ bracketleft, braceleft, leftdoublequotemark, rightdoublequotemark ] };
+ key <AD12> { [bracketright, braceright, leftsinglequotemark, rightsinglequotemark ] };
+ key <BKSL> { [ backslash, bar, guillemotleft, guillemotright ] };
+
+ key <AC01> { [ a, A, aring, Aring ] };
+ key <AC02> { [ s, S, ssharp, dead_stroke ] };
+ key <AC03> { [ d, D, partialderivative, eth ] };
+ key <AC04> { [ f, F, function, dead_hook ] };
+ key <AC05> { [ g, G, copyright, dead_doubleacute ] };
+ key <AC06> { [ h, H, dead_abovedot, dead_belowdot ] };
+ key <AC07> { [ j, J, U2206, onehalf ] };
+ key <AC08> { [ k, K,dead_abovering, UF8FF ] };
+
+ key <AC09> { [ l, L, notsign, THORN ] };
+ key <AC10> { [ semicolon, colon, U2026, thorn ] };
+ key <AC11> { [apostrophe, quotedbl, ae, AE ] };
+
+ key <AB01> { [ z, Z, Greek_OMEGA, dead_cedilla ] };
+ key <AB02> { [ x, X, U2248, dead_ogonek ] };
+ // unclear whether "approxeq" is 2248 or 2245
+ key <AB03> { [ c, C, ccedilla, Ccedilla ] };
+ key <AB04> { [ v, V, squareroot, U25CA ] };
+ key <AB05> { [ b, B, integral, idotless ] };
+ key <AB06> { [ n, N, dead_tilde, U02DC ] };
+ key <AB07> { [ m, M, mu, threequarters ] };
+ key <AB08> { [ comma, less, lessthanequal, dead_macron ] };
+ key <AB09> { [ period, greater, greaterthanequal, dead_breve ] };
+ key <AB10> { [ slash, question, division, questiondown ] };
+
+ include "level3(ralt_switch)"
+};
+
+// Colemak symbols for xkb on X.Org Server 7.x
+// 2006-01-01 Shai Coleman, http://colemak.com/ . Public domain.
+
+partial alphanumeric_keys
+xkb_symbols "colemak" {
+ include "us"
+ name[Group1]= "USA - Colemak";
+
+ // Alphanumeric section
+ key <TLDE> { [ grave, asciitilde, dead_tilde, asciitilde ] };
+ key <AE01> { [ 1, exclam, exclamdown, onesuperior ] };
+ key <AE02> { [ 2, at, masculine, twosuperior ] };
+ key <AE03> { [ 3, numbersign, ordfeminine, threesuperior ] };
+ key <AE04> { [ 4, dollar, cent, sterling ] };
+ key <AE05> { [ 5, percent, EuroSign, yen ] };
+ key <AE06> { [ 6, asciicircum, hstroke, Hstroke ] };
+ key <AE07> { [ 7, ampersand, eth, ETH ] };
+ key <AE08> { [ 8, asterisk, thorn, THORN ] };
+ key <AE09> { [ 9, parenleft, leftsinglequotemark, leftdoublequotemark ] };
+ key <AE10> { [ 0, parenright, rightsinglequotemark, rightdoublequotemark ] };
+ key <AE11> { [ minus, underscore, endash, emdash ] };
+ key <AE12> { [ equal, plus, multiply, division ] };
+
+ key <AD01> { [ q, Q, adiaeresis, Adiaeresis ] };
+ key <AD02> { [ w, W, aring, Aring ] };
+ key <AD03> { [ f, F, atilde, Atilde ] };
+ key <AD04> { [ p, P, oslash, Ooblique ] };
+ key <AD05> { [ g, G, dead_ogonek, asciitilde ] };
+ key <AD06> { [ j, J, dstroke, Dstroke ] };
+ key <AD07> { [ l, L, lstroke, Lstroke ] };
+ key <AD08> { [ u, U, uacute, Uacute ] };
+ key <AD09> { [ y, Y, udiaeresis, Udiaeresis ] };
+ key <AD10> { [ semicolon, colon, odiaeresis, Odiaeresis ] };
+ key <AD11> { [ bracketleft, braceleft, guillemotleft, 0x1002039 ] };
+ key <AD12> { [ bracketright, braceright, guillemotright, 0x100203a ] };
+ key <BKSL> { [ backslash, bar, asciitilde, asciitilde ] };
+
+ key <AC01> { [ a, A, aacute, Aacute ] };
+ key <AC02> { [ r, R, dead_grave, asciitilde ] };
+ key <AC03> { [ s, S, ssharp, asciitilde ] };
+ key <AC04> { [ t, T, dead_acute, dead_doubleacute ] };
+ key <AC05> { [ d, D, dead_diaeresis, asciitilde ] };
+ key <AC06> { [ h, H, dead_caron, asciitilde ] };
+ key <AC07> { [ n, N, ntilde, Ntilde ] };
+ key <AC08> { [ e, E, eacute, Eacute ] };
+ key <AC09> { [ i, I, iacute, Iacute ] };
+ key <AC10> { [ o, O, oacute, Oacute ] };
+ key <AC11> { [ apostrophe, quotedbl, otilde, Otilde ] };
+
+ key <AB01> { [ z, Z, ae, AE ] };
+ key <AB02> { [ x, X, dead_circumflex, asciitilde ] };
+ key <AB03> { [ c, C, ccedilla, Ccedilla ] };
+ key <AB04> { [ v, V, oe, OE ] };
+ key <AB05> { [ b, B, dead_breve, asciitilde ] };
+ key <AB06> { [ k, K, dead_abovering, asciitilde ] };
+ key <AB07> { [ m, M, dead_macron, asciitilde ] };
+ key <AB08> { [ comma, less, dead_cedilla, asciitilde ] };
+ key <AB09> { [ period, greater, dead_abovedot, asciitilde ] };
+ key <AB10> { [ slash, question, questiondown, asciitilde ] };
+
+ key <CAPS> { [ BackSpace, BackSpace, BackSpace, BackSpace ] };
+ key <LSGT> { [ minus, underscore, endash, emdash ] };
+ key <SPCE> { [ space, space, space, nobreakspace ] };
+
+ include "level3(ralt_switch)"
+};
+
+// I do NOT like dead-keys - the International keyboard as defined by Microsoft
+// doesn't fit my needs. Why use two keystrokes for all simple characters (eg '
+// and <space> generates a single ') just to have an é (eacute) in two strokes
+// as well? I type ' more often than é (eacute).
+//
+// This file works just like a regular keyboard, BUT has all dead-keys
+// accessible at level3 (through AltGr). An ë (ediaeresis) is now: AltGr+"
+// followed by an e. In other words, this keyboard is not international as long
+// as you leave the right Alt key alone.
+//
+// The original MS International keyboard was intended for Latin1 (iso8859-1).
+// With the introduction of iso8859-15, the (important) ligature oe (and OE)
+// became available. I added them next to ae. Because I write ediaeresis more
+// often than registered, I moved registered to be next to copyright and added
+// ediaeresis and idiaeresis. - Adriaan
+
+partial alphanumeric_keys
+xkb_symbols "altgr-intl" {
+
+ name[Group1]= "USA - International (AltGr dead keys)";
+
+ include "us(intl)"
+
+// five dead keys moved into level3:
+
+ key <TLDE> { [ grave, asciitilde, dead_grave, dead_tilde ] };
+ key <AC11> { [apostrophe,quotedbl, dead_acute, dead_diaeresis ] };
+
+// diversions from the MS Intl keyboard:
+
+ key <AE01> { [ 1, exclam, onesuperior, exclamdown ] };
+ key <AD04> { [ r, R, ediaeresis, Ediaeresis ] };
+ key <AC07> { [ j, J, idiaeresis, Idiaeresis ] };
+ key <AB02> { [ x, X, oe, OE ] };
+ key <AB04> { [ v, V, registered, registered ] };
+
+// onequarter etc (not in iso8859-15) moved to get three unshifted deadkeys:
+
+ key <AE06> { [ 6, asciicircum, dead_circumflex, onequarter ] };
+ key <AE07> { [ 7, ampersand, dead_horn, onehalf ] };
+ key <AE08> { [ 8, asterisk, dead_ogonek, threequarters ] };
+
+ include "level3(ralt_switch)"
+};
+
+// Intel ClassmatePC Keyboard Layout
+// by Piter PUNK <piterpk@terra.com.br>
+//
+// The keyboard layouts below maps the us(basic), us(intl) and us(alt-intl)
+// to ClassmatePC keyboard. All layouts uses RCTL as level3(switch) since
+// the keyboard doesn't have AltGr key. The EuroSign is engraved at 5 key.
+
+// classmate - us(basic)
+partial alphanumeric_keys
+xkb_symbols "classmate" {
+ include "us(basic)"
+ name[Group1]= "USA - ClassmatePC";
+
+ key <LSGT> { [ backslash, bar, backslash, bar ] };
+
+ include "eurosign(5)"
+ include "level3(switch)"
+};
+
+// classmate-intl - us(intl)
+// RCTL is generated by Fn+Alt, because that, when trying to access
+// the level3 symbols at 7,8,9,0,u,i,o,p,j,k,l,;,m,. and / we got
+// the keypad keycodes. The keypad is changed to make Fn+Alt+<KP_key>
+// generate the same symbol as the original key.
+partial alphanumeric_keys
+xkb_symbols "classmate-intl" {
+ include "us(intl)"
+ name[Group1]= "USA - ClassmatePC (International)";
+ key.type[Group1]="FOUR_LEVEL";
+
+ key <LSGT> { [ backslash, bar, backslash, bar ] };
+
+ key <KP7> { [ KP_Home, KP_7,
+ onehalf, dead_horn ] };
+ key <KP8> { [ KP_Up, KP_8,
+ threequarters, dead_ogonek ] };
+ key <KP9> { [ KP_Prior, KP_9,
+ leftsinglequotemark, dead_breve ] };
+ key <KPMU> { [ KP_Multiply, KP_Multiply,
+ rightsinglequotemark, dead_abovering ] };
+
+ key <KP4> { [ KP_Left, KP_4,
+ uacute, Uacute ] };
+ key <KP5> { [ KP_Begin, KP_5,
+ iacute, Iacute ] };
+ key <KP6> { [ KP_Right, KP_6,
+ oacute, Oacute ] };
+ key <KPSU> { [ KP_Subtract, KP_Subtract,
+ odiaeresis, Odiaeresis ] };
+
+ key <KP2> { [ KP_Down, KP_2,
+ oe, OE ] };
+ key <KP3> { [ KP_Next, KP_3,
+ oslash, Ooblique ] };
+ key <KPAD> { [ KP_Add, KP_Add,
+ paragraph, degree ] };
+
+ key <KP0> { [ KP_Insert, KP_0,
+ mu, mu ] };
+ key <KPDL> { [ KP_Delete, KP_Decimal,
+ dead_abovedot, dead_caron ] };
+ key <KPDV> { [ KP_Divide, KP_Divide,
+ questiondown, dead_hook ] };
+
+ include "level3(switch)"
+};
+
+// classmate-alt-intl - us(alt-intl)
+// RCTL is generated by Fn+Alt, because that, when trying to access
+// the level3 symbols at 7,8,9,0,u,i,o,p,j,k,l,;,m,. and / we got
+// the keypad keycodes. The keypad is changed to make Fn+Alt+<KP_key>
+// generate the same symbol as the original key.
+partial alphanumeric_keys
+xkb_symbols "classmate-alt-intl" {
+ include "us(alt-intl)"
+ name[Group1]= "USA - ClassmatePC (Alternative international)";
+ key.type[Group1]="FOUR_LEVEL";
+
+ key <LSGT> { [ backslash, bar, backslash, bar ] };
+
+ key <KPSU> { [ KP_Subtract, KP_Subtract ] };
+
+ key <KP9> { [ KP_Prior, KP_9,
+ leftsinglequotemark, dead_breve ] };
+ key <KPMU> { [ KP_Multiply, KP_Multiply,
+ rightsinglequotemark, dead_abovering ] };
+
+ key <KPAD> { [ KP_Add, KP_Add,
+ dead_ogonek, dead_diaeresis ] };
+
+ key <KPDL> { [ KP_Delete, KP_Decimal,
+ dead_abovedot, dead_circumflex ] };
+ key <KPDV> { [ KP_Divide, KP_Divide,
+ dead_hook, dead_hook ] };
+
+ include "level3(switch)"
+};
+
+// classmate-altgr-intl - us(altgr-intl)
+// RCTL is generated by Fn+Alt, because that, when trying to access
+// the level3 symbols at 7,8,9,0,u,i,o,p,j,k,l,;,m,. and / we got
+// the keypad keycodes. The keypad is changed to make Fn+Alt+<KP_key>
+// generate the same symbol as the original key.
+partial alphanumeric_keys
+xkb_symbols "classmate-altgr-intl" {
+ include "us(altgr-intl)"
+ name[Group1]= "USA - ClassmatePC (International Fn+Alt dead-keys)";
+ key.type[Group1]="FOUR_LEVEL";
+
+ key <LSGT> { [ backslash, bar, backslash, bar ] };
+
+ key <KP7> { [ KP_Home, KP_7,
+ dead_horn, dead_horn ] };
+ key <KP8> { [ KP_Up, KP_8,
+ dead_ogonek, dead_ogonek ] };
+ key <KP9> { [ KP_Prior, KP_9,
+ leftsinglequotemark, dead_breve ] };
+ key <KPMU> { [ KP_Multiply, KP_Multiply,
+ rightsinglequotemark, dead_abovering ] };
+
+ key <KP4> { [ KP_Left, KP_4,
+ uacute, Uacute ] };
+ key <KP5> { [ KP_Begin, KP_5,
+ iacute, Iacute ] };
+ key <KP6> { [ KP_Right, KP_6,
+ oacute, Oacute ] };
+ key <KPSU> { [ KP_Subtract, KP_Subtract,
+ odiaeresis, Odiaeresis ] };
+
+ key <KP1> { [ KP_End, KP_1,
+ idiaeresis, Idiaeresis ] };
+ key <KP2> { [ KP_Down, KP_2,
+ oe, OE ] };
+ key <KP3> { [ KP_Next, KP_3,
+ oslash, Ooblique ] };
+ key <KPAD> { [ KP_Add, KP_Add,
+ paragraph, degree ] };
+
+ key <KP0> { [ KP_Insert, KP_0,
+ mu, mu ] };
+ key <KPDL> { [ KP_Delete, KP_Decimal,
+ dead_abovedot, dead_caron ] };
+ key <KPDV> { [ KP_Divide, KP_Divide,
+ questiondown, dead_hook ] };
+
+ include "level3(switch)"
+};
+
+partial alphanumeric_keys
+xkb_symbols "olpc" {
+
+ include "us(basic)"
+ name[Group1]= "USA";
+
+ // OLPC international US English keyboard layout.
+ // It's a little different from the usual international layout.
+ // See: http://wiki.laptop.org/go/Image:Keyboard_english.png
+
+ key <TLDE> { [ grave, asciitilde, dead_grave, dead_tilde ] };
+ key <AE01> { [ 1, exclam, exclamdown, exclamdown ] };
+ key <AE02> { [ 2, at, notsign, notsign ] };
+ key <AE03> { [ 3, numbersign, 0x1000300, 0x1000300 ] }; // combining grave
+ key <AE04> { [ 4, dollar, 0x1000301, 0x1000301 ] }; // combining acute
+ key <AE05> { [ 5, percent, 0x1000306, 0x1000306 ] }; // combining breve above
+ key <AE06> { [ 6,asciicircum, 0x100030A, 0x100030A ] }; // combining ring above
+ key <AE07> { [ 7, ampersand, 0x1000302, 0x1000302 ] }; // combining circumflex above
+ key <AE08> { [ 8, asterisk, 0x100030C, 0x100030C ] }; // combining caron above
+ key <AE09> { [ 9, parenleft, 0x1000307, 0x1000307 ] }; // combining dot above
+ key <AE10> { [ 0, parenright, 0x1000308, 0x1000308 ] }; // combining diaeresis above
+ key <AE11> { [ minus, underscore, 0x1000304, 0x1000304 ] }; // combining macron above
+ key <AE12> { [ equal, plus, 0x1000303, 0x1000303 ] }; // combining tilde above
+
+ key <AD01> { [ q, Q, Greek_omega, Greek_OMEGA ] };
+ key <AD02> { [ w, W, oslash, Oslash ] };
+ key <AD03> { [ e, E, oe, OE ] };
+ key <AD04> { [ r, R, 0x1000327, 0x1000327 ] }; // combining cedilla
+ key <AD05> { [ t, T, 0x100032E, 0x100032E ] }; // combining breve below
+ key <AD06> { [ y, Y, 0x1000325, 0x1000325 ] }; // combining ring below
+ key <AD07> { [ u, U, 0x100032D, 0x100032D ] }; // combining circumflex below
+ key <AD08> { [ i, I, 0x100032C, 0x100032C ] }; // combining caron below
+ key <AD09> { [ o, O, 0x1000323, 0x1000323 ] }; // combining dot below
+ key <AD10> { [ p, P, 0x1000324, 0x1000324 ] }; // combining diaeresis below
+ key <AD11> { [ bracketleft, braceleft, 0x1000331, 0x1000331 ] }; // combining macron below
+ key <AD12> { [bracketright, braceright, 0x1000330, 0x1000330 ] }; // combining tilde below
+
+ key <AC01> { [ a, A, ae, AE ] };
+ key <AC02> { [ s, S, ssharp, 0x1001E9C ] }; // uppercase S sharp
+ key <AC03> { [ d, D, eth, ETH ] };
+ key <AC04> { [ f, F, thorn, THORN ] };
+ key <AC06> { [ h, H, sterling, sterling ] };
+ key <AC07> { [ j, J, EuroSign, EuroSign ] };
+ key <AC10> { [ semicolon, colon, masculine, ordfeminine ] };
+ key <AC11> { [ apostrophe, quotedbl, currency, currency ] };
+ key <BKSL> { [ backslash, bar, section, section ] };
+
+ key <AB03> { [ c, C, ccedilla, Ccedilla ] };
+ key <AB06> { [ n, N, ntilde, Ntilde ] };
+ key <AB07> { [ m, M, mu, mu ] };
+ key <AB08> { [ comma, less, guillemotleft, guillemotleft ] };
+ key <AB09> { [ period, greater, guillemotright, guillemotright ] };
+ key <AB10> { [ slash, question, questiondown, questiondown ] };
+
+ key <I219> { [ multiply, division, ISO_Next_Group, ISO_Prev_Group ] };
+
+ include "level3(ralt_switch)"
+};
+
+partial alphanumeric_keys
+xkb_symbols "olpc2" {
+ include "us(olpc)"
+ name[Group1]= "USA - Layout toggle on multiply/divide key";
+ include "group(olpc)"
+};
+
+// Based on Cherokee Nation Official Layout
+// http://www.cherokee.org/extras/downloads/font/Keyboard.htm
+
+partial alphanumeric_keys modifier_keys
+xkb_symbols "chr" {
+
+ name[Group1]= "USA - Cherokee";
+ key.type[group1]="ALPHABETIC";
+
+ // Alphanumeric section
+ key <TLDE> { [ grave, U13CA ] };
+ key <AE01> { [ 1, U13B1 ] };
+ key <AE02> { [ 2, U13C7 ] };
+ key <AE03> { [ 3, U13E7 ] };
+ key <AE04> { [ U13D9, U13B0 ] };
+ key <AE05> { [ U13E6, U13B9 ] };
+ key <AE06> { [ U13DC, U13DD ] };
+ key <AE07> { [ U13CB, U13E1 ] };
+ key <AE08> { [ U13D6, U13BA ] };
+ key <AE09> { [ U13D2, parenleft ] };
+ key <AE10> { [ U13C4, parenright ] };
+ key <AE11> { [ U13BF, U13BC ] };
+ key <AE12> { [ U13F3, U13BD ] };
+
+ key <AD01> { [ U13AA, U13C6 ] };
+ key <AD02> { [ U13B3, U13EB ] };
+ key <AD03> { [ U13A1, U13E3 ] };
+ key <AD04> { [ U13DB, U13CF ] };
+ key <AD05> { [ U13D4, U13D8 ] };
+ key <AD06> { [ U13EF, U13F2 ] };
+ key <AD07> { [ U13A4, U13AD ] };
+ key <AD08> { [ U13A2, U13F1 ] };
+ key <AD09> { [ U13A3, U13EC ] };
+ key <AD10> { [ U13C1, U13EA ] };
+ key <AD11> { [ U13D5, U13D1 ] };
+ key <AD12> { [ U13B6, U13E4 ] };
+ key <BKSL> { [ U13E9, U13EE ] };
+
+ key <AC01> { [ U13A0, U13CC ] };
+ key <AC02> { [ U13CD, U13CE ] };
+ key <AC03> { [ U13D7, U13D0 ] };
+ key <AC04> { [ U13A9, U13C8 ] };
+ key <AC05> { [ U13A6, U13E5 ] };
+ key <AC06> { [ U13AF, U13B2 ] };
+ key <AC07> { [ U13DA, U13AB ] };
+ key <AC08> { [ U13B8, U13A7 ] };
+ key <AC09> { [ U13B5, U13AE ] };
+ key <AC10> { [ U13E8, U13E0 ] };
+ key <AC11> { [ apostrophe, quotedbl ] };
+
+ key <AB01> { [ U13AC, U13C3 ] };
+ key <AB02> { [ U13F4, U13ED ] };
+ key <AB03> { [ U13D3, U13DF ] };
+ key <AB04> { [ U13A5, U13DE ] };
+ key <AB05> { [ U13A8, U13F0 ] };
+ key <AB06> { [ U13BE, U13BB ] };
+ key <AB07> { [ U13C5, U13B7 ] };
+ key <AB08> { [ comma, U13E2 ] };
+ key <AB09> { [ period, U13B4 ] };
+ key <AB10> { [ U13C2, U13C9 ] };
+
+ // End alphanumeric section
+};
+
+// Serbian charecters added as third level symbols to US keyboard layout.
+
+partial alphanumeric_keys
+xkb_symbols "hbs" {
+
+ name[Group1]= "USA - Serbo-Croatian";
+
+ include "us"
+
+ key <TLDE> { [ grave, asciitilde ] };
+ key <AE06> { [ 6, dead_caron, asciicircum, asciicircum ] };
+ key <AC09> { [ l, L, U1C9, U1C8 ] };
+ key <AB06> { [ n, N, U1CC, U1CB ] };
+ key <AB01> { [ z, Z, U1C6, U1C5 ] };
+ key <AD03> { [ e, E, EuroSign, cent ] };
+ key <AC03> { [ d, D, dstroke, Dstroke ] };
+ key <AC11> { [ dead_acute, quotedbl, apostrophe, apostrophe ] };
+ key <SPCE> { [ space, space, nobreakspace, nobreakspace ] };
+ key <AB08> { [ comma, less, NoSymbol, guillemotright ] };
+ key <AB09> { [ period, greater, NoSymbol, guillemotleft ] };
+
+ include "level3(ralt_switch)"
+};
+
+//based on http://upload.wikimedia.org/wikipedia/commons/1/18/T-Mobile_G1_launch_event_2.jpg
+partial alphanumeric_keys
+xkb_symbols "htcdream" {
+ include "inet(htcdream)"
+ name[Group1]= "USA - htcdream";
+
+ //second row
+ key <AD01> { [ q, Q, Tab, Tab ] };
+ key <AD02> { [ w, W, grave, grave ] };
+ key <AD03> { [ e, E, underscore, underscore ] };
+ key <AD04> { [ r, R, sterling, sterling ] };
+ key <AD05> { [ t, T, EuroSign, EuroSign ] };
+ key <AD06> { [ y, Y, division, division ] };
+ key <AD07> { [ u, U, multiply, multiply ] };
+ key <AD08> { [ i, I, minus, minus ] };
+ key <AD09> { [ o, O, plus, plus ] };
+ key <AD10> { [ p, P, equal, equal ] };
+
+ //third row
+ key <AC01> { [ a, A, NoSymbol, NoSymbol ] };
+ key <AC02> { [ s, S, bar, bar ] };
+ key <AC03> { [ d ,D, backslash, backslash ] };
+ key <AC04> { [ f, F, braceleft, braceleft ] };
+ key <AC05> { [ g, G, braceright, braceright ] };
+ key <AC06> { [ h, H, colon, colon ] };
+ key <AC07> { [ j, J, semicolon, semicolon ] };
+ key <AC08> { [ k, K, quotedbl, quotedbl ] };
+ key <AC09> { [ l, L, apostrophe, apostrophe ] };
+
+ //forth row
+ key <AB01> { [ z, Z, NoSymbol, NoSymbol ] };
+ key <AB02> { [ x, X, NoSymbol, NoSymbol ] };
+ key <AB03> { [ c, C, NoSymbol, NoSymbol ] };
+ key <AB04> { [ v, V, bracketleft, bracketleft ] };
+ key <AB05> { [ b, B, bracketright, bracketright ] };
+ key <AB06> { [ n, N, less, less ] };
+ key <AB07> { [ m, M, greater, greater ] };
+ key <AB08> { [ comma, comma, question, question ] };
+
+ //fifth row
+ key <FK15> { [ at, at, asciitilde, asciitilde ] };
+
+ include "level3(alt_switch)"
+};