{"action":"created","comment":{"url":"https://api.github.com/repos/mpv-player/mpv/pulls/comments/28412126","id":28412126,"diff_hunk":"@@ -0,0 +1,509 @@\n+/*\n+ * video output driver for libdrm\n+ *\n+ * by rr- <rr-@sakuya.pl>\n+ *\n+ * This file is part of mpv.\n+ *\n+ * mpv is free software; you can redistribute it and/or modify\n+ * it under the terms of the GNU General Public License as published by\n+ * the Free Software Foundation; either version 2 of the License, or\n+ * (at your option) any later version.\n+ *\n+ * mpv is distributed in the hope that it will be useful,\n+ * but WITHOUT ANY WARRANTY; without even the implied warranty of\n+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\n+ * GNU General Public License for more details.\n+ *\n+ * You should have received a copy of the GNU General Public License along\n+ * with mpv.  If not, see <http://www.gnu.org/licenses/>.\n+ */\n+\n+#include <assert.h>\n+#include <errno.h>\n+#include <fcntl.h>\n+#include <stdbool.h>\n+#include <libswscale/swscale.h>\n+#include <sys/mman.h>\n+#include <xf86drm.h>\n+#include <xf86drmMode.h>\n+\n+#include \"common/msg.h\"\n+#include \"sub/osd.h\"\n+#include \"video/fmt-conversion.h\"\n+#include \"video/mp_image.h\"\n+#include \"video/sws_utils.h\"\n+#include \"vo.h\"\n+\n+#define BUF_COUNT 2\n+\n+struct modeset_buf {\n+    uint32_t width;\n+    uint32_t height;\n+    uint32_t stride;\n+    uint32_t size;\n+    uint32_t handle;\n+    uint8_t *map;\n+    uint32_t fb;\n+};\n+\n+struct modeset_dev {\n+    struct modeset_buf bufs[BUF_COUNT];\n+    drmModeModeInfo mode;\n+    uint32_t conn;\n+    uint32_t crtc;\n+    int front_buf;\n+};\n+\n+struct priv {\n+    int fd;\n+    struct modeset_dev *dev;\n+    drmModeCrtc *old_crtc;\n+\n+    char *device_path;\n+    int connector_id;\n+\n+    int32_t device_w;\n+    int32_t device_h;\n+    int32_t x, y;\n+    struct mp_image *curframe;\n+    struct mp_rect src;\n+    struct mp_rect dst;\n+    struct mp_osd_res osd;\n+    struct mp_sws_context *sws;\n+};\n+\n+static int modeset_open(struct vo *vo, int *out, const char *node)\n+{\n+    int fd;\n+    uint64_t has_dumb;\n+    fd = open(node, O_RDWR | O_CLOEXEC);\n+    if (fd < 0) {\n+        MP_ERR(vo, \"Cannot open \\\"%s\\\": %s.\\n\", node, mp_strerror(errno));\n+        return -errno;\n+    }\n+    if (drmGetCap(fd, DRM_CAP_DUMB_BUFFER, &has_dumb) < 0) {\n+        MP_ERR(vo, \"Device \\\"%s\\\" does not support dumb buffers.\\n\", node);\n+        return -EOPNOTSUPP;\n+    }\n+    *out = fd;\n+    return 0;\n+}\n+\n+static int modeset_create_fb(struct vo *vo, int fd, struct modeset_buf *buf)\n+{\n+    struct drm_mode_create_dumb creq;\n+    struct drm_mode_destroy_dumb dreq;\n+    struct drm_mode_map_dumb mreq;\n+    int ret;\n+\n+    // create dumb buffer\n+    memset(&creq, 0, sizeof(creq));","path":"video/out/vo_drm.c","position":101,"original_position":101,"commit_id":"5665a8ad3bf2858b55071854e4736d6bd65f4220","original_commit_id":"5665a8ad3bf2858b55071854e4736d6bd65f4220","user":{"login":"wm4","id":1387750,"avatar_url":"https://avatars.githubusercontent.com/u/1387750?v=3","gravatar_id":"","url":"https://api.github.com/users/wm4","html_url":"https://github.com/wm4","followers_url":"https://api.github.com/users/wm4/followers","following_url":"https://api.github.com/users/wm4/following{/other_user}","gists_url":"https://api.github.com/users/wm4/gists{/gist_id}","starred_url":"https://api.github.com/users/wm4/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/wm4/subscriptions","organizations_url":"https://api.github.com/users/wm4/orgs","repos_url":"https://api.github.com/users/wm4/repos","events_url":"https://api.github.com/users/wm4/events{/privacy}","received_events_url":"https://api.github.com/users/wm4/received_events","type":"User","site_admin":false},"body":"Instead of this, you can just write ``struct drm_mode_create_dumb creq = {0};``.","created_at":"2015-04-15T11:39:48Z","updated_at":"2015-04-15T11:39:48Z","html_url":"https://github.com/mpv-player/mpv/pull/1811#discussion_r28412126","pull_request_url":"https://api.github.com/repos/mpv-player/mpv/pulls/1811","_links":{"self":{"href":"https://api.github.com/repos/mpv-player/mpv/pulls/comments/28412126"},"html":{"href":"https://github.com/mpv-player/mpv/pull/1811#discussion_r28412126"},"pull_request":{"href":"https://api.github.com/repos/mpv-player/mpv/pulls/1811"}}},"pull_request":{"url":"https://api.github.com/repos/mpv-player/mpv/pulls/1811","id":33176487,"html_url":"https://github.com/mpv-player/mpv/pull/1811","diff_url":"https://github.com/mpv-player/mpv/pull/1811.diff","patch_url":"https://github.com/mpv-player/mpv/pull/1811.patch","issue_url":"https://api.github.com/repos/mpv-player/mpv/issues/1811","number":1811,"state":"open","locked":false,"title":"vo_drm: add KMS/DRM renderer support","user":{"login":"rr-","id":1045476,"avatar_url":"https://avatars.githubusercontent.com/u/1045476?v=3","gravatar_id":"","url":"https://api.github.com/users/rr-","html_url":"https://github.com/rr-","followers_url":"https://api.github.com/users/rr-/followers","following_url":"https://api.github.com/users/rr-/following{/other_user}","gists_url":"https://api.github.com/users/rr-/gists{/gist_id}","starred_url":"https://api.github.com/users/rr-/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/rr-/subscriptions","organizations_url":"https://api.github.com/users/rr-/orgs","repos_url":"https://api.github.com/users/rr-/repos","events_url":"https://api.github.com/users/rr-/events{/privacy}","received_events_url":"https://api.github.com/users/rr-/received_events","type":"User","site_admin":false},"body":"This pull request introduces new video output, `vo_drm`. It uses Direct Rendering Manager (DRM) and Kernel Mode Setting (KMS) to enable watching videos on Linux systems, where neither X window system nor wayland server are available. Its only dependency is `libdrm` (it doesn't even need OpenGL) and thus I draw a bold conclusion that in terms of dependencies, it is the most lightweight video renderer for Linux.\r\n\r\nBecause of this, it doesn't use hardware acceleration at all, and heavy videos / old hardware *will* experience performance problems. This was tested on a 5-year-old netbook equipped with AMD C-50 (1gHz) and Radeon 6250. Old movies were played acceptably, while 720p action videos with rich ass subtitles experienced massive frame drops. This behavior could be fixed to some extent with extreme `--vf=scale=-1:180 --sws-scaler=point`.\r\n\r\nI have no idea how it performs on better hardware. I'm going to purchase a powerful computer within one month.\r\n\r\nAdditionally, I (eventually) plan to develop a renderer for DRM that utilizes hardware acceleration, but it will need `libegl` and almost surely `libgbm` that come with their own (remarkable) chain of dependencies. In my opinion, these dependencies are what makes `vo_drm` attractive.","created_at":"2015-04-13T15:51:34Z","updated_at":"2015-04-15T11:39:48Z","closed_at":null,"merged_at":null,"merge_commit_sha":"4eb625c7cac0a19922349cce8606eeb608526b0d","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/mpv-player/mpv/pulls/1811/commits","review_comments_url":"https://api.github.com/repos/mpv-player/mpv/pulls/1811/comments","review_comment_url":"https://api.github.com/repos/mpv-player/mpv/pulls/comments{/number}","comments_url":"https://api.github.com/repos/mpv-player/mpv/issues/1811/comments","statuses_url":"https://api.github.com/repos/mpv-player/mpv/statuses/5665a8ad3bf2858b55071854e4736d6bd65f4220","head":{"label":"rr-:drm","ref":"drm","sha":"5665a8ad3bf2858b55071854e4736d6bd65f4220","user":{"login":"rr-","id":1045476,"avatar_url":"https://avatars.githubusercontent.com/u/1045476?v=3","gravatar_id":"","url":"https://api.github.com/users/rr-","html_url":"https://github.com/rr-","followers_url":"https://api.github.com/users/rr-/followers","following_url":"https://api.github.com/users/rr-/following{/other_user}","gists_url":"https://api.github.com/users/rr-/gists{/gist_id}","starred_url":"https://api.github.com/users/rr-/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/rr-/subscriptions","organizations_url":"https://api.github.com/users/rr-/orgs","repos_url":"https://api.github.com/users/rr-/repos","events_url":"https://api.github.com/users/rr-/events{/privacy}","received_events_url":"https://api.github.com/users/rr-/received_events","type":"User","site_admin":false},"repo":{"id":33629723,"name":"mpv","full_name":"rr-/mpv","owner":{"login":"rr-","id":1045476,"avatar_url":"https://avatars.githubusercontent.com/u/1045476?v=3","gravatar_id":"","url":"https://api.github.com/users/rr-","html_url":"https://github.com/rr-","followers_url":"https://api.github.com/users/rr-/followers","following_url":"https://api.github.com/users/rr-/following{/other_user}","gists_url":"https://api.github.com/users/rr-/gists{/gist_id}","starred_url":"https://api.github.com/users/rr-/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/rr-/subscriptions","organizations_url":"https://api.github.com/users/rr-/orgs","repos_url":"https://api.github.com/users/rr-/repos","events_url":"https://api.github.com/users/rr-/events{/privacy}","received_events_url":"https://api.github.com/users/rr-/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/rr-/mpv","description":"Video player based on MPlayer/mplayer2","fork":true,"url":"https://api.github.com/repos/rr-/mpv","forks_url":"https://api.github.com/repos/rr-/mpv/forks","keys_url":"https://api.github.com/repos/rr-/mpv/keys{/key_id}","collaborators_url":"https://api.github.com/repos/rr-/mpv/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/rr-/mpv/teams","hooks_url":"https://api.github.com/repos/rr-/mpv/hooks","issue_events_url":"https://api.github.com/repos/rr-/mpv/issues/events{/number}","events_url":"https://api.github.com/repos/rr-/mpv/events","assignees_url":"https://api.github.com/repos/rr-/mpv/assignees{/user}","branches_url":"https://api.github.com/repos/rr-/mpv/branches{/branch}","tags_url":"https://api.github.com/repos/rr-/mpv/tags","blobs_url":"https://api.github.com/repos/rr-/mpv/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/rr-/mpv/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/rr-/mpv/git/refs{/sha}","trees_url":"https://api.github.com/repos/rr-/mpv/git/trees{/sha}","statuses_url":"https://api.github.com/repos/rr-/mpv/statuses/{sha}","languages_url":"https://api.github.com/repos/rr-/mpv/languages","stargazers_url":"https://api.github.com/repos/rr-/mpv/stargazers","contributors_url":"https://api.github.com/repos/rr-/mpv/contributors","subscribers_url":"https://api.github.com/repos/rr-/mpv/subscribers","subscription_url":"https://api.github.com/repos/rr-/mpv/subscription","commits_url":"https://api.github.com/repos/rr-/mpv/commits{/sha}","git_commits_url":"https://api.github.com/repos/rr-/mpv/git/commits{/sha}","comments_url":"https://api.github.com/repos/rr-/mpv/comments{/number}","issue_comment_url":"https://api.github.com/repos/rr-/mpv/issues/comments{/number}","contents_url":"https://api.github.com/repos/rr-/mpv/contents/{+path}","compare_url":"https://api.github.com/repos/rr-/mpv/compare/{base}...{head}","merges_url":"https://api.github.com/repos/rr-/mpv/merges","archive_url":"https://api.github.com/repos/rr-/mpv/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/rr-/mpv/downloads","issues_url":"https://api.github.com/repos/rr-/mpv/issues{/number}","pulls_url":"https://api.github.com/repos/rr-/mpv/pulls{/number}","milestones_url":"https://api.github.com/repos/rr-/mpv/milestones{/number}","notifications_url":"https://api.github.com/repos/rr-/mpv/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/rr-/mpv/labels{/name}","releases_url":"https://api.github.com/repos/rr-/mpv/releases{/id}","created_at":"2015-04-08T20:11:57Z","updated_at":"2015-04-13T06:51:15Z","pushed_at":"2015-04-14T18:14:03Z","git_url":"git://github.com/rr-/mpv.git","ssh_url":"git@github.com:rr-/mpv.git","clone_url":"https://github.com/rr-/mpv.git","svn_url":"https://github.com/rr-/mpv","homepage":"http://mpv.io","size":67963,"stargazers_count":0,"watchers_count":0,"language":"C","has_issues":false,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":0,"forks":0,"open_issues":0,"watchers":0,"default_branch":"master"}},"base":{"label":"mpv-player:master","ref":"master","sha":"3b2cc79d2f42eefebf4390ccf722e1bb02d6f734","user":{"login":"mpv-player","id":2550273,"avatar_url":"https://avatars.githubusercontent.com/u/2550273?v=3","gravatar_id":"","url":"https://api.github.com/users/mpv-player","html_url":"https://github.com/mpv-player","followers_url":"https://api.github.com/users/mpv-player/followers","following_url":"https://api.github.com/users/mpv-player/following{/other_user}","gists_url":"https://api.github.com/users/mpv-player/gists{/gist_id}","starred_url":"https://api.github.com/users/mpv-player/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mpv-player/subscriptions","organizations_url":"https://api.github.com/users/mpv-player/orgs","repos_url":"https://api.github.com/users/mpv-player/repos","events_url":"https://api.github.com/users/mpv-player/events{/privacy}","received_events_url":"https://api.github.com/users/mpv-player/received_events","type":"Organization","site_admin":false},"repo":{"id":6201092,"name":"mpv","full_name":"mpv-player/mpv","owner":{"login":"mpv-player","id":2550273,"avatar_url":"https://avatars.githubusercontent.com/u/2550273?v=3","gravatar_id":"","url":"https://api.github.com/users/mpv-player","html_url":"https://github.com/mpv-player","followers_url":"https://api.github.com/users/mpv-player/followers","following_url":"https://api.github.com/users/mpv-player/following{/other_user}","gists_url":"https://api.github.com/users/mpv-player/gists{/gist_id}","starred_url":"https://api.github.com/users/mpv-player/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mpv-player/subscriptions","organizations_url":"https://api.github.com/users/mpv-player/orgs","repos_url":"https://api.github.com/users/mpv-player/repos","events_url":"https://api.github.com/users/mpv-player/events{/privacy}","received_events_url":"https://api.github.com/users/mpv-player/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/mpv-player/mpv","description":"Video player based on MPlayer/mplayer2","fork":false,"url":"https://api.github.com/repos/mpv-player/mpv","forks_url":"https://api.github.com/repos/mpv-player/mpv/forks","keys_url":"https://api.github.com/repos/mpv-player/mpv/keys{/key_id}","collaborators_url":"https://api.github.com/repos/mpv-player/mpv/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/mpv-player/mpv/teams","hooks_url":"https://api.github.com/repos/mpv-player/mpv/hooks","issue_events_url":"https://api.github.com/repos/mpv-player/mpv/issues/events{/number}","events_url":"https://api.github.com/repos/mpv-player/mpv/events","assignees_url":"https://api.github.com/repos/mpv-player/mpv/assignees{/user}","branches_url":"https://api.github.com/repos/mpv-player/mpv/branches{/branch}","tags_url":"https://api.github.com/repos/mpv-player/mpv/tags","blobs_url":"https://api.github.com/repos/mpv-player/mpv/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/mpv-player/mpv/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/mpv-player/mpv/git/refs{/sha}","trees_url":"https://api.github.com/repos/mpv-player/mpv/git/trees{/sha}","statuses_url":"https://api.github.com/repos/mpv-player/mpv/statuses/{sha}","languages_url":"https://api.github.com/repos/mpv-player/mpv/languages","stargazers_url":"https://api.github.com/repos/mpv-player/mpv/stargazers","contributors_url":"https://api.github.com/repos/mpv-player/mpv/contributors","subscribers_url":"https://api.github.com/repos/mpv-player/mpv/subscribers","subscription_url":"https://api.github.com/repos/mpv-player/mpv/subscription","commits_url":"https://api.github.com/repos/mpv-player/mpv/commits{/sha}","git_commits_url":"https://api.github.com/repos/mpv-player/mpv/git/commits{/sha}","comments_url":"https://api.github.com/repos/mpv-player/mpv/comments{/number}","issue_comment_url":"https://api.github.com/repos/mpv-player/mpv/issues/comments{/number}","contents_url":"https://api.github.com/repos/mpv-player/mpv/contents/{+path}","compare_url":"https://api.github.com/repos/mpv-player/mpv/compare/{base}...{head}","merges_url":"https://api.github.com/repos/mpv-player/mpv/merges","archive_url":"https://api.github.com/repos/mpv-player/mpv/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/mpv-player/mpv/downloads","issues_url":"https://api.github.com/repos/mpv-player/mpv/issues{/number}","pulls_url":"https://api.github.com/repos/mpv-player/mpv/pulls{/number}","milestones_url":"https://api.github.com/repos/mpv-player/mpv/milestones{/number}","notifications_url":"https://api.github.com/repos/mpv-player/mpv/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/mpv-player/mpv/labels{/name}","releases_url":"https://api.github.com/repos/mpv-player/mpv/releases{/id}","created_at":"2012-10-13T08:08:44Z","updated_at":"2015-04-15T11:29:00Z","pushed_at":"2015-04-15T11:29:00Z","git_url":"git://github.com/mpv-player/mpv.git","ssh_url":"git@github.com:mpv-player/mpv.git","clone_url":"https://github.com/mpv-player/mpv.git","svn_url":"https://github.com/mpv-player/mpv","homepage":"http://mpv.io","size":97834,"stargazers_count":1729,"watchers_count":1729,"language":"C","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":235,"mirror_url":null,"open_issues_count":200,"forks":235,"open_issues":200,"watchers":1729,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/mpv-player/mpv/pulls/1811"},"html":{"href":"https://github.com/mpv-player/mpv/pull/1811"},"issue":{"href":"https://api.github.com/repos/mpv-player/mpv/issues/1811"},"comments":{"href":"https://api.github.com/repos/mpv-player/mpv/issues/1811/comments"},"review_comments":{"href":"https://api.github.com/repos/mpv-player/mpv/pulls/1811/comments"},"review_comment":{"href":"https://api.github.com/repos/mpv-player/mpv/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/mpv-player/mpv/pulls/1811/commits"},"statuses":{"href":"https://api.github.com/repos/mpv-player/mpv/statuses/5665a8ad3bf2858b55071854e4736d6bd65f4220"}}}}