Skip to content

Commit 3758b4d

Browse files
authored
Merge pull request #38 from ua0lnj/master
Added drm device selection. /dev/dri/card1 and /dev/dri/card0 will be…
2 parents 69c1c6e + 950b541 commit 3758b4d

File tree

6 files changed

+33
-3
lines changed

6 files changed

+33
-3
lines changed

README

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -105,6 +105,9 @@ Command line arguments
105105
You can set X11 geometry with this parameter [W[xH]][+-x+-y][/WS] or x:y.
106106
Resolution of OSD get from settings of output plugin (softhd*). OSD is scaled to video size.
107107

108+
-e drm device
109+
force set drm device (ex. /dev/dri/card0). Otherwise they will be tried /dev/dri/card1 and /dev/dri/card0.
110+
108111
Plugin setup options
109112
--------------------
110113

config.c

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@ cMpvPluginConfig::cMpvPluginConfig()
4545
Geometry = "";
4646
Windowed = 0;
4747
ShowOptions = 0;
48+
DRMdev = "";
4849
}
4950

5051
vector<string> cMpvPluginConfig::ExplodeString(string Input)
@@ -73,7 +74,7 @@ int cMpvPluginConfig::ProcessArgs(int argc, char *const argv[])
7374

7475
for (;;)
7576
{
76-
switch (getopt(argc, argv, "a:v:h:c:d:b:l:x:rm:swg:"))
77+
switch (getopt(argc, argv, "a:v:h:c:d:b:l:x:rm:swg:e:"))
7778
{
7879
case 'a': // audio out
7980
AudioOut = optarg;
@@ -114,6 +115,9 @@ int cMpvPluginConfig::ProcessArgs(int argc, char *const argv[])
114115
case 'g':
115116
Geometry = optarg;
116117
continue;
118+
case 'e':
119+
DRMdev = optarg;
120+
continue;
117121
case EOF:
118122
break;
119123
case ':':

config.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,7 @@ class cMpvPluginConfig
6060
string X11Display; // X11 display used for mpv
6161
string TitleOverride; // title to display (ovveride used via service interface)
6262
string Geometry; // X11 display geometry
63+
string DRMdev; // DRM device
6364
int Windowed; // windowed mode, not fullscreen
6465

6566
int ShowOptions; // switch show menu options or filebrowser menu

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.6.1"
22+
static const char *VERSION = "1.7.0"
2323
#ifdef GIT_REV
2424
"-GIT" GIT_REV
2525
#endif

player.c

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ volatile int cMpvPlayer::running = 0;
4343
cMpvPlayer *cMpvPlayer::PlayerHandle = NULL;
4444
std::string LocaleSave;
4545
int drm_ctx = 0;
46-
46+
const char *drm_dev = NULL;
4747
Display *Dpy = NULL;
4848
xcb_connection_t *Connect = NULL;
4949
xcb_window_t VideoWindow = 0;
@@ -453,6 +453,25 @@ void cMpvPlayer::PlayerHideCursor()
453453
}
454454

455455
#ifdef USE_DRM
456+
int cMpvPlayer::PlayerTryDRM()
457+
{
458+
int fd;
459+
if (strcmp(MpvPluginConfig->DRMdev.c_str(),"")) {
460+
drm_dev = MpvPluginConfig->DRMdev.c_str();
461+
return 1;
462+
}
463+
//card1 mean external card, card0 internal. First try external card
464+
fd = open("/dev/dri/card1", O_RDWR);
465+
if (fd < 0) {
466+
fd = open("/dev/dri/card0", O_RDWR);
467+
if (fd < 0) return 0;
468+
else drm_dev = "/dev/dri/card0";
469+
} else drm_dev = "/dev/dri/card1";
470+
471+
close(fd);
472+
return 1;
473+
}
474+
456475
void cMpvPlayer::PlayerGetDRM()
457476
{
458477
int fd, i;
@@ -520,6 +539,8 @@ void cMpvPlayer::PlayerStart()
520539
if (!strcmp(MpvPluginConfig->GpuCtx.c_str(),"drm") || !strcmp(MpvPluginConfig->VideoOut.c_str(),"drm"))
521540
{
522541
drm_ctx = 1;
542+
if (!PlayerTryDRM()) return;
543+
check_error(mpv_set_option_string(hMpv, "drm-device", drm_dev));
523544
}
524545
//no geometry with drm
525546
if (!drm_ctx) {

player.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ class cMpvPlayer:public cPlayer
2626
void SwitchOsdToMpv();
2727
void PlayerHideCursor();
2828
void PlayerGetDRM();
29+
int PlayerTryDRM();
2930

3031
string PlayFilename; // file to play
3132
bool PlayShuffle; // shuffle playlist

0 commit comments

Comments
 (0)