Thread (45 messages) 45 messages, 5 authors, 2003-09-15

RE: Re: New radeonfb, mostly untested

From: Tony <hidden>
Date: 2003-09-15 00:46:17

void calc_mode_timings(int xres, int yres, int refresh,
struct fb_videomode *mode)
{
        int dbsize = sizeof(modedb)/sizeof(modedb[0]);
        struct fb_videomode *cur;
        int i;

        for (i = 0; i < dbsize; i++) {
                cur = &modedb[i];

                if (cur->xres == xres && cur->yres == yres &&
                                     cur->refreh == refresh) {
                        /* Yeah */
                        mode->xres = xres;
                        mode->yres = yres;
                        mode->pixclock = cur->pixclock;
                        mode->refresh = refresh;
                        mode->left_margin = cur->left_margin;
                        mode->right_margin = cur->right_margin;
                        mode->upper_margin = cur->upper_margin;
                        mode->lower_margin = cur->lower_margin;
                        mode->hsync_len = cur->hsync_len;
                        mode->vsync_len = cur->vsync_len;
                        mode->vmode = cur->vmode;
                        mode->sync = cur->sync;

                        return;
                }
        }

        BUG();
}
The bug may actually be in the following code:

static int get_std_timing(unsigned char *block, struct fb_videomode
*mode)
{
	int xres, yres = 0, refresh, ratio, i;

	xres = (block[0] + 31) * 8;
	if (xres <= 256)
		return 0;

 	ratio = (block[1] & 0xc0) >> 6;
 	switch (ratio) {
	case 0:
		yres = xres;
 		break;
	case 1:
		yres = (xres * 3)/4;
		break;
 	case 2:
 		yres = (xres * 4)/5;
		break;j
	case 3:
 		yres = (xres * 9)/16;
		break;
	}
	refresh = (block[1] & 0x3f) + 60;

 	for (i = 0; i < VESA_MODEDB_SIZE; i++) {
		if (vesa_modes[i].xres == xres &&
		    vesa_modes[i].yres == yres &&
 		    vesa_modes[i].refresh == refresh) {
 			*mode = vesa_modes[i];
			break;
 		} else {
			calc_mode_timings(xres, yres, refresh, mode);
			break;
 		}
 	}
	return 1;
}
----------------------------------

Maybe you can replace it with this:

static int get_std_timing(unsigned char *block, struct fb_videomode
*mode)
{
	int xres, yres = 0, refresh, ratio, i, j = 0;

	xres = (block[0] + 31) * 8;
	if (xres <= 256)
		return 0;

 	ratio = (block[1] & 0xc0) >> 6;
 	switch (ratio) {
	case 0:
		yres = xres;
 		break;
	case 1:
		yres = (xres * 3)/4;
		break;
 	case 2:
 		yres = (xres * 4)/5;
		break;j
	case 3:
 		yres = (xres * 9)/16;
		break;
	}
	refresh = (block[1] & 0x3f) + 60;

	/* First find standard mode from the table of VESA modes */
 	for (i = 0; i < VESA_MODEDB_SIZE; i++) {
		if (vesa_modes[i].xres == xres &&
		    vesa_modes[i].yres == yres &&
 		    vesa_modes[i].refresh == refresh) {
 			*mode = vesa_modes[i];
			j = 1;
			break;
 		}
	}

	/* If mode is not found in table, calculate using GTF */
	if (!j)
		calc_mode_timings(xres, yres, refresh, mode);

	return 1;
}

Tony




-------------------------------------------------------
This sf.net email is sponsored by:ThinkGeek
Welcome to geek heaven.
http://thinkgeek.com/sf
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help