Skip to content
Snippets Groups Projects

Compare revisions

Changes are shown as if the source revision was being merged into the target revision. Learn more about comparing revisions.

Source

Select target project
No results found

Target

Select target project
  • videolan/vlc
  • chouquette/vlc
  • bakiewicz.marek122/vlc
  • devnexen/vlc
  • rohanrajpal/vlc
  • blurrrb/vlc
  • gsoc/gsoc2019/darkapex/vlc
  • b1ue/vlc
  • fkuehne/vlc
  • magsoft/vlc
  • chub/vlc
  • cramiro9/vlc
  • robUx4/vlc
  • rom1v/vlc
  • akshayaky/vlc
  • tmk907/vlc
  • akymaster/vlc
  • govind.sharma/vlc
  • psilokos/vlc
  • xjbeta/vlc
  • jahan/vlc
  • 1480c1/vlc
  • amanchande/vlc
  • aaqib/vlc
  • rist/vlc
  • apol/vlc
  • mindfreeze/vlc
  • alexandre-janniaux/vlc
  • sandsmark/vlc
  • jagannatharjun/vlc
  • gsoc/gsoc2020/matiaslgonzalez/vlc
  • gsoc/gsoc2020/jagannatharjun/vlc
  • mstorsjo/vlc
  • gsoc/gsoc2020/vedenta/vlc
  • gsoc/gsoc2020/arnav-ishaan/vlc
  • gsoc/gsoc2020/andreduong/vlc
  • fuzun/vlc
  • gsoc/gsoc2020/vatsin/vlc
  • gsoc/gsoc2020/sagid/vlc
  • yaron/vlc
  • Phoenix/vlc
  • Garf/vlc
  • ePiratWorkarounds/vlc
  • tguillem/vlc
  • jnqnfe/vlc
  • mdc/vlc
  • Vedaa/vlc
  • rasa/vlc
  • quink/vlc
  • yealo/vlc
  • aleksey_ak/vlc
  • ePirat/vlc
  • ilya.yanok/vlc
  • asenat/vlc
  • m/vlc
  • bunjee/vlc
  • BLumia/vlc
  • sagudev/vlc
  • hamedmonji30/vlc
  • nullgemm/vlc
  • DivyamAhuja/vlc
  • thesamesam/vlc
  • dag7/vlc
  • snehil101/vlc
  • haasn/vlc
  • jbk/vlc
  • ValZapod/vlc
  • mfkl/vlc
  • WangChuan/vlc
  • core1024/vlc
  • GhostVaibhav/vlc
  • dfuhrmann/vlc
  • davide.prade/vlc
  • tmatth/vlc
  • Courmisch/vlc
  • zouya/vlc
  • hpi/vlc
  • EwoutH/vlc
  • aleung27/vlc
  • hengwu0/vlc
  • saladin/vlc
  • ashuio/vlc
  • richselwood/vlc
  • verma16Ayush/vlc
  • chemicalflash/vlc
  • PoignardAzur/vlc
  • huangjieNT/vlc
  • Blake-Haydon/vlc
  • AnuthaDev/vlc
  • gsoc/gsoc2021/mpd/vlc
  • nicolas_lequec/vlc
  • sambassaly/vlc
  • thresh/vlc
  • bonniegong/vlc
  • myaashish/vlc
  • stavros.vagionitis/vlc
  • ileoo/vlc
  • louis-santucci/vlc
  • cchristiansen/vlc
  • sabyasachi07/vlc
  • AbduAmeen/vlc
  • ashishb0410/vlc
  • urbanhusky/vlc
  • davidepietrasanta/vlc
  • riksleutelstad/vlc
  • jeremyVignelles/vlc
  • komh/vlc
  • iamjithinjohn/vlc
  • JohannesKauffmann/vlc2
  • kunglao/vlc
  • natzberg/vlc
  • jill/vlc
  • cwendling/vlc
  • adufou/vlc
  • ErwanAirone/vlc
  • HasinduDilshan10/vlc
  • vagrantc/vlc
  • rafiv/macos-bigsur-icon
  • Aymeriic/vlc
  • saranshg20/vlc
  • metzlove24/vlc
  • linkfanel/vlc
  • Ds886/vlc
  • metehan-arslan/vlc
  • Skantes/vlc
  • kgsandundananjaya96/vlc
  • mitchcapper/vlc
  • advaitgupta/vlc
  • StefanBruens/vlc
  • ratajs/vlc
  • T.M.F.B.3761/vlc
  • m222059/vlc
  • casemerrick/vlc
  • joshuaword2alt/vlc
  • sjwaddy/vlc
  • dima/vlc
  • Ybalrid/vlc
  • umxprime/vlc
  • eschmidt/vlc
  • vannieuwenhuysenmichelle/vlc
  • badcf00d/vlc
  • wesinator/vlc
  • louis/vlc
  • xqq/vlc
  • EmperorYP7/vlc
  • NicoLiam/vlc
  • loveleen/vlc
  • rofferom/vlc
  • rbultje/vlc
  • TheUnamed/vlc
  • pratiksharma341/vlc
  • Saurab17/vlc
  • purist.coder/vlc
  • Shuicheng/vlc
  • mdrrubel292/vlc
  • silverbleu00/vlc
  • metif12/vlc
  • asher-m/vlc
  • jeffk/vlc
  • Brandonbr1/vlc
  • beautyyuyanli/vlc
  • rego21/vlc
  • muyangren907/vlc
  • collectionbylawrencejason/vlc
  • evelez/vlc
  • GSMgeeth/vlc
  • Oneric/vlc
  • TJ5/vlc
  • XuanTung95/vlc
  • darrenjenny21/vlc
  • Trenly/vlc
  • RockyTDR/vlc
  • mjakubowski/vlc
  • caprica/vlc
  • ForteFrankie/vlc
  • seannamiller19/vlc
  • junlon2006/vlc
  • kiwiren6666/vlc
  • iuseiphonexs/vlc
  • fenngtun/vlc
  • Rajdutt999/vlc
  • typx/vlc
  • leon.vitanos/vlc
  • robertogarci0938/vlc
  • gsoc/gsoc2022/luc65r/vlc-mpd
  • skeller/vlc
  • MCJack123/vlc
  • luc65r/vlc-mpd
  • popov895/vlc
  • claucambra/vlc
  • brad/vlc
  • matthewmurua88/vlc
  • Tomas8874/vlc
  • philenotfound/vlc
  • makita-do3/vlc
  • LZXCorp/vlc
  • mar0x/vlc
  • senojetkennedy0102/vlc
  • shaneb243/vlc
  • ahmadbader/vlc
  • rajduttcse26/vlc-audio-filters
  • Juniorzito8415/vlc
  • achernyakov/vlc
  • lucasjetgroup/vlc
  • pupdoggy666/vlc
  • gmde9363/vlc
  • alexnwayne/vlc
  • bahareebrahimi781/vlc
  • hamad633666/vlc
  • umghof3112/vlc
  • joe0199771874/vlc
  • Octocats66666666/vlc
  • jjm_223/vlc
  • btech10110.19/vlc
  • sunnykfc028/vlc-audio-filters
  • loic/vlc
  • nguyenminhducmx1/vlc
  • JanekKrueger/vlc
  • bstubbington2/vlc
  • rcombs/vlc
  • Ordissimo/vlc
  • king7532/vlc
  • noobsauce101/vlc
  • schong0525/vlc
  • myQwil/vlc
  • apisbg91/vlc
  • geeboy0101017/vlc
  • kim.faughey/vlc
  • nurupo/vlc
  • yyusea/vlc
  • 0711235879.khco/vlc
  • ialo/vlc
  • iloveyeye2/vlc
  • gdtdftdqtd/vlc
  • leandroconsiglio/vlc
  • AndyHTML2012/vlc
  • ncz/vlc
  • lucenticus/vlc
  • knr1931/vlc
  • kjoonlee/vlc
  • chandrakant100/vlc-qt
  • johge42/vlc
  • polter/vlc
  • hexchain/vlc
  • Tushwrld/vlc
  • mztea928/vlc
  • jbelloncastro/vlc
  • alvinhochun/vlc
  • ghostpiratecrow/vlc
  • ujjwaltwitx/vlc
  • alexsonarin06/vlc
  • adrianbon76/vlc
  • altsod/vlc
  • damien.lucas44/vlc
  • dmytrivtaisa/vlc
  • utk202/vlc
  • aaxhrj/vlc
  • thomas.hermes/vlc
  • structurenewworldorder/vlc
  • slomo/vlc
  • wantlamy/vlc
  • musc.o3cminc/vlc
  • thebarshablog/vlc
  • kerrick/vlc
  • kratos142518/vlc
  • leogps/vlc
  • vacantron/vlc
  • luna_koly/vlc
  • Ratio2/vlc
  • anuoshemohammad/vlc
  • apsun/vlc
  • aaa1115910/vlc
  • alimotmoyo/vlc
  • Ambossmann/vlc
  • Sam-LearnsToCode/vlc
  • Chilledheart/vlc
  • Labnann/vlc
  • ktcoooot1/vlc
  • mohit-marathe/vlc
  • johnddx/vlc
  • manstabuk/vlc
  • Omar-ahmed314/vlc
  • vineethkm/vlc
  • 9Enemi86/vlc
  • radoslav.m.panteleev/vlc
  • ashishami2002/vlc
  • Corbax/vlc
  • firnasahmed/vlc
  • pelayarmalam4/vlc
  • c0ff330k/vlc
  • shikhindahikar/vlc
  • l342723951/vlc
  • christianschwandner/vlc
  • douniwan5788/vlc
  • 7damian7/vlc
  • ferdnyc/vlc
  • f.ales1/vlc
  • pandagby/vlc
  • BaaBaa/vlc
  • jewe37/vlc
  • w00drow/vlc
  • russelltg/vlc
  • ironicallygod/vlc
  • soumyaDghosh/vlc
  • linzihao1999/vlc
  • deyayush6/vlc
  • mibi88/vlc
  • newabdallah10/vlc
  • jhorbincolombia/vlc
  • rimvihaqueshupto/vlc
  • andrewkhon98/vlc
  • fab78/vlc
  • lapaz17/vlc
  • amanna13/vlc
  • mdakram28/vlc
  • 07jw1980/vlc
  • sohamgupta/vlc
  • Eson-Jia1/vlc
  • Sumou/vlc
  • vikram-kangotra/vlc
  • chalice191/vlc
  • olivercalder/vlc
  • aaasg4001/vlc
  • zipdox/vlc
  • kwizart/vlc
  • Dragon-S/vlc
  • jdemeule/vlc
  • gabriel_lt/vlc
  • locutusofborg/vlc
  • sammirata/vlc-librist
  • another/vlc
  • Benjamin_Loison/vlc
  • ahmedmoselhi/vlc
  • petergaal/vlc
  • huynhsontung/vlc
  • dariusmihut/vlc
  • tvermaashutosh/vlc
  • buti/vlc
  • Niram7777/vlc
  • rohan-here/vlc
  • balaji-sivasakthi/vlc
  • rlindner81/vlc
  • Kakadus/vlc
  • djain/vlc
  • ABBurmeister/vlc
  • craighuggins/vlc
  • orbea/vlc
  • maxos/vlc
  • aakarshmj/vlc
  • kblaschke/vlc
  • ankitm/vlc
  • advait-0/vlc
  • mohak2003/vlc
  • yselkowitz/vlc
  • AZM999/vlc-azm
  • andrey.turkin/vlc
  • Disha-Baghel/vlc
  • nowrep/vlc
  • Apeng/vlc
  • Choucroute_melba/vlc
  • autra/vlc
  • eclipseo/vlc
  • fhuber/vlc
  • olafhering/vlc
  • sdasda7777/vlc
  • 1div0/vlc
  • skosnits/vlc-extended-playlist-support
  • dnicolson/vlc
  • Timshel/vlc
  • octopols/vlc
  • MangalK/vlc
  • nima64/vlc
  • misawai/vlc
  • Alexander-Wilms/vlc
  • Maxime2/vlc-fork-for-visualizer
  • ww/vlc
  • jeske/vlc
  • sgross-emlix/vlc
  • morenonatural/vlc
  • freakingLovesVLC/vlc
  • borisgolovnev/vlc
  • mpromonet/vlc
  • diogo.simao-marques/vlc
  • masstock/vlc
  • pratikpatel8982/vlc
  • hugok79/vlc
  • longervision/vlc
  • abhiudaysurya/vlc
  • rishabhgarg/vlc
  • tumic/vlc
  • cart/vlc
  • shubham442/vlc
  • Aditya692005/vlc
  • sammirata/vlc4
  • syrykh/vlc
  • Vvorcun/macos-new-icon
  • AyaanshC/vlc
  • nasso/vlc
  • Quark/vlc
  • sebastinas/vlc
  • rhstone/vlc
  • talregev/vlc
  • Managor/vlc
