@@ -511,6 +511,8 @@ void cMpvPlayer::PlayerGetDRM()
511511 drmModeRes * resources ;
512512 drmModeConnector * connector ;
513513 drmModeModeInfo mode ;
514+ drmModeEncoder * encoder ;
515+ drmModeCrtc * crtc ;
514516
515517 fd = open (drm_dev , O_RDWR );
516518 if (fd < 0 ) return ;
@@ -526,13 +528,22 @@ void cMpvPlayer::PlayerGetDRM()
526528 }
527529 }
528530 if (i < resources -> count_connectors ) {
529- mode = connector -> modes [0 ];
531+
532+ encoder = drmModeGetEncoder (fd , connector -> encoder_id );
533+ crtc = drmModeGetCrtc (fd , encoder -> crtc_id );
534+
535+ mode = crtc -> mode ;
530536 windowWidth = mode .hdisplay ;
531537 windowHeight = mode .vdisplay ;
538+
539+ drmModeFreeCrtc (crtc );
540+ drmModeFreeEncoder (encoder );
532541 drmModeFreeConnector (connector );
542+
533543 } else
534544 esyslog ("No active connector found\n" );
535545
546+ esyslog ("windowWidth %d windowHeight %d\n" ,windowWidth ,windowHeight );
536547 drmModeFreeResources (resources );
537548 close (fd );
538549 }
@@ -580,8 +591,9 @@ void cMpvPlayer::PlayerStart()
580591 check_error (mpv_set_option_string (hMpv , "drm-device" , drm_dev ));
581592 }
582593#endif
583- //no geometry with drm
584- if (!drm_ctx ) {
594+ //window geometry with x11, drm-mode with drm
595+ if (!drm_ctx ) //x11
596+ {
585597 if (strcmp (MpvPluginConfig -> Geometry .c_str (),"" ))
586598 {
587599 check_error (mpv_set_option_string (hMpv , "geometry" , MpvPluginConfig -> Geometry .c_str ()));
@@ -590,11 +602,20 @@ void cMpvPlayer::PlayerStart()
590602 sprintf (geo , "%dx%d+%d+%d" , windowWidth , windowHeight , windowX , windowY );
591603 check_error (mpv_set_option_string (hMpv , "geometry" , geo ));
592604 }
605+ if (!MpvPluginConfig -> Windowed )
606+ {
607+ check_error (mpv_set_option_string (hMpv , "fullscreen" , "yes" ));
608+ }
593609 }
594- if (!MpvPluginConfig -> Windowed )
610+ #ifdef USE_DRM
611+ else //drm
595612 {
596- check_error (mpv_set_option_string (hMpv , "fullscreen" , "yes" ));
613+ if (strcmp (MpvPluginConfig -> Geometry .c_str (),"" ))
614+ {
615+ check_error (mpv_set_option_string (hMpv , "drm-mode" , MpvPluginConfig -> Geometry .c_str ()));
616+ }
597617 }
618+ #endif
598619 if (MpvPluginConfig -> UseDeinterlace )
599620 {
600621 set_deinterlace (hMpv );
@@ -949,51 +970,55 @@ bool cMpvPlayer::IsPlaylist(string File)
949970
950971void cMpvPlayer ::ChangeFrameRate (int TargetRate )
951972{
952- #ifdef USE_XRANDR
953- if (!MpvPluginConfig -> RefreshRate || drm_ctx )
973+ if (!MpvPluginConfig -> RefreshRate )
954974 return ;
955975
956- Display * Dpl ;
957- int RefreshRate ;
958- XRRScreenConfiguration * CurrInfo ;
976+ int RefreshRate = 0 ;
977+ #ifdef USE_XRANDR
978+ if (!drm_ctx )
979+ {
980+ Display * Dpl ;
959981
960- if (TargetRate == 25 )
961- TargetRate = 50 ; // fix DVD audio and since this is doubled it's ok
982+ XRRScreenConfiguration * CurrInfo ;
962983
963- if (TargetRate == 23 )
964- TargetRate = 24 ;
984+ if (TargetRate == 25 )
985+ TargetRate = 50 ; // fix DVD audio and since this is doubled it's ok
965986
966- Dpl = XOpenDisplay (MpvPluginConfig -> X11Display .c_str ());
987+ if (TargetRate == 23 )
988+ TargetRate = 24 ;
967989
968- if (Dpl )
969- {
970- short * Rates ;
971- int NumberOfRates ;
972- SizeID CurrentSizeId ;
973- Rotation CurrentRotation ;
974- int RateFound = 0 ;
975-
976- CurrInfo = XRRGetScreenInfo (Dpl , DefaultRootWindow (Dpl ));
977- RefreshRate = XRRConfigCurrentRate (CurrInfo );
978- CurrentSizeId =
979- XRRConfigCurrentConfiguration (CurrInfo , & CurrentRotation );
980- Rates = XRRConfigRates (CurrInfo , CurrentSizeId , & NumberOfRates );
981-
982- while (NumberOfRates -- > 0 )
983- {
984- if (TargetRate == * Rates ++ )
985- RateFound = 1 ;
986- }
990+ Dpl = XOpenDisplay (MpvPluginConfig -> X11Display .c_str ());
987991
988- if (( RefreshRate != TargetRate ) && ( RateFound == 1 ) )
992+ if (Dpl )
989993 {
990- OriginalFps = RefreshRate ;
991- XRRSetScreenConfigAndRate (Dpl , CurrInfo , DefaultRootWindow (Dpl ),
992- CurrentSizeId , CurrentRotation , TargetRate , CurrentTime );
993- }
994+ short * Rates ;
995+ int NumberOfRates ;
996+ SizeID CurrentSizeId ;
997+ Rotation CurrentRotation ;
998+ int RateFound = 0 ;
999+
1000+ CurrInfo = XRRGetScreenInfo (Dpl , DefaultRootWindow (Dpl ));
1001+ RefreshRate = XRRConfigCurrentRate (CurrInfo );
1002+ CurrentSizeId =
1003+ XRRConfigCurrentConfiguration (CurrInfo , & CurrentRotation );
1004+ Rates = XRRConfigRates (CurrInfo , CurrentSizeId , & NumberOfRates );
1005+
1006+ while (NumberOfRates -- > 0 )
1007+ {
1008+ if (TargetRate == * Rates ++ )
1009+ RateFound = 1 ;
1010+ }
1011+
1012+ if ((RefreshRate != TargetRate ) && (RateFound == 1 ))
1013+ {
1014+ OriginalFps = RefreshRate ;
1015+ XRRSetScreenConfigAndRate (Dpl , CurrInfo , DefaultRootWindow (Dpl ),
1016+ CurrentSizeId , CurrentRotation , TargetRate , CurrentTime );
1017+ }
9941018
995- XRRFreeScreenConfigInfo (CurrInfo );
996- XCloseDisplay (Dpl );
1019+ XRRFreeScreenConfigInfo (CurrInfo );
1020+ XCloseDisplay (Dpl );
1021+ }
9971022 }
9981023#endif
9991024}
0 commit comments