fix formatting

This commit is contained in:
Markus Fröschle
2017-04-08 18:36:47 +00:00
parent dd402d57fc
commit 87952098b2

View File

@@ -41,13 +41,15 @@
#define FBMON_FIX_HEADER 1 #define FBMON_FIX_HEADER 1
#define FBMON_FIX_INPUT 2 #define FBMON_FIX_INPUT 2
struct broken_edid { struct broken_edid
{
unsigned char manufacturer[4]; unsigned char manufacturer[4];
unsigned long model; unsigned long model;
unsigned long fix; unsigned long fix;
}; };
static struct broken_edid brokendb[] = { static struct broken_edid brokendb[] =
{
/* DEC FR-PCXAV-YZ */ /* DEC FR-PCXAV-YZ */
{ {
.manufacturer = "DEC", .manufacturer = "DEC",
@@ -62,7 +64,9 @@ static struct broken_edid brokendb[] = {
}, },
}; };
static const unsigned char edid_v1_header[] = { 0x00, 0xff, 0xff, 0xff, static const unsigned char edid_v1_header[] =
{
0x00, 0xff, 0xff, 0xff,
0xff, 0xff, 0xff, 0x00 0xff, 0xff, 0xff, 0x00
}; };
@@ -82,6 +86,7 @@ static int32_t check_edid(unsigned char *edid)
unsigned char *b; unsigned char *b;
unsigned long model; unsigned long model;
int32_t i, fix = 0, ret = 0; int32_t i, fix = 0, ret = 0;
manufacturer[0] = ((block[0] & 0x7c) >> 2) + '@'; manufacturer[0] = ((block[0] & 0x7c) >> 2) + '@';
manufacturer[1] = ((block[0] & 0x03) << 3) + ((block[1] & 0xe0) >> 5) + '@'; manufacturer[1] = ((block[0] & 0x03) << 3) + ((block[1] & 0xe0) >> 5) + '@';
manufacturer[2] = (block[1] & 0x1f) + '@'; manufacturer[2] = (block[1] & 0x1f) + '@';
@@ -89,11 +94,11 @@ static int32_t check_edid(unsigned char *edid)
model = block[2] + (block[3] << 8); model = block[2] + (block[3] << 8);
for (i = 0; i < sizeof(brokendb)/sizeof(*brokendb); i++) for (i = 0; i < sizeof(brokendb)/sizeof(*brokendb); i++)
{ {
if(manufacturer[0] == brokendb[i].manufacturer[0] if (manufacturer[0] == brokendb[i].manufacturer[0] &&
&& manufacturer[1] == brokendb[i].manufacturer[1] manufacturer[1] == brokendb[i].manufacturer[1] &&
&& manufacturer[2] == brokendb[i].manufacturer[2] manufacturer[2] == brokendb[i].manufacturer[2] &&
&& manufacturer[3] == brokendb[i].manufacturer[3] manufacturer[3] == brokendb[i].manufacturer[3] &&
&& brokendb[i].model == model) brokendb[i].model == model)
{ {
fix = brokendb[i].fix; fix = brokendb[i].fix;
break; break;
@@ -108,6 +113,7 @@ static int32_t check_edid(unsigned char *edid)
ret = fix; ret = fix;
} }
break; break;
case FBMON_FIX_INPUT: case FBMON_FIX_INPUT:
b = edid + EDID_STRUCT_DISPLAY; b = edid + EDID_STRUCT_DISPLAY;
/* Only if display is GTF capable will /* Only if display is GTF capable will
@@ -122,11 +128,13 @@ static int32_t check_edid(unsigned char *edid)
static void fix_edid(unsigned char *edid, int32_t fix) static void fix_edid(unsigned char *edid, int32_t fix)
{ {
unsigned char *b; unsigned char *b;
switch (fix) switch (fix)
{ {
case FBMON_FIX_HEADER: case FBMON_FIX_HEADER:
memcpy(edid, edid_v1_header, 8); memcpy(edid, edid_v1_header, 8);
break; break;
case FBMON_FIX_INPUT: case FBMON_FIX_INPUT:
b = edid + EDID_STRUCT_DISPLAY; b = edid + EDID_STRUCT_DISPLAY;
b[0] &= ~0x80; b[0] &= ~0x80;
@@ -139,6 +147,7 @@ static int32_t edid_checksum(unsigned char *edid)
{ {
unsigned char i, csum = 0, all_null = 0; unsigned char i, csum = 0, all_null = 0;
int32_t err = 0, fix = check_edid(edid); int32_t err = 0, fix = check_edid(edid);
if (fix) if (fix)
fix_edid(edid, fix); fix_edid(edid, fix);
for (i = 0; i < EDID_LENGTH; i++) for (i = 0; i < EDID_LENGTH; i++)
@@ -157,6 +166,7 @@ static int32_t edid_checksum(unsigned char *edid)
static int32_t edid_check_header(unsigned char *edid) static int32_t edid_check_header(unsigned char *edid)
{ {
int32_t i, err = 1, fix = check_edid(edid); int32_t i, err = 1, fix = check_edid(edid);
if (fix) if (fix)
fix_edid(edid, fix); fix_edid(edid, fix);
for (i = 0; i < 8; i++) for (i = 0; i < 8; i++)
@@ -421,18 +431,29 @@ static int32_t get_std_timing(unsigned char *block, struct fb_videomode *mode)
ratio = (block[1] & 0xc0) >> 6; ratio = (block[1] & 0xc0) >> 6;
switch(ratio) switch(ratio)
{ {
case 0: yres = xres; break; case 0:
case 1: yres = (xres * 3)/4; break; yres = xres;
case 2: yres = (xres * 4)/5; break; break;
case 3: yres = (xres * 9)/16; break;
case 1:
yres = (xres * 3) / 4;
break;
case 2:
yres = (xres * 4) / 5;
break;
case 3:
yres = (xres * 9) / 16;
break;
} }
refresh = (block[1] & 0x3f) + 60; refresh = (block[1] & 0x3f) + 60;
dbg("%dx%d@ Hz\r\n",xres, yres, refresh); dbg("%dx%d@ Hz\r\n",xres, yres, refresh);
for (i = 0; i < VESA_MODEDB_SIZE; i++) for (i = 0; i < VESA_MODEDB_SIZE; i++)
{ {
if(vesa_modes[i].xres == xres && vesa_modes[i].yres == yres if (vesa_modes[i].xres == xres && vesa_modes[i].yres == yres &&
&& vesa_modes[i].refresh == refresh) vesa_modes[i].refresh == refresh)
{ {
*mode = vesa_modes[i]; *mode = vesa_modes[i];
mode->flag |= FB_MODE_IS_STANDARD; mode->flag |= FB_MODE_IS_STANDARD;
@@ -494,12 +515,13 @@ static struct fb_videomode *alloc_db(int32_t num)
{ {
int32_t i = 0; int32_t i = 0;
if (!num) if (!num)
return(NULL); return NULL;
while (i < MAX_DB_ALLOC) while (i < MAX_DB_ALLOC)
{ {
if ((db_used[i] == NULL) && ((i + num) <= MAX_DB_ALLOC)) if ((db_used[i] == NULL) && ((i + num) <= MAX_DB_ALLOC))
{ {
int32_t j; /* search contiguous num db free */ int32_t j; /* search contiguous num db free */
for (j = 0; j < num; j++) for (j = 0; j < num; j++)
{ {
if (db_used[i+j] != NULL) if (db_used[i+j] != NULL)
@@ -508,18 +530,21 @@ static struct fb_videomode *alloc_db(int32_t num)
if (j >= num) if (j >= num)
{ {
struct fb_videomode *p = &tab_db[i]; struct fb_videomode *p = &tab_db[i];
for (j = 0; j < num; db_used[i+j] = p, j++); for (j = 0; j < num; db_used[i+j] = p, j++);
return(p);
return p;
} }
} }
i++; i++;
} }
return(NULL); return NULL;
} }
static void free_db(struct fb_videomode *db) static void free_db(struct fb_videomode *db)
{ {
int32_t i; int32_t i;
for (i = 0; i < MAX_DB_ALLOC; i++) for (i = 0; i < MAX_DB_ALLOC; i++)
{ {
if (db_used[i] == db) if (db_used[i] == db)
@@ -556,14 +581,17 @@ static struct fb_videomode *fb_create_modedb(unsigned char *edid, int32_t *dbsiz
struct fb_videomode *mode, *m; struct fb_videomode *mode, *m;
unsigned char *block; unsigned char *block;
int32_t num = 0, i; int32_t num = 0, i;
// mode = Funcs_malloc(50 * sizeof(struct fb_videomode), 3); // mode = Funcs_malloc(50 * sizeof(struct fb_videomode), 3);
mode = alloc_db(50); mode = alloc_db(50);
if (mode == NULL) if (mode == NULL)
return NULL; return NULL;
memset((char *)mode, 0, 50 * sizeof(struct fb_videomode)); memset((char *)mode, 0, 50 * sizeof(struct fb_videomode));
if (edid == NULL || !edid_checksum(edid) || !edid_check_header(edid)) if (edid == NULL || !edid_checksum(edid) || !edid_check_header(edid))
{ {
fb_destroy_modedb(mode); fb_destroy_modedb(mode);
return NULL; return NULL;
} }
*dbsize = 0; *dbsize = 0;
@@ -579,6 +607,7 @@ static struct fb_videomode *fb_create_modedb(unsigned char *edid, int32_t *dbsiz
for (i = 0; i < 4; i++, block+= DETAILED_TIMING_DESCRIPTION_SIZE) for (i = 0; i < 4; i++, block+= DETAILED_TIMING_DESCRIPTION_SIZE)
{ {
int32_t first = 1; int32_t first = 1;
if (block[0] == 0x00 && block[1] == 0x00) if (block[0] == 0x00 && block[1] == 0x00)
{ {
if (block[3] == 0xfa) if (block[3] == 0xfa)
@@ -599,6 +628,7 @@ static struct fb_videomode *fb_create_modedb(unsigned char *edid, int32_t *dbsiz
if (!num) if (!num)
{ {
fb_destroy_modedb(mode); fb_destroy_modedb(mode);
return NULL; return NULL;
} }
*dbsize = num; *dbsize = num;
@@ -608,6 +638,7 @@ static struct fb_videomode *fb_create_modedb(unsigned char *edid, int32_t *dbsiz
return mode; return mode;
memcpy(m, mode, num * sizeof(struct fb_videomode)); memcpy(m, mode, num * sizeof(struct fb_videomode));
fb_destroy_modedb(mode); fb_destroy_modedb(mode);
return m; return m;
} }
@@ -615,6 +646,7 @@ static int32_t fb_get_monitor_limits(unsigned char *edid, struct fb_monspecs *sp
{ {
int32_t i, retval = 1; int32_t i, retval = 1;
unsigned char *block; unsigned char *block;
block = edid + DETAILED_TIMING_DESCRIPTIONS_START; block = edid + DETAILED_TIMING_DESCRIPTIONS_START;
dbg(" Monitor Operating Limits: "); dbg(" Monitor Operating Limits: ");
for (i = 0; i < 4; i++, block += DETAILED_TIMING_DESCRIPTION_SIZE) for (i = 0; i < 4; i++, block += DETAILED_TIMING_DESCRIPTION_SIZE)
@@ -637,10 +669,12 @@ static int32_t fb_get_monitor_limits(unsigned char *edid, struct fb_monspecs *sp
{ {
struct fb_videomode *modes; struct fb_videomode *modes;
int32_t num_modes, i, hz, hscan, pixclock; int32_t num_modes, i, hz, hscan, pixclock;
modes = fb_create_modedb(edid, &num_modes); modes = fb_create_modedb(edid, &num_modes);
if (!modes) if (!modes)
{ {
dbg("None Available\r\n"); dbg("None Available\r\n");
return 1; return 1;
} }
retval = 0; retval = 0;
@@ -671,16 +705,19 @@ static int32_t fb_get_monitor_limits(unsigned char *edid, struct fb_monspecs *sp
specs->vfmin, specs->vfmin,
specs->vfmax, specs->vfmax,
specs->dclkmax / 1000000); specs->dclkmax / 1000000);
return retval; return retval;
} }
static void get_monspecs(unsigned char *edid, struct fb_monspecs *specs) static void get_monspecs(unsigned char *edid, struct fb_monspecs *specs)
{ {
unsigned char c, *block; unsigned char c, *block;
block = edid + EDID_STRUCT_DISPLAY; block = edid + EDID_STRUCT_DISPLAY;
fb_get_monitor_limits(edid, specs); fb_get_monitor_limits(edid, specs);
c = block[0] & 0x80; c = block[0] & 0x80;
specs->input = 0; specs->input = 0;
if (c) if (c)
{ {
specs->input |= FB_DISP_DDI; specs->input |= FB_DISP_DDI;
@@ -694,14 +731,17 @@ static void get_monspecs(unsigned char *edid, struct fb_monspecs *specs)
//dbg(" Analog Display Input: Input Voltage - 0.700V/0.300V"); //dbg(" Analog Display Input: Input Voltage - 0.700V/0.300V");
specs->input |= FB_DISP_ANA_700_300; specs->input |= FB_DISP_ANA_700_300;
break; break;
case 1: case 1:
//dbg("0.714V/0.286V"); //dbg("0.714V/0.286V");
specs->input |= FB_DISP_ANA_714_286; specs->input |= FB_DISP_ANA_714_286;
break; break;
case 2: case 2:
//dbg("1.000V/0.400V"); //dbg("1.000V/0.400V");
specs->input |= FB_DISP_ANA_1000_400; specs->input |= FB_DISP_ANA_1000_400;
break; break;
case 3: case 3:
//dbg("0.700V/0.000V"); //dbg("0.700V/0.000V");
specs->input |= FB_DISP_ANA_700_000; specs->input |= FB_DISP_ANA_700_000;
@@ -716,26 +756,31 @@ static void get_monspecs(unsigned char *edid, struct fb_monspecs *specs)
} }
c = block[0] & 0x0f; c = block[0] & 0x0f;
specs->signal = 0; specs->signal = 0;
if (c & 0x10) if (c & 0x10)
{ {
//DPRINT("Blank to Blank "); //DPRINT("Blank to Blank ");
specs->signal |= FB_SIGNAL_BLANK_BLANK; specs->signal |= FB_SIGNAL_BLANK_BLANK;
} }
if (c & 0x08) if (c & 0x08)
{ {
//DPRINT("Separate "); //DPRINT("Separate ");
specs->signal |= FB_SIGNAL_SEPARATE; specs->signal |= FB_SIGNAL_SEPARATE;
} }
if (c & 0x04) if (c & 0x04)
{ {
//DPRINT("Composite "); //DPRINT("Composite ");
specs->signal |= FB_SIGNAL_COMPOSITE; specs->signal |= FB_SIGNAL_COMPOSITE;
} }
if (c & 0x02) if (c & 0x02)
{ {
//DPRINT("Sync on Green "); //DPRINT("Sync on Green ");
specs->signal |= FB_SIGNAL_SYNC_ON_GREEN; specs->signal |= FB_SIGNAL_SYNC_ON_GREEN;
} }
if (c & 0x01) if (c & 0x01)
{ {
// DPRINT("Serration on "); // DPRINT("Serration on ");
@@ -749,20 +794,24 @@ static void get_monspecs(unsigned char *edid, struct fb_monspecs *specs)
specs->gamma = c+100; specs->gamma = c+100;
dbg(" Gamma %d\r\n: ",specs->gamma / 100); dbg(" Gamma %d\r\n: ",specs->gamma / 100);
get_dpms_capabilities(block[4], specs); get_dpms_capabilities(block[4], specs);
switch ((block[4] & 0x18) >> 3) switch ((block[4] & 0x18) >> 3)
{ {
case 0: case 0:
//DPRINT(" Monochrome/Grayscale\r\n"); //DPRINT(" Monochrome/Grayscale\r\n");
specs->input |= FB_DISP_MONO; specs->input |= FB_DISP_MONO;
break; break;
case 1: case 1:
//DPRINT(" RGB Color Display\r\n"); //DPRINT(" RGB Color Display\r\n");
specs->input |= FB_DISP_RGB; specs->input |= FB_DISP_RGB;
break; break;
case 2: case 2:
//DPRINT(" Non-RGB Multicolor Display\r\n"); //DPRINT(" Non-RGB Multicolor Display\r\n");
specs->input |= FB_DISP_MULTI; specs->input |= FB_DISP_MULTI;
break; break;
default: default:
//DPRINT(" Unknown\r\n"); //DPRINT(" Unknown\r\n");
specs->input |= FB_DISP_UNKNOWN; specs->input |= FB_DISP_UNKNOWN;
@@ -801,6 +850,7 @@ int32_t fb_parse_edid(unsigned char *edid, struct fb_var_screeninfo *var)
{ {
int32_t i; int32_t i;
unsigned char *block; unsigned char *block;
if (edid == NULL || var == NULL) if (edid == NULL || var == NULL)
return 1; return 1;
if (!(edid_checksum(edid))) if (!(edid_checksum(edid)))
@@ -832,6 +882,7 @@ int32_t fb_parse_edid(unsigned char *edid, struct fb_var_screeninfo *var)
} }
} }
dbg("edid no timing block\r\n"); dbg("edid no timing block\r\n");
return 1; return 1;
} }
@@ -839,6 +890,7 @@ void fb_edid_to_monspecs(unsigned char *edid, struct fb_monspecs *specs)
{ {
unsigned char *block; unsigned char *block;
int32_t i; int32_t i;
if (edid == NULL) if (edid == NULL)
return; return;
if (!(edid_checksum(edid))) if (!(edid_checksum(edid)))
@@ -900,7 +952,8 @@ void fb_edid_to_monspecs(unsigned char *edid, struct fb_monspecs *specs)
#define C_VAL 30 #define C_VAL 30
#define M_VAL 300 #define M_VAL 300
struct __fb_timings { struct __fb_timings
{
unsigned long dclk; unsigned long dclk;
unsigned long hfreq; unsigned long hfreq;
unsigned long vfreq; unsigned long vfreq;
@@ -930,9 +983,10 @@ struct __fb_timings {
static unsigned long fb_get_vblank(unsigned long hfreq) static unsigned long fb_get_vblank(unsigned long hfreq)
{ {
unsigned long vblank; unsigned long vblank;
vblank = (hfreq * FLYBACK)/1000; vblank = (hfreq * FLYBACK)/1000;
vblank = (vblank + 500)/1000; vblank = (vblank + 500)/1000;
return (vblank + V_FRONTPORCH); return vblank + V_FRONTPORCH;
} }
/** /**
@@ -958,18 +1012,21 @@ static unsigned long fb_get_vblank(unsigned long hfreq)
static unsigned long fb_get_hblank_by_hfreq(unsigned long hfreq, unsigned long xres) static unsigned long fb_get_hblank_by_hfreq(unsigned long hfreq, unsigned long xres)
{ {
unsigned long c_val, m_val, duty_cycle, hblank; unsigned long c_val, m_val, duty_cycle, hblank;
c_val = (((H_OFFSET - H_SCALEFACTOR) * H_BLANKSCALE)/256 + H_SCALEFACTOR) * 1000; c_val = (((H_OFFSET - H_SCALEFACTOR) * H_BLANKSCALE)/256 + H_SCALEFACTOR) * 1000;
m_val = (H_BLANKSCALE * H_GRADIENT)/256; m_val = (H_BLANKSCALE * H_GRADIENT)/256;
m_val = (m_val * 1000000)/hfreq; m_val = (m_val * 1000000)/hfreq;
duty_cycle = c_val - m_val; duty_cycle = c_val - m_val;
hblank = (xres * duty_cycle)/(100000 - duty_cycle); hblank = (xres * duty_cycle)/(100000 - duty_cycle);
return (hblank);
return hblank;
} }
/* Quick integer square root using binomial theorem (from Dr. Dobbs journal) */ /* Quick integer square root using binomial theorem (from Dr. Dobbs journal) */
static int32_t int32_t_sqrt(int32_t N) static int32_t int32_t_sqrt(int32_t N)
{ {
unsigned long l2, u, v, u2, n; unsigned long l2, u, v, u2, n;
if (N < 2) if (N < 2)
return N; return N;
u = N; u = N;
@@ -980,6 +1037,7 @@ static int32_t int32_t_sqrt(int32_t N)
u = 1L << l2; u = 1L << l2;
v = u; v = u;
u2 = u << l2; u2 = u << l2;
while (l2--) while (l2--)
{ {
v >>= 1; v >>= 1;
@@ -1018,6 +1076,7 @@ static int32_t int32_t_sqrt(int32_t N)
static unsigned long fb_get_hblank_by_dclk(unsigned long dclk, unsigned long xres) static unsigned long fb_get_hblank_by_dclk(unsigned long dclk, unsigned long xres)
{ {
unsigned long duty_cycle, h_period, hblank; unsigned long duty_cycle, h_period, hblank;
dclk /= 1000; dclk /= 1000;
h_period = 100 - C_VAL; h_period = 100 - C_VAL;
h_period *= h_period; h_period *= h_period;
@@ -1030,7 +1089,8 @@ static unsigned long fb_get_hblank_by_dclk(unsigned long dclk, unsigned long xre
duty_cycle = C_VAL * 1000 - (M_VAL * h_period)/100; duty_cycle = C_VAL * 1000 - (M_VAL * h_period)/100;
hblank = (xres * duty_cycle)/(100000 - duty_cycle) + 8; hblank = (xres * duty_cycle)/(100000 - duty_cycle) + 8;
hblank &= ~15; hblank &= ~15;
return (hblank);
return hblank;
} }
/** /**
@@ -1049,9 +1109,11 @@ static unsigned long fb_get_hblank_by_dclk(unsigned long dclk, unsigned long xre
static unsigned long fb_get_hfreq(unsigned long vfreq, unsigned long yres) static unsigned long fb_get_hfreq(unsigned long vfreq, unsigned long yres)
{ {
unsigned long divisor, hfreq; unsigned long divisor, hfreq;
divisor = (1000000 - (vfreq * FLYBACK))/1000; divisor = (1000000 - (vfreq * FLYBACK))/1000;
hfreq = (yres + V_FRONTPORCH) * vfreq * 1000; hfreq = (yres + V_FRONTPORCH) * vfreq * 1000;
return (hfreq/divisor);
return hfreq / divisor;
} }
static void fb_timings_vfreq(struct __fb_timings *timings) static void fb_timings_vfreq(struct __fb_timings *timings)
@@ -1124,6 +1186,7 @@ int32_t fb_get_mode(int32_t flags, uint32_t val, struct fb_var_screeninfo *var,
struct __fb_timings timings; struct __fb_timings timings;
unsigned long interlace = 1, dscan = 1; unsigned long interlace = 1, dscan = 1;
unsigned long hfmin, hfmax, vfmin, vfmax, dclkmin, dclkmax; unsigned long hfmin, hfmax, vfmin, vfmax, dclkmin, dclkmax;
/* /*
* If monspecs are invalid, use values that are enough * If monspecs are invalid, use values that are enough
* for 640x480@60 * for 640x480@60
@@ -1148,16 +1211,19 @@ int32_t fb_get_mode(int32_t flags, uint32_t val, struct fb_var_screeninfo *var,
memset((char *)&timings, 0, sizeof(struct __fb_timings)); memset((char *)&timings, 0, sizeof(struct __fb_timings));
timings.hactive = var->xres; timings.hactive = var->xres;
timings.vactive = var->yres; timings.vactive = var->yres;
if (var->vmode & FB_VMODE_INTERLACED) if (var->vmode & FB_VMODE_INTERLACED)
{ {
timings.vactive /= 2; timings.vactive /= 2;
interlace = 2; interlace = 2;
} }
if (var->vmode & FB_VMODE_DOUBLE) if (var->vmode & FB_VMODE_DOUBLE)
{ {
timings.vactive *= 2; timings.vactive *= 2;
dscan = 2; dscan = 2;
} }
switch (flags & ~FB_IGNOREMON) switch (flags & ~FB_IGNOREMON)
{ {
case FB_MAXTIMINGS: /* maximize refresh rate */ case FB_MAXTIMINGS: /* maximize refresh rate */
@@ -1168,24 +1234,29 @@ int32_t fb_get_mode(int32_t flags, uint32_t val, struct fb_var_screeninfo *var,
timings.vfreq = vfmax; timings.vfreq = vfmax;
fb_timings_vfreq(&timings); fb_timings_vfreq(&timings);
} }
if (timings.dclk > dclkmax) if (timings.dclk > dclkmax)
{ {
timings.dclk = dclkmax; timings.dclk = dclkmax;
fb_timings_dclk(&timings); fb_timings_dclk(&timings);
} }
break; break;
case FB_VSYNCTIMINGS: /* vrefresh driven */ case FB_VSYNCTIMINGS: /* vrefresh driven */
timings.vfreq = val; timings.vfreq = val;
fb_timings_vfreq(&timings); fb_timings_vfreq(&timings);
break; break;
case FB_HSYNCTIMINGS: /* hsync driven */ case FB_HSYNCTIMINGS: /* hsync driven */
timings.hfreq = val; timings.hfreq = val;
fb_timings_hfreq(&timings); fb_timings_hfreq(&timings);
break; break;
case FB_DCLKTIMINGS: /* pixelclock driven */ case FB_DCLKTIMINGS: /* pixelclock driven */
timings.dclk = PICOS2KHZ(val) * 1000; timings.dclk = PICOS2KHZ(val) * 1000;
fb_timings_dclk(&timings); fb_timings_dclk(&timings);
break; break;
default: default:
return -1; // -EINVAL; return -1; // -EINVAL;
} }
@@ -1194,6 +1265,7 @@ int32_t fb_get_mode(int32_t flags, uint32_t val, struct fb_var_screeninfo *var,
|| timings.hfreq < hfmin || timings.hfreq > hfmax || timings.hfreq < hfmin || timings.hfreq > hfmax
|| timings.dclk < dclkmin || timings.dclk > dclkmax)) || timings.dclk < dclkmin || timings.dclk > dclkmax))
return -1; //-EINVAL; return -1; //-EINVAL;
var->pixclock = KHZ2PICOS(timings.dclk/1000); var->pixclock = KHZ2PICOS(timings.dclk/1000);
var->hsync_len = (timings.htotal * 8)/100; var->hsync_len = (timings.htotal * 8)/100;
var->right_margin = (timings.hblank/2) - var->hsync_len; var->right_margin = (timings.hblank/2) - var->hsync_len;
@@ -1201,6 +1273,7 @@ int32_t fb_get_mode(int32_t flags, uint32_t val, struct fb_var_screeninfo *var,
var->vsync_len = (3 * interlace)/dscan; var->vsync_len = (3 * interlace)/dscan;
var->lower_margin = (1 * interlace)/dscan; var->lower_margin = (1 * interlace)/dscan;
var->upper_margin = (timings.vblank * interlace)/dscan - (var->vsync_len + var->lower_margin); var->upper_margin = (timings.vblank * interlace)/dscan - (var->vsync_len + var->lower_margin);
return 0; return 0;
} }
@@ -1244,6 +1317,7 @@ int32_t fb_validate_mode(const struct fb_var_screeninfo *var, struct fb_info *in
} }
if (!var->pixclock) if (!var->pixclock)
return -1; // -EINVAL; return -1; // -EINVAL;
pixclock = PICOS2KHZ(var->pixclock) * 1000; pixclock = PICOS2KHZ(var->pixclock) * 1000;
htotal = var->xres + var->right_margin + var->hsync_len + var->left_margin; htotal = var->xres + var->right_margin + var->hsync_len + var->left_margin;
vtotal = var->yres + var->lower_margin + var->vsync_len + var->upper_margin; vtotal = var->yres + var->lower_margin + var->vsync_len + var->upper_margin;