summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDamian Hobson-Garcia <dhobsong@igel.co.jp>2022-04-14 15:24:11 +0900
committerDamian Hobson-Garcia <dhobsong@igel.co.jp>2022-04-20 10:58:39 +0900
commit5c27165cdcfb28c8b2eccc139802fa0dd6403776 (patch)
tree29fcfe154457dfcbdcfd0ed0634ce1b7662c3010
parent84bd108e702b753bc1f7b232c94baa5b84295b5f (diff)
Add 'optional' property to connector configuration
All connectors will default to mandatory. i.e. if any specified connector is in the lease configuration is not available, that lease will not be created. Setting a connector as 'optional' lets the lease creation succeed even if the connector is not physically present on the system. Failing to create a lease does not affect the creation of other leases. The drm-lease-manager daemon will run as long as one lease is successfully created. Bug-AGL: SPEC-3815 Change-Id: I5edf8a97a2a3589e8eb5368c0a5b13adb4cb5c9b Signed-off-by: Damian Hobson-Garcia <dhobsong@igel.co.jp>
-rw-r--r--drm-lease-manager/drm-lease.h2
-rw-r--r--drm-lease-manager/lease-config.c17
-rw-r--r--drm-lease-manager/lease-manager.c22
3 files changed, 36 insertions, 5 deletions
diff --git a/drm-lease-manager/drm-lease.h b/drm-lease-manager/drm-lease.h
index 2de4fa4..84fa942 100644
--- a/drm-lease-manager/drm-lease.h
+++ b/drm-lease-manager/drm-lease.h
@@ -15,6 +15,7 @@
#ifndef DRM_LEASE_H
#define DRM_LEASE_H
+#include <stdbool.h>
#include <stdint.h>
struct lease_handle {
@@ -24,6 +25,7 @@ struct lease_handle {
struct connector_config {
char *name;
+ bool optional;
};
struct lease_config {
diff --git a/drm-lease-manager/lease-config.c b/drm-lease-manager/lease-config.c
index e246445..b3f35a1 100644
--- a/drm-lease-manager/lease-config.c
+++ b/drm-lease-manager/lease-config.c
@@ -24,6 +24,7 @@
#define CONFIG_ERROR(x, ...) ERROR_LOG("%s: " x, filename, ##__VA_ARGS__)
static bool populate_connector_config(struct lease_config *config,
+ toml_table_t *global_table,
toml_array_t *conns)
{
int nconnectors = toml_array_nelem(conns);
@@ -36,13 +37,24 @@ static bool populate_connector_config(struct lease_config *config,
config->nconnectors = nconnectors;
for (int i = 0; i < config->nconnectors; i++) {
+ struct connector_config *conn_config = &config->connectors[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->connectors[i].name = conn.u.s;
+ conn_config->name = conn.u.s;
+
+ toml_table_t *conn_config_data =
+ toml_table_in(global_table, conn.u.s);
+ if (!conn_config_data)
+ continue;
+
+ toml_datum_t optional =
+ toml_bool_in(conn_config_data, "optional");
+ if (optional.ok)
+ config->connectors[i].optional = optional.u.b;
}
return true;
}
@@ -92,7 +104,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_config(&config[i], conns)) {
+ if (conns &&
+ !populate_connector_config(&config[i], t_config, conns)) {
CONFIG_ERROR("Error configuring lease: %s\n",
config[i].lease_name);
goto err_free_config;
diff --git a/drm-lease-manager/lease-manager.c b/drm-lease-manager/lease-manager.c
index 177a241..3834631 100644
--- a/drm-lease-manager/lease-manager.c
+++ b/drm-lease-manager/lease-manager.c
@@ -356,11 +356,27 @@ static struct lease *lease_create(struct lm *lm,
for (int i = 0; i < nconnectors; i++) {
uint32_t cid;
+ struct connector_config *con_config = NULL;
- if (config->nconnectors > 0) {
- char *connector_name = config->connectors[i].name;
+ if (config->nconnectors > 0)
+ con_config = &config->connectors[i];
- if (!drm_find_connector(lm, connector_name, &cid)) {
+ if (con_config) {
+ char *connector_name = con_config->name;
+ bool optional = con_config->optional;
+
+ bool found =
+ drm_find_connector(lm, connector_name, &cid);
+
+ bool missing_mandatory = !found && !optional;
+ bool missing_optional = !found && optional;
+
+ if (missing_mandatory) {
+ ERROR_LOG("Lease: %s, "
+ "mandatory connector %s not found\n",
+ config->lease_name, connector_name);
+ goto err;
+ } else if (missing_optional) {
WARN_LOG("Lease: %s, "
"unknown DRM connector: %s\n",
config->lease_name, connector_name);