Пример #1
0
static void
draw_enable(void)
{
	if(visible)
		return;
	visible = 1;

	/* restore screen drawing functions*/
	set_subdriver(&scrdev, &save, FALSE);
}
Пример #2
0
static void
draw_disable(void)
{
	if(!visible)
		return;
	visible = 0;

	/* save screen drawing functions and reroute drawing*/
	get_subdriver(&scrdev, &save);

	/* set null driver*/
	set_subdriver(&scrdev, &nulldriver, FALSE);
}
Пример #3
0
/* initialize memory device with passed parms, and select suitable fb driver*/
static MWBOOL
VGA_mapmemgc(PSD mempsd,MWCOORD w,MWCOORD h,int planes,int bpp,int linelen,
	int size,void *addr)
{
	extern SUBDRIVER memplan4;

	/* initialize mem screen driver*/
	initmemgc(mempsd, w, h, planes, bpp, linelen, size, addr);

	/* set and initialize subdriver into mem screen driver*/
	if (!set_subdriver(mempsd, &memplan4, TRUE))
		return 0;

	return 1;
}
Пример #4
0
/* 
 * Initialize memory device with passed parms,
 * select suitable framebuffer subdriver,
 * and set subdriver in memory device.
 */
MWBOOL
fb_mapmemgc(PSD mempsd,MWCOORD w,MWCOORD h,int planes,int bpp,int linelen,
	int size,void *addr)
{
	PSUBDRIVER subdriver;

	/* initialize mem screen driver*/
	initmemgc(mempsd, w, h, planes, bpp, linelen, size, addr);

/* FIXME kluge for current portrait mode subdriver in scr_fbportrait.c*/
//if(mempsd->portrait != MWPORTRAIT_NONE) return 1;

	/* select a framebuffer subdriver based on planes and bpp*/
	subdriver = select_fb_subdriver(mempsd);
	if(!subdriver)
		return 0;

	/* set and initialize subdriver into mem screen driver*/
	if(!set_subdriver(mempsd, subdriver, TRUE))
		return 0;

	return 1;
}
Пример #5
0
/*
 * Set portrait subdriver or original subdriver according
 * to current portrait mode.
 */
