summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorYi Sun <yi.sun@intel.com>2011-08-01 13:35:39 +0800
committerYi Sun <yi.sun@intel.com>2011-08-01 13:35:39 +0800
commit4c49fa1eb8c6853a2230006ed4006a63204b086d (patch)
treee9dc6b5585d51349befdbad66f47629b9a465ef7
parent8440123cf71beb4f1bc6fbf46316fb188615851f (diff)
Refine it.
-rwxr-xr-xtestedid.c621
1 files changed, 302 insertions, 319 deletions
diff --git a/testedid.c b/testedid.c
index 92d6b99..4258bc0 100755
--- a/testedid.c
+++ b/testedid.c
@@ -1,3 +1,33 @@
+/*
+ * Copyright 2010 Intel Corporation
+ * Jesse Barnes <jesse.barnes@intel.com>
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+ * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
+ * IN THE SOFTWARE.
+ */
+
+/*
+ * This program is intended for testing EDID. It is used to parse the EDID.
+ * Now, it is mainly parse all the information in the block 0 of the EDID.
+ *
+ * TODO:
+ */
+
#include <stdio.h>
#include <stddef.h> /*dir */
#include <sys/types.h>
@@ -14,8 +44,8 @@
#define MAXCARD 10
#define MAXFILENAME 256
#define MAXEDID 256
-struct mode_line
-{
+
+struct mode_line {
char mode[12];
int freq;
};
@@ -27,12 +57,9 @@ int get_card_list(struct dirent *cardlist[])
int card_count=0;
drm_dir_ptr = opendir(EDIDPATH);
- if(drm_dir_ptr != NULL)
- {
- while(dirent_ptr = readdir(drm_dir_ptr))
- {
- if( strstr(dirent_ptr->d_name,"card0-")>0 )
- {
+ if(drm_dir_ptr != NULL) {
+ while(dirent_ptr = readdir(drm_dir_ptr)) {
+ if( strstr(dirent_ptr->d_name,"card0-")>0 ){
memcpy(cardlist[card_count],dirent_ptr,sizeof(struct dirent));
card_count++;
}
@@ -47,8 +74,7 @@ int get_card_list(struct dirent *cardlist[])
int get_edid(char edid_file[],char edid[])
{
int edid_fp = open(edid_file,O_RDONLY);
- if(edid_fp < 0)
- {
+ if(edid_fp < 0) {
printf("open edid file error:%s\n",edid_file);
return 1;
}
@@ -61,27 +87,23 @@ int get_connected_card_list(struct dirent *connected_card_list[],char *connected
struct dirent *cardlist[MAXCARD];
char edid[MAXEDID];
char edid_file[MAXFILENAME];
- for(int i=0; i<MAXCARD; i++)
- {
+ for(int i=0; i<MAXCARD; i++) {
cardlist[i] = (struct dirent*)malloc(sizeof(struct dirent));
}
int card_count =get_card_list(cardlist);
- for (int i=0; i<card_count;i++)
- {
+ for (int i=0; i<card_count;i++) {
memset(edid,0,MAXEDID);
sprintf(edid_file,"%s%s/edid",EDIDPATH,cardlist[i]->d_name);
int cun = get_edid(edid_file,edid);
- if(cun !=0)
- {
+ if(cun !=0) {
memcpy(connected_card_list[connecter_count],cardlist[i],sizeof(struct dirent));
memcpy(connected_edid[connecter_count],edid,MAXEDID);
connecter_count++;
}
}
- for(int i=0; i<MAXCARD; i++)
- {
+ for(int i=0; i<MAXCARD; i++) {
if(cardlist[i] != NULL)
free(cardlist[i]);
}
@@ -90,8 +112,7 @@ int get_connected_card_list(struct dirent *connected_card_list[],char *connected
void print_edid(char edid[])
{
printf("\t%0004hhx: ",0);
- for(int j=0;j<MAXEDID;j++)
- {
+ for(int j=0;j<MAXEDID;j++) {
if(j%8 == 0 && j != 0)
printf(" ");
if(j%16 ==0 && j != 0)
@@ -109,10 +130,8 @@ char chrmap(char ch)
*/
void find_dmt_mode(struct mode_line* m,struct drm_display_mode* rmode)
{
- for(int i=0;i<sizeof(dmt_modes)/sizeof(struct drm_display_mode);i++)
- {
- if(strcmp(m->mode,dmt_modes[i].name) == 0 && m->freq==dmt_modes[i].freq)
- {
+ for(int i=0;i<sizeof(dmt_modes)/sizeof(struct drm_display_mode);i++) {
+ if(strcmp(m->mode,dmt_modes[i].name) == 0 && m->freq==dmt_modes[i].freq) {
memcpy(rmode,&dmt_modes[i],sizeof(struct drm_display_mode));
}
}
@@ -120,20 +139,16 @@ void find_dmt_mode(struct mode_line* m,struct drm_display_mode* rmode)
void find_est_mode(struct mode_line* m,struct drm_display_mode* rmode)
{
- for(int i=0;i<16;i++)
- {
- if(strcmp(m->mode,est_modes[i].name) == 0 && m->freq==est_modes[i].freq)
- {
+ for(int i=0;i<16;i++) {
+ if(strcmp(m->mode,est_modes[i].name) == 0 && m->freq==est_modes[i].freq) {
memcpy(rmode,&est_modes[i],sizeof(struct drm_display_mode));
}
}
}
int gethdmiblock(char edid[])
{
- for(int i=0;i<MAXEDID;i++)
- {
- if(edid[i] == 0x03 && edid[i+1] == 0x0c && edid[i+2] == 0)
- {
+ for(int i=0;i<MAXEDID;i++) {
+ if(edid[i] == 0x03 && edid[i+1] == 0x0c && edid[i+2] == 0) {
return i;
}
}
@@ -143,8 +158,7 @@ int gethdmiblock(char edid[])
int check_edid(char edid[])
{
char edid_head[]={0x0,0xff,0xff,0xff,0xff,0xff,0xff,0x0};
- if( memcmp(edid, edid_head,8) !=0)
- {
+ if( memcmp(edid, edid_head,8) !=0) {
puts("Bad edid file\n");
return 1;
}
@@ -155,25 +169,22 @@ int parse_edid(char edid[])
if (check_edid(edid))
return 1;
/*
-3.4 Vendor & Product ID: 10 Bytes
-08h, 09h 2 ID Manufacturer Name Section 3.4.1
-0Ah, 0Bh 2 ID Product Code Section 3.4.2
-0Ch → 0Fh 4 ID Serial Number Section 3.4.3
-10h, 11h 2 Week of Manufacture or Model Year Flag,
+ * Vendor & Product ID: 10 Bytes
+ * 08h, 09h 2 ID Manufacturer Name Section 3.4.1
+ * 0Ah, 0Bh 2 ID Product Code Section 3.4.2
+ * 0Ch → 0Fh 4 ID Serial Number Section 3.4.3
+ * 10h, 11h 2 Week of Manufacture or Model Year Flag,
*/
- union VendorProduct
- {
- struct
- {
+ union VendorProduct {
+ struct {
int c:5;
int b:5;
int a:5;
} idchr;
- struct
- {
+ struct {
int lb:8;
int hb:8;
- }singlechr;
+ } singlechr;
} mfid;
mfid.singlechr.hb = edid[8];
mfid.singlechr.lb = edid[9];
@@ -185,53 +196,51 @@ int parse_edid(char edid[])
printf("\tEdidVersion: %hhx.%hhx\n",edid[0x12],edid[0x13]);
/*
-Address Bit Definitions Description
-7 _ _ _ _ _ _ _ Video Signal Interface: Bit 7
-0 _ _ _ _ _ _ _ Input is an Analog Video Signal Interface:
-7 6 5 _ _ _ _ _ Signal Level Standard: Video : Sync : Total Bits 6 & 5
-0 0 0 _ _ _ _ _ 0.700 : 0.300 : 1.000 V p-p
-0 0 1 _ _ _ _ _ 0.714 : 0.286 : 1.000 V p-p
-0 1 0 _ _ _ _ _ 1.000 : 0.400 : 1.400 V p-p
-0 1 1 _ _ _ _ _ 0.700 : 0.000 : 0.700 V p-p
-7 _ _ 4 _ _ _ _ Video Setup: Bit 4
-0 _ _ 0 _ _ _ _ Video Setup: Blank Level = Black Level
-0 _ _ 1 _ _ _ _ Video Setup: Blank-to-Black setup or pedestal (see Note 1)
-7 _ _ _ 3 2 1 _ Synchronization Types: Bits 3 → 1
-0 _ _ _ 0 _ _ _ Separate Sync H & V Signals are not supported
-0 _ _ _ 1 _ _ _ Separate Sync H & V Signals are supported
-0 _ _ _ _ 0 _ _ Composite Sync Signal on Horizontal is not supported
-0 _ _ _ _ 1 _ _ Composite Sync Signal on Horizontal is supported
-0 _ _ _ _ _ 0 _ Composite Sync Signal on Green Video is not supported
-0 _ _ _ _ _ 1 _ Composite Sync Signal on Green Video is supported
-7 _ _ _ _ _ _ 0 Serrations: Bit 0
-0 _ _ _ _ _ _ 0 Serration on the Vertical Sync is not supported
-14h
-0 _ _ _ _ _ _ 1 Serration on the Vertical Sync is supported (see Note 2)
-7 _ _ _ _ _ _ _ Video Signal Interface: Bit 7
-1 _ _ _ _ _ _ _ Input is a Digital Video Signal Interface: (see Note 3)
-7 6 5 4 _ _ _ _ Color Bit Depth: Bits 6 → 4
-1 0 0 0 _ _ _ _ Color Bit Depth is undefined
-1 0 0 1 _ _ _ _ 6 Bits per Primary Color
-1 0 1 0 _ _ _ _ 8 Bits per Primary Color
-1 0 1 1 _ _ _ _ 10 Bits per Primary Color
-1 1 0 0 _ _ _ _ 12 Bits per Primary Color
-1 1 0 1 _ _ _ _ 14 Bits per Primary Color
-1 1 1 0 _ _ _ _ 16 Bits per Primary Color
-1 1 1 1 _ _ _ _ Reserved (Do Not Use)
-7 _ _ _ 3 2 1 0 Digital Video Interface Standard Supported: Bits 3 → 0
-1 _ _ _ 0 0 0 0 Digital Interface is not defined (see Note 4)
-1 _ _ _ 0 0 0 1 DVI is supported
-1 _ _ _ 0 0 1 0 HDMI-a is supported
-1 _ _ _ 0 0 1 1 HDMI-b is supported
-1 _ _ _ 0 1 0 0 MDDI is supported
-1 _ _ _ 0 1 0 1 DisplayPort is supported
-14h
-1 _ _ _ → → → → All remaining values for Bits 3 → 0 are Reserved: Do Not Use
-*/
- union VideoInputDefinition
- {
- struct
- {
+ * Address Bit Definitions Description
+ * 7 _ _ _ _ _ _ _ Video Signal Interface: Bit 7
+ * 0 _ _ _ _ _ _ _ Input is an Analog Video Signal Interface:
+ * 7 6 5 _ _ _ _ _ Signal Level Standard: Video : Sync : Total Bits 6 & 5
+ * 0 0 0 _ _ _ _ _ 0.700 : 0.300 : 1.000 V p-p
+ * 0 0 1 _ _ _ _ _ 0.714 : 0.286 : 1.000 V p-p
+ * 0 1 0 _ _ _ _ _ 1.000 : 0.400 : 1.400 V p-p
+ * 0 1 1 _ _ _ _ _ 0.700 : 0.000 : 0.700 V p-p
+ * 7 _ _ 4 _ _ _ _ Video Setup: Bit 4
+ * 0 _ _ 0 _ _ _ _ Video Setup: Blank Level = Black Level
+ * 0 _ _ 1 _ _ _ _ Video Setup: Blank-to-Black setup or pedestal (see Note 1)
+ * 7 _ _ _ 3 2 1 _ Synchronization Types: Bits 3 → 1
+ * 0 _ _ _ 0 _ _ _ Separate Sync H & V Signals are not supported
+ * 0 _ _ _ 1 _ _ _ Separate Sync H & V Signals are supported
+ * 0 _ _ _ _ 0 _ _ Composite Sync Signal on Horizontal is not supported
+ * 0 _ _ _ _ 1 _ _ Composite Sync Signal on Horizontal is supported
+ * 0 _ _ _ _ _ 0 _ Composite Sync Signal on Green Video is not supported
+ * 0 _ _ _ _ _ 1 _ Composite Sync Signal on Green Video is supported
+ * 7 _ _ _ _ _ _ 0 Serrations: Bit 0
+ * 0 _ _ _ _ _ _ 0 Serration on the Vertical Sync is not supported
+ * 14h
+ * 0 _ _ _ _ _ _ 1 Serration on the Vertical Sync is supported (see Note 2)
+ * 7 _ _ _ _ _ _ _ Video Signal Interface: Bit 7
+ * 1 _ _ _ _ _ _ _ Input is a Digital Video Signal Interface: (see Note 3)
+ * 7 6 5 4 _ _ _ _ Color Bit Depth: Bits 6 → 4
+ * 1 0 0 0 _ _ _ _ Color Bit Depth is undefined
+ * 1 0 0 1 _ _ _ _ 6 Bits per Primary Color
+ * 1 0 1 0 _ _ _ _ 8 Bits per Primary Color
+ * 1 0 1 1 _ _ _ _ 10 Bits per Primary Color
+ * 1 1 0 0 _ _ _ _ 12 Bits per Primary Color
+ * 1 1 0 1 _ _ _ _ 14 Bits per Primary Color
+ * 1 1 1 0 _ _ _ _ 16 Bits per Primary Color
+ * 1 1 1 1 _ _ _ _ Reserved (Do Not Use)
+ * 7 _ _ _ 3 2 1 0 Digital Video Interface Standard Supported: Bits 3 → 0
+ * 1 _ _ _ 0 0 0 0 Digital Interface is not defined (see Note 4)
+ * 1 _ _ _ 0 0 0 1 DVI is supported
+ * 1 _ _ _ 0 0 1 0 HDMI-a is supported
+ * 1 _ _ _ 0 0 1 1 HDMI-b is supported
+ * 1 _ _ _ 0 1 0 0 MDDI is supported
+ * 1 _ _ _ 0 1 0 1 DisplayPort is supported
+ * 14h
+ * 1 _ _ _ → → → → All remaining values for Bits 3 → 0 are Reserved: Do Not Use
+ */
+ union VideoInputDefinition {
+ struct {
char serrationvsync:1;
char syncongreen:1;
char compositesync:1;
@@ -240,8 +249,7 @@ Address Bit Definitions Description
char videolevel:2;
char analogordigital:1;
} inputdef_a;
- struct
- {
+ struct {
char InterfaceStandardSupported:4;
char colorbitdepth:3;
char analogordigital:1;
@@ -249,51 +257,48 @@ Address Bit Definitions Description
} inputdef;
memcpy(&inputdef,&edid[0x14],1);
- if(inputdef.inputdef_a.analogordigital)
- {
- printf("\tMonitorType: %s\n","Digital");
+ if(inputdef.inputdef_a.analogordigital) {
int bitsperprimarycolor[]={0,6,8,10,12,14,16,0};
- printf("\tColorBitDepth: %d Bits per Primary Color\n",bitsperprimarycolor[inputdef.inputdef_d.colorbitdepth]);
char *interfacetpye[]={"","DVI","HDMI-a","HDMI-b","MDDI","DisplayPort"};
+ printf("\tMonitorType: %s\n","Digital");
+ printf("\tColorBitDepth: %d Bits per Primary Color\n",bitsperprimarycolor[inputdef.inputdef_d.colorbitdepth]);
printf("\tInterfaceStandardSupported: %s\n",bitsperprimarycolor[inputdef.inputdef_d.InterfaceStandardSupported]);
}
- else
- {
+ else {
printf("\tMonitorType: %s\n","Analogor");
printf("\tMaxImagesize: %hhdcm x %hhdcm\n",edid[0x15],edid[0x16]);
printf("\tMonitorGamma: %.2f\n",((edid[0x17]+100)*1.0/100.0));
}
/*
-Address Bits Definitions Description
-7 6 5 _ _ _ _ _ Display Power Management: (See Note 1) Bits 7 → 5
-1 _ _ _ _ _ _ _ Standby Mode is supported. Bit 7
-0 _ _ _ _ _ _ _ Standby Mode is not supported. Bit 7
-_ 1 _ _ _ _ _ _ Suspend Mode is supported. Bit 6
-_ 0 _ _ _ _ _ _ Suspend Mode is not supported. Bit 6
-_ _ 1 _ _ _ _ _ Active Off = Very Low Power is supported. Bit 5
-_ _ 0 _ _ _ _ _ Active Off = Very Low Power is not supported. Bit 5
-4 3 _ _ _ If bit 7 at address 14h = ‘0’ then bits 4 & 3 at address 18h defines the
-Display Color Type: (See Note 2) Bits 4 & 3
-0 0 _ _ _ Monochrome or Grayscale display
-0 1 _ _ _ RGB color display
-1 0 _ _ _ Non-RGB color display
-1 1 _ _ _ Display Color Type is Undefined
-4 3 _ _ _ If bit 7 at address 14h = ‘1’ then bits 4 & 3 at address 18h defines the
-Supported Color Encoding Format/s: (See Note 2) Bits 4 & 3
-0 0 _ _ _ RGB 4:4:4
-0 1 _ _ _ RGB 4:4:4 & YCrCb 4:4:4
-1 0 _ _ _ RGB 4:4:4 & YCrCb 4:2:2
-1 1 _ _ _ RGB 4:4:4 & YCrCb 4:4:4 & YCrCb 4:2:2
-2 1 0 Other Feature Support Flags: Bits 2 → 0
-1 _ _ sRGB Standard is the default color space. (See Note 3) Bit 2
-0 _ _ sRGB Standard is not the default color space. Bit 2
-_ 1 _ Preferred Timing Mode includes the native pixel format and preferred refresh rate of the display device. (See Note 4) Bit 1
-_ 0 _ Preferred Timing Mode does not include the native pixel format and preferred refresh rate of the display device. Bit 1
-_ _ 1 Display is continuous frequency. (See Note 5) Bit 0
-_ _ 0 Display is non-continuous frequency (multi-mode). Bit 0
+ * Address Bits Definitions Description
+ * 7 6 5 _ _ _ _ _ Display Power Management: (See Note 1) Bits 7 → 5
+ * 1 _ _ _ _ _ _ _ Standby Mode is supported. Bit 7
+ * 0 _ _ _ _ _ _ _ Standby Mode is not supported. Bit 7
+ * _ 1 _ _ _ _ _ _ Suspend Mode is supported. Bit 6
+ * _ 0 _ _ _ _ _ _ Suspend Mode is not supported. Bit 6
+ * _ _ 1 _ _ _ _ _ Active Off = Very Low Power is supported. Bit 5
+ * _ _ 0 _ _ _ _ _ Active Off = Very Low Power is not supported. Bit 5
+ * 4 3 _ _ _ If bit 7 at address 14h = ‘0’ then bits 4 & 3 at address 18h defines the
+ * Display Color Type: (See Note 2) Bits 4 & 3
+ * 0 0 _ _ _ Monochrome or Grayscale display
+ * 0 1 _ _ _ RGB color display
+ * 1 0 _ _ _ Non-RGB color display
+ * 1 1 _ _ _ Display Color Type is Undefined
+ * 4 3 _ _ _ If bit 7 at address 14h = ‘1’ then bits 4 & 3 at address 18h defines the
+ * Supported Color Encoding Format/s: (See Note 2) Bits 4 & 3
+ * 0 0 _ _ _ RGB 4:4:4
+ * 0 1 _ _ _ RGB 4:4:4 & YCrCb 4:4:4
+ * 1 0 _ _ _ RGB 4:4:4 & YCrCb 4:2:2
+ * 1 1 _ _ _ RGB 4:4:4 & YCrCb 4:4:4 & YCrCb 4:2:2
+ * 2 1 0 Other Feature Support Flags: Bits 2 → 0
+ * 1 _ _ sRGB Standard is the default color space. (See Note 3) Bit 2
+ * 0 _ _ sRGB Standard is not the default color space. Bit 2
+ * _ 1 _ Preferred Timing Mode includes the native pixel format and preferred refresh rate of the display device. (See Note 4) Bit 1
+ * _ 0 _ Preferred Timing Mode does not include the native pixel format and preferred refresh rate of the display device. Bit 1
+ * _ _ 1 Display is continuous frequency. (See Note 5) Bit 0
+ * _ _ 0 Display is non-continuous frequency (multi-mode). Bit 0
*/
- struct
- {
+ struct {
char GTFSupport:1;
char perfertimemod:1;
char stdcolorspace:1;
@@ -314,105 +319,97 @@ _ _ 0 Display is non-continuous frequency (multi-mode). Bit 0
else if(powman.activeoff & 1) strcat(msg,"RGB ");
else if(powman.activeoff & 2) strcat(msg,"Non RGB ");
else if(powman.activeoff & 3) strcat(msg,"Undefineed ");
- printf("\tPowerSupport: %s\n",msg);
+ printf("\tPowerSupport: %s\n",msg);
printf("\tChromaInfo: %hhx %hhx %hhx %hhx %hhx %hhx %hhx %hhx %hhx %hhx \n",edid[0x19],edid[0x1a],edid[0x1b],edid[0x1c],edid[0x1d],edid[0x1e],edid[0x1f],edid[0x20],edid[0x21],edid[0x22]);
char estiming[16][256];
-// memset(estiming,0,512);
-// if(edid[0x24] & 1) strcat(estiming,"1280x1024 @ 75 \t");
-// if(edid[0x24] & 2) strcat(estiming,"1024x768 @ 75 \t");
-// if(edid[0x24] & 4) strcat(estiming,"1024x768 @ 70 \t");
-// if(edid[0x24] & 8) strcat(estiming,"1024x768 @ 60 \t");
-// if(edid[0x24] & 16) strcat(estiming,"1024x768 @ 87 \t");
-// if(edid[0x24] & 32) strcat(estiming,"832x624 @ 75 \t");
-// if(edid[0x24] & 64) strcat(estiming,"800x600 @ 75 \t");
-// if(edid[0x24] & 128) strcat(estiming,"800x600 @ 72 \t");
-//
-// if(edid[0x23] & 1) strcat(estiming,"800x600 @ 60 \t");
-// if(edid[0x23] & 2) strcat(estiming,"800x600 @ 56 \t");
-// if(edid[0x23] & 4) strcat(estiming,"640x480 @ 75 \t");
-// if(edid[0x23] & 8) strcat(estiming,"640x480 @ 72 \t");
-// if(edid[0x23] & 16) strcat(estiming,"640x480 @ 67 \t");
-// if(edid[0x23] & 32) strcat(estiming,"640x480 @ 60 \t");
-// if(edid[0x23] & 64) strcat(estiming,"720x400 @ 88 \t");
-// if(edid[0x23] & 128) strcat(estiming,"720x400 @ 70 \t");
/*
-23h 1 Established Timing I
-7 720 x 400 @ 70Hz IBM, VGA
-6 720 x 400 @ 88Hz IBM, XGA2
-5 640 x 480 @ 60Hz IBM, VGA
-4 640 x 480 @ 67Hz Apple, Mac II
-3 640 x 480 @ 72Hz VESA
-2 640 x 480 @ 75Hz VESA
-1 800 x 600 @ 56Hz VESA
-0 800 x 600 @ 60Hz VESA
-24h 1 Established Timing II
-7 800 x 600 @ 72Hz VESA
-6 800 x 600 @ 75Hz VESA
-5 832 x 624 @ 75Hz Apple, Mac II
-4 1024 x 768 @ 87Hz(I) IBM - Interlaced
-3 1024 x 768 @ 60Hz VESA
-2 1024 x 768 @ 70Hz VESA
-1 1024 x 768 @ 75Hz VESA
-0 1280 x 1024 @ 75Hz VESA
-25h 1 Manufacturer's Timings
-7 1152 x 870 @ 75Hz Apple, Mac II
-*/
+ * 23h 1 Established Timing I
+ * 7 720 x 400 @ 70Hz IBM, VGA
+ * 6 720 x 400 @ 88Hz IBM, XGA2
+ * 5 640 x 480 @ 60Hz IBM, VGA
+ * 4 640 x 480 @ 67Hz Apple, Mac II
+ * 3 640 x 480 @ 72Hz VESA
+ * 2 640 x 480 @ 75Hz VESA
+ * 1 800 x 600 @ 56Hz VESA
+ * 0 800 x 600 @ 60Hz VESA
+ * 24h 1 Established Timing II
+ * 7 800 x 600 @ 72Hz VESA
+ * 6 800 x 600 @ 75Hz VESA
+ * 5 832 x 624 @ 75Hz Apple, Mac II
+ * 4 1024 x 768 @ 87Hz(I) IBM - Interlaced
+ * 3 1024 x 768 @ 60Hz VESA
+ * 2 1024 x 768 @ 70Hz VESA
+ * 1 1024 x 768 @ 75Hz VESA
+ * 0 1280 x 1024 @ 75Hz VESA
+ * 25h 1 Manufacturer's Timings
+ * 7 1152 x 870 @ 75Hz Apple, Mac II
+ */
struct mode_line estmode[]={
- {"1280x1024",75} , {"1024x768",75} , {"1024x768",70} , {"1024x768",60} , {"1024x768",87} , {"832x624",75} , {"800x600",75} , {"800x600",72} , {"800x600",60} , {"800x600",56} , {"640x480",75} , {"640x480",72} , {"640x480",67} , {"640x480",60} , {"720x400",88} , {"720x400",70}};
+ {"1280x1024",75} ,
+ {"1024x768",75} ,
+ {"1024x768",70} ,
+ {"1024x768",60} ,
+ {"1024x768",87} ,
+ {"832x624",75} ,
+ {"800x600",75} ,
+ {"800x600",72} ,
+ {"800x600",60} ,
+ {"800x600",56} ,
+ {"640x480",75} ,
+ {"640x480",72} ,
+ {"640x480",67} ,
+ {"640x480",60} ,
+ {"720x400",88} ,
+ {"720x400",70}
+ };
struct mode_line curestmode[80];
printf("\tEstablishedTiming: \n");
char es = edid[0x24];
int escount=0;
- for(int i=0;i<8;i++)
- {
- if(es & 0x01)
- {
+ for(int i=0;i<8;i++) {
+ if(es & 0x01) {
memcpy(&curestmode[escount],&estmode[i],sizeof(struct mode_line));
escount++;
}
es = es >> 1;
}
es = edid[0x23];
- for(int i=0;i<8;i++)
- {
- if(es & 0x01)
- {
+ for(int i=0;i<8;i++) {
+ if(es & 0x01) {
memcpy(&curestmode[escount],&estmode[i+8],sizeof(struct mode_line));
escount++;
}
es = es >> 1;
}
- for(int i=0;i<escount;i++)
- {
+ for(int i=0;i<escount;i++) {
struct drm_display_mode rmodeline;
find_est_mode(&curestmode[i],&rmodeline);
printf("\t\t%s @ %d %d %d %d\n",rmodeline.name,rmodeline.freq,rmodeline.pclock, rmodeline.htot,rmodeline.vtot);
}
/*
-26h 1 256 pixels → 2288 pixels, in increments of 8 pixels
-00h Reserved: Do not use.
-Bit Definitions Description
-7 6 _ _ _ _ _ _ Image Aspect Ratio: bits 7 & 6
-0 0 _ _ _ _ _ _ 16 : 10 AR
-0 1 _ _ _ _ _ _ 4 : 3 AR
-1 0 _ _ _ _ _ _ 5 : 4 AR
-1 1 _ _ _ _ _ _ 16 : 9 AR
-5 4 3 2 1 0 Field Refresh Rate: bits 5 → 0
-Value Stored (in binary) = Field Refresh Rate (in Hz) – 60
-27h 1
-n n n n n n
-Range: 60 Hz → 123Hz
-*/
+ * 26h 1 256 pixels → 2288 pixels, in increments of 8 pixels
+ * 00h Reserved: Do not use.
+ * Bit Definitions Description
+ * 7 6 _ _ _ _ _ _ Image Aspect Ratio: bits 7 & 6
+ * 0 0 _ _ _ _ _ _ 16 : 10 AR
+ * 0 1 _ _ _ _ _ _ 4 : 3 AR
+ * 1 0 _ _ _ _ _ _ 5 : 4 AR
+ * 1 1 _ _ _ _ _ _ 16 : 9 AR
+ * 5 4 3 2 1 0 Field Refresh Rate: bits 5 → 0
+ * Value Stored (in binary) = Field Refresh Rate (in Hz) – 60
+ * 27h 1
+ * n n n n n n
+ * Range: 60 Hz → 123Hz
+ */
char stdtiming[8][256];
- struct
- {
+ struct {
int vertfrequency:6;
int aspectratio:2;
- }stdtiminginfo;
+ } stdtiminginfo;
printf("\r\tStandTiming:\n");
memset(curestmode,0,80*sizeof(struct mode_line));
@@ -421,8 +418,7 @@ Range: 60 Hz → 123Hz
struct drm_display_mode rmodeline;
char tmod[20];
char ratio[2][6];
- for(int i=0;i<8;i++)
- {
+ for(int i=0;i<8;i++) {
int tem=0;
memcpy(&tem,&edid[38+2*i],1);
memcpy(&stdtiminginfo,&edid[39+2*i],1);
@@ -437,8 +433,7 @@ Range: 60 Hz → 123Hz
memcpy(ratio[1],msgp+1,strlen(msgp));
int hratio = atoi(ratio[0]);
int vratio = atoi(ratio[1]);
- if(tem != 1)
- {
+ if(tem != 1) {
memset(&rmodeline,0,sizeof(struct drm_display_mode));
memset(&tdmtmode,0,sizeof(struct mode_line));
memset(tmod,0,20);
@@ -453,80 +448,77 @@ Range: 60 Hz → 123Hz
}
}
/*
-Value Detailed Timing Definitions
-(00 01)h → (FF FF)h
-Stored Value = Pixel clock ÷ 10,000
-LSB stored in byte 0 and MSB stored in byte 1
-0, 1 2 Range: 10 kHz to 655.35 MHz in 10 kHz steps
-(00 00)h Reserved: Do not use for Detailed Timing Descriptor
-2 1 00h → FFh Horizontal Addressable Video in pixels --- contains lower 8 bits
-3 1 00h → FFh Horizontal Blanking in pixels --- contains lower 8 bits
-({HA}h, {HB}h)
-where
-Horizontal Addressable Video in pixels –
-4 1 -- stored in Upper Nibble : contains upper 4 bits
-0h ≤ HA ≤ Fh and
-0h ≤ HB ≤ Fh
-Horizontal Blanking in pixels --- stored in Lower Nibble : contains
-upper 4 bits
-5 1 00h → FFh Vertical Addressable Video in lines --- contains lower 8 bits
-6 1 00h → FFh Vertical Blanking in lines --- contains lower 8 bits
-({VA}h, {VB}h)
-where
-Vertical Addressable Video in lines -- stored in Upper Nibble :
-7 1 contains upper 4 bits
-0h ≤ VA ≤ Fh and
-0h ≤ VB ≤ Fh
-Vertical Blanking in lines --- stored in Lower Nibble : contains
-upper 4 bits
-8 1 00h → FFh Horizontal Front Porch in pixels --- contains lower 8 bits
-9 1 00h → FFh Horizontal Sync Pulse Width in pixels --- contains lower 8 bits
-({VF}h, {VS}h)
-where
-Vertical Front Porch in Lines --- stored in Upper Nibble : contains
-10 1 lower 4 bits
-0h ≤ VF ≤ Fh and
-0h ≤ VS ≤ Fh
-Vertical Sync Pulse Width in Lines --- stored in Lower Nibble :
-contains lower 4 bits
-7 6 5 4 3 2 1 0 Bit Definitions
-n n _ _ _ _ _ _ Horizontal Front Porch in pixels --- contains upper 2 bits
-_ _ n n _ _ _ _ Horizontal Sync Pulse Width in Pixels --- contains upper 2 bits
-_ _ _ _ n n _ _ Vertical Front Porch in lines --- contains upper 2 bits
-11 1
-_ _ _ _ _ _ n n Vertical Sync Pulse Width in lines --- contains upper 2 bits
-Value Video Image Size & Border Definitions
-12 1 00h → FFh Horizontal Addressable Video Image Size in mm --- contains lower
-8 bits
-13 1 00h → FFh Vertical Addressable Video Image Size in mm --- contains lower 8
-bits
-({HI}h, {VI}h)
-where
-Horizontal Addressable Video Image Size in mm --- stored in Upper
-14 1 Nibble : contains upper 4 bits
-0h ≤ HI ≤ Fh and
-0h ≤ VI ≤ Fh
-Vertical Addressable Video Image Size in mm --- stored in Lower
-Nibble : contains upper 4 bits
-15 1 00h → FFh Right Horizontal Border or Left Horizontal Border in pixels --- refer
-to Section 3.12 – Right Border is equal to Left Border
-16 1 00h → FFh Top Vertical Border or Bottom Vertical Border in Lines --- refer to
-Section 3.12 – Top Border is equal to Bottom Border
+ * Value Detailed Timing Definitions
+ * (00 01)h → (FF FF)h
+ * Stored Value = Pixel clock ÷ 10,000
+ * LSB stored in byte 0 and MSB stored in byte 1
+ * 0, 1 2 Range: 10 kHz to 655.35 MHz in 10 kHz steps
+ * (00 00)h Reserved: Do not use for Detailed Timing Descriptor
+ * 2 1 00h → FFh Horizontal Addressable Video in pixels --- contains lower 8 bits
+ * 3 1 00h → FFh Horizontal Blanking in pixels --- contains lower 8 bits
+ * ({HA}h, {HB}h)
+ * where
+ * Horizontal Addressable Video in pixels –
+ * 4 1 -- stored in Upper Nibble : contains upper 4 bits
+ * 0h ≤ HA ≤ Fh and
+ * 0h ≤ HB ≤ Fh
+ * Horizontal Blanking in pixels --- stored in Lower Nibble : contains
+ * upper 4 bits
+ * 5 1 00h → FFh Vertical Addressable Video in lines --- contains lower 8 bits
+ * 6 1 00h → FFh Vertical Blanking in lines --- contains lower 8 bits
+ * ({VA}h, {VB}h)
+ * where
+ * Vertical Addressable Video in lines -- stored in Upper Nibble :
+ * 7 1 contains upper 4 bits
+ * 0h ≤ VA ≤ Fh and
+ * 0h ≤ VB ≤ Fh
+ * Vertical Blanking in lines --- stored in Lower Nibble : contains
+ * upper 4 bits
+ * 8 1 00h → FFh Horizontal Front Porch in pixels --- contains lower 8 bits
+ * 9 1 00h → FFh Horizontal Sync Pulse Width in pixels --- contains lower 8 bits
+ * ({VF}h, {VS}h)
+ * where
+ * Vertical Front Porch in Lines --- stored in Upper Nibble : contains
+ * 10 1 lower 4 bits
+ * 0h ≤ VF ≤ Fh and
+ * 0h ≤ VS ≤ Fh
+ * Vertical Sync Pulse Width in Lines --- stored in Lower Nibble :
+ * contains lower 4 bits
+ * 7 6 5 4 3 2 1 0 Bit Definitions
+ * n n _ _ _ _ _ _ Horizontal Front Porch in pixels --- contains upper 2 bits
+ * _ _ n n _ _ _ _ Horizontal Sync Pulse Width in Pixels --- contains upper 2 bits
+ * _ _ _ _ n n _ _ Vertical Front Porch in lines --- contains upper 2 bits
+ * 11 1
+ * _ _ _ _ _ _ n n Vertical Sync Pulse Width in lines --- contains upper 2 bits
+ * Value Video Image Size & Border Definitions
+ * 12 1 00h → FFh Horizontal Addressable Video Image Size in mm --- contains lower
+ * 8 bits
+ * 13 1 00h → FFh Vertical Addressable Video Image Size in mm --- contains lower 8
+ * bits
+ * ({HI}h, {VI}h)
+ * where
+ * Horizontal Addressable Video Image Size in mm --- stored in Upper
+ * 14 1 Nibble : contains upper 4 bits
+ * 0h ≤ HI ≤ Fh and
+ * 0h ≤ VI ≤ Fh
+ * Vertical Addressable Video Image Size in mm --- stored in Lower
+ * Nibble : contains upper 4 bits
+ * 15 1 00h → FFh Right Horizontal Border or Left Horizontal Border in pixels --- refer
+ * to Section 3.12 – Right Border is equal to Left Border
+ * 16 1 00h → FFh Top Vertical Border or Bottom Vertical Border in Lines --- refer to
+ * Section 3.12 – Top Border is equal to Bottom Border
*/
- union
- {
- struct
- {
+ union {
+ struct {
int clkl:8;
int clkh:8;
int :16;
}clkchr;
int clk;
}pixclk;
- union
- {
- struct
- {
+
+ union {
+ struct {
int vdispl:8;
int vdisph:4;
int :0;
@@ -534,28 +526,24 @@ Section 3.12 – Top Border is equal to Bottom Border
int value;
}vdisp;
- union
- {
- struct
- {
+ union {
+ struct {
int syncl:8;
int synch:2;
}syncchr;
int value;
}sync;
- for(int i=0;i<4;i++)
- {
+ for(int i=0;i<4;i++) {
int Hdisp,Vdisp,Hblank,Vblank;
float freq;
pixclk.clkchr.clkl =edid[0x36 +i*18];
pixclk.clkchr.clkh=edid[0x37 + i*18];
if(pixclk.clk == 0) continue;
//printf("pixel clock: %d\n",pixclk.clk*10);
- union
- {
- struct
- {
+
+ union {
+ struct {
char blank:4;
char disp:4;
}h4bitchr;
@@ -596,16 +584,16 @@ Section 3.12 – Top Border is equal to Bottom Border
freq = pixclk.clk*10000.0/(Hdisp+Hblank)/(Vdisp+Vblank);
//printf("Vblank: %d\n",vdisp.value);
printf("\tDetailTiming:\n\t\t%dx%d @ %.2f %d %d %d\n",Hdisp,Vdisp,freq,pixclk.clk*10,Hdisp+Hblank,Vdisp+Vblank);
- union
- {
- struct
- {
+
+ union {
+ struct {
char vsync:2;
char dsync:2;
char hsync:2;
}chr;
char value;
}h2bit;
+
h2bit.value=edid[0x36+i*18+11];
memset(&sync,0,4);
sync.syncchr.syncl=edid[0x36+i*18+8];
@@ -613,19 +601,17 @@ Section 3.12 – Top Border is equal to Bottom Border
// printf("VSync: %d\n",sync.value);
}
-////////////////
-//For HDMI
-///////////////
+/*
+ * Extended block for HDMI
+ */
+
+ char *bppinfo[]={ "DVI_Dual" , "", "", "DC_Y444", "DC_30bit", "DC_36bit", "DC_48bit", "Supports_AI"};
int phdmiindex = gethdmiblock(edid);
- if(phdmiindex != -1)
- {
+ if(phdmiindex != -1) {
printf("\tHaving a hdmi block, start position is:%2hhx\n",phdmiindex);
- char *bppinfo[]={ "DVI_Dual" , "", "", "DC_Y444", "DC_30bit", "DC_36bit", "DC_48bit", "Supports_AI"};
char bppbyte=edid[phdmiindex + 5];
- for(int i=0;i<8;i++)
- {
- if(bppbyte & 0x01)
- {
+ for(int i=0;i<8;i++) {
+ if(bppbyte & 0x01) {
printf("\tHDMI bpp supports: %s\n",bppinfo[i]);
}
bppbyte = bppbyte >> 1;
@@ -635,31 +621,28 @@ Section 3.12 – Top Border is equal to Bottom Border
int main(void)
{
- struct dirent *cardlist[MAXCARD];
- char *edid[MAXCARD];
- for(int i=0; i<MAXCARD; i++)
- {
- cardlist[i] = (struct dirent*)malloc(sizeof(struct dirent));
- edid[i] = (char *)malloc(MAXEDID);
- }
-
- int connecter_count = get_connected_card_list(cardlist,edid);
- printf("\33[1;;32mThe connected monitor number: %d\n\33[0m",connecter_count);
-
- for(int i=0;i<connecter_count;i++)
- {
- printf("\33[1;;32m%d. Connected monitor card: %s\n\33[0m",i+1,cardlist[i]->d_name);
- print_edid(edid[i]);
- parse_edid(edid[i]);
- }
-
- for(int i=0; i<MAXCARD; i++)
- {
- if(cardlist[i] != NULL)
- free(cardlist[i]);
- if(edid[i] != NULL)
- free(edid[i]);
- }
- return 0;
+ struct dirent *cardlist[MAXCARD];
+ char *edid[MAXCARD];
+ for(int i=0; i<MAXCARD; i++) {
+ cardlist[i] = (struct dirent*)malloc(sizeof(struct dirent));
+ edid[i] = (char *)malloc(MAXEDID);
+ }
+
+ int connecter_count = get_connected_card_list(cardlist,edid);
+ printf("\33[1;;32mThe connected monitor number: %d\n\33[0m",connecter_count);
+
+ for(int i=0;i<connecter_count;i++) {
+ printf("\33[1;;32m%d. Connected monitor card: %s\n\33[0m",i+1,cardlist[i]->d_name);
+ print_edid(edid[i]);
+ parse_edid(edid[i]);
+ }
+
+ for(int i=0; i<MAXCARD; i++) {
+ if(cardlist[i] != NULL)
+ free(cardlist[i]);
+ if(edid[i] != NULL)
+ free(edid[i]);
+ }
+ return 0;
}