[PATCH 127/156] drm/nouveau/nvif: rework head "scanoutpos" api

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]<

 



- transition from "ioctl" interface

Signed-off-by: Ben Skeggs <bskeggs@xxxxxxxxxx>
---
 .../gpu/drm/nouveau/include/nvif/driverif.h   |  4 ++
 drivers/gpu/drm/nouveau/include/nvif/if0013.h | 18 --------
 drivers/gpu/drm/nouveau/nouveau_display.c     | 20 +++++----
 .../gpu/drm/nouveau/nvkm/engine/disp/uhead.c  | 43 +++++++------------
 4 files changed, 30 insertions(+), 55 deletions(-)

diff --git a/drivers/gpu/drm/nouveau/include/nvif/driverif.h b/drivers/gpu/drm/nouveau/include/nvif/driverif.h
index 83acedd108bb..927d0d75dd29 100644
--- a/drivers/gpu/drm/nouveau/include/nvif/driverif.h
+++ b/drivers/gpu/drm/nouveau/include/nvif/driverif.h
@@ -351,6 +351,10 @@ struct nvif_outp_impl {
 
 struct nvif_head_impl {
 	void (*del)(struct nvif_head_priv *);
+
+	int (*scanoutpos)(struct nvif_head_priv *, s64 time[2],
+			  u16 *vblanks, u16 *vblanke, u16 *vtotal, u16 *vline,
+			  u16 *hblanks, u16 *hblanke, u16 *htotal, u16 *hline);
 };
 
 struct nvif_disp_impl {
diff --git a/drivers/gpu/drm/nouveau/include/nvif/if0013.h b/drivers/gpu/drm/nouveau/include/nvif/if0013.h
index 751f75bf7e59..f2b39f86a9cc 100644
--- a/drivers/gpu/drm/nouveau/include/nvif/if0013.h
+++ b/drivers/gpu/drm/nouveau/include/nvif/if0013.h
@@ -6,22 +6,4 @@ union nvif_head_event_args {
 	struct nvif_head_event_vn {
 	} vn;
 };
-
-#define NVIF_HEAD_V0_SCANOUTPOS 0x00
-
-union nvif_head_scanoutpos_args {
-	struct nvif_head_scanoutpos_v0 {
-		__u8  version;
-		__u8  pad01[7];
-		__s64 time[2];
-		__u16 vblanks;
-		__u16 vblanke;
-		__u16 vtotal;
-		__u16 vline;
-		__u16 hblanks;
-		__u16 hblanke;
-		__u16 htotal;
-		__u16 hline;
-	} v0;
-};
 #endif
diff --git a/drivers/gpu/drm/nouveau/nouveau_display.c b/drivers/gpu/drm/nouveau/nouveau_display.c
index 27b69032fd9e..0d2dae7a94d0 100644
--- a/drivers/gpu/drm/nouveau/nouveau_display.c
+++ b/drivers/gpu/drm/nouveau/nouveau_display.c
@@ -85,18 +85,20 @@ nouveau_display_scanoutpos_head(struct drm_crtc *crtc, int *vpos, int *hpos,
 {
 	struct drm_vblank_crtc *vblank = &crtc->dev->vblank[drm_crtc_index(crtc)];
 	struct nvif_head *head = &nouveau_crtc(crtc)->head;
-	struct nvif_head_scanoutpos_v0 args;
+	u16 vblanks, vblanke, vtotal, vline;
+	u16 hblanks, hblanke, htotal, hline;
+	s64 time[2];
 	int retry = 20;
 	bool ret = false;
 
-	args.version = 0;
-
 	do {
-		ret = nvif_mthd(&head->object, NVIF_HEAD_V0_SCANOUTPOS, &args, sizeof(args));
+		ret = head->impl->scanoutpos(head->priv, time,
+					     &vblanks, &vblanke, &vtotal, &vline,
+					     &hblanks, &hblanke, &htotal, &hline);
 		if (ret != 0)
 			return false;
 
-		if (args.vline) {
+		if (vline) {
 			ret = true;
 			break;
 		}
@@ -104,10 +106,10 @@ nouveau_display_scanoutpos_head(struct drm_crtc *crtc, int *vpos, int *hpos,
 		if (retry) ndelay(vblank->linedur_ns);
 	} while (retry--);
 
-	*hpos = args.hline;
-	*vpos = calc(args.vblanks, args.vblanke, args.vtotal, args.vline);
-	if (stime) *stime = ns_to_ktime(args.time[0]);
-	if (etime) *etime = ns_to_ktime(args.time[1]);
+	*hpos = hline;
+	*vpos = calc(vblanks, vblanke, vtotal, vline);
+	if (stime) *stime = ns_to_ktime(time[0]);
+	if (etime) *etime = ns_to_ktime(time[1]);
 
 	return ret;
 }
diff --git a/drivers/gpu/drm/nouveau/nvkm/engine/disp/uhead.c b/drivers/gpu/drm/nouveau/nvkm/engine/disp/uhead.c
index 3456e988f9b3..ebf72333ae99 100644
--- a/drivers/gpu/drm/nouveau/nvkm/engine/disp/uhead.c
+++ b/drivers/gpu/drm/nouveau/nvkm/engine/disp/uhead.c
@@ -47,46 +47,33 @@ nvkm_uhead_uevent(struct nvkm_object *object, void *argv, u32 argc, struct nvkm_
 }
 
 static int
-nvkm_uhead_mthd_scanoutpos(struct nvkm_head *head, void *argv, u32 argc)
+nvkm_uhead_scanoutpos(struct nvif_head_priv *uhead, s64 time[2],
+		      u16 *vblanks, u16 *vblanke, u16 *vtotal, u16 *vline,
+		      u16 *hblanks, u16 *hblanke, u16 *htotal, u16 *hline)
 {
-	union nvif_head_scanoutpos_args *args = argv;
-
-	if (argc != sizeof(args->v0) || args->v0.version != 0)
-		return -ENOSYS;
+	struct nvkm_head *head = uhead->head;
 
 	head->func->state(head, &head->arm);
-	args->v0.vtotal  = head->arm.vtotal;
-	args->v0.vblanks = head->arm.vblanks;
-	args->v0.vblanke = head->arm.vblanke;
-	args->v0.htotal  = head->arm.htotal;
-	args->v0.hblanks = head->arm.hblanks;
-	args->v0.hblanke = head->arm.hblanke;
+	*vtotal  = head->arm.vtotal;
+	*vblanks = head->arm.vblanks;
+	*vblanke = head->arm.vblanke;
+	*htotal  = head->arm.htotal;
+	*hblanks = head->arm.hblanks;
+	*hblanke = head->arm.hblanke;
 
 	/* We don't support reading htotal/vtotal on pre-NV50 VGA,
 	 * so we have to give up and trigger the timestamping
 	 * fallback in the drm core.
 	 */
-	if (!args->v0.vtotal || !args->v0.htotal)
+	if (!*vtotal || !*htotal)
 		return -ENOTSUPP;
 
-	args->v0.time[0] = ktime_to_ns(ktime_get());
-	head->func->rgpos(head, &args->v0.hline, &args->v0.vline);
-	args->v0.time[1] = ktime_to_ns(ktime_get());
+	time[0] = ktime_to_ns(ktime_get());
+	head->func->rgpos(head, hline, vline);
+	time[1] = ktime_to_ns(ktime_get());
 	return 0;
 }
 
-static int
-nvkm_uhead_mthd(struct nvkm_object *object, u32 mthd, void *argv, u32 argc)
-{
-	struct nvkm_head *head = container_of(object, struct nvif_head_priv, object)->head;
-
-	switch (mthd) {
-	case NVIF_HEAD_V0_SCANOUTPOS: return nvkm_uhead_mthd_scanoutpos(head, argv, argc);
-	default:
-		return -EINVAL;
-	}
-}
-
 static void
 nvkm_uhead_del(struct nvif_head_priv *uhead)
 {
@@ -98,6 +85,7 @@ nvkm_uhead_del(struct nvif_head_priv *uhead)
 static const struct nvif_head_impl
 nvkm_uhead_impl = {
 	.del = nvkm_uhead_del,
+	.scanoutpos = nvkm_uhead_scanoutpos,
 };
 
 static void *
@@ -115,7 +103,6 @@ nvkm_uhead_dtor(struct nvkm_object *object)
 static const struct nvkm_object_func
 nvkm_uhead = {
 	.dtor = nvkm_uhead_dtor,
-	.mthd = nvkm_uhead_mthd,
 	.uevent = nvkm_uhead_uevent,
 };
 
-- 
2.41.0




[Index of Archives]     [Linux ARM Kernel]     [Linux ARM]     [Linux Omap]     [Fedora ARM]     [IETF Annouce]     [Security]     [Bugtraq]     [Linux]     [Linux OMAP]     [Linux MIPS]     [eCos]     [Asterisk Internet PBX]     [Linux API]

  Powered by Linux