kdrive: allow screen size specification

This commit is contained in:
Keith Packard 2000-12-08 22:59:37 +00:00
parent 6b61d48f21
commit d09a156d92
2 changed files with 86 additions and 44 deletions

View File

@ -21,7 +21,7 @@
* TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
* PERFORMANCE OF THIS SOFTWARE. * PERFORMANCE OF THIS SOFTWARE.
*/ */
/* $XFree86: xc/programs/Xserver/hw/kdrive/kdrive.c,v 1.7 2000/09/15 15:18:59 keithp Exp $ */ /* $XFree86: xc/programs/Xserver/hw/kdrive/kdrive.c,v 1.10 2000/09/27 20:47:36 keithp Exp $ */
#include "kdrive.h" #include "kdrive.h"
#ifdef PSEUDO8 #ifdef PSEUDO8
@ -304,12 +304,30 @@ ddxGiveUp ()
Bool kdDumbDriver; Bool kdDumbDriver;
Bool kdSoftCursor; Bool kdSoftCursor;
char *
KdParseFindNext (char *cur, char *delim, char *save, char *last)
{
while (*cur && !strchr (delim, *cur))
{
*save++ = *cur++;
}
*save = 0;
*last = *cur;
if (*cur)
cur++;
return cur;
}
void void
KdParseScreen (KdScreenInfo *screen, KdParseScreen (KdScreenInfo *screen,
char *arg) char *arg)
{ {
char *bpp; char *bpp;
char delim;
char save[1024];
int fb; int fb;
int i;
int pixels, mm;
screen->dumb = kdDumbDriver; screen->dumb = kdDumbDriver;
screen->softCursor = kdSoftCursor; screen->softCursor = kdSoftCursor;
@ -317,55 +335,74 @@ KdParseScreen (KdScreenInfo *screen,
kdSoftCursor = FALSE; kdSoftCursor = FALSE;
screen->width = 0; screen->width = 0;
screen->height = 0; screen->height = 0;
screen->width_mm = 0;
screen->height_mm = 0;
screen->rate = 0; screen->rate = 0;
for (fb = 0; fb < KD_MAX_FB; fb++) for (fb = 0; fb < KD_MAX_FB; fb++)
screen->fb[fb].depth = 0; screen->fb[fb].depth = 0;
if (!arg) if (!arg)
return; return;
if (strlen (arg) > sizeof (save))
return;
for (i = 0; i < 2; i++)
{
arg = KdParseFindNext (arg, "x/", save, &delim);
if (!save[0])
return;
pixels = atoi(save);
mm = 0;
if (delim == '/')
{
arg = KdParseFindNext (arg, "x", save, &delim);
if (!save[0])
return;
mm = atoi(save);
}
if (i == 0)
{
screen->width = pixels;
screen->width_mm = mm;
}
else
{
screen->height = pixels;
screen->height_mm = mm;
}
if (delim != 'x')
return;
}
screen->width = atoi(arg);
arg = strchr (arg, 'x');
if (!arg)
return;
arg++;
screen->height = atoi(arg);
arg = strchr (arg, 'x');
if (!arg)
return;
arg++;
fb = 0; fb = 0;
while (fb < KD_MAX_FB) while (fb < KD_MAX_FB)
{ {
screen->fb[fb].depth = atoi(arg); arg = KdParseFindNext (arg, "x/,", save, &delim);
if (!save[0])
bpp = strchr (arg, '/'); break;
if (bpp) screen->fb[fb].depth = atoi(save);
if (delim == '/')
{ {
bpp++; arg = KdParseFindNext (arg, "x,", save, &delim);
screen->fb[fb].bitsPerPixel = atoi(bpp); if (!save[0])
arg = bpp; break;
screen->fb[fb].bitsPerPixel = atoi (save);
} }
else else
screen->fb[fb].bitsPerPixel = 0; screen->fb[fb].bitsPerPixel = 0;
bpp = strchr (arg, ','); if (delim != ',')
if (!bpp)
break; break;
arg = bpp+1;
fb++; fb++;
} }
arg = strchr (arg, 'x'); if (delim == 'x')
if (!arg) {
return; arg = KdParseFindNext (arg, "x", save, &delim);
arg++; if (save[0])
screen->rate = atoi(save);
screen->rate = atoi(arg); }
arg = strchr (arg, 'x');
if (!arg)
return;
arg++;
} }
int int
@ -615,7 +652,7 @@ KdScreenInit(int index, ScreenPtr pScreen, int argc, char **argv)
if (!fbSetupScreen (pScreen, if (!fbSetupScreen (pScreen,
screen->fb[0].frameBuffer, screen->fb[0].frameBuffer,
screen->width, screen->height, screen->width, screen->height,
screen->dpix, screen->dpiy, 75, 75,
screen->fb[0].pixelStride, screen->fb[0].pixelStride,
screen->fb[0].bitsPerPixel)) screen->fb[0].bitsPerPixel))
{ {
@ -648,7 +685,7 @@ KdScreenInit(int index, ScreenPtr pScreen, int argc, char **argv)
screen->fb[0].frameBuffer, screen->fb[0].frameBuffer,
screen->fb[1].frameBuffer, screen->fb[1].frameBuffer,
screen->width, screen->height, screen->width, screen->height,
screen->dpix, screen->dpiy, 75, 75,
screen->fb[0].pixelStride, screen->fb[0].pixelStride,
screen->fb[1].pixelStride, screen->fb[1].pixelStride,
screen->fb[0].bitsPerPixel, screen->fb[0].bitsPerPixel,
@ -664,8 +701,8 @@ KdScreenInit(int index, ScreenPtr pScreen, int argc, char **argv)
{ {
if (!fbFinishScreenInit (pScreen, if (!fbFinishScreenInit (pScreen,
screen->fb[0].frameBuffer, screen->fb[0].frameBuffer,
screen->width, screen->height, screen->width, screen->height,
screen->dpix, screen->dpiy, 75, 75,
screen->fb[0].pixelStride, screen->fb[0].pixelStride,
screen->fb[0].bitsPerPixel)) screen->fb[0].bitsPerPixel))
{ {
@ -673,6 +710,15 @@ KdScreenInit(int index, ScreenPtr pScreen, int argc, char **argv)
} }
} }
/*
* Fix screen sizes; for some reason mi takes dpi instead of mm.
* Rounding errors are annoying
*/
if (screen->width_mm)
pScreen->mmWidth = screen->width_mm;
if (screen->height_mm)
pScreen->mmHeight = screen->height_mm;
/* /*
* Plug in our own block/wakeup handlers. * Plug in our own block/wakeup handlers.
* miScreenInit installs NoopDDA in both places * miScreenInit installs NoopDDA in both places
@ -769,11 +815,6 @@ KdInitScreen (ScreenInfo *pScreenInfo,
(*card->cfuncs->scrinit) (screen); (*card->cfuncs->scrinit) (screen);
if (!screen->dpix)
screen->dpix = 75;
if (!screen->dpiy)
screen->dpiy = 75;
if (!card->cfuncs->initAccel) if (!card->cfuncs->initAccel)
screen->dumb = TRUE; screen->dumb = TRUE;
if (!card->cfuncs->initCursor) if (!card->cfuncs->initCursor)

View File

@ -21,7 +21,7 @@
* TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
* PERFORMANCE OF THIS SOFTWARE. * PERFORMANCE OF THIS SOFTWARE.
*/ */
/* $XFree86: xc/programs/Xserver/hw/kdrive/kdrive.h,v 1.10 2000/09/27 20:47:37 keithp Exp $ */ /* $XFree86: xc/programs/Xserver/hw/kdrive/kdrive.h,v 1.11 2000/11/29 08:42:25 keithp Exp $ */
#include <stdio.h> #include <stdio.h>
#include "X.h" #include "X.h"
@ -104,7 +104,8 @@ typedef struct _KdScreenInfo {
int width; int width;
int height; int height;
int rate; int rate;
int dpix, dpiy; int width_mm;
int height_mm;
Bool dumb; Bool dumb;
Bool softCursor; Bool softCursor;
int mynum; int mynum;