From: Thomas Zimmermann <tzimmermann@suse.de>
To: airlied@linux.ie, daniel@ffwll.ch, alexander.deucher@amd.com,
christian.koenig@amd.com, David1.Zhou@amd.com,
maarten.lankhorst@linux.intel.com, patrik.r.jakobsson@gmail.com,
robdclark@gmail.com, sean@poorly.run,
benjamin.gaignard@linaro.org, vincent.abriou@st.com,
yannick.fertre@st.com, philippe.cornu@st.com,
mcoquelin.stm32@gmail.com, alexandre.torgue@st.com,
eric@anholt.net, rodrigosiqueiramelo@gmail.com,
hamohammed.sa@gmail.com, linux-graphics-maintainer@vmware.com,
thellstrom@vmware.com, bskeggs@redhat.com,
harry.wentland@amd.com, sunpeng.li@amd.com,
jani.nikula@linux.intel.com, joonas.lahtinen@linux.intel.com,
rodrigo.vivi@intel.com
Cc: linux-arm-msm@vger.kernel.org, intel-gfx@lists.freedesktop.org,
amd-gfx@lists.freedesktop.org, dri-devel@lists.freedesktop.org,
Thomas Zimmermann <tzimmermann@suse.de>,
nouveau@lists.freedesktop.org, freedreno@lists.freedesktop.org
Subject: [PATCH v2 01/21] drm: Add get_scanout_position() to struct drm_crtc_helper_funcs
Date: Wed, 15 Jan 2020 13:16:32 +0100 [thread overview]
Message-ID: <20200115121652.7050-2-tzimmermann@suse.de> (raw)
In-Reply-To: <20200115121652.7050-1-tzimmermann@suse.de>
The new callback get_scanout_position() reads the current location of
the scanout process. The operation is currentyl located in struct
drm_driver, but really belongs to the CRTC. Drivers will be converted
in separate patches.
v2:
* fix logical op in drm_calc_vbltimestamp_from_scanoutpos()
Signed-off-by: Thomas Zimmermann <tzimmermann@suse.de>
Tested-by: Yannick Fertré <yannick.fertre@st.com>
---
drivers/gpu/drm/drm_vblank.c | 24 ++++++++----
include/drm/drm_drv.h | 7 +---
include/drm/drm_modeset_helper_vtables.h | 47 ++++++++++++++++++++++++
3 files changed, 65 insertions(+), 13 deletions(-)
diff --git a/drivers/gpu/drm/drm_vblank.c b/drivers/gpu/drm/drm_vblank.c
index 1659b13b178c..3f1dd54cc8bb 100644
--- a/drivers/gpu/drm/drm_vblank.c
+++ b/drivers/gpu/drm/drm_vblank.c
@@ -30,6 +30,7 @@
#include <drm/drm_crtc.h>
#include <drm/drm_drv.h>
#include <drm/drm_framebuffer.h>
+#include <drm/drm_modeset_helper_vtables.h>
#include <drm/drm_print.h>
#include <drm/drm_vblank.h>
@@ -590,7 +591,7 @@ EXPORT_SYMBOL(drm_calc_timestamping_constants);
* Implements calculation of exact vblank timestamps from given drm_display_mode
* timings and current video scanout position of a CRTC. This can be directly
* used as the &drm_driver.get_vblank_timestamp implementation of a kms driver
- * if &drm_driver.get_scanout_position is implemented.
+ * if &drm_crtc_helper_funcs.get_scanout_position is implemented.
*
* The current implementation only handles standard video modes. For double scan
* and interlaced modes the driver is supposed to adjust the hardware mode
@@ -632,8 +633,9 @@ bool drm_calc_vbltimestamp_from_scanoutpos(struct drm_device *dev,
}
/* Scanout position query not supported? Should not happen. */
- if (!dev->driver->get_scanout_position) {
- DRM_ERROR("Called from driver w/o get_scanout_position()!?\n");
+ if (!dev->driver->get_scanout_position &&
+ !crtc->helper_private->get_scanout_position) {
+ DRM_ERROR("Called from CRTC w/o get_scanout_position()!?\n");
return false;
}
@@ -664,11 +666,17 @@ bool drm_calc_vbltimestamp_from_scanoutpos(struct drm_device *dev,
* Get vertical and horizontal scanout position vpos, hpos,
* and bounding timestamps stime, etime, pre/post query.
*/
- vbl_status = dev->driver->get_scanout_position(dev, pipe,
- in_vblank_irq,
- &vpos, &hpos,
- &stime, &etime,
- mode);
+ if (crtc->helper_private->get_scanout_position) {
+ vbl_status =
+ crtc->helper_private->get_scanout_position(
+ crtc, in_vblank_irq, &vpos, &hpos,
+ &stime, &etime, mode);
+ } else {
+ vbl_status =
+ dev->driver->get_scanout_position(
+ dev, pipe, in_vblank_irq, &vpos,
+ &hpos, &stime, &etime, mode);
+ }
/* Return as no-op if scanout query unsupported or failed. */
if (!vbl_status) {
diff --git a/include/drm/drm_drv.h b/include/drm/drm_drv.h
index cf13470810a5..d0049e5786fc 100644
--- a/include/drm/drm_drv.h
+++ b/include/drm/drm_drv.h
@@ -362,11 +362,8 @@ struct drm_driver {
* True on success, false if a reliable scanout position counter could
* not be read out.
*
- * FIXME:
- *
- * Since this is a helper to implement @get_vblank_timestamp, we should
- * move it to &struct drm_crtc_helper_funcs, like all the other
- * helper-internal hooks.
+ * This is deprecated and should not be used by new drivers.
+ * Use &drm_crtc_helper_funcs.get_scanout_position instead.
*/
bool (*get_scanout_position) (struct drm_device *dev, unsigned int pipe,
bool in_vblank_irq, int *vpos, int *hpos,
diff --git a/include/drm/drm_modeset_helper_vtables.h b/include/drm/drm_modeset_helper_vtables.h
index 5a87f1bd7a3f..e398512bfd5f 100644
--- a/include/drm/drm_modeset_helper_vtables.h
+++ b/include/drm/drm_modeset_helper_vtables.h
@@ -450,6 +450,53 @@ struct drm_crtc_helper_funcs {
*/
void (*atomic_disable)(struct drm_crtc *crtc,
struct drm_crtc_state *old_crtc_state);
+
+ /**
+ * @get_scanout_position:
+ *
+ * Called by vblank timestamping code.
+ *
+ * Returns the current display scanout position from a CRTC and an
+ * optional accurate ktime_get() timestamp of when the position was
+ * measured. Note that this is a helper callback which is only used
+ * if a driver uses drm_calc_vbltimestamp_from_scanoutpos() for the
+ * @drm_driver.get_vblank_timestamp callback.
+ *
+ * Parameters:
+ *
+ * crtc:
+ * The CRTC.
+ * in_vblank_irq:
+ * True when called from drm_crtc_handle_vblank(). Some drivers
+ * need to apply some workarounds for gpu-specific vblank irq
+ * quirks if the flag is set.
+ * vpos:
+ * Target location for current vertical scanout position.
+ * hpos:
+ * Target location for current horizontal scanout position.
+ * stime:
+ * Target location for timestamp taken immediately before
+ * scanout position query. Can be NULL to skip timestamp.
+ * etime:
+ * Target location for timestamp taken immediately after
+ * scanout position query. Can be NULL to skip timestamp.
+ * mode:
+ * Current display timings.
+ *
+ * Returns vpos as a positive number while in active scanout area.
+ * Returns vpos as a negative number inside vblank, counting the number
+ * of scanlines to go until end of vblank, e.g., -1 means "one scanline
+ * until start of active scanout / end of vblank."
+ *
+ * Returns:
+ *
+ * True on success, false if a reliable scanout position counter could
+ * not be read out.
+ */
+ bool (*get_scanout_position)(struct drm_crtc *crtc,
+ bool in_vblank_irq, int *vpos, int *hpos,
+ ktime_t *stime, ktime_t *etime,
+ const struct drm_display_mode *mode);
};
/**
--
2.24.1
_______________________________________________
amd-gfx mailing list
amd-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/amd-gfx
next prev parent reply other threads:[~2020-01-15 12:17 UTC|newest]
Thread overview: 31+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-01-15 12:16 [PATCH v2 00/21] drm: Clean up VBLANK callbacks in struct drm_driver Thomas Zimmermann
2020-01-15 12:16 ` Thomas Zimmermann [this message]
2020-01-15 12:16 ` [PATCH v2 02/21] drm: Evaluate struct drm_device.vblank_disable_immediate on each use Thomas Zimmermann
2020-01-15 14:37 ` [Intel-gfx] " Ville Syrjälä
2020-01-16 8:03 ` Thomas Zimmermann
2020-01-15 12:16 ` [PATCH v2 03/21] drm: Add get_vblank_timestamp() to struct drm_crtc_funcs Thomas Zimmermann
2020-01-15 14:49 ` [Intel-gfx] " Ville Syrjälä
2020-01-16 8:44 ` Thomas Zimmermann
2020-01-16 11:21 ` Ville Syrjälä
2020-01-15 12:16 ` [PATCH v2 04/21] drm/amdgpu: Convert to struct drm_crtc_helper_funcs.get_scanout_position() Thomas Zimmermann
2020-01-15 12:16 ` [PATCH v2 05/21] drm/amdgpu: Convert to CRTC VBLANK callbacks Thomas Zimmermann
2020-01-15 12:16 ` [PATCH v2 06/21] drm/gma500: " Thomas Zimmermann
2020-01-15 12:16 ` [PATCH v2 07/21] drm/i915: " Thomas Zimmermann
2020-01-15 12:38 ` Jani Nikula
2020-01-15 15:11 ` Ville Syrjälä
2020-01-15 12:16 ` [PATCH v2 08/21] drm/nouveau: Convert to struct drm_crtc_helper_funcs.get_scanout_position() Thomas Zimmermann
2020-01-15 12:16 ` [PATCH v2 09/21] drm/nouveau: Convert to CRTC VBLANK callbacks Thomas Zimmermann
2020-01-15 12:16 ` [PATCH v2 10/21] drm/radeon: Convert to struct drm_crtc_helper_funcs.get_scanout_position() Thomas Zimmermann
2020-01-15 12:16 ` [PATCH v2 11/21] drm/radeon: Convert to CRTC VBLANK callbacks Thomas Zimmermann
2020-01-15 12:16 ` [PATCH v2 12/21] drm/msm: Convert to struct drm_crtc_helper_funcs.get_scanout_position() Thomas Zimmermann
2020-01-15 12:16 ` [PATCH v2 13/21] drm/msm: Convert to CRTC VBLANK callbacks Thomas Zimmermann
2020-01-15 12:16 ` [PATCH v2 14/21] drm/stm: Convert to struct drm_crtc_helper_funcs.get_scanout_position() Thomas Zimmermann
2020-01-15 12:16 ` [PATCH v2 15/21] drm/stm: Convert to CRTC VBLANK callbacks Thomas Zimmermann
2020-01-15 12:16 ` [PATCH v2 16/21] drm/sti: " Thomas Zimmermann
2020-01-15 12:16 ` [PATCH v2 17/21] drm/vc4: Convert to struct drm_crtc_helper_funcs.get_scanout_position() Thomas Zimmermann
2020-01-15 12:16 ` [PATCH v2 18/21] drm/vc4: Convert to CRTC VBLANK callbacks Thomas Zimmermann
2020-01-15 12:16 ` [PATCH v2 19/21] drm/vkms: " Thomas Zimmermann
2020-01-15 23:18 ` Rodrigo Siqueira
2020-01-17 13:22 ` Thomas Zimmermann
2020-01-15 12:16 ` [PATCH v2 20/21] drm/vmwgfx: " Thomas Zimmermann
2020-01-15 12:16 ` [PATCH v2 21/21] drm: Clean-up VBLANK-related callbacks in struct drm_driver Thomas Zimmermann
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=20200115121652.7050-2-tzimmermann@suse.de \
--to=tzimmermann@suse.de \
--cc=David1.Zhou@amd.com \
--cc=airlied@linux.ie \
--cc=alexander.deucher@amd.com \
--cc=alexandre.torgue@st.com \
--cc=amd-gfx@lists.freedesktop.org \
--cc=benjamin.gaignard@linaro.org \
--cc=bskeggs@redhat.com \
--cc=christian.koenig@amd.com \
--cc=daniel@ffwll.ch \
--cc=dri-devel@lists.freedesktop.org \
--cc=eric@anholt.net \
--cc=freedreno@lists.freedesktop.org \
--cc=hamohammed.sa@gmail.com \
--cc=harry.wentland@amd.com \
--cc=intel-gfx@lists.freedesktop.org \
--cc=jani.nikula@linux.intel.com \
--cc=joonas.lahtinen@linux.intel.com \
--cc=linux-arm-msm@vger.kernel.org \
--cc=linux-graphics-maintainer@vmware.com \
--cc=maarten.lankhorst@linux.intel.com \
--cc=mcoquelin.stm32@gmail.com \
--cc=nouveau@lists.freedesktop.org \
--cc=patrik.r.jakobsson@gmail.com \
--cc=philippe.cornu@st.com \
--cc=robdclark@gmail.com \
--cc=rodrigo.vivi@intel.com \
--cc=rodrigosiqueiramelo@gmail.com \
--cc=sean@poorly.run \
--cc=sunpeng.li@amd.com \
--cc=thellstrom@vmware.com \
--cc=vincent.abriou@st.com \
--cc=yannick.fertre@st.com \
/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;
as well as URLs for NNTP newsgroup(s).