@@ -220,12 +220,14 @@ static const char* drmConnectLibdrm(FFDisplayServerResult* result)
220
220
FF_LIBRARY_LOAD_SYMBOL_MESSAGE (libdrm , drmModeGetConnectorCurrent )
221
221
FF_LIBRARY_LOAD_SYMBOL_MESSAGE (libdrm , drmModeGetCrtc )
222
222
FF_LIBRARY_LOAD_SYMBOL_MESSAGE (libdrm , drmModeGetEncoder )
223
+ FF_LIBRARY_LOAD_SYMBOL_MESSAGE (libdrm , drmModeGetFB )
223
224
FF_LIBRARY_LOAD_SYMBOL_MESSAGE (libdrm , drmModeGetProperty )
224
225
FF_LIBRARY_LOAD_SYMBOL_MESSAGE (libdrm , drmModeGetPropertyBlob )
225
226
FF_LIBRARY_LOAD_SYMBOL_MESSAGE (libdrm , drmModeFreeResources )
226
227
FF_LIBRARY_LOAD_SYMBOL_MESSAGE (libdrm , drmModeFreeCrtc )
227
- FF_LIBRARY_LOAD_SYMBOL_MESSAGE (libdrm , drmModeFreeEncoder )
228
228
FF_LIBRARY_LOAD_SYMBOL_MESSAGE (libdrm , drmModeFreeConnector )
229
+ FF_LIBRARY_LOAD_SYMBOL_MESSAGE (libdrm , drmModeFreeEncoder )
230
+ FF_LIBRARY_LOAD_SYMBOL_MESSAGE (libdrm , drmModeFreeFB )
229
231
FF_LIBRARY_LOAD_SYMBOL_MESSAGE (libdrm , drmModeFreeProperty )
230
232
FF_LIBRARY_LOAD_SYMBOL_MESSAGE (libdrm , drmModeFreePropertyBlob )
231
233
FF_LIBRARY_LOAD_SYMBOL_MESSAGE (libdrm , drmFreeDevices )
@@ -254,28 +256,29 @@ static const char* drmConnectLibdrm(FFDisplayServerResult* result)
254
256
continue ;
255
257
#endif
256
258
257
- FF_AUTO_CLOSE_FD int fd = open (path , O_RDONLY | O_CLOEXEC );
258
- if (fd < 0 )
259
+ FF_AUTO_CLOSE_FD int primaryFd = open (path , O_RDWR | O_CLOEXEC );
260
+ if (primaryFd < 0 )
259
261
continue ;
260
262
261
- drmModeRes * res = ffdrmModeGetResources (fd );
263
+ drmModeRes * res = ffdrmModeGetResources (primaryFd );
262
264
if (!res )
263
265
continue ;
264
266
265
267
for (int iConn = 0 ; iConn < res -> count_connectors ; ++ iConn )
266
268
{
267
- drmModeConnector * conn = ffdrmModeGetConnectorCurrent (fd , res -> connectors [iConn ]);
269
+ drmModeConnector * conn = ffdrmModeGetConnectorCurrent (primaryFd , res -> connectors [iConn ]);
268
270
if (!conn )
269
271
continue ;
270
272
271
273
if (conn -> connection != DRM_MODE_DISCONNECTED )
272
274
{
273
- drmModeEncoder * encoder = ffdrmModeGetEncoder (fd , conn -> encoder_id );
275
+ drmModeEncoder * encoder = ffdrmModeGetEncoder (primaryFd , conn -> encoder_id );
274
276
uint32_t width = 0 , height = 0 , refreshRate = 0 ;
277
+ uint8_t bitDepth = 0 ;
275
278
276
279
if (encoder )
277
280
{
278
- drmModeCrtc * crtc = ffdrmModeGetCrtc (fd , encoder -> crtc_id );
281
+ drmModeCrtc * crtc = ffdrmModeGetCrtc (primaryFd , encoder -> crtc_id );
279
282
if (crtc )
280
283
{
281
284
width = crtc -> mode .hdisplay ;
@@ -294,6 +297,14 @@ static const char* drmConnectLibdrm(FFDisplayServerResult* result)
294
297
}
295
298
}
296
299
}
300
+
301
+ drmModeFBPtr fb = ffdrmModeGetFB (primaryFd , crtc -> buffer_id );
302
+ if (fb )
303
+ {
304
+ bitDepth = (uint8_t ) (fb -> depth / 3 );
305
+ ffdrmModeFreeFB (fb );
306
+ }
307
+
297
308
ffdrmModeFreeCrtc (crtc );
298
309
}
299
310
@@ -332,7 +343,7 @@ static const char* drmConnectLibdrm(FFDisplayServerResult* result)
332
343
333
344
for (int iProp = 0 ; iProp < conn -> count_props ; ++ iProp )
334
345
{
335
- drmModePropertyRes * prop = ffdrmModeGetProperty (fd , conn -> props [iProp ]);
346
+ drmModePropertyRes * prop = ffdrmModeGetProperty (primaryFd , conn -> props [iProp ]);
336
347
if (!prop )
337
348
continue ;
338
349
@@ -342,9 +353,9 @@ static const char* drmConnectLibdrm(FFDisplayServerResult* result)
342
353
drmModePropertyBlobPtr blob = NULL ;
343
354
344
355
if (prop -> count_blobs > 0 && prop -> blob_ids != NULL )
345
- blob = ffdrmModeGetPropertyBlob (fd , prop -> blob_ids [0 ]);
356
+ blob = ffdrmModeGetPropertyBlob (primaryFd , prop -> blob_ids [0 ]);
346
357
else
347
- blob = ffdrmModeGetPropertyBlob (fd , (uint32_t ) conn -> prop_values [iProp ]);
358
+ blob = ffdrmModeGetPropertyBlob (primaryFd , (uint32_t ) conn -> prop_values [iProp ]);
348
359
349
360
if (blob )
350
361
{
@@ -412,6 +423,7 @@ static const char* drmConnectLibdrm(FFDisplayServerResult* result)
412
423
item -> serial = serial ;
413
424
item -> manufactureYear = myear ;
414
425
item -> manufactureWeek = mweak ;
426
+ item -> bitDepth = bitDepth ;
415
427
}
416
428
}
417
429
0 commit comments