- transition from "ioctl" interface Signed-off-by: Ben Skeggs <bskeggs@xxxxxxxxxx> --- drivers/gpu/drm/nouveau/include/nvif/conn.h | 18 ++----- .../gpu/drm/nouveau/include/nvif/driverif.h | 20 +++++++ drivers/gpu/drm/nouveau/include/nvif/if0011.h | 18 ------- drivers/gpu/drm/nouveau/nouveau_connector.c | 2 +- drivers/gpu/drm/nouveau/nvif/conn.c | 32 +++--------- .../gpu/drm/nouveau/nvkm/engine/disp/priv.h | 1 - .../gpu/drm/nouveau/nvkm/engine/disp/uconn.c | 52 ++++++++++++------- .../gpu/drm/nouveau/nvkm/engine/disp/uconn.h | 3 ++ .../gpu/drm/nouveau/nvkm/engine/disp/udisp.c | 24 ++++++--- 9 files changed, 87 insertions(+), 83 deletions(-) diff --git a/drivers/gpu/drm/nouveau/include/nvif/conn.h b/drivers/gpu/drm/nouveau/include/nvif/conn.h index 406c12a111f9..0f0ca002fe47 100644 --- a/drivers/gpu/drm/nouveau/include/nvif/conn.h +++ b/drivers/gpu/drm/nouveau/include/nvif/conn.h @@ -2,26 +2,16 @@ #ifndef __NVIF_CONN_H__ #define __NVIF_CONN_H__ #include <nvif/object.h> +#include <nvif/driverif.h> #include <nvif/event.h> struct nvif_disp; struct nvif_conn { + const struct nvif_conn_impl *impl; + struct nvif_conn_priv *priv; struct nvif_object object; - u32 id; - struct { - enum { - NVIF_CONN_VGA, - NVIF_CONN_TV, - NVIF_CONN_DVI_I, - NVIF_CONN_DVI_D, - NVIF_CONN_LVDS, - NVIF_CONN_LVDS_SPWG, - NVIF_CONN_HDMI, - NVIF_CONN_DP, - NVIF_CONN_EDP, - } type; - } info; + u32 id; }; int nvif_conn_ctor(struct nvif_disp *, const char *name, int id, struct nvif_conn *); diff --git a/drivers/gpu/drm/nouveau/include/nvif/driverif.h b/drivers/gpu/drm/nouveau/include/nvif/driverif.h index 412b2dff3a74..fb741c7293f6 100644 --- a/drivers/gpu/drm/nouveau/include/nvif/driverif.h +++ b/drivers/gpu/drm/nouveau/include/nvif/driverif.h @@ -12,6 +12,7 @@ struct nvif_vmm_priv; struct nvif_faultbuf_priv; struct nvif_disp_priv; struct nvif_disp_caps_priv; +struct nvif_conn_priv; struct nvif_driver { const char *name; @@ -223,6 +224,22 @@ struct nvif_disp_caps_impl { struct nvif_mapinfo map; }; +struct nvif_conn_impl { + void (*del)(struct nvif_conn_priv *); + + enum nvif_conn_type { + NVIF_CONN_VGA, + NVIF_CONN_TV, + NVIF_CONN_DVI_I, + NVIF_CONN_DVI_D, + NVIF_CONN_HDMI, + NVIF_CONN_LVDS, + NVIF_CONN_LVDS_SPWG, + NVIF_CONN_DP, + NVIF_CONN_EDP, + } type; +}; + struct nvif_disp_impl { void (*del)(struct nvif_disp_priv *); @@ -234,6 +251,9 @@ struct nvif_disp_impl { struct { u32 mask; + int (*new)(struct nvif_disp_priv *, u8 id, + const struct nvif_conn_impl **, struct nvif_conn_priv **, + u64 handle); } conn; struct { diff --git a/drivers/gpu/drm/nouveau/include/nvif/if0011.h b/drivers/gpu/drm/nouveau/include/nvif/if0011.h index 3ed0ddd75bd8..6e717445d10a 100644 --- a/drivers/gpu/drm/nouveau/include/nvif/if0011.h +++ b/drivers/gpu/drm/nouveau/include/nvif/if0011.h @@ -2,24 +2,6 @@ #ifndef __NVIF_IF0011_H__ #define __NVIF_IF0011_H__ -union nvif_conn_args { - struct nvif_conn_v0 { - __u8 version; - __u8 id; /* DCB connector table index. */ - __u8 pad02[6]; -#define NVIF_CONN_V0_VGA 0x00 -#define NVIF_CONN_V0_TV 0x01 -#define NVIF_CONN_V0_DVI_I 0x02 -#define NVIF_CONN_V0_DVI_D 0x03 -#define NVIF_CONN_V0_LVDS 0x04 -#define NVIF_CONN_V0_LVDS_SPWG 0x05 -#define NVIF_CONN_V0_HDMI 0x06 -#define NVIF_CONN_V0_DP 0x07 -#define NVIF_CONN_V0_EDP 0x08 - __u8 type; - } v0; -}; - union nvif_conn_event_args { struct nvif_conn_event_v0 { __u8 version; diff --git a/drivers/gpu/drm/nouveau/nouveau_connector.c b/drivers/gpu/drm/nouveau/nouveau_connector.c index 856b3ef5edb8..b1bd8264b703 100644 --- a/drivers/gpu/drm/nouveau/nouveau_connector.c +++ b/drivers/gpu/drm/nouveau/nouveau_connector.c @@ -1311,7 +1311,7 @@ nouveau_connector_create(struct drm_device *dev, int index) return ERR_PTR(ret); } - switch (nv_connector->conn.info.type) { + switch (nv_connector->conn.impl->type) { case NVIF_CONN_VGA : type = DCB_CONNECTOR_VGA; break; case NVIF_CONN_DVI_I : type = DCB_CONNECTOR_DVI_I; break; case NVIF_CONN_DVI_D : type = DCB_CONNECTOR_DVI_D; break; diff --git a/drivers/gpu/drm/nouveau/nvif/conn.c b/drivers/gpu/drm/nouveau/nvif/conn.c index 9ee18cb99264..48927282a7ce 100644 --- a/drivers/gpu/drm/nouveau/nvif/conn.c +++ b/drivers/gpu/drm/nouveau/nvif/conn.c @@ -23,7 +23,6 @@ #include <nvif/disp.h> #include <nvif/printf.h> -#include <nvif/class.h> #include <nvif/if0011.h> int @@ -48,40 +47,25 @@ nvif_conn_event_ctor(struct nvif_conn *conn, const char *name, nvif_event_func f void nvif_conn_dtor(struct nvif_conn *conn) { - nvif_object_dtor(&conn->object); + if (!conn->impl) + return; + + conn->impl->del(conn->priv); + conn->impl = NULL; } int nvif_conn_ctor(struct nvif_disp *disp, const char *name, int id, struct nvif_conn *conn) { - struct nvif_conn_v0 args; int ret; - args.version = 0; - args.id = id; - - ret = nvif_object_ctor(&disp->object, name ?: "nvifConn", id, NVIF_CLASS_CONN, - &args, sizeof(args), &conn->object); + ret = disp->impl->conn.new(disp->priv, id, &conn->impl, &conn->priv, + nvif_handle(&conn->object)); NVIF_ERRON(ret, &disp->object, "[NEW conn id:%d]", id); if (ret) return ret; + nvif_object_ctor(&disp->object, name ?: "nvifConn", id, 0, &conn->object); conn->id = id; - - switch (args.type) { - case NVIF_CONN_V0_VGA : conn->info.type = NVIF_CONN_VGA; break; - case NVIF_CONN_V0_TV : conn->info.type = NVIF_CONN_TV; break; - case NVIF_CONN_V0_DVI_I : conn->info.type = NVIF_CONN_DVI_I; break; - case NVIF_CONN_V0_DVI_D : conn->info.type = NVIF_CONN_DVI_D; break; - case NVIF_CONN_V0_LVDS : conn->info.type = NVIF_CONN_LVDS; break; - case NVIF_CONN_V0_LVDS_SPWG: conn->info.type = NVIF_CONN_LVDS_SPWG; break; - case NVIF_CONN_V0_HDMI : conn->info.type = NVIF_CONN_HDMI; break; - case NVIF_CONN_V0_DP : conn->info.type = NVIF_CONN_DP; break; - case NVIF_CONN_V0_EDP : conn->info.type = NVIF_CONN_EDP; break; - default: - break; - } - return 0; - } diff --git a/drivers/gpu/drm/nouveau/nvkm/engine/disp/priv.h b/drivers/gpu/drm/nouveau/nvkm/engine/disp/priv.h index 822c4ffe5a38..890cfb23da77 100644 --- a/drivers/gpu/drm/nouveau/nvkm/engine/disp/priv.h +++ b/drivers/gpu/drm/nouveau/nvkm/engine/disp/priv.h @@ -89,7 +89,6 @@ void nv50_disp_chan_uevent_send(struct nvkm_disp *, int); extern const struct nvkm_event_func gf119_disp_chan_uevent; extern const struct nvkm_event_func gv100_disp_chan_uevent; -int nvkm_uconn_new(const struct nvkm_oclass *, void *, u32, struct nvkm_object **); int nvkm_uoutp_new(const struct nvkm_oclass *, void *, u32, struct nvkm_object **); int nvkm_uhead_new(const struct nvkm_oclass *, void *, u32, struct nvkm_object **); #endif diff --git a/drivers/gpu/drm/nouveau/nvkm/engine/disp/uconn.c b/drivers/gpu/drm/nouveau/nvkm/engine/disp/uconn.c index 773e49e557f8..5f72db9276b8 100644 --- a/drivers/gpu/drm/nouveau/nvkm/engine/disp/uconn.c +++ b/drivers/gpu/drm/nouveau/nvkm/engine/disp/uconn.c @@ -32,6 +32,8 @@ struct nvif_conn_priv { struct nvkm_object object; struct nvkm_conn *conn; + + struct nvif_conn_impl impl; }; static int @@ -152,6 +154,19 @@ nvkm_uconn_uevent(struct nvkm_object *object, void *argv, u32 argc, struct nvkm_ nvkm_uconn_uevent_gpio); } +static void +nvkm_uconn_del(struct nvif_conn_priv *uconn) +{ + struct nvkm_object *object = &uconn->object; + + nvkm_object_del(&object); +} + +static const struct nvif_conn_impl +nvkm_uconn_impl = { + .del = nvkm_uconn_del, +}; + static void * nvkm_uconn_dtor(struct nvkm_object *object) { @@ -170,20 +185,16 @@ nvkm_uconn = { .uevent = nvkm_uconn_uevent, }; -#include "udisp.h" int -nvkm_uconn_new(const struct nvkm_oclass *oclass, void *argv, u32 argc, struct nvkm_object **pobject) +nvkm_uconn_new(struct nvkm_disp *disp, u8 id, const struct nvif_conn_impl **pimpl, + struct nvif_conn_priv **ppriv, struct nvkm_object **pobject) { - struct nvkm_disp *disp = container_of(oclass->parent, struct nvif_disp_priv, object)->disp; struct nvkm_conn *cont, *conn = NULL; - union nvif_conn_args *args = argv; struct nvif_conn_priv *uconn; - - if (argc != sizeof(args->v0) || args->v0.version != 0) - return -ENOSYS; + enum nvif_conn_type type; list_for_each_entry(cont, &disp->conns, head) { - if (cont->index == args->v0.id) { + if (cont->index == id) { conn = cont; break; } @@ -193,25 +204,25 @@ nvkm_uconn_new(const struct nvkm_oclass *oclass, void *argv, u32 argc, struct nv return -EINVAL; switch (conn->info.type) { - case DCB_CONNECTOR_VGA : args->v0.type = NVIF_CONN_V0_VGA; break; + case DCB_CONNECTOR_VGA : type = NVIF_CONN_VGA; break; case DCB_CONNECTOR_TV_0 : case DCB_CONNECTOR_TV_1 : - case DCB_CONNECTOR_TV_3 : args->v0.type = NVIF_CONN_V0_TV; break; + case DCB_CONNECTOR_TV_3 : type = NVIF_CONN_TV; break; case DCB_CONNECTOR_DMS59_0 : case DCB_CONNECTOR_DMS59_1 : - case DCB_CONNECTOR_DVI_I : args->v0.type = NVIF_CONN_V0_DVI_I; break; - case DCB_CONNECTOR_DVI_D : args->v0.type = NVIF_CONN_V0_DVI_D; break; - case DCB_CONNECTOR_LVDS : args->v0.type = NVIF_CONN_V0_LVDS; break; - case DCB_CONNECTOR_LVDS_SPWG: args->v0.type = NVIF_CONN_V0_LVDS_SPWG; break; + case DCB_CONNECTOR_DVI_I : type = NVIF_CONN_DVI_I; break; + case DCB_CONNECTOR_DVI_D : type = NVIF_CONN_DVI_D; break; + case DCB_CONNECTOR_LVDS : type = NVIF_CONN_LVDS; break; + case DCB_CONNECTOR_LVDS_SPWG: type = NVIF_CONN_LVDS_SPWG; break; case DCB_CONNECTOR_DMS59_DP0: case DCB_CONNECTOR_DMS59_DP1: case DCB_CONNECTOR_DP : case DCB_CONNECTOR_mDP : - case DCB_CONNECTOR_USB_C : args->v0.type = NVIF_CONN_V0_DP; break; - case DCB_CONNECTOR_eDP : args->v0.type = NVIF_CONN_V0_EDP; break; + case DCB_CONNECTOR_USB_C : type = NVIF_CONN_DP; break; + case DCB_CONNECTOR_eDP : type = NVIF_CONN_EDP; break; case DCB_CONNECTOR_HDMI_0 : case DCB_CONNECTOR_HDMI_1 : - case DCB_CONNECTOR_HDMI_C : args->v0.type = NVIF_CONN_V0_HDMI; break; + case DCB_CONNECTOR_HDMI_C : type = NVIF_CONN_HDMI; break; default: WARN_ON(1); return -EINVAL; @@ -230,8 +241,13 @@ nvkm_uconn_new(const struct nvkm_oclass *oclass, void *argv, u32 argc, struct nv conn->user = true; spin_unlock(&disp->user.lock); - nvkm_object_ctor(&nvkm_uconn, oclass, &uconn->object); + nvkm_object_ctor(&nvkm_uconn, &(struct nvkm_oclass) {}, &uconn->object); + uconn->impl = nvkm_uconn_impl; + uconn->impl.type = type; uconn->conn = conn; + + *pimpl = &uconn->impl; + *ppriv = uconn; *pobject = &uconn->object; return 0; } diff --git a/drivers/gpu/drm/nouveau/nvkm/engine/disp/uconn.h b/drivers/gpu/drm/nouveau/nvkm/engine/disp/uconn.h index f53d151e5b09..736d24951b12 100644 --- a/drivers/gpu/drm/nouveau/nvkm/engine/disp/uconn.h +++ b/drivers/gpu/drm/nouveau/nvkm/engine/disp/uconn.h @@ -2,5 +2,8 @@ #ifndef __NVKM_UCONN_H__ #define __NVKM_UCONN_H__ #include "conn.h" +#include <nvif/driverif.h> +int nvkm_uconn_new(struct nvkm_disp *, u8 id, const struct nvif_conn_impl **, + struct nvif_conn_priv **, struct nvkm_object **); #endif diff --git a/drivers/gpu/drm/nouveau/nvkm/engine/disp/udisp.c b/drivers/gpu/drm/nouveau/nvkm/engine/disp/udisp.c index cef8427cca91..01333ded466b 100644 --- a/drivers/gpu/drm/nouveau/nvkm/engine/disp/udisp.c +++ b/drivers/gpu/drm/nouveau/nvkm/engine/disp/udisp.c @@ -22,7 +22,7 @@ #include "udisp.h" #include "ucaps.h" #include "chan.h" -#include "conn.h" +#include "uconn.h" #include "head.h" #include "outp.h" @@ -33,12 +33,6 @@ nvkm_udisp_sclass(struct nvkm_object *object, int index, struct nvkm_oclass *scl { struct nvkm_disp *disp = container_of(object, struct nvif_disp_priv, object)->disp; - if (index-- == 0) { - sclass->base = (struct nvkm_sclass) { 0, 0, NVIF_CLASS_CONN }; - sclass->ctor = nvkm_uconn_new; - return 0; - } - if (index-- == 0) { sclass->base = (struct nvkm_sclass) { 0, 0, NVIF_CLASS_OUTP }; sclass->ctor = nvkm_uoutp_new; @@ -96,6 +90,21 @@ nvkm_udisp_sclass(struct nvkm_object *object, int index, struct nvkm_oclass *scl return -EINVAL; } +static int +nvkm_udisp_conn_new(struct nvif_disp_priv *udisp, u8 id, + const struct nvif_conn_impl **pimpl, struct nvif_conn_priv **ppriv, + u64 handle) +{ + struct nvkm_object *object; + int ret; + + ret = nvkm_uconn_new(udisp->disp, id, pimpl, ppriv, &object); + if (ret) + return ret; + + return nvkm_object_link_rb(udisp->object.client, &udisp->object, handle, object); +} + static int nvkm_udisp_caps_new(struct nvif_disp_priv *udisp, const struct nvif_disp_caps_impl **pimpl, struct nvif_disp_caps_priv **ppriv) @@ -123,6 +132,7 @@ nvkm_udisp_del(struct nvif_disp_priv *udisp) static const struct nvif_disp_impl nvkm_udisp_impl = { .del = nvkm_udisp_del, + .conn.new = nvkm_udisp_conn_new, }; static void * -- 2.41.0