aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--drm-lease-manager/drm-lease.h8
-rw-r--r--drm-lease-manager/lease-config.c28
-rw-r--r--drm-lease-manager/lease-manager.c7
-rw-r--r--drm-lease-manager/test/lease-config-test.c12
-rw-r--r--drm-lease-manager/test/lease-manager-test.c8
5 files changed, 37 insertions, 26 deletions
diff --git a/drm-lease-manager/drm-lease.h b/drm-lease-manager/drm-lease.h
index 76f0bd7..2de4fa4 100644
--- a/drm-lease-manager/drm-lease.h
+++ b/drm-lease-manager/drm-lease.h
@@ -22,14 +22,18 @@ struct lease_handle {
void *user_data;
};
+struct connector_config {
+ char *name;
+};
+
struct lease_config {
char *lease_name;
int ncids;
uint32_t *connector_ids;
- int cnames;
- char **connector_names;
+ int nconnectors;
+ struct connector_config *connectors;
};
#endif
diff --git a/drm-lease-manager/lease-config.c b/drm-lease-manager/lease-config.c
index abb7fc1..e246445 100644
--- a/drm-lease-manager/lease-config.c
+++ b/drm-lease-manager/lease-config.c
@@ -23,24 +23,26 @@
#define CONFIG_ERROR(x, ...) ERROR_LOG("%s: " x, filename, ##__VA_ARGS__)
-static bool populate_connector_names(struct lease_config *config,
- toml_array_t *conns)
+static bool populate_connector_config(struct lease_config *config,
+ toml_array_t *conns)
{
- int cnames = toml_array_nelem(conns);
- config->connector_names = calloc(cnames, sizeof(char *));
- if (!config->connector_names) {
+ int nconnectors = toml_array_nelem(conns);
+ config->connectors = calloc(nconnectors, sizeof(*config->connectors));
+ if (!config->connectors) {
DEBUG_LOG("Memory allocation failed: %s\n", strerror(errno));
return false;
}
- config->cnames = cnames;
+ config->nconnectors = nconnectors;
- for (int i = 0; i < config->cnames; i++) {
+ for (int i = 0; i < config->nconnectors; i++) {
toml_datum_t conn = toml_string_at(conns, i);
if (!conn.ok) {
+ ERROR_LOG("Invalid connector in lease %s: idx:%d\n",
+ config->lease_name, i);
return false;
}
- config->connector_names[i] = conn.u.s;
+ config->connectors[i].name = conn.u.s;
}
return true;
}
@@ -90,8 +92,8 @@ int parse_config(char *filename, struct lease_config **parsed_config)
config[i].lease_name = name.u.s;
toml_array_t *conns = toml_array_in(lease, "connectors");
- if (conns && !populate_connector_names(&config[i], conns)) {
- CONFIG_ERROR("Non string connector name in lease: %s\n",
+ if (conns && !populate_connector_config(&config[i], conns)) {
+ CONFIG_ERROR("Error configuring lease: %s\n",
config[i].lease_name);
goto err_free_config;
}
@@ -113,9 +115,9 @@ void release_config(int num_leases, struct lease_config *config)
for (int i = 0; i < num_leases; i++) {
struct lease_config *c = &config[i];
free(c->lease_name);
- for (int j = 0; j < c->cnames; j++)
- free(c->connector_names[j]);
- free(c->connector_names);
+ for (int j = 0; j < c->nconnectors; j++)
+ free(c->connectors[j].name);
+ free(c->connectors);
}
free(config);
}
diff --git a/drm-lease-manager/lease-manager.c b/drm-lease-manager/lease-manager.c
index 291594c..177a241 100644
--- a/drm-lease-manager/lease-manager.c
+++ b/drm-lease-manager/lease-manager.c
@@ -343,7 +343,8 @@ static struct lease *lease_create(struct lm *lm,
goto err;
}
- int nconnectors = config->cnames > 0 ? config->cnames : config->ncids;
+ int nconnectors =
+ config->nconnectors > 0 ? config->nconnectors : config->ncids;
int nobjects = lm->drm_plane_resource->count_planes +
nconnectors * DRM_OBJECTS_PER_CONNECTOR;
@@ -356,8 +357,8 @@ static struct lease *lease_create(struct lm *lm,
for (int i = 0; i < nconnectors; i++) {
uint32_t cid;
- if (config->cnames > 0) {
- char *connector_name = config->connector_names[i];
+ if (config->nconnectors > 0) {
+ char *connector_name = config->connectors[i].name;
if (!drm_find_connector(lm, connector_name, &cid)) {
WARN_LOG("Lease: %s, "
diff --git a/drm-lease-manager/test/lease-config-test.c b/drm-lease-manager/test/lease-config-test.c
index fa5edcd..65bd32a 100644
--- a/drm-lease-manager/test/lease-config-test.c
+++ b/drm-lease-manager/test/lease-config-test.c
@@ -61,14 +61,14 @@ START_TEST(parse_leases)
ck_assert_ptr_ne(config, NULL);
ck_assert_str_eq(config[0].lease_name, "lease 1");
- ck_assert_int_eq(config[0].cnames, 3);
- ck_assert_str_eq(config[0].connector_names[0], "1");
- ck_assert_str_eq(config[0].connector_names[1], "b");
- ck_assert_str_eq(config[0].connector_names[2], "gamma");
+ ck_assert_int_eq(config[0].nconnectors, 3);
+ ck_assert_str_eq(config[0].connectors[0].name, "1");
+ ck_assert_str_eq(config[0].connectors[1].name, "b");
+ ck_assert_str_eq(config[0].connectors[2].name, "gamma");
ck_assert_str_eq(config[1].lease_name, "lease 2");
- ck_assert_int_eq(config[1].cnames, 1);
- ck_assert_str_eq(config[1].connector_names[0], "connector 3");
+ ck_assert_int_eq(config[1].nconnectors, 1);
+ ck_assert_str_eq(config[1].connectors[0].name, "connector 3");
release_config(nconfigs, config);
}
diff --git a/drm-lease-manager/test/lease-manager-test.c b/drm-lease-manager/test/lease-manager-test.c
index f6524ab..b32cd05 100644
--- a/drm-lease-manager/test/lease-manager-test.c
+++ b/drm-lease-manager/test/lease-manager-test.c
@@ -508,8 +508,12 @@ START_TEST(named_connector_config)
struct lease_config lconfig = {
.lease_name = "Lease Config Test 1",
- .cnames = 2,
- .connector_names = (char *[]){"HDMI-A-1", "VGA-3"},
+ .nconnectors = 2,
+ .connectors =
+ (struct connector_config[]){
+ {.name = "HDMI-A-1"},
+ {.name = "VGA-3"},
+ },
};
struct lease_handle **handles = create_leases(lease_cnt, &lconfig);