drm/nouveau/disp/nv50-: port OR manual sink detection to nvkm_ior
authorBen Skeggs <bskeggs@redhat.com>
Fri, 19 May 2017 13:59:35 +0000 (23:59 +1000)
committerBen Skeggs <bskeggs@redhat.com>
Fri, 16 Jun 2017 04:04:54 +0000 (14:04 +1000)
Signed-off-by: Ben Skeggs <bskeggs@redhat.com>
17 files changed:
drivers/gpu/drm/nouveau/nvkm/engine/disp/dacgf119.c
drivers/gpu/drm/nouveau/nvkm/engine/disp/dacnv50.c
drivers/gpu/drm/nouveau/nvkm/engine/disp/g84.c
drivers/gpu/drm/nouveau/nvkm/engine/disp/g94.c
drivers/gpu/drm/nouveau/nvkm/engine/disp/gf119.c
drivers/gpu/drm/nouveau/nvkm/engine/disp/gk104.c
drivers/gpu/drm/nouveau/nvkm/engine/disp/gk110.c
drivers/gpu/drm/nouveau/nvkm/engine/disp/gm107.c
drivers/gpu/drm/nouveau/nvkm/engine/disp/gm200.c
drivers/gpu/drm/nouveau/nvkm/engine/disp/gt200.c
drivers/gpu/drm/nouveau/nvkm/engine/disp/gt215.c
drivers/gpu/drm/nouveau/nvkm/engine/disp/ior.h
drivers/gpu/drm/nouveau/nvkm/engine/disp/mcp77.c
drivers/gpu/drm/nouveau/nvkm/engine/disp/mcp89.c
drivers/gpu/drm/nouveau/nvkm/engine/disp/nv50.c
drivers/gpu/drm/nouveau/nvkm/engine/disp/nv50.h
drivers/gpu/drm/nouveau/nvkm/engine/disp/rootnv50.c

index 2ef07c0fcc2dd25b55cc6de97ba6800a43e79a1d..7d2d929eec16bb67d3b0e4d6993c8ea71c5f9ece 100644 (file)
@@ -43,6 +43,7 @@ static const struct nvkm_ior_func
 gf119_dac = {
        .state = gf119_dac_state,
        .power = nv50_dac_power,
+       .sense = nv50_dac_sense,
 };
 
 int
index 48fbf8c34a537246b6a30d689af3e2cf51285fb7..0e51e144c1bdb6bfb60df1fceda6621d9bebd05d 100644 (file)
  * Authors: Ben Skeggs
  */
 #include "ior.h"
-#include "nv50.h"
 #include "outp.h"
 
-#include <core/client.h>
 #include <subdev/timer.h>
 
-#include <nvif/cl5070.h>
-#include <nvif/unpack.h>
-
 static const struct nvkm_output_func
 nv50_dac_output_func = {
 };
@@ -44,50 +39,23 @@ nv50_dac_output_new(struct nvkm_disp *disp, int index,
 }
 
 int
-nv50_dac_sense(NV50_DISP_MTHD_V1)
+nv50_dac_sense(struct nvkm_ior *dac, u32 loadval)
 {
-       struct nvkm_subdev *subdev = &disp->base.engine.subdev;
-       struct nvkm_device *device = subdev->device;
-       union {
-               struct nv50_disp_dac_load_v0 v0;
-       } *args = data;
-       const u32 doff = outp->or * 0x800;
-       u32 loadval;
-       int ret = -ENOSYS;
-
-       nvif_ioctl(object, "disp dac load size %d\n", size);
-       if (!(ret = nvif_unpack(ret, &data, &size, args->v0, 0, 0, false))) {
-               nvif_ioctl(object, "disp dac load vers %d data %08x\n",
-                          args->v0.version, args->v0.data);
-               if (args->v0.data & 0xfff00000)
-                       return -EINVAL;
-               loadval = args->v0.data;
-       } else
-               return ret;
-
-       nvkm_mask(device, 0x61a004 + doff, 0x807f0000, 0x80150000);
-       nvkm_msec(device, 2000,
-               if (!(nvkm_rd32(device, 0x61a004 + doff) & 0x80000000))
-                       break;
-       );
+       struct nvkm_device *device = dac->disp->engine.subdev.device;
+       const u32 doff = nv50_ior_base(dac);
+
+       dac->func->power(dac, false, true, false, false, false);
 
        nvkm_wr32(device, 0x61a00c + doff, 0x00100000 | loadval);
        mdelay(9);
        udelay(500);
        loadval = nvkm_mask(device, 0x61a00c + doff, 0xffffffff, 0x00000000);
 
-       nvkm_mask(device, 0x61a004 + doff, 0x807f0000, 0x80550000);
-       nvkm_msec(device, 2000,
-               if (!(nvkm_rd32(device, 0x61a004 + doff) & 0x80000000))
-                       break;
-       );
-
-       nvkm_debug(subdev, "DAC%d sense: %08x\n", outp->or, loadval);
+       dac->func->power(dac, false, false, false, false, false);
        if (!(loadval & 0x80000000))
                return -ETIMEDOUT;
 
-       args->v0.load = (loadval & 0x38000000) >> 27;
-       return 0;
+       return (loadval & 0x38000000) >> 27;
 }
 
 static void