void
set_portrait_subdriver(PSD psd)
{
	PSUBDRIVER subdriver=0;
	extern SUBDRIVER fbportrait_left;
	extern SUBDRIVER fbportrait_right;
	extern SUBDRIVER fbportrait_down;

	switch (psd->portrait) {
	case MWPORTRAIT_NONE:
		subdriver = psd->orgsubdriver;
		break;
	case MWPORTRAIT_LEFT:
		subdriver = &fbportrait_left;
		break;
	case MWPORTRAIT_RIGHT:
		subdriver = &fbportrait_right;
		break;
	case MWPORTRAIT_DOWN:
		subdriver = &fbportrait_down;
		break;
	}
	set_subdriver(psd, subdriver, FALSE);
}
Пример #6
0
/* init framebuffer*/
static PSD
fb_open(PSD psd)
{
    PSUBDRIVER subdriver;

    char* fb=qvfb_connect();

    diag_printf("******** fb is %p\n", fb);

    if (fb==NULL)
       goto fail;

//    diag_printf("DISPLAY=%s\n", cyg_hal_sys_getenv("DISPLAY"));

    assert(status < 2);

    psd->xres = psd->xvirtres = qvfb_width();
    psd->yres = psd->yvirtres = qvfb_height();

    /* set planes from fb type*/
    psd->planes = 1;   /* FIXME */

    psd->bpp = qvfb_depth();

    psd->ncolors = (psd->bpp >= 24)? (1 << 24): (1 << psd->bpp);

    /* set linelen to byte length, possibly converted later*/
    psd->linelen = qvfb_linestep();
    psd->size = 0;		/* force subdriver init of size*/

    psd->flags = PSF_SCREEN | PSF_HAVEBLIT;
    if (psd->bpp == 16)
        psd->flags |= PSF_HAVEOP_COPY;

    /* set pixel format*/
    switch (psd->bpp) {
    case 32:
        psd->pixtype = MWPF_TRUECOLOR0888;
        break;
    case 16:
        psd->pixtype = MWPF_TRUECOLOR565;
        break;
    default:
        EPRINTF("Unsupported display type: %d\n", psd->bpp);
        goto fail;
    }

    diag_printf("%dx%dx%d linelen %d bpp %d\n", psd->xres,
      psd->yres, psd->ncolors, psd->linelen, psd->bpp);

    /* select a framebuffer subdriver based on planes and bpp*/
    subdriver = select_fb_subdriver(psd);
    if (!subdriver) {
        EPRINTF("No driver for screen\n", psd->bpp);
        goto fail;
    }

    /*
     * set and initialize subdriver into screen driver
     * psd->size is calculated by subdriver init
     */
    if(!set_subdriver(psd, subdriver, TRUE)) {
        EPRINTF("Driver initialize failed\n", psd->bpp);
        goto fail;
    }

    /* mmap framebuffer into this address space*/
    psd->addr = fb;
    if(psd->addr == NULL || psd->addr == (unsigned char *)-1) {
//        EPRINTF("Error mmaping %s: %m\n", env);
        goto fail;
    }

    status = 2;
    return psd;	/* success*/

 fail:
    return NULL;
}
Пример #7
0
/* init framebuffer */
static PSD
fb_open (PSD psd)
{
	vesa_mode_info_t mi;
	vesa_display_t display;
	PSUBDRIVER subdriver;
	unsigned short mode;

#if MWPIXEL_FORMAT == MWPF_TRUECOLOR565
	psd->bpp = 16;
#elif MWPIXEL_FORMAT == MWPF_TRUECOLOR888
	psd->bpp = 24;
#elif MWPIXEL_FORMAT == MWPF_TRUECOLOR0888
	psd->bpp = 32;
#elif MWPIXEL_FORMAT == MWPF_TRUECOLOR8888
	psd->bpp = 32;
#else
#error Incorrect value of MWPIXEL_FORMAT!
#endif
	mode = 0;
	if (vesa_get_display_info (&display)) {
		display_x_centimeters = display.max_x;
		display_y_centimeters = display.max_y;
		if (display.misc & VESA_MISC_1ST_DETAIL) {
			/* Get preferred display resolution. */
			psd->xres = display.detailed_modes[0].xres;
			psd->yres = display.detailed_modes[0].yres;
			mode = find_mode (psd->xres, psd->yres, psd->bpp, &mi);
		}
	}
	if (! mode) {
		psd->xres = DEFAULT_WIDTH;
		psd->yres = DEFAULT_HEIGHT;
		mode = find_mode (psd->xres, psd->yres, psd->bpp, &mi);
	}
	if (! mode) {
		debug_printf ("No %d x %d x %d resolution found.\n",
			psd->xres, psd->yres, psd->bpp);
		return 0;
	}

	psd->xvirtres = psd->xres;
	psd->yvirtres = psd->yres;
	psd->planes = 1;
	psd->ncolors = (psd->bpp >= 24) ? (1 << 24) : (1 << psd->bpp);
	psd->linelen = mi.bytes_per_scan_line;
	psd->addr = (void*) mi.phys_base_ptr;

	psd->flags = PSF_SCREEN | PSF_HAVEBLIT;
	switch (psd->bpp) {
	case 16:
		psd->flags |= PSF_HAVEOP_COPY;
		psd->pixtype = MWPF_TRUECOLOR565;
		break;
	case 24:
		psd->pixtype = MWPF_TRUECOLOR888;
		break;
	case 32:
#if MWPIXEL_FORMAT == MWPF_TRUECOLOR8888
		psd->pixtype = MWPF_TRUECOLOR8888;
#else
		psd->pixtype = MWPF_TRUECOLOR0888;
#endif
		break;
	default:
		debug_printf ("Unsupported %d color (%d bpp) truecolor framebuffer\n",
			psd->ncolors, psd->bpp);
		return 0;
	}

	/* select a framebuffer subdriver based on planes and bpp */
	subdriver = select_fb_subdriver (psd);
	if (! subdriver) {
		debug_printf ("No driver for screen bpp %d\n", psd->bpp);
		return 0;
	}

	old_mode = vesa_get_mode ();
	vesa_set_mode (mode | 0x4000); /* linear */

	/*
	 * set and initialize subdriver into screen driver
	 * psd->size is calculated by subdriver init
	 */
	if (! set_subdriver (psd, subdriver, TRUE)) {
		vesa_set_mode (old_mode);
		debug_printf ("Driver initialize failed bpp %d\n", psd->bpp);
		return 0;
	}

	/* Redirect debug_printf() output. */
	debug_redirect (debug_putchar_graphics, (void*) psd);
	return psd;
}
Пример #8
0
/* init framebuffer*/
static PSD
fb_open(PSD psd)
{
	PSUBDRIVER subdriver;
	char *env;

	/* set statically in struct definition, may be overridden before calling fb_open*/
	//psd->xres = psd->xvirtres = SCREEN_WIDTH;
	//psd->yres = psd->yvirtres = SCREEN_HEIGHT;

	/* use pixel format to set bpp*/
	psd->pixtype = MWPIXEL_FORMAT;
	switch (psd->pixtype) {
	case MWPF_TRUECOLORARGB:
	case MWPF_TRUECOLORABGR:
	default:
		psd->bpp = 32;
		break;

	case MWPF_TRUECOLORRGB:
		psd->bpp = 24;
		break;

	case MWPF_TRUECOLOR565:
	case MWPF_TRUECOLOR555:
		psd->bpp = 16;
		break;

	case MWPF_TRUECOLOR332:
		psd->bpp = 8;
		break;

#if MWPIXEL_FORMAT == MWPF_PALETTE
	case MWPF_PALETTE:
		psd->bpp = SCREEN_DEPTH;
		break;
#endif
	}
	psd->planes = 1;

	/* set standard data format from bpp and pixtype*/
	psd->data_format = set_data_format(psd);

	/* Calculate the correct size and pitch from xres, yres and bpp*/
	GdCalcMemGCAlloc(psd, psd->xres, psd->yres, psd->planes, psd->bpp, &psd->size, &psd->pitch);

	psd->ncolors = (psd->bpp >= 24)? (1 << 24): (1 << psd->bpp);
	psd->flags = PSF_SCREEN;
	psd->portrait = MWPORTRAIT_NONE;

	/* select an fb subdriver matching our planes and bpp for backing store*/
	subdriver = select_fb_subdriver(psd);
	psd->orgsubdriver = subdriver;
	if (!subdriver)
		return NULL;

	/* set subdriver into screen driver*/
	set_subdriver(psd, subdriver);

#ifdef PATH_FRAMEBUFFER
	/* try opening framebuffer file for mmap*/
	if((env = getenv("FRAMEBUFFER")) == NULL)
		env = PATH_FRAMEBUFFER;
	fb = open(env, O_RDWR);
#endif
	if (fb >= 0) {
		/* mmap framebuffer into this address space*/
		psd->size = (psd->size + getpagesize() - 1) / getpagesize() * getpagesize();
		psd->addr = mmap(NULL, psd->size, PROT_READ|PROT_WRITE, MAP_SHARED, fb, 0);
		if (psd->addr == NULL || psd->addr == (unsigned char *)-1) {
			EPRINTF("Error mmaping shared framebuffer %s: %m\n", env);
			close(fb);
			return NULL;
		}
	} else {
		/* allocate framebuffer*/
		if ((psd->addr = malloc(psd->size)) == NULL)
			return NULL;
		psd->flags |= PSF_ADDRMALLOC;
	}

	/* allocate update region*/
	fb_updateregion = GdAllocRegion();

	return psd;	/* success*/
}
Пример #9
0
/* init framebuffer*/
static PSD
fb_open(PSD psd)
{
    PSUBDRIVER subdriver;
    struct lcd_info li;

    assert(status < 2);

    // Initialize LCD screen
    lcd_init(16);
    lcd_getinfo(&li);

	psd->portrait = MWPORTRAIT_NONE;
    psd->xres = psd->xvirtres = li.width;
    psd->yres = psd->yvirtres = li.height;
    psd->planes = 1;
    psd->bpp = li.bpp;
    psd->ncolors = (psd->bpp >= 24)? (1 << 24): (1 << psd->bpp);
	psd->pitch = li.rlen;
	psd->size = psd->yres * psd->pitch;
    psd->flags = PSF_SCREEN;

    /* set pixel format*/
    switch (li.type) {
    case FB_TRUE_RGB565:
        psd->pixtype = MWPF_TRUECOLOR565;
        break;
    default:
        EPRINTF("Unsupported display type: %d\n", li.type);
        goto fail;
    }
#if 0
    if(1 /*visual == FB_VISUAL_TRUECOLOR || visual == FB_VISUAL_DIRECTCOLOR*/) {
        switch(psd->bpp) {
        case 8:
            psd->pixtype = MWPF_TRUECOLOR332;
            break;
        case 16:
            psd->pixtype = MWPF_TRUECOLOR565;
            break;
        case 24:
            psd->pixtype = MWPF_TRUECOLOR888;
            break;
        case 32:
            psd->pixtype = MWPF_TRUECOLOR8888;
            break;
        default:
            EPRINTF("Unsupported %d color (%d bpp) truecolor framebuffer\n", psd->ncolors, psd->bpp);
            goto fail;
        }
    } else psd->pixtype = MWPF_PALETTE;
#endif

    diag_printf("%dx%dx%d pitch %d type %d bpp %d\n", psd->xres,
      psd->yres, psd->ncolors, psd->pitch, li.type, psd->bpp);

	/* set standard data format from bpp and pixtype*/
	psd->data_format = set_data_format(psd);

    /* select a framebuffer subdriver based on planes and bpp*/
    subdriver = select_fb_subdriver(psd);
    if (!subdriver) {
        EPRINTF("No driver for screen bpp %d\n", psd->bpp);
        goto fail;
    }

	/* set subdriver into screen driver */
	set_subdriver(psd, subdriver);

    /* mmap framebuffer into this address space*/
    psd->addr = li.fb;
    if(psd->addr == NULL || psd->addr == (unsigned char *)-1) {
//        EPRINTF("Error mmaping %s: %m\n", env);
        goto fail;
    }

#if 0    /* FIXME */
    /* save original palette*/
    ioctl_getpalette(0, 16, saved_red, saved_green, saved_blue);

    /* setup direct color palette if required (ATI cards)*/
    if(visual == FB_VISUAL_DIRECTCOLOR)
        set_directcolor_palette(psd);
#endif

    status = 2;
    return psd;	/* success*/

 fail:
    return NULL;
}
Пример #10
0
/*
**	Open graphics
*/
static PSD
DJGR_open(PSD psd)
{
	PSUBDRIVER subdriver;

	GrVideoMode	*md_info;
	
	int vwidth,vheight,vbpp;
	
	vwidth = SCREEN_WIDTH;
	vheight = SCREEN_HEIGHT;
	if(SCREEN_PIXTYPE == MWPF_TRUECOLOR8888) {
		vbpp=32;
	} else if(SCREEN_PIXTYPE == MWPF_TRUECOLOR888) {
		vbpp=24;
	} else if(SCREEN_PIXTYPE == MWPF_TRUECOLOR565)  {
		vbpp=16;
	} else {
		vbpp=8; //palette
	}

    GrSetMode(GR_width_height_bpp_graphics,vwidth,vheight,vbpp);

    md_info = (GrVideoMode *) GrCurrentVideoMode();

	psd->xres = psd->xvirtres = GrScreenX();
	psd->yres = psd->yvirtres = GrScreenY();
	psd->planes = 1;
	psd->bpp = md_info->bpp;
	psd->ncolors = psd->bpp >= 24 ? (1 << 24) : (1 << psd->bpp);
	psd->flags = PSF_SCREEN | PSF_ADDRMALLOC;
	/* Calculate the correct size and linelen here */
	GdCalcMemGCAlloc(psd, psd->xres, psd->yres, psd->planes, psd->bpp,
		&psd->size, &psd->pitch);

    if(psd->bpp == 32) {
		psd->pixtype = MWPF_TRUECOLOR8888;	
	} else if(psd->bpp == 16) {
		psd->pixtype = MWPF_TRUECOLOR565; 
	} else if(psd->bpp == 24)  {
		psd->pixtype = MWPF_TRUECOLOR888;
	} else {
		psd->pixtype = MWPF_PALETTE;
	}
		  
  psd->portrait = MWPORTRAIT_NONE;
  psd->data_format = set_data_format(psd);

  /*
   * set and initialize subdriver into screen driver
   * psd->size is calculated by subdriver init
   */
  subdriver = select_fb_subdriver(psd);
  
  psd->orgsubdriver = subdriver;

  set_subdriver(psd, subdriver);

  if ((psd->addr = malloc(psd->size)) == NULL)
		return NULL;

  return psd;

}
Пример #11
0
static PSD
n3ds888_open(PSD psd)
{
  PSUBDRIVER subdriver;

  /* init driver variables depending on ega/vga mode*/
  psd->xres = psd->xvirtres = 240;
  psd->yres = psd->yvirtres = 340;
  psd->planes = 1;
  psd->bpp = 24;
  psd->ncolors = psd->bpp >= 24? (1 << 24): (1 << psd->bpp);
  psd->pixtype = MWPF_TRUECOLOR888;
  psd->portrait = MWPORTRAIT_NONE;
  psd->data_format = set_data_format(psd);

  /* Calculate the correct size and pitch from xres, yres and bpp*/
  GdCalcMemGCAlloc(psd, psd->xres, psd->yres, psd->planes, psd->bpp,
		   &psd->size, &psd->pitch);

  psd->flags = PSF_SCREEN;

  /*
   * set and initialize subdriver into screen driver
   * psd->size is calculated by subdriver init
   */
  
  // Currently attempting to use FB16 subdriver
  subdriver = select_fb_subdriver(psd);

  // Check that a valid subdriver exists
  if (!subdriver) 
    {
      EPRINTF("No driver for screen bpp %d\n", psd->bpp);
      return NULL;
    }
 
  psd->orgsubdriver = subdriver;

  set_subdriver(psd, subdriver);

//FB_BOT_1
//  psd->addr = (void*) 0x0008CA00//launcher 0x202118E0;

	srvInit();			// mandatory
	aptInit();			// mandatory
	hidInit(NULL);	// input (buttons, screen)

  gfxInit();
//  screenBottom=0x48F000;
//  screenBottom=gfxGetFramebuffer(GFX_BOTTOM, GFX_BOTTOM, NULL, NULL);

  psd->addr = (void*) gfxGetFramebuffer(GFX_BOTTOM, GFX_BOTTOM, NULL, NULL);
  printf('nano-x --> n3ds888_open \n');
  gfxFlushBuffers();


//    0x1E6000-0x22C500 -- top screen 3D left framebuffer 0(240x400x3) (The "3D right first-framebuf" addr stored in the LCD register is set to this, when the 3D is set to "off")
//    0x22C800-0x272D00 -- top screen 3D left framebuffer 1(240x400x3)
//    0x273000-0x2B9500 -- top screen 3D right framebuffer 0(240x400x3)
//    0x2B9800-0x2FFD00 -- top screen 3D right framebuffer 1(240x400x3)
//    0x48F000-0x4C7400 -- bottom screen framebuffer 0(240x320x3)
//    0x4C7800-0x4FF800 -- bottom screen framebuffer 1(240x320x3) 

  return psd;
}
Пример #12
0
/* init framebuffer*/
static PSD fb_open(PSD psd)
{
	char *	env;
	int	type, visual;
	PSUBDRIVER subdriver;
	struct fb_fix_screeninfo fb_fix;
	struct fb_var_screeninfo fb_var;

	/* locate and open framebuffer, get info*/
	if(!(env = getenv ("FRAMEBUFFER")))
		env = "/dev/fb0";
	fb = open(env, O_RDWR);
	if(fb < 0) {
		fprintf(stderr,"GAL fbcon engine: Error when opening %s: %m. Please check kernel config.\n", env);
		return NULL;
	}
	if(ioctl(fb, FBIOGET_FSCREENINFO, &fb_fix) == -1 ||
		ioctl(fb, FBIOGET_VSCREENINFO, &fb_var) == -1) {
			fprintf(stderr,"GAL fbcon engine: Error when reading screen info: %m.\n");
			goto fail;
	}
	/* setup screen device from framebuffer info*/
	type = fb_fix.type;
	visual = fb_fix.visual;

	psd->xres = psd->xvirtres = fb_var.xres;
	psd->yres = psd->yvirtres = fb_var.yres;

	/* set planes from fb type*/
	if (type == FB_TYPE_VGA_PLANES)
		psd->planes = 4;
	else if (type == FB_TYPE_PACKED_PIXELS)
		psd->planes = 1;
	else psd->planes = 0;	/* force error later*/

	psd->bpp = fb_var.bits_per_pixel;
	psd->ncolors = (psd->bpp >= 24)? (1 << 24): (1 << psd->bpp);

	/* set linelen to byte length, possibly converted later*/
	psd->linelen = (psd->xres * psd->bpp) >> 3;

    /*
     * Some framebuffer drivers give wrong line_length value.
     * If line_length < xres_virtual * bpp, it's certainly wrong.
     * But how do i know if line_length > xres_virtual * bpp.
     * God bless me!
     *          James Liu
     */
    if (fb_fix.line_length > psd->linelen)
        psd->linelen = fb_fix.line_length;

	psd->size = 0;		/* force subdriver init of size*/

	psd->flags = PSF_SCREEN;

    /*
     * For 1bpp, 2bpp and 4bpp framebuffer, some systems have
     * different bit order. That means the highest bits represent
     * the first pixel or the lowest bites represent first pixel.
     * 
     * For example:
     * 
     * EP7211 2bpp:                    Byte 1                                 Byte 2
     *         | D0  D1 | D2  D3 | D4  D5 | D6  D7 |  | D0  D1 | D2  D3 | D4  D5 | D6  D7 |
     *         | pixel0 | pixel1 | pixel2 | pixel3 |  | pixel4 | pixel5 | pixel6 | pixel7 |
     *         
     * Helio 2bpp:                  Byte 1                                 Byte 2
     *         | D0  D1 | D2  D3 | D4  D5 | D6  D7 |  | D0  D1 | D2  D3 | D4  D5 | D6  D7 |
     *         | pixel3 | pixel2 | pixel1 | pixel0 |  | pixel7 | pixel6 | pixel5 | pixel4 |
     */
    if (fb_var.red.msb_right)
        psd->flags |= PSF_MSBRIGHT;

	/* set pixel format*/
	if (visual == FB_VISUAL_TRUECOLOR || visual == FB_VISUAL_DIRECTCOLOR) {
		switch(psd->bpp) {
		case 8:
			psd->pixtype = PF_TRUECOLOR332;
		break;
		case 16:
			psd->pixtype = PF_TRUECOLOR565;
		break;
		case 24:
			psd->pixtype = PF_TRUECOLOR888;
		break;
		case 32:
			psd->pixtype = PF_TRUECOLOR0888;
		break;
		default:
			fprintf(stderr, "GAL fbcon engine: Unsupported FrameBuffer type\n");
			goto fail;
		}
	}
    else 
        psd->pixtype = PF_PALETTE;

	/* select a framebuffer subdriver based on planes and bpp*/
	subdriver = select_fb_subdriver(psd);
	if (!subdriver) {
		fprintf(stderr,"GAL fbcon engine: No driver for screen type %d visual %d bpp %d\n",
			type, visual, psd->bpp);
		goto fail;
	}

	/*
	 * set and initialize subdriver into screen driver
	 * psd->size is calculated by subdriver init
	 */
	if(!set_subdriver(psd, subdriver, TRUE)) {
		fprintf(stderr,"GAL fbcon engine: Driver initialize failed type %d visual %d bpp %d\n",
			type, visual, psd->bpp);
		goto fail;
	}

#ifdef _HAVE_TEXT_MODE
#ifdef _LITE_VERSION
    if (mgIsServer)
#endif
    {
	    /* open tty, enter graphics mode*/
        char* tty_dev;
        if (geteuid() == 0)
            tty_dev = "/dev/tty0";
        else    /* not a super user, so try to open the control terminal */
            tty_dev = "/dev/tty";

	    tty = open (tty_dev, O_RDWR);
	    if(tty < 0) {
		    fprintf(stderr,"GAL fbcon engine: Can't open /dev/tty0: %m\n");
		    goto fail;
	    }
	    if(ioctl (tty, KDSETMODE, KD_GRAPHICS) == -1) {
		    fprintf(stderr,"GAL fbcon engine: Error when setting console to graphics mode: %m\n");
		    fprintf(stderr,"GAL fbcon engine: Maybe have no enough permission.\n");
		    goto fail;
	    }
    }
#endif
	/* mmap framebuffer into this address space*/
	psd->size = (psd->size + getpagesize () - 1)
			/ getpagesize () * getpagesize ();
#ifdef __uClinux__
//cyli fix 20080219
//	psd->addr = mmap(NULL, psd->size, PROT_READ | PROT_WRITE, 0, fb, 0);
	psd->addr = do_mmap(NULL, psd->size, PROT_READ | PROT_WRITE, 0, fb, 0);
#else
//cyli fix 20080219
//	psd->addr = mmap(NULL, psd->size, PROT_READ | PROT_WRITE, MAP_SHARED, fb, 0);
	psd->addr = do_mmap(NULL, psd->size, PROT_READ | PROT_WRITE, MAP_SHARED, fb, 0);
#endif
//	printf("cyli test  mmap psd->addr=%x psd->size=%x \n", psd->addr, psd->size);
	if(psd->addr == NULL || psd->addr == (unsigned char *)-1) {
		fprintf(stderr,"GAL fbcon engine: Error when mmaping %s: %m\n", env);
		goto fail;
	}
	/* save original palette*/
	ioctl_getpalette(0, 16, saved_red, saved_green, saved_blue);
	status = 2;
	psd->gr_mode = MODE_SET;
	return psd;	/* success*/

fail:

#ifdef _HAVE_TEXT_MODE
#ifdef _LITE_VERSION
    if (mgIsServer) {
#endif
	    /* enter text mode*/
        if (tty >= 0) {
	        ioctl (tty, KDSETMODE, KD_TEXT);
	        close (tty);
            tty = -1;
        }
#ifdef _LITE_VERSION
    }
#endif
#endif
	close(fb);
	return NULL;
}