Beispiel #1
0
//
// This function is called to init the video driver for specific mode
//
static int config(uint32_t width, uint32_t height, uint32_t d_width,
                  uint32_t d_height, uint32_t flags, char *title,
                  uint32_t format) {
    int32_t req_w = width;// (d_width > 0 ? d_width : width);
    int32_t req_h = height;// (d_height > 0 ? d_height : height);
    uint16_t vid_mode = 0;
    int32_t req_bpp;

    uint32_t accflags;
    mp_msg(MSGT_VO,MSGL_V, "vo_svga: config(%i, %i, %i, %i, %08x, %s, %08x)\n", width, height,
           d_width, d_height, flags, title, format);
//Only RGB modes supported
    if (!IMGFMT_IS_RGB(format) && !IMGFMT_IS_BGR(format)) {
        assert(0);
        return -1;
    }
    req_bpp = IMGFMT_BGR_DEPTH(format);

    if( vo_dbpp!=0 && vo_dbpp!=req_bpp) {
        assert(0);
        return-1;
    }

    if(!force_vm) {
        mp_msg(MSGT_VO,MSGL_V, "vo_svga: Looking for the best resolution...\n");
        mp_msg(MSGT_VO,MSGL_V, "vo_svga: req_w: %d, req_h: %d, bpp: %d\n",req_w,req_h,req_bpp);
        vid_mode=find_best_svga_mode(req_w,req_h,req_bpp);
        if(vid_mode==0)
            return 1;
        modeinfo=vga_getmodeinfo(vid_mode);
    } else { //force_vm
        vid_mode=force_vm;
        if(vga_hasmode(vid_mode) == 0) {
            mp_msg(MSGT_VO,MSGL_ERR, MSGTR_LIBVO_SVGA_ForcedVidmodeNotAvailable,
                   vid_mode,vga_getmodename(vid_mode));
            return 1; //error;
        }
        modeinfo=vga_getmodeinfo(vid_mode);
        if( (modeinfo->width < req_w) || (modeinfo->height < req_h) ) {
            mp_msg(MSGT_VO,MSGL_ERR, MSGTR_LIBVO_SVGA_ForcedVidmodeTooSmall,
                   vid_mode,vga_getmodename(vid_mode));
            return 1;
        }
    }
    mode_bpp=bpp_from_vminfo(modeinfo);

    mp_msg(MSGT_VO,MSGL_INFO, MSGTR_LIBVO_SVGA_Vidmode,
           vid_mode,modeinfo->width,modeinfo->height,mode_bpp);

    if (vga_setmode(vid_mode) == -1) {
        mp_msg(MSGT_VO,MSGL_ERR, MSGTR_LIBVO_SVGA_VgasetmodeFailed,vid_mode);
        uninit();
        return 1; // error
    }
    /* set 332 palette for 8 bpp */
    if(mode_bpp==8) {
        int i;
        for(i=0; i<256; i++)
            vga_setpalette(i, ((i>>5)&7)*9, ((i>>2)&7)*9, (i&3)*21);
    }
Beispiel #2
0
static int find_best_svga_mode(int req_w,int req_h, int req_bpp){
 int badness,prev_badness;
 int bestmode,lastmode;
 int i;
 vga_modeinfo *vminfo;
//int best aspect mode // best linear mode // best normal mode (no modeX)

  prev_badness = 0;//take care of special case below
  bestmode = 0; //0 is the TEXT mode
  lastmode = vga_lastmodenumber();
  for(i=1;i<=lastmode;i++){
    vminfo = vga_getmodeinfo(i);
    if( vminfo == NULL ) continue;
    if( mp_msg_test(MSGT_VO,MSGL_DBG4) )
      mp_msg(MSGT_VO,MSGL_DBG4, "vo_svga: testing mode %d (%s)\n",i,vga_getmodename(i));
    if( vga_hasmode(i) == 0 ) continue;
    if( req_bpp != bpp_from_vminfo(vminfo) )continue;
    if( (vminfo->width < req_w) || (vminfo->height < req_h) ) continue;
    badness=(vminfo->width * vminfo->height) - (req_h * req_w);
    //put here aspect calculations
    if(squarepix) 
      if( vminfo->width*3 != vminfo->height*4 ) continue;

    if( bestmode==0 || prev_badness >= badness ){//modeX etc...
      prev_badness=badness;
      bestmode=i;
      if( mp_msg_test(MSGT_VO,MSGL_DBG4) )
        mp_msg(MSGT_VO,MSGL_DBG4, "vo_svga: found good mode %d with badness %d\n",i,badness);
    }
  }
  return bestmode;
}
Beispiel #3
0
/* This one won't type an error message ... */
int __svgalib_name2number(char *m)
{
    int i;

    for (i = G320x200x16; i <= GLASTMODE; i++) {
	if (strcasecmp(m, vga_getmodename(i)) == 0)	/* check name */
	    return i;
    }
    return -1;
}
Beispiel #4
0
void configure(void)
{
    int allowed[GLASTMODE + 1];

    for (;;) {
	int i;
	int m;
	for (i = G320x200x16; i <= GLASTMODE; i++) {
	    allowed[i] = 0;
	    if (vga_hasmode(i)) {
		printf("%2d  %s\n", i, vga_getmodename(i));
		allowed[i] = 1;
	    }
	}

	printf("\nWhich mode? ");
	scanf("%d", &m);
	getchar();
	printf("\n");
	if (m >= G320x200x16 && m <= GLASTMODE) {
	    VGAMODE = m;
	    if (vga_getmodeinfo(m)->bytesperpixel >= 1)
		USEGL = 1;
	    else
		USEGL = 0;
	    break;
	}
    }

    vga_setmode(VGAMODE);
#ifdef LINEAR_ADDRESSING
    vga_setlinearaddressing();
#endif
    if (USEGL) {
	gl_setcontextvga(VGAMODE);
	physicalscreen = gl_allocatecontext();
	gl_getcontext(physicalscreen);
    }
}