403 results
Show changes
Commits on Source (4)
......@@ -324,6 +324,7 @@ libdrm_display_plugin_la_SOURCES = \
video_output/drm/vlc_drm.h \
video_output/drm/fourcc.c \
video_output/drm/buffers.c \
video_output/drm/planes.c \
video_output/drm/display.c
libdrm_display_plugin_la_CPPFLAGS = $(AM_CPPFLAGS) $(KMS_CFLAGS)
libdrm_display_plugin_la_LIBADD = $(KMS_LIBS)
......
......@@ -86,7 +86,6 @@ typedef struct vout_display_sys_t {
static struct
{
uint32_t drm;
uint32_t plane_id;
bool present;
bool isYUV;
} fourccmatching[] = {
......@@ -103,7 +102,7 @@ static struct
};
static void CheckFourCCList(uint32_t drmfourcc, uint32_t plane_id)
static void CheckFourCCList(uint32_t drmfourcc)
{
unsigned i;
......@@ -116,7 +115,6 @@ static void CheckFourCCList(uint32_t drmfourcc, uint32_t plane_id)
break;
fourccmatching[i].present = true;
fourccmatching[i].plane_id = plane_id;
break;
}
}
......@@ -128,60 +126,22 @@ static vlc_fourcc_t ChromaNegotiation(vout_display_t *vd)
vout_window_t *wnd = vd->cfg->window;
unsigned i, c;
drmModePlaneRes *plane_res = NULL;
drmModePlane *plane;
bool YUVFormat;
int drm_fd = wnd->display.drm_fd;
drmModeRes *resources = drmModeGetResources(drm_fd);
if (resources == NULL)
return 0;
int crtc_index = -1;
for (int crtc_id=0; crtc_id < resources->count_crtcs; ++crtc_id)
{
if (resources->crtcs[crtc_id] == wnd->handle.crtc)
{
crtc_index = crtc_id;
break;
}
}
drmModeFreeResources(resources);
/*
* For convenience print out in debug prints all supported
* DRM modes so they can be seen if use verbose mode.
*/
plane_res = drmModeGetPlaneResources(drm_fd);
sys->plane_id = 0;
if (plane_res != NULL && plane_res->count_planes > 0) {
for (c = 0; c < plane_res->count_planes; c++) {
plane = drmModeGetPlane(drm_fd, plane_res->planes[c]);
if (plane != NULL && plane->count_formats > 0) {
if ((plane->possible_crtcs & (1 << crtc_index)) == 0)
{
drmModeFreePlane(plane);
continue;
}
for (i = 0; i < plane->count_formats; i++) {
CheckFourCCList(plane->formats[i], plane->plane_id);
if (sys->forced_drm_fourcc && sys->plane_id == 0 &&
plane->formats[i] == sys->drm_fourcc) {
sys->plane_id = plane->plane_id;
}
}
drmModeFreePlane(plane);
} else {
msg_Err(vd, "Couldn't get list of DRM formats");
drmModeFreePlaneResources(plane_res);
return 0;
}
}
drmModeFreePlaneResources(plane_res);
drmModePlane *plane = drmModeGetPlane(drm_fd, sys->plane_id);
if (plane != NULL) {
for (i = 0; i < plane->count_formats; i++)
CheckFourCCList(plane->formats[i]);
drmModeFreePlane(plane);
} else {
msg_Err(vd, "Couldn't get list of DRM formats");
return 0;
}
vlc_fourcc_t fourcc = vd->source->i_chroma;
......@@ -209,10 +169,8 @@ static vlc_fourcc_t ChromaNegotiation(vout_display_t *vd)
for (c = i = 0; c < ARRAY_SIZE(fourccmatching); c++) {
if (fourccmatching[c].drm == drm_fourcc) {
if (!sys->forced_drm_fourcc && fourccmatching[c].present) {
if (!sys->forced_drm_fourcc && fourccmatching[c].present)
sys->drm_fourcc = fourccmatching[c].drm;
sys->plane_id = fourccmatching[c].plane_id;
}
if (!sys->drm_fourcc) {
msg_Err(vd, "Forced VLC fourcc (%.4s) not matching anything available in kernel, please set manually",
......@@ -227,10 +185,8 @@ static vlc_fourcc_t ChromaNegotiation(vout_display_t *vd)
for (c = i = 0; c < ARRAY_SIZE(fourccmatching); c++) {
if (fourccmatching[c].isYUV == YUVFormat
&& fourccmatching[c].present) {
if (!sys->forced_drm_fourcc) {
if (!sys->forced_drm_fourcc)
sys->drm_fourcc = fourccmatching[c].drm;
sys->plane_id = fourccmatching[c].plane_id;
}
return vlc_fourcc_drm(fourccmatching[c].drm);
}
......@@ -239,10 +195,8 @@ static vlc_fourcc_t ChromaNegotiation(vout_display_t *vd)
for (i = 0; c < ARRAY_SIZE(fourccmatching); c++) {
if (!fourccmatching[c].isYUV != YUVFormat
&& fourccmatching[c].present) {
if (!sys->forced_drm_fourcc) {
if (!sys->forced_drm_fourcc)
sys->drm_fourcc = fourccmatching[c].drm;
sys->plane_id = fourccmatching[c].plane_id;
}
return vlc_fourcc_drm(fourccmatching[c].drm);
}
......@@ -336,12 +290,13 @@ static const struct vlc_display_operations ops = {
static int Open(vout_display_t *vd,
video_format_t *fmtp, vlc_video_context *context)
{
vout_window_t *wnd = vd->cfg->window;
vout_display_sys_t *sys;
uint32_t local_drm_chroma;
video_format_t fmt;
char *chroma;
if (vd->cfg->window->type != VOUT_WINDOW_TYPE_KMS)
if (wnd->type != VOUT_WINDOW_TYPE_KMS)
return VLC_EGENERIC;
/*
......@@ -368,7 +323,28 @@ static int Open(vout_display_t *vd,
chroma = NULL;
}
int fd = vd->cfg->window->display.drm_fd;
int fd = wnd->display.drm_fd;
int crtc_index = vlc_drm_get_crtc_index(fd, wnd->handle.crtc);
if (crtc_index < 0) {
msg_Err(vd, "DRM CRTC object ID %"PRIu32" error: %s",
wnd->handle.crtc, vlc_strerror_c(errno));
return -errno;
}
msg_Dbg(vd, "using DRM CRTC object ID %"PRIu32", index %d",
wnd->handle.crtc, crtc_index);
sys->plane_id = vlc_drm_get_crtc_primary_plane(fd, crtc_index);
if (sys->plane_id == 0) {
/* Most likely the window provider failed to set universal mode, or
* failed to lease a primary plane. */
msg_Err(vd, "DRM primary plane not found: %s", vlc_strerror_c(errno));
return -errno;
}
msg_Dbg(vd, "using DRM plane ID %"PRIu32, sys->plane_id);
vlc_fourcc_t fourcc = ChromaNegotiation(vd);
if (!fourcc)
return VLC_EGENERIC;
......
/**
* @file planes.c
* @brief DRM planes
*/
/*****************************************************************************
* Copyright © 2022 Rémi Denis-Courmont
*
* This program is free software; you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation; either version 2.1 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program; if not, write to the Free Software Foundation,
* Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
*****************************************************************************/
#ifdef HAVE_CONFIG_H
# include <config.h>
#endif
#include <assert.h>
#include <errno.h>
#include <stdlib.h>
#include <string.h>
#include <drm_mode.h>
#include <vlc_common.h>
#include "vlc_drm.h"
enum { /* DO NOT CHANGE. MUST MATCH KERNEL ABI. */
VLC_DRM_PLANE_TYPE_OVERLAY=0,
VLC_DRM_PLANE_TYPE_PRIMARY=1,
VLC_DRM_PLANE_TYPE_CURSOR=2,
};
int vlc_drm_get_crtc_index(int fd, uint_fast32_t crtc_id)
{
uint32_t crtcs[32];
struct drm_mode_card_res res = {
.crtc_id_ptr = (uintptr_t)(void *)crtcs,
.count_crtcs = ARRAY_SIZE(crtcs),
};
if (vlc_drm_ioctl(fd, DRM_IOCTL_MODE_GETRESOURCES, &res) < 0)
return -1;
if (unlikely(res.count_crtcs > ARRAY_SIZE(crtcs))) {
/* The API cannot deal with more than 32 CRTCs. Buggy driver? */
errno = ENOBUFS;
return -1;
}
for (size_t i = 0; i < res.count_crtcs; i++)
if (crtcs[i] == crtc_id)
return i;
errno = ENXIO;
return -1;
}
static bool vlc_drm_prop_match(int fd, uint_fast32_t pid, const char *name)
{
struct drm_mode_get_property prop = {
.prop_id = pid,
};
if (vlc_drm_ioctl(fd, DRM_IOCTL_MODE_GETPROPERTY, &prop) < 0)
return false;
return strcmp(name, prop.name) == 0;
}
static int vlc_drm_get_prop(int fd, uint_fast32_t oid, uint_fast32_t tid,
const char *name, uint64_t *restrict valp)
{
struct drm_mode_obj_get_properties counter = {
.obj_id = oid,
.obj_type = tid,
};
int ret = -1;
if (vlc_drm_ioctl(fd, DRM_IOCTL_MODE_OBJ_GETPROPERTIES, &counter) < 0)
return -1;
size_t count = counter.count_props;
uint32_t *ids = vlc_alloc(count, sizeof (*ids));
uint64_t *values = vlc_alloc(count, sizeof (*values));
if (unlikely(ids == NULL || values == NULL))
goto out;
struct drm_mode_obj_get_properties props = {
.props_ptr = (uintptr_t)(void *)ids,
.prop_values_ptr = (uintptr_t)(void *)values,
.count_props = count,
.obj_id = oid,
.obj_type = tid,
};
if (vlc_drm_ioctl(fd, DRM_IOCTL_MODE_OBJ_GETPROPERTIES, &props) < 0)
goto out;
if (unlikely(count < props.count_props)) {
/*
* Properties should not be created asynchronously. It could
* theoretically occur if the underlying object was hot-unplugged, then
* different object with the same type was hot-plugged and got the same
* object identifier. But if so, everything we thought we knew till now
* has potentially become invalid, so we might as well fail safely.
*/
errno = ENOBUFS;
goto out;
}
/* NOTE: if more than one property is needed, rethink this function */
for (size_t i = 0; i < props.count_props; i++) {
if (vlc_drm_prop_match(fd, ids[i], name)) {
*valp = values[i];
ret = 0;
goto out;
}
}
errno = ENXIO;
out:
free(values);
free(ids);
return ret;
}
static int vlc_drm_get_plane_prop(int fd, uint_fast32_t plane,
const char *name, uint64_t *restrict valp)
{
return vlc_drm_get_prop(fd, plane, DRM_MODE_OBJECT_PLANE, name, valp);
}
static ssize_t vlc_drm_get_planes(int fd, uint32_t **restrict listp)
{
size_t count = 32;
for (;;) {
uint32_t *planes = vlc_alloc(count, sizeof (*planes));
if (unlikely(planes == NULL))
return -1;
struct drm_mode_get_plane_res res = {
.plane_id_ptr = (uintptr_t)(void *)planes,
.count_planes = count,
};
if (vlc_drm_ioctl(fd, DRM_IOCTL_MODE_GETPLANERESOURCES, &res) < 0) {
free(planes);
return -1;
}
if (likely(count >= res.count_planes)) {
*listp = planes;
return res.count_planes;
}
free(planes);
}
}
uint_fast32_t vlc_drm_get_crtc_primary_plane(int fd, unsigned int idx)
{
assert(idx < 32); /* Don't mix up object IDs and indices! */
uint32_t *planes;
ssize_t count = vlc_drm_get_planes(fd, &planes);
if (count < 0)
return -1;
uint_fast32_t ret = 0;
for (ssize_t i = 0; i < count; i++) {
struct drm_mode_get_plane plane = {
.plane_id = planes[i],
};
uint64_t planetype;
if (vlc_drm_ioctl(fd, DRM_IOCTL_MODE_GETPLANE, &plane) >= 0
&& ((plane.possible_crtcs >> idx) & 1)
&& vlc_drm_get_plane_prop(fd, planes[i], "type", &planetype) == 0
&& planetype == VLC_DRM_PLANE_TYPE_PRIMARY) {
ret = planes[i];
goto out;
}
}
errno = ENXIO;
out:
free(planes);
return ret;
}
......@@ -84,6 +84,28 @@ picture_t *vlc_drm_dumb_alloc_fb(struct vlc_logger *, int fd,
uint32_t vlc_drm_dumb_get_fb_id(const picture_t *pic);
/**
* Finds the index of a CRTC.
*
* The DRM API represents sets of CRTCs as 32-bit bit masks.
* This function determines the bit index of a given CRTC.
*
* \param fd DRM device file descriptor
* \param crtc_id CRTC object ID
* \return On success, the index (between 0 and 31) of object is returned,
* On error, -1 is returned and @c errno is set.
*/
int vlc_drm_get_crtc_index(int fd, uint_fast32_t crtc_id);
/**
* Finds the primary plane of a CRTC.
*
* \param fd DRM device file descriptor
* \param idx CRTC object index (as returned by vlc_drm_get_crtc_index())
* \return the primary plane object ID or zero on error
*/
uint_fast32_t vlc_drm_get_crtc_primary_plane(int fd, unsigned int idx);
static inline int vlc_drm_ioctl(int fd, unsigned long cmd, void *argp)
{
int ret;
......