summaryrefslogtreecommitdiffstats
path: root/4a-hal-utilities
diff options
context:
space:
mode:
Diffstat (limited to '4a-hal-utilities')
-rw-r--r--4a-hal-utilities/4a-hal-utilities-alsa-data.c51
-rw-r--r--4a-hal-utilities/4a-hal-utilities-alsa-data.h72
-rw-r--r--4a-hal-utilities/4a-hal-utilities-appfw-responses-handler.c147
-rw-r--r--4a-hal-utilities/4a-hal-utilities-appfw-responses-handler.h45
-rw-r--r--4a-hal-utilities/4a-hal-utilities-data.c243
-rw-r--r--4a-hal-utilities/4a-hal-utilities-data.h108
-rw-r--r--4a-hal-utilities/4a-hal-utilities-verbs-loader.c50
-rw-r--r--4a-hal-utilities/4a-hal-utilities-verbs-loader.h28
-rw-r--r--4a-hal-utilities/CMakeLists.txt40
9 files changed, 784 insertions, 0 deletions
diff --git a/4a-hal-utilities/4a-hal-utilities-alsa-data.c b/4a-hal-utilities/4a-hal-utilities-alsa-data.c
new file mode 100644
index 0000000..ef2967a
--- /dev/null
+++ b/4a-hal-utilities/4a-hal-utilities-alsa-data.c
@@ -0,0 +1,51 @@
+/*
+ * Copyright (C) 2019 "IoT.bzh"
+ * Author Jonathan Aillet <jonathan.aillet@iot.bzh>
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#define _GNU_SOURCE
+
+#include <stdio.h>
+
+#include <afb-definitions.h>
+
+#include "4a-hal-utilities-alsa-data.h"
+
+/*******************************************************************************
+ * Free contents of 'CtlHalAlsaMapT' data structure *
+ ******************************************************************************/
+
+uint8_t HalUtlFreeAlsaCtlsMap(struct CtlHalAlsaMapT *alsaCtlsMap)
+{
+ int idx;
+
+ if(! alsaCtlsMap)
+ return -1;
+
+ if(alsaCtlsMap->ctlsCount > 0 && ! alsaCtlsMap->ctls)
+ return -2;
+
+ for(idx = 0; idx < alsaCtlsMap->ctlsCount; idx++) {
+ free(alsaCtlsMap->ctls[idx].action);
+ free(alsaCtlsMap->ctls[idx].ctl.alsaCtlProperties.enums);
+ free(alsaCtlsMap->ctls[idx].ctl.alsaCtlProperties.dbscale);
+ }
+
+ free(alsaCtlsMap->ctls);
+
+ free(alsaCtlsMap);
+
+ return 0;
+} \ No newline at end of file
diff --git a/4a-hal-utilities/4a-hal-utilities-alsa-data.h b/4a-hal-utilities/4a-hal-utilities-alsa-data.h
new file mode 100644
index 0000000..5a998ae
--- /dev/null
+++ b/4a-hal-utilities/4a-hal-utilities-alsa-data.h
@@ -0,0 +1,72 @@
+/*
+* Copyright (C) 2019 "IoT.bzh"
+* Author Jonathan Aillet <jonathan.aillet@iot.bzh>
+*
+* Licensed under the Apache License, Version 2.0 (the "License");
+* you may not use this file except in compliance with the License.
+* You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS,
+* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*/
+
+#ifndef _HAL_UTILITIES_ALSA_DATA_INCLUDE_
+#define _HAL_UTILITIES_ALSA_DATA_INCLUDE_
+
+#include <stdio.h>
+
+#include <json-c/json.h>
+
+#include <alsa/asoundlib.h>
+
+#include <ctl-config.h>
+
+struct CtlHalAlsaDBScale {
+ int min;
+ int max;
+ int step;
+ int mute;
+};
+
+struct CtlHalAlsaCtlProperties {
+ snd_ctl_elem_type_t type;
+ int count;
+ int minval;
+ int maxval;
+ int step;
+ // TBD JAI : use them
+ const char **enums;
+ struct CtlHalAlsaDBScale *dbscale;
+};
+
+struct CtlHalAlsaCtl {
+ char *name;
+ int numid;
+ int value;
+ struct CtlHalAlsaCtlProperties alsaCtlProperties;
+ struct CtlHalAlsaCtlProperties *alsaCtlCreation;
+};
+
+struct CtlHalAlsaMap {
+ const char *uid;
+ char *info;
+ AFB_EventT alsaControlEvent;
+ struct CtlHalAlsaCtl ctl;
+ json_object *actionJ;
+ CtlActionT *action;
+};
+
+struct CtlHalAlsaMapT {
+ struct CtlHalAlsaMap *ctls;
+ unsigned int ctlsCount;
+};
+
+// Free contents of 'CtlHalAlsaMapT' data structure
+uint8_t HalUtlFreeAlsaCtlsMap(struct CtlHalAlsaMapT *alsaCtlsMap);
+
+#endif /* _HAL_UTILITIES_ALSA_DATA_INCLUDE_ */ \ No newline at end of file
diff --git a/4a-hal-utilities/4a-hal-utilities-appfw-responses-handler.c b/4a-hal-utilities/4a-hal-utilities-appfw-responses-handler.c
new file mode 100644
index 0000000..40581ef
--- /dev/null
+++ b/4a-hal-utilities/4a-hal-utilities-appfw-responses-handler.c
@@ -0,0 +1,147 @@
+/*
+ * Copyright (C) 2018 "IoT.bzh"
+ * Author Jonathan Aillet <jonathan.aillet@iot.bzh>
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#define _GNU_SOURCE
+
+#include <stdio.h>
+#include <string.h>
+
+#include "4a-hal-utilities-appfw-responses-handler.h"
+
+/*******************************************************************************
+ * Handle application framework response function *
+ ******************************************************************************/
+
+enum CallError HalUtlHandleAppFwCallError(AFB_ApiT apiHandle, char *apiCalled, char *verbCalled, json_object *callReturnJ, char **returnedStatus, char **returnedInfo)
+{
+ json_object *returnedRequestJ, *returnedStatusJ, *returnedInfoJ;
+
+ if(! apiHandle || ! apiCalled || ! verbCalled || ! callReturnJ)
+ return CALL_ERROR_INVALID_ARGS;
+
+ if(! json_object_object_get_ex(callReturnJ, "request", &returnedRequestJ)) {
+ AFB_ApiWarning(apiHandle, "Couldn't get response request object");
+ return CALL_ERROR_REQUEST_UNAVAILABLE;
+ }
+
+ if(! json_object_is_type(returnedRequestJ, json_type_object)) {
+ AFB_ApiWarning(apiHandle, "Response request object is not valid");
+ return CALL_ERROR_REQUEST_NOT_VALID;
+ }
+
+ if(! json_object_object_get_ex(returnedRequestJ, "status", &returnedStatusJ)) {
+ AFB_ApiWarning(apiHandle, "Couldn't get response status object");
+ return CALL_ERROR_REQUEST_STATUS_UNAVAILABLE;
+ }
+
+ if(! json_object_is_type(returnedStatusJ, json_type_string)) {
+ AFB_ApiWarning(apiHandle, "Response status object is not valid");
+ return CALL_ERROR_REQUEST_STATUS_NOT_VALID;
+ }
+
+ *returnedStatus = (char *) json_object_get_string(returnedStatusJ);
+
+ if(! strcmp(*returnedStatus, "unknown-api")) {
+ AFB_ApiWarning(apiHandle, "Api %s not found", apiCalled);
+ return CALL_ERROR_API_UNAVAILABLE;
+ }
+
+ if(! strcmp(*returnedStatus, "unknown-verb")) {
+ AFB_ApiWarning(apiHandle, "Verb %s of api %s not found", verbCalled, apiCalled);
+ return CALL_ERROR_VERB_UNAVAILABLE;
+ }
+
+ if(! json_object_object_get_ex(returnedRequestJ, "info", &returnedInfoJ)) {
+ AFB_ApiWarning(apiHandle, "Couldn't get response info object");
+ return CALL_ERROR_REQUEST_INFO_UNAVAILABLE;
+ }
+
+ if(! json_object_is_type(returnedInfoJ, json_type_string)) {
+ AFB_ApiWarning(apiHandle, "Response info object is not valid");
+ return CALL_ERROR_REQUEST_INFO_NOT_VALID;
+ }
+
+ *returnedInfo = (char *) json_object_get_string(returnedInfoJ);
+
+ AFB_ApiWarning(apiHandle,
+ "Api %s and verb %s found, but this error was raised : '%s' with this info : '%s'",
+ apiCalled,
+ verbCalled,
+ *returnedStatus,
+ *returnedInfo);
+
+ return CALL_ERROR_RETURNED;
+}
+
+void HalUtlHandleAppFwCallErrorInRequest(AFB_ReqT request, char *apiCalled, char *verbCalled, json_object *callReturnJ, char *errorStatusToSend)
+{
+ char *returnedStatus = NULL, *returnedInfo = NULL;
+
+ AFB_ApiT apiHandle;
+
+ if(! request || ! apiCalled || ! verbCalled || ! callReturnJ) {
+ AFB_ReqFailF(request, "invalid_args", "Invalid arguments");
+ return;
+ }
+
+ apiHandle = (AFB_ApiT) AFB_ReqGetApi(request);
+ if(! apiHandle) {
+ AFB_ReqFailF(request, "api_handle", "Can't get hal manager api handle");
+ return;
+ }
+
+ switch(HalUtlHandleAppFwCallError(apiHandle, apiCalled, verbCalled, callReturnJ, &returnedStatus, &returnedInfo)) {
+ case CALL_ERROR_REQUEST_UNAVAILABLE:
+ case CALL_ERROR_REQUEST_NOT_VALID:
+ case CALL_ERROR_REQUEST_STATUS_UNAVAILABLE:
+ case CALL_ERROR_REQUEST_STATUS_NOT_VALID:
+ case CALL_ERROR_REQUEST_INFO_UNAVAILABLE:
+ case CALL_ERROR_REQUEST_INFO_NOT_VALID:
+ AFB_ReqFail(request, errorStatusToSend, "Error with response object");
+ return;
+
+ case CALL_ERROR_API_UNAVAILABLE:
+ AFB_ReqFailF(request, errorStatusToSend, "Api %s not found", apiCalled);
+ return;
+
+ case CALL_ERROR_VERB_UNAVAILABLE:
+ AFB_ReqFailF(request, errorStatusToSend, "Verb %s of api %s not found", verbCalled, apiCalled);
+ return;
+
+ case CALL_ERROR_RETURNED:
+ AFB_ReqFailF(request,
+ errorStatusToSend,
+ "Api %s and verb %s found, but this error was raised : '%s' with this info : '%s'",
+ apiCalled,
+ verbCalled,
+ returnedStatus ? returnedStatus : "not returned",
+ returnedInfo ? returnedInfo : "not returned");
+ return;
+
+ case CALL_ERROR_INVALID_ARGS:
+ AFB_ReqFailF(request,
+ errorStatusToSend,
+ "Api %s and verb %s found, but the arguments are invalid",
+ apiCalled,
+ verbCalled);
+ return;
+
+ default:
+ AFB_ReqFailF(request, errorStatusToSend, "Unknown error happened during call to verb %s of api %s", verbCalled, apiCalled);
+ return;
+ }
+} \ No newline at end of file
diff --git a/4a-hal-utilities/4a-hal-utilities-appfw-responses-handler.h b/4a-hal-utilities/4a-hal-utilities-appfw-responses-handler.h
new file mode 100644
index 0000000..923ca6b
--- /dev/null
+++ b/4a-hal-utilities/4a-hal-utilities-appfw-responses-handler.h
@@ -0,0 +1,45 @@
+/*
+ * Copyright (C) 2018 "IoT.bzh"
+ * Author Jonathan Aillet <jonathan.aillet@iot.bzh>
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef _HAL_UTILITIES_APPFW_RESP_HANDLER_INCLUDE_
+#define _HAL_UTILITIES_APPFW_RESP_HANDLER_INCLUDE_
+
+#include <stdio.h>
+
+#include <wrap-json.h>
+
+#include <afb-definitions.h>
+
+// Enum for the type of error detected
+enum CallError {
+ CALL_ERROR_INVALID_ARGS=-1,
+ CALL_ERROR_REQUEST_UNAVAILABLE=-2,
+ CALL_ERROR_REQUEST_NOT_VALID=-3,
+ CALL_ERROR_REQUEST_STATUS_UNAVAILABLE=-4,
+ CALL_ERROR_REQUEST_STATUS_NOT_VALID=-5,
+ CALL_ERROR_API_UNAVAILABLE=-6,
+ CALL_ERROR_VERB_UNAVAILABLE=-7,
+ CALL_ERROR_REQUEST_INFO_UNAVAILABLE=-8,
+ CALL_ERROR_REQUEST_INFO_NOT_VALID=-9,
+ CALL_ERROR_RETURNED=-10,
+};
+
+// Handle application framework response function
+extern enum CallError HalUtlHandleAppFwCallError(AFB_ApiT apiHandle, char *apiCalled, char *verbCalled, json_object *callReturnJ, char **returnedStatus, char **returnedInfo);
+void HalUtlHandleAppFwCallErrorInRequest(AFB_ReqT request, char *apiCalled, char *verbCalled, json_object *callReturnJ, char *errorStatusToSend);
+
+#endif /* _HAL_UTILITIES_APPFW_RESP_HANDLER_INCLUDE_ */ \ No newline at end of file
diff --git a/4a-hal-utilities/4a-hal-utilities-data.c b/4a-hal-utilities/4a-hal-utilities-data.c
new file mode 100644
index 0000000..4bb19a8
--- /dev/null
+++ b/4a-hal-utilities/4a-hal-utilities-data.c
@@ -0,0 +1,243 @@
+/*
+ * Copyright (C) 2018 "IoT.bzh"
+ * Author Jonathan Aillet <jonathan.aillet@iot.bzh>
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#define _GNU_SOURCE
+
+#include <stdio.h>
+#include <string.h>
+
+#include <wrap-json.h>
+
+#include "4a-hal-utilities-data.h"
+#include "4a-hal-utilities-alsa-data.h"
+
+/*******************************************************************************
+ * Specfic Hal controller streams data handling functions *
+ ******************************************************************************/
+
+uint8_t HalUtlRemoveAllCtlHalStreamsData(struct CtlHalMixerDataT *ctlHalStreamsData)
+{
+ unsigned int cpt;
+
+ if(! ctlHalStreamsData)
+ return -1;
+
+ if(! ctlHalStreamsData->count)
+ return -2;
+
+ for(cpt = 0; cpt < ctlHalStreamsData->count; cpt++) {
+ free(ctlHalStreamsData->data[cpt].verb);
+ free(ctlHalStreamsData->data[cpt].verbToCall);
+ free(ctlHalStreamsData->data[cpt].streamCardId);
+ }
+
+ free(ctlHalStreamsData->data);
+
+ return 0;
+}
+
+/*******************************************************************************
+ * Specfic Hal data handling functions *
+ ******************************************************************************/
+
+struct SpecificHalData *HalUtlAddHalApiToHalList(struct SpecificHalData **firstHalData)
+{
+ struct SpecificHalData *currentApi;
+
+ if(! firstHalData)
+ return NULL;
+
+ currentApi = *firstHalData;
+
+ if(! currentApi) {
+ currentApi = (struct SpecificHalData *) calloc(1, sizeof(struct SpecificHalData));
+ if(! currentApi)
+ return NULL;
+
+ *firstHalData = currentApi;
+ }
+ else {
+ while(currentApi->next)
+ currentApi = currentApi->next;
+
+ currentApi->next = calloc(1, sizeof(struct SpecificHalData));
+ if(! currentApi)
+ return NULL;
+
+ currentApi = currentApi->next;
+ }
+
+ memset(currentApi, 0, sizeof(struct SpecificHalData));
+
+ return currentApi;
+}
+
+int8_t HalUtlRemoveSelectedHalFromList(struct SpecificHalData **firstHalData, struct SpecificHalData *apiToRemove)
+{
+ struct SpecificHalData *currentApi, *matchingApi;
+
+ if(! firstHalData || ! apiToRemove)
+ return -1;
+
+ currentApi = *firstHalData;
+
+ if(currentApi == apiToRemove) {
+ *firstHalData = currentApi->next;
+ matchingApi = currentApi;
+ }
+ else {
+ while(currentApi && currentApi->next != apiToRemove)
+ currentApi = currentApi->next;
+
+ if(currentApi) {
+ matchingApi = currentApi->next;
+ currentApi->next = currentApi->next->next;
+ }
+ else {
+ return -2;
+ }
+ }
+
+ if(! matchingApi->internal) {
+ free(matchingApi->apiName);
+ free(matchingApi->sndCardPath);
+ free(matchingApi->info);
+ free(matchingApi->author);
+ free(matchingApi->version);
+ free(matchingApi->date);
+ }
+ else {
+ HalUtlRemoveAllCtlHalStreamsData(&matchingApi->ctlHalSpecificData->ctlHalStreamsData);
+
+ HalUtlFreeAlsaCtlsMap(matchingApi->ctlHalSpecificData->ctlHalAlsaMapT);
+
+ free(matchingApi->ctlHalSpecificData);
+ }
+
+ free(matchingApi);
+
+ return 0;
+}
+
+int64_t HalUtlRemoveAllHalFromList(struct SpecificHalData **firstHalData)
+{
+ int8_t ret;
+ int64_t CtlHalApiRemoved = 0;
+
+ while(*firstHalData) {
+ ret = HalUtlRemoveSelectedHalFromList(firstHalData, *firstHalData);
+ if(ret)
+ return (int64_t) ret;
+
+ CtlHalApiRemoved++;
+ }
+
+ return CtlHalApiRemoved;
+}
+
+int64_t HalUtlGetNumberOfHalInList(struct SpecificHalData **firstHalData)
+{
+ int64_t numberOfCtlHal = 0;
+ struct SpecificHalData *currentApi;
+
+ if(! firstHalData)
+ return -1;
+
+ currentApi = *firstHalData;
+
+ while(currentApi) {
+ currentApi = currentApi->next;
+ numberOfCtlHal++;
+ }
+
+ return numberOfCtlHal;
+}
+
+struct SpecificHalData *HalUtlSearchHalDataByApiName(struct SpecificHalData **firstHalData, char *apiName)
+{
+ struct SpecificHalData *currentApi;
+
+ if(! firstHalData || ! apiName)
+ return NULL;
+
+ currentApi = *firstHalData;
+
+ while(currentApi) {
+ if(! strcmp(apiName, currentApi->apiName))
+ return currentApi;
+
+ currentApi = currentApi->next;
+ }
+
+ return NULL;
+}
+
+
+struct SpecificHalData *HalUtlSearchReadyHalDataByCarId(struct SpecificHalData **firstHalData, int cardId)
+{
+ struct SpecificHalData *currentApi;
+
+ if(! firstHalData)
+ return NULL;
+
+ currentApi = *firstHalData;
+ while(currentApi) {
+ if(currentApi->status == HAL_STATUS_READY && currentApi->sndCardId == cardId)
+ return currentApi;
+
+ currentApi = currentApi->next;
+ }
+
+ return NULL;
+}
+
+/*******************************************************************************
+ * Hal Manager data handling functions *
+ ******************************************************************************/
+
+uint8_t HalUtlInitializeHalMgrData(AFB_ApiT apiHandle, struct HalMgrData *HalMgrGlobalData, char *apiName, char *info)
+{
+ if(! apiHandle || ! HalMgrGlobalData || ! apiName || ! info)
+ return -1;
+
+ // Allocate and fill apiName and info strings
+ HalMgrGlobalData->apiName = strdup(apiName);
+ if(! HalMgrGlobalData->apiName)
+ return -2;
+
+ HalMgrGlobalData->info = strdup(info);
+ if(! HalMgrGlobalData->apiName)
+ return -3;
+
+ HalMgrGlobalData->apiHandle = apiHandle;
+
+ return 0;
+}
+
+void HalUtlRemoveHalMgrData(struct HalMgrData *HalMgrGlobalData)
+{
+ if(! HalMgrGlobalData)
+ return;
+
+ if(HalMgrGlobalData->first)
+ HalUtlRemoveAllHalFromList(&HalMgrGlobalData->first);
+
+ free(HalMgrGlobalData->apiName);
+ free(HalMgrGlobalData->info);
+
+ free(HalMgrGlobalData);
+} \ No newline at end of file
diff --git a/4a-hal-utilities/4a-hal-utilities-data.h b/4a-hal-utilities/4a-hal-utilities-data.h
new file mode 100644
index 0000000..031fa9b
--- /dev/null
+++ b/4a-hal-utilities/4a-hal-utilities-data.h
@@ -0,0 +1,108 @@
+/*
+ * Copyright (C) 2018 "IoT.bzh"
+ * Author Jonathan Aillet <jonathan.aillet@iot.bzh>
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef _HAL_UTILITIES_DATA_INCLUDE_
+#define _HAL_UTILITIES_DATA_INCLUDE_
+
+#include <stdio.h>
+
+#include <wrap-json.h>
+
+#include <afb-definitions.h>
+
+#include <ctl-config.h>
+
+#include "4a-hal-utilities-alsa-data.h"
+
+// Enum for sharing hal (controller or external) status
+enum HalStatus {
+ HAL_STATUS_UNAVAILABLE=0,
+ HAL_STATUS_AVAILABLE=1,
+ HAL_STATUS_READY=2
+};
+
+// Structure to store stream data
+struct CtlHalMixerData {
+ char *verb;
+ char *verbToCall;
+ char *streamCardId;
+ AFB_EventT event;
+};
+
+// Structure to store stream data table
+struct CtlHalMixerDataT {
+ struct CtlHalMixerData *data;
+ unsigned int count;
+};
+
+// Structure to store specific controller hal data
+struct CtlHalSpecificData {
+ char *mixerApiName;
+ char *prefix;
+ json_object *halMixerJ;
+
+ struct CtlHalMixerDataT ctlHalStreamsData;
+ struct CtlHalMixerDataT ctlHalPlaybacksData;
+ struct CtlHalMixerDataT ctlHalCapturesData;
+ struct CtlHalAlsaMapT *ctlHalAlsaMapT;
+
+ AFB_ApiT apiHandle;
+ CtlConfigT *ctrlConfig;
+};
+
+// Structure to store specific hal (controller or external) data
+struct SpecificHalData {
+ char *apiName;
+ enum HalStatus status;
+ char *sndCardPath;
+ int sndCardId;
+ char *info;
+ unsigned int internal;
+
+ char *author;
+ char *version;
+ char *date;
+ // Can be beefed up if needed
+
+ struct CtlHalSpecificData *ctlHalSpecificData; // Can be NULL if external api
+
+ struct SpecificHalData *next;
+};
+
+// Structure to store hal manager data
+struct HalMgrData {
+ char *apiName;
+ char *info;
+
+ AFB_ApiT apiHandle;
+
+ struct SpecificHalData *first;
+};
+
+// Exported verbs for 'struct SpecificHalData' handling
+struct SpecificHalData *HalUtlAddHalApiToHalList(struct SpecificHalData **firstHalData);
+int8_t HalUtlRemoveSelectedHalFromList(struct SpecificHalData **firstHalData, struct SpecificHalData *ApiToRemove);
+int64_t HalUtlRemoveAllHalFromList(struct SpecificHalData **firstHalData);
+int64_t HalUtlGetNumberOfHalInList(struct SpecificHalData **firstHalData);
+struct SpecificHalData *HalUtlSearchHalDataByApiName(struct SpecificHalData **firstHalData, char *apiName);
+struct SpecificHalData *HalUtlSearchReadyHalDataByCarId(struct SpecificHalData **firstHalData, int cardId);
+
+// Exported verbs for 'struct HalMgrData' handling
+uint8_t HalUtlInitializeHalMgrData(AFB_ApiT apiHandle, struct HalMgrData *HalMgrGlobalData, char *apiName, char *info);
+void HalUtlRemoveHalMgrData(struct HalMgrData *HalMgrGlobalData);
+
+#endif /* _HAL_UTILITIES_DATA_INCLUDE_ */ \ No newline at end of file
diff --git a/4a-hal-utilities/4a-hal-utilities-verbs-loader.c b/4a-hal-utilities/4a-hal-utilities-verbs-loader.c
new file mode 100644
index 0000000..f557f4c
--- /dev/null
+++ b/4a-hal-utilities/4a-hal-utilities-verbs-loader.c
@@ -0,0 +1,50 @@
+/*
+ * Copyright (C) 2018 "IoT.bzh"
+ * Author Jonathan Aillet <jonathan.aillet@iot.bzh>
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#define _GNU_SOURCE
+
+#include <stdio.h>
+#include <string.h>
+
+#include <afb-definitions.h>
+
+#include "4a-hal-utilities-verbs-loader.h"
+
+/*******************************************************************************
+ * Dynamic API common functions *
+ ******************************************************************************/
+
+int HalUtlLoadVerbs(AFB_ApiT apiHandle, AFB_ApiVerbs *verbs)
+{
+ int idx, errCount = 0;
+
+ if(! apiHandle || ! verbs)
+ return -1;
+
+ for (idx = 0; verbs[idx].verb; idx++) {
+ errCount+= AFB_ApiAddVerb(apiHandle,
+ verbs[idx].verb,
+ NULL,
+ verbs[idx].callback,
+ (void *) &verbs[idx],
+ verbs[idx].auth,
+ 0,
+ 0);
+ }
+
+ return errCount;
+} \ No newline at end of file
diff --git a/4a-hal-utilities/4a-hal-utilities-verbs-loader.h b/4a-hal-utilities/4a-hal-utilities-verbs-loader.h
new file mode 100644
index 0000000..2bfa1cd
--- /dev/null
+++ b/4a-hal-utilities/4a-hal-utilities-verbs-loader.h
@@ -0,0 +1,28 @@
+/*
+ * Copyright (C) 2018 "IoT.bzh"
+ * Author Jonathan Aillet <jonathan.aillet@iot.bzh>
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef _HAL_UTILITIES_VERBS_LOADER_INCLUDE_
+#define _HAL_UTILITIES_VERBS_LOADER_INCLUDE_
+
+#include <stdio.h>
+
+#include <afb-definitions.h>
+
+// Verb that allows to add verb to a dynamic api
+int HalUtlLoadVerbs(AFB_ApiT apiHandle, AFB_ApiVerbs *verbs);
+
+#endif /* _HAL_UTILITIES_VERBS_LOADER_INCLUDE_ */ \ No newline at end of file
diff --git a/4a-hal-utilities/CMakeLists.txt b/4a-hal-utilities/CMakeLists.txt
new file mode 100644
index 0000000..a45cb2c
--- /dev/null
+++ b/4a-hal-utilities/CMakeLists.txt
@@ -0,0 +1,40 @@
+###########################################################################
+# Copyright 2015, 2016, 2017, 2018, 2019 IoT.bzh
+#
+# author: Fulup Ar Foll <fulup@iot.bzh>
+# contrib: Jonathan Aillet <jonathan.aillet@iot.bzh>
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+###########################################################################
+
+# Add target to project dependency list
+PROJECT_TARGET_ADD(4a-hal-utilities)
+
+ # Define project Targets
+ ADD_LIBRARY(${TARGET_NAME} STATIC
+ 4a-hal-utilities-alsa-data.c
+ 4a-hal-utilities-appfw-responses-handler.c
+ 4a-hal-utilities-data.c
+ 4a-hal-utilities-verbs-loader.c)
+
+ # Library dependencies (include updates automatically)
+ TARGET_LINK_LIBRARIES(${TARGET_NAME}
+ afb-helpers
+ ctl-utilities
+ ${link_libraries}
+ )
+
+ # Define target includes for this target client
+ TARGET_INCLUDE_DIRECTORIES(${TARGET_NAME} PUBLIC
+ ${CMAKE_CURRENT_SOURCE_DIR}
+ )