CVS commit: src/sys/dev/videomode
Module Name:src Committed By: maxv Date: Sat Jan 25 15:59:11 UTC 2020 Modified Files: src/sys/dev/videomode: edid.c Log Message: Fix uninitialized variable. There may not be a TYPE_ASCII block. Found by kMSan with nouveau. To generate a diff of this commit: cvs rdiff -u -r1.14 -r1.15 src/sys/dev/videomode/edid.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/dev/videomode/edid.c diff -u src/sys/dev/videomode/edid.c:1.14 src/sys/dev/videomode/edid.c:1.15 --- src/sys/dev/videomode/edid.c:1.14 Tue Jul 10 01:44:30 2018 +++ src/sys/dev/videomode/edid.c Sat Jan 25 15:59:11 2020 @@ -1,4 +1,4 @@ -/* $NetBSD: edid.c,v 1.14 2018/07/10 01:44:30 macallan Exp $ */ +/* $NetBSD: edid.c,v 1.15 2020/01/25 15:59:11 maxv Exp $ */ /*- * Copyright (c) 2006 Itronix Inc. @@ -32,7 +32,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: edid.c,v 1.14 2018/07/10 01:44:30 macallan Exp $"); +__KERNEL_RCSID(0, "$NetBSD: edid.c,v 1.15 2020/01/25 15:59:11 maxv Exp $"); #include #include @@ -467,6 +467,7 @@ edid_block(struct edid_info *edid, uint8 break; case EDID_DESC_BLOCK_TYPE_ASCII: + memset(edid->edid_comment, 0, sizeof(edid->edid_comment)); memcpy(edid->edid_comment, data + EDID_DESC_ASCII_DATA_OFFSET, EDID_DESC_ASCII_DATA_LEN); edid->edid_comment[sizeof(edid->edid_comment) - 1] = 0; @@ -562,6 +563,8 @@ edid_parse(uint8_t *data, struct edid_in snprintf(edid->edid_serial, sizeof(edid->edid_serial), "%08x", EDID_SERIAL_NUMBER(data)); + edid->edid_comment[0] = '\0'; + edid->edid_week = EDID_WEEK(data); edid->edid_year = EDID_YEAR(data);
CVS commit: src/sys/dev/videomode
Module Name:src Committed By: macallan Date: Tue Jul 10 01:44:30 UTC 2018 Modified Files: src/sys/dev/videomode: edid.c Log Message: add quirk to find the native resolution on certain Iiyama monitors tested by MOCHIDA Shuji To generate a diff of this commit: cvs rdiff -u -r1.13 -r1.14 src/sys/dev/videomode/edid.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/dev/videomode/edid.c diff -u src/sys/dev/videomode/edid.c:1.13 src/sys/dev/videomode/edid.c:1.14 --- src/sys/dev/videomode/edid.c:1.13 Mon Nov 17 00:46:04 2014 +++ src/sys/dev/videomode/edid.c Tue Jul 10 01:44:30 2018 @@ -1,4 +1,4 @@ -/* $NetBSD: edid.c,v 1.13 2014/11/17 00:46:04 jmcneill Exp $ */ +/* $NetBSD: edid.c,v 1.14 2018/07/10 01:44:30 macallan Exp $ */ /*- * Copyright (c) 2006 Itronix Inc. @@ -32,7 +32,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: edid.c,v 1.13 2014/11/17 00:46:04 jmcneill Exp $"); +__KERNEL_RCSID(0, "$NetBSD: edid.c,v 1.14 2018/07/10 01:44:30 macallan Exp $"); #include #include @@ -420,6 +420,22 @@ edid_det_timing(uint8_t *data, struct vi return 1; } +static void bump_preferred_mode(struct edid_info *edid, struct videomode *m) +{ + /* + * XXX + * Iiyama 4800 series monitors may have their native resolution in the + * 2nd detailed timing descriptor instead of the 1st. Try to detect + * that here and pick the native mode anyway. + */ + if (edid->edid_preferred_mode == NULL) { + edid->edid_preferred_mode = m; + } else if ((strncmp(edid->edid_vendor, "IVM", 3) == 0) && + (edid->edid_product == 0x4800) && + (edid->edid_preferred_mode->dot_clock < m->dot_clock)) + edid->edid_preferred_mode = m; +} + static void edid_block(struct edid_info *edid, uint8_t *data) { @@ -433,13 +449,11 @@ edid_block(struct edid_info *edid, uint8 exist_mode = edid_search_mode(edid, ); if (exist_mode != NULL) { *exist_mode = mode; - if (edid->edid_preferred_mode == NULL) -edid->edid_preferred_mode = exist_mode; + bump_preferred_mode(edid, exist_mode); } else { edid->edid_modes[edid->edid_nmodes] = mode; - if (edid->edid_preferred_mode == NULL) -edid->edid_preferred_mode = ->edid_modes[edid->edid_nmodes]; + bump_preferred_mode(edid, + >edid_modes[edid->edid_nmodes]); edid->edid_nmodes++; } return;
CVS commit: src/sys/dev/videomode
Module Name:src Committed By: jmcneill Date: Mon Nov 17 00:46:04 UTC 2014 Modified Files: src/sys/dev/videomode: edid.c edidreg.h edidvar.h Log Message: Parse the extension block count field, and make it available in struct edid_info To generate a diff of this commit: cvs rdiff -u -r1.12 -r1.13 src/sys/dev/videomode/edid.c cvs rdiff -u -r1.3 -r1.4 src/sys/dev/videomode/edidreg.h cvs rdiff -u -r1.2 -r1.3 src/sys/dev/videomode/edidvar.h Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/dev/videomode/edid.c diff -u src/sys/dev/videomode/edid.c:1.12 src/sys/dev/videomode/edid.c:1.13 --- src/sys/dev/videomode/edid.c:1.12 Fri Feb 8 16:35:10 2013 +++ src/sys/dev/videomode/edid.c Mon Nov 17 00:46:04 2014 @@ -1,4 +1,4 @@ -/* $NetBSD: edid.c,v 1.12 2013/02/08 16:35:10 skrll Exp $ */ +/* $NetBSD: edid.c,v 1.13 2014/11/17 00:46:04 jmcneill Exp $ */ /*- * Copyright (c) 2006 Itronix Inc. @@ -32,7 +32,7 @@ */ #include sys/cdefs.h -__KERNEL_RCSID(0, $NetBSD: edid.c,v 1.12 2013/02/08 16:35:10 skrll Exp $); +__KERNEL_RCSID(0, $NetBSD: edid.c,v 1.13 2014/11/17 00:46:04 jmcneill Exp $); #include sys/param.h #include sys/systm.h @@ -286,6 +286,8 @@ edid_print(struct edid_info *edid) DIVIDE(DIVIDE(edid-edid_preferred_mode-dot_clock * 1000, edid-edid_preferred_mode-htotal), edid-edid_preferred_mode-vtotal)); + + printf(Number of extension blocks: %d\n, edid-edid_ext_block_count); } static const struct videomode * @@ -569,6 +571,8 @@ edid_parse(uint8_t *data, struct edid_in edid-edid_chroma.ec_whitex = EDID_CHROMA_WHITEX(data); edid-edid_chroma.ec_whitey = EDID_CHROMA_WHITEY(data); + edid-edid_ext_block_count = EDID_EXT_BLOCK_COUNT(data); + /* lookup established modes */ edid-edid_nmodes = 0; edid-edid_preferred_mode = NULL; Index: src/sys/dev/videomode/edidreg.h diff -u src/sys/dev/videomode/edidreg.h:1.3 src/sys/dev/videomode/edidreg.h:1.4 --- src/sys/dev/videomode/edidreg.h:1.3 Wed Mar 30 18:49:56 2011 +++ src/sys/dev/videomode/edidreg.h Mon Nov 17 00:46:04 2014 @@ -1,4 +1,4 @@ -/* $NetBSD: edidreg.h,v 1.3 2011/03/30 18:49:56 jdc Exp $ */ +/* $NetBSD: edidreg.h,v 1.4 2014/11/17 00:46:04 jmcneill Exp $ */ /*- * Copyright (c) 2006 Itronix Inc. @@ -250,4 +250,6 @@ #define EDID_DESC_STD_TIMING_START 5 #define EDID_DESC_STD_TIMING_COUNT 6 +#define EDID_EXT_BLOCK_COUNT(ptr) ((ptr)[126]) + #endif /* _DEV_VIDEOMODE_EDIDREG_H */ Index: src/sys/dev/videomode/edidvar.h diff -u src/sys/dev/videomode/edidvar.h:1.2 src/sys/dev/videomode/edidvar.h:1.3 --- src/sys/dev/videomode/edidvar.h:1.2 Thu May 11 19:05:41 2006 +++ src/sys/dev/videomode/edidvar.h Mon Nov 17 00:46:04 2014 @@ -1,4 +1,4 @@ -/* $NetBSD: edidvar.h,v 1.2 2006/05/11 19:05:41 gdamore Exp $ */ +/* $NetBSD: edidvar.h,v 1.3 2014/11/17 00:46:04 jmcneill Exp $ */ /*- * Copyright (c) 2006 Itronix Inc. @@ -75,6 +75,7 @@ struct edid_info { uint8_t edid_max_vsize; /* in cm */ uint8_t edid_gamma; uint8_t edid_features; + uint8_t edid_ext_block_count; int edid_have_range; struct edid_range edid_range;
CVS commit: src/sys/dev/videomode
Module Name:src Committed By: dholland Date: Fri Mar 21 22:00:00 UTC 2014 Modified Files: src/sys/dev/videomode: vesagtf.c Log Message: spelling in comments To generate a diff of this commit: cvs rdiff -u -r1.2 -r1.3 src/sys/dev/videomode/vesagtf.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/dev/videomode/vesagtf.c diff -u src/sys/dev/videomode/vesagtf.c:1.2 src/sys/dev/videomode/vesagtf.c:1.3 --- src/sys/dev/videomode/vesagtf.c:1.2 Sun Sep 15 15:56:07 2013 +++ src/sys/dev/videomode/vesagtf.c Fri Mar 21 22:00:00 2014 @@ -1,4 +1,4 @@ -/* $NetBSD: vesagtf.c,v 1.2 2013/09/15 15:56:07 martin Exp $ */ +/* $NetBSD: vesagtf.c,v 1.3 2014/03/21 22:00:00 dholland Exp $ */ /*- * Copyright (c) 2006 Itronix Inc. @@ -38,7 +38,7 @@ * Note that I have heavily modified the program for use in the EDID * kernel code for NetBSD, including removing the use of floating * point operations and making significant adjustments to minimize - * error propogation while operating with integer only math. + * error propagation while operating with integer only math. * * This has required the use of 64-bit integers in a few places, but * the upshot is that for a calculation of 1920x1200x85 (as an @@ -153,7 +153,7 @@ #ifdef _KERNEL #include sys/cdefs.h -__KERNEL_RCSID(0, $NetBSD: vesagtf.c,v 1.2 2013/09/15 15:56:07 martin Exp $); +__KERNEL_RCSID(0, $NetBSD: vesagtf.c,v 1.3 2014/03/21 22:00:00 dholland Exp $); #include sys/types.h #include sys/param.h #include sys/systm.h @@ -343,7 +343,7 @@ vesagtf_mode_params(unsigned h_pixels, u * * Finally we multiply by another 1000, to get value in picosec. * Why picosec? To minimize rounding errors. Gotta love integer - * math and error propogation. + * math and error propagation. */ h_period_est = DIVIDE(((DIVIDE(2ULL, v_field_rqd)) - @@ -402,7 +402,7 @@ vesagtf_mode_params(unsigned h_pixels, u * [V FIELD RATE EST] = 10 / [H PERIOD EST] / [TOTAL V LINES] * * This is all scaled to get the result in uHz. Again, we're trying to - * minimize error propogation. + * minimize error propagation. */ v_field_est = DIVIDE(DIVIDE(1000ULL, h_period_est), total_v_lines); @@ -495,7 +495,7 @@ vesagtf_mode_params(unsigned h_pixels, u * * The ending result is that our ideal_duty_cycle is 256000x larger * than the duty cycle used by VESA. But again, this reduces error - * propogation. + * propagation. */ ideal_duty_cycle =
CVS commit: src/sys/dev/videomode
Module Name:src Committed By: martin Date: Sun Sep 15 15:56:07 UTC 2013 Modified Files: src/sys/dev/videomode: vesagtf.c Log Message: Mark potentially unused variables To generate a diff of this commit: cvs rdiff -u -r1.1 -r1.2 src/sys/dev/videomode/vesagtf.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/dev/videomode/vesagtf.c diff -u src/sys/dev/videomode/vesagtf.c:1.1 src/sys/dev/videomode/vesagtf.c:1.2 --- src/sys/dev/videomode/vesagtf.c:1.1 Thu May 11 01:49:53 2006 +++ src/sys/dev/videomode/vesagtf.c Sun Sep 15 15:56:07 2013 @@ -1,4 +1,4 @@ -/* $NetBSD: vesagtf.c,v 1.1 2006/05/11 01:49:53 gdamore Exp $ */ +/* $NetBSD: vesagtf.c,v 1.2 2013/09/15 15:56:07 martin Exp $ */ /*- * Copyright (c) 2006 Itronix Inc. @@ -153,7 +153,7 @@ #ifdef _KERNEL #include sys/cdefs.h -__KERNEL_RCSID(0, $NetBSD: vesagtf.c,v 1.1 2006/05/11 01:49:53 gdamore Exp $); +__KERNEL_RCSID(0, $NetBSD: vesagtf.c,v 1.2 2013/09/15 15:56:07 martin Exp $); #include sys/types.h #include sys/param.h #include sys/systm.h @@ -226,12 +226,12 @@ vesagtf_mode_params(unsigned h_pixels, u unsigned interlace; uint64_t h_period_est; unsigned vsync_plus_bp; -unsigned v_back_porch; +unsigned v_back_porch __unused; unsigned total_v_lines; uint64_t v_field_est; uint64_t h_period; unsigned v_field_rate; -unsigned v_frame_rate; +unsigned v_frame_rate __unused; unsigned left_margin; unsigned right_margin; unsigned total_active_pixels;
CVS commit: src/sys/dev/videomode
Module Name:src Committed By: skrll Date: Fri Feb 8 16:35:10 UTC 2013 Modified Files: src/sys/dev/videomode: edid.c Log Message: aprint_verbose - aprint_debug To generate a diff of this commit: cvs rdiff -u -r1.11 -r1.12 src/sys/dev/videomode/edid.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/dev/videomode/edid.c diff -u src/sys/dev/videomode/edid.c:1.11 src/sys/dev/videomode/edid.c:1.12 --- src/sys/dev/videomode/edid.c:1.11 Sat Apr 9 22:09:05 2011 +++ src/sys/dev/videomode/edid.c Fri Feb 8 16:35:10 2013 @@ -1,4 +1,4 @@ -/* $NetBSD: edid.c,v 1.11 2011/04/09 22:09:05 christos Exp $ */ +/* $NetBSD: edid.c,v 1.12 2013/02/08 16:35:10 skrll Exp $ */ /*- * Copyright (c) 2006 Itronix Inc. @@ -32,7 +32,7 @@ */ #include sys/cdefs.h -__KERNEL_RCSID(0, $NetBSD: edid.c,v 1.11 2011/04/09 22:09:05 christos Exp $); +__KERNEL_RCSID(0, $NetBSD: edid.c,v 1.12 2013/02/08 16:35:10 skrll Exp $); #include sys/param.h #include sys/systm.h @@ -626,7 +626,7 @@ edid_parse(uint8_t *data, struct edid_in if (edid-edid_modes[i].dot_clock max_dotclock) max_dotclock = edid-edid_modes[i].dot_clock; - aprint_verbose(max_dotclock according to supported modes: %d\n, + aprint_debug(max_dotclock according to supported modes: %d\n, max_dotclock); mhz = (max_dotclock + 999) / 1000;
CVS commit: src/sys/dev/videomode
Module Name:src Committed By: jdc Date: Sat Apr 9 18:18:28 UTC 2011 Modified Files: src/sys/dev/videomode: edid.c Log Message: Remove duplicate video modes. When parsing the established and the detailed timings, check to see if this mode already exists in our mode list. If the mode exists when parsing established timings, then do nothing (we already have this exact mode). If the mode exists when parsing detailed timings, then replace our timings with the timings from the monitor. To generate a diff of this commit: cvs rdiff -u -r1.8 -r1.9 src/sys/dev/videomode/edid.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/dev/videomode/edid.c diff -u src/sys/dev/videomode/edid.c:1.8 src/sys/dev/videomode/edid.c:1.9 --- src/sys/dev/videomode/edid.c:1.8 Wed Mar 30 18:50:37 2011 +++ src/sys/dev/videomode/edid.c Sat Apr 9 18:18:28 2011 @@ -1,4 +1,4 @@ -/* $NetBSD: edid.c,v 1.8 2011/03/30 18:50:37 jdc Exp $ */ +/* $NetBSD: edid.c,v 1.9 2011/04/09 18:18:28 jdc Exp $ */ /*- * Copyright (c) 2006 Itronix Inc. @@ -32,7 +32,7 @@ */ #include sys/cdefs.h -__KERNEL_RCSID(0, $NetBSD: edid.c,v 1.8 2011/03/30 18:50:37 jdc Exp $); +__KERNEL_RCSID(0, $NetBSD: edid.c,v 1.9 2011/04/09 18:18:28 jdc Exp $); #include sys/param.h #include sys/systm.h @@ -300,6 +300,26 @@ return NULL; } +static struct videomode * +edid_search_mode(struct edid_info *edid, const struct videomode *mode) +{ + int refresh, i; + + refresh = DIVIDE(DIVIDE(mode-dot_clock * 1000, + mode-htotal), mode-vtotal); + for (i = 0; i edid-edid_nmodes; i++) { + if (mode-hdisplay == edid-edid_modes[i].hdisplay + mode-vdisplay == edid-edid_modes[i].vdisplay + refresh == DIVIDE(DIVIDE( + edid-edid_modes[i].dot_clock * 1000, + edid-edid_modes[i].htotal), + edid-edid_modes[i].vtotal)) { + return (edid-edid_modes[i]); + } + } + return NULL; +} + static int edid_std_timing(uint8_t *data, struct videomode *vmp) { @@ -373,7 +393,7 @@ vsyncwid = EDID_DET_TIMING_VSYNC_WIDTH(data); vsyncoff = EDID_DET_TIMING_VSYNC_OFFSET(data); - /* XXX: I'm not doing anything with the borders, should I? */ + /* Borders are contained within the blank areas. */ vmp-hdisplay = hactive; vmp-htotal = hactive + hblank; @@ -406,16 +426,27 @@ edid_block(struct edid_info *edid, uint8_t *data) { int i; - struct videomode mode; + struct videomode mode, *exist_mode; if (EDID_BLOCK_IS_DET_TIMING(data)) { if (edid_det_timing(data, mode)) { - edid-edid_modes[edid-edid_nmodes] = mode; - if (edid-edid_preferred_mode == NULL) { -edid-edid_preferred_mode = -edid-edid_modes[edid-edid_nmodes]; + /* Does this mode already exist? */ + exist_mode = edid_search_mode(edid, mode); + if (exist_mode != NULL) { +memcpy(exist_mode, mode, +sizeof(struct videomode)); +if (edid-edid_preferred_mode == NULL) { + edid-edid_preferred_mode = + exist_mode; +} + } else { +edid-edid_modes[edid-edid_nmodes] = mode; +if (edid-edid_preferred_mode == NULL) { + edid-edid_preferred_mode = + edid-edid_modes[edid-edid_nmodes]; +} +edid-edid_nmodes++; } - edid-edid_nmodes++; } return; } @@ -473,8 +504,13 @@ data += EDID_DESC_STD_TIMING_START; for (i = 0; i EDID_DESC_STD_TIMING_COUNT; i++) { if (edid_std_timing(data, mode)) { -edid-edid_modes[edid-edid_nmodes] = mode; -edid-edid_nmodes++; +/* Does this mode already exist? */ +exist_mode = edid_search_mode(edid, mode); +if (exist_mode == NULL) { + edid-edid_modes[edid-edid_nmodes] = + mode; + edid-edid_nmodes++; +} } data += 2; } @@ -574,11 +610,15 @@ /* do standard timing section */ for (i = 0; i EDID_STD_TIMING_COUNT; i++) { - struct videomode mode; + struct videomode mode, *exist_mode; if (edid_std_timing(data + EDID_OFFSET_STD_TIMING + i * 2, mode)) { - edid-edid_modes[edid-edid_nmodes] = mode; - edid-edid_nmodes++; + /* Does this mode already exist? */ + exist_mode = edid_search_mode(edid, mode); + if (exist_mode == NULL) { +edid-edid_modes[edid-edid_nmodes] = mode; +edid-edid_nmodes++; + } } }
CVS commit: src/sys/dev/videomode
Module Name:src Committed By: jdc Date: Sat Apr 9 18:22:31 UTC 2011 Modified Files: src/sys/dev/videomode: pickmode.c videomode.h Log Message: Add a new function - sort_modes() - to sort video modes in an approximate order of preference. The preferred mode is placed first. If there is no preferred mode, then the first mode with highest resolution is placed first. Other modes are then sorted on difference from the first mode by refresh rate, aspect ratio, then size. To generate a diff of this commit: cvs rdiff -u -r1.2 -r1.3 src/sys/dev/videomode/pickmode.c \ src/sys/dev/videomode/videomode.h Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/dev/videomode/pickmode.c diff -u src/sys/dev/videomode/pickmode.c:1.2 src/sys/dev/videomode/pickmode.c:1.3 --- src/sys/dev/videomode/pickmode.c:1.2 Tue Oct 12 16:18:19 2010 +++ src/sys/dev/videomode/pickmode.c Sat Apr 9 18:22:31 2011 @@ -1,4 +1,4 @@ -/* $NetBSD: pickmode.c,v 1.2 2010/10/12 16:18:19 macallan Exp $ */ +/* $NetBSD: pickmode.c,v 1.3 2011/04/09 18:22:31 jdc Exp $ */ /*- * Copyright (c) 2006 The NetBSD Foundation @@ -29,7 +29,7 @@ */ #include sys/cdefs.h -__KERNEL_RCSID(0, $NetBSD: pickmode.c,v 1.2 2010/10/12 16:18:19 macallan Exp $); +__KERNEL_RCSID(0, $NetBSD: pickmode.c,v 1.3 2011/04/09 18:22:31 jdc Exp $); #include sys/param.h #include dev/videomode/videomode.h @@ -101,3 +101,108 @@ return best; } + +static inline void +swap_modes(struct videomode *left, struct videomode *right) +{ + struct videomode temp; + + memcpy(temp, left, sizeof(struct videomode)); + memcpy(left, right, sizeof(struct videomode)); + memcpy(right, temp, sizeof(struct videomode)); +} + +/* + * Sort modes by refresh rate, aspect ratio (*), then resolution. + * Preferred mode or largest mode is first in the list and other modes + * are sorted on closest match to that mode. + * (*) Note that the aspect ratio calculation treats close aspect ratios + * (within 12.5%) as the same for this purpose. + */ +#define DIVIDE(x,y) (((x) + ((y) / 2)) / (y)) +void +sort_modes(struct videomode *modes, struct videomode **preferred, int nmodes) +{ + int aspect, refresh, hbest, vbest, abest, atemp, rbest, rtemp; + int i, j; + struct videomode *mtemp = NULL; + + if (nmodes 2) + return; + + if (*preferred != NULL) { + /* Put the preferred mode first in the list */ + aspect = (*preferred)-hdisplay * 100 / (*preferred)-vdisplay; + refresh = DIVIDE(DIVIDE((*preferred)-dot_clock * 1000, + (*preferred)-htotal), (*preferred)-vtotal); + if ((*preferred) != modes) { + swap_modes((*preferred), modes); + *preferred = modes; + } + } else { + /* + * Find the largest horizontal and vertical mode and put that + * first in the list. Preferred refresh rate is taken from + * the first mode of this size. + */ + hbest = 0; + vbest = 0; + for (i = 0; i nmodes; i++) { + if (modes[i].hdisplay hbest) { +hbest = modes[i].hdisplay; +vbest = modes[i].vdisplay; +mtemp = modes[i]; + } else if (modes[i].hdisplay == hbest + modes[i].vdisplay vbest) { +vbest = modes[i].vdisplay; +mtemp = modes[i]; + } + } + aspect = mtemp-hdisplay * 100 / mtemp-vdisplay; + refresh = DIVIDE(DIVIDE(mtemp-dot_clock * 1000, + mtemp-htotal), mtemp-vtotal); + if (mtemp != modes) + swap_modes(mtemp, modes); + } + + /* Sort other modes by refresh rate, aspect ratio, then resolution */ + for (j = 1; j nmodes - 1; j++) { + rbest = 1000; + abest = 1000; + hbest = 0; + vbest = 0; + for (i = j; i nmodes; i++) { + rtemp = abs(refresh - + DIVIDE(DIVIDE(modes[i].dot_clock * 1000, + modes[i].htotal), modes[i].vtotal)); + atemp = (modes[i].hdisplay * 100 / modes[i].vdisplay); + if (rtemp rbest) { +rbest = rtemp; +mtemp = modes[i]; + } + if (rtemp == rbest) { +/* Treat close aspect ratios as identical */ +if (abs(abest - atemp) (abest / 8) +abs(aspect - atemp) +abs(aspect - abest)) { + abest = atemp; + mtemp = modes[i]; +} +if (atemp == abest || +abs(abest - atemp) = (abest / 8)) { + if (modes[i].hdisplay hbest) { + hbest = modes[i].hdisplay; + mtemp = modes[i]; + } + if (modes[i].hdisplay == hbest + modes[i].vdisplay vbest) { + vbest = modes[i].vdisplay; + mtemp = modes[i]; + } +} + } + } + if (mtemp != modes[j]) + swap_modes(mtemp, modes[j]); + } +} Index: src/sys/dev/videomode/videomode.h diff -u src/sys/dev/videomode/videomode.h:1.2 src/sys/dev/videomode/videomode.h:1.3 --- src/sys/dev/videomode/videomode.h:1.2 Tue May 4 21:17:10 2010 +++ src/sys/dev/videomode/videomode.h Sat Apr 9 18:22:31 2011 @@ -1,4 +1,4 @@ -/* $NetBSD: videomode.h,v 1.2 2010/05/04 21:17:10 macallan Exp $ */ +/* $NetBSD: videomode.h,v 1.3 2011/04/09 18:22:31 jdc Exp $ */ /* * Copyright (c) 2001, 2002 Bang Jun-Young @@
CVS commit: src/sys/dev/videomode
Module Name:src Committed By: christos Date: Sat Apr 9 20:53:39 UTC 2011 Modified Files: src/sys/dev/videomode: edid.c pickmode.c Log Message: - little KNF - use struct copy instead of memcpy - snprintf(%s) - strlcpy - fix NUL termination To generate a diff of this commit: cvs rdiff -u -r1.9 -r1.10 src/sys/dev/videomode/edid.c cvs rdiff -u -r1.3 -r1.4 src/sys/dev/videomode/pickmode.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/dev/videomode/edid.c diff -u src/sys/dev/videomode/edid.c:1.9 src/sys/dev/videomode/edid.c:1.10 --- src/sys/dev/videomode/edid.c:1.9 Sat Apr 9 14:18:28 2011 +++ src/sys/dev/videomode/edid.c Sat Apr 9 16:53:39 2011 @@ -1,4 +1,4 @@ -/* $NetBSD: edid.c,v 1.9 2011/04/09 18:18:28 jdc Exp $ */ +/* $NetBSD: edid.c,v 1.10 2011/04/09 20:53:39 christos Exp $ */ /*- * Copyright (c) 2006 Itronix Inc. @@ -32,7 +32,7 @@ */ #include sys/cdefs.h -__KERNEL_RCSID(0, $NetBSD: edid.c,v 1.9 2011/04/09 18:18:28 jdc Exp $); +__KERNEL_RCSID(0, $NetBSD: edid.c,v 1.10 2011/04/09 20:53:39 christos Exp $); #include sys/param.h #include sys/systm.h @@ -91,7 +91,7 @@ for (n = 0; n edid_nvendors; n++) if (memcmp(edid_vendors[n].vendor, vendor, 3) == 0) - return (edid_vendors[n].name); + return edid_vendors[n].name; #endif return NULL; } @@ -103,9 +103,9 @@ int n; for (n = 0; n edid_nproducts; n++) - if ((edid_products[n].product == product) - (memcmp(edid_products[n].vendor, vendor, 3) == 0)) - return (edid_products[n].name); + if (edid_products[n].product == product + memcmp(edid_products[n].vendor, vendor, 3) == 0) + return (edid_products[n].name; #endif /* EDIDVERBOSE */ return NULL; @@ -116,11 +116,11 @@ { for (;;) { switch (*ptr) { - case 0: + case '\0': return; case '\r': case '\n': - *ptr = 0; + *ptr = '\0'; return; } ptr++; @@ -264,8 +264,7 @@ edid-edid_modes[i].hdisplay, edid-edid_modes[i].vdisplay, DIVIDE(DIVIDE(edid-edid_modes[i].dot_clock * 1000, - edid-edid_modes[i].htotal), - edid-edid_modes[i].vtotal)); + edid-edid_modes[i].htotal), edid-edid_modes[i].vtotal)); printf( (%d %d %d %d %d %d %d, edid-edid_modes[i].dot_clock, edid-edid_modes[i].hsync_start, @@ -285,8 +284,8 @@ edid-edid_preferred_mode-hdisplay, edid-edid_preferred_mode-vdisplay, DIVIDE(DIVIDE(edid-edid_preferred_mode-dot_clock * 1000, - edid-edid_preferred_mode-htotal), - edid-edid_preferred_mode-vtotal)); + edid-edid_preferred_mode-htotal), + edid-edid_preferred_mode-vtotal)); } static const struct videomode * @@ -312,9 +311,8 @@ mode-vdisplay == edid-edid_modes[i].vdisplay refresh == DIVIDE(DIVIDE( edid-edid_modes[i].dot_clock * 1000, - edid-edid_modes[i].htotal), - edid-edid_modes[i].vtotal)) { - return (edid-edid_modes[i]); + edid-edid_modes[i].htotal), edid-edid_modes[i].vtotal)) { + return edid-edid_modes[i]; } } return NULL; @@ -351,13 +349,11 @@ f = EDID_STD_TIMING_VFREQ(data); /* first try to lookup the mode as a DMT timing */ - snprintf(name, sizeof (name), %dx%dx%d, x, y, f); + snprintf(name, sizeof(name), %dx%dx%d, x, y, f); if ((lookup = edid_mode_lookup_list(name)) != NULL) { *vmp = *lookup; - } - - /* failing that, calculate it using gtf */ - else { + } else { + /* failing that, calculate it using gtf */ /* * Hmm. I'm not using alternate GTF timings, which * could, in theory, be present. @@ -429,68 +425,53 @@ struct videomode mode, *exist_mode; if (EDID_BLOCK_IS_DET_TIMING(data)) { - if (edid_det_timing(data, mode)) { - /* Does this mode already exist? */ - exist_mode = edid_search_mode(edid, mode); - if (exist_mode != NULL) { -memcpy(exist_mode, mode, -sizeof(struct videomode)); -if (edid-edid_preferred_mode == NULL) { - edid-edid_preferred_mode = - exist_mode; -} - } else { -edid-edid_modes[edid-edid_nmodes] = mode; -if (edid-edid_preferred_mode == NULL) { - edid-edid_preferred_mode = - edid-edid_modes[edid-edid_nmodes]; -} -edid-edid_nmodes++; - } + if (!edid_det_timing(data, mode)) { + return; + /* Does this mode already exist? */ + exist_mode = edid_search_mode(edid, mode); + if (exist_mode != NULL) { + *exist_mode = mode; + if (edid-edid_preferred_mode == NULL) +edid-edid_preferred_mode = exist_mode; + } else { + edid-edid_modes[edid-edid_nmodes] = mode; + if (edid-edid_preferred_mode == NULL) +edid-edid_preferred_mode = +edid-edid_modes[edid-edid_nmodes]; + edid-edid_nmodes++; } return; } switch (EDID_BLOCK_TYPE(data)) { case EDID_DESC_BLOCK_TYPE_SERIAL: - memcpy(edid-edid_serial, - data + EDID_DESC_ASCII_DATA_OFFSET, + memcpy(edid-edid_serial, data + EDID_DESC_ASCII_DATA_OFFSET,
CVS commit: src/sys/dev/videomode
Module Name:src Committed By: christos Date: Sat Apr 9 22:09:06 UTC 2011 Modified Files: src/sys/dev/videomode: edid.c Log Message: make this compile again. To generate a diff of this commit: cvs rdiff -u -r1.10 -r1.11 src/sys/dev/videomode/edid.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/dev/videomode/edid.c diff -u src/sys/dev/videomode/edid.c:1.10 src/sys/dev/videomode/edid.c:1.11 --- src/sys/dev/videomode/edid.c:1.10 Sat Apr 9 16:53:39 2011 +++ src/sys/dev/videomode/edid.c Sat Apr 9 18:09:05 2011 @@ -1,4 +1,4 @@ -/* $NetBSD: edid.c,v 1.10 2011/04/09 20:53:39 christos Exp $ */ +/* $NetBSD: edid.c,v 1.11 2011/04/09 22:09:05 christos Exp $ */ /*- * Copyright (c) 2006 Itronix Inc. @@ -32,7 +32,7 @@ */ #include sys/cdefs.h -__KERNEL_RCSID(0, $NetBSD: edid.c,v 1.10 2011/04/09 20:53:39 christos Exp $); +__KERNEL_RCSID(0, $NetBSD: edid.c,v 1.11 2011/04/09 22:09:05 christos Exp $); #include sys/param.h #include sys/systm.h @@ -105,7 +105,7 @@ for (n = 0; n edid_nproducts; n++) if (edid_products[n].product == product memcmp(edid_products[n].vendor, vendor, 3) == 0) - return (edid_products[n].name; + return edid_products[n].name; #endif /* EDIDVERBOSE */ return NULL; @@ -425,7 +425,7 @@ struct videomode mode, *exist_mode; if (EDID_BLOCK_IS_DET_TIMING(data)) { - if (!edid_det_timing(data, mode)) { + if (!edid_det_timing(data, mode)) return; /* Does this mode already exist? */ exist_mode = edid_search_mode(edid, mode);
CVS commit: src/sys/dev/videomode
Module Name:src Committed By: jdc Date: Wed Mar 30 18:45:05 UTC 2011 Modified Files: src/sys/dev/videomode: modelines Log Message: Update modes based on our current xsrc. Minor changes to 640x480 @ 60Hz, 640x480 @ 72Hz, 800x600 @ 85Hz, and 1024x768 @ 75Hz. To generate a diff of this commit: cvs rdiff -u -r1.8 -r1.9 src/sys/dev/videomode/modelines Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/dev/videomode/modelines diff -u src/sys/dev/videomode/modelines:1.8 src/sys/dev/videomode/modelines:1.9 --- src/sys/dev/videomode/modelines:1.8 Mon Mar 21 19:28:37 2011 +++ src/sys/dev/videomode/modelines Wed Mar 30 18:45:04 2011 @@ -1,4 +1,4 @@ -// $NetBSD: modelines,v 1.8 2011/03/21 19:28:37 jdc Exp $ +// $NetBSD: modelines,v 1.9 2011/03/30 18:45:04 jdc Exp $ // // This file was imported from XFree86, and is made of the contents of both // the vesamodes and extramodes files. As a result these should correspond @@ -31,10 +31,10 @@ ModeLine 720x40035.5 720 738 846 900400 421 423 449 -hsync -vsync # 640x480 @ 60Hz (Industry standard) hsync: 31.5kHz -ModeLine 640x48025.2 640 656 752 800480 490 492 525 -hsync -vsync +ModeLine 640x48025.175 640 656 752 800480 490 492 525 -hsync -vsync # 640x480 @ 72Hz (VESA) hsync: 37.9kHz -ModeLine 640x48031.5 640 664 704 832480 489 491 520 -hsync -vsync +ModeLine 640x48031.5 640 664 704 832480 489 492 520 -hsync -vsync # 640x480 @ 75Hz (VESA) hsync: 37.5kHz ModeLine 640x48031.5 640 656 720 840480 481 484 500 -hsync -vsync @@ -55,7 +55,7 @@ ModeLine 800x60049.5 800 816 896 1056600 601 604 625 +hsync +vsync # 800x600 @ 85Hz (VESA) hsync: 53.7kHz -ModeLine 800x60056.3 800 832 896 1048600 601 604 631 +hsync +vsync +ModeLine 800x60056.25 800 832 896 1048600 601 604 631 +hsync +vsync # 1024x768i @ 43Hz (industry standard) hsync: 35.5kHz ModeLine 1024x768 44.9 1024 1032 1208 1264768 768 776 817 +hsync +vsync Interlace @@ -67,7 +67,7 @@ ModeLine 1024x768 75.0 1024 1048 1184 1328768 771 777 806 -hsync -vsync # 1024x768 @ 75Hz (VESA) hsync: 60.0kHz -ModeLine 1024x768 78.8 1024 1040 1136 1312768 769 772 800 +hsync +vsync +ModeLine 1024x768 78.75 1024 1040 1136 1312768 769 772 800 +hsync +vsync # 1024x768 @ 85Hz (VESA) hsync: 68.7kHz ModeLine 1024x768 94.5 1024 1072 1168 1376768 769 772 808 +hsync +vsync
CVS commit: src/sys/dev/videomode
Module Name:src Committed By: jdc Date: Wed Mar 30 18:46:33 UTC 2011 Modified Files: src/sys/dev/videomode: videomode.c Log Message: Regenerate for: Update modes based on our current xsrc. Minor changes to 640x480 @ 60Hz, 640x480 @ 72Hz, 800x600 @ 85Hz, and 1024x768 @ 75Hz. To generate a diff of this commit: cvs rdiff -u -r1.10 -r1.11 src/sys/dev/videomode/videomode.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/dev/videomode/videomode.c diff -u src/sys/dev/videomode/videomode.c:1.10 src/sys/dev/videomode/videomode.c:1.11 --- src/sys/dev/videomode/videomode.c:1.10 Mon Mar 21 19:29:54 2011 +++ src/sys/dev/videomode/videomode.c Wed Mar 30 18:46:32 2011 @@ -1,14 +1,14 @@ -/* $NetBSD: videomode.c,v 1.10 2011/03/21 19:29:54 jdc Exp $ */ +/* $NetBSD: videomode.c,v 1.11 2011/03/30 18:46:32 jdc Exp $ */ /* * THIS FILE AUTOMATICALLY GENERATED. DO NOT EDIT. * * generated from: - * NetBSD: modelines,v 1.8 2011/03/21 19:28:37 jdc Exp + * NetBSD: modelines,v 1.9 2011/03/30 18:45:04 jdc Exp */ #include sys/cdefs.h -__KERNEL_RCSID(0, $NetBSD: videomode.c,v 1.10 2011/03/21 19:29:54 jdc Exp $); +__KERNEL_RCSID(0, $NetBSD: videomode.c,v 1.11 2011/03/30 18:46:32 jdc Exp $); #include dev/videomode/videomode.h @@ -31,19 +31,19 @@ M(720x400x70,720,400,28320,738,846,900,412,414,449,HN|VP), M(720x400x85,720,400,35500,756,828,936,401,404,446,HN|VP), M(720x400x87,720,400,35500,738,846,900,421,423,449,HN|VN), -M(640x480x60,640,480,25200,656,752,800,490,492,525,HN|VN), -M(640x480x72,640,480,31500,664,704,832,489,491,520,HN|VN), +M(640x480x60,640,480,25175,656,752,800,490,492,525,HN|VN), +M(640x480x72,640,480,31500,664,704,832,489,492,520,HN|VN), M(640x480x75,640,480,31500,656,720,840,481,484,500,HN|VN), M(640x480x85,640,480,36000,696,752,832,481,484,509,HN|VN), M(800x600x56,800,600,36000,824,896,1024,601,603,625,HP|VP), M(800x600x60,800,600,4,840,968,1056,601,605,628,HP|VP), M(800x600x72,800,600,5,856,976,1040,637,643,666,HP|VP), M(800x600x75,800,600,49500,816,896,1056,601,604,625,HP|VP), -M(800x600x85,800,600,56300,832,896,1048,601,604,631,HP|VP), +M(800x600x85,800,600,56250,832,896,1048,601,604,631,HP|VP), M(1024x768x87i,1024,768,44900,1032,1208,1264,768,776,817,HP|VP|I), M(1024x768x60,1024,768,65000,1048,1184,1344,771,777,806,HN|VN), M(1024x768x70,1024,768,75000,1048,1184,1328,771,777,806,HN|VN), -M(1024x768x75,1024,768,78800,1040,1136,1312,769,772,800,HP|VP), +M(1024x768x75,1024,768,78750,1040,1136,1312,769,772,800,HP|VP), M(1024x768x85,1024,768,94500,1072,1168,1376,769,772,808,HP|VP), M(1024x768x89,1024,768,10,1108,1280,1408,768,780,796,HP|VP), M(1152x864x75,1152,864,108000,1216,1344,1600,865,868,900,HP|VP), @@ -80,19 +80,19 @@ M(360x200x70,360,200,14160,369,423,450,206,207,224,HN|VP|DS), M(360x200x85,360,200,17750,378,414,468,200,202,223,HN|VP|DS), M(360x200x87,360,200,17750,369,423,450,210,211,224,HN|VN|DS), -M(320x240x60,320,240,12600,328,376,400,245,246,262,HN|VN|DS), -M(320x240x72,320,240,15750,332,352,416,244,245,260,HN|VN|DS), +M(320x240x60,320,240,12587,328,376,400,245,246,262,HN|VN|DS), +M(320x240x72,320,240,15750,332,352,416,244,246,260,HN|VN|DS), M(320x240x75,320,240,15750,328,360,420,240,242,250,HN|VN|DS), M(320x240x85,320,240,18000,348,376,416,240,242,254,HN|VN|DS), M(400x300x56,400,300,18000,412,448,512,300,301,312,HP|VP|DS), M(400x300x60,400,300,2,420,484,528,300,302,314,HP|VP|DS), M(400x300x72,400,300,25000,428,488,520,318,321,333,HP|VP|DS), M(400x300x75,400,300,24750,408,448,528,300,302,312,HP|VP|DS), -M(400x300x85,400,300,28150,416,448,524,300,302,315,HP|VP|DS), +M(400x300x85,400,300,28125,416,448,524,300,302,315,HP|VP|DS), M(512x384x87i,512,384,22450,516,604,632,384,388,408,HP|VP|DS|I), M(512x384x60,512,384,32500,524,592,672,385,388,403,HN|VN|DS), M(512x384x70,512,384,37500,524,592,664,385,388,403,HN|VN|DS), -M(512x384x75,512,384,39400,520,568,656,384,386,400,HP|VP|DS), +M(512x384x75,512,384,39375,520,568,656,384,386,400,HP|VP|DS), M(512x384x85,512,384,47250,536,584,688,384,386,404,HP|VP|DS), M(512x384x89,512,384,5,554,640,704,384,390,398,HP|VP|DS), M(576x432x75,576,432,54000,608,672,800,432,434,450,HP|VP|DS),
CVS commit: src/sys/dev/videomode
Module Name:src Committed By: jdc Date: Wed Mar 30 18:49:57 UTC 2011 Modified Files: src/sys/dev/videomode: edidreg.h Log Message: Adjustments to detailed timing flags: give the stereo modes slightly better names correct the hsync positive and vsync positive bits (these were reversed) To generate a diff of this commit: cvs rdiff -u -r1.2 -r1.3 src/sys/dev/videomode/edidreg.h Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/dev/videomode/edidreg.h diff -u src/sys/dev/videomode/edidreg.h:1.2 src/sys/dev/videomode/edidreg.h:1.3 --- src/sys/dev/videomode/edidreg.h:1.2 Sat May 13 00:39:19 2006 +++ src/sys/dev/videomode/edidreg.h Wed Mar 30 18:49:56 2011 @@ -1,4 +1,4 @@ -/* $NetBSD: edidreg.h,v 1.2 2006/05/13 00:39:19 gdamore Exp $ */ +/* $NetBSD: edidreg.h,v 1.3 2011/03/30 18:49:56 jdc Exp $ */ /*- * Copyright (c) 2006 Itronix Inc. @@ -203,11 +203,11 @@ #define EDID_DET_TIMING_VBORDER(ptr) ((ptr)[16]) #define EDID_DET_TIMING_FLAGS(ptr) ((ptr)[17]) #define EDID_DET_TIMING_FLAG_INTERLACE 0x80 -#define EDID_DET_TIMING_FLAG_STEREO 0x60 /* wtf? */ +#define EDID_DET_TIMING_FLAG_STEREO 0x60 /* stereo or not */ #define EDID_DET_TIMING_FLAG_SYNC_SEPARATE 0x18 -#define EDID_DET_TIMING_FLAG_HSYNC_POSITIVE 0x04 -#define EDID_DET_TIMING_FLAG_VSYNC_POSITIVE 0x02 -#define EDID_DET_TIMING_FLAG_STEREO1 0x01 /* wtf? */ +#define EDID_DET_TIMING_FLAG_VSYNC_POSITIVE 0x04 +#define EDID_DET_TIMING_FLAG_HSYNC_POSITIVE 0x02 +#define EDID_DET_TIMING_FLAG_STEREO_MODE 0x01 /* stereo mode */ /* N.B.: these tests assume that we already checked for detailed timing! */
CVS commit: src/sys/dev/videomode
Module Name:src Committed By: jdc Date: Wed Mar 30 18:50:37 UTC 2011 Modified Files: src/sys/dev/videomode: edid.c Log Message: Display detailed timing parameters in edid_print(). To generate a diff of this commit: cvs rdiff -u -r1.7 -r1.8 src/sys/dev/videomode/edid.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/dev/videomode/edid.c diff -u src/sys/dev/videomode/edid.c:1.7 src/sys/dev/videomode/edid.c:1.8 --- src/sys/dev/videomode/edid.c:1.7 Mon Mar 21 19:34:27 2011 +++ src/sys/dev/videomode/edid.c Wed Mar 30 18:50:37 2011 @@ -1,4 +1,4 @@ -/* $NetBSD: edid.c,v 1.7 2011/03/21 19:34:27 jdc Exp $ */ +/* $NetBSD: edid.c,v 1.8 2011/03/30 18:50:37 jdc Exp $ */ /*- * Copyright (c) 2006 Itronix Inc. @@ -32,7 +32,7 @@ */ #include sys/cdefs.h -__KERNEL_RCSID(0, $NetBSD: edid.c,v 1.7 2011/03/21 19:34:27 jdc Exp $); +__KERNEL_RCSID(0, $NetBSD: edid.c,v 1.8 2011/03/30 18:50:37 jdc Exp $); #include sys/param.h #include sys/systm.h @@ -260,12 +260,25 @@ } printf(Video modes:\n); for (i = 0; i edid-edid_nmodes; i++) { - printf(\t%dx%d @ %dHz\n, + printf(\t%dx%d @ %dHz, edid-edid_modes[i].hdisplay, edid-edid_modes[i].vdisplay, DIVIDE(DIVIDE(edid-edid_modes[i].dot_clock * 1000, edid-edid_modes[i].htotal), edid-edid_modes[i].vtotal)); + printf( (%d %d %d %d %d %d %d, + edid-edid_modes[i].dot_clock, + edid-edid_modes[i].hsync_start, + edid-edid_modes[i].hsync_end, + edid-edid_modes[i].htotal, + edid-edid_modes[i].vsync_start, + edid-edid_modes[i].vsync_end, + edid-edid_modes[i].vtotal); + printf( %s%sH %s%sV)\n, + edid-edid_modes[i].flags VID_PHSYNC ? + : , + edid-edid_modes[i].flags VID_NHSYNC ? - : , + edid-edid_modes[i].flags VID_PVSYNC ? + : , + edid-edid_modes[i].flags VID_NVSYNC ? - : ); } if (edid-edid_preferred_mode) printf(Preferred mode: %dx%d @ %dHz\n, @@ -345,7 +358,7 @@ /* we don't support stereo modes (for now) */ if (flags (EDID_DET_TIMING_FLAG_STEREO | - EDID_DET_TIMING_FLAG_STEREO1)) + EDID_DET_TIMING_FLAG_STEREO_MODE)) return 0; vmp-dot_clock = EDID_DET_TIMING_DOT_CLOCK(data) / 1000;
CVS commit: src/sys/dev/videomode
Module Name:src Committed By: jdc Date: Mon Mar 21 19:28:37 UTC 2011 Modified Files: src/sys/dev/videomode: modelines Log Message: Add EDID established timing modelines for 720x400x70 and 720x400x88 To generate a diff of this commit: cvs rdiff -u -r1.7 -r1.8 src/sys/dev/videomode/modelines Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/dev/videomode/modelines diff -u src/sys/dev/videomode/modelines:1.7 src/sys/dev/videomode/modelines:1.8 --- src/sys/dev/videomode/modelines:1.7 Wed Jan 21 14:40:25 2009 +++ src/sys/dev/videomode/modelines Mon Mar 21 19:28:37 2011 @@ -1,4 +1,4 @@ -// $NetBSD: modelines,v 1.7 2009/01/21 14:40:25 jnemeth Exp $ +// $NetBSD: modelines,v 1.8 2011/03/21 19:28:37 jdc Exp $ // // This file was imported from XFree86, and is made of the contents of both // the vesamodes and extramodes files. As a result these should correspond @@ -21,9 +21,15 @@ # 640x400 @ 85Hz (VESA) hsync: 37.9kHz ModeLine 640x40031.5 640 672 736 832400 401 404 445 -hsync +vsync +# 720x400 @ 70Hz (EDID established timing) hsync: 31.47kHz +ModeLine 720x40028.32 720 738 846 900400 412 414 449 -hsync +vsync + # 720x400 @ 85Hz (VESA) hsync: 37.9kHz ModeLine 720x40035.5 720 756 828 936400 401 404 446 -hsync +vsync +# 720x400 @ 88Hz (EDID established timing) hsync: 39.44kHz +ModeLine 720x40035.5 720 738 846 900400 421 423 449 -hsync -vsync + # 640x480 @ 60Hz (Industry standard) hsync: 31.5kHz ModeLine 640x48025.2 640 656 752 800480 490 492 525 -hsync -vsync
CVS commit: src/sys/dev/videomode
Module Name:src Committed By: jdc Date: Mon Mar 21 19:29:54 UTC 2011 Modified Files: src/sys/dev/videomode: videomode.c Log Message: Regenerate for: Add EDID established timing modelines for 720x400x70 and 720x400x88 To generate a diff of this commit: cvs rdiff -u -r1.9 -r1.10 src/sys/dev/videomode/videomode.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/dev/videomode/videomode.c diff -u src/sys/dev/videomode/videomode.c:1.9 src/sys/dev/videomode/videomode.c:1.10 --- src/sys/dev/videomode/videomode.c:1.9 Tue Oct 21 06:04:37 2008 +++ src/sys/dev/videomode/videomode.c Mon Mar 21 19:29:54 2011 @@ -1,14 +1,14 @@ -/* $NetBSD: videomode.c,v 1.9 2008/10/21 06:04:37 macallan Exp $ */ +/* $NetBSD: videomode.c,v 1.10 2011/03/21 19:29:54 jdc Exp $ */ /* * THIS FILE AUTOMATICALLY GENERATED. DO NOT EDIT. * * generated from: - * NetBSD: modelines,v 1.5 2007/04/03 03:33:41 macallan Exp + * NetBSD: modelines,v 1.8 2011/03/21 19:28:37 jdc Exp */ #include sys/cdefs.h -__KERNEL_RCSID(0, $NetBSD: videomode.c,v 1.9 2008/10/21 06:04:37 macallan Exp $); +__KERNEL_RCSID(0, $NetBSD: videomode.c,v 1.10 2011/03/21 19:29:54 jdc Exp $); #include dev/videomode/videomode.h @@ -28,7 +28,9 @@ const struct videomode videomode_list[] = { M(640x350x85,640,350,31500,672,736,832,382,385,445,HP|VN), M(640x400x85,640,400,31500,672,736,832,401,404,445,HN|VP), +M(720x400x70,720,400,28320,738,846,900,412,414,449,HN|VP), M(720x400x85,720,400,35500,756,828,936,401,404,446,HN|VP), +M(720x400x87,720,400,35500,738,846,900,421,423,449,HN|VN), M(640x480x60,640,480,25200,656,752,800,490,492,525,HN|VN), M(640x480x72,640,480,31500,664,704,832,489,491,520,HN|VN), M(640x480x75,640,480,31500,656,720,840,481,484,500,HN|VN), @@ -75,7 +77,9 @@ M(320x175x85,320,175,15750,336,368,416,191,192,222,HP|VN|DS), M(320x200x85,320,200,15750,336,368,416,200,202,222,HN|VP|DS), +M(360x200x70,360,200,14160,369,423,450,206,207,224,HN|VP|DS), M(360x200x85,360,200,17750,378,414,468,200,202,223,HN|VP|DS), +M(360x200x87,360,200,17750,369,423,450,210,211,224,HN|VN|DS), M(320x240x60,320,240,12600,328,376,400,245,246,262,HN|VN|DS), M(320x240x72,320,240,15750,332,352,416,244,245,260,HN|VN|DS), M(320x240x75,320,240,15750,328,360,420,240,242,250,HN|VN|DS), @@ -119,4 +123,4 @@ M(576x450x76,576,450,52780,584,640,736,451,453,471,HN|VN|DS), }; -const int videomode_count = 44; +const int videomode_count = 46;
CVS commit: src/sys/dev/videomode
Module Name:src Committed By: jdc Date: Mon Mar 21 19:32:27 UTC 2011 Modified Files: src/sys/dev/videomode: modelines2c.awk Log Message: Clarify vrefresh comment (no functional change) To generate a diff of this commit: cvs rdiff -u -r1.4 -r1.5 src/sys/dev/videomode/modelines2c.awk Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/dev/videomode/modelines2c.awk diff -u src/sys/dev/videomode/modelines2c.awk:1.4 src/sys/dev/videomode/modelines2c.awk:1.5 --- src/sys/dev/videomode/modelines2c.awk:1.4 Thu Oct 26 23:19:50 2006 +++ src/sys/dev/videomode/modelines2c.awk Mon Mar 21 19:32:26 2011 @@ -1,5 +1,5 @@ #! /usr/bin/awk -f -# $NetBSD: modelines2c.awk,v 1.4 2006/10/26 23:19:50 bjh21 Exp $ +# $NetBSD: modelines2c.awk,v 1.5 2011/03/21 19:32:26 jdc Exp $ # # Copyright (c) 2006 Itronix Inc. # All rights reserved. @@ -104,8 +104,9 @@ ifactor = 2.0; } - # why the additional .1 to vrefresh? well it seems that awk likes to - # make some rounding errors, and this will compensate + # We truncate the vrefresh figure, but some mode descriptions rely + # on rounding, so we can't win here. Adding an additional .1 + # compensates to some extent. hrefresh= (dotclock * 100) / htotal; vrefresh= int(((hrefresh * ifactor) / vtotal) + .1);
CVS commit: src/sys/dev/videomode
Module Name:src Committed By: jdc Date: Mon Mar 21 19:34:27 UTC 2011 Modified Files: src/sys/dev/videomode: edid.c Log Message: Correct 832x624x74. Update comments. Reverse iteratiion, so that modes are in established timing order. To generate a diff of this commit: cvs rdiff -u -r1.6 -r1.7 src/sys/dev/videomode/edid.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/dev/videomode/edid.c diff -u src/sys/dev/videomode/edid.c:1.6 src/sys/dev/videomode/edid.c:1.7 --- src/sys/dev/videomode/edid.c:1.6 Sat Nov 14 09:19:41 2009 +++ src/sys/dev/videomode/edid.c Mon Mar 21 19:34:27 2011 @@ -1,4 +1,4 @@ -/* $NetBSD: edid.c,v 1.6 2009/11/14 09:19:41 tsutsui Exp $ */ +/* $NetBSD: edid.c,v 1.7 2011/03/21 19:34:27 jdc Exp $ */ /*- * Copyright (c) 2006 Itronix Inc. @@ -32,7 +32,7 @@ */ #include sys/cdefs.h -__KERNEL_RCSID(0, $NetBSD: edid.c,v 1.6 2009/11/14 09:19:41 tsutsui Exp $); +__KERNEL_RCSID(0, $NetBSD: edid.c,v 1.7 2011/03/21 19:34:27 jdc Exp $); #include sys/param.h #include sys/systm.h @@ -48,13 +48,14 @@ #define EDIDVERBOSE 1 #define DIVIDE(x,y) (((x) + ((y) / 2)) / (y)) +/* These are reversed established timing order */ static const char *_edid_modes[] = { 1280x1024x75, 1024x768x75, 1024x768x70, 1024x768x60, 1024x768x87i, - 832x768x74, /* rounding error, 74.55 Hz aka 832x624x75 */ + 832x624x74, /* rounding error, 74.55 Hz aka 832x624x75 */ 800x600x75, 800x600x72, 800x600x60, @@ -63,8 +64,8 @@ 640x480x72, 640x480x67, 640x480x60, - 720x400x85, /* should this really be 720x400x88 ? */ - 720x400x70, /* hmm... videmode.c doesn't have this one */ + 720x400x87, /* rounding error, 87.85 Hz aka 720x400x88 */ + 720x400x70, }; #ifdef EDIDVERBOSE @@ -542,7 +543,8 @@ edid-edid_nmodes = 0; edid-edid_preferred_mode = NULL; estmodes = EDID_EST_TIMING(data); - for (i = 0; i 16; i++) { + /* Iterate in esztablished timing order */ + for (i = 15; i = 0; i--) { if (estmodes (1 i)) { vmp = edid_mode_lookup_list(_edid_modes[i]); if (vmp != NULL) {
CVS commit: src/sys/dev/videomode
Module Name:src Committed By: macallan Date: Tue Oct 12 16:18:20 UTC 2010 Modified Files: src/sys/dev/videomode: pickmode.c Log Message: fix off-by-one error which happened when the first mode with matching size is also the best match by refresh rate To generate a diff of this commit: cvs rdiff -u -r1.1 -r1.2 src/sys/dev/videomode/pickmode.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/dev/videomode/pickmode.c diff -u src/sys/dev/videomode/pickmode.c:1.1 src/sys/dev/videomode/pickmode.c:1.2 --- src/sys/dev/videomode/pickmode.c:1.1 Tue May 4 21:17:10 2010 +++ src/sys/dev/videomode/pickmode.c Tue Oct 12 16:18:19 2010 @@ -1,4 +1,4 @@ -/* $NetBSD: pickmode.c,v 1.1 2010/05/04 21:17:10 macallan Exp $ */ +/* $NetBSD: pickmode.c,v 1.2 2010/10/12 16:18:19 macallan Exp $ */ /*- * Copyright (c) 2006 The NetBSD Foundation @@ -29,7 +29,7 @@ */ #include sys/cdefs.h -__KERNEL_RCSID(0, $NetBSD: pickmode.c,v 1.1 2010/05/04 21:17:10 macallan Exp $); +__KERNEL_RCSID(0, $NetBSD: pickmode.c,v 1.2 2010/10/12 16:18:19 macallan Exp $); #include sys/param.h #include dev/videomode/videomode.h @@ -81,9 +81,9 @@ this = videomode_list[i]; mref = this-dot_clock * 1000 / (this-htotal * this-vtotal); diff = abs(mref - refresh); - if ((this-hdisplay != width) || (this-vdisplay != height) || - (diff closest)) + if ((this-hdisplay != width) || (this-vdisplay != height)) continue; + DPRINTF(%s in %d hz, diff %d\n, this-name, mref, diff); if (best != NULL) { if (diff closest) { @@ -91,11 +91,13 @@ best = this; closest = diff; } - } else + } else { best = this; + closest = diff; + } } if (best!= NULL) - DPRINTF(found %s\n, best-name); + DPRINTF(found %s %d\n, best-name, best-dot_clock); return best; }
CVS commit: src/sys/dev/videomode
Module Name:src Committed By: macallan Date: Tue May 4 21:17:10 UTC 2010 Modified Files: src/sys/dev/videomode: files.videomode videomode.h Added Files: src/sys/dev/videomode: pickmode.c Log Message: add a bunch of small utility functions to pick video modes based on things like dot clock, resolution etc. To generate a diff of this commit: cvs rdiff -u -r1.3 -r1.4 src/sys/dev/videomode/files.videomode cvs rdiff -u -r0 -r1.1 src/sys/dev/videomode/pickmode.c cvs rdiff -u -r1.1 -r1.2 src/sys/dev/videomode/videomode.h Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/dev/videomode/files.videomode diff -u src/sys/dev/videomode/files.videomode:1.3 src/sys/dev/videomode/files.videomode:1.4 --- src/sys/dev/videomode/files.videomode:1.3 Thu May 11 01:49:53 2006 +++ src/sys/dev/videomode/files.videomode Tue May 4 21:17:10 2010 @@ -1,4 +1,4 @@ -# $NetBSD: files.videomode,v 1.3 2006/05/11 01:49:53 gdamore Exp $ +# $NetBSD: files.videomode,v 1.4 2010/05/04 21:17:10 macallan Exp $ define videomode define edid @@ -7,5 +7,7 @@ file dev/videomode/videomode.c videomode | edid file dev/videomode/edid.c edid +file dev/videomode/pickmode.c videomode +defflag opt_videomode.h PICKMODE_DEBUG file dev/videomode/vesagtf.c vesagtf | edid Index: src/sys/dev/videomode/videomode.h diff -u src/sys/dev/videomode/videomode.h:1.1 src/sys/dev/videomode/videomode.h:1.2 --- src/sys/dev/videomode/videomode.h:1.1 Sat Mar 4 02:34:27 2006 +++ src/sys/dev/videomode/videomode.h Tue May 4 21:17:10 2010 @@ -1,4 +1,4 @@ -/* $NetBSD: videomode.h,v 1.1 2006/03/04 02:34:27 gdamore Exp $ */ +/* $NetBSD: videomode.h,v 1.2 2010/05/04 21:17:10 macallan Exp $ */ /* * Copyright (c) 2001, 2002 Bang Jun-Young @@ -66,4 +66,7 @@ extern const struct videomode videomode_list[]; extern const int videomode_count; +const struct videomode *pick_mode_by_dotclock(int, int, int); +const struct videomode *pick_mode_by_ref(int, int, int); + #endif /* _DEV_VIDEOMODE_H */ Added files: Index: src/sys/dev/videomode/pickmode.c diff -u /dev/null src/sys/dev/videomode/pickmode.c:1.1 --- /dev/null Tue May 4 21:17:10 2010 +++ src/sys/dev/videomode/pickmode.c Tue May 4 21:17:10 2010 @@ -0,0 +1,101 @@ +/* $NetBSD: pickmode.c,v 1.1 2010/05/04 21:17:10 macallan Exp $ */ + +/*- + * Copyright (c) 2006 The NetBSD Foundation + * All rights reserved. + * + * this code was contributed to The NetBSD Foundation by Michael Lorenz + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + *notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + *notice, this list of conditions and the following disclaimer in the + *documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS + * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE NETBSD FOUNDATION BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE + * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, + * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#include sys/cdefs.h +__KERNEL_RCSID(0, $NetBSD: pickmode.c,v 1.1 2010/05/04 21:17:10 macallan Exp $); + +#include sys/param.h +#include dev/videomode/videomode.h +#include opt_videomode.h + +#ifdef PICKMODE_DEBUG +#define DPRINTF printf +#else +#define DPRINTF while (0) printf +#endif + +const struct videomode * +pick_mode_by_dotclock(int width, int height, int dotclock) +{ + const struct videomode *this, *best = NULL; + int i; + + DPRINTF(%s: looking for %d x %d at up to %d kHz\n, __func__, width, + height, dotclock); + for (i = 0; i videomode_count; i++) { + + this = videomode_list[i]; + if ((this-hdisplay != width) || (this-vdisplay != height) || + (this-dot_clock dotclock)) + continue; + if (best != NULL) { + + if (this-dot_clock best-dot_clock) +best = this; + } else + best = this; + } + if (best!= NULL) + DPRINTF(found %s\n, best-name); + + return best; +} + +const struct videomode * +pick_mode_by_ref(int width, int height, int refresh) +{ + const struct videomode *this, *best = NULL; + int mref, closest = 1000, i, diff; + + DPRINTF(%s: looking for %d x %d at up to %d Hz\n, __func__, width, + height, refresh); + for