int nconnectors;
struct connector_config *connectors;
+
+ bool have_plane_setting;
};
#endif
toml_array_t *planes =
toml_array_in(conn_config_data, "planes");
- if (planes && !populate_connector_planes(conn_config, planes)) {
- ERROR_LOG("Invalid plane id for connector: %s\n",
- conn_config->name);
- return false;
+ if (planes != NULL) {
+ bool ret =
+ populate_connector_planes(conn_config, planes);
+ if (ret == false) {
+ ERROR_LOG(
+ "Invalid plane id for connector: %s\n",
+ conn_config->name);
+ return false;
+ } else {
+ config->have_plane_setting = true;
+ }
}
}
return true;
DEBUG_LOG("Memory allocation failed: %s\n", strerror(errno));
goto err;
}
+ config->have_plane_setting = false;
for (i = 0; i < toml_array_nelem(leases); i++) {
toml_table_t *lease = toml_table_at(leases, i);
return -1;
}
-static struct lm *drm_device_get_resources(const char *device)
+static struct lm *drm_device_get_resources(const char *device,
+ bool universal_plane)
{
struct lm *lm = calloc(1, sizeof(struct lm));
+ uint64_t value = 0;
+
if (!lm) {
DEBUG_LOG("Memory allocation failed: %s\n", strerror(errno));
return NULL;
goto err;
}
- /* Enable universal planes so that ALL planes, even primary and cursor
- * planes can be assigned from lease configurations. */
- if (drmSetClientCap(lm->drm_fd, DRM_CLIENT_CAP_UNIVERSAL_PLANES, 1)) {
+ /* When -u option set at args. Enable universal planes so that ALL
+ planes, even primary and cursor planes can be assigned from lease
+ configurations. */
+ if (universal_plane == true) {
+ DEBUG_LOG("Enable universal plean mode.\n");
+ value = 1;
+ }
+
+ if (drmSetClientCap(lm->drm_fd, DRM_CLIENT_CAP_UNIVERSAL_PLANES,
+ value)) {
DEBUG_LOG("drmSetClientCap failed\n");
goto err;
}
}
if (lm->drm_resource->count_connectors <= 0 ||
- lm->drm_resource->count_crtcs <= 0 ||
- lm->drm_resource->count_encoders <= 0) {
+ lm->drm_resource->count_crtcs <= 0 ||
+ lm->drm_resource->count_encoders <= 0) {
DEBUG_LOG("Insufficient DRM resources on device(%s)\n", device);
goto err;
}
return NULL;
}
-static struct lm *drm_find_drm_device(const char *device)
+static struct lm *drm_find_drm_device(const char *device, bool universal_plane)
{
drmDevicePtr devices[64];
int ndevs;
struct lm *lm = NULL;
if (device)
- return drm_device_get_resources(device);
+ return drm_device_get_resources(device, universal_plane);
ndevs = drmGetDevices2(0, devices, 64);
for (int i = 0; i < ndevs; i++) {
lm = drm_device_get_resources(
- devices[i]->nodes[DRM_NODE_PRIMARY]);
+ devices[i]->nodes[DRM_NODE_PRIMARY], universal_plane);
if (lm)
break;
}
}
struct lm *lm_create_with_config(const char *device, int num_leases,
- struct lease_config *configs)
+ struct lease_config *configs,
+ bool universal_plane)
{
struct lease_config *default_configs = NULL;
- struct lm *lm = drm_find_drm_device(device);
+ struct lm *lm = drm_find_drm_device(device, universal_plane);
if (!lm) {
ERROR_LOG("No available DRM device found\n");
struct lm *lm_create(const char *device)
{
- return lm_create_with_config(device, 0, NULL);
+ return lm_create_with_config(device, 0, NULL, false);
}
void lm_destroy(struct lm *lm)
struct lm *lm_create(const char *path);
struct lm *lm_create_with_config(const char *path, int leases,
- struct lease_config *configs);
+ struct lease_config *configs,
+ bool universal_plane);
void lm_destroy(struct lm *lm);
static void usage(const char *progname)
{
- printf("Usage: %s [OPTIONS] [<DRM device>]\n\n"
- "Options:\n"
- "-h, --help \tPrint this help\n"
- "-c, --config \t path to configuration file (default "
- "/etc/drm-lease-manager.toml)\n"
- "-v, --verbose \tEnable verbose debug messages\n"
- "-t, --lease-transfer \tAllow lease transfter to new clients\n"
- "-k, --keep-on-crash \tDon't close lease on client crash\n",
- progname);
+ printf(
+ "Usage: %s [OPTIONS] [<DRM device>]\n\n"
+ "Options:\n"
+ "-h, --help \tPrint this help\n"
+ "-c, --config \t path to configuration file (default "
+ "/etc/drm-lease-manager.toml)\n"
+ "-v, --verbose \tEnable verbose debug messages\n"
+ "-t, --lease-transfer \tAllow lease transfter to new clients\n"
+ "-k, --keep-on-crash \tDon't close lease on client crash\n",
+ "-u, --enable-universal-plane \tEnable universal plane support\n",
+ progname);
}
-const char *opts = "vtkhc:";
+const char *opts = "vtkhcu:";
const struct option options[] = {
{"help", no_argument, NULL, 'h'},
{"verbose", no_argument, NULL, 'v'},
{"lease-transfer", no_argument, NULL, 't'},
{"keep-on-crash", no_argument, NULL, 'k'},
{"config", required_argument, NULL, 'c'},
+ {"enable-universal-plane", required_argument, NULL, 'u'},
{NULL, 0, NULL, 0},
};
bool debug_log = false;
bool can_transfer_leases = false;
bool keep_on_crash = false;
+ bool universal_plane = false;
int c;
while ((c = getopt_long(argc, argv, opts, options, NULL)) != -1) {
case 'c':
config_file = optarg;
break;
+ case 'u':
+ universal_plane = true;
+ break;
case 'h':
ret = EXIT_SUCCESS;
/* fall through */
struct lease_config *lease_configs = NULL;
int num_configs = parse_config(config_file, &lease_configs);
- struct lm *lm =
- lm_create_with_config(device, num_configs, lease_configs);
+ struct lm *lm = lm_create_with_config(device, num_configs,
+ lease_configs, universal_plane);
if (!lm) {
ERROR_LOG("DRM Lease initialization failed\n");