mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Munique Feitoza <muniquefeitoz4@gmail.com>
To: Lyude Paul <lyude.paul@maintainer.cc>,
	Danilo Krummrich <dakr@kernel.org>
Cc: Maarten Lankhorst <maarten.lankhorst@linux.intel.com>,
	Maxime Ripard <mripard@kernel.org>,
	Thomas Zimmermann <tzimmermann@suse.de>,
	David Airlie <airlied@gmail.com>, Simona Vetter <simona@ffwll.ch>,
	nouveau@lists.freedesktop.org, dri-devel@lists.freedesktop.org,
	linux-kernel@vger.kernel.org,
	Munique Feitoza <muniquefeitoz4@gmail.com>
Subject: [PATCH v2 1/2] drm/nouveau/nvif: add NVIF_HEAD_V0_STATE method for head timing readback
Date: Sun,  6 Dec 2026 05:31:33 -0300	[thread overview]
Message-ID: <20261206083134.6503-2-muniquefeitoz4@gmail.com> (raw)
In-Reply-To: <20261206083134.6503-1-muniquefeitoz4@gmail.com>

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 <muniquefeitoz4@gmail.com>
---
 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


  reply	other threads:[~2026-12-06  8:31 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-12-05 17:25 [PATCH] drm/nouveau/dispnv50: skip vblank and timestamp constants when dotclock is 0 Munique Feitoza
2026-12-06  8:31 ` [PATCH v2 0/2] drm/nouveau/dispnv50: read back inherited firmware head mode timings Munique Feitoza
2026-12-06  8:31   ` Munique Feitoza [this message]
2026-12-06  8:31   ` [PATCH v2 2/2] drm/nouveau/dispnv50: read back hardware mode timings on probe Munique Feitoza

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20261206083134.6503-2-muniquefeitoz4@gmail.com \
    --to=muniquefeitoz4@gmail.com \
    --cc=airlied@gmail.com \
    --cc=dakr@kernel.org \
    --cc=dri-devel@lists.freedesktop.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=lyude.paul@maintainer.cc \
    --cc=maarten.lankhorst@linux.intel.com \
    --cc=mripard@kernel.org \
    --cc=nouveau@lists.freedesktop.org \
    --cc=simona@ffwll.ch \
    --cc=tzimmermann@suse.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®