diff options
-rw-r--r-- | drm-lease-manager/drm-lease.h | 2 | ||||
-rw-r--r-- | drm-lease-manager/lease-config.c | 16 | ||||
-rw-r--r-- | drm-lease-manager/lease-manager.c | 35 | ||||
-rw-r--r-- | drm-lease-manager/lease-manager.h | 3 | ||||
-rw-r--r-- | drm-lease-manager/main.c | 31 |
5 files changed, 58 insertions, 29 deletions
diff --git a/drm-lease-manager/drm-lease.h b/drm-lease-manager/drm-lease.h index 5670fa8..1a61075 100644 --- a/drm-lease-manager/drm-lease.h +++ b/drm-lease-manager/drm-lease.h @@ -38,6 +38,8 @@ struct lease_config { int nconnectors; struct connector_config *connectors; + + bool have_plane_setting; }; #endif diff --git a/drm-lease-manager/lease-config.c b/drm-lease-manager/lease-config.c index aaba6b6..d3214eb 100644 --- a/drm-lease-manager/lease-config.c +++ b/drm-lease-manager/lease-config.c @@ -78,10 +78,17 @@ static bool populate_connector_config(struct lease_config *config, 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; @@ -119,6 +126,7 @@ int parse_config(char *filename, struct lease_config **parsed_config) 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); diff --git a/drm-lease-manager/lease-manager.c b/drm-lease-manager/lease-manager.c index 51a4613..7147078 100644 --- a/drm-lease-manager/lease-manager.c +++ b/drm-lease-manager/lease-manager.c @@ -504,9 +504,12 @@ err: 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; @@ -518,9 +521,16 @@ static struct lm *drm_device_get_resources(const char *device) 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; } @@ -533,8 +543,8 @@ static struct lm *drm_device_get_resources(const char *device) } 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; } @@ -577,20 +587,20 @@ 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; } @@ -626,10 +636,11 @@ static int lm_create_leases(struct lm *lm, int num_leases, } 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"); @@ -658,7 +669,7 @@ struct lm *lm_create_with_config(const char *device, int num_leases, 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) diff --git a/drm-lease-manager/lease-manager.h b/drm-lease-manager/lease-manager.h index d13ca43..9891adc 100644 --- a/drm-lease-manager/lease-manager.h +++ b/drm-lease-manager/lease-manager.h @@ -21,7 +21,8 @@ struct 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); diff --git a/drm-lease-manager/main.c b/drm-lease-manager/main.c index 5ac3600..d5e8788 100644 --- a/drm-lease-manager/main.c +++ b/drm-lease-manager/main.c @@ -30,24 +30,27 @@ 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}, }; @@ -59,6 +62,7 @@ int main(int argc, char **argv) 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) { @@ -76,6 +80,9 @@ int main(int argc, char **argv) case 'c': config_file = optarg; break; + case 'u': + universal_plane = true; + break; case 'h': ret = EXIT_SUCCESS; /* fall through */ @@ -93,8 +100,8 @@ int main(int argc, char **argv) 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"); |