Commit 4b2b42f8 authored by Ben Skeggs's avatar Ben Skeggs

drm/nouveau/disp: delay output path / connector construction until oneinit()

This is to allow hw-specific code to instantiate output resources first,
so we can cull unsupported output paths based on them.
Signed-off-by: default avatarBen Skeggs <bskeggs@redhat.com>
parent 981a8162
...@@ -8,7 +8,9 @@ struct nvkm_disp { ...@@ -8,7 +8,9 @@ struct nvkm_disp {
const struct nvkm_disp_func *func; const struct nvkm_disp_func *func;
struct nvkm_engine engine; struct nvkm_engine engine;
struct nvkm_oproxy *client; struct {
int nr;
} head;
struct list_head outp; struct list_head outp;
struct list_head conn; struct list_head conn;
...@@ -16,9 +18,7 @@ struct nvkm_disp { ...@@ -16,9 +18,7 @@ struct nvkm_disp {
struct nvkm_event hpd; struct nvkm_event hpd;
struct nvkm_event vblank; struct nvkm_event vblank;
struct { struct nvkm_oproxy *client;
int nr;
} head;
}; };
int nv04_disp_new(struct nvkm_device *, int, struct nvkm_disp **); int nv04_disp_new(struct nvkm_device *, int, struct nvkm_disp **);
......
...@@ -242,49 +242,11 @@ nvkm_disp_init(struct nvkm_engine *engine) ...@@ -242,49 +242,11 @@ nvkm_disp_init(struct nvkm_engine *engine)
return 0; return 0;
} }
static void * static int
nvkm_disp_dtor(struct nvkm_engine *engine) nvkm_disp_oneinit(struct nvkm_engine *engine)
{ {
struct nvkm_disp *disp = nvkm_disp(engine); struct nvkm_disp *disp = nvkm_disp(engine);
struct nvkm_conn *conn; struct nvkm_bios *bios = disp->engine.subdev.device->bios;
struct nvkm_outp *outp;
void *data = disp;
if (disp->func->dtor)
data = disp->func->dtor(disp);
nvkm_event_fini(&disp->vblank);
nvkm_event_fini(&disp->hpd);
while (!list_empty(&disp->outp)) {
outp = list_first_entry(&disp->outp, typeof(*outp), head);
list_del(&outp->head);
nvkm_outp_del(&outp);
}
while (!list_empty(&disp->conn)) {
conn = list_first_entry(&disp->conn, typeof(*conn), head);
list_del(&conn->head);
nvkm_conn_del(&conn);
}
return data;
}
static const struct nvkm_engine_func
nvkm_disp = {
.dtor = nvkm_disp_dtor,
.init = nvkm_disp_init,
.fini = nvkm_disp_fini,
.intr = nvkm_disp_intr,
.base.sclass = nvkm_disp_class_get,
};
int
nvkm_disp_ctor(const struct nvkm_disp_func *func, struct nvkm_device *device,
int index, int heads, struct nvkm_disp *disp)
{
struct nvkm_bios *bios = device->bios;
struct nvkm_outp *outp, *outt, *pair; struct nvkm_outp *outp, *outt, *pair;
struct nvkm_conn *conn; struct nvkm_conn *conn;
struct nvbios_connE connE; struct nvbios_connE connE;
...@@ -293,16 +255,7 @@ nvkm_disp_ctor(const struct nvkm_disp_func *func, struct nvkm_device *device, ...@@ -293,16 +255,7 @@ nvkm_disp_ctor(const struct nvkm_disp_func *func, struct nvkm_device *device,
u32 data; u32 data;
int ret, i; int ret, i;
INIT_LIST_HEAD(&disp->outp); /* Create output path objects for each VBIOS display path. */
INIT_LIST_HEAD(&disp->conn);
disp->func = func;
disp->head.nr = heads;
ret = nvkm_engine_ctor(&nvkm_disp, device, index, true, &disp->engine);
if (ret)
return ret;
/* create output objects for each display path in the vbios */
i = -1; i = -1;
while ((data = dcb_outp_parse(bios, ++i, &ver, &hdr, &dcbE))) { while ((data = dcb_outp_parse(bios, ++i, &ver, &hdr, &dcbE))) {
const struct nvkm_disp_func_outp *outps; const struct nvkm_disp_func_outp *outps;
...@@ -349,7 +302,7 @@ nvkm_disp_ctor(const struct nvkm_disp_func *func, struct nvkm_device *device, ...@@ -349,7 +302,7 @@ nvkm_disp_ctor(const struct nvkm_disp_func *func, struct nvkm_device *device,
continue; continue;
} }
nvkm_error(&disp->engine.subdev, nvkm_error(&disp->engine.subdev,
"failed to create output %d\n", i); "failed to create outp %d\n", i);
nvkm_outp_del(&outp); nvkm_outp_del(&outp);
continue; continue;
} }
...@@ -358,18 +311,18 @@ nvkm_disp_ctor(const struct nvkm_disp_func *func, struct nvkm_device *device, ...@@ -358,18 +311,18 @@ nvkm_disp_ctor(const struct nvkm_disp_func *func, struct nvkm_device *device,
hpd = max(hpd, (u8)(dcbE.connector + 1)); hpd = max(hpd, (u8)(dcbE.connector + 1));
} }
/* create connector objects based on the outputs we support */ /* Create connector objects based on available output paths. */
list_for_each_entry_safe(outp, outt, &disp->outp, head) { list_for_each_entry_safe(outp, outt, &disp->outp, head) {
/* bios data *should* give us the most useful information */ /* VBIOS data *should* give us the most useful information. */
data = nvbios_connEp(bios, outp->info.connector, &ver, &hdr, data = nvbios_connEp(bios, outp->info.connector, &ver, &hdr,
&connE); &connE);
/* no bios connector data... */ /* No bios connector data... */
if (!data) { if (!data) {
/* heuristic: anything with the same ccb index is /* Heuristic: anything with the same ccb index is
* considered to be on the same connector, any * considered to be on the same connector, any
* output path without an associated ccb entry will * output path without an associated ccb entry will
* be put on its own connector * be put on its own connector.
*/ */
int ccb_index = outp->info.i2c_index; int ccb_index = outp->info.i2c_index;
if (ccb_index != 0xf) { if (ccb_index != 0xf) {
...@@ -381,7 +334,7 @@ nvkm_disp_ctor(const struct nvkm_disp_func *func, struct nvkm_device *device, ...@@ -381,7 +334,7 @@ nvkm_disp_ctor(const struct nvkm_disp_func *func, struct nvkm_device *device,
} }
} }
/* connector shared with another output path */ /* Connector shared with another output path. */
if (outp->conn) if (outp->conn)
continue; continue;
...@@ -392,7 +345,7 @@ nvkm_disp_ctor(const struct nvkm_disp_func *func, struct nvkm_device *device, ...@@ -392,7 +345,7 @@ nvkm_disp_ctor(const struct nvkm_disp_func *func, struct nvkm_device *device,
i = outp->info.connector; i = outp->info.connector;
} }
/* check that we haven't already created this connector */ /* Check that we haven't already created this connector. */
list_for_each_entry(conn, &disp->conn, head) { list_for_each_entry(conn, &disp->conn, head) {
if (conn->index == outp->info.connector) { if (conn->index == outp->info.connector) {
outp->conn = conn; outp->conn = conn;
...@@ -403,11 +356,11 @@ nvkm_disp_ctor(const struct nvkm_disp_func *func, struct nvkm_device *device, ...@@ -403,11 +356,11 @@ nvkm_disp_ctor(const struct nvkm_disp_func *func, struct nvkm_device *device,
if (outp->conn) if (outp->conn)
continue; continue;
/* apparently we need to create a new one! */ /* Apparently we need to create a new one! */
ret = nvkm_conn_new(disp, i, &connE, &outp->conn); ret = nvkm_conn_new(disp, i, &connE, &outp->conn);
if (ret) { if (ret) {
nvkm_error(&disp->engine.subdev, nvkm_error(&disp->engine.subdev,
"failed to create output %d conn: %d\n", "failed to create outp %d conn: %d\n",
outp->index, ret); outp->index, ret);
nvkm_conn_del(&outp->conn); nvkm_conn_del(&outp->conn);
list_del(&outp->head); list_del(&outp->head);
...@@ -422,11 +375,58 @@ nvkm_disp_ctor(const struct nvkm_disp_func *func, struct nvkm_device *device, ...@@ -422,11 +375,58 @@ nvkm_disp_ctor(const struct nvkm_disp_func *func, struct nvkm_device *device,
if (ret) if (ret)
return ret; return ret;
ret = nvkm_event_init(&nvkm_disp_vblank_func, 1, heads, &disp->vblank); return nvkm_event_init(&nvkm_disp_vblank_func, 1,
if (ret) disp->head.nr, &disp->vblank);
return ret; }
return 0; static void *
nvkm_disp_dtor(struct nvkm_engine *engine)
{
struct nvkm_disp *disp = nvkm_disp(engine);
struct nvkm_conn *conn;
struct nvkm_outp *outp;
void *data = disp;
if (disp->func->dtor)
data = disp->func->dtor(disp);
nvkm_event_fini(&disp->vblank);
nvkm_event_fini(&disp->hpd);
while (!list_empty(&disp->conn)) {
conn = list_first_entry(&disp->conn, typeof(*conn), head);
list_del(&conn->head);
nvkm_conn_del(&conn);
}
while (!list_empty(&disp->outp)) {
outp = list_first_entry(&disp->outp, typeof(*outp), head);
list_del(&outp->head);
nvkm_outp_del(&outp);
}
return data;
}
static const struct nvkm_engine_func
nvkm_disp = {
.dtor = nvkm_disp_dtor,
.oneinit = nvkm_disp_oneinit,
.init = nvkm_disp_init,
.fini = nvkm_disp_fini,
.intr = nvkm_disp_intr,
.base.sclass = nvkm_disp_class_get,
};
int
nvkm_disp_ctor(const struct nvkm_disp_func *func, struct nvkm_device *device,
int index, int heads, struct nvkm_disp *disp)
{
disp->func = func;
disp->head.nr = heads;
INIT_LIST_HEAD(&disp->outp);
INIT_LIST_HEAD(&disp->conn);
return nvkm_engine_ctor(&nvkm_disp, device, index, true, &disp->engine);
} }
int int
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment