summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorStéphane Desneux <stephane.desneux@iot.bzh>2019-10-17 13:41:13 +0000
committerGerrit Code Review <gerrit@automotivelinux.org>2019-10-17 13:41:13 +0000
commite9230768a7027bb7b3ecb69cfaad587ab3f918b5 (patch)
tree4922f0042019c1c9abba27e6f98533b2ca1b4a6a
parent43be16676a6d76fc7fd980f5523af10fa19aeebc (diff)
parentdd706b1a0d0897130e749bcb5dcfc4fa954697b5 (diff)
Merge "Rework mixer calls to handle dependencies"
-rw-r--r--lib/4a-hal-utilities/4a-hal-utilities-data.h9
-rw-r--r--src/4a-internals-hal/4a-internals-hal-cb.c25
-rw-r--r--src/4a-internals-hal/4a-internals-hal-mixer-link.c14
-rw-r--r--src/4a-internals-hal/4a-internals-hal-mixer-link.h2
4 files changed, 39 insertions, 11 deletions
diff --git a/lib/4a-hal-utilities/4a-hal-utilities-data.h b/lib/4a-hal-utilities/4a-hal-utilities-data.h
index e57bd85..38cade6 100644
--- a/lib/4a-hal-utilities/4a-hal-utilities-data.h
+++ b/lib/4a-hal-utilities/4a-hal-utilities-data.h
@@ -56,6 +56,14 @@ enum ProbedDeviceClasses {
MANDATORY_PROBED_DEVICE = 3
};
+// Enum for dependencies mixer link status
+enum DependencyMixerStatus {
+ DEPENDENCY_NO_MIXER_LINK = 0,
+ DEPENDENCY_MIXER_LINK_USELESS = 1,
+ DEPENDENCY_MIXER_ATTACH_SUCCEED = 2,
+ DEPENDENCY_MIXER_ATTACH_FAILED = 3
+};
+
// Enum for probed devices (dependencies) info format requested
enum DependencyInfoJsonFormat {
DEPENDENCY_COMPACT_JSON = 0,
@@ -91,6 +99,7 @@ struct InternalHalProbedDevice {
json_object *requestedDeviceJ;
struct InternalHalDeviceData *deviceData;
+ enum DependencyMixerStatus mixerLinkStatus;
struct cds_list_head node;
};
diff --git a/src/4a-internals-hal/4a-internals-hal-cb.c b/src/4a-internals-hal/4a-internals-hal-cb.c
index c5f19a2..1e872bb 100644
--- a/src/4a-internals-hal/4a-internals-hal-cb.c
+++ b/src/4a-internals-hal/4a-internals-hal-cb.c
@@ -725,6 +725,7 @@ int InternalHalHalMixerConfig(afb_api_t apiHandle, CtlSectionT *section, json_ob
CtlConfigT *ctrlConfig;
struct HalData *currentHalData;
+ struct InternalHalProbedDevice *currentProbedDevice;
if(! apiHandle || ! section)
return -1;
@@ -752,17 +753,31 @@ int InternalHalHalMixerConfig(afb_api_t apiHandle, CtlSectionT *section, json_ob
return -6;
if(prefix) {
- currentHalData->internalHalData->prefix = strdup(prefix);
+ currentHalData->internalHalData->prefix = strdup(prefix);
if(! currentHalData->internalHalData->prefix)
return -7;
}
}
else if(currentHalData->status == HAL_STATUS_AVAILABLE) {
- err = InternalHalAttachToMixer(apiHandle);
- if(err) {
- AFB_API_ERROR(apiHandle, "Error %i while attaching to mixer", err);
- return -8;
+ cds_list_for_each_entry(currentProbedDevice, &currentHalData->internalHalData->probedDevicesListHead, node) {
+ if(! currentProbedDevice->deviceData) {
+ currentProbedDevice->mixerLinkStatus = DEPENDENCY_MIXER_LINK_USELESS;
+ continue;
+ }
+
+ if(currentProbedDevice->mixerLinkStatus == DEPENDENCY_MIXER_ATTACH_SUCCEED) {
+ AFB_API_WARNING(apiHandle, "Mixer status is already initialized, moving to next one");
+ continue;
+ }
+
+ err = InternalHalAttachDependencyToMixer(apiHandle, currentProbedDevice);
+ if(err) {
+ AFB_API_ERROR(apiHandle, "Error %i while attaching to mixer", err);
+ return -8;
+ }
}
+
+ currentHalData->status = HAL_STATUS_READY;
}
return 0;
diff --git a/src/4a-internals-hal/4a-internals-hal-mixer-link.c b/src/4a-internals-hal/4a-internals-hal-mixer-link.c
index 56dc840..a1b87b0 100644
--- a/src/4a-internals-hal/4a-internals-hal-mixer-link.c
+++ b/src/4a-internals-hal/4a-internals-hal-mixer-link.c
@@ -142,7 +142,7 @@ int InternalHalHandleMixerAttachResponse(afb_api_t apiHandle, struct InternalHal
return 0;
}
-int InternalHalAttachToMixer(afb_api_t apiHandle)
+int InternalHalAttachDependencyToMixer(afb_api_t apiHandle, struct InternalHalProbedDevice *probedDeviceToAttach)
{
int err = 0, mixerError;
@@ -194,9 +194,10 @@ int InternalHalAttachToMixer(afb_api_t apiHandle)
return -6;
}
- dependencyJ = HalUtlGetJsonArrayForAllDependencies(apiHandle,
- &currentHalData->internalHalData->probedDevicesListHead,
- DEPENDENCY_COMPACT_JSON);
+ dependencyJ = HalUtlGetJsonArrayForAllDependenciesInfoWithHandledDependency(apiHandle,
+ &currentHalData->internalHalData->probedDevicesListHead,
+ DEPENDENCY_COMPACT_JSON,
+ probedDeviceToAttach->uid);
if(! dependencyJ) {
AFB_API_ERROR(apiHandle, "Didn't succeed to generate available dependencies compact json array");
return -7;
@@ -251,10 +252,13 @@ int InternalHalAttachToMixer(afb_api_t apiHandle)
MIXER_ATTACH_VERB,
apiToCall,
json_object_get_string(responseJ));
- currentHalData->status = HAL_STATUS_READY;
}
}
+ if(err)
+ probedDeviceToAttach->mixerLinkStatus = DEPENDENCY_MIXER_ATTACH_FAILED;
+ else
+ probedDeviceToAttach->mixerLinkStatus = DEPENDENCY_MIXER_ATTACH_SUCCEED;
if(responseJ)
json_object_put(responseJ);
diff --git a/src/4a-internals-hal/4a-internals-hal-mixer-link.h b/src/4a-internals-hal/4a-internals-hal-mixer-link.h
index 7132aca..b22b5b2 100644
--- a/src/4a-internals-hal/4a-internals-hal-mixer-link.h
+++ b/src/4a-internals-hal/4a-internals-hal-mixer-link.h
@@ -34,7 +34,7 @@
#define HAL_ALL_STREAMS_VERB "all-streams"
// Internals HAL handle mixer calls functions
-int InternalHalAttachToMixer(afb_api_t apiHandle);
+int InternalHalAttachDependencyToMixer(afb_api_t apiHandle, struct InternalHalProbedDevice *probedDeviceToAttach);
int InternalHalGetInfoFromMixer(afb_api_t apiHandle,
char *apiToCall,
json_object *requestJson,