root/morphix/trunk/ddcxinfo/ddcxinfo.c

Revision 2, 2.1 kB (checked in by nextime, 2 years ago)

Initial import, branching from morphix svn

Line 
1 #include <stdio.h>
2 #include <stdlib.h>
3 #include <string.h>
4 #include "vbe.h"
5 #ident "$Id: ddcxinfo.c 1815 2005-04-25 08:27:54Z alextreme $"
6
7 int main(int argc, char **argv)
8 {
9         int i, j;
10         unsigned char hmin = -1, hmax = -1, vmin = -1, vmax = -1;
11         if(argc < 2) {
12                 char *p = argv[0];
13                 if(strchr(p, '/')) {
14                         p = strchr(p, '/');
15                         p++;
16                 }
17                 fprintf(stderr,"syntax: %s [-hsync] [-vsync] [-modelines]\n",p);
18                 exit(1);
19         }
20         for(i = 1; i < argc; i++) {
21                 if((strcmp(argv[i], "-hsync") == 0) ||
22                    (strcmp(argv[i], "-vsync") == 0)) {
23                         vbe_get_edid_ranges(&hmin, &hmax, &vmin, &vmax);
24                         if(!hmin && !hmax && !vmin && !vmax) {
25                                 struct vbe_modeline* modelines;
26                                 modelines = vbe_get_edid_modelines();
27                                 for(j = 0;
28                                     modelines && (modelines[j].refresh != 0);
29                                    j++) {
30                                         if(hmin == 0) hmin = modelines[j].hfreq;
31                                         /* guess */
32                                         if(modelines[j].hfreq)
33                                         hmin = (hmin < modelines[j].hfreq) ?
34                                                 hmin : modelines[j].hfreq;
35                                         if(modelines[j].hfreq)
36                                         hmax = (hmax > modelines[j].hfreq) ?
37                                                 hmax : modelines[j].hfreq;
38                                         if(vmin == 0) vmin = modelines[j].vfreq;
39                                         if(modelines[j].vfreq)
40                                         vmin = (vmin < modelines[j].vfreq) ?
41                                                 vmin : modelines[j].vfreq;
42                                         if(modelines[j].vfreq)
43                                         vmax = (vmax > modelines[j].vfreq) ?
44                                                 vmax : modelines[j].vfreq;
45                                 }
46                         }
47                 }
48                 if(strcmp(argv[i], "-hsync") == 0) {
49                         printf("%d-%d\n", hmin, hmax);
50                 }
51                 if(strcmp(argv[i], "-vsync") == 0) {
52                         printf("%d-%d\n", vmin, vmax);
53                 }
54                 if(strcmp(argv[i], "-modelines") == 0) {
55                         struct vbe_modeline* modelines;
56                         modelines = vbe_get_edid_modelines();
57                         for(j=0; modelines && (modelines[j].refresh != 0); j++){
58                                 if(modelines[j].modeline) {
59                                         printf("# %dx%d, %1.1f%sHz; hfreq=%f, vfreq=%f\n%s\n",
60                                                modelines[j].width,
61                                                modelines[j].height,
62                                                modelines[j].refresh,
63                                                modelines[j].interlaced?"i":"",
64                                                modelines[j].hfreq,
65                                                modelines[j].vfreq,
66                                                modelines[j].modeline);
67                                 }
68                         }
69                         if(modelines) {
70                                 free(modelines);
71                         } else {
72                                 return 1;
73                         }
74                 }
75         }
76         return 0;
77 }
Note: See TracBrowser for help on using the browser.