diff options
author | Florian Tobias Schandinat <FlorianSchandinat@gmx.de> | 2010-03-10 15:21:28 -0800 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2010-03-12 15:52:33 -0800 |
commit | dd73d6868b9ecb4841def0c6ff0a25da27db33ba (patch) | |
tree | 353558254ac6ad9561beb6f3bac7b5254301c95c /drivers/video/via/viamode.c | |
parent | 2365dfe99495159b3395dd0eddece2f0d58f527a (diff) | |
download | op-kernel-dev-dd73d6868b9ecb4841def0c6ff0a25da27db33ba.zip op-kernel-dev-dd73d6868b9ecb4841def0c6ff0a25da27db33ba.tar.gz |
viafb: split global index up
This is the first step to remove an artificial global index that was used
in two ways:
1. As a pseudo index in the mode table. Pseudo as you had to search
through the table to find the referenced entry. This was replaced by
using a pointer to the entry.
2. As a shortcut to compare a combination of horizontal and vertical
resolution at the same time.
This was replaced by a "(hres<<16) | vres" which is good enough for
now and the near future. If vres or hres become greater than 2^16 this
might indeed cause problems but this solution allows to split this
indexing mess up without the requirement to do even more code changes.
This is a big change that will allow more clean ups. It should be a bit
faster but that is probably not relevant for normal operation. No
regressions expected but as this is a relatively big step heavy testing is
appreciated.
Signed-off-by: Florian Tobias Schandinat <FlorianSchandinat@gmx.de>
Cc: Joseph Chan <JosephChan@via.com.tw>
Cc: Scott Fang <ScottFang@viatech.com.cn>
Cc: Krzysztof Helt <krzysztof.h1@poczta.fm>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'drivers/video/via/viamode.c')
-rw-r--r-- | drivers/video/via/viamode.c | 180 |
1 files changed, 93 insertions, 87 deletions
diff --git a/drivers/video/via/viamode.c b/drivers/video/via/viamode.c index b74f8a6..af50e24 100644 --- a/drivers/video/via/viamode.c +++ b/drivers/video/via/viamode.c @@ -412,7 +412,7 @@ struct io_reg PM1024x768[] = { {VIASR, 0x16, 0xBF, 0x0C}, }; struct patch_table res_patch_table[] = { - {VIA_RES_1024X768, ARRAY_SIZE(PM1024x768), PM1024x768} + {ARRAY_SIZE(PM1024x768), PM1024x768} }; /* struct VPITTable { @@ -879,169 +879,151 @@ struct crt_mode_table CRTM2048x1536[] = { {2800, 2048, 2048, 752, 2200, 224, 1592, 1536, 1536, 56, 1539, 4} } }; -/* Video Mode Table */ -/* struct VideoModeTable {*/ -/* int ModeIndex;*/ -/* struct crt_mode_table *crtc;*/ -/* int mode_array;*/ -/* };*/ -struct VideoModeTable CLE266Modes[] = { +struct VideoModeTable viafb_modes[] = { /* Display : 480x640 (GTF) */ - {VIA_RES_480X640, CRTM480x640, ARRAY_SIZE(CRTM480x640)}, + {CRTM480x640, ARRAY_SIZE(CRTM480x640)}, /* Display : 640x480 */ - {VIA_RES_640X480, CRTM640x480, ARRAY_SIZE(CRTM640x480)}, + {CRTM640x480, ARRAY_SIZE(CRTM640x480)}, /* Display : 720x480 (GTF) */ - {VIA_RES_720X480, CRTM720x480, ARRAY_SIZE(CRTM720x480)}, + {CRTM720x480, ARRAY_SIZE(CRTM720x480)}, /* Display : 720x576 (GTF) */ - {VIA_RES_720X576, CRTM720x576, ARRAY_SIZE(CRTM720x576)}, + {CRTM720x576, ARRAY_SIZE(CRTM720x576)}, /* Display : 800x600 */ - {VIA_RES_800X600, CRTM800x600, ARRAY_SIZE(CRTM800x600)}, + {CRTM800x600, ARRAY_SIZE(CRTM800x600)}, /* Display : 800x480 (CVT) */ - {VIA_RES_800X480, CRTM800x480, ARRAY_SIZE(CRTM800x480)}, + {CRTM800x480, ARRAY_SIZE(CRTM800x480)}, /* Display : 848x480 (CVT) */ - {VIA_RES_848X480, CRTM848x480, ARRAY_SIZE(CRTM848x480)}, + {CRTM848x480, ARRAY_SIZE(CRTM848x480)}, /* Display : 852x480 (GTF) */ - {VIA_RES_856X480, CRTM852x480, ARRAY_SIZE(CRTM852x480)}, + {CRTM852x480, ARRAY_SIZE(CRTM852x480)}, /* Display : 1024x512 (GTF) */ - {VIA_RES_1024X512, CRTM1024x512, ARRAY_SIZE(CRTM1024x512)}, + {CRTM1024x512, ARRAY_SIZE(CRTM1024x512)}, /* Display : 1024x600 */ - {VIA_RES_1024X600, CRTM1024x600, ARRAY_SIZE(CRTM1024x600)}, - - /* Display : 1024x576 (GTF) */ - /*{ VIA_RES_1024X576, CRTM1024x576, ARRAY_SIZE(CRTM1024x576)}, */ + {CRTM1024x600, ARRAY_SIZE(CRTM1024x600)}, /* Display : 1024x768 */ - {VIA_RES_1024X768, CRTM1024x768, ARRAY_SIZE(CRTM1024x768)}, + {CRTM1024x768, ARRAY_SIZE(CRTM1024x768)}, /* Display : 1152x864 */ - {VIA_RES_1152X864, CRTM1152x864, ARRAY_SIZE(CRTM1152x864)}, + {CRTM1152x864, ARRAY_SIZE(CRTM1152x864)}, /* Display : 1280x768 (GTF) */ - {VIA_RES_1280X768, CRTM1280x768, ARRAY_SIZE(CRTM1280x768)}, + {CRTM1280x768, ARRAY_SIZE(CRTM1280x768)}, /* Display : 960x600 (CVT) */ - {VIA_RES_960X600, CRTM960x600, ARRAY_SIZE(CRTM960x600)}, + {CRTM960x600, ARRAY_SIZE(CRTM960x600)}, /* Display : 1000x600 (GTF) */ - {VIA_RES_1000X600, CRTM1000x600, ARRAY_SIZE(CRTM1000x600)}, + {CRTM1000x600, ARRAY_SIZE(CRTM1000x600)}, /* Display : 1024x576 (GTF) */ - {VIA_RES_1024X576, CRTM1024x576, ARRAY_SIZE(CRTM1024x576)}, + {CRTM1024x576, ARRAY_SIZE(CRTM1024x576)}, /* Display : 1088x612 (GTF) */ - {VIA_RES_1088X612, CRTM1088x612, ARRAY_SIZE(CRTM1088x612)}, + {CRTM1088x612, ARRAY_SIZE(CRTM1088x612)}, /* Display : 1152x720 (CVT) */ - {VIA_RES_1152X720, CRTM1152x720, ARRAY_SIZE(CRTM1152x720)}, + {CRTM1152x720, ARRAY_SIZE(CRTM1152x720)}, /* Display : 1200x720 (GTF) */ - {VIA_RES_1200X720, CRTM1200x720, ARRAY_SIZE(CRTM1200x720)}, + {CRTM1200x720, ARRAY_SIZE(CRTM1200x720)}, /* Display : 1280x600 (GTF) */ - {VIA_RES_1280X600, CRTM1280x600, ARRAY_SIZE(CRTM1280x600)}, + {CRTM1280x600, ARRAY_SIZE(CRTM1280x600)}, /* Display : 1280x800 (CVT) */ - {VIA_RES_1280X800, CRTM1280x800, ARRAY_SIZE(CRTM1280x800)}, - - /* Display : 1280x800 (GTF) */ - /*{ M1280x800, CRTM1280x800, ARRAY_SIZE(CRTM1280x800)}, */ + {CRTM1280x800, ARRAY_SIZE(CRTM1280x800)}, /* Display : 1280x960 */ - {VIA_RES_1280X960, CRTM1280x960, ARRAY_SIZE(CRTM1280x960)}, + {CRTM1280x960, ARRAY_SIZE(CRTM1280x960)}, /* Display : 1280x1024 */ - {VIA_RES_1280X1024, CRTM1280x1024, ARRAY_SIZE(CRTM1280x1024)}, + {CRTM1280x1024, ARRAY_SIZE(CRTM1280x1024)}, /* Display : 1360x768 (CVT) */ - {VIA_RES_1360X768, CRTM1360x768, ARRAY_SIZE(CRTM1360x768)}, - - /* Display : 1360x768 (CVT Reduce Blanking) */ - {VIA_RES_1360X768_RB, CRTM1360x768_RB, - ARRAY_SIZE(CRTM1360x768_RB)}, + {CRTM1360x768, ARRAY_SIZE(CRTM1360x768)}, /* Display : 1366x768 */ - {VIA_RES_1366X768, CRTM1366x768, ARRAY_SIZE(CRTM1366x768)}, + {CRTM1366x768, ARRAY_SIZE(CRTM1366x768)}, /* Display : 1368x768 (GTF) */ - /*{ M1368x768,CRTM1368x768,ARRAY_SIZE(CRTM1368x768)}, */ - /* Display : 1368x768 (GTF) */ - {VIA_RES_1368X768, CRTM1368x768, ARRAY_SIZE(CRTM1368x768)}, + {CRTM1368x768, ARRAY_SIZE(CRTM1368x768)}, /* Display : 1440x900 (CVT) */ - {VIA_RES_1440X900, CRTM1440x900, ARRAY_SIZE(CRTM1440x900)}, - - /* Display : 1440x900 (CVT Reduce Blanking) */ - {VIA_RES_1440X900_RB, CRTM1440x900_RB, - ARRAY_SIZE(CRTM1440x900_RB)}, + {CRTM1440x900, ARRAY_SIZE(CRTM1440x900)}, /* Display : 1440x1050 (GTF) */ - {VIA_RES_1440X1050, CRTM1440x1050, ARRAY_SIZE(CRTM1440x1050)}, - - /* Display : 1400x1050 (CVT Reduce Blanking) */ - {VIA_RES_1400X1050_RB, CRTM1400x1050_RB, - ARRAY_SIZE(CRTM1400x1050_RB)}, + {CRTM1440x1050, ARRAY_SIZE(CRTM1440x1050)}, /* Display : 1600x900 (CVT) */ - {VIA_RES_1600X900, CRTM1600x900, ARRAY_SIZE(CRTM1600x900)}, - - /* Display : 1600x900 (CVT Reduce Blanking) */ - {VIA_RES_1600X900_RB, CRTM1600x900_RB, - ARRAY_SIZE(CRTM1600x900_RB)}, + {CRTM1600x900, ARRAY_SIZE(CRTM1600x900)}, /* Display : 1600x1024 (GTF) */ - {VIA_RES_1600X1024, CRTM1600x1024, ARRAY_SIZE(CRTM1600x1024)}, + {CRTM1600x1024, ARRAY_SIZE(CRTM1600x1024)}, /* Display : 1600x1200 */ - {VIA_RES_1600X1200, CRTM1600x1200, ARRAY_SIZE(CRTM1600x1200)}, + {CRTM1600x1200, ARRAY_SIZE(CRTM1600x1200)}, /* Display : 1680x1050 (CVT) */ - {VIA_RES_1680X1050, CRTM1680x1050, ARRAY_SIZE(CRTM1680x1050)}, - - /* Display : 1680x1050 (CVT Reduce Blanking) */ - {VIA_RES_1680X1050_RB, CRTM1680x1050_RB, - ARRAY_SIZE(CRTM1680x1050_RB)}, + {CRTM1680x1050, ARRAY_SIZE(CRTM1680x1050)}, /* Display : 1792x1344 (DMT) */ - {VIA_RES_1792X1344, CRTM1792x1344, ARRAY_SIZE(CRTM1792x1344)}, + {CRTM1792x1344, ARRAY_SIZE(CRTM1792x1344)}, /* Display : 1856x1392 (DMT) */ - {VIA_RES_1856X1392, CRTM1856x1392, ARRAY_SIZE(CRTM1856x1392)}, + {CRTM1856x1392, ARRAY_SIZE(CRTM1856x1392)}, /* Display : 1920x1440 */ - {VIA_RES_1920X1440, CRTM1920x1440, ARRAY_SIZE(CRTM1920x1440)}, + {CRTM1920x1440, ARRAY_SIZE(CRTM1920x1440)}, /* Display : 2048x1536 */ - {VIA_RES_2048X1536, CRTM2048x1536, ARRAY_SIZE(CRTM2048x1536)}, + {CRTM2048x1536, ARRAY_SIZE(CRTM2048x1536)}, /* Display : 1280x720 */ - {VIA_RES_1280X720, CRTM1280x720, ARRAY_SIZE(CRTM1280x720)}, + {CRTM1280x720, ARRAY_SIZE(CRTM1280x720)}, /* Display : 1920x1080 (CVT) */ - {VIA_RES_1920X1080, CRTM1920x1080, ARRAY_SIZE(CRTM1920x1080)}, - - /* Display : 1920x1080 (CVT Reduce Blanking) */ - {VIA_RES_1920X1080_RB, CRTM1920x1080_RB, - ARRAY_SIZE(CRTM1920x1080_RB)}, + {CRTM1920x1080, ARRAY_SIZE(CRTM1920x1080)}, /* Display : 1920x1200 (CVT) */ - {VIA_RES_1920X1200, CRTM1920x1200, ARRAY_SIZE(CRTM1920x1200)}, - - /* Display : 1920x1200 (CVT Reduce Blanking) */ - {VIA_RES_1920X1200_RB, CRTM1920x1200_RB, - ARRAY_SIZE(CRTM1920x1200_RB)}, + {CRTM1920x1200, ARRAY_SIZE(CRTM1920x1200)}, /* Display : 1400x1050 (CVT) */ - {VIA_RES_1400X1050, CRTM1400x1050, ARRAY_SIZE(CRTM1400x1050)} + {CRTM1400x1050, ARRAY_SIZE(CRTM1400x1050)} }; + +struct VideoModeTable viafb_rb_modes[] = { + /* Display : 1360x768 (CVT Reduce Blanking) */ + {CRTM1360x768_RB, ARRAY_SIZE(CRTM1360x768_RB)}, + + /* Display : 1440x900 (CVT Reduce Blanking) */ + {CRTM1440x900_RB, ARRAY_SIZE(CRTM1440x900_RB)}, + + /* Display : 1400x1050 (CVT Reduce Blanking) */ + {CRTM1400x1050_RB, ARRAY_SIZE(CRTM1400x1050_RB)}, + + /* Display : 1600x900 (CVT Reduce Blanking) */ + {CRTM1600x900_RB, ARRAY_SIZE(CRTM1600x900_RB)}, + + /* Display : 1680x1050 (CVT Reduce Blanking) */ + {CRTM1680x1050_RB, ARRAY_SIZE(CRTM1680x1050_RB)}, + + /* Display : 1920x1080 (CVT Reduce Blanking) */ + {CRTM1920x1080_RB, ARRAY_SIZE(CRTM1920x1080_RB)}, + + /* Display : 1920x1200 (CVT Reduce Blanking) */ + {CRTM1920x1200_RB, ARRAY_SIZE(CRTM1920x1200_RB)} +}; + struct crt_mode_table CEAM1280x720[] = { {REFRESH_60, CLK_74_270M, M1280X720_CEA_R60_HSP, M1280X720_CEA_R60_VSP, @@ -1056,8 +1038,8 @@ struct crt_mode_table CEAM1920x1080[] = { }; struct VideoModeTable CEA_HDMI_Modes[] = { /* Display : 1280x720 */ - {VIA_RES_1280X720, CEAM1280x720, ARRAY_SIZE(CEAM1280x720)}, - {VIA_RES_1920X1080, CEAM1920x1080, ARRAY_SIZE(CEAM1920x1080)} + {CEAM1280x720, ARRAY_SIZE(CEAM1280x720)}, + {CEAM1920x1080, ARRAY_SIZE(CEAM1920x1080)} }; int NUM_TOTAL_RES_MAP_REFRESH = ARRAY_SIZE(res_map_refresh_tbl); @@ -1069,4 +1051,28 @@ int NUM_TOTAL_CX700_ModeXregs = ARRAY_SIZE(CX700_ModeXregs); int NUM_TOTAL_VX855_ModeXregs = ARRAY_SIZE(VX855_ModeXregs); int NUM_TOTAL_CLE266_ModeXregs = ARRAY_SIZE(CLE266_ModeXregs); int NUM_TOTAL_PATCH_MODE = ARRAY_SIZE(res_patch_table); -int NUM_TOTAL_MODETABLE = ARRAY_SIZE(CLE266Modes); + + +struct VideoModeTable *viafb_get_mode(int hres, int vres) +{ + u32 i; + for (i = 0; i < ARRAY_SIZE(viafb_modes); i++) + if (viafb_modes[i].mode_array && + viafb_modes[i].crtc[0].crtc.hor_addr == hres && + viafb_modes[i].crtc[0].crtc.ver_addr == vres) + return &viafb_modes[i]; + + return NULL; +} + +struct VideoModeTable *viafb_get_rb_mode(int hres, int vres) +{ + u32 i; + for (i = 0; i < ARRAY_SIZE(viafb_rb_modes); i++) + if (viafb_rb_modes[i].mode_array && + viafb_rb_modes[i].crtc[0].crtc.hor_addr == hres && + viafb_rb_modes[i].crtc[0].crtc.ver_addr == vres) + return &viafb_rb_modes[i]; + + return NULL; +} |