Commit d0b58c2a authored by ROOL's avatar ROOL 🤖
Browse files

Omit mode name from lookup tables

Detail:
  Save 4k of ROM space by not storing the mode name string; always generate it at run time.
  Split the ModeDefinition struct into the timings part (ModeDef) and full definition (ModeDefinition).
Admin:
  Submission for the EDID bounty.
  Tagged as ScrModes-0_56-smalltables.
parent faff5d05
......@@ -150,7 +150,7 @@ void compute_modedescription(ModeDescriptionRef md)
{
uint32_t vtot, htot;
int pn;
ModeDefinition *mp = &md->definition; /* for terseness! */
ModeDef *mp = &md->definition.timings; /* for terseness! */
for (htot = 0, vtot = 0, pn = 0; pn < FR__COUNT; ++pn)
{
htot += mp->hpar[pn];
......@@ -175,19 +175,19 @@ void compute_modedescription(ModeDescriptionRef md)
*/
static int modes_inorder(ModeDescriptionRef m1, ModeDescriptionRef m2)
{
if (m1->definition.xres < m2->definition.xres)
if (m1->definition.timings.xres < m2->definition.timings.xres)
{
return 1;
}
if (m1->definition.xres > m2->definition.xres)
if (m1->definition.timings.xres > m2->definition.timings.xres)
{
return 0;
}
if (m1->definition.yres < m2->definition.yres)
if (m1->definition.timings.yres < m2->definition.timings.yres)
{
return 1;
}
if (m1->definition.yres > m2->definition.yres)
if (m1->definition.timings.yres > m2->definition.timings.yres)
{
return 0;
}
......@@ -199,11 +199,11 @@ static int modes_inorder(ModeDescriptionRef m1, ModeDescriptionRef m2)
{
return 0;
}
if (m1->definition.pixel_khz < m2->definition.pixel_khz)
if (m1->definition.timings.pixel_khz < m2->definition.timings.pixel_khz)
{
return 1;
}
if (m1->definition.pixel_khz > m2->definition.pixel_khz)
if (m1->definition.timings.pixel_khz > m2->definition.timings.pixel_khz)
{
return 0;
}
......@@ -418,11 +418,11 @@ static void build_a_vidclist(VIDCListRef vp, ModeDescriptionRef mp, const PixelF
vp->depth = pf->log2bpp;
for (fn = 0; fn < FR__COUNT; ++fn)
{
vp->hpar[fn] = mp->definition.hpar[fn];
vp->vpar[fn] = mp->definition.vpar[fn];
vp->hpar[fn] = mp->definition.timings.hpar[fn];
vp->vpar[fn] = mp->definition.timings.vpar[fn];
}
vp->pixelrate = mp->definition.pixel_khz;
vp->syncpol = mp->definition.syncpol;
vp->pixelrate = mp->definition.timings.pixel_khz;
vp->syncpol = mp->definition.timings.syncpol;
/* Only specify ModeFlags & NColour if necessary? */
if (!is_old_format(pf))
......@@ -465,14 +465,14 @@ static void build_a_vidclist(VIDCListRef vp, ModeDescriptionRef mp, const PixelF
ctrllistpos++;
}
if (mp->definition.external_clock != -1)
if (mp->definition.timings.external_clock != -1)
{
vp->vcparam[ctrllistpos].index = HCLK_INDEX;
vp->vcparam[ctrllistpos].value = mp->definition.external_clock;
vp->vcparam[ctrllistpos].value = mp->definition.timings.external_clock;
ctrllistpos++;
}
if (mp->definition.interlaced)
if (mp->definition.timings.interlaced)
{
vp->vcparam[ctrllistpos].index = INTERLACED_INDEX;
vp->vcparam[ctrllistpos].value = 1;
......@@ -500,9 +500,9 @@ static int mode_valid(ModeDescriptionRef mp, const PixelFormatRef pf,
{
_kernel_swi_regs r;
VIDCList vetlist;
uint32_t pixrate = mp->definition.pixel_khz;
uint32_t mx = mp->definition.xres;
uint32_t my = mp->definition.yres;
uint32_t pixrate = mp->definition.timings.pixel_khz;
uint32_t mx = mp->definition.timings.xres;
uint32_t my = mp->definition.timings.yres;
uint32_t pixels = mx * my;
uint32_t datarate, datasize;
......@@ -594,11 +594,11 @@ static int mode_valid(ModeDescriptionRef mp, const PixelFormatRef pf,
static ModeDescriptionRef find_by_xy(ModeDescriptionRef mp,
uint32_t xres, uint32_t yres, int *count)
{
while (mp && mp->definition.xres < xres)
while (mp && mp->definition.timings.xres < xres)
mp = mp->next;
while (mp && mp->definition.xres == xres && mp->definition.yres < yres)
while (mp && mp->definition.timings.xres == xres && mp->definition.timings.yres < yres)
mp = mp->next;
if (mp && mp->definition.xres == xres && mp->definition.yres == yres)
if (mp && mp->definition.timings.xres == xres && mp->definition.timings.yres == yres)
{
int entries;
ModeDescriptionRef head = mp;
......@@ -607,8 +607,8 @@ static ModeDescriptionRef find_by_xy(ModeDescriptionRef mp,
{
++entries;
mp = mp->next;
} while (mp && mp->definition.xres == xres &&
mp->definition.yres == yres);
} while (mp && mp->definition.timings.xres == xres &&
mp->definition.timings.yres == yres);
*count = entries;
return head;
}
......@@ -844,8 +844,8 @@ static void service_enumeratescreenmodes(_kernel_swi_regs *regs)
/* Copy the mode information into the supplied data buffer */
ip->blocksize = entrysize;
ip->format = 0; ip->flags = 0; ip->bit0 = 1;
ip->xresol = mp->definition.xres;
ip->yresol = mp->definition.yres;
ip->xresol = mp->definition.timings.xres;
ip->yresol = mp->definition.timings.yres;
ip->depth = pf->log2bpp; /* log2(bits/pixel) */
ip->framerate = mp->frame_hz; /* integer Hz value used here */
......@@ -863,8 +863,8 @@ static void service_enumeratescreenmodes(_kernel_swi_regs *regs)
/* Copy the mode information into the supplied data buffer */
ip->blocksize = entrysize;
ip->format = 1; ip->flags = 0; ip->bit0 = 1;
ip->xresol = mp->definition.xres;
ip->yresol = mp->definition.yres;
ip->xresol = mp->definition.timings.xres;
ip->yresol = mp->definition.timings.yres;
ip->pixelformat = *pf;
ip->framerate = mp->frame_hz; /* integer Hz value used here */
......
......@@ -50,6 +50,8 @@ static int timing_support = EDID_USE_DMT;
*/
static bool add_proposed_mode(MonitorDescriptionRef monitor_definition, ModeDescriptionRef proposed_mode, int32_t frame_hz, uint8_t priority)
{
sprintf(proposed_mode->definition.name, "%u x %u", proposed_mode->definition.timings.xres,
proposed_mode->definition.timings.yres);
compute_modedescription(proposed_mode);
if (frame_hz != -1)
{
......@@ -101,7 +103,7 @@ static void display_mode_parameters(ModeDescriptionRef mode_desc)
/* Copy a builtin mode and add it to the monitor description
*/
static _kernel_oserror *add_builtin_mode(MonitorDescriptionRef monitor, const ModeDefinition *mode, uint8_t priority)
static _kernel_oserror *add_builtin_mode(MonitorDescriptionRef monitor, const ModeDef *mode, uint8_t priority)
{
ModeDescriptionRef mode_desc = (ModeDescriptionRef) malloc(sizeof(ModeDescription));
if (mode_desc == NULL)
......@@ -109,7 +111,8 @@ static _kernel_oserror *add_builtin_mode(MonitorDescriptionRef monitor, const Mo
return error(ERR_NOSPACE, 0, 0, 0);
}
mode_desc->definition = *mode;
mode_desc->definition.timings = *mode;
if (!add_proposed_mode(monitor, mode_desc, mode->freq, priority))
{
free(mode_desc);
......@@ -227,6 +230,7 @@ static bool generate_mode_using_gtf(uint32_t h_pixels, uint32_t v_lines, uint32_
uint32_t pixel_freq;
uint64_t num, den;
int32_t ideal_duty_cycle_s7p24;
ModeDef *mp;
const bool int_rqd = false; /* Interlacing not propagated to mode description */
const bool margins_rqd = false; /* Margins currently not offered */
......@@ -329,32 +333,32 @@ static bool generate_mode_using_gtf(uint32_t h_pixels, uint32_t v_lines, uint32_
v_front_porch = GTF_MIN_PORCH;
v_sync_rqd = GTF_V_SYNC_RQD;
mode_desc->definition.xres = h_pixels;
mode_desc->definition.yres = v_lines;
mode_desc->definition.hpar[FR_SYNC] = h_sync_pixels;
mode_desc->definition.hpar[FR_BPCH] = h_back_porch;
mode_desc->definition.hpar[FR_BDR1] = left_margin;
mode_desc->definition.hpar[FR_DISP] = h_pixels;
mode_desc->definition.hpar[FR_BDR2] = right_margin;
mode_desc->definition.hpar[FR_FPCH] = h_front_porch;
mode_desc->definition.vpar[FR_SYNC] = v_sync_rqd;
mode_desc->definition.vpar[FR_BPCH] = v_back_porch; /* Note, loss of interlacing */
mode_desc->definition.vpar[FR_BDR1] = top_margin;
mode_desc->definition.vpar[FR_DISP] = v_lines;
mode_desc->definition.vpar[FR_BDR2] = bottom_margin;
mode_desc->definition.vpar[FR_FPCH] = v_front_porch; /* Note, loss of interlacing */
mode_desc->definition.pixel_khz = pixel_freq;
mode_desc->definition.external_clock = -1;
mp = &mode_desc->definition.timings;
mp->xres = h_pixels;
mp->yres = v_lines;
mp->hpar[FR_SYNC] = h_sync_pixels;
mp->hpar[FR_BPCH] = h_back_porch;
mp->hpar[FR_BDR1] = left_margin;
mp->hpar[FR_DISP] = h_pixels;
mp->hpar[FR_BDR2] = right_margin;
mp->hpar[FR_FPCH] = h_front_porch;
mp->vpar[FR_SYNC] = v_sync_rqd;
mp->vpar[FR_BPCH] = v_back_porch; /* Note, loss of interlacing */
mp->vpar[FR_BDR1] = top_margin;
mp->vpar[FR_DISP] = v_lines;
mp->vpar[FR_BDR2] = bottom_margin;
mp->vpar[FR_FPCH] = v_front_porch; /* Note, loss of interlacing */
mp->pixel_khz = pixel_freq;
mp->external_clock = -1;
if (timing_support == EDID_USE_GTF)
{
mode_desc->definition.syncpol = HSync_Negative+VSync_Positive; /* Default GTF */
mp->syncpol = HSync_Negative+VSync_Positive; /* Default GTF */
}
else
{
mode_desc->definition.syncpol = HSync_Positive+VSync_Negative; /* Secondary GTF */
mp->syncpol = HSync_Positive+VSync_Negative; /* Secondary GTF */
}
mode_desc->definition.interlaced = int_rqd ? 1 : 0;
sprintf(mode_desc->definition.name, "%d x %d", h_pixels, v_lines);
mp->interlaced = int_rqd ? 1 : 0;
if (!add_proposed_mode(monitor, mode_desc, ip_freq_rqd, 6))
{
......@@ -400,6 +404,7 @@ static bool generate_mode_using_cvt_rb(uint32_t h_pixels, uint32_t v_lines, uint
uint32_t pixel_freq;
uint64_t num, den;
int32_t ideal_duty_cycle_s7p24;
ModeDef *mp;
const bool int_rqd = false; /* Interlacing not propagated to mode description */
const bool margins_rqd = false; /* Margins currently not offered */
......@@ -530,32 +535,32 @@ static bool generate_mode_using_cvt_rb(uint32_t h_pixels, uint32_t v_lines, uint
h_front_porch = (h_blank / 2) - h_sync_pixels;
h_back_porch = h_front_porch + h_sync_pixels;
mode_desc->definition.xres = h_pixels;
mode_desc->definition.yres = v_lines;
mode_desc->definition.hpar[FR_SYNC] = h_sync_pixels;
mode_desc->definition.hpar[FR_BPCH] = h_back_porch;
mode_desc->definition.hpar[FR_BDR1] = left_margin;
mode_desc->definition.hpar[FR_DISP] = h_pixels;
mode_desc->definition.hpar[FR_BDR2] = right_margin;
mode_desc->definition.hpar[FR_FPCH] = h_front_porch;
mode_desc->definition.vpar[FR_SYNC] = v_sync_rnd;
mode_desc->definition.vpar[FR_BPCH] = v_back_porch;
mode_desc->definition.vpar[FR_BDR1] = top_margin;
mode_desc->definition.vpar[FR_DISP] = v_lines;
mode_desc->definition.vpar[FR_BDR2] = bottom_margin;
mode_desc->definition.vpar[FR_FPCH] = v_front_porch;
mode_desc->definition.pixel_khz = pixel_freq;
mode_desc->definition.external_clock = -1;
mp = &mode_desc->definition.timings;
mp->xres = h_pixels;
mp->yres = v_lines;
mp->hpar[FR_SYNC] = h_sync_pixels;
mp->hpar[FR_BPCH] = h_back_porch;
mp->hpar[FR_BDR1] = left_margin;
mp->hpar[FR_DISP] = h_pixels;
mp->hpar[FR_BDR2] = right_margin;
mp->hpar[FR_FPCH] = h_front_porch;
mp->vpar[FR_SYNC] = v_sync_rnd;
mp->vpar[FR_BPCH] = v_back_porch;
mp->vpar[FR_BDR1] = top_margin;
mp->vpar[FR_DISP] = v_lines;
mp->vpar[FR_BDR2] = bottom_margin;
mp->vpar[FR_FPCH] = v_front_porch;
mp->pixel_khz = pixel_freq;
mp->external_clock = -1;
if (timing_support == EDID_USE_CVT)
{
mode_desc->definition.syncpol = HSync_Negative+VSync_Positive; /* CVT */
mp->syncpol = HSync_Negative+VSync_Positive; /* CVT */
}
else
{
mode_desc->definition.syncpol = HSync_Positive+VSync_Negative; /* CVT reduced blanking */
mp->syncpol = HSync_Positive+VSync_Negative; /* CVT reduced blanking */
}
mode_desc->definition.interlaced = int_rqd ? 1 : 0;
sprintf(mode_desc->definition.name, "%d x %d", h_pixels, v_lines);
mp->interlaced = int_rqd ? 1 : 0;
if (!add_proposed_mode(monitor, mode_desc, ip_freq_rqd, 6))
{
......@@ -585,7 +590,8 @@ static _kernel_oserror *generate_standard_timing(char std1, char std2, MonitorDe
return error(ERR_NOSPACE, 0, 0, 0);
}
mode_desc->definition = display_monitor_timings[std_timings[i].dmt-1];
mode_desc->definition.timings = display_monitor_timings[std_timings[i].dmt-1];
if (!add_proposed_mode(monitor, mode_desc,
display_monitor_timings[std_timings[i].dmt-1].freq, 5))
{
......@@ -678,7 +684,8 @@ static _kernel_oserror *generate_cvt3_timing(char cvt1, char cvt2, char cvt3, Mo
return error(ERR_NOSPACE, 0, 0, 0);
}
mode_desc->definition = display_monitor_timings[cvt_timings[i].dmt-1];
mode_desc->definition.timings = display_monitor_timings[cvt_timings[i].dmt-1];
if (!add_proposed_mode(monitor, mode_desc,
display_monitor_timings[cvt_timings[i].dmt-1].freq, 4))
{
......@@ -818,32 +825,34 @@ static _kernel_oserror *generate_cvt3_timing(char cvt1, char cvt2, char cvt3, Mo
*/
static bool dtd_block_to_modedesc(const uint8_t *dtd_data, MonitorDescriptionRef monitor, ModeDescriptionRef mode_desc, uint8_t priority)
{
ModeDef *mp = & mode_desc->definition.timings;
IFDEBUG printf("Detailed timing descriptor:\n");
mode_desc->definition.xres = dtd_data[2] + ((dtd_data[4] & 0xf0) << 4);
mode_desc->definition.yres = dtd_data[5] + ((dtd_data[7] & 0xf0) << 4);
mode_desc->definition.interlaced = ((dtd_data[17]>>7) & 1);
mode_desc->definition.hpar[FR_SYNC] = dtd_data[9] + ((dtd_data[11] & 0x30) << 4);
mode_desc->definition.hpar[FR_BDR1] = dtd_data[15];
mode_desc->definition.hpar[FR_DISP] = mode_desc->definition.xres;
mode_desc->definition.hpar[FR_BDR2] = dtd_data[15];
mode_desc->definition.hpar[FR_FPCH] = dtd_data[8] + ((dtd_data[11] & 0xc0) << 2);
mode_desc->definition.hpar[FR_BPCH] = dtd_data[3] + ((dtd_data[4] & 0x0f) << 8) -
mode_desc->definition.hpar[FR_SYNC] -
mode_desc->definition.hpar[FR_FPCH] -
mode_desc->definition.hpar[FR_BDR1] -
mode_desc->definition.hpar[FR_BDR2];
mode_desc->definition.vpar[FR_SYNC] = (dtd_data[10] & 0xf) + ((dtd_data[11] & 0x3) << 4);
mode_desc->definition.vpar[FR_BDR1] = dtd_data[16];
mode_desc->definition.vpar[FR_DISP] = mode_desc->definition.yres;
mode_desc->definition.vpar[FR_BDR2] = dtd_data[16];
mode_desc->definition.vpar[FR_FPCH] = (dtd_data[10] >> 4) + ((dtd_data[11] & 0xc) << 2);
mode_desc->definition.vpar[FR_BPCH] = dtd_data[6] + ((dtd_data[7] & 0x0f) << 8) -
mode_desc->definition.vpar[FR_SYNC] -
mode_desc->definition.vpar[FR_FPCH] -
mode_desc->definition.vpar[FR_BDR1] -
mode_desc->definition.vpar[FR_BDR2];
mode_desc->definition.pixel_khz = (dtd_data[0] + (dtd_data[1]<<8)) * 10;
mode_desc->definition.external_clock = -1;
mp->xres = dtd_data[2] + ((dtd_data[4] & 0xf0) << 4);
mp->yres = dtd_data[5] + ((dtd_data[7] & 0xf0) << 4);
mp->interlaced = ((dtd_data[17]>>7) & 1);
mp->hpar[FR_SYNC] = dtd_data[9] + ((dtd_data[11] & 0x30) << 4);
mp->hpar[FR_BDR1] = dtd_data[15];
mp->hpar[FR_DISP] = mp->xres;
mp->hpar[FR_BDR2] = dtd_data[15];
mp->hpar[FR_FPCH] = dtd_data[8] + ((dtd_data[11] & 0xc0) << 2);
mp->hpar[FR_BPCH] = dtd_data[3] + ((dtd_data[4] & 0x0f) << 8) -
mp->hpar[FR_SYNC] -
mp->hpar[FR_FPCH] -
mp->hpar[FR_BDR1] -
mp->hpar[FR_BDR2];
mp->vpar[FR_SYNC] = (dtd_data[10] & 0xf) + ((dtd_data[11] & 0x3) << 4);
mp->vpar[FR_BDR1] = dtd_data[16];
mp->vpar[FR_DISP] = mp->yres;
mp->vpar[FR_BDR2] = dtd_data[16];
mp->vpar[FR_FPCH] = (dtd_data[10] >> 4) + ((dtd_data[11] & 0xc) << 2);
mp->vpar[FR_BPCH] = dtd_data[6] + ((dtd_data[7] & 0x0f) << 8) -
mp->vpar[FR_SYNC] -
mp->vpar[FR_FPCH] -
mp->vpar[FR_BDR1] -
mp->vpar[FR_BDR2];
mp->pixel_khz = (dtd_data[0] + (dtd_data[1]<<8)) * 10;
mp->external_clock = -1;
/* Only accept non-stereoscopic modes
* Technically we should check for sync here (since we only really support
......@@ -860,22 +869,21 @@ static bool dtd_block_to_modedesc(const uint8_t *dtd_data, MonitorDescriptionRef
}
/* -----00- is negative-negative, start with that and then invert if necessary */
mode_desc->definition.syncpol = HSync_Negative+VSync_Negative;
mp->syncpol = HSync_Negative+VSync_Negative;
if (dtd_data[17] & 4)
{
mode_desc->definition.syncpol ^= VSync_Negative^VSync_Positive;
mp->syncpol ^= VSync_Negative^VSync_Positive;
}
if (dtd_data[17] & 2)
{
mode_desc->definition.syncpol ^= HSync_Negative^HSync_Positive;
mp->syncpol ^= HSync_Negative^HSync_Positive;
}
/* If we are interlaced, we need to double the number of vertical pixels */
if (mode_desc->definition.interlaced == 1)
if (mp->interlaced == 1)
{
mode_desc->definition.yres = mode_desc->definition.yres * 2;
mp->yres = mp->yres * 2;
}
sprintf(mode_desc->definition.name, "%d x %d", mode_desc->definition.xres, mode_desc->definition.yres);
if (!add_proposed_mode(monitor, mode_desc, -1, priority))
{
......@@ -1028,7 +1036,7 @@ static _kernel_oserror *process_cea_video_data_block(EDIDExtensionBlockRef ext_b
{
_kernel_oserror *err;
uint8_t num = block[0] & 0x7f;
const ModeDefinition *mode;
const ModeDef *mode;
IFDEBUG printf("CEA SVD %02x -> CEA mode %d%s\n", block[0], num, (block[0] & 128) ? " (native)" : "");
block++;
......@@ -1336,7 +1344,7 @@ static _kernel_oserror *parseedid(char *ediddata, const char *file)
/* Sort the data blocks - store information strings and detailed
* timing descriptors. Defer CVT codes and Established timings III
* The first block is the 'preferred timing mode' and has highest
* priority to go in the MDF. Any other 'detailed timing modes
* priority to go in the MDF. Any other 'detailed timing modes'
* have second priority so they will go in next.
*/
for (int blockno = 0; blockno < 4; blockno++)
......@@ -1361,7 +1369,7 @@ static _kernel_oserror *parseedid(char *ediddata, const char *file)
free(mp);
break;
}
IFDEBUG printf("Detailed Mode: %s, X: %i Y: %i\n", mp->definition.name,mp->definition.xres, mp->definition.yres);
IFDEBUG printf("Detailed Mode: %s, X: %i Y: %i\n", mp->definition.name, mp->definition.timings.xres, mp->definition.timings.yres);
if (blockno == 0)
{
/* The first block should define the preferred mode */
......@@ -1479,12 +1487,12 @@ static _kernel_oserror *parseedid(char *ediddata, const char *file)
* http://www.javiervalcarce.eu/html/vga-signal-format-timming-specs-en.html
* http://www.epanorama.net/documents/pc/vga_timing.html
*/
static const ModeDefinition established_timing_7 =
static const ModeDef established_timing_7 =
{
/* 720 x 400 @ 70Hz */
"720 x 400", 720, 400, 108, 54, 0, 720, 0, 18,
2, 34, 0, 400, 0, 13,
28322, -1, NP, 0, 70, 0
720, 400, 108, 54, 0, 720, 0, 18,
2, 34, 0, 400, 0, 13,
28322, -1, NP, 0, 70, 0
};
/* There are 3 cases which do not have defined DMT codes.
......@@ -1663,16 +1671,18 @@ static _kernel_oserror *parseedid(char *ediddata, const char *file)
ModeDescriptionRef this = new_monitor->modelist;
do
{
fprintf(f,"\n# Mode: %d x %d @ %dHz",this->definition.xres,this->definition.yres,this->frame_hz);
ModeDef *mp = &this->definition.timings;
fprintf(f,"\n# Mode: %d x %d @ %dHz",mp->xres,mp->yres,this->frame_hz);
fprintf(f,"\nstartmode");
fprintf(f,"\n mode_name:%d x %d",this->definition.xres,this->definition.yres);
fprintf(f,"\n x_res:%d",this->definition.xres);
fprintf(f,"\n y_res:%d",this->definition.yres);
fprintf(f,"\n pixel_rate:%d",this->definition.pixel_khz);
fprintf(f,"\n h_timings:%d,%d,%d,%d,%d,%d",this->definition.hpar[0],this->definition.hpar[1],this->definition.hpar[2],this->definition.hpar[3],this->definition.hpar[4],this->definition.hpar[5]);
fprintf(f,"\n v_timings:%d,%d,%d,%d,%d,%d",this->definition.vpar[0],this->definition.vpar[1],this->definition.vpar[2],this->definition.vpar[3],this->definition.vpar[4],this->definition.vpar[5]);
fprintf(f,"\n sync_pol:%d",this->definition.syncpol);
if (this->definition.interlaced == 1)
fprintf(f,"\n mode_name:%d x %d",mp->xres,mp->yres);
fprintf(f,"\n x_res:%d",mp->xres);
fprintf(f,"\n y_res:%d",mp->yres);
fprintf(f,"\n pixel_rate:%d",mp->pixel_khz);
fprintf(f,"\n h_timings:%d,%d,%d,%d,%d,%d",mp->hpar[0],mp->hpar[1],mp->hpar[2],mp->hpar[3],mp->hpar[4],mp->hpar[5]);
fprintf(f,"\n v_timings:%d,%d,%d,%d,%d,%d",mp->vpar[0],mp->vpar[1],mp->vpar[2],mp->vpar[3],mp->vpar[4],mp->vpar[5]);
fprintf(f,"\n sync_pol:%d",mp->syncpol);
if (mp->interlaced == 1)
{
fprintf(f,"\n interlaced");
}
......@@ -1726,8 +1736,8 @@ static _kernel_oserror *parseedid(char *ediddata, const char *file)
{
preferred_mode->bit0 = 1;
preferred_mode->format = 0;
preferred_mode->xresol = new_preferred_mode->definition.xres;
preferred_mode->yresol = new_preferred_mode->definition.yres;
preferred_mode->xresol = new_preferred_mode->definition.timings.xres;
preferred_mode->yresol = new_preferred_mode->definition.timings.yres;
preferred_mode->depth = 5;
preferred_mode->framerate = new_preferred_mode->frame_hz;
preferred_mode->param[0].index = -1;
......
......@@ -382,9 +382,10 @@ static _kernel_oserror *check_keyword(enum keycode code, int colon)
}
}
static _kernel_oserror *parse_mode(ModeDefinition *mode)
static _kernel_oserror *parse_mode(ModeDefinition *definition)
{
uint32_t keyseen;
ModeDef *mode = &definition->timings;
keyseen = 0;
mode->interlaced = 0; /* Assume mode is not interlaced, unless we see the keyword */
......@@ -438,7 +439,7 @@ static _kernel_oserror *parse_mode(ModeDefinition *mode)
}
else
{
return semerrS(ERR_INCOMPLETE, mode->name);
return semerrS(ERR_INCOMPLETE, definition->name);
}
}
/* If xres and/or yres missing, use the xdisp and/or ydisp values */
......@@ -455,7 +456,7 @@ static _kernel_oserror *parse_mode(ModeDefinition *mode)
if (mode->xres != mode->hpar[FR_DISP] ||
mode->yres != mode->vpar[FR_DISP] * (mode->interlaced+1))
{
return semerrS(ERR_INCONSISTENT, mode->name);
return semerrS(ERR_INCONSISTENT, definition->name);
}
return check_eol(1);
......@@ -526,7 +527,7 @@ static _kernel_oserror *parse_mode(ModeDefinition *mode)
* Passing in -1 as the error number for read_text means don't
* fault blank lines.
*/
res = read_text(mode->name, sizeof(mode->name), -1);
res = read_text(definition->name, sizeof(definition->name), -1);
if (res)
{
return res;
......@@ -607,9 +608,9 @@ static _kernel_oserror *parse_modelist(MonitorDescriptionRef monitor, enum keyco
return res; /* failed */
}
/* fill in defaults */
if (mp->definition.external_clock == -1)
if (mp->definition.timings.external_clock == -1)
{
mp->definition.external_clock = monitor->external_clock;
mp->definition.timings.external_clock = monitor->external_clock;
}
/* derive frame and line rates */
compute_modedescription(mp);
......@@ -650,7 +651,7 @@ static void show_monitor(MonitorDescriptionRef monitor)
printf("Monitor title: \"%s\"\n", monitor->name);
for (mode = monitor->modelist; mode; mode = mode->next)
{
ModeDefinition *dp = &mode->definition;
ModeDef *dp = &mode->definition.timings;
uint32_t pixrate = dp->pixel_khz;
uint32_t pixels = dp->xres * dp->yres;
int log2bpp;
......
This diff is collapsed.
......@@ -44,8 +44,8 @@ static void comparetimings(ModeDescriptionRef a, ModeDescriptionRef b, int rate)
countall++;
for (i = 0; i < FR__COUNT; i++)
{
if ((a->definition.vpar[i] != b->definition.vpar[i]) ||
(a->definition.vpar[i] != b->definition.vpar[i]))
if ((a->definition.timings.vpar[i] != b->definition.timings.vpar[i]) ||
(a->definition.timings.vpar[i] != b->definition.timings.vpar[i]))
{
same = false;
break;
......@@ -55,7 +55,7 @@ static void comparetimings(ModeDescriptionRef a, ModeDescriptionRef b, int rate)
/* Allow 0.5% tolerance on pixel clock (CVT 3.3.1) so we can compare
* rational integer fractions with irrational float fractions.
*/
error = (1000 * a->definition.pixel_khz) / b->definition.pixel_khz;
error = (1000 * a->definition.timings.pixel_khz) / b->definition.timings.pixel_khz;
error = 1000 - error;
if (abs(error) > 5) same = false;
if (same)
......@@ -64,19 +64,19 @@ static void comparetimings(ModeDescriptionRef a, ModeDescriptionRef b, int rate)
return;
}
printf("Mode differs for %dx%d @ %d\n", a->definition.xres, a->definition.yres, rate);
printf("pclk %d %d\n", a->definition.pixel_khz, b->definition.pixel_khz);
printf("Mode differs for %dx%d @ %d\n", a->definition.timings.xres, a->definition.timings.yres, rate);
printf("pclk %d %d\n", a->definition.timings.pixel_khz, b->definition.timings.pixel_khz);
for (i = 0; i < FR__COUNT; i++)
{
printf("hpar %d %d, vpar %d %d\n", a->definition.hpar[i], b->definition.hpar[i],
a->definition.vpar[i], b->definition.vpar[i]);
printf("hpar %d %d, vpar %d %d\n", a->definition.timings.hpar[i], b->definition.timings.hpar[i],
a->definition.timings.vpar[i], b->definition.timings.vpar[i]);
}
}
#define ROUND_DIV(n,d) (((n) + ((d) >> 1)) / (d)) /* Excel's ROUND(n/d,0) */
#define ROUNDDOWN_DIV(n,d) ((n) / (d)) /* Excel's ROUNDDOWN(n/d,0) */
static void generate_mode_using_gtfint(uint32_t h_pixels, uint32_t v_lines, uint32_t ip_freq_rqd, ModeDescriptionRef mode_desc, MonitorDescriptionRef monitor)
static bool generate_mode_using_gtfint(uint32_t h_pixels, uint32_t v_lines, uint32_t ip_freq_rqd, ModeDescriptionRef mode_desc, MonitorDescriptionRef monitor)
{
/* Based on VESA GTF spec 1.1, the variable names match those in the spec and equation
* numbers labelled for cross referencing.
......@@ -107,6 +107,7 @@ static void generate_mode_using_gtfint(uint32_t h_pixels, uint32_t v_lines, uint
uint32_t pixel_freq;
uint64_t num, den;
int32_t ideal_duty_cycle_s7p24;
ModeDef *mp;
const bool int_rqd = false; /* Interlacing not propagated to mode description */
const bool margins_rqd = false; /* Margins currently not offered */
......@@ -181,7 +182,7 @@ static void generate_mode_using_gtfint(uint32_t h_pixels, uint32_t v_lines, uint
ideal_duty_cycle_s7p24 = (int32_t)((GTF_C_PRIME << 24) - (uint32_t)(num / den));
if (ideal_duty_cycle_s7p24 < 0)
{
return; /* Not a valid duty cycle */
return false; /* Not a valid duty cycle */
}
/* 7.3.19 horizontal blanking period in pixels & 7.3.20 total pixels */
......@@ -207,25 +208,28 @@ static void generate_mode_using_gtfint(uint32_t h_pixels, uint32_t v_lines, uint
v_front_porch = GTF_MIN_PORCH;
v_sync_rqd = GTF_V_SYNC_RQD;