@@ -139,6 +107,7 @@ static const struct nvkm_ior_func
 nv50_dac = {
        .state = nv50_dac_state,
        .power = nv50_dac_power,
+       .sense = nv50_dac_sense,
 };
 
 int
index aa713b24a606930930c21475ddba57ab7f5ea6aa..3e110108272c8e660f1948d98a653347a5995d29 100644 (file)
@@ -38,9 +38,7 @@ g84_disp = {
        .outp.internal.lvds = nv50_sor_output_new,
        .outp.external.tmds = nv50_pior_output_new,
        .outp.external.dp = nv50_pior_dp_new,
-       .dac.nr = 3,
-       .dac.new = nv50_dac_new,
-       .dac.sense = nv50_dac_sense,
+       .dac = { .nr = 3, .new = nv50_dac_new },
        .sor.nr = 2,
        .sor.new = g84_sor_new,
        .sor.hdmi = g84_hdmi_ctrl,
index 5c6c8640bab143a884864e33718005fa72183702..ac9cd335e4f3fe29136222fd495ad9f25dd83a67 100644 (file)
@@ -39,9 +39,7 @@ g94_disp = {
        .outp.internal.dp = g94_sor_dp_new,
        .outp.external.tmds = nv50_pior_output_new,
        .outp.external.dp = nv50_pior_dp_new,
-       .dac.nr = 3,
-       .dac.new = nv50_dac_new,
-       .dac.sense = nv50_dac_sense,
+       .dac = { .nr = 3, .new = nv50_dac_new },
        .sor.nr = 4,
        .sor.new = g94_sor_new,
        .sor.hdmi = g84_hdmi_ctrl,
index 05fdbdb1df50ea5bae82487b1fb8d9dc598fe377..76972e009f365c52a5db5da24cb9ae1b0b062821 100644 (file)
@@ -506,9 +506,7 @@ gf119_disp = {
        .outp.internal.tmds = nv50_sor_output_new,
        .outp.internal.lvds = nv50_sor_output_new,
        .outp.internal.dp = gf119_sor_dp_new,
-       .dac.nr = 3,
-       .dac.new = gf119_dac_new,
-       .dac.sense = nv50_dac_sense,
+       .dac = { .nr = 3, .new = gf119_dac_new },
        .sor.nr = 4,
        .sor.new = gf119_sor_new,
        .sor.hda_eld = gf119_hda_eld,
index efbbbff0b93f556f1c46653b86c77e8b6b9519c2..2f84b1b5a4698b5331fbc69ae31607d04c5c84b5 100644 (file)
@@ -38,9 +38,7 @@ gk104_disp = {
        .outp.internal.tmds = nv50_sor_output_new,
        .outp.internal.lvds = nv50_sor_output_new,
        .outp.internal.dp = gf119_sor_dp_new,
-       .dac.nr = 3,
-       .dac.new = gf119_dac_new,
-       .dac.sense = nv50_dac_sense,
+       .dac = { .nr = 3, .new = gf119_dac_new },
        .sor.nr = 4,
        .sor.new = gk104_sor_new,
        .sor.hda_eld = gf119_hda_eld,
index bca825373dc138396f6bd5cb977e7ef3e47fa2e7..abf50b20b88c26d10d04005616c5ae4148504b6b 100644 (file)
@@ -38,9 +38,7 @@ gk110_disp = {
        .outp.internal.tmds = nv50_sor_output_new,
        .outp.internal.lvds = nv50_sor_output_new,
        .outp.internal.dp = gf119_sor_dp_new,
-       .dac.nr = 3,
-       .dac.new = gf119_dac_new,
-       .dac.sense = nv50_dac_sense,
+       .dac = { .nr = 3, .new = gf119_dac_new },
        .sor.nr = 4,
        .sor.new = gk104_sor_new,
        .sor.hda_eld = gf119_hda_eld,
index 90fc36e96335465d2f3619c80c0a2c5eaf861eda..0923ca4b42b6f80a0ff9c0cae7747ad7e05ee5e3 100644 (file)
@@ -38,9 +38,7 @@ gm107_disp = {
        .outp.internal.tmds = nv50_sor_output_new,
        .outp.internal.lvds = nv50_sor_output_new,
        .outp.internal.dp = gm107_sor_dp_new,
-       .dac.nr = 3,
-       .dac.new = gf119_dac_new,
-       .dac.sense = nv50_dac_sense,
+       .dac = { .nr = 3, .new = gf119_dac_new },
        .sor.nr = 4,
        .sor.new = gm107_sor_new,
        .sor.hda_eld = gf119_hda_eld,
index 2e0f81e75124887a50da56a5ebce07d6ad105721..cc83734e321be279ed1b2dd199dde667f3ede34c 100644 (file)
@@ -38,9 +38,7 @@ gm200_disp = {
        .outp.internal.tmds = nv50_sor_output_new,
        .outp.internal.lvds = nv50_sor_output_new,
        .outp.internal.dp = gm200_sor_dp_new,
-       .dac.nr = 3,
-       .dac.new = gf119_dac_new,
-       .dac.sense = nv50_dac_sense,
+       .dac = { .nr = 3, .new = gf119_dac_new },
        .sor.nr = 4,
        .sor.new = gm200_sor_new,
        .sor.hda_eld = gf119_hda_eld,
index a41909e8ab1f55efe062b3f0126e507724f9de1c..f9d43768acba7f9ca6d7ff15218e12b9abc0ba1a 100644 (file)
@@ -38,9 +38,7 @@ gt200_disp = {
        .outp.internal.lvds = nv50_sor_output_new,
        .outp.external.tmds = nv50_pior_output_new,
        .outp.external.dp = nv50_pior_dp_new,
-       .dac.nr = 3,
-       .dac.new = nv50_dac_new,
-       .dac.sense = nv50_dac_sense,
+       .dac = { .nr = 3, .new = nv50_dac_new },
        .sor.nr = 2,
        .sor.new = g84_sor_new,
        .sor.hdmi = g84_hdmi_ctrl,
index 230e43ded8eb340db33a4d5d1a9f9f3e7df6e7a4..6c75a975bf45bff05d2409b43e23be2bebe0110c 100644 (file)
@@ -39,9 +39,7 @@ gt215_disp = {
        .outp.internal.dp = g94_sor_dp_new,
        .outp.external.tmds = nv50_pior_output_new,
        .outp.external.dp = nv50_pior_dp_new,
-       .dac.nr = 3,
-       .dac.new = nv50_dac_new,
-       .dac.sense = nv50_dac_sense,
+       .dac = { .nr = 3, .new = nv50_dac_new },
        .sor.nr = 4,
        .sor.new = gt215_sor_new,
        .sor.hda_eld = gt215_hda_eld,
index 9dd526cfe2a2bc9a00ec3dae4818c22d212c22f9..ea80e7fd7d238285d032cc7fed2a7678116ee733 100644 (file)
@@ -42,6 +42,7 @@ struct nvkm_ior_func {
        void (*state)(struct nvkm_ior *, struct nvkm_ior_state *);
        void (*power)(struct nvkm_ior *, bool normal, bool pu,
                      bool data, bool vsync, bool hsync);
+       int (*sense)(struct nvkm_ior *, u32 loadval);
 };
 
 int nvkm_ior_new_(const struct nvkm_ior_func *func, struct nvkm_disp *,
@@ -56,6 +57,7 @@ nv50_ior_base(struct nvkm_ior *ior)
 }
 
 void nv50_dac_power(struct nvkm_ior *, bool, bool, bool, bool, bool);
+int nv50_dac_sense(struct nvkm_ior *, u32);
 
 void nv50_sor_state(struct nvkm_ior *, struct nvkm_ior_state *);
 void nv50_sor_power(struct nvkm_ior *, bool, bool, bool, bool, bool);
index ee8c2324a351521a86b325285b310da541d8ba2b..d707d8f4c0f03aa419cb7663befd29ea01cebc62 100644 (file)
@@ -37,9 +37,7 @@ mcp77_disp = {
        .outp.internal.dp = g94_sor_dp_new,
        .outp.external.tmds = nv50_pior_output_new,
        .outp.external.dp = nv50_pior_dp_new,
-       .dac.nr = 3,
-       .dac.new = nv50_dac_new,
-       .dac.sense = nv50_dac_sense,
+       .dac = { .nr = 3, .new = nv50_dac_new },
        .sor.nr = 4,
        .sor.new = mcp77_sor_new,
        .sor.hdmi = g84_hdmi_ctrl,
index 6dccb3d2c8dce5885c65147f0ba9c1ec48406fdb..24f46705f6167c623462ec3b6d741a68c14aac08 100644 (file)
@@ -37,9 +37,7 @@ mcp89_disp = {
        .outp.internal.dp = g94_sor_dp_new,
        .outp.external.tmds = nv50_pior_output_new,
        .outp.external.dp = nv50_pior_dp_new,
-       .dac.nr = 3,
-       .dac.new = nv50_dac_new,
-       .dac.sense = nv50_dac_sense,
+       .dac = { .nr = 3, .new = nv50_dac_new },
        .sor.nr = 4,
        .sor.new = mcp89_sor_new,
        .sor.hda_eld = gt215_hda_eld,
index f8986299dc542325a0a127a00ce6bb527cc09a96..ae570f65e097370babfd35c30d7925e80eec039f 100644 (file)
@@ -844,9 +844,7 @@ nv50_disp = {
        .outp.internal.lvds = nv50_sor_output_new,
        .outp.external.tmds = nv50_pior_output_new,
        .outp.external.dp = nv50_pior_dp_new,
-       .dac.nr = 3,
-       .dac.new = nv50_dac_new,
-       .dac.sense = nv50_dac_sense,
+       .dac = { .nr = 3, .new = nv50_dac_new },
        .sor = { .nr = 2, .new = nv50_sor_new },
        .pior = { .nr = 3, .new = nv50_pior_new },
 };
index 66180585df2a60cc1f6ab1b8b9656cb8bec508d7..263c3a7f9d8880486d6d277c6f92e03656c5028c 100644 (file)
@@ -31,8 +31,6 @@ struct nv50_disp {
 
 void nv50_disp_super_1(struct nv50_disp *);
 
-int nv50_dac_sense(NV50_DISP_MTHD_V1);
-
 int gt215_hda_eld(NV50_DISP_MTHD_V1);
 int gf119_hda_eld(NV50_DISP_MTHD_V1);
 
@@ -80,7 +78,6 @@ struct nv50_disp_func {
        struct {
                int nr;
                int (*new)(struct nvkm_disp *, int id);
-               int (*sense)(NV50_DISP_MTHD_V1);
        } dac;
 
        struct {
index 3f02e37f30bb0a0668b0ded773705a967a3ede7b..7ebea3e14e18208a4c6b7c17d4ec00d30e0c5e25 100644 (file)
@@ -95,8 +95,23 @@ nv50_disp_root_mthd_(struct nvkm_object *object, u32 mthd, void *data, u32 size)
        }
 
        switch (mthd * !!outp) {
-       case NV50_DISP_MTHD_V1_DAC_LOAD:
-               return func->dac.sense(object, disp, data, size, hidx, outp);
+       case NV50_DISP_MTHD_V1_DAC_LOAD: {
+               union {
+                       struct nv50_disp_dac_load_v0 v0;
+               } *args = data;
+               int ret = -ENOSYS;
+               if (!(ret = nvif_unpack(ret, &data, &size, args->v0, 0, 0, false))) {
+                       if (args->v0.data & 0xfff00000)
+                               return -EINVAL;
+                       ret = outp->ior->func->sense(outp->ior, args->v0.data);
+                       if (ret < 0)
+                               return ret;
+                       args->v0.load = ret;
+                       return 0;
+               } else
+                       return ret;
+       }
+               break;
        case NV50_DISP_MTHD_V1_SOR_HDA_ELD:
                if (!func->sor.hda_eld)
                        return -ENODEV;