@@ -2785,8 +2785,63 @@ drmmode_crtc_vrr_init(int drm_fd, xf86CrtcPtr crtc)
27852785    drmModeFreeObjectProperties (drm_props );
27862786}
27872787
2788+ static  drmmode_cursor_dim_rec 
2789+ drmmode_cursor_get_fallback (drmmode_ptr  drmmode )
2790+ {
2791+     drmmode_cursor_dim_rec  fallback ;
2792+ 
2793+     const  char  * fallback_cursor_str  =  xf86GetOptValString (drmmode -> Options ,
2794+                                                           OPTION_FALLBACK_CURSOR );
2795+ 
2796+     char  * height ;
2797+ 
2798+     if  (!fallback_cursor_str ) {
2799+         goto kms_default ;
2800+     }
2801+ 
2802+     errno  =  0 ;
2803+     fallback .width  =  strtol (fallback_cursor_str , & height , 10 );
2804+     if  (errno  ||  fallback .width  ==  0 ) {
2805+         goto kms_default ;
2806+     }
2807+ 
2808+     if  (* height  ==  '\0' ) {
2809+         /* we have a width, but don't have a height */ 
2810+         fallback .height  =  fallback .width ;
2811+         return  fallback ;
2812+     }
2813+ 
2814+     fallback .height  =  strtol (height  +  1 , NULL , 10 );
2815+     if  (errno  ||  fallback .height  ==  0 ) {
2816+         goto kms_default ;
2817+     }
2818+ 
2819+     return  fallback ;
2820+ kms_default :
2821+     /* This is the safest fallback value as 
2822+      * it is the default value that KMS uses.  */ 
2823+     fallback  =  (drmmode_cursor_dim_rec ){
2824+         .width   =  64 ,
2825+         .height  =  64 ,
2826+     };
2827+ 
2828+ #if  0  /* We could instead use the largest possible cursor, but that uses more power */ 
2829+     ret  =  drmGetCap (drmmode -> fd , DRM_CAP_CURSOR_WIDTH , & value );
2830+     if  (!ret ) {
2831+         fallback .width  =  value ;
2832+     }
2833+ 
2834+     ret  =  drmGetCap (drmmode -> fd , DRM_CAP_CURSOR_HEIGHT , & value );
2835+     if  (!ret ) {
2836+         fallback .height  =  value ;
2837+     }
2838+ #endif 
2839+ 
2840+     return  fallback ;
2841+ }
2842+ 
27882843static  unsigned int  
2789- drmmode_crtc_init (ScrnInfoPtr  pScrn , drmmode_ptr  drmmode , drmModeResPtr  mode_res , drmmode_cursor_dim_rec   fallback ,  int  num )
2844+ drmmode_crtc_init (ScrnInfoPtr  pScrn , drmmode_ptr  drmmode , drmModeResPtr  mode_res , int  num )
27902845{
27912846    xf86CrtcPtr  crtc ;
27922847    drmmode_crtc_private_ptr  drmmode_crtc ;
@@ -2817,8 +2872,7 @@ drmmode_crtc_init(ScrnInfoPtr pScrn, drmmode_ptr drmmode, drmModeResPtr mode_res
28172872    drmmode_crtc -> cursor .num_dimensions  =  1 ;
28182873    drmmode_crtc -> cursor .dimensions  =  xnfalloc (sizeof (drmmode_cursor_dim_rec ));
28192874
2820-     drmmode_crtc -> cursor .dimensions [0 ].width  =  fallback .width ;
2821-     drmmode_crtc -> cursor .dimensions [0 ].height  =  fallback .height ;
2875+     drmmode_crtc -> cursor .dimensions [0 ] =  drmmode_cursor_get_fallback (drmmode );
28222876
28232877    props  =  drmModeObjectGetProperties (drmmode -> fd , mode_res -> crtcs [num ],
28242878                                       DRM_MODE_OBJECT_CRTC );
@@ -4143,31 +4197,12 @@ drmmode_pre_init(ScrnInfoPtr pScrn, drmmode_ptr drmmode, int cpp)
41434197    xf86DrvMsgVerb (pScrn -> scrnIndex , X_INFO , MS_LOGLEVEL_DEBUG ,
41444198                   "Up to %d crtcs needed for screen.\n" , crtcs_needed );
41454199
4146-     /* This is the safest fallback value as 
4147-      * it is the default value that KMS uses.  */ 
4148-     drmmode_cursor_dim_rec  fallback  =  {
4149-         .width   =  64 ,
4150-         .height  =  64 ,
4151-     };
4152- 
4153- #if  0  /* We could instead use the largest possible cursor, but that uses more power */ 
4154-     ret  =  drmGetCap (drmmode -> fd , DRM_CAP_CURSOR_WIDTH , & value );
4155-     if  (!ret ) {
4156-         fallback .width  =  value ;
4157-     }
4158- 
4159-     ret  =  drmGetCap (drmmode -> fd , DRM_CAP_CURSOR_HEIGHT , & value );
4160-     if  (!ret ) {
4161-         fallback .height  =  value ;
4162-     }
4163- #endif 
4164- 
41654200    xf86CrtcSetSizeRange (pScrn , 320 , 200 , mode_res -> max_width ,
41664201                         mode_res -> max_height );
41674202    for  (i  =  0 ; i  <  mode_res -> count_crtcs ; i ++ )
41684203        if  (!xf86IsEntityShared (pScrn -> entityList [0 ]) || 
41694204            (crtcs_needed  &&  !(ms_ent -> assigned_crtcs  &  (1  << i ))))
4170-             crtcs_needed  -=  drmmode_crtc_init (pScrn , drmmode , mode_res , fallback ,  i );
4205+             crtcs_needed  -=  drmmode_crtc_init (pScrn , drmmode , mode_res , i );
41714206
41724207    /* All ZaphodHeads outputs provided with matching crtcs? */ 
41734208    if  (xf86IsEntityShared (pScrn -> entityList [0 ]) &&  (crtcs_needed  >  0 ))
0 commit comments