diff mbox

[2/2] drm/udl: Implement page_flip ioctl

Message ID 1404339223-7009-2-git-send-email-marcheu@chromium.org (mailing list archive)
State New, archived
Headers show

Commit Message

Stéphane Marchesin July 2, 2014, 10:13 p.m. UTC
This is a very crude page_flip implementation for UDL. There are ways
to make it better (make it asynchronous, make it do actual vsynced
flips...) but that's for another patch.

Signed-off-by: Stéphane Marchesin <marcheu@chromium.org>
---
 drivers/gpu/drm/udl/udl_modeset.c | 21 +++++++++++++++++++++
 1 file changed, 21 insertions(+)

Comments

David Herrmann July 8, 2014, 7:15 a.m. UTC | #1
Hi

On Thu, Jul 3, 2014 at 12:13 AM, Stéphane Marchesin
<marcheu@chromium.org> wrote:
> This is a very crude page_flip implementation for UDL. There are ways
> to make it better (make it asynchronous, make it do actual vsynced
> flips...) but that's for another patch.
>
> Signed-off-by: Stéphane Marchesin <marcheu@chromium.org>
> ---
>  drivers/gpu/drm/udl/udl_modeset.c | 21 +++++++++++++++++++++
>  1 file changed, 21 insertions(+)
>
> diff --git a/drivers/gpu/drm/udl/udl_modeset.c b/drivers/gpu/drm/udl/udl_modeset.c
> index cddc4fc..7dc3bd8 100644
> --- a/drivers/gpu/drm/udl/udl_modeset.c
> +++ b/drivers/gpu/drm/udl/udl_modeset.c
> @@ -363,6 +363,26 @@ static void udl_crtc_destroy(struct drm_crtc *crtc)
>         kfree(crtc);
>  }
>
> +static int udl_crtc_page_flip(struct drm_crtc *crtc,
> +                             struct drm_framebuffer *fb,
> +                             struct drm_pending_vblank_event *event,
> +                             uint32_t page_flip_flags)
> +{
> +       struct udl_framebuffer *ufb = to_udl_fb(fb);
> +       struct drm_device *dev = crtc->dev;
> +       unsigned long flags;
> +
> +       udl_handle_damage(ufb, 0, 0, fb->width, fb->height);
> +
> +       spin_lock_irqsave(&dev->event_lock, flags);
> +       if (event)
> +               drm_send_vblank_event(dev, 0, event);
> +       spin_unlock_irqrestore(&dev->event_lock, flags);
> +       crtc->fb = fb;

Doesn't this break user-space that expects page-flip events to not
occur more often than the refresh-rate? For instance, weston
re-renders on each page-flip event. With this patch, it will never
sleep on udl as it immediately gets the page-flip event back?

Thanks
David

> +
> +       return 0;
> +}
> +
>  static void udl_crtc_prepare(struct drm_crtc *crtc)
>  {
>  }
> @@ -384,6 +404,7 @@ static struct drm_crtc_helper_funcs udl_helper_funcs = {
>  static const struct drm_crtc_funcs udl_crtc_funcs = {
>         .set_config = drm_crtc_helper_set_config,
>         .destroy = udl_crtc_destroy,
> +       .page_flip = udl_crtc_page_flip,
>  };
>
>  static int udl_crtc_init(struct drm_device *dev)
> --
> 2.0.0.526.g5318336
>
> _______________________________________________
> dri-devel mailing list
> dri-devel@lists.freedesktop.org
> http://lists.freedesktop.org/mailman/listinfo/dri-devel
Dave Airlie July 8, 2014, 7:17 a.m. UTC | #2
On 8 July 2014 17:15, David Herrmann <dh.herrmann@gmail.com> wrote:
> Hi
>
> On Thu, Jul 3, 2014 at 12:13 AM, Stéphane Marchesin
> <marcheu@chromium.org> wrote:
>> This is a very crude page_flip implementation for UDL. There are ways
>> to make it better (make it asynchronous, make it do actual vsynced
>> flips...) but that's for another patch.
>>
>> Signed-off-by: Stéphane Marchesin <marcheu@chromium.org>
>> ---
>>  drivers/gpu/drm/udl/udl_modeset.c | 21 +++++++++++++++++++++
>>  1 file changed, 21 insertions(+)
>>
>> diff --git a/drivers/gpu/drm/udl/udl_modeset.c b/drivers/gpu/drm/udl/udl_modeset.c
>> index cddc4fc..7dc3bd8 100644
>> --- a/drivers/gpu/drm/udl/udl_modeset.c
>> +++ b/drivers/gpu/drm/udl/udl_modeset.c
>> @@ -363,6 +363,26 @@ static void udl_crtc_destroy(struct drm_crtc *crtc)
>>         kfree(crtc);
>>  }
>>
>> +static int udl_crtc_page_flip(struct drm_crtc *crtc,
>> +                             struct drm_framebuffer *fb,
>> +                             struct drm_pending_vblank_event *event,
>> +                             uint32_t page_flip_flags)
>> +{
>> +       struct udl_framebuffer *ufb = to_udl_fb(fb);
>> +       struct drm_device *dev = crtc->dev;
>> +       unsigned long flags;
>> +
>> +       udl_handle_damage(ufb, 0, 0, fb->width, fb->height);
>> +
>> +       spin_lock_irqsave(&dev->event_lock, flags);
>> +       if (event)
>> +               drm_send_vblank_event(dev, 0, event);
>> +       spin_unlock_irqrestore(&dev->event_lock, flags);
>> +       crtc->fb = fb;
>
> Doesn't this break user-space that expects page-flip events to not
> occur more often than the refresh-rate? For instance, weston
> re-renders on each page-flip event. With this patch, it will never
> sleep on udl as it immediately gets the page-flip event back?

I don't think you can update the USB device quicker than the refresh rate :-P

though that might change if we ever get USB3!
Dave.
David Herrmann July 8, 2014, 7:19 a.m. UTC | #3
Hi

On Tue, Jul 8, 2014 at 9:17 AM, Dave Airlie <airlied@gmail.com> wrote:
> On 8 July 2014 17:15, David Herrmann <dh.herrmann@gmail.com> wrote:
>> Hi
>>
>> On Thu, Jul 3, 2014 at 12:13 AM, Stéphane Marchesin
>> <marcheu@chromium.org> wrote:
>>> This is a very crude page_flip implementation for UDL. There are ways
>>> to make it better (make it asynchronous, make it do actual vsynced
>>> flips...) but that's for another patch.
>>>
>>> Signed-off-by: Stéphane Marchesin <marcheu@chromium.org>
>>> ---
>>>  drivers/gpu/drm/udl/udl_modeset.c | 21 +++++++++++++++++++++
>>>  1 file changed, 21 insertions(+)
>>>
>>> diff --git a/drivers/gpu/drm/udl/udl_modeset.c b/drivers/gpu/drm/udl/udl_modeset.c
>>> index cddc4fc..7dc3bd8 100644
>>> --- a/drivers/gpu/drm/udl/udl_modeset.c
>>> +++ b/drivers/gpu/drm/udl/udl_modeset.c
>>> @@ -363,6 +363,26 @@ static void udl_crtc_destroy(struct drm_crtc *crtc)
>>>         kfree(crtc);
>>>  }
>>>
>>> +static int udl_crtc_page_flip(struct drm_crtc *crtc,
>>> +                             struct drm_framebuffer *fb,
>>> +                             struct drm_pending_vblank_event *event,
>>> +                             uint32_t page_flip_flags)
>>> +{
>>> +       struct udl_framebuffer *ufb = to_udl_fb(fb);
>>> +       struct drm_device *dev = crtc->dev;
>>> +       unsigned long flags;
>>> +
>>> +       udl_handle_damage(ufb, 0, 0, fb->width, fb->height);
>>> +
>>> +       spin_lock_irqsave(&dev->event_lock, flags);
>>> +       if (event)
>>> +               drm_send_vblank_event(dev, 0, event);
>>> +       spin_unlock_irqrestore(&dev->event_lock, flags);
>>> +       crtc->fb = fb;
>>
>> Doesn't this break user-space that expects page-flip events to not
>> occur more often than the refresh-rate? For instance, weston
>> re-renders on each page-flip event. With this patch, it will never
>> sleep on udl as it immediately gets the page-flip event back?
>
> I don't think you can update the USB device quicker than the refresh rate :-P
>
> though that might change if we ever get USB3!

Fair enough. I will keep it in mind and if something turns up, we can
always add a 60Hz software-timer.

Thanks
David
Chris Wilson July 8, 2014, 7:31 a.m. UTC | #4
On Wed, Jul 02, 2014 at 03:13:43PM -0700, Stéphane Marchesin wrote:
> This is a very crude page_flip implementation for UDL. There are ways
> to make it better (make it asynchronous, make it do actual vsynced
> flips...) but that's for another patch.
> 
> Signed-off-by: Stéphane Marchesin <marcheu@chromium.org>
> ---
>  drivers/gpu/drm/udl/udl_modeset.c | 21 +++++++++++++++++++++
>  1 file changed, 21 insertions(+)
> 
> diff --git a/drivers/gpu/drm/udl/udl_modeset.c b/drivers/gpu/drm/udl/udl_modeset.c
> index cddc4fc..7dc3bd8 100644
> --- a/drivers/gpu/drm/udl/udl_modeset.c
> +++ b/drivers/gpu/drm/udl/udl_modeset.c
> @@ -363,6 +363,26 @@ static void udl_crtc_destroy(struct drm_crtc *crtc)
>  	kfree(crtc);
>  }
>  
> +static int udl_crtc_page_flip(struct drm_crtc *crtc,
> +			      struct drm_framebuffer *fb,
> +			      struct drm_pending_vblank_event *event,
> +			      uint32_t page_flip_flags)
> +{
> +	struct udl_framebuffer *ufb = to_udl_fb(fb);
> +	struct drm_device *dev = crtc->dev;
> +	unsigned long flags;
> +
> +	udl_handle_damage(ufb, 0, 0, fb->width, fb->height);

Could we not save the damage from an earlier dirtyfb and limit the data
we have to send here?
-Chris
diff mbox

Patch

diff --git a/drivers/gpu/drm/udl/udl_modeset.c b/drivers/gpu/drm/udl/udl_modeset.c
index cddc4fc..7dc3bd8 100644
--- a/drivers/gpu/drm/udl/udl_modeset.c
+++ b/drivers/gpu/drm/udl/udl_modeset.c
@@ -363,6 +363,26 @@  static void udl_crtc_destroy(struct drm_crtc *crtc)
 	kfree(crtc);
 }
 
+static int udl_crtc_page_flip(struct drm_crtc *crtc,
+			      struct drm_framebuffer *fb,
+			      struct drm_pending_vblank_event *event,
+			      uint32_t page_flip_flags)
+{
+	struct udl_framebuffer *ufb = to_udl_fb(fb);
+	struct drm_device *dev = crtc->dev;
+	unsigned long flags;
+
+	udl_handle_damage(ufb, 0, 0, fb->width, fb->height);
+
+	spin_lock_irqsave(&dev->event_lock, flags);
+	if (event)
+		drm_send_vblank_event(dev, 0, event);
+	spin_unlock_irqrestore(&dev->event_lock, flags);
+	crtc->fb = fb;
+
+	return 0;
+}
+
 static void udl_crtc_prepare(struct drm_crtc *crtc)
 {
 }
@@ -384,6 +404,7 @@  static struct drm_crtc_helper_funcs udl_helper_funcs = {
 static const struct drm_crtc_funcs udl_crtc_funcs = {
 	.set_config = drm_crtc_helper_set_config,
 	.destroy = udl_crtc_destroy,
+	.page_flip = udl_crtc_page_flip,
 };
 
 static int udl_crtc_init(struct drm_device *dev)