Add NVIF_HEAD_V0_STATE and nvif_head_state() to expose the hardware head timings and pixel clock already read by nvkm_head_func.state() to the DRM client layer.
Signed-off-by: Munique Feitoza <[email protected]> --- drivers/gpu/drm/nouveau/include/nvif/head.h | 13 ++++++++++ drivers/gpu/drm/nouveau/include/nvif/if0013.h | 17 +++++++++++++ drivers/gpu/drm/nouveau/nvif/head.c | 24 ++++++++++++++++++ .../gpu/drm/nouveau/nvkm/engine/disp/uhead.c | 25 +++++++++++++++++++ 4 files changed, 79 insertions(+) diff --git a/drivers/gpu/drm/nouveau/include/nvif/head.h b/drivers/gpu/drm/nouveau/include/nvif/head.h index 3ec36999e9560d..699ac6f6c316b4 100644 --- a/drivers/gpu/drm/nouveau/include/nvif/head.h +++ b/drivers/gpu/drm/nouveau/include/nvif/head.h @@ -18,6 +18,19 @@ nvif_head_id(struct nvif_head *head) return head->object.handle; } +struct nvif_head_state { + u32 hz; + u16 htotal; + u16 hsynce; + u16 hblanke; + u16 hblanks; + u16 vtotal; + u16 vsynce; + u16 vblanke; + u16 vblanks; +}; + +int nvif_head_state(struct nvif_head *head, struct nvif_head_state *state); int nvif_head_vblank_event_ctor(struct nvif_head *, const char *name, nvif_event_func, bool wait, struct nvif_event *); #endif diff --git a/drivers/gpu/drm/nouveau/include/nvif/if0013.h b/drivers/gpu/drm/nouveau/include/nvif/if0013.h index 6756c7467ae4ef..892d2347cacddd 100644 --- a/drivers/gpu/drm/nouveau/include/nvif/if0013.h +++ b/drivers/gpu/drm/nouveau/include/nvif/if0013.h @@ -16,6 +16,7 @@ union nvif_head_event_args { }; #define NVIF_HEAD_V0_SCANOUTPOS 0x00 +#define NVIF_HEAD_V0_STATE 0x01 union nvif_head_scanoutpos_args { struct nvif_head_scanoutpos_v0 { @@ -32,4 +33,20 @@ union nvif_head_scanoutpos_args { __u16 hline; } v0; }; + +union nvif_head_state_args { + struct nvif_head_state_v0 { + __u8 version; + __u8 pad01[3]; + __u32 hz; + __u16 htotal; + __u16 hsynce; + __u16 hblanke; + __u16 hblanks; + __u16 vtotal; + __u16 vsynce; + __u16 vblanke; + __u16 vblanks; + } v0; +}; #endif diff --git a/drivers/gpu/drm/nouveau/nvif/head.c b/drivers/gpu/drm/nouveau/nvif/head.c index f00e01d232db43..e751f73e56f2df 100644 --- a/drivers/gpu/drm/nouveau/nvif/head.c +++ b/drivers/gpu/drm/nouveau/nvif/head.c @@ -26,6 +26,30 @@ #include <nvif/class.h> #include <nvif/if0013.h> +int +nvif_head_state(struct nvif_head *head, struct nvif_head_state *state) +{ + struct nvif_head_state_v0 args; + int ret; + + args.version = 0; + + ret = nvif_object_mthd(&head->object, NVIF_HEAD_V0_STATE, &args, sizeof(args)); + if (ret) + return ret; + + state->hz = args.hz; + state->htotal = args.htotal; + state->hsynce = args.hsynce; + state->hblanke = args.hblanke; + state->hblanks = args.hblanks; + state->vtotal = args.vtotal; + state->vsynce = args.vsynce; + state->vblanke = args.vblanke; + state->vblanks = args.vblanks; + return 0; +} + int nvif_head_vblank_event_ctor(struct nvif_head *head, const char *name, nvif_event_func func, bool wait, struct nvif_event *event) diff --git a/drivers/gpu/drm/nouveau/nvkm/engine/disp/uhead.c b/drivers/gpu/drm/nouveau/nvkm/engine/disp/uhead.c index f072cec1604028..4181713fabb6f7 100644 --- a/drivers/gpu/drm/nouveau/nvkm/engine/disp/uhead.c +++ b/drivers/gpu/drm/nouveau/nvkm/engine/disp/uhead.c @@ -71,6 +71,30 @@ nvkm_uhead_mthd_scanoutpos(struct nvkm_head *head, void *argv, u32 argc) return 0; } +static int +nvkm_uhead_mthd_state(struct nvkm_head *head, void *argv, u32 argc) +{ + union nvif_head_state_args *args = argv; + + if (argc != sizeof(args->v0) || args->v0.version != 0) + return -ENOSYS; + + if (!head->func->state) + return -EOPNOTSUPP; + + head->func->state(head, &head->arm); + args->v0.hz = head->arm.hz; + args->v0.htotal = head->arm.htotal; + args->v0.hsynce = head->arm.hsynce; + args->v0.hblanke = head->arm.hblanke; + args->v0.hblanks = head->arm.hblanks; + args->v0.vtotal = head->arm.vtotal; + args->v0.vsynce = head->arm.vsynce; + args->v0.vblanke = head->arm.vblanke; + args->v0.vblanks = head->arm.vblanks; + return 0; +} + static int nvkm_uhead_mthd(struct nvkm_object *object, u32 mthd, void *argv, u32 argc) { @@ -78,6 +102,7 @@ nvkm_uhead_mthd(struct nvkm_object *object, u32 mthd, void *argv, u32 argc) switch (mthd) { case NVIF_HEAD_V0_SCANOUTPOS: return nvkm_uhead_mthd_scanoutpos(head, argv, argc); + case NVIF_HEAD_V0_STATE: return nvkm_uhead_mthd_state(head, argv, argc); default: return -EINVAL; } -- 2.56.1
