@@ -102,12 +102,15 @@ pub trait Device: Send + Sync {
102102
103103 /// Set the cursor image for a CRTC. `buffer` contains ARGB8888 pixel data.
104104 /// If `buffer` is None, the cursor should be hidden.
105+ /// `hot_x` and `hot_y` are the hotspot offsets (pixels from top-left of cursor image).
105106 fn set_cursor (
106107 & self ,
107108 _crtc_id : u32 ,
108109 _buffer : Option < Arc < dyn BufferObject > > ,
109110 _width : u32 ,
110111 _height : u32 ,
112+ _hot_x : i32 ,
113+ _hot_y : i32 ,
111114 ) -> EResult < ( ) > {
112115 Err ( Errno :: ENOSYS )
113116 }
@@ -895,6 +898,10 @@ impl FileOps for DrmFile {
895898 self . rd_event . wake_all ( ) ;
896899 }
897900 }
901+ drm:: DRM_IOCTL_WAIT_VBLANK => {
902+ warn ! ( "DRM_IOCTL_WAIT_VBLANK is not supported" ) ;
903+ return Err ( Errno :: ENOTTY ) ;
904+ }
898905 drm:: DRM_IOCTL_CRTC_GET_SEQUENCE => {
899906 return Err ( Errno :: ENOTTY ) ;
900907 }
@@ -911,7 +918,7 @@ impl FileOps for DrmFile {
911918 if val. flags & DRM_MODE_CURSOR_BO != 0 {
912919 if val. handle == 0 {
913920 // Hide cursor
914- self . device . set_cursor ( val. crtc_id , None , 0 , 0 ) ?;
921+ self . device . set_cursor ( val. crtc_id , None , 0 , 0 , 0 , 0 ) ?;
915922 } else {
916923 // Set cursor image
917924 let buffers = self . buffers . lock ( ) ;
@@ -921,8 +928,48 @@ impl FileOps for DrmFile {
921928 . ok_or ( Errno :: EINVAL ) ?
922929 . clone ( ) ;
923930 drop ( buffers) ;
924- self . device
925- . set_cursor ( val. crtc_id , Some ( buffer) , val. width , val. height ) ?;
931+ self . device . set_cursor (
932+ val. crtc_id ,
933+ Some ( buffer) ,
934+ val. width ,
935+ val. height ,
936+ 0 ,
937+ 0 ,
938+ ) ?;
939+ }
940+ }
941+ if val. flags & DRM_MODE_CURSOR_MOVE != 0 {
942+ self . device . move_cursor ( val. crtc_id , val. x , val. y ) ?;
943+ }
944+ }
945+ drm:: DRM_IOCTL_MODE_CURSOR2 => {
946+ let ptr = UserPtr :: < drm:: drm_mode_cursor2 > :: new ( arg) ;
947+ let val = ptr. read ( ) . ok_or ( Errno :: EFAULT ) ?;
948+
949+ const DRM_MODE_CURSOR_BO : u32 = 0x01 ;
950+ const DRM_MODE_CURSOR_MOVE : u32 = 0x02 ;
951+
952+ if val. flags & DRM_MODE_CURSOR_BO != 0 {
953+ if val. handle == 0 {
954+ // Hide cursor
955+ self . device . set_cursor ( val. crtc_id , None , 0 , 0 , 0 , 0 ) ?;
956+ } else {
957+ // Set cursor image with hotspot
958+ let buffers = self . buffers . lock ( ) ;
959+ let buffer = buffers
960+ . iter ( )
961+ . find ( |b| b. id ( ) == val. handle )
962+ . ok_or ( Errno :: EINVAL ) ?
963+ . clone ( ) ;
964+ drop ( buffers) ;
965+ self . device . set_cursor (
966+ val. crtc_id ,
967+ Some ( buffer) ,
968+ val. width ,
969+ val. height ,
970+ val. hot_x ,
971+ val. hot_y ,
972+ ) ?;
926973 }
927974 }
928975 if val. flags & DRM_MODE_CURSOR_MOVE != 0 {
0 commit comments