minigbm: add minigbm_create_default_device helper

Variants of minigbm_create_default_device are open-coded in multiple
places.  This should be used wherever minigbm can be assumed.

BUG=none
TEST=manual check that the function works

Change-Id: I3ad9897355ab72080fdca329674df09087b9adfd
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/minigbm/+/4163418
Reviewed-by: Yiwei Zhang <zzyiwei@chromium.org>
Tested-by: Chia-I Wu <olv@google.com>
Commit-Queue: Chia-I Wu <olv@google.com>
This commit is contained in:
Chia-I Wu 2023-01-12 10:58:58 -08:00 committed by Chromeos LUCI
parent afa4dedecd
commit 52fca9c2cd
3 changed files with 69 additions and 1 deletions

View file

@ -6,6 +6,8 @@
#ifndef _MINIGBM_HELPERS_H_
#define _MINIGBM_HELPERS_H_
#include <stdint.h>
#ifdef __cplusplus
extern "C" {
#endif
@ -18,6 +20,8 @@ extern "C" {
#define GBM_DEV_TYPE_FLAG_BLOCKED (1u << 5) /* Unsuitable device e.g. vgem, udl, evdi. */
#define GBM_DEV_TYPE_FLAG_INTERNAL_LCD (1u << 6) /* Device is driving internal LCD. */
struct gbm_device;
struct gbm_device_info {
uint32_t dev_type_flags;
int dri_node_num; /* DRI node number (0..63), for easy matching of devices. */
@ -36,6 +40,12 @@ int gbm_detect_device_info_path(unsigned int detect_flags, const char *dev_node,
*/
int gbm_get_default_device_fd(void);
/*
* Create "default" gbm device. This can pick a different DRM device than
* gbm_get_default_device_fd and should be preferred in most cases.
*/
struct gbm_device *minigbm_create_default_device(int *out_fd);
#ifdef __cplusplus
}
#endif