OSDN Git Service

Merge branch 'modesetting-dirty-libdrm'
authorJakob Bornecrantz <jakob@vmware.com>
Wed, 2 Dec 2009 18:40:58 +0000 (19:40 +0100)
committerJakob Bornecrantz <jakob@vmware.com>
Wed, 2 Dec 2009 18:40:58 +0000 (19:40 +0100)
Conflicts:
include/drm/drm.h

1  2 
include/drm/drm.h
include/drm/drm_mode.h
xf86drmMode.c
xf86drmMode.h

diff --combined include/drm/drm.h
@@@ -696,10 -696,8 +696,11 @@@ struct drm_gem_open 
  #define DRM_IOCTL_MODE_GETFB          DRM_IOWR(0xAD, struct drm_mode_fb_cmd)
  #define DRM_IOCTL_MODE_ADDFB          DRM_IOWR(0xAE, struct drm_mode_fb_cmd)
  #define DRM_IOCTL_MODE_RMFB           DRM_IOWR(0xAF, unsigned int)
 +#define DRM_IOCTL_MODE_PAGE_FLIP      DRM_IOWR(0xB0, struct drm_mode_crtc_page_flip)
+ #define DRM_IOCTL_MODE_DIRTYFB                DRM_IOWR(0xB1, struct drm_mode_fb_dirty_cmd)
  
 +/*@}*/
 +
  /**
   * Device specific ioctls should only be in their respective headers
   * The device specific ioctl range is from 0x40 to 0x99.
@@@ -729,7 -727,6 +730,7 @@@ struct drm_event 
  };
  
  #define DRM_EVENT_VBLANK 0x01
 +#define DRM_EVENT_FLIP_COMPLETE 0x02
  
  struct drm_event_vblank {
        struct drm_event base;
diff --combined include/drm/drm_mode.h
@@@ -222,6 -222,45 +222,45 @@@ struct drm_mode_fb_cmd 
        __u32 handle;
  };
  
+ #define DRM_MODE_FB_DIRTY_ANNOTATE_COPY 0x01
+ #define DRM_MODE_FB_DIRTY_ANNOTATE_FILL 0x02
+ #define DRM_MODE_FB_DIRTY_FLAGS         0x03
+ /*
+  * Mark a region of a framebuffer as dirty.
+  *
+  * Some hardware does not automatically update display contents
+  * as a hardware or software draw to a framebuffer. This ioctl
+  * allows userspace to tell the kernel and the hardware what
+  * regions of the framebuffer have changed.
+  *
+  * The kernel or hardware is free to update more then just the
+  * region specified by the clip rects. The kernel or hardware
+  * may also delay and/or coalesce several calls to dirty into a
+  * single update.
+  *
+  * Userspace may annotate the updates, the annotates are a
+  * promise made by the caller that the change is either a copy
+  * of pixels or a fill of a single color in the region specified.
+  *
+  * If the DRM_MODE_FB_DIRTY_ANNOTATE_COPY flag is given then
+  * the number of updated regions are half of num_clips given,
+  * where the clip rects are paired in src and dst. The width and
+  * height of each one of the pairs must match.
+  *
+  * If the DRM_MODE_FB_DIRTY_ANNOTATE_FILL flag is given the caller
+  * promises that the region specified of the clip rects is filled
+  * completely with a single color as given in the color argument.
+  */
+ struct drm_mode_fb_dirty_cmd {
+       __u32 fb_id;
+       __u32 flags;
+       __u32 color;
+       __u32 num_clips;
+       __u64 clips_ptr;
+ };
  struct drm_mode_mode_cmd {
        __u32 connector_id;
        struct drm_mode_modeinfo mode;
@@@ -265,15 -304,4 +304,15 @@@ struct drm_mode_crtc_lut 
        __u64 blue;
  };
  
 +#define DRM_MODE_PAGE_FLIP_EVENT 0x01
 +#define DRM_MODE_PAGE_FLIP_FLAGS DRM_MODE_PAGE_FLIP_EVENT
 +
 +struct drm_mode_crtc_page_flip {
 +      uint32_t crtc_id;
 +      uint32_t fb_id;
 +      uint32_t flags;
 +      uint32_t reserved;
 +      uint64_t user_data;
 +};
 +
  #endif
