2009/5/8 Kristian Høgsberg <k...@bitplanet.net>:
> From: Kristian Høgsberg <k...@redhat.com>
>
> This patch adds a vblank synced pageflip ioctl for to the modesetting
> family of ioctls.  The ioctl takes a crtc and an fb and schedules a
> pageflip to the new fb at the next coming vertical blank event.  This
> feature lets userspace implement tear-free updating of the screen contents
> with hw-guaranteed low latency page flipping.
>
> The ioctl is asynchronous in that it returns immediately and then later
> notifies the client by making an event available for reading on the drm fd.
> This lets applications add the drm fd to their main loop and handle other
> tasks while waiting for the flip to happen.  The event includes the time
> of the flip, the frame counter and a 64 bit opaque token provided by
> user space in the ioctl.

Great idea with the poll/read stuff.

I think you have the userspace <-> kernel part pretty much all figured out now.

[SNIP]

> +
> +/**
> + * drm_mode_page_flip - page flip ioctl
> + * @dev: DRM device
> + * @data: ioctl args
> + * @file_priv: file private data
> + *
> + * The page flip ioctl replaces the current front buffer with a new one,
> + * using the CRTC's mode_set_base function, which should just update
> + * the front buffer base pointer.  It's up to mode_set_base to make
> + * sure the update doesn't result in tearing (on some hardware the base
> + * register is double buffered, so this is easy).
> + *
> + * Note that this covers just the simple case of flipping the front
> + * buffer immediately.  Interval handling and interlaced modes have to
> + * be handled by userspace, or with new ioctls.
> + */
> +int drm_mode_page_flip(struct drm_device *dev, void *data,
> +                      struct drm_file *file_priv)

This function should have _ioctl appended to it. It should also go
into the drm_crtc.c file. And should not use drm_crtc_helper functions
and structs since those are not apart of the core kms implementation.

Also I rather see as much as possible of the code below be put in the
generic part and not just wrap this functions in a small function.

[SNIP]

> +       /*
> +        * The mode_set_base call will change the domain on the new
> +        * fb, which will force the rendering to finish and block the
> +        * ioctl.  We need to do this last part from a work queue, to
> +        * avoid blocking userspace here.
> +        */
> +       crtc->fb = obj_to_fb(fb_obj);
> +       ret = crtc_funcs->mode_set_base(crtc, 0, 0, NULL);

We should not block on rendering in the ioctl but do the call from a
worker thread. And you probably need one thread per crtc.

Also holding the struct_mutex while waiting for rendering might blow
up in your face big time if the rendering command takes a long while
to complete.

[SNIP]

> +
> +       /*
> +        * Unpin the old fb after setting a mode.  Must be called
> +        * after the old framebuffer is no longer visible, ie, after
> +        * the next vblank, typically.
> +        */
> +       void (*mode_unpin_fb)(struct drm_crtc *crtc, struct drm_framebuffer 
> *fb);

I was going to say that should probably go on the framebuffer
functions but the framebuffer doesn't have any helper functions.

Cheers Jakob.

------------------------------------------------------------------------------
The NEW KODAK i700 Series Scanners deliver under ANY circumstances! Your
production scanning environment may not be a perfect world - but thanks to
Kodak, there's a perfect scanner to get the job done! With the NEW KODAK i700
Series Scanner you'll get full speed at 300 dpi even with all image 
processing features enabled. http://p.sf.net/sfu/kodak-com
--
_______________________________________________
Dri-devel mailing list
Dri-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/dri-devel

Reply via email to