Merge branch 'server-1.5-branch' into xorg-server-1.5-apple
This commit is contained in:
commit
f5201d47d0
|
@ -26,8 +26,8 @@ dnl
|
|||
dnl Process this file with autoconf to create configure.
|
||||
|
||||
AC_PREREQ(2.57)
|
||||
AC_INIT([xorg-server], 1.5.1, [https://bugs.freedesktop.org/enter_bug.cgi?product=xorg], xorg-server)
|
||||
RELEASE_DATE="23 September 2008"
|
||||
AC_INIT([xorg-server], 1.5.2, [https://bugs.freedesktop.org/enter_bug.cgi?product=xorg], xorg-server)
|
||||
RELEASE_DATE="10 October 2008"
|
||||
AC_CONFIG_SRCDIR([Makefile.am])
|
||||
AM_INIT_AUTOMAKE([dist-bzip2 foreign])
|
||||
AM_MAINTAINER_MODE
|
||||
|
|
205
dix/privates.c
205
dix/privates.c
|
@ -40,8 +40,9 @@ from The Open Group.
|
|||
#include "inputstr.h"
|
||||
|
||||
struct _Private {
|
||||
int state;
|
||||
pointer value;
|
||||
DevPrivateKey key;
|
||||
pointer value;
|
||||
struct _Private *next;
|
||||
};
|
||||
|
||||
typedef struct _PrivateDesc {
|
||||
|
@ -49,36 +50,22 @@ typedef struct _PrivateDesc {
|
|||
unsigned size;
|
||||
CallbackListPtr initfuncs;
|
||||
CallbackListPtr deletefuncs;
|
||||
struct _PrivateDesc *next;
|
||||
} PrivateDescRec;
|
||||
|
||||
#define PRIV_MAX 256
|
||||
#define PRIV_STEP 16
|
||||
|
||||
/* list of all allocated privates */
|
||||
static PrivateDescRec items[PRIV_MAX];
|
||||
static int nextPriv;
|
||||
static PrivateDescRec *items = NULL;
|
||||
|
||||
static PrivateDescRec *
|
||||
static _X_INLINE PrivateDescRec *
|
||||
findItem(const DevPrivateKey key)
|
||||
{
|
||||
if (!*key) {
|
||||
if (nextPriv >= PRIV_MAX)
|
||||
return NULL;
|
||||
|
||||
items[nextPriv].key = key;
|
||||
*key = nextPriv;
|
||||
nextPriv++;
|
||||
PrivateDescRec *item = items;
|
||||
while (item) {
|
||||
if (item->key == key)
|
||||
return item;
|
||||
item = item->next;
|
||||
}
|
||||
|
||||
return items + *key;
|
||||
}
|
||||
|
||||
static _X_INLINE int
|
||||
privateExists(PrivateRec **privates, const DevPrivateKey key)
|
||||
{
|
||||
return *key && *privates &&
|
||||
(*privates)[0].state > *key &&
|
||||
(*privates)[*key].state;
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -88,10 +75,21 @@ _X_EXPORT int
|
|||
dixRequestPrivate(const DevPrivateKey key, unsigned size)
|
||||
{
|
||||
PrivateDescRec *item = findItem(key);
|
||||
if (!item)
|
||||
return FALSE;
|
||||
if (size > item->size)
|
||||
if (item) {
|
||||
if (size > item->size)
|
||||
item->size = size;
|
||||
} else {
|
||||
item = (PrivateDescRec *)xalloc(sizeof(PrivateDescRec));
|
||||
if (!item)
|
||||
return FALSE;
|
||||
memset(item, 0, sizeof(PrivateDescRec));
|
||||
|
||||
/* add privates descriptor */
|
||||
item->key = key;
|
||||
item->size = size;
|
||||
item->next = items;
|
||||
items = item;
|
||||
}
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
|
@ -102,52 +100,25 @@ _X_EXPORT pointer *
|
|||
dixAllocatePrivate(PrivateRec **privates, const DevPrivateKey key)
|
||||
{
|
||||
PrivateDescRec *item = findItem(key);
|
||||
PrivateCallbackRec calldata;
|
||||
PrivateRec *ptr;
|
||||
pointer value;
|
||||
int oldsize, newsize;
|
||||
unsigned size = sizeof(PrivateRec);
|
||||
|
||||
if (item)
|
||||
size += item->size;
|
||||
|
||||
newsize = (*key / PRIV_STEP + 1) * PRIV_STEP;
|
||||
|
||||
/* resize or init privates array */
|
||||
if (!item)
|
||||
ptr = (PrivateRec *)xcalloc(size, 1);
|
||||
if (!ptr)
|
||||
return NULL;
|
||||
ptr->key = key;
|
||||
ptr->value = (size > sizeof(PrivateRec)) ? (ptr + 1) : NULL;
|
||||
ptr->next = *privates;
|
||||
*privates = ptr;
|
||||
|
||||
/* initialize privates array if necessary */
|
||||
if (!*privates) {
|
||||
ptr = xcalloc(newsize, sizeof(*ptr));
|
||||
if (!ptr)
|
||||
return NULL;
|
||||
*privates = ptr;
|
||||
(*privates)[0].state = newsize;
|
||||
/* call any init funcs and return */
|
||||
if (item) {
|
||||
PrivateCallbackRec calldata = { key, &ptr->value };
|
||||
CallCallbacks(&item->initfuncs, &calldata);
|
||||
}
|
||||
|
||||
oldsize = (*privates)[0].state;
|
||||
|
||||
/* resize privates array if necessary */
|
||||
if (*key >= oldsize) {
|
||||
ptr = xrealloc(*privates, newsize * sizeof(*ptr));
|
||||
if (!ptr)
|
||||
return NULL;
|
||||
memset(ptr + oldsize, 0, (newsize - oldsize) * sizeof(*ptr));
|
||||
*privates = ptr;
|
||||
(*privates)[0].state = newsize;
|
||||
}
|
||||
|
||||
/* initialize slot */
|
||||
ptr = *privates + *key;
|
||||
ptr->state = 1;
|
||||
if (item->size) {
|
||||
value = xcalloc(item->size, 1);
|
||||
if (!value)
|
||||
return NULL;
|
||||
ptr->value = value;
|
||||
}
|
||||
|
||||
calldata.key = key;
|
||||
calldata.value = &ptr->value;
|
||||
CallCallbacks(&item->initfuncs, &calldata);
|
||||
|
||||
return &ptr->value;
|
||||
}
|
||||
|
||||
|
@ -157,10 +128,14 @@ dixAllocatePrivate(PrivateRec **privates, const DevPrivateKey key)
|
|||
_X_EXPORT pointer
|
||||
dixLookupPrivate(PrivateRec **privates, const DevPrivateKey key)
|
||||
{
|
||||
PrivateRec *rec = *privates;
|
||||
pointer *ptr;
|
||||
|
||||
if (privateExists(privates, key))
|
||||
return (*privates)[*key].value;
|
||||
while (rec) {
|
||||
if (rec->key == key)
|
||||
return rec->value;
|
||||
rec = rec->next;
|
||||
}
|
||||
|
||||
ptr = dixAllocatePrivate(privates, key);
|
||||
return ptr ? *ptr : NULL;
|
||||
|
@ -172,8 +147,13 @@ dixLookupPrivate(PrivateRec **privates, const DevPrivateKey key)
|
|||
_X_EXPORT pointer *
|
||||
dixLookupPrivateAddr(PrivateRec **privates, const DevPrivateKey key)
|
||||
{
|
||||
if (privateExists(privates, key))
|
||||
return &(*privates)[*key].value;
|
||||
PrivateRec *rec = *privates;
|
||||
|
||||
while (rec) {
|
||||
if (rec->key == key)
|
||||
return &rec->value;
|
||||
rec = rec->next;
|
||||
}
|
||||
|
||||
return dixAllocatePrivate(privates, key);
|
||||
}
|
||||
|
@ -184,10 +164,16 @@ dixLookupPrivateAddr(PrivateRec **privates, const DevPrivateKey key)
|
|||
_X_EXPORT int
|
||||
dixSetPrivate(PrivateRec **privates, const DevPrivateKey key, pointer val)
|
||||
{
|
||||
PrivateRec *rec;
|
||||
|
||||
top:
|
||||
if (privateExists(privates, key)) {
|
||||
(*privates)[*key].value = val;
|
||||
return TRUE;
|
||||
rec = *privates;
|
||||
while (rec) {
|
||||
if (rec->key == key) {
|
||||
rec->value = val;
|
||||
return TRUE;
|
||||
}
|
||||
rec = rec->next;
|
||||
}
|
||||
|
||||
if (!dixAllocatePrivate(privates, key))
|
||||
|
@ -201,23 +187,27 @@ dixSetPrivate(PrivateRec **privates, const DevPrivateKey key, pointer val)
|
|||
_X_EXPORT void
|
||||
dixFreePrivates(PrivateRec *privates)
|
||||
{
|
||||
int i;
|
||||
PrivateRec *ptr, *next;
|
||||
PrivateDescRec *item;
|
||||
PrivateCallbackRec calldata;
|
||||
|
||||
if (privates)
|
||||
for (i = 1; i < privates->state; i++)
|
||||
if (privates[i].state) {
|
||||
/* call the delete callbacks */
|
||||
calldata.key = items[i].key;
|
||||
calldata.value = &privates[i].value;
|
||||
CallCallbacks(&items[i].deletefuncs, &calldata);
|
||||
|
||||
/* free pre-allocated memory */
|
||||
if (items[i].size)
|
||||
xfree(privates[i].value);
|
||||
}
|
||||
|
||||
xfree(privates);
|
||||
/* first pass calls the delete callbacks */
|
||||
for (ptr = privates; ptr; ptr = ptr->next) {
|
||||
item = findItem(ptr->key);
|
||||
if (item) {
|
||||
calldata.key = ptr->key;
|
||||
calldata.value = &ptr->value;
|
||||
CallCallbacks(&item->deletefuncs, &calldata);
|
||||
}
|
||||
}
|
||||
|
||||
/* second pass frees the memory */
|
||||
ptr = privates;
|
||||
while (ptr) {
|
||||
next = ptr->next;
|
||||
xfree(ptr);
|
||||
ptr = next;
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -228,9 +218,11 @@ dixRegisterPrivateInitFunc(const DevPrivateKey key,
|
|||
CallbackProcPtr callback, pointer data)
|
||||
{
|
||||
PrivateDescRec *item = findItem(key);
|
||||
if (!item)
|
||||
return FALSE;
|
||||
|
||||
if (!item) {
|
||||
if (!dixRequestPrivate(key, 0))
|
||||
return FALSE;
|
||||
item = findItem(key);
|
||||
}
|
||||
return AddCallback(&item->initfuncs, callback, data);
|
||||
}
|
||||
|
||||
|
@ -239,9 +231,11 @@ dixRegisterPrivateDeleteFunc(const DevPrivateKey key,
|
|||
CallbackProcPtr callback, pointer data)
|
||||
{
|
||||
PrivateDescRec *item = findItem(key);
|
||||
if (!item)
|
||||
return FALSE;
|
||||
|
||||
if (!item) {
|
||||
if (!dixRequestPrivate(key, 0))
|
||||
return FALSE;
|
||||
item = findItem(key);
|
||||
}
|
||||
return AddCallback(&item->deletefuncs, callback, data);
|
||||
}
|
||||
|
||||
|
@ -298,17 +292,16 @@ dixLookupPrivateOffset(RESTYPE type)
|
|||
int
|
||||
dixResetPrivates(void)
|
||||
{
|
||||
int i;
|
||||
PrivateDescRec *next;
|
||||
|
||||
/* reset private descriptors */
|
||||
for (i = 1; i < nextPriv; i++) {
|
||||
*items[i].key = 0;
|
||||
DeleteCallbackList(&items[i].initfuncs);
|
||||
DeleteCallbackList(&items[i].deletefuncs);
|
||||
/* reset internal structures */
|
||||
while (items) {
|
||||
next = items->next;
|
||||
DeleteCallbackList(&items->initfuncs);
|
||||
DeleteCallbackList(&items->deletefuncs);
|
||||
xfree(items);
|
||||
items = next;
|
||||
}
|
||||
nextPriv = 1;
|
||||
|
||||
/* reset offsets */
|
||||
if (offsets)
|
||||
xfree(offsets);
|
||||
offsetsSize = sizeof(offsetDefaults);
|
||||
|
|
|
@ -85,6 +85,47 @@ handle_edid_quirks(xf86MonPtr m)
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* some monitors encode the aspect ratio instead of the physical size.
|
||||
* try to find the largest detailed timing that matches that aspect
|
||||
* ratio and use that to fill in the feature section.
|
||||
*/
|
||||
if ((m->features.hsize == 16 && m->features.vsize == 9) ||
|
||||
(m->features.hsize == 16 && m->features.vsize == 10) ||
|
||||
(m->features.hsize == 4 && m->features.vsize == 3) ||
|
||||
(m->features.hsize == 5 && m->features.vsize == 4)) {
|
||||
int real_hsize = 0, real_vsize = 0;
|
||||
float target_aspect, timing_aspect;
|
||||
|
||||
target_aspect = (float)m->features.hsize / (float)m->features.vsize;
|
||||
for (i = 0; i < 4; i++) {
|
||||
if (m->det_mon[i].type == DT) {
|
||||
struct detailed_timings *timing;
|
||||
timing = &m->det_mon[i].section.d_timings;
|
||||
|
||||
if (!timing->v_size)
|
||||
continue;
|
||||
|
||||
timing_aspect = (float)timing->h_size / (float)timing->v_size;
|
||||
if (fabs(1 - (timing_aspect / target_aspect)) < 0.05) {
|
||||
real_hsize = max(real_hsize, timing->h_size);
|
||||
real_vsize = max(real_vsize, timing->v_size);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (real_hsize && real_vsize) {
|
||||
/* convert mm to cm */
|
||||
m->features.hsize = (real_hsize + 5) / 10;
|
||||
m->features.vsize = (real_vsize + 5) / 10;
|
||||
} else {
|
||||
m->features.hsize = m->features.vsize = 0;
|
||||
}
|
||||
|
||||
xf86Msg(X_INFO, "Quirked EDID physical size to %dx%d cm\n",
|
||||
m->features.hsize, m->features.vsize);
|
||||
}
|
||||
}
|
||||
|
||||
xf86MonPtr
|
||||
|
|
|
@ -19,7 +19,7 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|||
* STUFF FOR PRIVATES
|
||||
*****************************************************************/
|
||||
|
||||
typedef int *DevPrivateKey;
|
||||
typedef void *DevPrivateKey;
|
||||
struct _Private;
|
||||
typedef struct _Private PrivateRec;
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user