viafb: remove duplicated mode information
[cascardo/linux.git] / drivers / video / via / viafbdev.c
index 72833f3..50e9300 100644 (file)
@@ -53,68 +53,19 @@ static void retrieve_device_setting(struct viafb_ioctl_setting
 static void viafb_set_video_device(u32 video_dev_info);
 static void viafb_get_video_device(u32 *video_dev_info);
 
-/* Mode information */
-static const struct viafb_modeinfo viafb_modentry[] = {
-       {480, 640, VIA_RES_480X640},
-       {640, 480, VIA_RES_640X480},
-       {800, 480, VIA_RES_800X480},
-       {800, 600, VIA_RES_800X600},
-       {1024, 768, VIA_RES_1024X768},
-       {1152, 864, VIA_RES_1152X864},
-       {1280, 1024, VIA_RES_1280X1024},
-       {1600, 1200, VIA_RES_1600X1200},
-       {1440, 1050, VIA_RES_1440X1050},
-       {1280, 768, VIA_RES_1280X768,},
-       {1280, 800, VIA_RES_1280X800},
-       {1280, 960, VIA_RES_1280X960},
-       {1920, 1440, VIA_RES_1920X1440},
-       {848, 480, VIA_RES_848X480},
-       {1400, 1050, VIA_RES_1400X1050},
-       {720, 480, VIA_RES_720X480},
-       {720, 576, VIA_RES_720X576},
-       {1024, 512, VIA_RES_1024X512},
-       {1024, 576, VIA_RES_1024X576},
-       {1024, 600, VIA_RES_1024X600},
-       {1280, 720, VIA_RES_1280X720},
-       {1920, 1080, VIA_RES_1920X1080},
-       {1366, 768, VIA_RES_1368X768},
-       {1680, 1050, VIA_RES_1680X1050},
-       {960, 600, VIA_RES_960X600},
-       {1000, 600, VIA_RES_1000X600},
-       {1024, 576, VIA_RES_1024X576},
-       {1024, 600, VIA_RES_1024X600},
-       {1088, 612, VIA_RES_1088X612},
-       {1152, 720, VIA_RES_1152X720},
-       {1200, 720, VIA_RES_1200X720},
-       {1280, 600, VIA_RES_1280X600},
-       {1360, 768, VIA_RES_1360X768},
-       {1440, 900, VIA_RES_1440X900},
-       {1600, 900, VIA_RES_1600X900},
-       {1600, 1024, VIA_RES_1600X1024},
-       {1792, 1344, VIA_RES_1792X1344},
-       {1856, 1392, VIA_RES_1856X1392},
-       {1920, 1200, VIA_RES_1920X1200},
-       {2048, 1536, VIA_RES_2048X1536},
-       {0, 0, VIA_RES_INVALID}
-};
-
 static struct fb_ops viafb_ops;
 
-static int viafb_update_fix(struct fb_fix_screeninfo *fix, struct fb_info *info)
-{
-       struct viafb_par *ppar;
-       ppar = info->par;
-
-       DEBUG_MSG(KERN_INFO "viafb_update_fix!\n");
 
-       fix->visual =
-           ppar->bpp == 8 ? FB_VISUAL_PSEUDOCOLOR : FB_VISUAL_TRUECOLOR;
-       fix->line_length = ppar->linelength;
+static void viafb_update_fix(struct fb_info *info)
+{
+       u32 bpp = info->var.bits_per_pixel;
 
-       return 0;
+       info->fix.visual =
+               bpp == 8 ? FB_VISUAL_PSEUDOCOLOR : FB_VISUAL_TRUECOLOR;
+       info->fix.line_length =
+               ((info->var.xres_virtual + 7) & ~7) * bpp / 8;
 }
 
-
 static void viafb_setup_fixinfo(struct fb_fix_screeninfo *fix,
        struct viafb_par *viaparinfo)
 {
@@ -147,19 +98,6 @@ static int viafb_release(struct fb_info *info, int user)
        return 0;
 }
 
-static void viafb_update_viafb_par(struct fb_info *info)
-{
-       struct viafb_par *ppar;
-
-       ppar = info->par;
-       ppar->bpp = info->var.bits_per_pixel;
-       ppar->linelength = ((info->var.xres_virtual + 7) & ~7) * ppar->bpp / 8;
-       ppar->hres = info->var.xres;
-       ppar->vres = info->var.yres;
-       ppar->xoffset = info->var.xoffset;
-       ppar->yoffset = info->var.yoffset;
-}
-
 static int viafb_check_var(struct fb_var_screeninfo *var,
        struct fb_info *info)
 {
@@ -255,12 +193,7 @@ static int viafb_set_par(struct fb_info *info)
                /*We should set memory offset according virtual_x */
                /*Fix me:put this function into viafb_setmode */
                viafb_memory_pitch_patch(info);
-
-               /* Update ***fb_par information */
-               viafb_update_viafb_par(info);
-
-               /* Update other fixed information */
-               viafb_update_fix(&info->fix, info);
+               viafb_update_fix(info);
                viafb_bpp = info->var.bits_per_pixel;
                /* Update viafb_accel, it is necessary to our 2D accelerate */
                viafb_accel = info->var.accel_flags;
@@ -503,12 +436,7 @@ static int viafb_pan_display(struct fb_var_screeninfo *var,
            var->bits_per_pixel / 16;
 
        DEBUG_MSG(KERN_INFO "\nviafb_pan_display,offset =%d ", offset);
-
-       viafb_write_reg_mask(0x48, 0x3d4, ((offset >> 24) & 0x3), 0x3);
-       viafb_write_reg_mask(0x34, 0x3d4, ((offset >> 16) & 0xff), 0xff);
-       viafb_write_reg_mask(0x0c, 0x3d4, ((offset >> 8) & 0xff), 0xff);
-       viafb_write_reg_mask(0x0d, 0x3d4, (offset & 0xff), 0xff);
-
+       viafb_set_primary_address(offset);
        return 0;
 }
 
@@ -1266,12 +1194,16 @@ int viafb_get_mode_index(int hres, int vres)
        u32 i;
        DEBUG_MSG(KERN_INFO "viafb_get_mode_index!\n");
 
-       for (i = 0; viafb_modentry[i].mode_index != VIA_RES_INVALID; i++)
-               if (viafb_modentry[i].xres == hres &&
-                       viafb_modentry[i].yres == vres)
+       for (i = 0; i < NUM_TOTAL_MODETABLE; i++)
+               if (CLE266Modes[i].mode_array &&
+                       CLE266Modes[i].crtc[0].crtc.hor_addr == hres &&
+                       CLE266Modes[i].crtc[0].crtc.ver_addr == vres)
                        break;
 
-       return viafb_modentry[i].mode_index;
+       if (i == NUM_TOTAL_MODETABLE)
+               return VIA_RES_INVALID;
+
+       return CLE266Modes[i].ModeIndex;
 }
 
 static void check_available_device_to_enable(int device_id)
@@ -1375,7 +1307,8 @@ static void viafb_set_device(struct device_t active_dev)
                viafb_SAMM_ON = active_dev.samm;
        viafb_primary_dev = active_dev.primary_dev;
 
-       viafb_set_start_addr();
+       viafb_set_primary_address(0);
+       viafb_set_secondary_address(viafb_SAMM_ON ? viafb_second_offset : 0);
        viafb_set_iga_path();
 }
 
@@ -1559,7 +1492,8 @@ static int apply_device_setting(struct viafb_ioctl_setting setting_info,
                        if (viafb_SAMM_ON)
                                viafb_primary_dev = setting_info.primary_device;
 
-                       viafb_set_start_addr();
+                       viafb_set_primary_address(0);
+                       viafb_set_secondary_address(viafb_SAMM_ON ? viafb_second_offset : 0);
                        viafb_set_iga_path();
                }
                need_set_mode = 1;
@@ -2159,12 +2093,16 @@ static int __devinit via_pci_probe(void)
 
        if (!viaparinfo->fbmem_virt) {
                printk(KERN_INFO "ioremap failed\n");
-               return -1;
+               return -ENOMEM;
        }
 
        viafb_get_mmio_info(&viaparinfo->mmio_base, &viaparinfo->mmio_len);
        viaparinfo->io_virt = ioremap_nocache(viaparinfo->mmio_base,
                viaparinfo->mmio_len);
+       if (!viaparinfo->io_virt) {
+               printk(KERN_WARNING "ioremap failed: hardware acceleration disabled\n");
+               viafb_accel = 0;
+       }
 
        viafbinfo->node = 0;
        viafbinfo->fbops = &viafb_ops;
@@ -2297,6 +2235,8 @@ static int __devinit via_pci_probe(void)
                                viafb_second_offset;
                }
 
+               viaparinfo->iga_path = IGA1;
+               viaparinfo1->iga_path = IGA2;
                memcpy(viafbinfo1, viafbinfo, sizeof(struct fb_info));
                viafbinfo1->screen_base = viafbinfo->screen_base +
                        viafb_second_offset;
@@ -2323,15 +2263,13 @@ static int __devinit via_pci_probe(void)
                viafb_setup_fixinfo(&viafbinfo1->fix, viaparinfo1);
                viafb_check_var(&default_var, viafbinfo1);
                viafbinfo1->var = default_var;
-               viafb_update_viafb_par(viafbinfo);
-               viafb_update_fix(&viafbinfo1->fix, viafbinfo1);
+               viafb_update_fix(viafbinfo1);
        }
 
        viafb_setup_fixinfo(&viafbinfo->fix, viaparinfo);
        viafb_check_var(&default_var, viafbinfo);
        viafbinfo->var = default_var;
-       viafb_update_viafb_par(viafbinfo);
-       viafb_update_fix(&viafbinfo->fix, viafbinfo);
+       viafb_update_fix(viafbinfo);
        default_var.activate = FB_ACTIVATE_NOW;
        fb_alloc_cmap(&viafbinfo->cmap, 256, 0);