drm/nouveau/dp: store unencoded link_bw everywhere
authorBen Skeggs <bskeggs@redhat.com>
Wed, 3 Aug 2011 23:55:44 +0000 (09:55 +1000)
committerBen Skeggs <bskeggs@redhat.com>
Tue, 20 Sep 2011 06:10:24 +0000 (16:10 +1000)
Signed-off-by: Ben Skeggs <bskeggs@redhat.com>
drivers/gpu/drm/nouveau/nouveau_bios.c
drivers/gpu/drm/nouveau/nouveau_connector.c
drivers/gpu/drm/nouveau/nouveau_dp.c

index b6efa8c7cdbf3c5b2edb5de5a82e0edd8a0d15f3..bea5df7cf93c32279e3ab9fa4d6c94dbf6a9d575 100644 (file)
@@ -6199,7 +6199,14 @@ parse_dcb20_entry(struct drm_device *dev, struct dcb_table *dcb,
        }
        case OUTPUT_DP:
                entry->dpconf.sor.link = (conf & 0x00000030) >> 4;
-               entry->dpconf.link_bw = (conf & 0x00e00000) >> 21;
+               switch ((conf & 0x00e00000) >> 21) {
+               case 0:
+                       entry->dpconf.link_bw = 162000;
+                       break;
+               default:
+                       entry->dpconf.link_bw = 270000;
+                       break;
+               }
                switch ((conf & 0x0f000000) >> 24) {
                case 0xf:
                        entry->dpconf.link_nr = 4;
index 5308024ce56ab6247ec0df817900ee30a562f65c..e0d275e1c96c05c302693c49b7093cde95eccc40 100644 (file)
@@ -708,11 +708,8 @@ nouveau_connector_mode_valid(struct drm_connector *connector,
        case OUTPUT_TV:
                return get_slave_funcs(encoder)->mode_valid(encoder, mode);
        case OUTPUT_DP:
-               if (nv_encoder->dp.link_bw == DP_LINK_BW_2_7)
-                       max_clock = nv_encoder->dp.link_nr * 270000;
-               else
-                       max_clock = nv_encoder->dp.link_nr * 162000;
-
+               max_clock  = nv_encoder->dp.link_nr;
+               max_clock *= nv_encoder->dp.link_bw;
                clock = clock * nouveau_connector_bpp(connector) / 8;
                break;
        default:
index 726d0ac63b9b8c73dd1defc5dd7ac2c9f2345857..47bd3ada6a3b4e0d17445c86a608d8ffab61c825 100644 (file)
@@ -516,7 +516,7 @@ nouveau_dp_link_train(struct drm_encoder *encoder, u32 datarate)
        nouveau_bios_run_init_table(dev, ROM16(bios[6]), dp.dcb, dp.crtc);
 
        /* start off at highest link rate supported by encoder and display */
-       if (nv_encoder->dp.link_bw == DP_LINK_BW_1_62)
+       while (*link_bw > nv_encoder->dp.link_bw)
                link_bw++;
 
        while (link_bw[0]) {
@@ -566,24 +566,24 @@ nouveau_dp_detect(struct drm_encoder *encoder)
        if (ret)
                return false;
 
-       NV_DEBUG_KMS(dev, "encoder: link_bw %d, link_nr %d\n"
-                     "display: link_bw %d, link_nr %d version 0x%02x\n",
-                nv_encoder->dcb->dpconf.link_bw,
-                nv_encoder->dcb->dpconf.link_nr,
-                dpcd[1], dpcd[2] & 0x0f, dpcd[0]);
-
        nv_encoder->dp.dpcd_version = dpcd[0];
+       nv_encoder->dp.link_bw = 27000 * dpcd[1];
+       nv_encoder->dp.link_nr = dpcd[2] & DP_MAX_LANE_COUNT_MASK;
+       nv_encoder->dp.enhanced_frame = dpcd[2] & DP_ENHANCED_FRAME_CAP;
 
-       nv_encoder->dp.link_bw = dpcd[1];
-       if (nv_encoder->dp.link_bw != DP_LINK_BW_1_62 &&
-           !nv_encoder->dcb->dpconf.link_bw)
-               nv_encoder->dp.link_bw = DP_LINK_BW_1_62;
+       NV_DEBUG_KMS(dev, "display: %dx%d dpcd 0x%02x\n",
+                    nv_encoder->dp.link_nr, nv_encoder->dp.link_bw, dpcd[0]);
+       NV_DEBUG_KMS(dev, "encoder: %dx%d\n",
+                    nv_encoder->dcb->dpconf.link_nr,
+                    nv_encoder->dcb->dpconf.link_bw);
 
-       nv_encoder->dp.link_nr = dpcd[2] & DP_MAX_LANE_COUNT_MASK;
-       if (nv_encoder->dp.link_nr > nv_encoder->dcb->dpconf.link_nr)
+       if (nv_encoder->dcb->dpconf.link_nr < nv_encoder->dp.link_nr)
                nv_encoder->dp.link_nr = nv_encoder->dcb->dpconf.link_nr;
+       if (nv_encoder->dcb->dpconf.link_bw < nv_encoder->dp.link_bw)
+               nv_encoder->dp.link_bw = nv_encoder->dcb->dpconf.link_bw;
 
-       nv_encoder->dp.enhanced_frame = (dpcd[2] & DP_ENHANCED_FRAME_CAP);
+       NV_DEBUG_KMS(dev, "maximum: %dx%d\n",
+                    nv_encoder->dp.link_nr, nv_encoder->dp.link_bw);
 
        return true;
 }