drm: stm: implement get_scanout_position function
Subsystems (4)
A message that is not in the archive (sent off-list or not yet received): [email protected]
PATCH 1/1 drm: stm: implement get_scanout_position function
Reviewed-by/tested-by: [email protected]
-------- Forwarded Message --------
Subject: [PATCH] drm: stm: implement get_scanout_position function
Date: Fri, 29 Jun 2018 15:01:40 +0200
From: Benjamin Gaignard <[email protected]>
To: [email protected], [email protected], [email protected]
CC: [email protected], [email protected], Benjamin Gaignard <[email protected]>, Benjamin Gaignard <[email protected]>
Hardware allow to read the position in scanout buffer so we can use this information to make wait of vblank more accurate.
Active area bounds (start, end, total height) have already been computed and written in ltdc registers, read them and get the current line position to compute vpos value.
--- drivers/gpu/drm/stm/drv.c | 2 ++ drivers/gpu/drm/stm/ltdc.c | 45 +++++++++++++++++++++++++++++++++++++++++++++ drivers/gpu/drm/stm/ltdc.h | 5 +++++ 3 files changed, 52 insertions(+)
drivers/gpu/drm/stm/drv.c +2 -0
@@ -72,6 +72,8 @@ static struct drm_driver drv_driver = { .gem_prime_vmap = drm_gem_cma_prime_vmap, .gem_prime_vunmap = drm_gem_cma_prime_vunmap, .gem_prime_mmap = drm_gem_cma_prime_mmap, + .get_scanout_position = ltdc_crtc_scanoutpos, + .get_vblank_timestamp = drm_calc_vbltimestamp_from_scanoutpos, };static int drv_load (struct drm_device *ddev)
drivers/gpu/drm/stm/ltdc.c +1 -0
@@ -148,6 +148,8 @@#define IER_TERRIE BIT(2)/* Transfer ERRor Interrupt Enable */ #define IER_RRIE BIT(3)/* Register Reload Interrupt enable */ +#define CPSR_CYPOS GENMASK(15, 0) /* Current Y position */ +#define ISR_LIF BIT(0)/* Line Interrupt Flag */ #define ISR_FUIF BIT(1)/* Fifo Underrun Interrupt Flag */ #define ISR_TERRIF BIT(2)/* Transfer ERRor Interrupt Flag */
@@ -622,6 +624,49 @@ static void ltdc_crtc_disable_vblank(struct
drm_crtc *crtc)
reg_clear(ldev->regs, LTDC_IER, IER_LIE);
}
+bool ltdc_crtc_scanoutpos(struct drm_device *ddev, unsigned int pipe,
+ bool in_vblank_irq, int *vpos, int *hpos, + ktime_t *stime, ktime_t *etime, + const struct drm_display_mode *mode)
+{
+ struct ltdc_device *ldev = ddev->dev_private;
+ int line, vactive_start, vactive_end, vtotal;
+
+ if (stime)
+ *stime = ktime_get();
+
+ /* The active area starts after vsync + front porch and ends
+ * at vsync + front porc + display size.
+ * The total height also include back porch.
+ * We have 3 possible cases to handle:
+ * - line < vactive_start: vpos = line - vactive_start and will be
+ * negative
+ * - vactive_start < line < vactive_end: vpos = line - vactive_start
+ * and will be positive
+ * - line > vactive_end: vpos = line - vtotal - vactive_start
+ * and will negative
+ *
+ * Computation for the two first cases are identical so we can
+ * simplify the code and only test if line > vactive_end
+ */
+ line = reg_read(ldev->regs, LTDC_CPSR) & CPSR_CYPOS;
+ vactive_start = reg_read(ldev->regs, LTDC_BPCR) & BPCR_AVBP;
+ vactive_end = reg_read(ldev->regs, LTDC_AWCR) & AWCR_AAH;
+ vtotal = reg_read(ldev->regs, LTDC_TWCR) & TWCR_TOTALH;
+
+ if (line > vactive_end)
+ *vpos = line - vtotal - vactive_start;
+ else
+ *vpos = line - vactive_start;
+
+ *hpos = 0;
+
+ if (etime)
+ *etime = ktime_get();
+
+ return true;
+}
+
static const struct drm_crtc_funcs ltdc_crtc_funcs = {
.destroy = drm_crtc_cleanup,
.set_config = drm_atomic_helper_set_config,
drivers/gpu/drm/stm/ltdc.h +4 -0
@@ -37,6 +37,11 @@ struct ltdc_device {struct fps_info plane_fpsi[LTDC_MAX_LAYER ]; }; +bool ltdc_crtc_scanoutpos(struct drm_device *dev, unsigned int pipe, + bool in_vblank_irq, int *vpos, int *hpos, + ktime_t *stime, ktime_t *etime, + const struct drm_display_mode *mode); +int ltdc_load (struct drm_device *ddev);void ltdc_unload (struct drm_device *ddev); -- 2.15.0
_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel
Quoted 118 lines · Yannick FERTRE
Reviewed-by/tested-by: [email protected]
-------- Forwarded Message --------
Subject: [PATCH] drm: stm: implementget_scanout_positionfunction
Date: Fri, 29 Jun 2018 15:01:40 +0200
From: Benjamin Gaignard <[email protected]>
To: [email protected], [email protected], [email protected]
CC: [email protected], [email protected], Benjamin Gaignard <[email protected]>, Benjamin Gaignard <[email protected]>Hardware allow to read the position in scanout buffer so we can use this information to make wait of vblank more accurate.
Active area bounds (start, end, total height) have already been computed and written in ltdc registers, read them and get the current line position to compute vpos value.
Signed-off-by Benjamin Gaignard <[email protected]>---
drivers/gpu/drm/stm/drv.c | 2 ++
drivers/gpu/drm/stm/ltdc.c| 45
+++++++++++++++++++++++++++++++++++++++++++++
drivers/gpu/drm/stm/ltdc.h| 5 +++++3 files changed, 52 insertions(+)drivers/gpu/drm/stm/drv.c +2
-0@@ -72,6 +72,8 @@ static struct drm_driver drv_driver = { .gem_prime_vmap = drm_gem_cma_prime_vmap, .gem_prime_vunmap = drm_gem_cma_prime_vunmap, .gem_prime_mmap = drm_gem_cma_prime_mmap, + .get_scanout_position = ltdc_crtc_scanoutpos, + .get_vblank_timestamp = drm_calc_vbltimestamp_from_scanoutpos, }; static int drv_load(struct drm_device *ddev)drivers/gpu/drm/stm/ltdc.c +0
-0@@ -148,6 +148,8 @@ #define IER_TERRIE BIT(2) /* Transfer ERRor InterruptEnable */
#define IER_RRIE BIT(3) /* Register Reload Interrupt enable */
+#define CPSR_CYPOSGENMASK(15, 0)/* Current Y position */ +
#define ISR_LIF BIT(0) /* Line Interrupt Flag */ #define ISR_FUIF BIT(1) /* Fifo Underrun Interrupt Flag */ #define ISR_TERRIF BIT(2) /* Transfer ERRor Interrupt Flag */drivers/gpu/drm/stm/ltdc.c +42
-0@@ -622,6 +624,49 @@ static void ltdc_crtc_disable_vblank(struct drm_crtc *crtc) reg_clear(ldev->regs, LTDC_IER, IER_LIE); } +bool ltdc_crtc_scanoutpos(struct drm_device *ddev, unsigned int pipe, + bool in_vblank_irq, int *vpos, int *hpos, + ktime_t *stime, ktime_t *etime, + const struct drm_display_mode *mode) +{ + struct ltdc_device *ldev = ddev->dev_private; + int line, vactive_start, vactive_end, vtotal; + + if (stime) + *stime = ktime_get(); + + /* The active area starts after vsync + front porch and ends + * at vsync + front porc + display size. + * The total height also include back porch. + * We have 3 possible cases to handle: + * - line < vactive_start: vpos = line - vactive_start and will be + * negative + * - vactive_start < line < vactive_end: vpos = line - vactive_start + * and will be positive + * - line > vactive_end: vpos = line - vtotal - vactive_start + * and will negative + * + * Computation for the two first cases are identical so we can + * simplify the code and only test if line > vactive_end + */ + line = reg_read(ldev->regs, LTDC_CPSR) & CPSR_CYPOS; + vactive_start = reg_read(ldev->regs, LTDC_BPCR) & BPCR_AVBP; + vactive_end = reg_read(ldev->regs, LTDC_AWCR) & AWCR_AAH; + vtotal = reg_read(ldev->regs, LTDC_TWCR) & TWCR_TOTALH; + + if (line > vactive_end) + *vpos = line - vtotal - vactive_start; + else + *vpos = line - vactive_start; + + *hpos = 0; + + if (etime) + *etime = ktime_get(); + + return true; +} + static const struct drm_crtc_funcs ltdc_crtc_funcs = { .destroy = drm_crtc_cleanup,.set_config =
drm_atomic_helper_set_config,drivers/gpu/drm/stm/ltdc.h +4
-0@@ -37,6 +37,11 @@ struct ltdc_device { struct fps_info plane_fpsi[LTDC_MAX_LAYER]; }; +bool ltdc_crtc_scanoutpos(struct drm_device *dev, unsigned int pipe, + bool in_vblank_irq, int *vpos, int *hpos, + ktime_t *stime, ktime_t *etime, + const struct drm_display_mode *mode); + int ltdc_load(struct drm_device *ddev); void ltdc_unload(struct drm_device *ddev);-- 2.15.0
Signature · 6 lines
Yannick Fertré | TINA: 166 7152 | Tel: +33 244027152 | Mobile: +33 620600270 Microcontrollers and Digital ICs Group | Microcontrolleurs Division _______________________________________________ dri-devel mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/dri-devel
Quoted 3 lines · Yannick FERTRE
Reviewed-by Yannick Fertré <[email protected]>Tested-by Yannick Fertré <[email protected]>
Applied on drm-misc-next,
Thanks,
Benjamin
Quoted 128 lines · Yannick FERTRE
Quoted 108 lines
Reviewed-by/tested-by: [email protected]
-------- Forwarded Message --------
Subject: [PATCH] drm: stm: implementget_scanout_positionfunction
Date: Fri, 29 Jun 2018 15:01:40 +0200
From: Benjamin Gaignard <[email protected]>
To: [email protected], [email protected], [email protected]
CC: [email protected], [email protected], Benjamin Gaignard <[email protected]>, Benjamin Gaignard <[email protected]>Hardware allow to read the position in scanout buffer so we can use this information to make wait of vblank more accurate.
Active area bounds (start, end, total height) have already been computed and written in ltdc registers, read them and get the current line position to compute vpos value.
Signed-off-by Benjamin Gaignard <[email protected]>--- drivers/gpu/drm/stm/drv.c | 2 ++ drivers/gpu/drm/stm/ltdc.c | 45 +++++++++++++++++++++++++++++++++++++++++++++ drivers/gpu/drm/stm/ltdc.h | 5 +++++ 3 files changed, 52 insertions(+)drivers/gpu/drm/stm/drv.c +2
-0@@ -72,6 +72,8 @@ static struct drm_driver drv_driver = { .gem_prime_vmap = drm_gem_cma_prime_vmap, .gem_prime_vunmap = drm_gem_cma_prime_vunmap, .gem_prime_mmap = drm_gem_cma_prime_mmap, + .get_scanout_position = ltdc_crtc_scanoutpos, + .get_vblank_timestamp = drm_calc_vbltimestamp_from_scanoutpos, };static int drv_load (struct drm_device *ddev)drivers/gpu/drm/stm/ltdc.c +0
-0@@ -148,6 +148,8 @@#define IER_TERRIE BIT(2)/* Transfer ERRor Interrupt Enable */
#defineIER_RRIEBIT(3) /* Register Reload Interrupt
enable */
+#defineCPSR_CYPOSGENMASK(15, 0)/* Current Y position */drivers/gpu/drm/stm/ltdc.c +43
-0+#define ISR_LIF BIT(0)/* Line Interrupt Flag */ #define ISR_FUIF BIT(1)/* Fifo Underrun Interrupt Flag */ #define ISR_TERRIF BIT(2)/* Transfer ERRor Interrupt Flag */ @@ -622,6 +624,49 @@ static void ltdc_crtc_disable_vblank(struct drm_crtc *crtc) reg_clear(ldev->regs, LTDC_IER, IER_LIE); } +bool ltdc_crtc_scanoutpos(struct drm_device *ddev, unsigned int pipe, + bool in_vblank_irq, int *vpos, int *hpos, + ktime_t *stime, ktime_t *etime, + const struct drm_display_mode *mode) +{ + struct ltdc_device *ldev = ddev->dev_private; +int line, vactive_start, vactive_end, vtotal; + +if (stime) + *stime =ktime_get (); + +/* The active area starts after vsync + front porch and ends +* at vsync + front porc + display size. +* The total height also include back porch. +* We have 3 possible cases to handle: +* - line < vactive_start: vpos = line - vactive_start and will be +* negative +* - vactive_start < line < vactive_end: vpos = line - vactive_start +* and will be positive +* - line > vactive_end: vpos = line - vtotal - vactive_start +* and will negative +* +* Computation for the two first cases are identical so we can +* simplify the code and only test if line > vactive_end +*/ + line =reg_read (ldev->regs,LTDC_CPSR ) &CPSR_CYPOS ; + vactive_start =reg_read (ldev->regs,LTDC_BPCR ) &BPCR_AVBP ; + vactive_end =reg_read (ldev->regs,LTDC_AWCR ) &AWCR_AAH ; + vtotal =reg_read (ldev->regs,LTDC_TWCR ) &TWCR_TOTALH ; + +if (line > vactive_end) + *vpos = line - vtotal - vactive_start; +else + *vpos = line - vactive_start; + + *hpos =0 ; + +if (etime) + *etime =ktime_get (); + +return true; +} +static const struct drm_crtc_funcs ltdc_crtc_funcs = { .destroy = drm_crtc_cleanup, .set_config = drm_atomic_helper_set_config,drivers/gpu/drm/stm/ltdc.h +0
-0drivers/gpu/drm/stm/ltdc.h struct ltdc_device { · line 46
Quoted 10 lines
drivers/gpu/drm/stm/ltdc.h +4
-0@@ -37,6 +37,11 @@ struct ltdc_device {struct fps_info plane_fpsi[LTDC_MAX_LAYER ]; }; +bool ltdc_crtc_scanoutpos(struct drm_device *dev, unsigned int pipe, + bool in_vblank_irq, int *vpos, int *hpos, + ktime_t *stime, ktime_t *etime, + const struct drm_display_mode *mode); +int ltdc_load (struct drm_device *ddev);void ltdc_unload (struct drm_device *ddev); -- 2.15.0--
Yannick Fertré | TINA: 166 7152 | Tel: +33 244027152 | Mobile: +33 620600270 Microcontrollers and Digital ICs Group | Microcontrolleurs Division
_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel