drm/radeon/kms/combios: match lvds panel info parsing to ddx
[deliverable/linux.git] / drivers / gpu / drm / radeon / radeon_combios.c
index 2becdeda68a34ae4d94d8102f33d0d87fe6de959..44198581ba9efedea1dcc59a5d2083b756e2cea2 100644 (file)
@@ -450,17 +450,17 @@ bool radeon_combios_check_hardcoded_edid(struct radeon_device *rdev)
 {
        int edid_info;
        struct edid *edid;
+       unsigned char *raw;
        edid_info = combios_get_table_offset(rdev->ddev, COMBIOS_HARDCODED_EDID_TABLE);
        if (!edid_info)
                return false;
 
-       edid = kmalloc(EDID_LENGTH * (DRM_MAX_EDID_EXT_NUM + 1),
-                      GFP_KERNEL);
+       raw = rdev->bios + edid_info;
+       edid = kmalloc(EDID_LENGTH * (raw[0x7e] + 1), GFP_KERNEL);
        if (edid == NULL)
                return false;
 
-       memcpy((unsigned char *)edid,
-              (unsigned char *)(rdev->bios + edid_info), EDID_LENGTH);
+       memcpy((unsigned char *)edid, raw, EDID_LENGTH * (raw[0x7e] + 1));
 
        if (!drm_edid_is_valid(edid)) {
                kfree(edid);
@@ -760,7 +760,9 @@ struct radeon_encoder_primary_dac *radeon_combios_get_primary_dac_info(struct
                        dac = RBIOS8(dac_info + 0x3) & 0xf;
                        p_dac->ps2_pdac_adj = (bg << 8) | (dac);
                }
-               found = 1;
+               /* if the values are all zeros, use the table */
+               if (p_dac->ps2_pdac_adj)
+                       found = 1;
        }
 
        if (!found) /* fallback to defaults */
@@ -895,7 +897,9 @@ struct radeon_encoder_tv_dac *radeon_combios_get_tv_dac_info(struct
                        bg = RBIOS8(dac_info + 0x10) & 0xf;
                        dac = RBIOS8(dac_info + 0x11) & 0xf;
                        tv_dac->ntsc_tvdac_adj = (bg << 16) | (dac << 20);
-                       found = 1;
+                       /* if the values are all zeros, use the table */
+                       if (tv_dac->ps2_tvdac_adj)
+                               found = 1;
                } else if (rev > 1) {
                        bg = RBIOS8(dac_info + 0xc) & 0xf;
                        dac = (RBIOS8(dac_info + 0xc) >> 4) & 0xf;
@@ -908,7 +912,9 @@ struct radeon_encoder_tv_dac *radeon_combios_get_tv_dac_info(struct
                        bg = RBIOS8(dac_info + 0xe) & 0xf;
                        dac = (RBIOS8(dac_info + 0xe) >> 4) & 0xf;
                        tv_dac->ntsc_tvdac_adj = (bg << 16) | (dac << 20);
-                       found = 1;
+                       /* if the values are all zeros, use the table */
+                       if (tv_dac->ps2_tvdac_adj)
+                               found = 1;
                }
                tv_dac->tv_std = radeon_combios_get_tv_info(rdev);
        }
@@ -925,7 +931,9 @@ struct radeon_encoder_tv_dac *radeon_combios_get_tv_dac_info(struct
                                    (bg << 16) | (dac << 20);
                                tv_dac->pal_tvdac_adj = tv_dac->ps2_tvdac_adj;
                                tv_dac->ntsc_tvdac_adj = tv_dac->ps2_tvdac_adj;
-                               found = 1;
+                               /* if the values are all zeros, use the table */
+                               if (tv_dac->ps2_tvdac_adj)
+                                       found = 1;
                        } else {
                                bg = RBIOS8(dac_info + 0x4) & 0xf;
                                dac = RBIOS8(dac_info + 0x5) & 0xf;
@@ -933,7 +941,9 @@ struct radeon_encoder_tv_dac *radeon_combios_get_tv_dac_info(struct
                                    (bg << 16) | (dac << 20);
                                tv_dac->pal_tvdac_adj = tv_dac->ps2_tvdac_adj;
                                tv_dac->ntsc_tvdac_adj = tv_dac->ps2_tvdac_adj;
-                               found = 1;
+                               /* if the values are all zeros, use the table */
+                               if (tv_dac->ps2_tvdac_adj)
+                                       found = 1;
                        }
                } else {
                        DRM_INFO("No TV DAC info found in BIOS\n");
@@ -1103,18 +1113,20 @@ struct radeon_encoder_lvds *radeon_combios_get_lvds_info(struct radeon_encoder
                                break;
 
                        if ((RBIOS16(tmp) == lvds->native_mode.hdisplay) &&
-                           (RBIOS16(tmp + 2) ==
-                            lvds->native_mode.vdisplay)) {
-                               lvds->native_mode.htotal = RBIOS16(tmp + 17) * 8;
-                               lvds->native_mode.hsync_start = RBIOS16(tmp + 21) * 8;
-                               lvds->native_mode.hsync_end = (RBIOS8(tmp + 23) +
-                                                              RBIOS16(tmp + 21)) * 8;
-
-                               lvds->native_mode.vtotal = RBIOS16(tmp + 24);
-                               lvds->native_mode.vsync_start = RBIOS16(tmp + 28) & 0x7ff;
-                               lvds->native_mode.vsync_end =
-                                       ((RBIOS16(tmp + 28) & 0xf800) >> 11) +
-                                       (RBIOS16(tmp + 28) & 0x7ff);
+                           (RBIOS16(tmp + 2) == lvds->native_mode.vdisplay)) {
+                               lvds->native_mode.htotal = lvds->native_mode.hdisplay +
+                                       (RBIOS16(tmp + 17) - RBIOS16(tmp + 19)) * 8;
+                               lvds->native_mode.hsync_start = lvds->native_mode.hdisplay +
+                                       (RBIOS16(tmp + 21) - RBIOS16(tmp + 19) - 1) * 8;
+                               lvds->native_mode.hsync_end = lvds->native_mode.hsync_start +
+                                       (RBIOS8(tmp + 23) * 8);
+
+                               lvds->native_mode.vtotal = lvds->native_mode.vdisplay +
+                                       (RBIOS16(tmp + 24) - RBIOS16(tmp + 26));
+                               lvds->native_mode.vsync_start = lvds->native_mode.vdisplay +
+                                       ((RBIOS16(tmp + 28) & 0x7ff) - RBIOS16(tmp + 26));
+                               lvds->native_mode.vsync_end = lvds->native_mode.vsync_start +
+                                       ((RBIOS16(tmp + 28) & 0xf800) >> 11);
 
                                lvds->native_mode.clock = RBIOS16(tmp + 9) * 10;
                                lvds->native_mode.flags = 0;
This page took 0.027523 seconds and 5 git commands to generate.