diff --git a/README b/README index 4eaf317..6054d00 100644 --- a/README +++ b/README @@ -87,6 +87,7 @@ Command line arguments -r switch modeline to refresh rate of played file + x11: xrandr is needed for this to work. If no xrandr is detected during compile time this feature will be deactivated. @@ -102,7 +103,10 @@ Command line arguments windowed mode, not fullscreen -g geometry - You can set X11 geometry with this parameter [W[xH]][+-x+-y][/WS] or x:y. + x11: + You can set X11 geometry with this parameter [W[xH]][+-x+-y][/WS] or x:y. + drm: + You can set drm mode with this parameter [WxH][@R]. Resolution of OSD get from settings of output plugin (softhd*). OSD is scaled to video size. -e drm device diff --git a/mpv.c b/mpv.c index d83de5a..9e3c174 100644 --- a/mpv.c +++ b/mpv.c @@ -19,7 +19,7 @@ #include "menu_options.h" #include "mpv_service.h" -static const char *VERSION = "1.7.4" +static const char *VERSION = "1.8.0" #ifdef GIT_REV "-GIT" GIT_REV #endif diff --git a/player.c b/player.c index fc892f6..c8766cf 100644 --- a/player.c +++ b/player.c @@ -511,6 +511,8 @@ void cMpvPlayer::PlayerGetDRM() drmModeRes *resources; drmModeConnector *connector; drmModeModeInfo mode; + drmModeEncoder *encoder; + drmModeCrtc *crtc; fd = open(drm_dev, O_RDWR); if (fd < 0) return; @@ -526,13 +528,22 @@ void cMpvPlayer::PlayerGetDRM() } } if(i < resources->count_connectors) { - mode = connector->modes[0]; + + encoder = drmModeGetEncoder(fd, connector->encoder_id); + crtc = drmModeGetCrtc(fd, encoder->crtc_id); + + mode = crtc->mode; windowWidth = mode.hdisplay; windowHeight = mode.vdisplay; + + drmModeFreeCrtc(crtc); + drmModeFreeEncoder(encoder); drmModeFreeConnector(connector); + } else esyslog("No active connector found\n"); + esyslog("windowWidth %d windowHeight %d\n",windowWidth,windowHeight); drmModeFreeResources(resources); close(fd); } @@ -580,8 +591,9 @@ void cMpvPlayer::PlayerStart() check_error(mpv_set_option_string(hMpv, "drm-device", drm_dev)); } #endif - //no geometry with drm - if (!drm_ctx) { + //window geometry with x11, drm-mode with drm + if (!drm_ctx) //x11 + { if (strcmp(MpvPluginConfig->Geometry.c_str(),"")) { check_error(mpv_set_option_string(hMpv, "geometry", MpvPluginConfig->Geometry.c_str())); @@ -590,11 +602,20 @@ void cMpvPlayer::PlayerStart() sprintf(geo, "%dx%d+%d+%d", windowWidth, windowHeight, windowX, windowY); check_error(mpv_set_option_string(hMpv, "geometry", geo)); } + if (!MpvPluginConfig->Windowed) + { + check_error(mpv_set_option_string(hMpv, "fullscreen", "yes")); + } } - if (!MpvPluginConfig->Windowed) +#ifdef USE_DRM + else //drm { - check_error(mpv_set_option_string(hMpv, "fullscreen", "yes")); + if (strcmp(MpvPluginConfig->Geometry.c_str(),"")) + { + check_error(mpv_set_option_string(hMpv, "drm-mode", MpvPluginConfig->Geometry.c_str())); + } } +#endif if (MpvPluginConfig->UseDeinterlace) { set_deinterlace(hMpv); @@ -949,51 +970,55 @@ bool cMpvPlayer::IsPlaylist(string File) void cMpvPlayer::ChangeFrameRate(int TargetRate) { -#ifdef USE_XRANDR - if (!MpvPluginConfig->RefreshRate || drm_ctx) + if (!MpvPluginConfig->RefreshRate) return; - Display *Dpl; - int RefreshRate; - XRRScreenConfiguration *CurrInfo; + int RefreshRate = 0; +#ifdef USE_XRANDR + if (!drm_ctx) + { + Display *Dpl; - if (TargetRate == 25) - TargetRate = 50; // fix DVD audio and since this is doubled it's ok + XRRScreenConfiguration *CurrInfo; - if (TargetRate == 23) - TargetRate = 24; + if (TargetRate == 25) + TargetRate = 50; // fix DVD audio and since this is doubled it's ok - Dpl = XOpenDisplay(MpvPluginConfig->X11Display.c_str()); + if (TargetRate == 23) + TargetRate = 24; - if (Dpl) - { - short *Rates; - int NumberOfRates; - SizeID CurrentSizeId; - Rotation CurrentRotation; - int RateFound = 0; - - CurrInfo = XRRGetScreenInfo(Dpl, DefaultRootWindow(Dpl)); - RefreshRate = XRRConfigCurrentRate(CurrInfo); - CurrentSizeId = - XRRConfigCurrentConfiguration(CurrInfo, &CurrentRotation); - Rates = XRRConfigRates(CurrInfo, CurrentSizeId, &NumberOfRates); - - while (NumberOfRates-- > 0) - { - if (TargetRate == *Rates++) - RateFound = 1; - } + Dpl = XOpenDisplay(MpvPluginConfig->X11Display.c_str()); - if ((RefreshRate != TargetRate) && (RateFound == 1)) + if (Dpl) { - OriginalFps = RefreshRate; - XRRSetScreenConfigAndRate(Dpl, CurrInfo, DefaultRootWindow(Dpl), - CurrentSizeId, CurrentRotation, TargetRate, CurrentTime); - } + short *Rates; + int NumberOfRates; + SizeID CurrentSizeId; + Rotation CurrentRotation; + int RateFound = 0; + + CurrInfo = XRRGetScreenInfo(Dpl, DefaultRootWindow(Dpl)); + RefreshRate = XRRConfigCurrentRate(CurrInfo); + CurrentSizeId = + XRRConfigCurrentConfiguration(CurrInfo, &CurrentRotation); + Rates = XRRConfigRates(CurrInfo, CurrentSizeId, &NumberOfRates); + + while (NumberOfRates-- > 0) + { + if (TargetRate == *Rates++) + RateFound = 1; + } + + if ((RefreshRate != TargetRate) && (RateFound == 1)) + { + OriginalFps = RefreshRate; + XRRSetScreenConfigAndRate(Dpl, CurrInfo, DefaultRootWindow(Dpl), + CurrentSizeId, CurrentRotation, TargetRate, CurrentTime); + } - XRRFreeScreenConfigInfo(CurrInfo); - XCloseDisplay(Dpl); + XRRFreeScreenConfigInfo(CurrInfo); + XCloseDisplay(Dpl); + } } #endif }