viafb: get rid of the remaining modetable structure assumptions
authorFlorian Tobias Schandinat <FlorianSchandinat@gmx.de>
Sun, 7 Aug 2011 13:34:35 +0000 (13:34 +0000)
committerFlorian Tobias Schandinat <FlorianSchandinat@gmx.de>
Sun, 7 Aug 2011 13:34:35 +0000 (13:34 +0000)
This patch removes the remaining places where assumptions about the
structure of the modetable were made. Aside from some places where
assumptions are made that certain modes are in the modetable the
only code dealing with the modetable and not just a single mode is
in viamode. This will allow chaniging the modetable and use other
sources for videomodes like the subsystem or EDID.

Signed-off-by: Florian Tobias Schandinat <FlorianSchandinat@gmx.de>
drivers/video/via/global.c
drivers/video/via/global.h
drivers/video/via/hw.c
drivers/video/via/hw.h
drivers/video/via/viafbdev.c
drivers/video/via/viamode.c
drivers/video/via/viamode.h

index e10d8249534c682543f0a43cfb9398240e357219..3102171c16743200ce3fc8e1462a00ffe1839fff 100644 (file)
@@ -35,6 +35,8 @@ int viafb_LCD_ON ;
 int viafb_LCD2_ON;
 int viafb_SAMM_ON;
 int viafb_dual_fb;
+unsigned int viafb_second_xres = 640;
+unsigned int viafb_second_yres = 480;
 int viafb_hotplug_Xres = 640;
 int viafb_hotplug_Yres = 480;
 int viafb_hotplug_bpp = 32;
index ff969dc3459352bbfea5df7dec88e111576584c3..275dbbbd6b81227ac690028588ac24c7691ffe8a 100644 (file)
@@ -67,6 +67,8 @@ extern int viafb_lcd_dsp_method;
 extern int viafb_lcd_mode;
 
 extern int viafb_CRT_ON;
+extern unsigned int viafb_second_xres;
+extern unsigned int viafb_second_yres;
 extern int viafb_hotplug_Xres;
 extern int viafb_hotplug_Yres;
 extern int viafb_hotplug_bpp;
index 30668bd17875266b49013ad4bc96efd8bcc25474..d5aaca9cfa7e2b7b6a4e5770b5965cbc199e262a 100644 (file)
@@ -1840,23 +1840,16 @@ static void hw_init(void)
        load_fix_bit_crtc_reg();
 }
 
