diff options
author | root <root@sunyi-pc.(none)> | 2011-05-24 12:43:32 +0800 |
---|---|---|
committer | root <root@sunyi-pc.(none)> | 2011-05-24 12:43:32 +0800 |
commit | c6dba7ff25ae61fc51ee1c44109594eaafb55ba9 (patch) | |
tree | e620e233f3c83b64328b034bd02f8c8235303ef4 | |
parent | 96a8d55d574a0c713ae7a62e99ab259ddde6879d (diff) |
Perfect the output.
-rw-r--r-- | testedid.c | 111 |
1 files changed, 62 insertions, 49 deletions
@@ -96,13 +96,13 @@ int getconcardlist(struct dirent *concardlist[],char *conedid[]) } void printedid(char edid[]) { - printf("%0004hhx: ",0); + printf("\t%0004hhx: ",0); for(int j=0;j<MAXEDID;j++) { if(j%8 == 0 && j != 0) printf(" "); if(j%16 ==0 && j != 0) - printf("\n%0004hhx: ",j); + printf("\n\t%0004hhx: ",j); printf("%02hhx ",edid[j]); } printf("\n"); @@ -116,7 +116,10 @@ void analizeedid(char edid[]) { char head[]={0x0,0xff,0xff,0xff,0xff,0xff,0xff,0x0}; if( memcmp(edid,head,8) !=0) + { puts("Bad edid file\n"); + exit(1); + } union mfdata { struct @@ -124,8 +127,6 @@ void analizeedid(char edid[]) int c:5; int b:5; int a:5; - // char b:5; - // char c:5; } idchr; struct { @@ -137,11 +138,11 @@ void analizeedid(char edid[]) mfid.singlechr.lb = edid[9]; //printf("ManufactureID: %02hhx %02hhx %02hhx\n",mfid.idchr.a,mfid.idchr.b,mfid.idchr.c); - printf("ManufactureID: %c%c%c\n",chrmap(mfid.idchr.a),chrmap(mfid.idchr.b),chrmap(mfid.idchr.c)); - printf("Monitor ID: %hhx%hhx\n",edid[0xb],edid[0xa]); - printf("Monitor SeriesID: %c%c%c%c\n",edid[0xf],edid[0xe],edid[0xd],edid[0xc]); - printf("Product Week/year: %d/%d\n",edid[0x10],edid[0x11]+1990); - printf("Edid Version: %hhx.%hhx\n",edid[0x12],edid[0x13]); + printf("\tManufactureID: %c%c%c\t",chrmap(mfid.idchr.a),chrmap(mfid.idchr.b),chrmap(mfid.idchr.c)); + printf("\tMonitorID: %hhx%hhx\t",edid[0xb],edid[0xa]); + printf("\tSerialNumber: %c%c%c%c\n",edid[0xf],edid[0xe],edid[0xd],edid[0xc]); + printf("\tProductWeek/year: %d/%d\n",edid[0x10],edid[0x11]+1990); + printf("\tEdidVersion: %hhx.%hhx\n",edid[0x12],edid[0x13]); struct { char serrationvsync:1; @@ -158,10 +159,9 @@ void analizeedid(char edid[]) strcat(msg,"Digital"); else strcat(msg, "Analogor"); - printf("Monitor Type: %s\n",msg); - - printf("MaxImage size: %hhdcm x %hhdcm\n",edid[0x15],edid[0x16]); - printf("Monitor Gamma: %.2f\n",((edid[0x17]+100)*1.0/100.0)); + printf("\tMonitorType: %s\n",msg); + printf("\tMaxImagesize: %hhdcm x %hhdcm\n",edid[0x15],edid[0x16]); + printf("\tMonitorGamma: %.2f\n",((edid[0x17]+100)*1.0/100.0)); struct { @@ -182,36 +182,36 @@ void analizeedid(char edid[]) 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("MonitorPowerSupport: %s\n",msg); + printf("\tPowerSupport: %s\n",msg); - printf("Chroma Info: %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]); + 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[512]; memset(estiming,0,512); - if(edid[0x24] & 1) strcat(estiming,"1280x1024@75 "); - if(edid[0x24] & 2) strcat(estiming,"1024x768@75 "); - if(edid[0x24] & 4) strcat(estiming,"1024x768@70 "); - if(edid[0x24] & 8) strcat(estiming,"1024x768@60 "); - if(edid[0x24] & 16) strcat(estiming,"1024x768@87 "); - if(edid[0x24] & 32) strcat(estiming,"832x624@75 "); - if(edid[0x24] & 64) strcat(estiming,"800x600@75 "); - if(edid[0x24] & 128) strcat(estiming,"800x600@72 "); + 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 "); - if(edid[0x23] & 2) strcat(estiming,"800x600@56 "); - if(edid[0x23] & 4) strcat(estiming,"640x480@75 "); - if(edid[0x23] & 8) strcat(estiming,"640x480@72 "); - if(edid[0x23] & 16) strcat(estiming,"640x480@67 "); - if(edid[0x23] & 32) strcat(estiming,"640x480@60 "); - if(edid[0x23] & 64) strcat(estiming,"720x400@88 "); - if(edid[0x23] & 128) strcat(estiming,"720x400@70 "); + 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"); - printf("Established Timing: \n"); + printf("\tEstablishedTiming: \n\t\t"); int len=strlen(estiming); for(int i=0;i<len;i++) { - if(estiming[i] == ' ') - printf("\n"); + if(estiming[i] == '\t') + printf("\n\t\t"); else printf("%c",estiming[i]); } @@ -221,7 +221,7 @@ void analizeedid(char edid[]) int vertfrequency:6; int aspectratio:2; }stdtiminginfo; - printf("Stand timing:\n"); + printf("\r\tStandTiming:\n"); for(int i=0;i<8;i++) { int tem=0; @@ -232,9 +232,16 @@ void analizeedid(char edid[]) else if(stdtiminginfo.aspectratio & 1) strcat(msg,"4:3"); else if(stdtiminginfo.aspectratio & 2) strcat(msg,"5:4"); else if(stdtiminginfo.aspectratio & 3) strcat(msg,"16:9"); - + char ratio[2][4]; + char *msgp = strstr(msg,":"); + memcpy(ratio[0],msg,msgp-msg); + memcpy(ratio[1],msgp+1,strlen(msgp)); +// ratio[0] = strtok(msg,":"); +// ratio[1] = strtok(NULL,":"); + int hratio = atoi(ratio[0]); + int vratio = atoi(ratio[1]); if(tem != 1) - printf("%d: %d(H) %d(V) %s\n",i,tem*8+248,stdtiminginfo.vertfrequency+60,msg); + printf("\t\t%dx%d @ %d (%s)\n",tem*8+248,(tem*8+248)*vratio/hratio,stdtiminginfo.vertfrequency+60,msg); } union { @@ -267,13 +274,14 @@ void analizeedid(char edid[]) int value; }sync; - for(int i=0;i<4;i++) { - pixclk.clkchr.clkh =edid[0x36 +i*18]; - pixclk.clkchr.clkl=edid[0x37 + i*18]; + 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); + //printf("pixel clock: %d\n",pixclk.clk*10); union { struct @@ -287,7 +295,8 @@ void analizeedid(char edid[]) h4bit.value = edid[0x36+ i*18+ 4]; vdisp.vdispchr.vdispl=edid[0x36+ i*18+ 2]; vdisp.vdispchr.vdisph=h4bit.h4bitchr.disp; - printf("Hdisplay: %d\n",vdisp.value); + Hdisp = vdisp.value; + // printf("Hdisplay: %d\n",vdisp.value); memset(&h4bit,0,1); memset(&vdisp,0,4); @@ -295,7 +304,8 @@ void analizeedid(char edid[]) h4bit.value = edid[0x36+ i*18+ 7]; vdisp.vdispchr.vdispl=edid[0x36+ i*18+ 5]; vdisp.vdispchr.vdisph=h4bit.h4bitchr.disp; - printf("Vdisplay: %d\n",vdisp.value); + Vdisp = vdisp.value; + //printf("Vdisplay: %d\n",vdisp.value); memset(&h4bit,0,1); memset(&vdisp,0,4); @@ -303,7 +313,8 @@ void analizeedid(char edid[]) h4bit.value = edid[0x36+ i*18+ 4]; vdisp.vdispchr.vdispl=edid[0x36+ i*18+ 3]; vdisp.vdispchr.vdisph=h4bit.h4bitchr.blank; - printf("Hblank:: %d\n",vdisp.value); + Hblank = vdisp.value; + //printf("Hblank:: %d\n",vdisp.value); memset(&h4bit,0,1); memset(&vdisp,0,4); @@ -311,8 +322,10 @@ void analizeedid(char edid[]) h4bit.value = edid[0x36+ i*18+ 7]; vdisp.vdispchr.vdispl=edid[0x36+ i*18+ 6]; vdisp.vdispchr.vdisph=h4bit.h4bitchr.blank; - printf("Vblank: %d\n",vdisp.value); - + Vblank = vdisp.value; + freq = pixclk.clk*10000.0/(Hdisp+Hblank)/(Vdisp+Vblank); + //printf("Vblank: %d\n",vdisp.value); + printf("\tDetailTiming:\n\t\t%dx%d @ %.2f %d\n",Hdisp,Vdisp,freq,pixclk.clk*10000); union { struct @@ -327,7 +340,7 @@ void analizeedid(char edid[]) memset(&sync,0,4); sync.syncchr.syncl=edid[0x36+i*18+8]; sync.syncchr.synch=h2bit.chr.vsync; - printf("VSync: %d\n",sync.value); + // printf("VSync: %d\n",sync.value); } @@ -343,11 +356,11 @@ int main(void) } int connum = getconcardlist(cardlist,edid); - printf("The connected monitor number:%d\n",connum); + printf("The connected monitor number: %d\n",connum); for(int i=0;i<connum;i++) { - printf("%d Connected monitor card:%s\n",i+1,cardlist[i]->d_name); + printf("%d. Connected monitor card: %s\n",i+1,cardlist[i]->d_name); printedid(edid[i]); analizeedid(edid[i]); } |