summaryrefslogtreecommitdiff
path: root/drivers/gpu/drm/nouveau/nvkm/engine/disp/base.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/gpu/drm/nouveau/nvkm/engine/disp/base.c')
-rw-r--r--drivers/gpu/drm/nouveau/nvkm/engine/disp/base.c243
1 files changed, 127 insertions, 116 deletions
diff --git a/drivers/gpu/drm/nouveau/nvkm/engine/disp/base.c b/drivers/gpu/drm/nouveau/nvkm/engine/disp/base.c
index 1efe91b1e22b..c7c84d34d97e 100644
--- a/drivers/gpu/drm/nouveau/nvkm/engine/disp/base.c
+++ b/drivers/gpu/drm/nouveau/nvkm/engine/disp/base.c
@@ -23,6 +23,9 @@
*/
#include "priv.h"
#include "conn.h"
+#include "dp.h"
+#include "head.h"
+#include "ior.h"
#include "outp.h"
#include <core/client.h>
@@ -37,17 +40,21 @@
#include <nvif/unpack.h>
static void
-nvkm_disp_vblank_fini(struct nvkm_event *event, int type, int head)
+nvkm_disp_vblank_fini(struct nvkm_event *event, int type, int id)
{
struct nvkm_disp *disp = container_of(event, typeof(*disp), vblank);
- disp->func->head.vblank_fini(disp, head);
+ struct nvkm_head *head = nvkm_head_find(disp, id);
+ if (head)
+ head->func->vblank_put(head);
}
static void
-nvkm_disp_vblank_init(struct nvkm_event *event, int type, int head)
+nvkm_disp_vblank_init(struct nvkm_event *event, int type, int id)
{
struct nvkm_disp *disp = container_of(event, typeof(*disp), vblank);
- disp->func->head.vblank_init(disp, head);
+ struct nvkm_head *head = nvkm_head_find(disp, id);
+ if (head)
+ head->func->vblank_get(head);
}
static int
@@ -96,7 +103,7 @@ nvkm_disp_hpd_ctor(struct nvkm_object *object, void *data, u32 size,
union {
struct nvif_notify_conn_req_v0 v0;
} *req = data;
- struct nvkm_output *outp;
+ struct nvkm_outp *outp;
int ret = -ENOSYS;
if (!(ret = nvif_unpack(ret, &data, &size, req->v0, 0, 0, false))) {
@@ -210,15 +217,15 @@ static int
nvkm_disp_fini(struct nvkm_engine *engine, bool suspend)
{
struct nvkm_disp *disp = nvkm_disp(engine);
- struct nvkm_connector *conn;
- struct nvkm_output *outp;
+ struct nvkm_conn *conn;
+ struct nvkm_outp *outp;
list_for_each_entry(outp, &disp->outp, head) {
- nvkm_output_fini(outp);
+ nvkm_outp_fini(outp);
}
list_for_each_entry(conn, &disp->conn, head) {
- nvkm_connector_fini(conn);
+ nvkm_conn_fini(conn);
}
return 0;
@@ -228,129 +235,70 @@ static int
nvkm_disp_init(struct nvkm_engine *engine)
{
struct nvkm_disp *disp = nvkm_disp(engine);
- struct nvkm_connector *conn;
- struct nvkm_output *outp;
+ struct nvkm_conn *conn;
+ struct nvkm_outp *outp;
list_for_each_entry(conn, &disp->conn, head) {
- nvkm_connector_init(conn);
+ nvkm_conn_init(conn);
}
list_for_each_entry(outp, &disp->outp, head) {
- nvkm_output_init(outp);
+ nvkm_outp_init(outp);
}
return 0;
}
-static void *
-nvkm_disp_dtor(struct nvkm_engine *engine)
+static int
+nvkm_disp_oneinit(struct nvkm_engine *engine)
{
struct nvkm_disp *disp = nvkm_disp(engine);
- struct nvkm_connector *conn;
- struct nvkm_output *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_output_del(&outp);
- }
-
- while (!list_empty(&disp->conn)) {
- conn = list_first_entry(&disp->conn, typeof(*conn), head);
- list_del(&conn->head);
- nvkm_connector_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_output *outp, *outt, *pair;
- struct nvkm_connector *conn;
+ struct nvkm_subdev *subdev = &disp->engine.subdev;
+ struct nvkm_bios *bios = subdev->device->bios;
+ struct nvkm_outp *outp, *outt, *pair;
+ struct nvkm_conn *conn;
+ struct nvkm_head *head;
struct nvbios_connE connE;
struct dcb_output dcbE;
u8 hpd = 0, ver, hdr;
u32 data;
int ret, i;
- INIT_LIST_HEAD(&disp->outp);
- 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 */
+ /* Create output path objects for each VBIOS display path. */
i = -1;
while ((data = dcb_outp_parse(bios, ++i, &ver, &hdr, &dcbE))) {
- const struct nvkm_disp_func_outp *outps;
- int (*ctor)(struct nvkm_disp *, int, struct dcb_output *,
- struct nvkm_output **);
-
if (dcbE.type == DCB_OUTPUT_UNUSED)
continue;
if (dcbE.type == DCB_OUTPUT_EOL)
break;
outp = NULL;
- switch (dcbE.location) {
- case 0: outps = &disp->func->outp.internal; break;
- case 1: outps = &disp->func->outp.external; break;
- default:
- nvkm_warn(&disp->engine.subdev,
- "dcb %d locn %d unknown\n", i, dcbE.location);
- continue;
- }
-
switch (dcbE.type) {
- case DCB_OUTPUT_ANALOG: ctor = outps->crt ; break;
- case DCB_OUTPUT_TV : ctor = outps->tv ; break;
- case DCB_OUTPUT_TMDS : ctor = outps->tmds; break;
- case DCB_OUTPUT_LVDS : ctor = outps->lvds; break;
- case DCB_OUTPUT_DP : ctor = outps->dp ; break;
+ case DCB_OUTPUT_ANALOG:
+ case DCB_OUTPUT_TV:
+ case DCB_OUTPUT_TMDS:
+ case DCB_OUTPUT_LVDS:
+ ret = nvkm_outp_new(disp, i, &dcbE, &outp);
+ break;
+ case DCB_OUTPUT_DP:
+ ret = nvkm_dp_new(disp, i, &dcbE, &outp);
+ break;
default:
- nvkm_warn(&disp->engine.subdev,
- "dcb %d type %d unknown\n", i, dcbE.type);
+ nvkm_warn(subdev, "dcb %d type %d unknown\n",
+ i, dcbE.type);
continue;
}
- if (ctor)
- ret = ctor(disp, i, &dcbE, &outp);
- else
- ret = -ENODEV;
-
if (ret) {
- if (ret == -ENODEV) {
- nvkm_debug(&disp->engine.subdev,
- "dcb %d %d/%d not supported\n",
- i, dcbE.location, dcbE.type);
+ if (outp) {
+ if (ret != -ENODEV)
+ OUTP_ERR(outp, "ctor failed: %d", ret);
+ else
+ OUTP_DBG(outp, "not supported");
+ nvkm_outp_del(&outp);
continue;
}
- nvkm_error(&disp->engine.subdev,
- "failed to create output %d\n", i);
- nvkm_output_del(&outp);
+ nvkm_error(subdev, "failed to create outp %d\n", i);
continue;
}
@@ -358,18 +306,18 @@ nvkm_disp_ctor(const struct nvkm_disp_func *func, struct nvkm_device *device,
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) {
- /* 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,
&connE);
- /* no bios connector data... */
+ /* No bios connector 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
* 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;
if (ccb_index != 0xf) {
@@ -381,7 +329,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)
continue;
@@ -392,7 +340,7 @@ nvkm_disp_ctor(const struct nvkm_disp_func *func, struct nvkm_device *device,
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) {
if (conn->index == outp->info.connector) {
outp->conn = conn;
@@ -403,15 +351,15 @@ nvkm_disp_ctor(const struct nvkm_disp_func *func, struct nvkm_device *device,
if (outp->conn)
continue;
- /* apparently we need to create a new one! */
- ret = nvkm_connector_new(disp, i, &connE, &outp->conn);
+ /* Apparently we need to create a new one! */
+ ret = nvkm_conn_new(disp, i, &connE, &outp->conn);
if (ret) {
nvkm_error(&disp->engine.subdev,
- "failed to create output %d conn: %d\n",
+ "failed to create outp %d conn: %d\n",
outp->index, ret);
- nvkm_connector_del(&outp->conn);
+ nvkm_conn_del(&outp->conn);
list_del(&outp->head);
- nvkm_output_del(&outp);
+ nvkm_outp_del(&outp);
continue;
}
@@ -422,18 +370,81 @@ nvkm_disp_ctor(const struct nvkm_disp_func *func, struct nvkm_device *device,
if (ret)
return ret;
- ret = nvkm_event_init(&nvkm_disp_vblank_func, 1, heads, &disp->vblank);
- if (ret)
- return ret;
+ i = 0;
+ list_for_each_entry(head, &disp->head, head)
+ i = max(i, head->id + 1);
- return 0;
+ return nvkm_event_init(&nvkm_disp_vblank_func, 1, i, &disp->vblank);
+}
+
+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);
+ }
+
+ while (!list_empty(&disp->ior)) {
+ struct nvkm_ior *ior =
+ list_first_entry(&disp->ior, typeof(*ior), head);
+ nvkm_ior_del(&ior);
+ }
+
+ while (!list_empty(&disp->head)) {
+ struct nvkm_head *head =
+ list_first_entry(&disp->head, typeof(*head), head);
+ nvkm_head_del(&head);
+ }
+
+ 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, struct nvkm_disp *disp)
+{
+ disp->func = func;
+ INIT_LIST_HEAD(&disp->head);
+ INIT_LIST_HEAD(&disp->ior);
+ INIT_LIST_HEAD(&disp->outp);
+ INIT_LIST_HEAD(&disp->conn);
+ return nvkm_engine_ctor(&nvkm_disp, device, index, true, &disp->engine);
}
int
nvkm_disp_new_(const struct nvkm_disp_func *func, struct nvkm_device *device,
- int index, int heads, struct nvkm_disp **pdisp)
+ int index, struct nvkm_disp **pdisp)
{
if (!(*pdisp = kzalloc(sizeof(**pdisp), GFP_KERNEL)))
return -ENOMEM;
- return nvkm_disp_ctor(func, device, index, heads, *pdisp);
+ return nvkm_disp_ctor(func, device, index, *pdisp);
}