-int viafb_setmode(struct VideoModeTable *vmode_tbl, int video_bpp,
-       struct VideoModeTable *vmode_tbl1, int video_bpp1)
+int viafb_setmode(int video_bpp, int video_bpp1)
 {
        int j;
        int port;
        u32 devices = viaparinfo->shared->iga1_devices
                | viaparinfo->shared->iga2_devices;
        u8 value, index, mask;
-       struct crt_mode_table *crt_timing;
-       struct crt_mode_table *crt_timing1 = NULL;
        struct fb_var_screeninfo var2;
 
        device_screen_off();
-       crt_timing = vmode_tbl->crtc;
-       if (viafb_SAMM_ON == 1)
-               crt_timing1 = vmode_tbl1->crtc;
-
        device_off();
        via_set_state(devices, VIA_STATE_OFF);
 
@@ -1865,9 +1858,8 @@ int viafb_setmode(struct VideoModeTable *vmode_tbl, int video_bpp,
        /* Update Patch Register */
 
        if ((viaparinfo->chip_info->gfx_chip_name == UNICHROME_CLE266
-           || viaparinfo->chip_info->gfx_chip_name == UNICHROME_K400)
-           && vmode_tbl->crtc[0].crtc.hor_addr == 1024
-           && vmode_tbl->crtc[0].crtc.ver_addr == 768) {
+               || viaparinfo->chip_info->gfx_chip_name == UNICHROME_K400)
+               && viafbinfo->var.xres == 1024 && viafbinfo->var.yres == 768) {
                for (j = 0; j < res_patch_table[0].table_length; j++) {
                        index = res_patch_table[0].io_reg_table[j].index;
                        port = res_patch_table[0].io_reg_table[j].port;
@@ -1898,8 +1890,7 @@ int viafb_setmode(struct VideoModeTable *vmode_tbl, int video_bpp,
                var2 = viafbinfo1->var;
        } else if (viafb_SAMM_ON) {
                viafb_fill_var_timing_info(&var2, viafb_get_best_mode(
-                       vmode_tbl1->crtc->crtc.hor_addr,
-                       vmode_tbl1->crtc->crtc.ver_addr, viafb_refresh1));
+                       viafb_second_xres, viafb_second_yres, viafb_refresh1));
                var2.bits_per_pixel = viafbinfo->var.bits_per_pixel;
        }
 
@@ -1916,7 +1907,7 @@ int viafb_setmode(struct VideoModeTable *vmode_tbl, int video_bpp,
                /* Patch if set_hres is not 8 alignment (1366) to viafb_setmode
                to 8 alignment (1368),there is several pixels (2 pixels)
                on right side of screen. */
-               if (vmode_tbl->crtc[0].crtc.hor_addr % 8) {
+               if (viafbinfo->var.xres % 8) {
                        viafb_unlock_crt();
                        viafb_write_reg(CR02, VIACR,
                                viafb_read_reg(VIACR, CR02) - 1);
@@ -1974,8 +1965,8 @@ int viafb_setmode(struct VideoModeTable *vmode_tbl, int video_bpp,
 
        /* If set mode normally, save resolution information for hot-plug . */
        if (!viafb_hotplug) {
-               viafb_hotplug_Xres = vmode_tbl->crtc[0].crtc.hor_addr;
-               viafb_hotplug_Yres = vmode_tbl->crtc[0].crtc.ver_addr;
+               viafb_hotplug_Xres = viafbinfo->var.xres;
+               viafb_hotplug_Yres = viafbinfo->var.yres;
                viafb_hotplug_bpp = video_bpp;
                viafb_hotplug_refresh = viafb_refresh;
 
index 46f65da11e771234afaa00a78e9b3ac23574ff11..4db5b6e8d8d092cfe4ad59f922010552277d40a0 100644 (file)
@@ -657,8 +657,7 @@ void viafb_load_FIFO_reg(int set_iga, int hor_active, int ver_active);
 void viafb_set_dpa_gfx(int output_interface, struct GFX_DPA_SETTING\
                                        *p_gfx_dpa_setting);
 
-int viafb_setmode(struct VideoModeTable *vmode_tbl, int video_bpp,
-       struct VideoModeTable *vmode_tbl1, int video_bpp1);
+int viafb_setmode(int video_bpp, int video_bpp1);
 void viafb_fill_var_timing_info(struct fb_var_screeninfo *var,
        struct crt_mode_table *mode);
 void __devinit viafb_init_chip_info(int chip_type);
index 0c0ef9568cf34893868942e0da8920ff0c45ca04..38567849a9d68f666db77bc96687af292be557b9 100644 (file)
@@ -38,8 +38,6 @@ static char *viafb_mode1;
 static int viafb_bpp = 32;
 static int viafb_bpp1 = 32;
 
-static unsigned int viafb_second_xres = 640;
-static unsigned int viafb_second_yres = 480;
 static unsigned int viafb_second_offset;
 static int viafb_second_size;
 
@@ -267,7 +265,6 @@ static int viafb_check_var(struct fb_var_screeninfo *var,
 static int viafb_set_par(struct fb_info *info)
 {
        struct viafb_par *viapar = info->par;
-       struct VideoModeTable *vmode_entry, *vmode_entry1 = NULL;
        int refresh;
        DEBUG_MSG(KERN_INFO "viafb_set_par!\n");
 
@@ -276,10 +273,7 @@ static int viafb_set_par(struct fb_info *info)
        viafb_update_device_setting(viafbinfo->var.xres, viafbinfo->var.yres,
                viafbinfo->var.bits_per_pixel, 0);
 
-       vmode_entry = viafb_get_mode(viafbinfo->var.xres, viafbinfo->var.yres);
        if (viafb_dual_fb) {
-               vmode_entry1 = viafb_get_mode(viafbinfo1->var.xres,
-                       viafbinfo1->var.yres);
                viafb_update_device_setting(viafbinfo1->var.xres,
                        viafbinfo1->var.yres, viafbinfo1->var.bits_per_pixel,
                        1);
@@ -287,8 +281,6 @@ static int viafb_set_par(struct fb_info *info)
                DEBUG_MSG(KERN_INFO
                "viafb_second_xres = %d, viafb_second_yres = %d, bpp = %d\n",
                          viafb_second_xres, viafb_second_yres, viafb_bpp1);
-               vmode_entry1 = viafb_get_mode(viafb_second_xres,
-                       viafb_second_yres);
 
                viafb_update_device_setting(viafb_second_xres,
                        viafb_second_yres, viafb_bpp1, 1);
@@ -296,7 +288,8 @@ static int viafb_set_par(struct fb_info *info)
 
        refresh = viafb_get_refresh(info->var.xres, info->var.yres,
                get_var_refresh(&info->var));
-       if (vmode_entry) {
+       if (viafb_get_best_mode(viafbinfo->var.xres, viafbinfo->var.yres,
+               refresh)) {
                if (viafb_dual_fb && viapar->iga_path == IGA2) {
                        viafb_bpp1 = info->var.bits_per_pixel;
                        viafb_refresh1 = refresh;
@@ -309,8 +302,7 @@ static int viafb_set_par(struct fb_info *info)
                        info->flags &= ~FBINFO_HWACCEL_DISABLED;
                else
                        info->flags |= FBINFO_HWACCEL_DISABLED;
-               viafb_setmode(vmode_entry, info->var.bits_per_pixel,
-                       vmode_entry1, viafb_bpp1);
+               viafb_setmode(info->var.bits_per_pixel, viafb_bpp1);
                viafb_pan_display(&info->var, info);
        }
 
index 88096e5fa07727e6723b63d40a23f983fa50da43..0911cac1b2ffb9cd3731b0c77f3040f035231f04 100644 (file)
@@ -896,7 +896,7 @@ static struct crt_mode_table *get_best_mode(struct VideoModeTable *vmt,
        return best;
 }
 
-struct VideoModeTable *viafb_get_mode(int hres, int vres)
+static struct VideoModeTable *viafb_get_mode(int hres, int vres)
 {
        return get_modes(viafb_modes, ARRAY_SIZE(viafb_modes), hres, vres);
 }
@@ -906,7 +906,7 @@ struct crt_mode_table *viafb_get_best_mode(int hres, int vres, int refresh)
        return get_best_mode(viafb_get_mode(hres, vres), refresh);
 }
 
-struct VideoModeTable *viafb_get_rb_mode(int hres, int vres)
+static struct VideoModeTable *viafb_get_rb_mode(int hres, int vres)
 {
        return get_modes(viafb_rb_modes, ARRAY_SIZE(viafb_rb_modes), hres,
                vres);
index 0396581b977521a4a556903eb41e58b8db7010ad..5917a2b00e1ba7b69dec0b0d3bcc262bfc4b9e0b 100644 (file)
@@ -60,9 +60,7 @@ extern struct io_reg PM1024x768[];
 extern struct patch_table res_patch_table[];
 extern struct VPITTable VPIT;
 
-struct VideoModeTable *viafb_get_mode(int hres, int vres);
 struct crt_mode_table *viafb_get_best_mode(int hres, int vres, int refresh);
-struct VideoModeTable *viafb_get_rb_mode(int hres, int vres);
 struct crt_mode_table *viafb_get_best_rb_mode(int hres, int vres, int refresh);
 
 #endif /* __VIAMODE_H__ */