Skip to content

Commit 292d029

Browse files
authored
Merge pull request #45 from ua0lnj/master
Added geomerty settings for drm video output, -g WidthxHeight[@Rate].…
2 parents 82e51ab + 25cf875 commit 292d029

File tree

3 files changed

+72
-43
lines changed

3 files changed

+72
-43
lines changed

README

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,7 @@ Command line arguments
8787

8888
-r
8989
switch modeline to refresh rate of played file
90+
x11:
9091
xrandr is needed for this to work. If no xrandr is detected during compile time
9192
this feature will be deactivated.
9293

@@ -102,7 +103,10 @@ Command line arguments
102103
windowed mode, not fullscreen
103104

104105
-g geometry
105-
You can set X11 geometry with this parameter [W[xH]][+-x+-y][/WS] or x:y.
106+
x11:
107+
You can set X11 geometry with this parameter [W[xH]][+-x+-y][/WS] or x:y.
108+
drm:
109+
You can set drm mode with this parameter [WxH][@R].
106110
Resolution of OSD get from settings of output plugin (softhd*). OSD is scaled to video size.
107111

108112
-e drm device

mpv.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
#include "menu_options.h"
2020
#include "mpv_service.h"
2121

22-
static const char *VERSION = "1.7.4"
22+
static const char *VERSION = "1.8.0"
2323
#ifdef GIT_REV
2424
"-GIT" GIT_REV
2525
#endif

player.c

Lines changed: 66 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -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

950971
void 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

Comments
 (0)