diff --git a/drivers/gpu/drm/nouveau/nvkm/engine/disp/dacgf119.c b/drivers/gpu/drm/nouveau/nvkm/engine/disp/dacgf119.c index dbd032ef352ae6865b4f9edeaf098da534e03578..71a94777ea2e6479c9ed37b420364f4a88675b83 100644 --- a/drivers/gpu/drm/nouveau/nvkm/engine/disp/dacgf119.c +++ b/drivers/gpu/drm/nouveau/nvkm/engine/disp/dacgf119.c @@ -58,8 +58,13 @@ gf119_dac = { int gf119_dac_new(struct nvkm_disp *disp, int id) { - struct nvkm_device *device = disp->engine.subdev.device; - if (!(nvkm_rd32(device, 0x612004) & (0x00000010 << id))) - return 0; return nvkm_ior_new_(&gf119_dac, disp, DAC, id); } + +int +gf119_dac_cnt(struct nvkm_disp *disp, unsigned long *pmask) +{ + struct nvkm_device *device = disp->engine.subdev.device; + *pmask = (nvkm_rd32(device, 0x612004) & 0x000000f0) >> 4; + return 4; +} diff --git a/drivers/gpu/drm/nouveau/nvkm/engine/disp/dacnv50.c b/drivers/gpu/drm/nouveau/nvkm/engine/disp/dacnv50.c index 85e692b122602956db896c85985a4cdf9fef16b3..558012db35f852f22b94c3bd951504b8dc29eda4 100644 --- a/drivers/gpu/drm/nouveau/nvkm/engine/disp/dacnv50.c +++ b/drivers/gpu/drm/nouveau/nvkm/engine/disp/dacnv50.c @@ -109,8 +109,13 @@ nv50_dac = { int nv50_dac_new(struct nvkm_disp *disp, int id) { - struct nvkm_device *device = disp->engine.subdev.device; - if (!(nvkm_rd32(device, 0x610184) & (0x00100000 << id))) - return 0; return nvkm_ior_new_(&nv50_dac, disp, DAC, id); } + +int +nv50_dac_cnt(struct nvkm_disp *disp, unsigned long *pmask) +{ + struct nvkm_device *device = disp->engine.subdev.device; + *pmask = (nvkm_rd32(device, 0x610184) & 0x00700000) >> 20; + return 3; +} diff --git a/drivers/gpu/drm/nouveau/nvkm/engine/disp/g84.c b/drivers/gpu/drm/nouveau/nvkm/engine/disp/g84.c index a1741a80bd050352780275b7047499c6d5b5e405..9f31f04e4e58e82fdaa79a7c8898bb9d37a811a1 100644 --- a/drivers/gpu/drm/nouveau/nvkm/engine/disp/g84.c +++ b/drivers/gpu/drm/nouveau/nvkm/engine/disp/g84.c @@ -33,7 +33,7 @@ g84_disp = { .super = nv50_disp_super, .root = &g84_disp_root_oclass, .head = { .cnt = nv50_head_cnt, .new = nv50_head_new }, - .dac = { .nr = 3, .new = nv50_dac_new }, + .dac = { .cnt = nv50_dac_cnt, .new = nv50_dac_new }, .sor = { .nr = 2, .new = g84_sor_new }, .pior = { .nr = 3, .new = nv50_pior_new }, }; diff --git a/drivers/gpu/drm/nouveau/nvkm/engine/disp/g94.c b/drivers/gpu/drm/nouveau/nvkm/engine/disp/g94.c index b7febc4b0f85613f009c22cde51c3a42e9cc73e0..71fe26b2583549cc4b647c59cee491ad93e4eefc 100644 --- a/drivers/gpu/drm/nouveau/nvkm/engine/disp/g94.c +++ b/drivers/gpu/drm/nouveau/nvkm/engine/disp/g94.c @@ -33,7 +33,7 @@ g94_disp = { .super = nv50_disp_super, .root = &g94_disp_root_oclass, .head = { .cnt = nv50_head_cnt, .new = nv50_head_new }, - .dac = { .nr = 3, .new = nv50_dac_new }, + .dac = { .cnt = nv50_dac_cnt, .new = nv50_dac_new }, .sor = { .nr = 4, .new = g94_sor_new }, .pior = { .nr = 3, .new = nv50_pior_new }, }; diff --git a/drivers/gpu/drm/nouveau/nvkm/engine/disp/gf119.c b/drivers/gpu/drm/nouveau/nvkm/engine/disp/gf119.c index b580ca9b4418bce1d696102eadfd20966427f4e3..c8495bcf289cff4fa9f96540f9a6e1cab5ca9a6a 100644 --- a/drivers/gpu/drm/nouveau/nvkm/engine/disp/gf119.c +++ b/drivers/gpu/drm/nouveau/nvkm/engine/disp/gf119.c @@ -172,7 +172,7 @@ gf119_disp = { .super = gf119_disp_super, .root = &gf119_disp_root_oclass, .head = { .cnt = gf119_head_cnt, .new = gf119_head_new }, - .dac = { .nr = 3, .new = gf119_dac_new }, + .dac = { .cnt = gf119_dac_cnt, .new = gf119_dac_new }, .sor = { .nr = 4, .new = gf119_sor_new }, }; diff --git a/drivers/gpu/drm/nouveau/nvkm/engine/disp/gk104.c b/drivers/gpu/drm/nouveau/nvkm/engine/disp/gk104.c index b3ee5b1d4a45f9b1089613edd6e9e21e9723f6cf..b948619818cc1bd28968e35969751bbef9c0e292 100644 --- a/drivers/gpu/drm/nouveau/nvkm/engine/disp/gk104.c +++ b/drivers/gpu/drm/nouveau/nvkm/engine/disp/gk104.c @@ -34,7 +34,7 @@ gk104_disp = { .super = gf119_disp_super, .root = &gk104_disp_root_oclass, .head = { .cnt = gf119_head_cnt, .new = gf119_head_new }, - .dac = { .nr = 3, .new = gf119_dac_new }, + .dac = { .cnt = gf119_dac_cnt, .new = gf119_dac_new }, .sor = { .nr = 4, .new = gk104_sor_new }, }; diff --git a/drivers/gpu/drm/nouveau/nvkm/engine/disp/gk110.c b/drivers/gpu/drm/nouveau/nvkm/engine/disp/gk110.c index 22533abbfb67c8600f64ec57a630b566bbcb539d..0b4945703568ef793e557a4eb37c6ce656e157aa 100644 --- a/drivers/gpu/drm/nouveau/nvkm/engine/disp/gk110.c +++ b/drivers/gpu/drm/nouveau/nvkm/engine/disp/gk110.c @@ -34,7 +34,7 @@ gk110_disp = { .super = gf119_disp_super, .root = &gk110_disp_root_oclass, .head = { .cnt = gf119_head_cnt, .new = gf119_head_new }, - .dac = { .nr = 3, .new = gf119_dac_new }, + .dac = { .cnt = gf119_dac_cnt, .new = gf119_dac_new }, .sor = { .nr = 4, .new = gk104_sor_new }, }; diff --git a/drivers/gpu/drm/nouveau/nvkm/engine/disp/gm107.c b/drivers/gpu/drm/nouveau/nvkm/engine/disp/gm107.c index 85e602120abc3be1cadde4de807576930ea79d84..35ad965ffee27c1c66c08f93c1fed50023e7b4c9 100644 --- a/drivers/gpu/drm/nouveau/nvkm/engine/disp/gm107.c +++ b/drivers/gpu/drm/nouveau/nvkm/engine/disp/gm107.c @@ -34,7 +34,7 @@ gm107_disp = { .super = gf119_disp_super, .root = &gm107_disp_root_oclass, .head = { .cnt = gf119_head_cnt, .new = gf119_head_new }, - .dac = { .nr = 3, .new = gf119_dac_new }, + .dac = { .cnt = gf119_dac_cnt, .new = gf119_dac_new }, .sor = { .nr = 4, .new = gm107_sor_new }, }; diff --git a/drivers/gpu/drm/nouveau/nvkm/engine/disp/gm200.c b/drivers/gpu/drm/nouveau/nvkm/engine/disp/gm200.c index 48ab65d827178be5d92b8c3ecc4a835c50637b22..b2a5d364ffaf4b5844a2deb3c3a83b487af46acc 100644 --- a/drivers/gpu/drm/nouveau/nvkm/engine/disp/gm200.c +++ b/drivers/gpu/drm/nouveau/nvkm/engine/disp/gm200.c @@ -34,7 +34,7 @@ gm200_disp = { .super = gf119_disp_super, .root = &gm200_disp_root_oclass, .head = { .cnt = gf119_head_cnt, .new = gf119_head_new }, - .dac = { .nr = 3, .new = gf119_dac_new }, + .dac = { .cnt = gf119_dac_cnt, .new = gf119_dac_new }, .sor = { .nr = 4, .new = gm200_sor_new }, }; diff --git a/drivers/gpu/drm/nouveau/nvkm/engine/disp/gt200.c b/drivers/gpu/drm/nouveau/nvkm/engine/disp/gt200.c index 7554c732a655a434b0a312e74c37cff50f66795a..88b6a34e9df7ff38fdd0e7f3e556ce08ca3682b4 100644 --- a/drivers/gpu/drm/nouveau/nvkm/engine/disp/gt200.c +++ b/drivers/gpu/drm/nouveau/nvkm/engine/disp/gt200.c @@ -33,7 +33,7 @@ gt200_disp = { .super = nv50_disp_super, .root = >200_disp_root_oclass, .head = { .cnt = nv50_head_cnt, .new = nv50_head_new }, - .dac = { .nr = 3, .new = nv50_dac_new }, + .dac = { .cnt = nv50_dac_cnt, .new = nv50_dac_new }, .sor = { .nr = 2, .new = g84_sor_new }, .pior = { .nr = 3, .new = nv50_pior_new }, }; diff --git a/drivers/gpu/drm/nouveau/nvkm/engine/disp/gt215.c b/drivers/gpu/drm/nouveau/nvkm/engine/disp/gt215.c index 6a878a7e6af35084124bcf61e049ba06d490ca36..1519ca566d9f82617aa655d9737e4fec581b2a17 100644 --- a/drivers/gpu/drm/nouveau/nvkm/engine/disp/gt215.c +++ b/drivers/gpu/drm/nouveau/nvkm/engine/disp/gt215.c @@ -33,7 +33,7 @@ gt215_disp = { .super = nv50_disp_super, .root = >215_disp_root_oclass, .head = { .cnt = nv50_head_cnt, .new = nv50_head_new }, - .dac = { .nr = 3, .new = nv50_dac_new }, + .dac = { .cnt = nv50_dac_cnt, .new = nv50_dac_new }, .sor = { .nr = 4, .new = gt215_sor_new }, .pior = { .nr = 3, .new = nv50_pior_new }, }; diff --git a/drivers/gpu/drm/nouveau/nvkm/engine/disp/ior.h b/drivers/gpu/drm/nouveau/nvkm/engine/disp/ior.h index 4548c031b9375f24951cbec7a15bd54561208e75..89d9ab154c4b6d36db76c1a61009766f4636482f 100644 --- a/drivers/gpu/drm/nouveau/nvkm/engine/disp/ior.h +++ b/drivers/gpu/drm/nouveau/nvkm/engine/disp/ior.h @@ -153,7 +153,10 @@ void gf119_hda_eld(struct nvkm_ior *, u8 *, u8); #define IOR_WARN(i,f,a...) IOR_MSG((i), warn, f, ##a) #define IOR_DBG(i,f,a...) IOR_MSG((i), debug, f, ##a) +int nv50_dac_cnt(struct nvkm_disp *, unsigned long *); int nv50_dac_new(struct nvkm_disp *, int); + +int gf119_dac_cnt(struct nvkm_disp *, unsigned long *); int gf119_dac_new(struct nvkm_disp *, int); int nv50_pior_new(struct nvkm_disp *, int); diff --git a/drivers/gpu/drm/nouveau/nvkm/engine/disp/mcp77.c b/drivers/gpu/drm/nouveau/nvkm/engine/disp/mcp77.c index 9fc7507774e15efcbbc4ef1ce4e3cff989a59799..fb188546f5f8f60de8b849ec1917431e7aa9aa2e 100644 --- a/drivers/gpu/drm/nouveau/nvkm/engine/disp/mcp77.c +++ b/drivers/gpu/drm/nouveau/nvkm/engine/disp/mcp77.c @@ -31,7 +31,7 @@ mcp77_disp = { .super = nv50_disp_super, .root = &g94_disp_root_oclass, .head = { .cnt = nv50_head_cnt, .new = nv50_head_new }, - .dac = { .nr = 3, .new = nv50_dac_new }, + .dac = { .cnt = nv50_dac_cnt, .new = nv50_dac_new }, .sor = { .nr = 4, .new = mcp77_sor_new }, .pior = { .nr = 3, .new = nv50_pior_new }, }; diff --git a/drivers/gpu/drm/nouveau/nvkm/engine/disp/mcp89.c b/drivers/gpu/drm/nouveau/nvkm/engine/disp/mcp89.c index 28647d365057dd36bab12cffb39c0594094879f0..ae7fb9625674822a4663e47fb9d506e687213b61 100644 --- a/drivers/gpu/drm/nouveau/nvkm/engine/disp/mcp89.c +++ b/drivers/gpu/drm/nouveau/nvkm/engine/disp/mcp89.c @@ -31,7 +31,7 @@ mcp89_disp = { .super = nv50_disp_super, .root = >215_disp_root_oclass, .head = { .cnt = nv50_head_cnt, .new = nv50_head_new }, - .dac = { .nr = 3, .new = nv50_dac_new }, + .dac = { .cnt = nv50_dac_cnt, .new = nv50_dac_new }, .sor = { .nr = 4, .new = mcp89_sor_new }, .pior = { .nr = 3, .new = nv50_pior_new }, }; diff --git a/drivers/gpu/drm/nouveau/nvkm/engine/disp/nv50.c b/drivers/gpu/drm/nouveau/nvkm/engine/disp/nv50.c index bf50b7be88267f8be6692caa36f433e3c38791e6..500ef8da696a01f73ddf27a48501f30061249b7c 100644 --- a/drivers/gpu/drm/nouveau/nvkm/engine/disp/nv50.c +++ b/drivers/gpu/drm/nouveau/nvkm/engine/disp/nv50.c @@ -76,10 +76,15 @@ nv50_disp_oneinit_(struct nvkm_disp *base) return ret; } - for (i = 0; func->dac.new && i < func->dac.nr; i++) { - ret = func->dac.new(&disp->base, i); - if (ret) - return ret; + if (func->dac.cnt) { + disp->dac.nr = func->dac.cnt(&disp->base, &disp->dac.mask); + nvkm_debug(subdev, " DAC(s): %d (%02lx)\n", + disp->dac.nr, disp->dac.mask); + for_each_set_bit(i, &disp->dac.mask, disp->dac.nr) { + ret = func->dac.new(&disp->base, i); + if (ret) + return ret; + } } for (i = 0; func->pior.new && i < func->pior.nr; i++) { @@ -637,7 +642,7 @@ nv50_disp = { .super = nv50_disp_super, .root = &nv50_disp_root_oclass, .head = { .cnt = nv50_head_cnt, .new = nv50_head_new }, - .dac = { .nr = 3, .new = nv50_dac_new }, + .dac = { .cnt = nv50_dac_cnt, .new = nv50_dac_new }, .sor = { .nr = 2, .new = nv50_sor_new }, .pior = { .nr = 3, .new = nv50_pior_new }, }; diff --git a/drivers/gpu/drm/nouveau/nvkm/engine/disp/nv50.h b/drivers/gpu/drm/nouveau/nvkm/engine/disp/nv50.h index c7fe29cf3e0535c275f047b90d2b89492dbc4261..3415a52584927aa9a4bb5b192bb53d91aec7cb0d 100644 --- a/drivers/gpu/drm/nouveau/nvkm/engine/disp/nv50.h +++ b/drivers/gpu/drm/nouveau/nvkm/engine/disp/nv50.h @@ -18,7 +18,7 @@ struct nv50_disp { struct { unsigned long mask; int nr; - } head; + } head, dac; struct { u32 lvdsconf; @@ -53,12 +53,7 @@ struct nv50_disp_func { struct { int (*cnt)(struct nvkm_disp *, unsigned long *mask); int (*new)(struct nvkm_disp *, int id); - } head; - - struct { - int nr; - int (*new)(struct nvkm_disp *, int id); - } dac; + } head, dac; struct { int nr; diff --git a/drivers/gpu/drm/nouveau/nvkm/engine/disp/rootgf119.c b/drivers/gpu/drm/nouveau/nvkm/engine/disp/rootgf119.c index 333c8424b413c1ab16919996df08051d20657584..7f22b875b9b3e82b646f092f45c9ea210baf08b3 100644 --- a/drivers/gpu/drm/nouveau/nvkm/engine/disp/rootgf119.c +++ b/drivers/gpu/drm/nouveau/nvkm/engine/disp/rootgf119.c @@ -64,7 +64,7 @@ gf119_disp_root_init(struct nv50_disp_root *root) } /* ... DAC caps */ - for (i = 0; i < disp->func->dac.nr; i++) { + for (i = 0; i < disp->dac.nr; i++) { tmp = nvkm_rd32(device, 0x61a000 + (i * 0x800)); nvkm_wr32(device, 0x6101c0 + (i * 0x800), tmp); } diff --git a/drivers/gpu/drm/nouveau/nvkm/engine/disp/rootnv50.c b/drivers/gpu/drm/nouveau/nvkm/engine/disp/rootnv50.c index 1208524aae14e7f8c16b064406851c2b2c33f2c2..3fbaccd9569bb6c6298aafb67b380283d0363675 100644 --- a/drivers/gpu/drm/nouveau/nvkm/engine/disp/rootnv50.c +++ b/drivers/gpu/drm/nouveau/nvkm/engine/disp/rootnv50.c @@ -427,7 +427,7 @@ nv50_disp_root_init(struct nv50_disp_root *root) } /* ... DAC caps */ - for (i = 0; i < disp->func->dac.nr; i++) { + for (i = 0; i < disp->dac.nr; i++) { tmp = nvkm_rd32(device, 0x61a000 + (i * 0x800)); nvkm_wr32(device, 0x6101d0 + (i * 0x04), tmp); }