diff mbox

[2/5] drm: use page-flip for sprites, in case no vblank event

Message ID 1331513325-1554-2-git-send-email-rob.clark@linaro.org
State New
Headers show

Commit Message

Rob Clark March 12, 2012, 12:48 a.m. UTC
From: Rob Clark <rob@ti.com>

If the output does not support vblank events (possibly the case with
USB or DSI command mode displays which do not have a traditional
vsync), use instead the page_flip handler to know when the display
is finished scanning out a sprite.
---
 src/compositor-drm.c |   17 +++++++++++++++--
 1 files changed, 15 insertions(+), 2 deletions(-)

Comments

David Herrmann March 12, 2012, 9:11 a.m. UTC | #1
Hi Rob

On Mon, Mar 12, 2012 at 1:48 AM, Rob Clark <rob.clark@linaro.org> wrote:
> From: Rob Clark <rob@ti.com>
>
> If the output does not support vblank events (possibly the case with
> USB or DSI command mode displays which do not have a traditional
> vsync), use instead the page_flip handler to know when the display
> is finished scanning out a sprite.
> ---
>  src/compositor-drm.c |   17 +++++++++++++++--
>  1 files changed, 15 insertions(+), 2 deletions(-)
>
> diff --git a/src/compositor-drm.c b/src/compositor-drm.c
> index 67fa500..500ec15 100644
> --- a/src/compositor-drm.c
> +++ b/src/compositor-drm.c
> @@ -117,6 +117,12 @@ struct drm_sprite {
>        uint32_t dest_x, dest_y;
>        uint32_t dest_w, dest_h;
>
> +       /*
> +        * for displays that don't have a vblank (dsi command-mode displays,
> +        * usb displays, etc), it can be simulated from the page-flip event
> +        */
> +       int simulate_vblank;
> +
>        uint32_t formats[];
>  };
>
> @@ -286,8 +292,7 @@ drm_output_repaint(struct weston_output *output_base,
>                vbl.request.signal = (unsigned long)s;
>                ret = drmWaitVBlank(compositor->drm.fd, &vbl);
>                if (ret) {
> -                       fprintf(stderr, "vblank event request failed: %d: %s\n",
> -                               ret, strerror(errno));
> +                       s->simulate_vblank = 1;
>                }

Doesn't it make sense to add an:
if (!s->simulate_vblank)
around this drmWaitVBlank call? Otherwise we try it at every repaint
and it will fail everytime.

Regards
David

>        }
>
> @@ -327,6 +332,7 @@ page_flip_handler(int fd, unsigned int frame,
>        struct drm_output *output = (struct drm_output *) data;
>        struct drm_compositor *c =
>                (struct drm_compositor *) output->base.compositor;
> +       struct drm_sprite *s;
>        uint32_t msecs;
>
>        if (output->scanout_buffer) {
> @@ -349,6 +355,13 @@ page_flip_handler(int fd, unsigned int frame,
>
>        msecs = sec * 1000 + usec / 1000;
>        weston_output_finish_frame(&output->base, msecs);
> +
> +       wl_list_for_each(s, &c->sprite_list, link) {
> +               if (s->simulate_vblank) {
> +                       vblank_handler(fd, frame, sec, usec, s);
> +                       s->simulate_vblank = 0;
> +               }
> +       }
>  }
>
>  static int
> --
> 1.7.5.4
>
> _______________________________________________
> wayland-devel mailing list
> wayland-devel@lists.freedesktop.org
> http://lists.freedesktop.org/mailman/listinfo/wayland-devel
Rob Clark March 12, 2012, 3:04 p.m. UTC | #2
On Mon, Mar 12, 2012 at 4:11 AM, David Herrmann
<dh.herrmann@googlemail.com> wrote:
> Hi Rob
>
> On Mon, Mar 12, 2012 at 1:48 AM, Rob Clark <rob.clark@linaro.org> wrote:
>> From: Rob Clark <rob@ti.com>
>>
>> If the output does not support vblank events (possibly the case with
>> USB or DSI command mode displays which do not have a traditional
>> vsync), use instead the page_flip handler to know when the display
>> is finished scanning out a sprite.
>> ---
>>  src/compositor-drm.c |   17 +++++++++++++++--
>>  1 files changed, 15 insertions(+), 2 deletions(-)
>>
>> diff --git a/src/compositor-drm.c b/src/compositor-drm.c
>> index 67fa500..500ec15 100644
>> --- a/src/compositor-drm.c
>> +++ b/src/compositor-drm.c
>> @@ -117,6 +117,12 @@ struct drm_sprite {
>>        uint32_t dest_x, dest_y;
>>        uint32_t dest_w, dest_h;
>>
>> +       /*
>> +        * for displays that don't have a vblank (dsi command-mode displays,
>> +        * usb displays, etc), it can be simulated from the page-flip event
>> +        */
>> +       int simulate_vblank;
>> +
>>        uint32_t formats[];
>>  };
>>
>> @@ -286,8 +292,7 @@ drm_output_repaint(struct weston_output *output_base,
>>                vbl.request.signal = (unsigned long)s;
>>                ret = drmWaitVBlank(compositor->drm.fd, &vbl);
>>                if (ret) {
>> -                       fprintf(stderr, "vblank event request failed: %d: %s\n",
>> -                               ret, strerror(errno));
>> +                       s->simulate_vblank = 1;
>>                }
>
> Doesn't it make sense to add an:
> if (!s->simulate_vblank)
> around this drmWaitVBlank call? Otherwise we try it at every repaint
> and it will fail everytime.

yeah, probably.. I guess I need to just make sure we set
s->simulate_vblank back to false if the connector changes..

BR,
-R


> Regards
> David
>
>>        }
>>
>> @@ -327,6 +332,7 @@ page_flip_handler(int fd, unsigned int frame,
>>        struct drm_output *output = (struct drm_output *) data;
>>        struct drm_compositor *c =
>>                (struct drm_compositor *) output->base.compositor;
>> +       struct drm_sprite *s;
>>        uint32_t msecs;
>>
>>        if (output->scanout_buffer) {
>> @@ -349,6 +355,13 @@ page_flip_handler(int fd, unsigned int frame,
>>
>>        msecs = sec * 1000 + usec / 1000;
>>        weston_output_finish_frame(&output->base, msecs);
>> +
>> +       wl_list_for_each(s, &c->sprite_list, link) {
>> +               if (s->simulate_vblank) {
>> +                       vblank_handler(fd, frame, sec, usec, s);
>> +                       s->simulate_vblank = 0;
>> +               }
>> +       }
>>  }
>>
>>  static int
>> --
>> 1.7.5.4
>>
>> _______________________________________________
>> wayland-devel mailing list
>> wayland-devel@lists.freedesktop.org
>> http://lists.freedesktop.org/mailman/listinfo/wayland-devel
> _______________________________________________
> wayland-devel mailing list
> wayland-devel@lists.freedesktop.org
> http://lists.freedesktop.org/mailman/listinfo/wayland-devel
diff mbox

Patch

diff --git a/src/compositor-drm.c b/src/compositor-drm.c
index 67fa500..500ec15 100644
--- a/src/compositor-drm.c
+++ b/src/compositor-drm.c
@@ -117,6 +117,12 @@  struct drm_sprite {
 	uint32_t dest_x, dest_y;
 	uint32_t dest_w, dest_h;
 
+	/*
+	 * for displays that don't have a vblank (dsi command-mode displays,
+	 * usb displays, etc), it can be simulated from the page-flip event
+	 */
+	int simulate_vblank;
+
 	uint32_t formats[];
 };
 
@@ -286,8 +292,7 @@  drm_output_repaint(struct weston_output *output_base,
 		vbl.request.signal = (unsigned long)s;
 		ret = drmWaitVBlank(compositor->drm.fd, &vbl);
 		if (ret) {
-			fprintf(stderr, "vblank event request failed: %d: %s\n",
-				ret, strerror(errno));
+			s->simulate_vblank = 1;
 		}
 	}
 
@@ -327,6 +332,7 @@  page_flip_handler(int fd, unsigned int frame,
 	struct drm_output *output = (struct drm_output *) data;
 	struct drm_compositor *c =
 		(struct drm_compositor *) output->base.compositor;
+	struct drm_sprite *s;
 	uint32_t msecs;
 
 	if (output->scanout_buffer) {
@@ -349,6 +355,13 @@  page_flip_handler(int fd, unsigned int frame,
 
 	msecs = sec * 1000 + usec / 1000;
 	weston_output_finish_frame(&output->base, msecs);
+
+	wl_list_for_each(s, &c->sprite_list, link) {
+		if (s->simulate_vblank) {
+			vblank_handler(fd, frame, sec, usec, s);
+			s->simulate_vblank = 0;
+		}
+	}
 }
 
 static int