drm/nouveau/dp: make dp dpms function common, call from sor code instead
authorBen Skeggs <bskeggs@redhat.com>
Sat, 10 Mar 2012 15:20:54 +0000 (01:20 +1000)
committerBen Skeggs <bskeggs@redhat.com>
Tue, 13 Mar 2012 07:15:04 +0000 (17:15 +1000)
GF119 will use this too.

Signed-off-by: Ben Skeggs <bskeggs@redhat.com>
drivers/gpu/drm/nouveau/nouveau_dp.c
drivers/gpu/drm/nouveau/nouveau_encoder.h
drivers/gpu/drm/nouveau/nv50_sor.c

index f38f561a00589024a07f7fa45d5f63acf9015558..7be4e06e8438645d480e489d3a2ee3af2b48185d 100644 (file)
@@ -475,6 +475,29 @@ nouveau_dp_link_train(struct drm_encoder *encoder, u32 datarate,
        return true;
 }
 
+void
+nouveau_dp_dpms(struct drm_encoder *encoder, int mode, u32 datarate,
+               struct dp_train_func *func)
+{
+       struct nouveau_encoder *nv_encoder = nouveau_encoder(encoder);
+       struct nouveau_i2c_chan *auxch;
+       u8 status;
+
+       auxch = nouveau_i2c_find(encoder->dev, nv_encoder->dcb->i2c_index);
+       if (!auxch)
+               return;
+
+       if (mode == DRM_MODE_DPMS_ON)
+               status = DP_SET_POWER_D0;
+       else
+               status = DP_SET_POWER_D3;
+
+       nouveau_dp_auxch(auxch, 8, DP_SET_POWER, &status, 1);
+
+       if (mode == DRM_MODE_DPMS_ON)
+               nouveau_dp_link_train(encoder, datarate, func);
+}
+
 bool
 nouveau_dp_detect(struct drm_encoder *encoder)
 {
index fa431742271eed2932585b9bd1601803592f7830..3dc14a3dcc4cf767b9fc4b28d078aa41fc490555 100644 (file)
@@ -90,8 +90,8 @@ get_slave_funcs(struct drm_encoder *enc)
 int nouveau_dp_auxch(struct nouveau_i2c_chan *auxch, int cmd, int addr,
                     uint8_t *data, int data_nr);
 bool nouveau_dp_detect(struct drm_encoder *);
-bool nouveau_dp_link_train(struct drm_encoder *, u32 datarate,
-                          struct dp_train_func *);
+void nouveau_dp_dpms(struct drm_encoder *, int mode, u32 datarate,
+                    struct dp_train_func *);
 u8 *nouveau_dp_bios_data(struct drm_device *, struct dcb_entry *, u8 **);
 
 struct nouveau_connector *
index ba1b8cc035457393dbe340f6b8190f9bdbff4e19..9a5c2c98658c3ba5511472fdca28bd88af351f62 100644 (file)
@@ -304,27 +304,13 @@ nv50_sor_dpms(struct drm_encoder *encoder, int mode)
        }
 
        if (nv_encoder->dcb->type == OUTPUT_DP) {
-               struct nouveau_i2c_chan *auxch;
+               struct dp_train_func func = {
+                       .link_set = nv50_sor_dp_link_set,
+                       .train_set = nv50_sor_dp_train_set,
+                       .train_adj = nv50_sor_dp_train_adj
+               };
 
-               auxch = nouveau_i2c_find(dev, nv_encoder->dcb->i2c_index);
-               if (!auxch)
-                       return;
-
-               if (mode == DRM_MODE_DPMS_ON) {
-                       struct dp_train_func func = {
-                               .link_set = nv50_sor_dp_link_set,
-                               .train_set = nv50_sor_dp_train_set,
-                               .train_adj = nv50_sor_dp_train_adj
-                       };
-                       u32 rate = nv_encoder->dp.datarate;
-                       u8 status = DP_SET_POWER_D0;
-
-                       nouveau_dp_auxch(auxch, 8, DP_SET_POWER, &status, 1);
-                       nouveau_dp_link_train(encoder, rate, &func);
-               } else {
-                       u8 status = DP_SET_POWER_D3;
-                       nouveau_dp_auxch(auxch, 8, DP_SET_POWER, &status, 1);
-               }
+               nouveau_dp_dpms(encoder, mode, nv_encoder->dp.datarate, &func);
        }
 }