diff --combined xf86drmMode.c
@@@ -241,6 -241,18 +241,18 @@@ drmModeFBPtr drmModeGetFB(int fd, uint3
        return r;
  }
  
+ int drmModeDirtyFB(int fd, uint32_t bufferId,
+                  drmModeClipPtr clips, uint32_t num_clips)
+ {
+       struct drm_mode_fb_dirty_cmd dirty = { 0 };
+       dirty.fb_id = bufferId;
+       dirty.clips_ptr = VOID2U64(clips);
+       dirty.num_clips = num_clips;
+       return drmIoctl(fd, DRM_IOCTL_MODE_DIRTYFB, &dirty);
+ }
  
  /*
   * Crtc functions
@@@ -700,17 -712,7 +712,17 @@@ int drmHandleEvent(int fd, drmEventCont
                                              vblank->tv_usec,
                                              U642VOID (vblank->user_data));
                        break;
 -                      
 +              case DRM_EVENT_FLIP_COMPLETE:
 +                      if (evctx->version < 2 ||
 +                          evctx->page_flip_handler == NULL)
 +                              break;
 +                      vblank = (struct drm_event_vblank *) e;
 +                      evctx->page_flip_handler(fd,
 +                                               vblank->sequence,
 +                                               vblank->tv_sec,
 +                                               vblank->tv_usec,
 +                                               U642VOID (vblank->user_data));
 +                      break;
                default:
                        break;
                }
        return 0;
  }
  
 +int drmModePageFlip(int fd, uint32_t crtc_id, uint32_t fb_id,
 +                  uint32_t flags, void *user_data)
 +{
 +      struct drm_mode_crtc_page_flip flip;
 +
 +      flip.fb_id = fb_id;
 +      flip.crtc_id = crtc_id;
 +      flip.user_data = VOID2U64(user_data);
 +      flip.flags = flags;
 +      flip.reserved = 0;
 +
 +      return drmIoctl(fd, DRM_IOCTL_MODE_PAGE_FLIP, &flip);
 +}
diff --combined xf86drmMode.h
  
  #endif /* _DRM_MODE_H */
  
+ /*
+  * Feature defines
+  *
+  * Just because these are defined doesn't mean that the kernel
+  * can do that feature, its just for new code vs old libdrm.
+  */
+ #define DRM_MODE_FEATURE_KMS          1
+ #define DRM_MODE_FEATURE_DIRTYFB      1
  typedef struct _drmModeRes {
  
        int count_fbs;
@@@ -185,6 -196,8 +196,8 @@@ typedef struct _drmModeFB 
        uint32_t handle;
  } drmModeFB, *drmModeFBPtr;
  
+ typedef struct drm_clip_rect drmModeClip, *drmModeClipPtr;
  typedef struct _drmModePropertyBlob {
        uint32_t id;
        uint32_t length;
@@@ -293,6 -306,13 +306,13 @@@ extern int drmModeAddFB(int fd, uint32_
   */
  extern int drmModeRmFB(int fd, uint32_t bufferId);
  
+ /**
+  * Mark a region of a framebuffer as dirty.
+  */
+ extern int drmModeDirtyFB(int fd, uint32_t bufferId,
+                         drmModeClipPtr clips, uint32_t num_clips);
  /*
   * Crtc functions
   */
@@@ -362,5 -382,3 +382,5 @@@ extern int drmModeCrtcSetGamma(int fd, 
                               uint16_t *red, uint16_t *green, uint16_t *blue);
  extern int drmModeCrtcGetGamma(int fd, uint32_t crtc_id, uint32_t size,
                               uint16_t *red, uint16_t *green, uint16_t *blue);
 +extern int drmModePageFlip(int fd, uint32_t crtc_id, uint32_t fb_id,
 +                         uint32_t flags, void *user_data);