aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorFulup Ar Foll <fulup@iot.bzh>2017-10-24 22:11:21 +0200
committerFulup Ar Foll <fulup@iot.bzh>2017-10-24 22:11:21 +0200
commit036268ddd8c62114faf9afd4da3c35ffa2b6ecba (patch)
tree72429524bb9e4be47b760915a674e6473e305026
parent2fd0fa8c77dbaaf40ba0812e43b6637ff1d1d76e (diff)
Initial working version as independent repo
-rw-r--r--.vscode/c_cpp_properties.json18
-rw-r--r--Alsa-Plugin/CMakeLists.txt23
-rw-r--r--Alsa-Plugin/_Alsa-Hal-plugin/AlsaHalPlug.h91
-rw-r--r--Alsa-Plugin/_Alsa-Hal-plugin/AlsaHalPlugCb.c66
-rw-r--r--Alsa-Plugin/_Alsa-Hal-plugin/AlsaHalPlugCtl.c423
-rw-r--r--Alsa-Plugin/_Alsa-Hal-plugin/CMakeLists.txt55
-rw-r--r--Alsa-Plugin/_Alsa-Hal-plugin/README.md44
-rw-r--r--Audio-Common/CMakeLists.txt39
-rw-r--r--Audio-Common/audio-common.c65
-rw-r--r--Audio-Common/audio-common.h115
-rw-r--r--HAL-afb/CMakeLists.txt23
-rw-r--r--HAL-afb/HAL-interface/CMakeLists.txt37
-rw-r--r--HAL-afb/HAL-interface/hal-interface.c626
-rw-r--r--HAL-afb/HAL-interface/hal-interface.h106
-rw-r--r--HAL-afb/HAL-interface/hal-volramp.c185
-rw-r--r--HAL-afb/HAL-interface/hal-volume.c150
-rw-r--r--HAL-afb/HAL_MOST_UNICENS/CMakeLists.txt46
-rw-r--r--HAL-afb/HAL_MOST_UNICENS/README.md51
-rw-r--r--HAL-afb/HAL_MOST_UNICENS/hal_most_unicens.c252
-rw-r--r--HAL-afb/HAL_MOST_UNICENS/ucs2-vol/CMakeLists.txt26
-rw-r--r--HAL-afb/HAL_MOST_UNICENS/ucs2-vol/inc/device_container.h59
-rw-r--r--HAL-afb/HAL_MOST_UNICENS/ucs2-vol/inc/device_value.h101
-rw-r--r--HAL-afb/HAL_MOST_UNICENS/ucs2-vol/inc/libmostvolume.h111
-rw-r--r--HAL-afb/HAL_MOST_UNICENS/ucs2-vol/inc/setup.h71
-rw-r--r--HAL-afb/HAL_MOST_UNICENS/ucs2-vol/src/CMakeLists.txt39
-rw-r--r--HAL-afb/HAL_MOST_UNICENS/ucs2-vol/src/device_container.cpp187
-rw-r--r--HAL-afb/HAL_MOST_UNICENS/ucs2-vol/src/device_value.cpp148
-rw-r--r--HAL-afb/HAL_MOST_UNICENS/ucs2-vol/src/libmostvolume.cpp99
-rw-r--r--HAL-afb/HAL_MOST_UNICENS/ucs2-vol/src/setup.cpp94
-rw-r--r--HAL-afb/HAL_MOST_UNICENS/wrap-json.c940
-rw-r--r--HAL-afb/HAL_MOST_UNICENS/wrap-json.h47
-rw-r--r--HAL-afb/HAL_MOST_UNICENS/wrap-json.md306
-rw-r--r--HAL-afb/HAL_MOST_UNICENS/wrap_unicens.c336
-rw-r--r--HAL-afb/HAL_MOST_UNICENS/wrap_unicens.h34
-rw-r--r--HAL-afb/HAL_MOST_UNICENS/wrap_volume.c132
-rw-r--r--HAL-afb/HAL_MOST_UNICENS/wrap_volume.h26
-rw-r--r--HAL-afb/HDA-intel/CMakeLists.txt39
-rw-r--r--HAL-afb/HDA-intel/IntelHdaHAL.c123
-rw-r--r--HAL-afb/Jabra-Solemate/CMakeLists.txt39
-rw-r--r--HAL-afb/Jabra-Solemate/JabraUsbHAL.c123
-rw-r--r--HAL-afb/Scarlett-Focusrite/CMakeLists.txt38
-rw-r--r--HAL-afb/Scarlett-Focusrite/ScarlettUsbHAL.c90
m---------afb-utilities0
-rw-r--r--alsa-binding/Alsa-AddCtl.c (renamed from Alsa-afb/Alsa-AddCtl.c)4
-rw-r--r--alsa-binding/Alsa-ApiHat.c (renamed from Alsa-afb/Alsa-ApiHat.c)5
-rw-r--r--alsa-binding/Alsa-ApiHat.h (renamed from Alsa-afb/Alsa-ApiHat.h)24
-rw-r--r--alsa-binding/Alsa-RegEvt.c (renamed from Alsa-afb/Alsa-RegEvt.c)0
-rw-r--r--alsa-binding/Alsa-SetGet.c (renamed from Alsa-afb/Alsa-SetGet.c)2
-rw-r--r--alsa-binding/Alsa-Ucm.c (renamed from Alsa-afb/Alsa-Ucm.c)0
-rw-r--r--alsa-binding/CMakeLists.txt (renamed from Alsa-afb/CMakeLists.txt)4
-rw-r--r--alsa-binding/README.md (renamed from Alsa-afb/README.md)0
m---------conf.d/app-templates0
-rwxr-xr-xconf.d/autobuild/agl/autobuild8
-rwxr-xr-xconf.d/autobuild/linux/autobuild8
-rw-r--r--conf.d/cmake/config.cmake4
-rw-r--r--hook-plugin/CMakeLists.txt (renamed from Alsa-Plugin/Alsa-Policy-Hook/CMakeLists.txt)0
-rw-r--r--hook-plugin/PolicyHookCb.c (renamed from Alsa-Plugin/Alsa-Policy-Hook/PolicyHookCb.c)58
-rw-r--r--hook-plugin/README.md (renamed from Alsa-Plugin/Alsa-Policy-Hook/README.md)13
-rw-r--r--htdocs/alsa-core.html64
-rw-r--r--htdocs/alsa-hal.html56
-rw-r--r--htdocs/audio-control.html28
-rw-r--r--htdocs/index.html70
-rw-r--r--nbproject/configurations.xml430
-rw-r--r--nbproject/project.xml4
64 files changed, 366 insertions, 6039 deletions
diff --git a/.vscode/c_cpp_properties.json b/.vscode/c_cpp_properties.json
deleted file mode 100644
index 5512cb3..0000000
--- a/.vscode/c_cpp_properties.json
+++ /dev/null
@@ -1,18 +0,0 @@
-{
- "configurations": [
- {
- "name": "null",
- "includePath": [],
- "defines": [],
- "browse": {
- "path": [
- "${workspaceRoot}"
- ],
- "limitSymbolsToIncludedHeaders": true,
- "databaseFilename": ""
- },
- "intelliSenseMode": "clang-x64"
- }
- ],
- "version": 2
-} \ No newline at end of file
diff --git a/Alsa-Plugin/CMakeLists.txt b/Alsa-Plugin/CMakeLists.txt
deleted file mode 100644
index b0c2e6a..0000000
--- a/Alsa-Plugin/CMakeLists.txt
+++ /dev/null
@@ -1,23 +0,0 @@
-###########################################################################
-# Copyright 2015, 2016, 2017 IoT.bzh
-#
-# author: Fulup Ar Foll <fulup@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.
-###########################################################################
-
-
-# Include any directory starting with a Capital letter
-# -----------------------------------------------------
-PROJECT_SUBDIRS_ADD(${PROJECT_SRC_DIR_PATTERN})
-
diff --git a/Alsa-Plugin/_Alsa-Hal-plugin/AlsaHalPlug.h b/Alsa-Plugin/_Alsa-Hal-plugin/AlsaHalPlug.h
deleted file mode 100644
index 98850bf..0000000
--- a/Alsa-Plugin/_Alsa-Hal-plugin/AlsaHalPlug.h
+++ /dev/null
@@ -1,91 +0,0 @@
-/*
- * Copyright (C) 2016 "IoT.bzh"
- * Author Fulup Ar Foll <fulup@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.
- *
- * AfbCallBack (snd_ctl_hal_t *handle, int numid, void **response);
- * AfbHalInit is mandatory and called with numid=0
- *
- * Syntaxe in .asoundrc file
- * CrlLabel { cb MyFunctionName name "My_Second_Control" }
- */
-
-
-#include <alsa/asoundlib.h>
-#include <alsa/control_external.h>
-#include <linux/soundcard.h>
-
-#ifndef SOUND_HAL_MAX_CTLS
-#define SOUND_HAL_MAX_CTLS 255
-#endif
-
-typedef enum {
- CTLCB_INIT,
- CTLCB_CLOSE,
- CTLCB_ELEM_COUNT,
- CTLCB_ELEM_LIST,
- CTLCB_FIND_ELEM,
- CTLCB_FREE_KEY,
- CTLCB_GET_ATTRIBUTE,
- CTLCB_GET_INTEGER_INFO,
- CTLCB_GET_INTEGER64_INFO,
- CTLCB_GET_ENUMERATED_INFO,
- CTLCB_GET_ENUMERATED_NAME,
- CTLCB_READ_INTEGER,
- CTLCB_READ_INTEGER64,
- CTLCB_READ_ENUMERATED,
- CTLCB_READ_BYTES,
- CTLCB_READ_IEC958,
- CTLCB_WRITE_INTEGER,
- CTLCB_WRITE_INTEGER64,
- CTLCB_WRITE_ENUMERATED,
- CTLCB_WRITE_BYTES,
- CTLCB_WRITE_IEC958,
- CTLCB_SUBSCRIBE_EVENTS,
- CTLCB_READ_EVENT,
- CTLCB_POLL_DESCRIPTORS_COUNT,
- CTLCB_POLL_DESCRIPTORS
-} snd_ctl_action_t;
-
-typedef struct {
- int ctlNumid;
- const char *ctlName;
-} snd_ctl_conf_t;
-
-typedef struct {
- int type;
- int acc;
- unsigned count;
-} snd_ctl_get_attrib_t;
-
-typedef struct {
- int imin;
- int imax;
- int istep;
-} snd_ctl_get_int_info_t;
-
-typedef int(*snd_ctl_cb_t)(void *handle, snd_ctl_action_t action, snd_ctl_ext_key_t key, void *response);
-
-typedef struct snd_ctl_hal {
- snd_ctl_ext_t ext;
- char *devid;
- snd_ctl_t *ctlDev;
- unsigned int ctlsCount;
- void *dlHandle;
- snd_ctl_conf_t ctls[SOUND_HAL_MAX_CTLS];
- snd_ctl_elem_info_t *infos[SOUND_HAL_MAX_CTLS];
- snd_ctl_cb_t cbs[SOUND_HAL_MAX_CTLS];
-} snd_ctl_hal_t;
-
-
diff --git a/Alsa-Plugin/_Alsa-Hal-plugin/AlsaHalPlugCb.c b/Alsa-Plugin/_Alsa-Hal-plugin/AlsaHalPlugCb.c
deleted file mode 100644
index 9e55f0c..0000000
--- a/Alsa-Plugin/_Alsa-Hal-plugin/AlsaHalPlugCb.c
+++ /dev/null
@@ -1,66 +0,0 @@
-/*
- * Copyright (C) 2016 "IoT.bzh"
- * Author Fulup Ar Foll <fulup@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.
- *
- * AfbCallBack (snd_ctl_hal_t *handle, int numid, void **response);
- * AfbHalInit is mandatory and called with numid=0
- *
- * Syntax in .asoundrc file
- * CrlLabel { cb MyFunctionName name "My_Second_Control" }
- *
- * Testing:
- * amixer -Dagl_hal controls
- * amixer -Dagl_hal cget name=My_Sample_Callback
- */
-
-
-#include "AlsaHalPlug.h"
-#include <stdio.h>
-
-int AfbHalInitCB(void *handle, snd_ctl_action_t action, int numid, void*response) {
- snd_ctl_hal_t *plughandle = (snd_ctl_hal_t*) handle;
-
- fprintf(stdout, "\n - CB AfbHalInit devid=%s\n", plughandle->devid);
- return 0;
-}
-
-int AfbHalSampleCB(void *handle, snd_ctl_action_t action, snd_ctl_ext_key_t key, void*response) {
-
- switch (action) {
- case CTLCB_GET_ATTRIBUTE:
- {
- fprintf(stdout, " - AfbHalSampleCB CTLCB_GET_ATTRIBUTE numid=%d\n", (int) key + 1);
- snd_ctl_get_attrib_t *item = (snd_ctl_get_attrib_t*) response;
- item->type = 1;
- item->count = 2;
- item->acc = SND_CTL_EXT_ACCESS_READWRITE;
- break;
- }
-
- case CTLCB_GET_INTEGER_INFO:
- {
- fprintf(stdout, " - AfbHalSampleCB CTLCB_GET_INTEGER_INFO numid=%d\n", (int) key + 1);
- snd_ctl_get_int_info_t *item = (snd_ctl_get_attrib_t*) response;
- item->istep = 10;
- item->imin = 20;
- item->imax = 200;
- break;
- }
-
- default:
- fprintf(stdout, "CB AfbHalSampleCB unsupported action=%d numid=%d\n", action, (int) key + 1);
- }
- return 0;
-}
diff --git a/Alsa-Plugin/_Alsa-Hal-plugin/AlsaHalPlugCtl.c b/Alsa-Plugin/_Alsa-Hal-plugin/AlsaHalPlugCtl.c
deleted file mode 100644
index 22c217b..0000000
--- a/Alsa-Plugin/_Alsa-Hal-plugin/AlsaHalPlugCtl.c
+++ /dev/null
@@ -1,423 +0,0 @@
-/*
- * Copyright (C) 2016 "IoT.bzh"
- * Author Fulup Ar Foll <fulup@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.
- *
- * Testing:
- * 1) Copy generated plugin [libasound_module_pcm_afbhal.so] in alsa-lib/ dir visible from LD_LIBRARY_PATH (eg: /usr/lib64/alsa-lib)
- * 2) Create a ~/.asounrc file base on following template
- * ctl.agl_hal {
- * type afbhal
- * devid "hw:4"
- * cblib "afbhal_cb_sample.so"
- * ctls {
- * # ctlLabel {numid integer name "Alsa Ctl Name"}
- * MasterSwitch { numid 4 name "My_First_Control" }
- * MasterVol { numid 5 name "My_Second_Control" }
- * CB_sample { ctlcb @AfbHalSampleCB name "My_Sample_Callback"}
- * }
- * pcm.agl_hal {
- * type copy # Copy PCM
- * slave "hw:4" # Slave name
- * }
- *
- * }
- * 3) Test with
- * - amixer -Dagl_hal controls # should list all your controls
- * - amixer -Dagl_hal cget numid=1
- * - amixer -Dagl_hal cset numid=1 '10,20'
- */
-
-
-#include <stdio.h>
-#include <sys/ioctl.h>
-#include "AlsaHalPlug.h"
-#include <dlfcn.h>
-
-static snd_ctl_ext_key_t AfbHalElemFind(snd_ctl_ext_t *ext, const snd_ctl_elem_id_t *id) {
- snd_ctl_hal_t *plughandle = (snd_ctl_hal_t*) ext->private_data;
- snd_ctl_ext_key_t key = NULL;
-
- int numid = snd_ctl_elem_id_get_numid(id);
- if (numid > 0) {
- if (numid > plughandle->ctlsCount) goto OnErrorExit;
- key = (snd_ctl_ext_key_t) numid - 1;
- goto SucessExit;
- }
-
- const char *ctlName = snd_ctl_elem_id_get_name(id);
- if (ctlName == NULL) goto OnErrorExit;
-
- for (int idx = 0; idx < plughandle->ctlsCount; idx++) {
- if (!strcmp(ctlName, plughandle->ctls[idx].ctlName)) {
- key = idx;
- goto SucessExit;
- }
- }
-
-SucessExit:
- return key;
-
-OnErrorExit:
- return -1;
-}
-
-static int AfbHalGetAttrib(snd_ctl_ext_t *ext, snd_ctl_ext_key_t key, int *type, unsigned int *acc, unsigned int *count) {
- snd_ctl_hal_t *plughandle = (snd_ctl_hal_t*) ext->private_data;
- snd_ctl_elem_info_t *elemInfo = plughandle->infos[key];
- snd_ctl_cb_t callback = plughandle->cbs[key];
-
-
- // search for equivalent NUMID in effective sound card
- if (elemInfo) {
- *type = snd_ctl_elem_info_get_type(elemInfo);
- *count = snd_ctl_elem_info_get_count(elemInfo);
- *acc = SND_CTL_EXT_ACCESS_READWRITE; // Future ToBeDone
- return 0;
- }
-
- if (callback) {
- snd_ctl_get_attrib_t item;
-
- int err = callback(plughandle, CTLCB_GET_ATTRIBUTE, key, &item);
- if (!err) {
- *type = item.type;
- *acc = item.acc;
- *count = item.count;
- }
- return err;
- }
-
- return -1;
-}
-
-static int AfbHalGetIntInfo(snd_ctl_ext_t *ext, snd_ctl_ext_key_t key, long *imin, long *imax, long *istep) {
- snd_ctl_hal_t *plughandle = (snd_ctl_hal_t*) ext->private_data;
- snd_ctl_elem_info_t *elemInfo = plughandle->infos[key];
- snd_ctl_cb_t callback = plughandle->cbs[key];
-
- if (elemInfo) {
-
- // Should be normalised to make everything 0-100%
- *imin = (long) snd_ctl_elem_info_get_min(elemInfo);
- *imax = (long) snd_ctl_elem_info_get_min(elemInfo);
- *istep = (long) snd_ctl_elem_info_get_min(elemInfo);
- return 0;
- }
-
- if (callback) {
- snd_ctl_get_int_info_t item;
-
- int err = callback(plughandle, CTLCB_GET_INTEGER_INFO, key, &item);
- if (!err) {
- *imin = item.imin;
- *imax = item.imax;
- *istep = item.istep;
- }
- return err;
- }
-
- return -1;
-}
-
-static int AfbHalGetEnumInfo(snd_ctl_ext_t *ext, snd_ctl_ext_key_t key, unsigned int *items) {
- snd_ctl_hal_t *plughandle = (snd_ctl_hal_t*) ext->private_data;
- snd_ctl_elem_info_t *elemInfo = plughandle->infos[key];
- snd_ctl_cb_t callback = plughandle->cbs[key];
-
- if (elemInfo) *items = snd_ctl_elem_info_get_items(elemInfo);
- if (callback) callback(plughandle, CTLCB_GET_ENUMERATED_INFO, key, items);
-
- return 0;
-}
-
-static int AfbHalGetEnumName(snd_ctl_ext_t *ext, snd_ctl_ext_key_t key, unsigned int item, char *name, size_t name_max_len) {
- snd_ctl_hal_t *plughandle = (snd_ctl_hal_t*) ext->private_data;
- snd_ctl_elem_info_t *elemInfo = plughandle->infos[key];
-
- //name= snd_ctl_elem_info_get_item_name(elemInfo);
- return 0;
-}
-
-static int AfbHalReadInt(snd_ctl_ext_t *ext, snd_ctl_ext_key_t key, long *value) {
- snd_ctl_hal_t *plughandle = (snd_ctl_hal_t*) ext->private_data;
- snd_ctl_elem_info_t *elemInfo = plughandle->infos[key];
-
- return 0;
-}
-
-static int AfbHalReadEnumerate(snd_ctl_ext_t *ext, snd_ctl_ext_key_t key, unsigned int *items) {
- snd_ctl_hal_t *plughandle = (snd_ctl_hal_t*) ext->private_data;
-
- return 0;
-}
-
-static int AfbHalWriteInt(snd_ctl_ext_t *ext, snd_ctl_ext_key_t key, long *value) {
- snd_ctl_hal_t *plughandle = (snd_ctl_hal_t*) ext->private_data;
-
- return 0;
-}
-
-static int AfbHalWriteEnum(snd_ctl_ext_t *ext, snd_ctl_ext_key_t key, unsigned int *items) {
- snd_ctl_hal_t *plughandle = (snd_ctl_hal_t*) ext->private_data;
-
- return 0;
-}
-
-static int AfbHalEventRead(snd_ctl_ext_t *ext, snd_ctl_elem_id_t *id, unsigned int *event_mask) {
- snd_ctl_hal_t *plughandle = (snd_ctl_hal_t*) ext->private_data;
-
- return -EAGAIN;
-}
-
-static int AfbHalElemList(snd_ctl_ext_t *ext, unsigned int offset, snd_ctl_elem_id_t *id) {
- snd_ctl_hal_t *plughandle = (snd_ctl_hal_t*) ext->private_data;
-
- snd_ctl_elem_id_set_interface(id, SND_CTL_ELEM_IFACE_MIXER);
- snd_ctl_elem_id_set_name(id, plughandle->ctls[offset].ctlName);
-
- return 0;
-}
-
-static int AfbHalElemCount(snd_ctl_ext_t *ext) {
- snd_ctl_hal_t *plughandle = (snd_ctl_hal_t*) ext->private_data;
- int count = plughandle->ctlsCount;
- return count;
-}
-
-static void AfbHalClose(snd_ctl_ext_t *ext) {
- snd_ctl_hal_t *plughandle = (snd_ctl_hal_t*) ext->private_data;
- int err;
-
- for (int idx = 0; idx < plughandle->ctlsCount; idx++) {
- if (plughandle->ctls[idx].ctlName) free((void*) plughandle->ctls[idx].ctlName);
- }
-
- err = snd_ctl_close(plughandle->ctlDev);
- if (err) SNDERR("Fail Close sndctl: devid=%s err=%s", plughandle->devid, snd_strerror(err));
-
- if (plughandle->devid) free(plughandle->devid);
- free(plughandle);
-}
-
-static snd_ctl_ext_callback_t afbHalCBs = {
- .close = AfbHalClose,
- .elem_count = AfbHalElemCount,
- .elem_list = AfbHalElemList,
- .find_elem = AfbHalElemFind,
- .get_attribute = AfbHalGetAttrib,
- .get_integer_info = AfbHalGetIntInfo,
- .get_enumerated_info = AfbHalGetEnumInfo,
- .get_enumerated_name = AfbHalGetEnumName,
- .read_integer = AfbHalReadInt,
- .read_enumerated = AfbHalReadEnumerate,
- .write_integer = AfbHalWriteInt,
- .write_enumerated = AfbHalWriteEnum,
- .read_event = AfbHalEventRead,
-};
-
-SND_CTL_PLUGIN_DEFINE_FUNC(afbhal) {
-
- snd_config_iterator_t it, next;
- snd_ctl_hal_t *plughandle;
- int err;
- snd_ctl_cb_t AfbHalInitCB;
- const char *libname;
-
- plughandle = calloc(1, sizeof (snd_ctl_hal_t));
-
- snd_config_for_each(it, next, conf) {
- snd_config_t *node = snd_config_iterator_entry(it);
- const char *id;
-
- // ignore comment en empty lines
- if (snd_config_get_id(node, &id) < 0) continue;
- if (strcmp(id, "comment") == 0 || strcmp(id, "type") == 0 || strcmp(id, "hint") == 0) continue;
-
- // devid should point onto a valid sound card
- if (strcmp(id, "devid") == 0) {
- const char *devid;
- if (snd_config_get_string(node, &devid) < 0) {
- SNDERR("Invalid string type for %s", id);
- return -EINVAL;
- }
- plughandle->devid = strdup(devid);
-
- // open control interface for devid
- err = snd_ctl_open(&plughandle->ctlDev, plughandle->devid, 0);
- if (err < 0) {
- SNDERR("Fail to open control device for devid=%s", plughandle->devid);
- return -EINVAL;
- }
- continue;
- }
-
- if (strcmp(id, "cblib") == 0) {
- if (snd_config_get_string(node, &libname) < 0) {
- SNDERR("Invalid libname string for %s", id);
- return -EINVAL;
- }
-
- plughandle->dlHandle = dlopen(libname, RTLD_NOW);
- if (!plughandle->dlHandle) {
- SNDERR("Fail to open callback sharelib=%s error=%s", libname, dlerror());
- return -EINVAL;
- }
-
- AfbHalInitCB = dlsym(plughandle->dlHandle, "AfbHalInitCB");
- if (!AfbHalInitCB) {
- SNDERR("Fail find 'AfbHalInitCB' symbol into callbacks sharelib=%s", libname);
- return -EINVAL;
- }
-
- err = (*AfbHalInitCB)(plughandle, CTLCB_INIT, 0, 0);
- if (err) {
- SNDERR("Fail AfbHalInitCB err=%d", err);
- return -EINVAL;
- }
-
- continue;
- }
-
- if (strcmp(id, "ctl") == 0) {
- const char *ctlConf;
- snd_config_type_t ctype;
- snd_config_iterator_t currentCtl, follow;
- snd_config_t *itemConf;
-
- ctype = snd_config_get_type(node);
- if (ctype != SND_CONFIG_TYPE_COMPOUND) {
- snd_config_get_string(node, &ctlConf);
- SNDERR("Invalid compound type for %s", node);
- return -EINVAL;
- }
-
- // loop on each ctl within ctls
-
- snd_config_for_each(currentCtl, follow, node) {
- snd_config_t *ctlconfig = snd_config_iterator_entry(currentCtl);
- snd_ctl_elem_info_t *elemInfo;
- const char *ctlLabel, *ctlName;
-
- // ignore empty line
- if (snd_config_get_id(ctlconfig, &ctlLabel) < 0) continue;
-
- // each clt should be a valid config compound
- ctype = snd_config_get_type(ctlconfig);
- if (ctype != SND_CONFIG_TYPE_COMPOUND) {
- snd_config_get_string(node, &ctlConf);
- SNDERR("Invalid ctl config for %s", ctlLabel);
- return -EINVAL;
- }
-
- err = snd_config_search(ctlconfig, "ctl", &itemConf);
- if (!err) {
- if (snd_config_get_integer(itemConf, (long*) &plughandle->ctls[plughandle->ctlsCount].ctlNumid) < 0) {
- SNDERR("Not Integer: ctl:%s numid should be a valid integer", ctlLabel);
- return -EINVAL;
- }
-
- // Make sure than numid is valid on slave snd card
- snd_ctl_elem_info_malloc(&elemInfo);
- snd_ctl_elem_info_set_numid(elemInfo, (int) plughandle->ctls[plughandle->ctlsCount].ctlNumid);
- plughandle->infos[plughandle->ctlsCount] = elemInfo;
-
- err = snd_ctl_elem_info(plughandle->ctlDev, elemInfo);
- if (err) {
- SNDERR("Not Found: 'numid=%d' for 'devid=%s'", plughandle->ctls[plughandle->ctlsCount].ctlNumid, plughandle->devid);
- return -EINVAL;
- }
- }
-
- err = snd_config_search(ctlconfig, "ctlcb", &itemConf);
- if (!err) {
- const char *funcname;
- void *funcaddr;
-
- if (snd_config_get_string(itemConf, &funcname) < 0) {
- SNDERR("Not string: ctl:%s cbname should be a valid string", ctlLabel);
- return -EINVAL;
- }
-
- if (funcname[0] != '@') {
- SNDERR("Not string: ctl:%s cbname=%s should be prefixed with '@' ", ctlLabel, funcname);
- return -EINVAL;
- }
-
- if (!plughandle->dlHandle) {
- SNDERR("No CB: ctl:%s cblib:/my/libcallback missing from asoundrc", ctlLabel);
- return -EINVAL;
- }
-
- funcaddr = dlsym(plughandle->dlHandle, &funcname[1]);
- if (!funcaddr) {
- SNDERR("NotFound CB: ctl:%s cbname='%s' no symbol into %s", ctlLabel, &funcname[1], libname);
- return -EINVAL;
- }
- plughandle->cbs[plughandle->ctlsCount] = funcaddr;
- }
-
- err = snd_config_search(ctlconfig, "name", &itemConf);
- if (err) {
- SNDERR("Not Found: 'name' mandatory in ctl config");
- return -EINVAL;
- }
-
- if (snd_config_get_string(itemConf, &ctlName) < 0) {
- SNDERR("Not String: ctl:%s 'name' should be a valie string", ctlLabel);
- return -EINVAL;
- }
- plughandle->ctls[plughandle->ctlsCount].ctlName = strdup(ctlName);
-
- // move to next ctl if any
- plughandle->ctlsCount++;
- } // end for each ctl
- continue;
- }
- SNDERR("Unknown field %s", id);
- return -EINVAL;
- }
-
-
-
- // Create ALSA control plugin structure
- plughandle->ext.version = SND_CTL_EXT_VERSION;
- plughandle->ext.card_idx = 0; /* FIXME */
- strcpy(plughandle->ext.id, "AFB-HAL-CTL");
- strcpy(plughandle->ext.driver, "AFB-HAL");
- strcpy(plughandle->ext.name, "AFB-HAL Control Plugin");
- strcpy(plughandle->ext.mixername, "AFB-HAL Mixer Plugin");
- strcpy(plughandle->ext.longname, "Automotive-Linux Sound Abstraction Control Plugin");
- plughandle->ext.poll_fd = -1;
- plughandle->ext.callback = &afbHalCBs;
- plughandle->ext.private_data = (void*) plughandle;
-
-
-
- err = snd_ctl_ext_create(&plughandle->ext, name, mode);
- if (err < 0) {
- SNDERR("Fail Register sndctl for devid=%s", plughandle->devid);
- goto OnErrorExit;
- }
-
- // Plugin register controls update handlep before exiting
- *handlep = plughandle->ext.handle;
- return 0;
-
-OnErrorExit:
- free(plughandle);
- return -1;
-}
-
-SND_CTL_PLUGIN_SYMBOL(afbhal);
diff --git a/Alsa-Plugin/_Alsa-Hal-plugin/CMakeLists.txt b/Alsa-Plugin/_Alsa-Hal-plugin/CMakeLists.txt
deleted file mode 100644
index 90ee5a3..0000000
--- a/Alsa-Plugin/_Alsa-Hal-plugin/CMakeLists.txt
+++ /dev/null
@@ -1,55 +0,0 @@
-###########################################################################
-# Copyright 2015, 2016, 2017 IoT.bzh
-#
-# author: Fulup Ar Foll <fulup@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.
-###########################################################################
-
-# Activate ALSA dynamic build build mode get resolve "snd_dlsym_start"
-add_compile_options(-DPIC)
-
-# Add target to project dependency list
-PROJECT_TARGET_ADD(ctl_afbhal)
-
- # Define targets
- ADD_LIBRARY(${TARGET_NAME} MODULE HalPlugCtl.c)
-
- # Alsa Plugin properties
- SET_TARGET_PROPERTIES(${TARGET_NAME} PROPERTIES
- PREFIX "libasound_module_"
- OUTPUT_NAME ${TARGET_NAME}
- )
-
- # Library dependencies (include updates automatically)
- TARGET_LINK_LIBRARIES(${TARGET_NAME}
- ${link_libraries}
- )
- install(TARGETS ${TARGET_NAME} LIBRARY DESTINATION lib/alsa-lib)
-
-PROJECT_TARGET_ADD(cb_sample)
-
- # Define targets
- ADD_LIBRARY(${TARGET_NAME} MODULE HalPlugCb.c)
-
- # Alsa Plugin properties
- SET_TARGET_PROPERTIES(${TARGET_NAME} PROPERTIES
- PREFIX "afbhal_"
- OUTPUT_NAME ${TARGET_NAME}
- )
-
- # Library dependencies (include updates automatically)
- TARGET_LINK_LIBRARIES(${TARGET_NAME}
- ${link_libraries}
- )
- install(TARGETS ${TARGET_NAME} LIBRARY DESTINATION lib)
diff --git a/Alsa-Plugin/_Alsa-Hal-plugin/README.md b/Alsa-Plugin/_Alsa-Hal-plugin/README.md
deleted file mode 100644
index a6fc90d..0000000
--- a/Alsa-Plugin/_Alsa-Hal-plugin/README.md
+++ /dev/null
@@ -1,44 +0,0 @@
-Hal-Plugin
-
-Object: Add virtual soft control to sound card
-Status: Proof of concept and not a usable product
-Author: Fulup Ar Foll
-Date : June-2017
-
-HAL-plugin allows:
- - to expose any existing NUMID under a customized label name, this is order to abstract sound card config.
- - to add non alsa NUMID supported through a callback mechanism (eg: volume rampdown, power off, ...)
-
-installation
- - Plugin should be placed where ever alsaplugins are located (typically: /usr/share/alsa-lib)
- - Callback sharelib directory should be declare in $LD_LIBRARY_PATH
-
-Config
-```
-cat ~/.asoundrc
- ctl.agl_hal {
- type afbhal
- devid "hw:4"
- cblib "afbhal_cb_sample.so"
- ctls {
- # ctlLabel {numid integer name "Alsa Ctl Name"}
- MasterSwitch { numid 4 name "My_First_Control" }
- MasterVol { numid 5 name "My_Second_Control" }
- CB_sample { ctlcb @AfbHalSampleCB name "My_Sample_Callback"}
- }
- pcm.agl_hal {
- type copy # Copy PCM
- slave "hw:4" # Slave name
- }
-```
-
-With such a config file
- - numid=4 from sndcard=hw:4 is renamed "My_First_Control"
- - numid=4 from sndcard=hw:4 is renamed "My_Second_Control"
- - numid=4 will call AfbHalSampleCB from afbhal_cb_sample.so
-
-Note: to really implement a usable HAL at minimum every ALSA call should be implemented and read/write of values should be normalised from 0 to 100% with a step of 1.
-
-Conclusion: This demonstrate that implementing a HAL that both abstract ALSA get/set and enable non ALSA support is possible at an acceptable cost
-without having to hack ALSA source code. The beauty of the model is than it is fully transparent to any ALSA application. The limit is that the plugin is loaded
-within every application context, thus interaction with an external event loop remains complete as well as conflict management in case of share resources.
diff --git a/Audio-Common/CMakeLists.txt b/Audio-Common/CMakeLists.txt
deleted file mode 100644
index 72e0df7..0000000
--- a/Audio-Common/CMakeLists.txt
+++ /dev/null
@@ -1,39 +0,0 @@
-###########################################################################
-# Copyright 2015, 2016, 2017 IoT.bzh
-#
-# author: Fulup Ar Foll <fulup@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(audio-common)
-
- # Define targets
- ADD_LIBRARY(${TARGET_NAME} STATIC audio-common.c)
-
- # Library properties
- SET_TARGET_PROPERTIES(${TARGET_NAME} PROPERTIES
- OUTPUT_NAME ${TARGET_NAME}
- )
-
- # Library dependencies
- TARGET_LINK_LIBRARIES(${TARGET_NAME}
- afb-utilities
- ${link_libraries}
- )
-
- # Define target includes
- TARGET_INCLUDE_DIRECTORIES(${TARGET_NAME}
- PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}
-)
diff --git a/Audio-Common/audio-common.c b/Audio-Common/audio-common.c
deleted file mode 100644
index 25629b5..0000000
--- a/Audio-Common/audio-common.c
+++ /dev/null
@@ -1,65 +0,0 @@
-/*
- * Copyright (C) 2016 "IoT.bzh"
- * Author Fulup Ar Foll <fulup@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 // needed for vasprintf
-#include "audio-common.h"
-
-PUBLIC const char *halCtlsLabels[] = {
-
- [Master_Playback_Volume] = "Master_Playback_Volume",
- [Master_OnOff_Switch] = "Master_OnOff_Switch",
- [Master_Playback_Ramp]= "Master_Playback_Ramp",
- [PCM_Playback_Volume] = "PCM_Playback_Volume",
- [PCM_Playback_Switch] = "PCM_Playback_Switch",
- [Capture_Volume] = "Capture_Volume",
-
- [Vol_Ramp_Set_Mode] = "Volume_Ramp_Mode",
- [Vol_Ramp_Set_Delay] = "Volume_Ramp_Delay",
- [Vol_Ramp_Set_Down] = "Volume_Ramp_Down",
- [Vol_Ramp_Set_Up] = "Volume_Ramp_Up",
- [Vol_Ramp_Set_Slave] = "Volume_Ramp_Slave",
-
- // Application Virtual Channels
- [Multimedia_Playback_Volume] = "Multimedia_Playback_Volume",
- [Navigation_Playback_Volume] = "Navigation_Playback_Volume",
- [Emergency_Playback_Volume] = "Emergency_Playback_Volume",
- [Telephony_Playback_Volume] = "Telephony_Playback_Volume",
-
- [Multimedia_Playback_Switch] = "Multimedia_Playback_Switch",
- [Navigation_Playback_Switch] = "Navigation_Playback_Switch",
- [Emergency_Playback_Switch] = "Emergency_Playback_Switch",
- [Telephony_Playback_Switch] = "Telephony_Playback_Switch",
-
- // Do not remove EndHalCrlTag
- [EndHalCrlTag] = NULL
-};
-
-PUBLIC const char *halVolRampModes[] = {
-
- [RAMP_VOL_NONE] = "None",
- [RAMP_VOL_NORMAL] = "Normal",
- [RAMP_VOL_SMOOTH] = "Smooth",
- [RAMP_VOL_EMERGENCY] = "Emergency",
-
- [EndHalVolMod] = NULL,
-
-};
-
-PUBLIC void pingtest(struct afb_req request) {
- json_object *query = afb_req_json(request);
- afb_req_success(request, query, NULL);
-}
diff --git a/Audio-Common/audio-common.h b/Audio-Common/audio-common.h
deleted file mode 100644
index 7077eab..0000000
--- a/Audio-Common/audio-common.h
+++ /dev/null
@@ -1,115 +0,0 @@
-/*
- * Copyright (C) 2016 "IoT.bzh"
- * Author Fulup Ar Foll <fulup@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.
- *
- * reference:
- * amixer contents; amixer controls;
- * http://www.tldp.org/HOWTO/Alsa-sound-6.html
- */
-
-#ifndef AUDIO_INTERF_H
-#define AUDIO_INTERF_H
-
-#define AFB_BINDING_VERSION 2
-#include <afb/afb-binding.h>
-#include <json-c/json.h>
-#include <filescan-utils.h>
-#include <wrap-json.h>
-
-// Waiting for official macro from José
-#define AFB_GET_VERBOSITY afb_get_verbosity_v2()
-
-#ifndef PUBLIC
- #define PUBLIC
-#endif
-#define STATIC static
-
-
-// Soft control have dynamically allocated numid
-#define CTL_AUTO -1
-
-typedef enum {
- QUERY_QUIET =0,
- QUERY_COMPACT =1,
- QUERY_VERBOSE =2,
- QUERY_FULL =3,
-} halQueryMode;
-
-// Most controls are MIXER but some vendor specific are possible
-typedef enum {
- OUTVOL,
- PCMVOL,
- INVOL,
- SWITCH,
- ROUTE,
- CARD,
- ENUM,
-} halGroupEnumT;
-
-typedef enum {
- READ,
- WRITE,
- RW,
-} halAclEnumT;
-
-typedef enum {
- StartHalCrlTag=0,
-
- // volume RAMP
- Vol_Ramp_Set_Mode,
- Vol_Ramp_Set_Delay,
- Vol_Ramp_Set_Down,
- Vol_Ramp_Set_Up,
- Vol_Ramp_Set_Slave,
-
- // HighLevel Audio Control List,
- Master_Playback_Volume,
- Master_Playback_Ramp,
- PCM_Playback_Volume,
- PCM_Playback_Switch,
- Capture_Volume,
- Master_OnOff_Switch,
- Telephony_Playback_Volume,
- Multimedia_Playback_Switch,
- Navigation_Playback_Switch,
- Emergency_Playback_Switch,
- Telephony_Playback_Switch,
-
-
- // Application Virtual Channels
- Multimedia_Playback_Volume,
- Navigation_Playback_Volume,
- Emergency_Playback_Volume,
-
- EndHalCrlTag // used to compute number of ctls
-} halCtlsTagT;
-
-
-typedef enum {
- RAMP_VOL_NONE = 0,
- RAMP_VOL_NORMAL = 1,
- RAMP_VOL_SMOOTH = 2,
- RAMP_VOL_EMERGENCY = 3,
-
- EndHalVolMod
-
-} halRampEnumT;
-
-PUBLIC void pingtest(struct afb_req request);
-extern const char *halVolRampModes[];
-extern const char *halCtlsLabels[];
-
-#endif /* AUDIO_INTERF_H */
-
diff --git a/HAL-afb/CMakeLists.txt b/HAL-afb/CMakeLists.txt
deleted file mode 100644
index 201d407..0000000
--- a/HAL-afb/CMakeLists.txt
+++ /dev/null
@@ -1,23 +0,0 @@
-###########################################################################
-# Copyright 2015, 2016, 2017 IoT.bzh
-#
-# author: Fulup Ar Foll <fulup@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.
-###########################################################################
-
-
-# Include any directory not starting with _
-# -----------------------------------------------------
-PROJECT_SUBDIRS_ADD(${PROJECT_SRC_DIR_PATTERN})
-
diff --git a/HAL-afb/HAL-interface/CMakeLists.txt b/HAL-afb/HAL-interface/CMakeLists.txt
deleted file mode 100644
index bbe2e94..0000000
--- a/HAL-afb/HAL-interface/CMakeLists.txt
+++ /dev/null
@@ -1,37 +0,0 @@
-###########################################################################
-# Copyright 2015, 2016, 2017 IoT.bzh
-#
-# author: Fulup Ar Foll <fulup@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(hal-interface)
-
- # Define targets
- ADD_LIBRARY(${TARGET_NAME} STATIC hal-volume.c hal-volramp.c hal-interface.c)
-
- # Library properties
- SET_TARGET_PROPERTIES(${TARGET_NAME} PROPERTIES OUTPUT_NAME halinterface)
-
- # Library dependencies (include updates automatically)
- TARGET_LINK_LIBRARIES(${TARGET_NAME}
- audio-common
- )
-
- # Define target includes
- TARGET_INCLUDE_DIRECTORIES(${TARGET_NAME}
- PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}
- )
diff --git a/HAL-afb/HAL-interface/hal-interface.c b/HAL-afb/HAL-interface/hal-interface.c
deleted file mode 100644
index 4a32d72..0000000
--- a/HAL-afb/HAL-interface/hal-interface.c
+++ /dev/null
@@ -1,626 +0,0 @@
-/*
- * Copyright (C) 2016 "IoT.bzh"
- * Author Fulup Ar Foll <fulup@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.
- *
- * reference:
- * amixer contents; amixer controls;
- * http://www.tldp.org/HOWTO/Alsa-sound-6.html
- */
-#define _GNU_SOURCE // needed for vasprintf
-#include <string.h>
-#include "hal-interface.h"
-#include <systemd/sd-event.h>
-
-alsaHalSndCardT *halSndCard;
-
-
-// Force specific HAL to depend on ShareHalLib
-PUBLIC char* SharedHalLibVersion = "1.0";
-
-// Subscribe to AudioBinding events
-
-STATIC void halSubscribe(afb_req request) {
- const char *devidJ = afb_req_value(request, "devid");
- if (devidJ == NULL) {
- afb_req_fail_f(request, "devidJ-missing", "devidJ=hw:xxx missing");
- }
-}
-
-// Map HAL ctlName to ctlLabel
-
-STATIC int halCtlStringToIndex(const char* label) {
- alsaHalMapT *halCtls = halSndCard->ctls;
-
- for (int idx = 0; halCtls[idx].tag != EndHalCrlTag; idx++) {
- if (halCtls[idx].label && !strcasecmp(halCtls[idx].label, label)) return idx;
- }
-
- // not found
- return -1;
-}
-
-STATIC int halCtlTagToIndex(halCtlsTagT tag) {
- alsaHalMapT *halCtls = halSndCard->ctls;
-
- for (int idx = 0; halCtls[idx].tag != EndHalCrlTag; idx++) {
- if (halCtls[idx].tag == tag) return idx;
- }
-
- // not found
- return -1;
-}
-
-
-// Return ALL HAL snd controls
-
-PUBLIC void halListCtls(afb_req request) {
- alsaHalMapT *halCtls = halSndCard->ctls;
- json_object *ctlsHalJ = json_object_new_array();
-
- for (int idx = 0; halCtls[idx].ctl.numid; idx++) {
- json_object *ctlHalJ = json_object_new_object();
-
- if (halCtls[idx].label) json_object_object_add(ctlHalJ, "label", json_object_new_string(halCtls[idx].label));
- else json_object_object_add(ctlHalJ, "label", json_object_new_string("HAL Label Not Set "));
- json_object_object_add(ctlHalJ, "tag", json_object_new_int(halCtls[idx].tag));
- json_object_object_add(ctlHalJ, "count", json_object_new_int(halCtls[idx].ctl.count));
-
- json_object_array_add(ctlsHalJ, ctlHalJ);
- }
-
- afb_req_success(request, ctlsHalJ, NULL);
-}
-
-STATIC int halGetCtlIndex(afb_req request, json_object*ctlInJ) {
- json_object *tmpJ;
- int tag, index, done;
-
- // check 1st short command mode [tag1, tag2, ...]
- enum json_type jtype = json_object_get_type(ctlInJ);
- switch (jtype) {
- case json_type_array:
- tmpJ = json_object_array_get_idx(ctlInJ, 0);
- tag = json_object_get_int(tmpJ);
- index = halCtlTagToIndex(tag);
- break;
-
- case json_type_int:
- tag = json_object_get_int(ctlInJ);
- index = halCtlTagToIndex(tag);
- break;
-
- case json_type_object:
- done = json_object_object_get_ex(ctlInJ, "tag", &tmpJ);
- if (done) {
- tag = json_object_get_int(tmpJ);
- index = halCtlTagToIndex(tag);
- } else {
- const char *label;
- done = json_object_object_get_ex(ctlInJ, "label", &tmpJ);
- if (!done) goto OnErrorExit;
- label = json_object_get_string(tmpJ);
- index = halCtlStringToIndex(label);
- }
- break;
-
- default:
- goto OnErrorExit;
- }
-
- if (index < 0) goto OnErrorExit;
-
- // return corresponding lowlevel numid to querylist
- return index;
-
-OnErrorExit:
- afb_req_fail_f(request, "ctl-invalid", "No Label/Tag given ctl='%s'", json_object_get_string(ctlInJ));
- return -1;
-}
-
-STATIC int halCallAlsaSetCtls(json_object *ctlsOutJ) {
- json_object *responseJ, *queryJ;
- int err;
-
- // Call now level CTL
- queryJ = json_object_new_object();
- json_object_object_add(queryJ, "devid", json_object_new_string(halSndCard->devid));
- json_object_object_add(queryJ, "ctl", ctlsOutJ);
-
- err = afb_service_call_sync("alsacore", "ctlset", queryJ, &responseJ);
- json_object_put(responseJ); // let's ignore response
-
- return err;
-}
-
-
-// retrieve a single HAL control from its tag.
-
-PUBLIC int halSetCtlByTag(halRampEnumT tag, int value) {
- json_object *ctlJ = json_object_new_array();
- alsaHalMapT *halCtls = halSndCard->ctls;
- int err, index;
-
- index = halCtlTagToIndex(tag);
- if (index < 0) goto OnErrorExit;
-
- json_object_array_add(ctlJ, json_object_new_int(halCtls[index].ctl.numid));
- json_object_array_add(ctlJ, volumeNormalise(ACTION_SET, &halCtls[index].ctl, json_object_new_int(value)));
-
- err = halCallAlsaSetCtls(ctlJ);
-
- return err;
-
-OnErrorExit:
- return -1;
-}
-
-
-// Translate high level control to low level and call lower layer
-
-PUBLIC void halSetCtls(afb_req request) {
- alsaHalMapT *halCtls = halSndCard->ctls;
- int err, done, index;
- json_object *ctlsInJ, *ctlsOutJ, *valuesJ;
-
- // get query from request
- ctlsInJ = afb_req_json(request);
-
- switch (json_object_get_type(ctlsInJ)) {
- case json_type_object:
- {
- ctlsOutJ = json_object_new_object();
-
- // control is in literal form {tag=xxx, label=xxx, value=xxxx}
- index = halGetCtlIndex(request, ctlsInJ);
- if (index < 0) goto OnErrorExit;
-
- done = json_object_object_get_ex(ctlsInJ, "val", &valuesJ);
- if (!done) {
- afb_req_fail_f(request, "ctl-invalid", "No val=[val1, ...] ctl='%s'", json_object_get_string(ctlsInJ));
- goto OnErrorExit;
- }
-
- json_object_object_add(ctlsOutJ, "id", json_object_new_int(halCtls[index].ctl.numid));
- json_object_object_add(ctlsOutJ, "val", volumeNormalise(ACTION_SET, &halCtls[index].ctl, valuesJ));
- break;
- }
-
- case json_type_array:
- {
- ctlsOutJ = json_object_new_array();
-
- for (int idx = 0; idx < json_object_array_length(ctlsInJ); idx++) {
- json_object *ctlInJ = json_object_array_get_idx(ctlsInJ, idx);
- index = halGetCtlIndex(request, ctlInJ);
- if (index < 0) goto OnErrorExit;
-
- done = json_object_object_get_ex(ctlInJ, "val", &valuesJ);
- if (!done) {
- afb_req_fail_f(request, "ctl-invalid", "No val=[val1, ...] ctl='%s'", json_object_get_string(ctlsInJ));
- goto OnErrorExit;
- }
- // let's create alsa low level set control request
- json_object *ctlOutJ = json_object_new_object();
- json_object_object_add(ctlOutJ, "id", json_object_new_int(halCtls[index].ctl.numid));
- json_object_object_add(ctlOutJ, "val", volumeNormalise(ACTION_SET, &halCtls[index].ctl, valuesJ));
-
- json_object_array_add(ctlsOutJ, ctlOutJ);
- }
- break;
- }
-
- default:
- afb_req_fail_f(request, "ctl-invalid", "Not a valid JSON ctl='%s'", json_object_get_string(ctlsInJ));
- goto OnErrorExit;
- }
-
- err = halCallAlsaSetCtls(ctlsOutJ);
- if (err) {
- afb_req_fail_f(request, "subcall:alsacore/setctl", "%s", json_object_get_string(ctlsOutJ));
- goto OnErrorExit;
- }
-
- afb_req_success(request, NULL, NULL);
- return;
-
-OnErrorExit:
- return;
-};
-
-// Remap low level controls into HAL hight level ones
-
-STATIC json_object *HalGetPrepareResponse(afb_req request, json_object *ctlsJ) {
- alsaHalMapT *halCtls = halSndCard->ctls;
- json_object *halResponseJ;
- int length;
-
- switch (json_object_get_type(ctlsJ)) {
- case json_type_array:
- // responseJ is a JSON array
- halResponseJ = json_object_new_array();
- length = json_object_array_length(ctlsJ);
- break;
- case json_type_object:
- halResponseJ = NULL;
- length = 1;
- break;
- default:
- afb_req_fail_f(request, "ctls-notarray", "Invalid Controls return from alsa/getcontrol ctlsJ=%s", json_object_get_string(ctlsJ));
- goto OnErrorExit;
- }
-
- // loop on array and store values into client context
- for (int idx = 0; idx < length; idx++) {
- json_object *sndCtlJ, *valJ, *numidJ;
- int numid;
-
- // extract control from array if any
- if (halResponseJ) sndCtlJ = json_object_array_get_idx(ctlsJ, idx);
- else sndCtlJ = ctlsJ;
-
- if (!json_object_object_get_ex(sndCtlJ, "id", &numidJ) || !json_object_object_get_ex(sndCtlJ, "val", &valJ)) {
- afb_req_fail_f(request, "ctl-invalid", "Invalid Control return from alsa/getcontrol ctl=%s", json_object_get_string(sndCtlJ));
- goto OnErrorExit;
- }
-
- // HAL and Business logic use the same AlsaMixerHal.h direct conversion
- numid = (halCtlsTagT) json_object_get_int(numidJ);
-
- for (int idx = 0; halCtls[idx].ctl.numid; idx++) {
- if (halCtls[idx].ctl.numid == numid) {
- // translate low level numid to HAL one and normalise values
- json_object *halCtlJ = json_object_new_object();
- json_object_object_add(halCtlJ, "label", json_object_new_string(halCtls[idx].label)); // idx+1 == HAL/NUMID
- json_object_object_add(halCtlJ, "tag", json_object_new_int(halCtls[idx].tag)); // idx+1 == HAL/NUMID
- json_object_object_add(halCtlJ, "val", volumeNormalise(ACTION_GET, &halCtls[idx].ctl, valJ));
-
- if (halResponseJ) json_object_array_add(halResponseJ, halCtlJ);
- else halResponseJ = halCtlJ;
-
- break;
- }
- }
- if (halCtls[idx].ctl.numid == 0) {
- afb_req_fail_f(request, "ctl-invalid", "Invalid Control numid=%d from alsa/getcontrol ctlJ=%s", numid, json_object_get_string(sndCtlJ));
- goto OnErrorExit;
- }
- }
- return halResponseJ;
-
-OnErrorExit:
- return NULL;
-}
-
-STATIC json_object *halCallAlsaGetCtls(json_object *ctlsOutJ) {
- json_object *responseJ, *queryJ;
- int err, done;
-
- // Call now level CTL
- queryJ = json_object_new_object();
- json_object_object_add(queryJ, "devid", json_object_new_string(halSndCard->devid));
- json_object_object_add(queryJ, "ctl", ctlsOutJ);
-
- err = afb_service_call_sync("alsacore", "ctlget", queryJ, &responseJ);
- if (err) goto OnErrorExit;
-
- // Let ignore info data if any and keep on response
- done = json_object_object_get_ex(responseJ, "response", &responseJ);
- if (!done) goto OnErrorExit;
-
- return responseJ;
-
-OnErrorExit:
- return NULL;
-}
-
-// retrieve a single HAL control from its tag.
-
-PUBLIC json_object *halGetCtlByTag(halRampEnumT tag) {
- json_object *responseJ, *valJ;
- alsaHalMapT *halCtls = halSndCard->ctls;
- int done, index;
-
- index = halCtlTagToIndex(tag);
- if (index < 0) goto OnErrorExit;
- responseJ = halCallAlsaGetCtls(json_object_new_int(halCtls[index].ctl.numid));
-
- done = json_object_object_get_ex(responseJ, "val", &valJ);
- if (!done) goto OnErrorExit;
-
- return volumeNormalise(ACTION_GET, &halCtls[index].ctl, valJ);
-
-OnErrorExit:
- return NULL;
-}
-
-
-// Translate high level control to low level and call lower layer
-
-PUBLIC void halGetCtls(afb_req request) {
- int index;
- alsaHalMapT *halCtls = halSndCard->ctls;
- json_object *ctlsInJ, *ctlsOutJ, *responseJ;
-
- // get query from request
- ctlsInJ = afb_req_json(request);
- ctlsOutJ = json_object_new_array();
-
- switch (json_object_get_type(ctlsInJ)) {
- case json_type_object:
- {
-
- index = halGetCtlIndex(request, ctlsInJ);
- if (index < 0) goto OnErrorExit;
- json_object_array_add(ctlsOutJ, json_object_new_int(halCtls[index].ctl.numid));
- break;
- }
-
- case json_type_array:
- {
-
- for (int idx = 0; idx < json_object_array_length(ctlsInJ); idx++) {
- json_object *ctlInJ = json_object_array_get_idx(ctlsInJ, idx);
- index = halGetCtlIndex(request, ctlInJ);
- if (index < 0) goto OnErrorExit;
- json_object_array_add(ctlsOutJ, json_object_new_int(halCtls[index].ctl.numid));
- }
- break;
- }
-
- default:
- afb_req_fail_f(request, "ctl-invalid", "Not a valid JSON ctl='%s'", json_object_get_string(ctlsInJ));
- goto OnErrorExit;
- }
-
- // Call now level CTL
- responseJ = halCallAlsaGetCtls(ctlsOutJ);
- if (!responseJ) {
- afb_req_fail_f(request, "subcall:alsacore/getctl", "%s", json_object_get_string(responseJ));
- goto OnErrorExit;
- }
-
- // map back low level response to HAL ctl with normalised values
- json_object *halResponse = HalGetPrepareResponse(request, responseJ);
- if (!halResponse) goto OnErrorExit;
-
- afb_req_success(request, halResponse, NULL);
- return;
-
-OnErrorExit:
- return;
-};
-
-STATIC int UpdateOneSndCtl(alsaHalCtlMapT *ctl, json_object *sndCtlJ) {
- json_object *tmpJ, *ctlJ;
-
- json_object_object_get_ex(sndCtlJ, "name", &tmpJ);
- ctl->name = (char*) json_object_get_string(tmpJ);
-
- json_object_object_get_ex(sndCtlJ, "id", &tmpJ);
- ctl->numid = json_object_get_int(tmpJ);
-
- // make sure we face a valid Alsa Low level ctl
- if (!json_object_object_get_ex(sndCtlJ, "ctl", &ctlJ)) goto OnErrorExit;
-
- json_object_object_get_ex(ctlJ, "min", &tmpJ);
- ctl->minval = json_object_get_int(tmpJ);
-
- json_object_object_get_ex(ctlJ, "max", &tmpJ);
- ctl->maxval = json_object_get_int(tmpJ);
-
- json_object_object_get_ex(ctlJ, "step", &tmpJ);
- ctl->step = json_object_get_int(tmpJ);
-
- json_object_object_get_ex(ctlJ, "count", &tmpJ);
- ctl->count = json_object_get_int(tmpJ);
-
- json_object_object_get_ex(ctlJ, "type", &tmpJ);
- ctl->type = (snd_ctl_elem_type_t) json_object_get_int(tmpJ);
-
- // process dbscale TLV if any
- if (json_object_object_get_ex(sndCtlJ, "tlv", &tmpJ)) {
- json_object *dbscaleJ;
-
- if (!json_object_object_get_ex(tmpJ, "dbscale", &dbscaleJ)) {
- AFB_WARNING("TLV found but not DBscale attached ctl name=%s numid=%d", ctl->name, ctl->numid);
- } else {
- ctl->dbscale = malloc(sizeof (alsaHalDBscaleT));
-
- json_object_object_get_ex(dbscaleJ, "min", &tmpJ);
- ctl->dbscale->min = (snd_ctl_elem_type_t) json_object_get_int(tmpJ);
-
- json_object_object_get_ex(dbscaleJ, "max", &tmpJ);
- ctl->dbscale->max = (snd_ctl_elem_type_t) json_object_get_int(tmpJ);
-
- json_object_object_get_ex(dbscaleJ, "step", &tmpJ);
- ctl->dbscale->step = (snd_ctl_elem_type_t) json_object_get_int(tmpJ);
-
- json_object_object_get_ex(dbscaleJ, "mute", &tmpJ);
- ctl->dbscale->mute = (snd_ctl_elem_type_t) json_object_get_int(tmpJ);
- }
- }
-
- return 0;
-
-OnErrorExit:
- return -1;
-}
-
-// this is call when after all bindings are loaded
-
-PUBLIC int halServiceInit(const char *apiPrefix, alsaHalSndCardT *alsaHalSndCard) {
- int err;
- json_object *queryurl, *responseJ, *devidJ, *ctlsJ, *tmpJ;
- alsaHalMapT *halCtls = alsaHalSndCard->ctls;
-
- // if not volume normalisation CB provided use default one
- if (!alsaHalSndCard->volumeCB) alsaHalSndCard->volumeCB = volumeNormalise;
- halSndCard = alsaHalSndCard;
-
- err = afb_daemon_require_api("alsacore", 1);
- if (err) {
- AFB_ERROR("AlsaCore missing cannot use AlsaHAL");
- goto OnErrorExit;
- }
-
- // register HAL with Alsa Low Level Binder
- queryurl = json_object_new_object();
- json_object_object_add(queryurl, "prefix", json_object_new_string(apiPrefix));
- json_object_object_add(queryurl, "sndname", json_object_new_string(alsaHalSndCard->name));
-
- err = afb_service_call_sync("alsacore", "halregister", queryurl, &responseJ);
- json_object_put(queryurl);
- if (err) {
- AFB_NOTICE("Fail to register HAL to ALSA lowlevel binding Response='%s'", json_object_get_string(responseJ));
- goto OnErrorExit;
- }
-
- // extract sound devidJ from HAL registration
- if (!json_object_object_get_ex(responseJ, "response", &tmpJ) || !json_object_object_get_ex(tmpJ, "devid", &devidJ)) {
- AFB_ERROR("Ooops: Internal error no devidJ return from HAL registration Response='%s'", json_object_get_string(responseJ));
- goto OnErrorExit;
- }
-
- // save devid for future use
- halSndCard->devid = strdup(json_object_get_string(devidJ));
-
- // for each Non Alsa Control callback create a custom control
- ctlsJ = json_object_new_array();
- for (int idx = 0; (halCtls[idx].ctl.name || halCtls[idx].ctl.numid); idx++) {
- json_object *ctlJ;
-
- // Try to find best equivalent label for tag
- if (halCtls[idx].tag >StartHalCrlTag && halCtls[idx].tag < EndHalCrlTag && halCtlsLabels[halCtls[idx].tag] != NULL) {
- halCtls[idx].label = halCtlsLabels[halCtls[idx].tag];
- } else {
- if (halCtls[idx].ctl.name) halCtls[idx].label=halCtls[idx].ctl.name;
- else if (halCtls[idx].info) halCtls[idx].label=halCtls[idx].info;
- else halCtls[idx].label="NoHalCttNameSet";
- }
-
- ctlJ = json_object_new_object();
- if (halCtls[idx].ctl.numid) json_object_object_add(ctlJ, "ctl", json_object_new_int(halCtls[idx].ctl.numid));
- if (halCtls[idx].ctl.name) json_object_object_add(ctlJ, "name", json_object_new_string(halCtls[idx].ctl.name));
- if (halCtls[idx].ctl.minval) json_object_object_add(ctlJ, "min", json_object_new_int(halCtls[idx].ctl.minval));
- if (halCtls[idx].ctl.maxval) json_object_object_add(ctlJ, "max", json_object_new_int(halCtls[idx].ctl.maxval));
- if (halCtls[idx].ctl.step) json_object_object_add(ctlJ, "step", json_object_new_int(halCtls[idx].ctl.step));
- if (halCtls[idx].ctl.type) json_object_object_add(ctlJ, "type", json_object_new_int(halCtls[idx].ctl.type));
- if (halCtls[idx].ctl.count) json_object_object_add(ctlJ, "count", json_object_new_int(halCtls[idx].ctl.count));
- if (halCtls[idx].ctl.value) json_object_object_add(ctlJ, "val", json_object_new_int(halCtls[idx].ctl.value));
-
- if (halCtls[idx].ctl.dbscale) {
- json_object *dbscaleJ = json_object_new_object();
- if (halCtls[idx].ctl.dbscale->max) json_object_object_add(dbscaleJ, "max", json_object_new_int(halCtls[idx].ctl.dbscale->max));
- if (halCtls[idx].ctl.dbscale->min) json_object_object_add(dbscaleJ, "min", json_object_new_int(halCtls[idx].ctl.dbscale->min));
- if (halCtls[idx].ctl.dbscale->step) json_object_object_add(dbscaleJ, "step", json_object_new_int(halCtls[idx].ctl.dbscale->step));
- if (halCtls[idx].ctl.dbscale->mute) json_object_object_add(dbscaleJ, "mute", json_object_new_int(halCtls[idx].ctl.dbscale->mute));
- json_object_object_add(ctlJ, "dbscale", dbscaleJ);
- }
-
- if (halCtls[idx].ctl.enums) {
- json_object *enumsJ = json_object_new_array();
- for (int jdx = 0; halCtls[idx].ctl.enums[jdx]; jdx++) {
- json_object_array_add(enumsJ, json_object_new_string(halCtls[idx].ctl.enums[jdx]));
- }
- json_object_object_add(ctlJ, "enums", enumsJ);
- }
- json_object_array_add(ctlsJ, ctlJ);
- }
-
- // Build new queryJ to add HAL custom control if any
- if (json_object_array_length(ctlsJ) > 0) {
- queryurl = json_object_new_object();
- json_object_get(devidJ); // make sure devidJ does not get free by 1st call.
- json_object_object_add(queryurl, "devid", devidJ);
- json_object_object_add(queryurl, "ctl", ctlsJ);
- json_object_object_add(queryurl, "mode", json_object_new_int(QUERY_COMPACT));
- err = afb_service_call_sync("alsacore", "addcustomctl", queryurl, &responseJ);
- if (err) {
- AFB_ERROR("Fail creating HAL Custom ALSA ctls Response='%s'", json_object_get_string(responseJ));
- goto OnErrorExit;
- }
- }
-
- // Make sure response is valid
- json_object_object_get_ex(responseJ, "response", &ctlsJ);
- if (json_object_get_type(ctlsJ) != json_type_array) {
- AFB_ERROR("Response Invalid JSON array ctls Response='%s'", json_object_get_string(responseJ));
- goto OnErrorExit;
- }
-
- // update HAL data from JSON response
- for (int idx = 0; idx < json_object_array_length(ctlsJ); idx++) {
- json_object *ctlJ = json_object_array_get_idx(ctlsJ, idx);
- err = UpdateOneSndCtl(&halCtls[idx].ctl, ctlJ);
- if (err) {
- AFB_ERROR("Fail found MAP Alsa Low level=%s", json_object_get_string(ctlJ));
- goto OnErrorExit;
- }
- }
-
-
- // finally register for alsa lowlevel event
- queryurl = json_object_new_object();
- json_object_object_add(queryurl, "devid", devidJ);
- err = afb_service_call_sync("alsacore", "subscribe", queryurl, &responseJ);
- if (err) {
- AFB_ERROR("Fail subscribing to ALSA lowlevel events");
- goto OnErrorExit;
- }
-
- return (0);
-
-OnErrorExit:
- return (1);
-};
-
-
-// This receive all event this binding subscribe to
-
-PUBLIC void halServiceEvent(const char *evtname, json_object *eventJ) {
- int numid;
- alsaHalMapT *halCtls = halSndCard->ctls;
- json_object *numidJ, *valuesJ;
-
- AFB_DEBUG("halServiceEvent evtname=%s [msg=%s]", evtname, json_object_get_string(eventJ));
-
- json_object_object_get_ex(eventJ, "id", &numidJ);
- numid = json_object_get_int(numidJ);
- if (!numid) {
- AFB_ERROR("halServiceEvent noid: evtname=%s [msg=%s]", evtname, json_object_get_string(eventJ));
- return;
- }
- json_object_object_get_ex(eventJ, "val", &valuesJ);
-
- // search it corresponding numid in halCtls attach a callback
- if (numid) {
- for (int idx = 0; halCtls[idx].ctl.numid; idx++) {
- if (halCtls[idx].ctl.numid == numid && halCtls[idx].cb.callback != NULL) {
- halCtls[idx].cb.callback(halCtls[idx].tag, &halCtls[idx].ctl, halCtls[idx].cb.handle, valuesJ);
- }
- }
- }
-}
-
-// Every HAL export the same API & Interface Mapping from SndCard to AudioLogic is done through alsaHalSndCardT
-PUBLIC afb_verb_v2 halServiceApi[] = {
- /* VERB'S NAME FUNCTION TO CALL SHORT DESCRIPTION */
- { .verb = "ping", .callback = pingtest, .info = "ping test for API"},
- { .verb = "ctllist", .callback = halListCtls, .info = "List AGL normalised Sound Controls"},
- { .verb = "ctlget", .callback = halGetCtls, .info = "Get one/many sound controls"},
- { .verb = "ctlset", .callback = halSetCtls, .info = "Set one/many sound controls"},
- { .verb = "evtsub", .callback = halSubscribe, .info = "Subscribe to HAL events"},
- { .verb = NULL} /* marker for end of the array */
-};
diff --git a/HAL-afb/HAL-interface/hal-interface.h b/HAL-afb/HAL-interface/hal-interface.h
deleted file mode 100644
index c210f02..0000000
--- a/HAL-afb/HAL-interface/hal-interface.h
+++ /dev/null
@@ -1,106 +0,0 @@
-/*
- * AlsaLibMapping -- provide low level interface with AUDIO lib (extracted from alsa-json-gateway code)
- * Copyright (C) 2015,2016,2017, Fulup Ar Foll fulup@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 SHAREHALLIB_H
-#define SHAREHALLIB_H
-
-#include <stdio.h>
-#include <alsa/asoundlib.h>
-
-#include "audio-common.h"
-#include <systemd/sd-event.h>
-
-typedef enum {
- ACTION_SET,
- ACTION_GET
-} ActionSetGetT;
-
-// VolRamp Handle Store current status for a given VolRam CB set
-
-typedef struct {
- halRampEnumT mode;
- halCtlsTagT slave;
- int delay; // delay between volset in us
- int stepDown; // linear %
- int stepUp; // linear %
- int current; // current volume for slave ctl
- int target; // target volume
- sd_event_source *evtsrc; // event loop timer source
-} halVolRampT;
-
-typedef struct {
- int min;
- int max;
- int step;
- int mute;
-} alsaHalDBscaleT;
-
-typedef struct {
- char* name;
- int numid;
- snd_ctl_elem_type_t type;
- int count;
- int minval;
- int maxval;
- int value;
- int step;
- const char **enums;
- alsaHalDBscaleT *dbscale;
-} alsaHalCtlMapT;
-
-
-// avoid compiler warning [Jose does not like typedef :) ]
-typedef struct afb_service alsaHalServiceT;
-
-typedef struct {
- void (*callback)(halCtlsTagT tag, alsaHalCtlMapT *control, void* handle, json_object *valuesJ);
- void* handle;
-} alsaHalCbMapT;
-
-typedef struct {
- halCtlsTagT tag;
- const char *label;
- alsaHalCtlMapT ctl;
- alsaHalCbMapT cb;
- char* info;
-} alsaHalMapT;
-
-typedef struct {
- const char *name;
- const char *info;
- alsaHalMapT *ctls;
- const char *devid;
- json_object* (*volumeCB)(ActionSetGetT action, const alsaHalCtlMapT *halCtls, json_object *valuesJ);
-} alsaHalSndCardT;
-
-// hal-interface.c
-extern afb_verb_v2 halServiceApi[];
-PUBLIC void halServiceEvent(const char *evtname, json_object *object);
-PUBLIC int halServiceInit(const char *apiPrefix, alsaHalSndCardT *alsaHalSndCard);
-PUBLIC json_object *halGetCtlByTag(halRampEnumT tag);
-PUBLIC int halSetCtlByTag(halRampEnumT tag, int value);
-
-
-// hal-volramp.c
-PUBLIC void volumeRamp(halCtlsTagT halTag, alsaHalCtlMapT *control, void* handle, json_object *valJ);
-
-// hal-volume.c
-PUBLIC json_object *volumeNormalise(ActionSetGetT action, const alsaHalCtlMapT *halCtls, json_object *valuesJ);
-
-
-#endif /* SHAREHALLIB_H */
-
diff --git a/HAL-afb/HAL-interface/hal-volramp.c b/HAL-afb/HAL-interface/hal-volramp.c
deleted file mode 100644
index 60e91d6..0000000
--- a/HAL-afb/HAL-interface/hal-volramp.c
+++ /dev/null
@@ -1,185 +0,0 @@
-/*
- * Copyright (C) 2016 "IoT.bzh"
- * Author Fulup Ar Foll <fulup@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 // needed for vasprintf
-#include "hal-interface.h"
-
-STATIC int RampTimerCB(sd_event_source* source, uint64_t timer, void* handle) {
- halVolRampT *volRamp = (halVolRampT*) handle;
- int err;
- uint64_t usec;
-
- // RampDown
- if (volRamp->current > volRamp->target) {
- volRamp->current = volRamp->current - volRamp->stepDown;
- if (volRamp->current < volRamp->target) volRamp->current = volRamp->target;
- }
-
- // RampUp
- if (volRamp->current < volRamp->target) {
- volRamp->current = volRamp->current + volRamp->stepUp;
- if (volRamp->current > volRamp->target) volRamp->current = volRamp->target;
- }
-
- // request current Volume Level
- err = halSetCtlByTag(volRamp->slave, volRamp->current);
- if (err) goto OnErrorExit;
-
- // we reach target stop volram event
- if (volRamp->current == volRamp->target) sd_event_source_unref(source);
- else {
- // otherwise validate timer for a new run
- sd_event_now(afb_daemon_get_event_loop(), CLOCK_MONOTONIC, &usec);
- sd_event_source_set_enabled(source, SD_EVENT_ONESHOT);
- err = sd_event_source_set_time(source, usec + volRamp->delay);
- }
-
- return 0;
-
-OnErrorExit:
- AFB_WARNING("RampTimerCB Fail to set HAL ctl tag=%d vol=%d", Master_Playback_Volume, volRamp->current);
- sd_event_source_unref(source); // abandon VolRamp
- return -1;
-}
-
-STATIC void SetRampTimer(void *handle) {
- halVolRampT *volRamp = (halVolRampT*) handle;
- uint64_t usec;
-
- // set a timer with ~250us accuracy
- sd_event_now(afb_daemon_get_event_loop(), CLOCK_MONOTONIC, &usec);
- sd_event_add_time(afb_daemon_get_event_loop(), &volRamp->evtsrc, CLOCK_MONOTONIC, usec, 250, RampTimerCB, volRamp);
-}
-
-STATIC int volumeDoRamp(halVolRampT *volRamp, int numid, json_object *volumeJ) {
- json_object *responseJ;
-
- // request current Volume Level
- responseJ = halGetCtlByTag(volRamp->slave);
- if (!responseJ) {
- AFB_WARNING("volumeDoRamp Fail to get HAL ctl tag=%d", Master_Playback_Volume);
- goto OnErrorExit;
- }
-
- // use 1st volume value as target for ramping
- switch (json_object_get_type(volumeJ)) {
- case json_type_array:
- volRamp->target = json_object_get_int(json_object_array_get_idx(volumeJ, 0));
- break;
-
- case json_type_int:
- volRamp->target = json_object_get_int(volumeJ);
- break;
-
- default:
- AFB_WARNING("volumeDoRamp Invalid volumeJ=%s", json_object_get_string(volumeJ));
- goto OnErrorExit;
- }
-
- // use 1st volume value as current for ramping
- switch (json_object_get_type(responseJ)) {
- case json_type_array:
- volRamp->current = json_object_get_int(json_object_array_get_idx(responseJ, 0));
- break;
-
- case json_type_int:
- volRamp->current = json_object_get_int(responseJ);
- break;
-
- default:
- AFB_WARNING("volumeDoRamp Invalid reponseJ=%s", json_object_get_string(responseJ));
- goto OnErrorExit;
- }
-
- SetRampTimer(volRamp);
-
- return 0;
-
-OnErrorExit:
- return -1;
-}
-
-PUBLIC void volumeRamp(halCtlsTagT halTag, alsaHalCtlMapT *ctl, void* handle, json_object *valJ) {
- halVolRampT *volRamp = (halVolRampT*) handle;
- json_object *tmpJ;
-
- if (json_object_get_type(valJ) != json_type_array || volRamp == NULL) goto OnErrorExit;
-
- switch (halTag) {
-
- // Only config use wellknown tag. Default is DoVolRamp
- default:
- tmpJ = json_object_array_get_idx(valJ, 0);
- volumeDoRamp(volRamp, ctl->numid, tmpJ);
- break;
-
- case Vol_Ramp_Set_Mode:
- tmpJ = json_object_array_get_idx(valJ, 0);
- volRamp->mode = json_object_get_int(tmpJ);
- switch (volRamp->mode) {
-
- case RAMP_VOL_SMOOTH:
- volRamp->delay = 100 * 1000;
- volRamp->stepDown = 1;
- volRamp->stepUp = 1;
- break;
-
- case RAMP_VOL_NORMAL:
- volRamp->delay = 100 * 1000;
- volRamp->stepDown = 3;
- volRamp->stepUp = 2;
- break;
-
- case RAMP_VOL_EMERGENCY:
- volRamp->delay = 50 * 1000;
- volRamp->stepDown = 6;
- volRamp->stepUp = 2;
- break;
-
- default:
- goto OnErrorExit;
- }
- break;
-
- case Vol_Ramp_Set_Slave:
- tmpJ = json_object_array_get_idx(valJ, 0);
- volRamp->slave = json_object_get_int(tmpJ);
- break;
-
- case Vol_Ramp_Set_Delay:
- tmpJ = json_object_array_get_idx(valJ, 0);
- volRamp->delay = 1000 * json_object_get_int(tmpJ);
- break;
-
- case Vol_Ramp_Set_Down:
- tmpJ = json_object_array_get_idx(valJ, 0);
- volRamp->stepDown = json_object_get_int(tmpJ);
- break;
-
- case Vol_Ramp_Set_Up:
- tmpJ = json_object_array_get_idx(valJ, 0);
- volRamp->stepUp = json_object_get_int(tmpJ);
- break;
- }
-
- return;
-
-OnErrorExit:
- AFB_WARNING("volumeRamp: Invalid Ctrl Event halCtlsTagT=%d numid=%d name=%s value=%s", halTag, ctl->numid, ctl->name, json_object_get_string(valJ));
- return;
-}
diff --git a/HAL-afb/HAL-interface/hal-volume.c b/HAL-afb/HAL-interface/hal-volume.c
deleted file mode 100644
index 997ce98..0000000
--- a/HAL-afb/HAL-interface/hal-volume.c
+++ /dev/null
@@ -1,150 +0,0 @@
-/*
- * Copyright (C) 2016 "IoT.bzh"
- * Author Fulup Ar Foll <fulup@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.
- *
- * references:
- * alsa-util/amixer.c + alsa-lib/simple.c
- * snd_tlv_convert_from_dB
- * nt snd_tlv_convert_to_dB
- * snd_tlv_get_dB_range
- */
-
-#define _GNU_SOURCE // needed for vasprintf
-#include <math.h>
-#include "hal-interface.h"
-
-typedef enum {
- NORMALIZE_NONE = 0,
- NORMALIZE_DB_LINEAR,
- NORMALIZE_DB_MATH,
- NORMALIZE_LINEAR,
-} enumRandeModeDB_T;
-
-
-// Return Value express from 0-100%
-
-STATIC int dbNormalizeVal(enumRandeModeDB_T normaliseMode, const alsaHalDBscaleT *dbscale, int value) {
- double normalized, min_norm;
-
- // To get real DB from TLV DB values should be divided by 100
- switch (normaliseMode) {
- case NORMALIZE_DB_LINEAR:
- normalized = ((double) (value - dbscale->min) / (double) (dbscale->max - dbscale->min));
- break;
-
- case NORMALIZE_DB_MATH:
- normalized = exp10((double) (value - dbscale->max) / 6000.0);
- if (dbscale->min != SND_CTL_TLV_DB_GAIN_MUTE) {
- min_norm = exp10((double) (dbscale->min - dbscale->max) / 20);
- normalized = (normalized - min_norm) / (1 - min_norm);
- }
-
- break;
-
- default:
- normalized = 0;
- }
-
- return (int) round(normalized * 100);
-}
-
-// HAL normalise volume values to 0-100%
-
-PUBLIC json_object *volumeNormalise(ActionSetGetT action, const alsaHalCtlMapT *halCtls, json_object *valuesJ) {
- enumRandeModeDB_T useNormalizeDB;
- int length;
-
- // If Integer look for DBscale
- if (halCtls->type == SND_CTL_ELEM_TYPE_INTEGER) {
-
- // If not valid db_scale let's use raw_scale
- if (!halCtls->dbscale || (halCtls->dbscale->min >= halCtls->dbscale->max)) {
-
- // dbscale is invalid let's try raw range
- if (halCtls->minval >= halCtls->maxval) goto ExitOnError;
-
- // Use Raw Scale Model
- useNormalizeDB = NORMALIZE_LINEAR;
-
- } else { // db_scale looks OK let's use it
- if ((halCtls->dbscale->max - halCtls->dbscale->min) <= MAX_LINEAR_DB_SCALE * 100) useNormalizeDB = NORMALIZE_DB_LINEAR;
- else useNormalizeDB = NORMALIZE_LINEAR; // Fulup not sure how to handle this useNormalizeDB=NORMALIZE_DB_MATH;
- }
- } else useNormalizeDB = NORMALIZE_NONE;
-
-
- // loop on values to normalise
- enum json_type jtype = json_object_get_type(valuesJ);
- if (jtype == json_type_array) length = json_object_array_length(valuesJ);
- else length = 1;
-
- json_object *normalisedJ = json_object_new_array();
- for (int idx = 0; idx < length; idx++) {
- int value;
-
- if (jtype == json_type_array) {
- json_object *valueJ = json_object_array_get_idx(valuesJ, idx);
- value = json_object_get_int(valueJ);
- } else {
- value = json_object_get_int(valuesJ);
- }
-
- // If Integer scale to 0/100
- if (halCtls->type == SND_CTL_ELEM_TYPE_INTEGER) {
-
- switch (action) {
-
- case ACTION_GET:
- switch (useNormalizeDB) {
- case NORMALIZE_LINEAR:
- value = 100 * (value - halCtls->minval) / (halCtls->maxval - halCtls->minval);
- break;
- case NORMALIZE_DB_MATH: //ToBeDone
- value = dbNormalizeVal(useNormalizeDB, halCtls->dbscale, value);
- break;
- case NORMALIZE_NONE:
- default:
- value = value;
- }
- break;
-
- case ACTION_SET:
- switch (useNormalizeDB) {
- case NORMALIZE_LINEAR:
- value = (value * (halCtls->maxval - halCtls->minval)) / 100;
- break;
- case NORMALIZE_DB_MATH: //ToBeDone
- value = dbNormalizeVal(useNormalizeDB, halCtls->dbscale, value);
- break;
- case NORMALIZE_NONE:
- default:
- value = value;
- }
- break;
-
- default:
- AFB_NOTICE("volumeNormalise: invalid action value=%d", (int) action);
- goto ExitOnError;
- }
- }
-
- json_object_array_add(normalisedJ, json_object_new_int(value));
- }
-
- return (normalisedJ);
-
-ExitOnError:
- return NULL;
-}
diff --git a/HAL-afb/HAL_MOST_UNICENS/CMakeLists.txt b/HAL-afb/HAL_MOST_UNICENS/CMakeLists.txt
deleted file mode 100644
index 3204dd1..0000000
--- a/HAL-afb/HAL_MOST_UNICENS/CMakeLists.txt
+++ /dev/null
@@ -1,46 +0,0 @@
-###########################################################################
-# Copyright 2015, 2016, 2017 IoT.bzh
-#
-# author: Fulup Ar Foll <fulup@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_SUBDIRECTORY(ucs2-vol)
-
-# Add target to project dependency list
-PROJECT_TARGET_ADD(hal-most-unicens)
-
- # Define project Targets
- ADD_LIBRARY(hal-most-unicens MODULE hal_most_unicens.c wrap-json.c wrap_unicens.c wrap_volume.c)
-
- # Binder exposes a unique public entry point
- SET_TARGET_PROPERTIES(${TARGET_NAME} PROPERTIES
- PREFIX "afb-"
- LABELS "BINDING"
- LINK_FLAGS ${BINDINGS_LINK_FLAG}
- OUTPUT_NAME ${TARGET_NAME}
- )
-
- # Library dependencies (include updates automatically)
- TARGET_LINK_LIBRARIES(${TARGET_NAME}
- hal-interface
- audio-common
- ucs2-volume
- ${link_libraries}
- )
-
- # Define properties to expose when others use this target
- TARGET_INCLUDE_DIRECTORIES(${TARGET_NAME}
- PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}/ucs2-vol/inc
- )
diff --git a/HAL-afb/HAL_MOST_UNICENS/README.md b/HAL-afb/HAL_MOST_UNICENS/README.md
deleted file mode 100644
index 4ce4261..0000000
--- a/HAL-afb/HAL_MOST_UNICENS/README.md
+++ /dev/null
@@ -1,51 +0,0 @@
-
-# HAL for MOST Sound Card
-
-## Introduction
-This Hardware Abstraction Layer (HAL) is intended to control MOST audio via
-standard ALSA mixer controls. Therefore the HAL add's controls to the MOST sound
-card. Modification of the mixer controls is mapped to control commands which are
-send to MOST nodes.
-
-The HAL requires to access the UNICENS V2 binding which is setting up the MOST
-network and the MOST node.
-
-Please check the following required components:
-* MOST Linux Driver
-* User must be member of "audio" group
-* UNICENS V2 binding
-* [K2L MOST150 Audio 5.1 Kit](https://www.k2l.de/products/74/MOST150%20Audio%205.1%20Kit/)
-
-## Possible Modifications
-Check if you need to adapt the default path for UNICENS configuration, e.g.
-```
-#define XML_CONFIG_PATH "/opt/AGL/unicens2-binding/config_multichannel_audio_kit.xml"
-```
-
-Check if you need to adapt the name of the MOST sound card.
-```
-#define ALSA_CARD_NAME "Microchip MOST:1"
-```
-
-You can check your MOST sound card name by calling ```aplay -l```, e.g.
-```
-aplay -l
-**** List of PLAYBACK Hardware Devices ****
-card 0: PCH [HDA Intel PCH], device 0: 92HD90BXX Analog [92HD90BXX Analog]
- Subdevices: 1/1
- Subdevice #0: subdevice #0
-card 1: ep016ch [Microchip MOST:1], device 0: ep01-6ch []
- Subdevices: 1/1
- Subdevice #0: subdevice #0
-card 2: ep022ch [Microchip MOST:2], device 0: ep02-2ch []
- Subdevices: 1/1
- Subdevice #0: subdevice #0
-
-```
-Choose the first sound card with 6 channels, e.g. if you see ```ep01-6ch``` just
-take ```Microchip MOST:1```.
-
-If you get messed up with card enumeration the following action may help:
-- Unplug your MOST USB hardware from target
-- Call ```sudo rm /var/lib/alsa/asound.state```
-- Connect MOST USB hardware after reboot or restart of ALSA
diff --git a/HAL-afb/HAL_MOST_UNICENS/hal_most_unicens.c b/HAL-afb/HAL_MOST_UNICENS/hal_most_unicens.c
deleted file mode 100644
index 5e29b59..0000000
--- a/HAL-afb/HAL_MOST_UNICENS/hal_most_unicens.c
+++ /dev/null
@@ -1,252 +0,0 @@
-/*
- * Copyright (C) 2017, Microchip Technology Inc. and its subsidiaries.
- * Author Tobias Jahnke
- *
- * 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 <string.h>
-#include "hal-interface.h"
-#include "audio-common.h"
-#include "wrap-json.h"
-#include "wrap_unicens.h"
-#include "wrap_volume.h"
-
-#ifndef UCS2_CFG_PATH
-# define UCS2_CFG_PATH "/home/agluser/DEVELOPMENT/AGL/BINDING/unicens2-binding/data"
-#endif
-
-#define ALSA_CARD_NAME "Microchip MOST:1"
-#define ALSA_DEVICE_ID "hw:1"
-#define PCM_MAX_CHANNELS 6
-
-static int master_volume;
-static json_bool master_switch;
-static int pcm_volume[PCM_MAX_CHANNELS];
-
-static void unicens_request_card_values_cb(void *closure, int status, struct json_object *j_response) {
-
- json_object *j_obj;
- int num_id;
- int values[6];
-
- AFB_INFO("unicens_request_card_values_cb: closure=%p status=%d, res=%s", closure, status, json_object_to_json_string(j_response));
-
- json_object_object_get_ex(j_response, "response", &j_obj);
-
- if (json_object_is_type(j_obj, json_type_object)) {
-
- }
- else if (json_object_is_type(j_obj, json_type_array)) {
- AFB_ERROR("unicens_request_card_values_cb: array not handled yet");
- return;
- }
- else {
- AFB_ERROR("unicens_request_card_values_cb: unknown response type");
- return;
- }
-
- if (wrap_json_unpack(j_obj, "{s:i, s:[iiiiii!]}", "id", &num_id, "val",
- &values[0], &values[1], &values[2], &values[3], &values[4], &values[5])
- == 0) {
- AFB_NOTICE("unicens_request_card_values_cb: success, num id:%d", num_id);
- }
- else {
- AFB_ERROR("unicens_request_card_values_cb: unpack failure");
- return;
- }
-
-#if 0
- if (num_id == 2) {
- wrap_volume_pcm(&values[0], 6);
- }
-#endif
-
-}
-
-__attribute__ ((unused)) static void unicens_request_card_values(const char* dev_id) {
-
- int err;
- json_object *j_query = NULL;
-
- err = wrap_json_pack(&j_query, "{s:s, s:i}", "devid", dev_id, "mode", 0);
-
- if (err) {
- AFB_ERROR("Failed to call wrap_json_pack");
- goto OnErrorExit;
- }
-
- afb_service_call("alsacore", "ctlget", j_query,
- &unicens_request_card_values_cb,
- NULL);
-
- if (err) {
- AFB_ERROR("Failed to call listconfig");
- goto OnErrorExit;
- }
-
-OnErrorExit:
- return;
-}
-
-void unicens_master_vol_cb(halCtlsTagT tag, alsaHalCtlMapT *control, void* handle, json_object *j_obj) {
-
- const char *j_str = json_object_to_json_string(j_obj);
-
- if (wrap_json_unpack(j_obj, "[i!]", &master_volume) == 0) {
- AFB_NOTICE("master_volume: %s, value=%d", j_str, master_volume);
- wrap_volume_master(master_volume);
- }
- else {
- AFB_NOTICE("master_volume: INVALID STRING %s", j_str);
- }
-}
-
-void unicens_master_switch_cb(halCtlsTagT tag, alsaHalCtlMapT *control, void* handle, json_object *j_obj) {
-
- const char *j_str = json_object_to_json_string(j_obj);
-
- if (wrap_json_unpack(j_obj, "[b!]", &master_switch) == 0) {
- AFB_NOTICE("master_switch: %s, value=%d", j_str, master_switch);
- }
- else {
- AFB_NOTICE("master_switch: INVALID STRING %s", j_str);
- }
-}
-
-void unicens_pcm_vol_cb(halCtlsTagT tag, alsaHalCtlMapT *control, void* handle, json_object *j_obj) {
-
- const char *j_str = json_object_to_json_string(j_obj);
-
- if (wrap_json_unpack(j_obj, "[iiiiii!]", &pcm_volume[0], &pcm_volume[1], &pcm_volume[2], &pcm_volume[3],
- &pcm_volume[4], &pcm_volume[5]) == 0) {
- AFB_NOTICE("pcm_vol: %s", j_str);
- wrap_volume_pcm(pcm_volume, PCM_MAX_CHANNELS/*array size*/);
- }
- else {
- AFB_NOTICE("pcm_vol: INVALID STRING %s", j_str);
- }
-}
-
-/* declare ALSA mixer controls */
-STATIC alsaHalMapT alsaHalMap[]= {
- { .tag=Master_Playback_Volume, .cb={.callback=unicens_master_vol_cb, .handle=&master_volume}, .info="Sets master playback volume",
- .ctl={.numid=CTL_AUTO, .type=SND_CTL_ELEM_TYPE_INTEGER, .count=1, .minval=0, .maxval=100, .step=1, .value=50, .name="Master Playback Volume"}
- },
- /*{ .tag=Master_OnOff_Switch, .cb={.callback=unicens_master_switch_cb, .handle=&master_switch}, .info="Sets master playback switch",
- .ctl={.numid=CTL_AUTO, .type=SND_CTL_ELEM_TYPE_BOOLEAN, .count=1, .minval=0, .maxval=1, .step=1, .value=1, .name="Master Playback Switch"}
- },*/
- { .tag=PCM_Playback_Volume, .cb={.callback=unicens_pcm_vol_cb, .handle=&pcm_volume}, .info="Sets PCM playback volume",
- .ctl={.numid=CTL_AUTO, .type=SND_CTL_ELEM_TYPE_INTEGER, .count=6, .minval=0, .maxval=100, .step=1, .value=100, .name="PCM Playback Volume"}
- },
- { .tag=EndHalCrlTag} /* marker for end of the array */
-} ;
-
-/* HAL sound card mapping info */
-STATIC alsaHalSndCardT alsaHalSndCard = {
- .name = ALSA_CARD_NAME, /* WARNING: name MUST match with 'aplay -l' */
- .info = "HAL for MICROCHIP MOST sound card controlled by UNICENS binding",
- .ctls = alsaHalMap,
- .volumeCB = NULL, /* use default volume normalization function */
-};
-
-/* initializes ALSA sound card, UNICENS API */
-STATIC int unicens_service_init() {
- int err = 0;
- char *config_file = NULL;
- AFB_NOTICE("Initializing HAL-MOST-UNICENS-BINDING");
-
- err = halServiceInit(afbBindingV2.api, &alsaHalSndCard);
- if (err) {
- AFB_ERROR("Cannot initialize ALSA soundcard.");
- goto OnErrorExit;
- }
-
- err= afb_daemon_require_api("UNICENS", 1);
- if (err) {
- AFB_ERROR("Failed to access UNICENS API");
- goto OnErrorExit;
- }
-
- err = wrap_ucs_getconfig_sync(UCS2_CFG_PATH, &config_file);
- if (err || (config_file == NULL)) {
- AFB_ERROR("Failed to retrieve configuration");
- goto OnErrorExit;
- }
- else {
- AFB_NOTICE("Found configuration: %s", config_file);
- }
-
- err = wrap_ucs_subscribe_sync();
- if (err) {
- AFB_ERROR("Failed to subscribe to UNICENS binding");
- goto OnErrorExit;
- }
-
- err = wrap_ucs_initialize_sync(config_file);
- free(config_file);
- config_file = NULL;
-
- if (err) {
- AFB_ERROR("Failed to initialize UNICENS binding");
- goto OnErrorExit;
- }
-
- err = wrap_volume_init();
- if (err) {
- AFB_ERROR("Failed to initialize wrapper for volume library");
- goto OnErrorExit;
- }
-
- /* request of initial card values */
- /* unicens_request_card_values(ALSA_DEVICE_ID); */
-
-OnErrorExit:
- AFB_NOTICE("Initializing HAL-MOST-UNICENS-BINDING done..");
- return err;
-}
-
-// This receive all event this binding subscribe to
-PUBLIC void unicens_event_cb(const char *evtname, json_object *j_event) {
-
- if (strncmp(evtname, "alsacore/", 9) == 0) {
- halServiceEvent(evtname, j_event);
- return;
- }
-
- if (strncmp(evtname, "UNICENS/", 8) == 0) {
- //AFB_NOTICE("unicens_event_cb: evtname=%s, event=%s", evtname, json_object_get_string(j_event));
- if (strcmp(evtname, "UNICENS/node-availibility") == 0) {
-
- int node;
- int available;
- if (wrap_json_unpack(j_event, "{s:i,s:b}", "node", &node, "available", &available) == 0) {
- AFB_NOTICE("Node-Availability: node=0x%03X, available=%d", node, available);
- wrap_volume_node_avail(node, available);
- }
- }
-
- return;
- }
-
- AFB_NOTICE("unicens_event_cb: UNHANDLED EVENT, evtname=%s, event=%s", evtname, json_object_get_string(j_event));
-}
-
-/* API prefix should be unique for each snd card */
-PUBLIC const struct afb_binding_v2 afbBindingV2 = {
- .api = "hal-most-unicens",
- .init = unicens_service_init,
- .verbs = halServiceApi,
- .onevent = unicens_event_cb,
-};
diff --git a/HAL-afb/HAL_MOST_UNICENS/ucs2-vol/CMakeLists.txt b/HAL-afb/HAL_MOST_UNICENS/ucs2-vol/CMakeLists.txt
deleted file mode 100644
index c734639..0000000
--- a/HAL-afb/HAL_MOST_UNICENS/ucs2-vol/CMakeLists.txt
+++ /dev/null
@@ -1,26 +0,0 @@
-###########################################################################
-# Copyright 2015, 2016, 2017 IoT.bzh
-#
-# author: Fulup Ar Foll <fulup@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 subproject targets
-ADD_SUBDIRECTORY(src)
-
-
-
-
diff --git a/HAL-afb/HAL_MOST_UNICENS/ucs2-vol/inc/device_container.h b/HAL-afb/HAL_MOST_UNICENS/ucs2-vol/inc/device_container.h
deleted file mode 100644
index 9fabdb5..0000000
--- a/HAL-afb/HAL_MOST_UNICENS/ucs2-vol/inc/device_container.h
+++ /dev/null
@@ -1,59 +0,0 @@
-/*
- * libmostvolume example
- *
- * Copyright (C) 2017 Microchip Technology Germany II GmbH & Co. KG
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- *
- * You may also obtain this software under a propriety license from Microchip.
- * Please contact Microchip for further information.
- *
- */
-
-#ifndef DEVICECONTAINER_H
-#define DEVICECONTAINER_H
-
-#include "device_value.h"
-#include "libmostvolume.h"
-
-class CDeviceContainer {
-
-public:
- CDeviceContainer();
- virtual ~CDeviceContainer();
-
- void AssignService(lib_most_volume_init_t *init_ptr) {_init_ptr = init_ptr;}
-
- void RegisterValues(CDeviceValue** list_pptr, uint16_t list_sz);
- void SetValue(uint16_t key, uint8_t value);
- void ClearValues();
- void Update();
- void ChangeNodeAvailable(uint16_t address, bool available);
-
-private:
- void RequestService(uint16_t timeout);
- void IncrementProcIndex(void);
- void HandleI2cResult(uint8_t result);
- static void OnI2cResult(uint8_t result, void *obj_ptr);
-
- uint16_t _idx_processing;
- uint16_t _values_sz;
- CDeviceValue **_values_pptr;
- bool _tx_busy;
- bool _service_requested;
- lib_most_volume_init_t *_init_ptr;
-};
-
-#endif /* DEVICECONTAINER_H */
-
diff --git a/HAL-afb/HAL_MOST_UNICENS/ucs2-vol/inc/device_value.h b/HAL-afb/HAL_MOST_UNICENS/ucs2-vol/inc/device_value.h
deleted file mode 100644
index bc8f142..0000000
--- a/HAL-afb/HAL_MOST_UNICENS/ucs2-vol/inc/device_value.h
+++ /dev/null
@@ -1,101 +0,0 @@
-/*
- * libmostvolume example
- *
- * Copyright (C) 2017 Microchip Technology Germany II GmbH & Co. KG
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- *
- * You may also obtain this software under a propriety license from Microchip.
- * Please contact Microchip for further information.
- *
- */
-
-#ifndef DEVICEVALUE_H
-#define DEVICEVALUE_H
-
-#include <stdint.h>
-#include "libmostvolume.h"
-
-struct SRxMessage {
- uint32_t devInst; /*instance if multiple devices are using the same group id*/
- uint32_t sourceAddr;
- uint32_t targetAddr;
- uint32_t nFBlock;
- uint32_t nInst;
- uint32_t nFunc;
- uint32_t nOpType;
- const uint8_t *pPayload;
- uint32_t payloadLen;
-};
-
-struct STxMessage {
- uint32_t devInst; /*instance if multiple devices are using the same group id*/
- uint32_t targetAddr;
- uint32_t nFBlock;
- uint32_t nInst;
- uint32_t nFunc;
- uint32_t nOpType;
- const uint8_t *pPayload;
- uint32_t payloadLen;
-};
-
-enum DeviceValueType {
- DEVICE_VAL_MASTER = 0,
- DEVICE_VAL_LEFT = 1,
- DEVICE_VAL_RIGHT = 2
-
-};
-
-class CDeviceValue {
-public:
- CDeviceValue(uint16_t address, DeviceValueType type, uint16_t key);
- virtual ~CDeviceValue();
-
- uint16_t GetKey(){return _key;}
- DeviceValueType GetType(){return _type;} // returns the assigned type
- void SetValue(uint8_t value){_target_value = value;} // sets desired value
-
- bool RequiresUpdate(); // returns true if target is not actual value
- // returns true if success, false if failed
- // -> stop transmission
- bool FireUpdateMessage(lib_most_volume_writei2c_cb_t writei2c_fptr,
- lib_most_volume_writei2c_result_cb_t result_fptr,
- void *result_user_ptr);// fires message & updates actual value
-
- void SetAvailable(bool active){this->_is_available = active; _actual_value = 0x01u;}
- bool IsAvailable() {return this->_is_available;}
- uint16_t GetAddress() {return this->_address;}
-
-private:
- void ApplyMostValue(uint8_t value, DeviceValueType type, uint8_t tx_payload[]);
- void HandleI2cResult(uint8_t result);
- static void OnI2cResult(uint8_t result, void *obj_ptr);
-
- bool _is_available; // related node is available
- bool _is_busy; // do not update while busy
- DeviceValueType _type; // determines the remote i2c command
- uint16_t _key; // lookup key
- uint16_t _address; // target node/group address
- uint8_t _target_value; // desired value
- uint8_t _transmitted_value;// value pending during transmission
- uint8_t _actual_value; // value set and confirmed via network
- uint8_t _tx_payload[20];
- uint8_t _tx_payload_sz;
-
- lib_most_volume_writei2c_result_cb_t _result_fptr;
- void *_result_user_ptr;
-};
-
-#endif /* DEVICEPROPERTY_H */
-
diff --git a/HAL-afb/HAL_MOST_UNICENS/ucs2-vol/inc/libmostvolume.h b/HAL-afb/HAL_MOST_UNICENS/ucs2-vol/inc/libmostvolume.h
deleted file mode 100644
index 1147993..0000000
--- a/HAL-afb/HAL_MOST_UNICENS/ucs2-vol/inc/libmostvolume.h
+++ /dev/null
@@ -1,111 +0,0 @@
-/*
- * libmostvolume example
- *
- * Copyright (C) 2017 Microchip Technology Germany II GmbH & Co. KG
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- *
- * You may also obtain this software under a propriety license from Microchip.
- * Please contact Microchip for further information.
- *
- */
-
-#ifndef LIB_MOST_VOLUME_H
-#define LIB_MOST_VOLUME_H
-
-#include <stdint.h>
-
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-/** Describes the volume control */
-enum lib_most_volume_channel_t{
- LIB_MOST_VOLUME_CH_FRONT_LEFT = 0,
- LIB_MOST_VOLUME_CH_FRONT_RIGHT = 1,
- LIB_MOST_VOLUME_CH_REAR_LEFT = 2,
- LIB_MOST_VOLUME_CH_REAR_RIGHT = 3,
- LIB_MOST_VOLUME_CH_CENTER = 4,
- LIB_MOST_VOLUME_CH_SUB = 5,
- LIB_MOST_VOLUME_MASTER = 6
-};
-
-/** Is fired when the application shall call "lib_most_volume_service()" after a certain time
- * \param timeout Time in ms after which the application shall call lib_most_volume_service().
- * Valid values:
- * 0x0000: as soon as possible,
- * 0x0001..0xFFFE: timeout in ms,
- * 0xFFFF: never
- */
-typedef void (*lib_most_volume_service_cb_t)(uint16_t timeout);
-
-typedef void (*lib_most_volume_writei2c_result_cb_t)(uint8_t result, void *user_ptr);
-
-/** Callback function required to write volume changes to network devices
- * \param node The node address
- * \param data_ptr I2C command data
- * \param data_sz Size of the I2C command data
- * \return Returns \c 0 for success, other value on failure.
- */
-typedef int (*lib_most_volume_writei2c_cb_t)(uint16_t node, uint8_t *data_ptr, uint8_t data_sz,
- lib_most_volume_writei2c_result_cb_t result_fptr,
- void *result_user_ptr);
-
-typedef struct lib_most_volume_init_ {
- lib_most_volume_service_cb_t service_cb;
- lib_most_volume_writei2c_cb_t writei2c_cb;
-
-} lib_most_volume_init_t;
-
-
-/** Initializes the library
- * \param UNICENS_inst Reference to the UNICENS instance, created by the application.
- * \param req_service_fptr Callback function which is fired if the application shall call
- * lib_most_volume_service.
- * \return '0' on success, otherwise value >'0'.
- */
-extern uint8_t lib_most_volume_init(lib_most_volume_init_t *init_ptr);
-
-/** Terminates the library
- * \return '0' on success, otherwise value >'0'.
- */
-extern uint8_t lib_most_volume_exit(void);
-
-/** Sets a single volume value.
- * \param channel The volume control to be set.
- * \param volume The volume value to be set. Valid values: 0..255.
- * \return '0' on success, otherwise value >'0'.
- */
-extern uint8_t lib_most_volume_set(enum lib_most_volume_channel_t channel, uint8_t volume);
-
-/** Must be called when the availability of a node has changed
- * \param address The node address
- * \param available Availability: 0 - not available, 1 - available
- * \return '0' on success, otherwise value >'0'.
- */
-extern uint8_t lib_most_volume_node_available(uint16_t address, uint8_t available);
-
-/** Shall be called either cyclically (e.g. 50ms -> polling) or after "timeout"
- * when "service_fptr" is fired (-> event triggered).
- * \return '0' on success, otherwise value >'0'.
- */
-extern uint8_t lib_most_volume_service(void);
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif /* LIB_MOST_VOLUME_H */
-
diff --git a/HAL-afb/HAL_MOST_UNICENS/ucs2-vol/inc/setup.h b/HAL-afb/HAL_MOST_UNICENS/ucs2-vol/inc/setup.h
deleted file mode 100644
index e7cda01..0000000
--- a/HAL-afb/HAL_MOST_UNICENS/ucs2-vol/inc/setup.h
+++ /dev/null
@@ -1,71 +0,0 @@
-/*
- * libmostvolume example
- *
- * Copyright (C) 2017 Microchip Technology Germany II GmbH & Co. KG
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- *
- * You may also obtain this software under a propriety license from Microchip.
- * Please contact Microchip for further information.
- *
- */
-
-#ifndef SETUP_H
-#define SETUP_H
-
-#include "libmostvolume.h"
-#include "device_value.h"
-#include "device_container.h"
-
-#define MAX_CHANNELS (LIB_MOST_VOLUME_MASTER + 1u)
-#define MAX_MASTERS 3u
-
-class CSetup {
-
-public:
- void Configure(lib_most_volume_init_t *init_ptr);
- void SetVolume(enum lib_most_volume_channel_t channel, uint8_t volume);
- void Update();
- void SetNodeAvailable(uint16_t address, bool available);
-
-private:
- CDeviceValue _volume_amp_270_m;
- CDeviceValue _volume_amp_270_l;
- CDeviceValue _volume_amp_270_r;
-
- CDeviceValue _volume_amp_271_m;
- CDeviceValue _volume_amp_271_l;
- CDeviceValue _volume_amp_271_r;
-
- CDeviceValue _volume_amp_272_m;
- CDeviceValue _volume_amp_272_l;
- CDeviceValue _volume_amp_272_r;
-
- CDeviceContainer _value_container;
- lib_most_volume_init_t init_data;
-
-public:
- static CSetup* GetInstance(); // singleton
- static void Release(); // singleton
-
-protected:
- CSetup(); // singleton
- virtual ~CSetup(); // singleton
-
-private:
- static CSetup* _instance; // singleton
-};
-
-#endif /* SETUP_H */
-
diff --git a/HAL-afb/HAL_MOST_UNICENS/ucs2-vol/src/CMakeLists.txt b/HAL-afb/HAL_MOST_UNICENS/ucs2-vol/src/CMakeLists.txt
deleted file mode 100644
index 1be7184..0000000
--- a/HAL-afb/HAL_MOST_UNICENS/ucs2-vol/src/CMakeLists.txt
+++ /dev/null
@@ -1,39 +0,0 @@
-###########################################################################
-# Copyright 2015, 2016, 2017 IoT.bzh
-#
-# author: Fulup Ar Foll <fulup@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(ucs2-volume)
-
-# Define targets source files
-ADD_LIBRARY(${TARGET_NAME} STATIC device_container.cpp device_value.cpp libmostvolume.cpp setup.cpp)
-
- # Library properties
- SET_TARGET_PROPERTIES(${TARGET_NAME} PROPERTIES
- OUTPUT_NAME ${TARGET_NAME}
- )
-
- # Library dependencies from PKG_REQUIRED_LIST
- #TARGET_LINK_LIBRARIES(ucs2-volume # Library dependencies (include updates automatically)
- # ${link_libraries}
- #)
-
- # Define properties to expose when others use this target
- TARGET_INCLUDE_DIRECTORIES(${TARGET_NAME}
- PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}/../inc
- )
-
diff --git a/HAL-afb/HAL_MOST_UNICENS/ucs2-vol/src/device_container.cpp b/HAL-afb/HAL_MOST_UNICENS/ucs2-vol/src/device_container.cpp
deleted file mode 100644
index f8b1961..0000000
--- a/HAL-afb/HAL_MOST_UNICENS/ucs2-vol/src/device_container.cpp
+++ /dev/null
@@ -1,187 +0,0 @@
-/*
- * libmostvolume example
- *
- * Copyright (C) 2017 Microchip Technology Germany II GmbH & Co. KG
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- *
- * You may also obtain this software under a propriety license from Microchip.
- * Please contact Microchip for further information.
- *
- */
-
-#include <stddef.h>
-#include "device_container.h"
-
-#define DEVCONT_TIME_RETRIGGER (uint16_t)30U
-#define DEVCONT_TIME_NOW (uint16_t)0U
-#define DEVCONT_TIME_STOP (uint16_t)0xFFFFU
-
-#define DEVCONT_UNUSED(a) (a = a)
-
-CDeviceContainer::CDeviceContainer()
-{
- this->_idx_processing = 0U;
- this->_values_pptr = NULL;
- this->_values_sz = 0U;
- this->_tx_busy = false;
- this->_service_requested = false;
- this->_init_ptr = NULL;
-}
-
-CDeviceContainer::~CDeviceContainer()
-{
- /*Clb_RegisterI2CResultCB(NULL, NULL);*/ /* avoid that the result callback is fired after object is destroyed */
-}
-
-void CDeviceContainer::RegisterValues(CDeviceValue** list_pptr, uint16_t list_sz)
-{
- this->_idx_processing = 0U;
- this->_values_pptr = list_pptr;
- this->_values_sz = list_sz;
- this->_tx_busy = false;
-
- if ((list_pptr != NULL) && (list_sz > 0U))
- {
- this->_idx_processing = (uint16_t)(list_sz - 1U);
- }
-}
-
-void CDeviceContainer::ClearValues()
-{
- this->_idx_processing = 0U;
- this->_values_pptr = NULL;
- this->_values_sz = 0U;
- this->_tx_busy = false;
-}
-
-void CDeviceContainer::SetValue(uint16_t key, uint8_t value)
-{
- uint16_t idx;
- bool req_update = false;
-
- for (idx = 0U; idx < this->_values_sz; idx++)
- {
- if (this->_values_pptr[idx]->GetKey() == key)
- {
- this->_values_pptr[idx]->SetValue(value);
- if (this->_values_pptr[idx]->RequiresUpdate())
- {
- req_update = true;
- }
- }
- }
-
- if (req_update && (!this->_tx_busy))
- {
- RequestService(DEVCONT_TIME_NOW); //fire callback
- }
-}
-
-void CDeviceContainer::IncrementProcIndex(void)
-{
- if ((_idx_processing + 1U) >= this->_values_sz)
- {
- _idx_processing = 0U;
- }
- else
- {
- _idx_processing++;
- }
-}
-
-// starts at latest position, searches next value to update, waits until response
-void CDeviceContainer::Update()
-{
- uint16_t cnt;
- bool error = false;
- _service_requested = false;
-
- if (this->_tx_busy)
- {
- return;
- }
-
- for (cnt = 0u; cnt < this->_values_sz; cnt++) /* just run one cycle */
- {
- IncrementProcIndex();
-
- if (_values_pptr[_idx_processing]->RequiresUpdate())
- {
- if (_values_pptr[_idx_processing]->FireUpdateMessage(this->_init_ptr->writei2c_cb,
- &OnI2cResult,
- this))
- {
- this->_tx_busy = true;
- error = false;
- break;
- }
- else
- {
- error = true;
- break;
- }
- }
- }
-
- if (error)
- {
- RequestService(DEVCONT_TIME_RETRIGGER);
- }
-}
-
-void CDeviceContainer::HandleI2cResult(uint8_t result)
-{
- this->_tx_busy = false;
- if (result == 0)
- this->RequestService(DEVCONT_TIME_NOW);
- else
- this->RequestService(DEVCONT_TIME_RETRIGGER);
-}
-
-void CDeviceContainer::OnI2cResult(uint8_t result, void *obj_ptr)
-{
- ((CDeviceContainer*)obj_ptr)->HandleI2cResult(result);
-}
-
-void CDeviceContainer::RequestService(uint16_t timeout)
-{
- if (!_service_requested)
- {
- _service_requested = true;
-
- if (this->_init_ptr && this->_init_ptr->service_cb)
- {
- this->_init_ptr->service_cb(timeout);
- }
- }
-}
-
-void CDeviceContainer::ChangeNodeAvailable(uint16_t address, bool available)
-{
- uint16_t idx;
-
- for (idx = 0U; idx < this->_values_sz; idx++)
- {
- if (this->_values_pptr[idx]->GetAddress() == address)
- {
- this->_values_pptr[idx]->SetAvailable(available);
- }
- }
-
- if (available)
- {
- RequestService(DEVCONT_TIME_RETRIGGER);
- }
-}
diff --git a/HAL-afb/HAL_MOST_UNICENS/ucs2-vol/src/device_value.cpp b/HAL-afb/HAL_MOST_UNICENS/ucs2-vol/src/device_value.cpp
deleted file mode 100644
index 7103192..0000000
--- a/HAL-afb/HAL_MOST_UNICENS/ucs2-vol/src/device_value.cpp
+++ /dev/null
@@ -1,148 +0,0 @@
-/*
- * libmostvolume example
- *
- * Copyright (C) 2017 Microchip Technology Germany II GmbH & Co. KG
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- *
- * You may also obtain this software under a propriety license from Microchip.
- * Please contact Microchip for further information.
- *
- */
-#include <stddef.h>
-#include "device_value.h"
-#include "setup.h"
-
-#define MUTE_VALUE 0x03FFU
-#define MUTE_VALUE_HB 0x03U
-#define MUTE_VALUE_LB 0xFFU
-
-#define CONTROL_MASTER 0x07U
-#define CONTROL_CH_1 0x08U
-#define CONTROL_CH_2 0x09U
-
-CDeviceValue::CDeviceValue(uint16_t address, DeviceValueType type, uint16_t key)
-{
- this->_is_available = false;
- this->_is_busy = false;
- this->_address = address;
- this->_target_value = 0x01u;
- this->_actual_value = 0x01u;
-
- this->_result_fptr = NULL;
- this->_result_user_ptr = NULL;
-
- this->_type = type;
- this->_key = key;
-
- _tx_payload[0] = CONTROL_MASTER;// 7: master, 8: channel 1, 9: Channel 2
- _tx_payload[1] = MUTE_VALUE_HB; //HB:Volume
- _tx_payload[2] = MUTE_VALUE_LB; //LB:Volume
- _tx_payload_sz = 3u;
-}
-
-CDeviceValue::~CDeviceValue()
-{
-}
-
-void CDeviceValue::ApplyMostValue(uint8_t value, DeviceValueType type, uint8_t tx_payload[])
-{
- uint16_t tmp = MUTE_VALUE;
-
- switch (type)
- {
- case DEVICE_VAL_LEFT:
- tmp = (uint16_t)(0x80U + 0x37FU - (0x37FU * ((int32_t)value) / (0xFFU)));
- //tmp = 0x3FF - (0x3FF * ((int32_t)value) / (0xFF));
- //tmp = 0x100 + 0x2FF - (0x2FF * ((int32_t)value) / (0xFF));
- tx_payload[0] = CONTROL_CH_1;
- break;
- case DEVICE_VAL_RIGHT:
- tmp = (uint16_t)(0x80U + 0x37FU - (0x37FU * ((int32_t)value) / (0xFFU)));
- //tmp = 0x3FF - (0x3FF * ((int32_t)value) / (0xFF));
- //tmp = 0x100 + 0x2FF - (0x2FF * ((int32_t)value) / (0xFF));
- tx_payload[0] = CONTROL_CH_2;
- break;
- default:
- /*std::cerr << "CDeviceValue::ApplyMostValue() error matching incorrect" << std::endl;*/
- case DEVICE_VAL_MASTER:
- tmp = (uint16_t)(0x100U + 0x2FFU - (0x2FFU * ((int32_t)value) / (0xFFU)));
- tx_payload[0] = CONTROL_MASTER;
- break;
- }
-
- tx_payload[1] = (uint8_t)((tmp >> 8U) & (uint16_t)0xFFU); //HB:Volume
- tx_payload[2] = (uint8_t)(tmp & (uint16_t)0xFFU); //LB:Volume
-}
-
-// returns true if target is not actual value
-bool CDeviceValue::RequiresUpdate()
-{
- if (this->_is_available && !this->_is_busy && (this->_target_value != this->_actual_value))
- {
- return true;
- }
-
- return false;
-}
-
-bool CDeviceValue::FireUpdateMessage(lib_most_volume_writei2c_cb_t writei2c_fptr,
- lib_most_volume_writei2c_result_cb_t result_fptr,
- void *result_user_ptr)
-{
- int ret = -1;
- ApplyMostValue(this->_target_value, _type, _tx_payload);
-
- if (this->_is_available && !this->_is_busy)
- {
- ret = writei2c_fptr(this->_address, &_tx_payload[0], _tx_payload_sz,
- &OnI2cResult,
- this);
-
- if (ret == 0)
- {
- this->_transmitted_value = this->_target_value;
- this->_is_busy = true;
- this->_result_fptr = result_fptr;
- this->_result_user_ptr = result_user_ptr;
- return true;
- }
- }
-
- return false;
-}
-
-void CDeviceValue::HandleI2cResult(uint8_t result)
-{
- if (result == 0)
- {
- /* transmission succeeded - now apply transmitted value */
- this->_actual_value = this->_transmitted_value;
- }
-
- if (this->_result_fptr)
- {
- /* notify container */
- this->_result_fptr(result, this->_result_user_ptr);
- }
-
- this->_result_fptr = NULL;
- this->_result_user_ptr = NULL;
- this->_is_busy = false;
-}
-
-void CDeviceValue::OnI2cResult(uint8_t result, void *obj_ptr)
-{
- ((CDeviceValue*)obj_ptr)->HandleI2cResult(result);
-}
diff --git a/HAL-afb/HAL_MOST_UNICENS/ucs2-vol/src/libmostvolume.cpp b/HAL-afb/HAL_MOST_UNICENS/ucs2-vol/src/libmostvolume.cpp
deleted file mode 100644
index 5eea3fd..0000000
--- a/HAL-afb/HAL_MOST_UNICENS/ucs2-vol/src/libmostvolume.cpp
+++ /dev/null
@@ -1,99 +0,0 @@
-/*
- * libmostvolume example
- *
- * Copyright (C) 2017 Microchip Technology Germany II GmbH & Co. KG
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- *
- * You may also obtain this software under a propriety license from Microchip.
- * Please contact Microchip for further information.
- *
- */
-
-#include "libmostvolume.h"
-#include "setup.h"
-/*#include <iostream>*/
-
-static bool _running = false;
-
-extern "C" uint8_t lib_most_volume_init(lib_most_volume_init_t *init_ptr)
-{
- uint8_t success = 1U;
- /*std::cerr << "lib_most_volume_init(): called" << std::endl;*/
-
- if (!_running && init_ptr)
- {
- CSetup::GetInstance()->Configure(init_ptr);
- success = 0U;
- _running = true;
- }
-
- return success;
-}
-
-extern "C" uint8_t lib_most_volume_exit(void)
-{
- uint8_t success = 1U;
- /*std::cerr << "lib_most_volume_exit(): called" << std::endl;*/
-
- if (_running)
- {
- CSetup::Release();
- success = 0U;
- _running = false;
- }
-
- return success;
-}
-
-extern "C" uint8_t lib_most_volume_set(enum lib_most_volume_channel_t channel, uint8_t volume)
-{
- uint8_t success = 1U;
- /*std::cerr << "lib_most_volume_set(): channel=" << channel << ", volume=" << (int)volume << std::endl;*/
-
- if (_running)
- {
- CSetup::GetInstance()->SetVolume(channel, volume);
- success = 0U;
- }
-
- return success;
-}
-
-extern uint8_t lib_most_volume_node_available(uint16_t address, uint8_t available)
-{
- uint8_t success = 1U;
-
- if (_running)
- {
- CSetup::GetInstance()->SetNodeAvailable(address, available);
- success = 0U;
- }
-
- return success;
-}
-
-extern "C" uint8_t lib_most_volume_service(void)
-{
- uint8_t success = 1U;
- /*std::cerr << "lib_most_volume_service(): called" << std::endl;*/
-
- if (_running)
- {
- CSetup::GetInstance()->Update();
- success = 0U;
- }
-
- return success;
-}
diff --git a/HAL-afb/HAL_MOST_UNICENS/ucs2-vol/src/setup.cpp b/HAL-afb/HAL_MOST_UNICENS/ucs2-vol/src/setup.cpp
deleted file mode 100644
index dd6675b..0000000
--- a/HAL-afb/HAL_MOST_UNICENS/ucs2-vol/src/setup.cpp
+++ /dev/null
@@ -1,94 +0,0 @@
-/*
- * libmostvolume example
- *
- * Copyright (C) 2017 Microchip Technology Germany II GmbH & Co. KG
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- *
- * You may also obtain this software under a propriety license from Microchip.
- * Please contact Microchip for further information.
- *
- */
-#include <stddef.h>
-#include "setup.h"
-
-CSetup* CSetup::_instance = NULL;
-
-// singleton
-CSetup* CSetup::GetInstance() {
- if (_instance == NULL) {
- _instance = new CSetup();
- }
-
- return _instance;
-}
-
-// singleton
-void CSetup::Release() {
- if (_instance != NULL) {
- delete _instance;
- }
- _instance = NULL;
-}
-
-CSetup::CSetup()
- : _volume_amp_270_m(0x270U, DEVICE_VAL_MASTER, LIB_MOST_VOLUME_MASTER),
- _volume_amp_270_l(0x270U, DEVICE_VAL_LEFT, LIB_MOST_VOLUME_CH_FRONT_LEFT),
- _volume_amp_270_r(0x270U, DEVICE_VAL_RIGHT, LIB_MOST_VOLUME_CH_FRONT_RIGHT),
- _volume_amp_271_m(0x271U, DEVICE_VAL_MASTER, LIB_MOST_VOLUME_MASTER),
- _volume_amp_271_l(0x271U, DEVICE_VAL_LEFT, LIB_MOST_VOLUME_CH_REAR_LEFT),
- _volume_amp_271_r(0x271U, DEVICE_VAL_RIGHT, LIB_MOST_VOLUME_CH_REAR_RIGHT),
- _volume_amp_272_m(0x272U, DEVICE_VAL_MASTER, LIB_MOST_VOLUME_MASTER),
- _volume_amp_272_l(0x272U, DEVICE_VAL_LEFT, LIB_MOST_VOLUME_CH_CENTER),
- _volume_amp_272_r(0x272U, DEVICE_VAL_RIGHT, LIB_MOST_VOLUME_CH_SUB),
- _value_container()
-{
- static CDeviceValue* value_list[9] = { &_volume_amp_270_m,
- &_volume_amp_270_l,
- &_volume_amp_270_r,
- &_volume_amp_271_m,
- &_volume_amp_271_l,
- &_volume_amp_271_r,
- &_volume_amp_272_m,
- &_volume_amp_272_l,
- &_volume_amp_272_r};
-
- _value_container.RegisterValues(value_list, 9U);
-}
-
-CSetup::~CSetup()
-{
-
-}
-
-void CSetup::Configure(lib_most_volume_init_t *init_ptr)
-{
- this->init_data = *init_ptr;
- _value_container.AssignService(&this->init_data);
-}
-
-void CSetup::SetVolume(enum lib_most_volume_channel_t channel, uint8_t volume)
-{
- _value_container.SetValue((uint16_t)channel, volume);
-}
-
-void CSetup::Update()
-{
- _value_container.Update();
-}
-
-void CSetup::SetNodeAvailable(uint16_t address, bool available)
-{
- _value_container.ChangeNodeAvailable(address, available);
-}
diff --git a/HAL-afb/HAL_MOST_UNICENS/wrap-json.c b/HAL-afb/HAL_MOST_UNICENS/wrap-json.c
deleted file mode 100644
index 987a008..0000000
--- a/HAL-afb/HAL_MOST_UNICENS/wrap-json.c
+++ /dev/null
@@ -1,940 +0,0 @@
-/*
- Copyright (C) 2016, 2017 "IoT.bzh"
-
- author: José Bollo <jose.bollo@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.
-*/
-
-#include <string.h>
-
-#include "wrap-json.h"
-
-#define STACKCOUNT 32
-#define STRCOUNT 8
-
-enum {
- wrap_json_error_none,
- wrap_json_error_null_object,
- wrap_json_error_truncated,
- wrap_json_error_internal_error,
- wrap_json_error_out_of_memory,
- wrap_json_error_invalid_character,
- wrap_json_error_too_long,
- wrap_json_error_too_deep,
- wrap_json_error_null_spec,
- wrap_json_error_null_key,
- wrap_json_error_null_string,
- wrap_json_error_out_of_range,
- wrap_json_error_incomplete,
- wrap_json_error_missfit_type,
- wrap_json_error_key_not_found,
- _wrap_json_error_count_
-};
-
-static const char ignore_all[] = " \t\n\r,:";
-static const char pack_accept_arr[] = "][{snbiIfoO";
-static const char pack_accept_key[] = "s}";
-#define pack_accept_any (&pack_accept_arr[1])
-
-static const char unpack_accept_arr[] = "*!][{snbiIfFoO";
-static const char unpack_accept_key[] = "*!s}";
-#define unpack_accept_any (&unpack_accept_arr[3])
-
-static const char *pack_errors[_wrap_json_error_count_] =
-{
- [wrap_json_error_none] = "unknown error",
- [wrap_json_error_null_object] = "null object",
- [wrap_json_error_truncated] = "truncated",
- [wrap_json_error_internal_error] = "internal error",
- [wrap_json_error_out_of_memory] = "out of memory",
- [wrap_json_error_invalid_character] = "invalid character",
- [wrap_json_error_too_long] = "too long",
- [wrap_json_error_too_deep] = "too deep",
- [wrap_json_error_null_spec] = "spec is NULL",
- [wrap_json_error_null_key] = "key is NULL",
- [wrap_json_error_null_string] = "string is NULL",
- [wrap_json_error_out_of_range] = "array too small",
- [wrap_json_error_incomplete] = "incomplete container",
- [wrap_json_error_missfit_type] = "missfit of type",
- [wrap_json_error_key_not_found] = "key not found"
-};
-
-int wrap_json_get_error_position(int rc)
-{
- if (rc < 0)
- rc = -rc;
- return (rc >> 4) + 1;
-}
-
-int wrap_json_get_error_code(int rc)
-{
- if (rc < 0)
- rc = -rc;
- return rc & 15;
-}
-
-const char *wrap_json_get_error_string(int rc)
-{
- rc = wrap_json_get_error_code(rc);
- if (rc >= sizeof pack_errors / sizeof *pack_errors)
- rc = 0;
- return pack_errors[rc];
-}
-
-
-
-static inline const char *skip(const char *d)
-{
- while (*d && strchr(ignore_all, *d))
- d++;
- return d;
-}
-
-int wrap_json_vpack(struct json_object **result, const char *desc, va_list args)
-{
- /* TODO: the case of structs with key being single char should be optimized */
- int nstr, notnull, nullable, rc;
- size_t sz, dsz, ssz;
- char *s;
- char c;
- const char *d;
- char buffer[256];
- struct { const char *str; size_t sz; } strs[STRCOUNT];
- struct { struct json_object *cont, *key; const char *acc; char type; } stack[STACKCOUNT], *top;
- struct json_object *obj;
-
- ssz = sizeof buffer;
- s = buffer;
- top = stack;
- top->key = NULL;
- top->cont = NULL;
- top->acc = pack_accept_any;
- top->type = 0;
- d = desc;
- if (!d)
- goto null_spec;
- d = skip(d);
- for(;;) {
- c = *d;
- if (!c)
- goto truncated;
- if (!strchr(top->acc, c))
- goto invalid_character;
- d = skip(++d);
- switch(c) {
- case 's':
- nullable = 0;
- notnull = 0;
- nstr = 0;
- sz = 0;
- for (;;) {
- strs[nstr].str = va_arg(args, const char*);
- if (strs[nstr].str)
- notnull = 1;
- if (*d == '?') {
- d = skip(++d);
- nullable = 1;
- }
- switch(*d) {
- case '%': strs[nstr].sz = va_arg(args, size_t); d = skip(++d); break;
- case '#': strs[nstr].sz = (size_t)va_arg(args, int); d = skip(++d); break;
- default: strs[nstr].sz = strs[nstr].str ? strlen(strs[nstr].str) : 0; break;
- }
- sz += strs[nstr++].sz;
- if (*d == '?') {
- d = skip(++d);
- nullable = 1;
- }
- if (*d != '+')
- break;
- if (nstr >= STRCOUNT)
- goto too_long;
- d = skip(++d);
- }
- if (*d == '*')
- nullable = 1;
- if (notnull) {
- if (sz > ssz) {
- ssz += ssz;
- if (ssz < sz)
- ssz = sz;
- s = alloca(sz);
- }
- dsz = sz;
- while (nstr) {
- nstr--;
- dsz -= strs[nstr].sz;
- memcpy(&s[dsz], strs[nstr].str, strs[nstr].sz);
- }
- obj = json_object_new_string_len(s, (int)sz);
- if (!obj)
- goto out_of_memory;
- } else if (nullable)
- obj = NULL;
- else
- goto null_string;
- break;
- case 'n':
- obj = NULL;
- break;
- case 'b':
- obj = json_object_new_boolean(va_arg(args, int));
- if (!obj)
- goto out_of_memory;
- break;
- case 'i':
- obj = json_object_new_int(va_arg(args, int));
- if (!obj)
- goto out_of_memory;
- break;
- case 'I':
- obj = json_object_new_int64(va_arg(args, int64_t));
- if (!obj)
- goto out_of_memory;
- break;
- case 'f':
- obj = json_object_new_double(va_arg(args, double));
- if (!obj)
- goto out_of_memory;
- break;
- case 'o':
- case 'O':
- obj = va_arg(args, struct json_object*);
- if (*d == '?')
- d = skip(++d);
- else if (*d != '*' && !obj)
- goto null_object;
- if (c == 'O')
- json_object_get(obj);
- break;
- case '[':
- case '{':
- if (++top >= &stack[STACKCOUNT])
- goto too_deep;
- top->key = NULL;
- if (c == '[') {
- top->type = ']';
- top->acc = pack_accept_arr;
- top->cont = json_object_new_array();
- } else {
- top->type = '}';
- top->acc = pack_accept_key;
- top->cont = json_object_new_object();
- }
- if (!top->cont)
- goto out_of_memory;
- continue;
- case '}':
- case ']':
- if (c != top->type || top <= stack)
- goto internal_error;
- obj = (top--)->cont;
- if (*d == '*' && !(c == '}' ? json_object_object_length(obj) : json_object_array_length(obj))) {
- json_object_put(obj);
- obj = NULL;
- }
- break;
- default:
- goto internal_error;
- }
- switch (top->type) {
- case 0:
- if (top != stack)
- goto internal_error;
- if (*d)
- goto invalid_character;
- *result = obj;
- return 0;
- case ']':
- if (obj || *d != '*')
- json_object_array_add(top->cont, obj);
- if (*d == '*')
- d = skip(++d);
- break;
- case '}':
- if (!obj)
- goto null_key;
- top->key = obj;
- top->acc = pack_accept_any;
- top->type = ':';
- break;
- case ':':
- if (obj || *d != '*')
- json_object_object_add(top->cont, json_object_get_string(top->key), obj);
- if (*d == '*')
- d = skip(++d);
- json_object_put(top->key);
- top->key = NULL;
- top->acc = pack_accept_key;
- top->type = '}';
- break;
- default:
- goto internal_error;
- }
- }
-
-null_object:
- rc = wrap_json_error_null_object;
- goto error;
-truncated:
- rc = wrap_json_error_truncated;
- goto error;
-internal_error:
- rc = wrap_json_error_internal_error;
- goto error;
-out_of_memory:
- rc = wrap_json_error_out_of_memory;
- goto error;
-invalid_character:
- rc = wrap_json_error_invalid_character;
- goto error;
-too_long:
- rc = wrap_json_error_too_long;
- goto error;
-too_deep:
- rc = wrap_json_error_too_deep;
- goto error;
-null_spec:
- rc = wrap_json_error_null_spec;
- goto error;
-null_key:
- rc = wrap_json_error_null_key;
- goto error;
-null_string:
- rc = wrap_json_error_null_string;
- goto error;
-error:
- do {
- json_object_put(top->key);
- json_object_put(top->cont);
- } while (--top >= stack);
- *result = NULL;
- rc = rc | (int)((d - desc) << 4);
- return -rc;
-}
-
-int wrap_json_pack(struct json_object **result, const char *desc, ...)
-{
- int rc;
- va_list args;
-
- va_start(args, desc);
- rc = wrap_json_vpack(result, desc, args);
- va_end(args);
- return rc;
-}
-
-static int vunpack(struct json_object *object, const char *desc, va_list args, int store)
-{
- int rc = 0, optionnal, ignore;
- char c, xacc[2] = { 0, 0 };
- const char *acc;
- const char *d, *fit = NULL;
- const char *key = NULL;
- const char **ps = NULL;
- double *pf = NULL;
- int *pi = NULL;
- int64_t *pI = NULL;
- size_t *pz = NULL;
- struct { struct json_object *parent; const char *acc; int index, count; char type; } stack[STACKCOUNT], *top;
- struct json_object *obj;
- struct json_object **po;
-
- xacc[0] = 0;
- ignore = 0;
- top = NULL;
- acc = unpack_accept_any;
- d = desc;
- if (!d)
- goto null_spec;
- d = skip(d);
- obj = object;
- for(;;) {
- fit = d;
- c = *d;
- if (!c)
- goto truncated;
- if (!strchr(acc, c))
- goto invalid_character;
- d = skip(++d);
- switch(c) {
- case 's':
- if (xacc[0] == '}') {
- /* expects a key */
- key = va_arg(args, const char *);
- if (!key)
- goto null_key;
- if (*d != '?')
- optionnal = 0;
- else {
- optionnal = 1;
- d = skip(++d);
- }
- if (ignore)
- ignore++;
- else {
- if (json_object_object_get_ex(top->parent, key, &obj)) {
- /* found */
- top->index++;
- } else {
- /* not found */
- if (!optionnal)
- goto key_not_found;
- ignore = 1;
- obj = NULL;
- }
- }
- xacc[0] = ':';
- acc = unpack_accept_any;
- continue;
- }
- /* get a string */
- if (store)
- ps = va_arg(args, const char **);
- if (!ignore) {
- if (!json_object_is_type(obj, json_type_string))
- goto missfit;
- if (store && ps)
- *ps = json_object_get_string(obj);
- }
- if (*d == '%') {
- d = skip(++d);
- if (store) {
- pz = va_arg(args, size_t *);
- if (!ignore && pz)
- *pz = (size_t)json_object_get_string_len(obj);
- }
- }
- break;
- case 'n':
- if (!ignore && !json_object_is_type(obj, json_type_null))
- goto missfit;
- break;
- case 'b':
- if (store)
- pi = va_arg(args, int *);
-
- if (!ignore) {
- if (!json_object_is_type(obj, json_type_boolean))
- goto missfit;
- if (store && pi)
- *pi = json_object_get_boolean(obj);
- }
- break;
- case 'i':
- if (store)
- pi = va_arg(args, int *);
-
- if (!ignore) {
- if (!json_object_is_type(obj, json_type_int))
- goto missfit;
- if (store && pi)
- *pi = json_object_get_int(obj);
- }
- break;
- case 'I':
- if (store)
- pI = va_arg(args, int64_t *);
-
- if (!ignore) {
- if (!json_object_is_type(obj, json_type_int))
- goto missfit;
- if (store && pI)
- *pI = json_object_get_int64(obj);
- }
- break;
- case 'f':
- case 'F':
- if (store)
- pf = va_arg(args, double *);
-
- if (!ignore) {
- if (!(json_object_is_type(obj, json_type_double) || (c == 'F' && json_object_is_type(obj, json_type_int))))
- goto missfit;
- if (store && pf)
- *pf = json_object_get_double(obj);
- }
- break;
- case 'o':
- case 'O':
- if (store) {
- po = va_arg(args, struct json_object **);
- if (!ignore && po) {
- if (c == 'O')
- obj = json_object_get(obj);
- *po = obj;
- }
- }
- break;
-
- case '[':
- case '{':
- if (!top)
- top = stack;
- else if (++top >= &stack[STACKCOUNT])
- goto too_deep;
-
- top->acc = acc;
- top->type = xacc[0];
- top->index = 0;
- top->parent = obj;
- if (ignore)
- ignore++;
- if (c == '[') {
- if (!ignore) {
- if (!json_object_is_type(obj, json_type_array))
- goto missfit;
- top->count = json_object_array_length(obj);
- }
- xacc[0] = ']';
- acc = unpack_accept_arr;
- } else {
- if (!ignore) {
- if (!json_object_is_type(obj, json_type_object))
- goto missfit;
- top->count = json_object_object_length(obj);
- }
- xacc[0] = '}';
- acc = unpack_accept_key;
- continue;
- }
- break;
- case '}':
- case ']':
- if (!top || c != xacc[0])
- goto internal_error;
- acc = top->acc;
- xacc[0] = top->type;
- top = top == stack ? NULL : top - 1;
- if (ignore)
- ignore--;
- break;
- case '!':
- if (*d != xacc[0])
- goto invalid_character;
- if (!ignore && top->index != top->count)
- goto incomplete;
- /*@fallthrough@*/
- case '*':
- acc = xacc;
- continue;
- default:
- goto internal_error;
- }
- switch (xacc[0]) {
- case 0:
- if (top)
- goto internal_error;
- if (*d)
- goto invalid_character;
- return 0;
- case ']':
- if (!ignore) {
- key = strchr(unpack_accept_arr, *d);
- if (key && key >= unpack_accept_any) {
- if (top->index >= top->count)
- goto out_of_range;
- obj = json_object_array_get_idx(top->parent, top->index++);
- }
- }
- break;
- case ':':
- acc = unpack_accept_key;
- xacc[0] = '}';
- if (ignore)
- ignore--;
- break;
- default:
- goto internal_error;
- }
- }
-truncated:
- rc = wrap_json_error_truncated;
- goto error;
-internal_error:
- rc = wrap_json_error_internal_error;
- goto error;
-invalid_character:
- rc = wrap_json_error_invalid_character;
- goto error;
-too_deep:
- rc = wrap_json_error_too_deep;
- goto error;
-null_spec:
- rc = wrap_json_error_null_spec;
- goto error;
-null_key:
- rc = wrap_json_error_null_key;
- goto error;
-out_of_range:
- rc = wrap_json_error_out_of_range;
- goto error;
-incomplete:
- rc = wrap_json_error_incomplete;
- goto error;
-missfit:
- rc = wrap_json_error_missfit_type;
- goto errorfit;
-key_not_found:
- rc = wrap_json_error_key_not_found;
- goto error;
-errorfit:
- d = fit;
-error:
- rc = rc | (int)((d - desc) << 4);
- return -rc;
-}
-
-int wrap_json_vcheck(struct json_object *object, const char *desc, va_list args)
-{
- return vunpack(object, desc, args, 0);
-}
-
-int wrap_json_check(struct json_object *object, const char *desc, ...)
-{
- int rc;
- va_list args;
-
- va_start(args, desc);
- rc = vunpack(object, desc, args, 0);
- va_end(args);
- return rc;
-}
-
-int wrap_json_vmatch(struct json_object *object, const char *desc, va_list args)
-{
- return !vunpack(object, desc, args, 0);
-}
-
-int wrap_json_match(struct json_object *object, const char *desc, ...)
-{
- int rc;
- va_list args;
-
- va_start(args, desc);
- rc = vunpack(object, desc, args, 0);
- va_end(args);
- return !rc;
-}
-
-int wrap_json_vunpack(struct json_object *object, const char *desc, va_list args)
-{
- return vunpack(object, desc, args, 1);
-}
-
-int wrap_json_unpack(struct json_object *object, const char *desc, ...)
-{
- int rc;
- va_list args;
-
- va_start(args, desc);
- rc = vunpack(object, desc, args, 1);
- va_end(args);
- return rc;
-}
-
-static void object_for_all(struct json_object *object, void (*callback)(void*,struct json_object*,const char*), void *closure)
-{
- struct json_object_iterator it = json_object_iter_begin(object);
- struct json_object_iterator end = json_object_iter_end(object);
- while (!json_object_iter_equal(&it, &end)) {
- callback(closure, json_object_iter_peek_value(&it), json_object_iter_peek_name(&it));
- json_object_iter_next(&it);
- }
-}
-
-static void array_for_all(struct json_object *object, void (*callback)(void*,struct json_object*), void *closure)
-{
- int n = json_object_array_length(object);
- int i = 0;
- while(i < n)
- callback(closure, json_object_array_get_idx(object, i++));
-}
-
-void wrap_json_optarray_for_all(struct json_object *object, void (*callback)(void*,struct json_object*), void *closure)
-{
- if (json_object_is_type(object, json_type_array))
- array_for_all(object, callback, closure);
- else
- callback(closure, object);
-}
-
-void wrap_json_array_for_all(struct json_object *object, void (*callback)(void*,struct json_object*), void *closure)
-{
- if (json_object_is_type(object, json_type_array))
- array_for_all(object, callback, closure);
-}
-
-void wrap_json_object_for_all(struct json_object *object, void (*callback)(void*,struct json_object*,const char*), void *closure)
-{
- if (json_object_is_type(object, json_type_object))
- object_for_all(object, callback, closure);
-}
-
-void wrap_json_optobject_for_all(struct json_object *object, void (*callback)(void*,struct json_object*,const char*), void *closure)
-{
- if (json_object_is_type(object, json_type_object))
- object_for_all(object, callback, closure);
- else
- callback(closure, object, NULL);
-}
-
-void wrap_json_for_all(struct json_object *object, void (*callback)(void*,struct json_object*,const char*), void *closure)
-{
- if (!object)
- /* do nothing */;
- else if (json_object_is_type(object, json_type_object))
- object_for_all(object, callback, closure);
- else if (!json_object_is_type(object, json_type_array))
- callback(closure, object, NULL);
- else {
- int n = json_object_array_length(object);
- int i = 0;
- while(i < n)
- callback(closure, json_object_array_get_idx(object, i++), NULL);
- }
-}
-
-#if defined(WRAP_JSON_TEST)
-#include <stdio.h>
-
-void p(const char *desc, ...)
-{
- int rc;
- va_list args;
- struct json_object *result;
-
- va_start(args, desc);
- rc = wrap_json_vpack(&result, desc, args);
- va_end(args);
- if (!rc)
- printf(" SUCCESS %s\n\n", json_object_to_json_string(result));
- else
- printf(" ERROR[char %d err %d] %s\n\n", wrap_json_get_error_position(rc), wrap_json_get_error_code(rc), wrap_json_get_error_string(rc));
- json_object_put(result);
-}
-
-const char *xs[10];
-int *xi[10];
-int64_t *xI[10];
-double *xf[10];
-struct json_object *xo[10];
-size_t xz[10];
-
-void u(const char *value, const char *desc, ...)
-{
- unsigned m, k;
- int rc;
- va_list args;
- struct json_object *obj, *o;
-
- memset(xs, 0, sizeof xs);
- memset(xi, 0, sizeof xi);
- memset(xI, 0, sizeof xI);
- memset(xf, 0, sizeof xf);
- memset(xo, 0, sizeof xo);
- memset(xz, 0, sizeof xz);
- obj = json_tokener_parse(value);
- va_start(args, desc);
- rc = wrap_json_vunpack(obj, desc, args);
- va_end(args);
- if (rc)
- printf(" ERROR[char %d err %d] %s\n\n", wrap_json_get_error_position(rc), wrap_json_get_error_code(rc), wrap_json_get_error_string(rc));
- else {
- value = NULL;
- printf(" SUCCESS");
- va_start(args, desc);
- k = m = 0;
- while(*desc) {
- switch(*desc) {
- case '{': m = (m << 1) | 1; k = 1; break;
- case '}': m = m >> 1; k = m&1; break;
- case '[': m = m << 1; k = 0; break;
- case ']': m = m >> 1; k = m&1; break;
- case 's': printf(" s:%s", k ? va_arg(args, const char*) : *(va_arg(args, const char**)?:&value)); k ^= m&1; break;
- case '%': printf(" %%:%zu", *va_arg(args, size_t*)); k = m&1; break;
- case 'n': printf(" n"); k = m&1; break;
- case 'b': printf(" b:%d", *va_arg(args, int*)); k = m&1; break;
- case 'i': printf(" i:%d", *va_arg(args, int*)); k = m&1; break;
- case 'I': printf(" I:%lld", *va_arg(args, int64_t*)); k = m&1; break;
- case 'f': printf(" f:%f", *va_arg(args, double*)); k = m&1; break;
- case 'F': printf(" F:%f", *va_arg(args, double*)); k = m&1; break;
- case 'o': printf(" o:%s", json_object_to_json_string(*va_arg(args, struct json_object**))); k = m&1; break;
- case 'O': o = *va_arg(args, struct json_object**); printf(" O:%s", json_object_to_json_string(o)); json_object_put(o); k = m&1; break;
- default: break;
- }
- desc++;
- }
- va_end(args);
- printf("\n\n");
- }
- json_object_put(obj);
-}
-
-#define P(...) do{ printf("pack(%s)\n",#__VA_ARGS__); p(__VA_ARGS__); } while(0)
-#define U(...) do{ printf("unpack(%s)\n",#__VA_ARGS__); u(__VA_ARGS__); } while(0)
-
-int main()
-{
- char buffer[4] = {'t', 'e', 's', 't'};
-
- P("n");
- P("b", 1);
- P("b", 0);
- P("i", 1);
- P("I", (uint64_t)0x123456789abcdef);
- P("f", 3.14);
- P("s", "test");
- P("s?", "test");
- P("s?", NULL);
- P("s#", "test asdf", 4);
- P("s%", "test asdf", (size_t)4);
- P("s#", buffer, 4);
- P("s%", buffer, (size_t)4);
- P("s++", "te", "st", "ing");
- P("s#+#+", "test", 1, "test", 2, "test");
- P("s%+%+", "test", (size_t)1, "test", (size_t)2, "test");
- P("{}", 1.0);
- P("[]", 1.0);
- P("o", json_object_new_int(1));
- P("o?", json_object_new_int(1));
- P("o?", NULL);
- P("O", json_object_new_int(1));
- P("O?", json_object_new_int(1));
- P("O?", NULL);
- P("{s:[]}", "foo");
- P("{s+#+: []}", "foo", "barbar", 3, "baz");
- P("{s:s,s:o,s:O}", "a", NULL, "b", NULL, "c", NULL);
- P("{s:**}", "a", NULL);
- P("{s:s*,s:o*,s:O*}", "a", NULL, "b", NULL, "c", NULL);
- P("[i,i,i]", 0, 1, 2);
- P("[s,o,O]", NULL, NULL, NULL);
- P("[**]", NULL);
- P("[s*,o*,O*]", NULL, NULL, NULL);
- P(" s ", "test");
- P("[ ]");
- P("[ i , i, i ] ", 1, 2, 3);
- P("{\n\n1");
- P("[}");
- P("{]");
- P("[");
- P("{");
- P("[i]a", 42);
- P("ia", 42);
- P("s", NULL);
- P("+", NULL);
- P(NULL);
- P("{s:i}", NULL, 1);
- P("{ {}: s }", "foo");
- P("{ s: {}, s:[ii{} }", "foo", "bar", 12, 13);
- P("[[[[[ [[[[[ [[[[ }]]]] ]]]] ]]]]]");
-
- U("true", "b", &xi[0]);
- U("false", "b", &xi[0]);
- U("null", "n");
- U("42", "i", &xi[0]);
- U("123456789", "I", &xI[0]);
- U("3.14", "f", &xf[0]);
- U("12345", "F", &xf[0]);
- U("3.14", "F", &xf[0]);
- U("\"foo\"", "s", &xs[0]);
- U("\"foo\"", "s%", &xs[0], &xz[0]);
- U("{}", "{}");
- U("[]", "[]");
- U("{}", "o", &xo[0]);
- U("{}", "O", &xo[0]);
- U("{\"foo\":42}", "{si}", "foo", &xi[0]);
- U("[1,2,3]", "[i,i,i]", &xi[0], &xi[1], &xi[2]);
- U("{\"a\":1,\"b\":2,\"c\":3}", "{s:i, s:i, s:i}", "a", &xi[0], "b", &xi[1], "c", &xi[2]);
- U("42", "z");
- U("null", "[i]");
- U("[]", "[}");
- U("{}", "{]");
- U("[]", "[");
- U("{}", "{");
- U("[42]", "[i]a", &xi[0]);
- U("42", "ia", &xi[0]);
- U("[]", NULL);
- U("\"foo\"", "s", NULL);
- U("42", "s", NULL);
- U("42", "n");
- U("42", "b", NULL);
- U("42", "f", NULL);
- U("42", "[i]", NULL);
- U("42", "{si}", "foo", NULL);
- U("\"foo\"", "n");
- U("\"foo\"", "b", NULL);
- U("\"foo\"", "i", NULL);
- U("\"foo\"", "I", NULL);
- U("\"foo\"", "f", NULL);
- U("\"foo\"", "F", NULL);
- U("true", "s", NULL);
- U("true", "n");
- U("true", "i", NULL);
- U("true", "I", NULL);
- U("true", "f", NULL);
- U("true", "F", NULL);
- U("[42]", "[ii]", &xi[0], &xi[1]);
- U("{\"foo\":42}", "{si}", NULL, &xi[0]);
- U("{\"foo\":42}", "{si}", "baz", &xi[0]);
- U("[1,2,3]", "[iii!]", &xi[0], &xi[1], &xi[2]);
- U("[1,2,3]", "[ii!]", &xi[0], &xi[1]);
- U("[1,2,3]", "[ii]", &xi[0], &xi[1]);
- U("[1,2,3]", "[ii*]", &xi[0], &xi[1]);
- U("{\"foo\":42,\"baz\":45}", "{sisi}", "baz", &xi[0], "foo", &xi[1]);
- U("{\"foo\":42,\"baz\":45}", "{sisi*}", "baz", &xi[0], "foo", &xi[1]);
- U("{\"foo\":42,\"baz\":45}", "{sisi!}", "baz", &xi[0], "foo", &xi[1]);
- U("{\"foo\":42,\"baz\":45}", "{si}", "baz", &xi[0], "foo", &xi[1]);
- U("{\"foo\":42,\"baz\":45}", "{si*}", "baz", &xi[0], "foo", &xi[1]);
- U("{\"foo\":42,\"baz\":45}", "{si!}", "baz", &xi[0], "foo", &xi[1]);
- U("[1,{\"foo\":2,\"bar\":null},[3,4]]", "[i{sisn}[ii]]", &xi[0], "foo", &xi[1], "bar", &xi[2], &xi[3]);
- U("[1,2,3]", "[ii!i]", &xi[0], &xi[1], &xi[2]);
- U("[1,2,3]", "[ii*i]", &xi[0], &xi[1], &xi[2]);
- U("{\"foo\":1,\"bar\":2}", "{si!si}", "foo", &xi[1], "bar", &xi[2]);
- U("{\"foo\":1,\"bar\":2}", "{si*si}", "foo", &xi[1], "bar", &xi[2]);
- U("{\"foo\":{\"baz\":null,\"bar\":null}}", "{s{sn!}}", "foo", "bar");
- U("[[1,2,3]]", "[[ii!]]", &xi[0], &xi[1]);
- U("{}", "{s?i}", "foo", &xi[0]);
- U("{\"foo\":1}", "{s?i}", "foo", &xi[0]);
- U("{}", "{s?[ii]s?{s{si!}}}", "foo", &xi[0], &xi[1], "bar", "baz", "quux", &xi[2]);
- U("{\"foo\":[1,2]}", "{s?[ii]s?{s{si!}}}", "foo", &xi[0], &xi[1], "bar", "baz", "quux", &xi[2]);
- U("{\"bar\":{\"baz\":{\"quux\":15}}}", "{s?[ii]s?{s{si!}}}", "foo", &xi[0], &xi[1], "bar", "baz", "quux", &xi[2]);
- U("{\"foo\":{\"bar\":4}}", "{s?{s?i}}", "foo", "bar", &xi[0]);
- U("{\"foo\":{}}", "{s?{s?i}}", "foo", "bar", &xi[0]);
- U("{}", "{s?{s?i}}", "foo", "bar", &xi[0]);
- U("{\"foo\":42,\"baz\":45}", "{s?isi!}", "baz", &xi[0], "foo", &xi[1]);
- U("{\"foo\":42}", "{s?isi!}", "baz", &xi[0], "foo", &xi[1]);
- return 0;
-}
-
-#endif
-
-#if 0
-
-
- /* Unpack the same item twice */
- j = json_pack("{s:s, s:i, s:b}", "foo", "bar", "baz", 42, "quux", 1);
- if(!json_unpack_ex(j, &error, 0, "{s:s,s:s!}", "foo", &s, "foo", &s))
- fail("json_unpack object with strict validation failed");
- {
- const char *possible_errors[] = {
- "2 object item(s) left unpacked: baz, quux",
- "2 object item(s) left unpacked: quux, baz"
- };
- check_errors(possible_errors, 2, "<validation>", 1, 10, 10);
- }
- json_decref(j);
-
-#endif
- \ No newline at end of file
diff --git a/HAL-afb/HAL_MOST_UNICENS/wrap-json.h b/HAL-afb/HAL_MOST_UNICENS/wrap-json.h
deleted file mode 100644
index b5eadf5..0000000
--- a/HAL-afb/HAL_MOST_UNICENS/wrap-json.h
+++ /dev/null
@@ -1,47 +0,0 @@
-/*
- Copyright (C) 2016, 2017 "IoT.bzh"
-
- author: José Bollo <jose.bollo@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.
-*/
-
-#pragma once
-
-#include <stdarg.h>
-#include <json-c/json.h>
-
-extern int wrap_json_get_error_position(int rc);
-extern int wrap_json_get_error_code(int rc);
-extern const char *wrap_json_get_error_string(int rc);
-
-extern int wrap_json_vpack(struct json_object **result, const char *desc, va_list args);
-extern int wrap_json_pack(struct json_object **result, const char *desc, ...);
-
-extern int wrap_json_vunpack(struct json_object *object, const char *desc, va_list args);
-extern int wrap_json_unpack(struct json_object *object, const char *desc, ...);
-extern int wrap_json_vcheck(struct json_object *object, const char *desc, va_list args);
-extern int wrap_json_check(struct json_object *object, const char *desc, ...);
-extern int wrap_json_vmatch(struct json_object *object, const char *desc, va_list args);
-extern int wrap_json_match(struct json_object *object, const char *desc, ...);
-
-extern void wrap_json_optarray_for_all(struct json_object *object, void (*callback)(void*,struct json_object*), void *closure);
-extern void wrap_json_array_for_all(struct json_object *object, void (*callback)(void*,struct json_object*), void *closure);
-
-extern void wrap_json_optarray_for_all(struct json_object *object, void (*callback)(void*,struct json_object*), void *closure);
-extern void wrap_json_array_for_all(struct json_object *object, void (*callback)(void*,struct json_object*), void *closure);
-extern void wrap_json_object_for_all(struct json_object *object, void (*callback)(void*,struct json_object*,const char*), void *closure);
-extern void wrap_json_optobject_for_all(struct json_object *object, void (*callback)(void*,struct json_object*,const char*), void *closure);
-extern void wrap_json_for_all(struct json_object *object, void (*callback)(void*,struct json_object*,const char*), void *closure);
-
- \ No newline at end of file
diff --git a/HAL-afb/HAL_MOST_UNICENS/wrap-json.md b/HAL-afb/HAL_MOST_UNICENS/wrap-json.md
deleted file mode 100644
index 3718b66..0000000
--- a/HAL-afb/HAL_MOST_UNICENS/wrap-json.md
+++ /dev/null
@@ -1,306 +0,0 @@
-WRAP-JSON facility
-==================
-
-The facility wrap-json is based on the pack/unpack API on the
-libray jansson. The two chapters below are copied from the
-documentation of jansson library copyrighted by Petri Lehtinen
-(see at end).
-
-Building Values
----------------
-
-This section describes functions that help to create, or *pack*, complex
-JSON values, especially nested objects and arrays. Value building is
-based on a *format string* that is used to tell the functions about the
-expected arguments.
-
-For example, the format string `"i"` specifies a single integer value,
-while the format string `"[ssb]"` or the equivalent `"[s, s, b]"`
-specifies an array value with two strings and a boolean as its items:
-
- /* Create the JSON integer 42 */
- wrap_json_pack(&result, "i", 42);
-
- /* Create the JSON array ["foo", "bar", true] */
- wrap_json_pack(&result, "[ssb]", "foo", "bar", 1);
-
-Here's the full list of format specifiers. The type in parentheses
-denotes the resulting JSON type, and the type in brackets (if any)
-denotes the C type that is expected as the corresponding argument or
-arguments.
-
-`s` (string) \[const char \*\]
-
-: Convert a null terminated UTF-8 string to a JSON string.
-
-`s?` (string) \[const char \*\]
-
-: Like `s`, but if the argument is *NULL*, output a JSON null value.
-
-`s*` (string) \[const char \*\]
-
-: Like `s`, but if the argument is *NULL*, do not output any value.
- This format can only be used inside an object or an array. If used
- inside an object, the corresponding key is additionally suppressed
- when the value is omitted. See below for an example.
-
-`s#` (string) \[const char \*, int\]
-
-: Convert a UTF-8 buffer of a given length to a JSON string.
-
-`s%` (string) \[const char \*, size\_t\]
-
-: Like `s#` but the length argument is of type size\_t.
-
-`+` \[const char \*\]
-
-: Like `s`, but concatenate to the previous string. Only valid after
- `s`, `s#`, `+` or `+#`.
-
-`+#` \[const char \*, int\]
-
-: Like `s#`, but concatenate to the previous string. Only valid after
- `s`, `s#`, `+` or `+#`.
-
-`+%` (string) \[const char \*, size\_t\]
-
-: Like `+#` but the length argument is of type size\_t.
-
-`n` (null)
-
-: Output a JSON null value. No argument is consumed.
-
-`b` (boolean) \[int\]
-
-: Convert a C int to JSON boolean value. Zero is converted to `false`
- and non-zero to `true`.
-
-`i` (integer) \[int\]
-
-: Convert a C int to JSON integer.
-
-`I` (integer) \[json\_int\_t\]
-
-: Convert a C json\_int\_t to JSON integer.
-
-`f` (real) \[double\]
-
-: Convert a C double to JSON real.
-
-`o` (any value) \[json\_t \*\]
-
-: Output any given JSON value as-is. If the value is added to an array
- or object, the reference to the value passed to `o` is stolen by the
- container.
-
-`O` (any value) \[json\_t \*\]
-
-: Like `o`, but the argument's reference count is incremented. This is
- useful if you pack into an array or object and want to keep the
- reference for the JSON value consumed by `O` to yourself.
-
-`o?`, `O?` (any value) \[json\_t \*\]
-
-: Like `o` and `O`, respectively, but if the argument is *NULL*,
- output a JSON null value.
-
-`o*`, `O*` (any value) \[json\_t \*\]
-
-: Like `o` and `O`, respectively, but if the argument is *NULL*, do
- not output any value. This format can only be used inside an object
- or an array. If used inside an object, the corresponding key is
- additionally suppressed. See below for an example.
-
-`[fmt]` (array)
-
-: Build an array with contents from the inner format string. `fmt` may
- contain objects and arrays, i.e. recursive value building is
- supported.
-
-`{fmt}` (object)
-
-: Build an object with contents from the inner format string `fmt`.
- The first, third, etc. format specifier represent a key, and must be
- a string (see `s`, `s#`, `+` and `+#` above), as object keys are
- always strings. The second, fourth, etc. format specifier represent
- a value. Any value may be an object or array, i.e. recursive value
- building is supported.
-
-Whitespace, `:` and `,` are ignored.
-
-More examples:
-
- /* Build an empty JSON object */
- wrap_json_pack(&result, "{}");
-
- /* Build the JSON object {"foo": 42, "bar": 7} */
- wrap_json_pack(&result, "{sisi}", "foo", 42, "bar", 7);
-
- /* Like above, ':', ',' and whitespace are ignored */
- wrap_json_pack(&result, "{s:i, s:i}", "foo", 42, "bar", 7);
-
- /* Build the JSON array [[1, 2], {"cool": true}] */
- wrap_json_pack(&result, "[[i,i],{s:b}]", 1, 2, "cool", 1);
-
- /* Build a string from a non-null terminated buffer */
- char buffer[4] = {'t', 'e', 's', 't'};
- wrap_json_pack(&result, "s#", buffer, 4);
-
- /* Concatenate strings together to build the JSON string "foobarbaz" */
- wrap_json_pack(&result, "s++", "foo", "bar", "baz");
-
- /* Create an empty object or array when optional members are missing */
- wrap_json_pack(&result, "{s:s*,s:o*,s:O*}", "foo", NULL, "bar", NULL, "baz", NULL);
- wrap_json_pack(&result, "[s*,o*,O*]", NULL, NULL, NULL);
-
-Parsing and Validating Values
------------------------------
-
-This section describes functions that help to validate complex values
-and extract, or *unpack*, data from them. Like building values
-&lt;apiref-pack&gt;, this is also based on format strings.
-
-While a JSON value is unpacked, the type specified in the format string
-is checked to match that of the JSON value. This is the validation part
-of the process. In addition to this, the unpacking functions can also
-check that all items of arrays and objects are unpacked. This check be
-enabled with the format specifier `!` or by using the flag
-`JSON_STRICT`. See below for details.
-
-Here's the full list of format specifiers. The type in parentheses
-denotes the JSON type, and the type in brackets (if any) denotes the C
-type whose address should be passed.
-
-`s` (string) \[const char \*\]
-
-: Convert a JSON string to a pointer to a null terminated UTF-8
- string. The resulting string is extracted by using
- json\_string\_value() internally, so it exists as long as there are
- still references to the corresponding JSON string.
-
-`s%` (string) \[const char \*, size\_t \*\]
-
-: Convert a JSON string to a pointer to a null terminated UTF-8 string
- and its length.
-
-`n` (null)
-
-: Expect a JSON null value. Nothing is extracted.
-
-`b` (boolean) \[int\]
-
-: Convert a JSON boolean value to a C int, so that `true` is converted
- to 1 and `false` to 0.
-
-`i` (integer) \[int\]
-
-: Convert a JSON integer to C int.
-
-`I` (integer) \[json\_int\_t\]
-
-: Convert a JSON integer to C json\_int\_t.
-
-`f` (real) \[double\]
-
-: Convert a JSON real to C double.
-
-`F` (integer or real) \[double\]
-
-: Convert a JSON number (integer or real) to C double.
-
-`o` (any value) \[json\_t \*\]
-
-: Store a JSON value with no conversion to a json\_t pointer.
-
-`O` (any value) \[json\_t \*\]
-
-: Like `O`, but the JSON value's reference count is incremented.
-
-`[fmt]` (array)
-
-: Convert each item in the JSON array according to the inner format
- string. `fmt` may contain objects and arrays, i.e. recursive value
- extraction is supported.
-
-`{fmt}` (object)
-
-: Convert each item in the JSON object according to the inner format
- string `fmt`. The first, third, etc. format specifier represent a
- key, and must be `s`. The corresponding argument to unpack functions
- is read as the object key. The second fourth, etc. format specifier
- represent a value and is written to the address given as the
- corresponding argument. **Note** that every other argument is read
- from and every other is written to.
-
- `fmt` may contain objects and arrays as values, i.e. recursive value
- extraction is supported.
-
-`!`
-
-: This special format specifier is used to enable the check that all
- object and array items are accessed, on a per-value basis. It must
- appear inside an array or object as the last format specifier before
- the closing bracket or brace.
-
-`*`
-
-: This special format specifier is the opposite of `!`. This is the default.
- It must appear inside an array or object as the last format specifier
- before the closing bracket or brace.
-
-Whitespace, `:` and `,` are ignored.
-
-Examples:
-
- /* root is the JSON integer 42 */
- int myint;
- wrap_json_unpack(root, "i", &myint);
- assert(myint == 42);
-
- /* root is the JSON object {"foo": "bar", "quux": true} */
- const char *str;
- int boolean;
- wrap_json_unpack(root, "{s:s, s:b}", "foo", &str, "quux", &boolean);
- assert(strcmp(str, "bar") == 0 && boolean == 1);
-
- /* root is the JSON array [[1, 2], {"baz": null} */
- wrap_json_check(root, "[[i,i], {s:n}]", "baz");
- /* returns 0 for validation success, nothing is extracted */
-
- /* root is the JSON array [1, 2, 3, 4, 5] */
- int myint1, myint2;
- wrap_json_unpack(root, "[ii!]", &myint1, &myint2);
- /* returns -1 for failed validation */
-
- /* root is an empty JSON object */
- int myint = 0, myint2 = 0, myint3 = 0;
- wrap_json_unpack(root, "{s?i, s?[ii]}",
- "foo", &myint1,
- "bar", &myint2, &myint3);
- /* myint1, myint2 or myint3 is no touched as "foo" and "bar" don't exist */
-
-
-Copyright
----------
-
-Copyright (c) 2009-2016 Petri Lehtinen <petri@digip.org>
-
-Permission is hereby granted, free of charge, to any person obtaining a copy
-of this software and associated documentation files (the "Software"), to deal
-in the Software without restriction, including without limitation the rights
-to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
-copies of the Software, and to permit persons to whom the Software is
-furnished to do so, subject to the following conditions:
-
-The above copyright notice and this permission notice shall be included in
-all copies or substantial portions of the Software.
-
-THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
-AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
-LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
-OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
-THE SOFTWARE.
-
- \ No newline at end of file
diff --git a/HAL-afb/HAL_MOST_UNICENS/wrap_unicens.c b/HAL-afb/HAL_MOST_UNICENS/wrap_unicens.c
deleted file mode 100644
index 095a2fe..0000000
--- a/HAL-afb/HAL_MOST_UNICENS/wrap_unicens.c
+++ /dev/null
@@ -1,336 +0,0 @@
-/*
- * Copyright (C) 2017, Microchip Technology Inc. and its subsidiaries.
- * Author Tobias Jahnke
- *
- * 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
-#define AFB_BINDING_VERSION 2
-
-#include <string.h>
-#include <json-c/json.h>
-#include <afb/afb-binding.h>
-#include "wrap_unicens.h"
-#include "wrap-json.h"
-
-typedef struct async_job_ {
- wrap_ucs_result_cb_t result_fptr;
- void *result_user_ptr;
-} async_job_t;
-
-typedef struct parse_result_ {
- int done;
- char *str_result;
-} parse_result_t;
-
-/* Subscribes to unicens2-binding events.
- * \return Returns 0 if successful, otherwise != 0".
- */
-extern int wrap_ucs_subscribe_sync() {
-
- json_object *j_response, *j_query = NULL;
- int err;
-
- /* Build an empty JSON object */
- err = wrap_json_pack(&j_query, "{}");
- if (err) {
- AFB_ERROR("Failed to create subscribe json object");
- goto OnErrorExit;
- }
-
- err = afb_service_call_sync("UNICENS", "subscribe", j_query, &j_response);
- if (err) {
- AFB_ERROR("Fail subscribing to UNICENS events");
- goto OnErrorExit;
- }
- else {
- AFB_NOTICE("Subscribed to UNICENS events, res=%s", json_object_to_json_string(j_response));
- json_object_put(j_response);
- }
- json_object_put(j_query);
- j_query = NULL;
-
-OnErrorExit:
- if (j_query)
- json_object_put(j_query);
- return err;
-}
-
-/* Checks if name ends with a given letter. */
-static int wrap_ucs_string_ends_with(const char *name, char letter) {
-
- int result = 0;
- size_t len = strlen(name);
-
- if (len > 0) {
-
- if (name[len] == letter) {
- result = 1;
- }
- }
-
- return result;
-}
-
-/* Callback for iteration through found files. Marks search as "done" as
- * soon as the search pattern "kit.xml" matches.
- * \param closure User reference. Points to parse_result_t.
- * \param j_obj Points to json object within array.
- */
-static void wrap_ucs_find_xml_cb(void *closure, struct json_object *j_obj) {
-
- const char *dir, *name;
- parse_result_t *result;
-
- if (!closure)
- return;
-
- result = (parse_result_t *)closure;
- if (result->done)
- return;
-
- wrap_json_unpack(j_obj, "{s:s, s:s}", "dirpath", &dir, "basename", &name);
- AFB_DEBUG("Found file: %s", name);
-
- if(strstr(name, "kit.xml") != NULL) {
- size_t sz = strlen(dir)+strlen(name)+10;
- char * full_path = malloc(sz);
-
- strncpy(full_path, dir, sz);
-
- if (!wrap_ucs_string_ends_with(dir, '/'))
- strncat(full_path, "/", sz);
-
- strncat(full_path, name, sz);
- AFB_DEBUG("Found XML file: %s", full_path);
-
- result->done = 1;
- result->str_result = full_path;
- }
-}
-
-/* Retrieves XML configuration path to initialize unicens2-binding.
- * \param config_path Directory containing XML configuration file(s).
- * \param file_found Points to found file_path or NULL if not found.
- * Memory must be released by calling free().
- * \return Returns 0 if successful, otherwise != 0".
- */
-extern int wrap_ucs_getconfig_sync(const char *config_path, char **file_found) {
-
- int err = 0;
- json_object *j_response, *j_query, *j_paths = NULL;
- parse_result_t result = {.done = 0, .str_result = NULL};
-
- *file_found = NULL;
-
- /* Build JSON object to retrieve UNICENS configuration */
- if ((config_path == NULL) || (strcmp(config_path, "") == 0))
- err = wrap_json_pack(&j_query, "{}");
- else
- err = wrap_json_pack(&j_query, "{s:s}", "cfgpath", config_path);
-
- if (err) {
- AFB_ERROR("Failed to create listconfig json object");
- goto OnErrorExit;
- }
-
- err = afb_service_call_sync("UNICENS", "listconfig", j_query, &j_response);
- if (err) {
- AFB_ERROR("Failed to call listconfig");
- goto OnErrorExit;
- }
- else {
- AFB_DEBUG("UNICENS listconfig result, res=%s", json_object_to_json_string(j_response));
-
- if (json_object_object_get_ex(j_response, "response", &j_paths)) {
-
- AFB_DEBUG("UNICENS listconfig result, paths=%s", json_object_to_json_string(j_paths));
-
- wrap_json_optarray_for_all(j_paths, &wrap_ucs_find_xml_cb, &result);
-
- if (result.done) {
- *file_found = strdup(result.str_result);
- free(result.str_result);
- result.str_result = NULL;
- }
- else {
- AFB_NOTICE("wrap_ucs_getconfig_sync, search pattern does not match for paths=%s", json_object_to_json_string(j_paths));
- err = -1;
- }
- }
-
- json_object_put(j_response);
- }
- json_object_put(j_query);
- j_query = NULL;
-
-OnErrorExit:
- if (j_query)
- json_object_put(j_query);
- return err;
-}
-
-/* Initializes the unicens2-binding.
- * \param file_name Path to XML configuration file or \c NULL for
- * first found file in default path.
- * \return Returns 0 if successful, otherwise != 0".
- */
-extern int wrap_ucs_initialize_sync(const char *file_name) {
- json_object *j_response, *j_query = NULL;
- int err;
-
- /* Build JSON object to initialize UNICENS */
- if (file_name != NULL)
- err = wrap_json_pack(&j_query, "{s:s}", "filename", file_name);
- else
- err = wrap_json_pack(&j_query, "{}");
-
- if (err) {
- AFB_ERROR("Failed to create initialize json object");
- goto OnErrorExit;
- }
- err = afb_service_call_sync("UNICENS", "initialise", j_query, &j_response);
- if (err) {
- AFB_ERROR("Failed to initialize UNICENS");
- goto OnErrorExit;
- }
- else {
- AFB_NOTICE("Initialized UNICENS, res=%s", json_object_to_json_string(j_response));
- json_object_put(j_response);
- }
-
- json_object_put(j_query);
- j_query = NULL;
-
-OnErrorExit:
- if (j_query)
- json_object_put(j_query);
- return err;
-}
-
-/* Write I2C command to a network node.
- * \param node Node address
- * \param data_ptr Reference to command data
- * \param data_sz Size of the command data. Valid values: 1..32.
- * \return Returns 0 if successful, otherwise != 0".
- */
-extern int wrap_ucs_i2cwrite_sync(uint16_t node, uint8_t *data_ptr, uint8_t data_sz) {
-
- json_object *j_response, *j_query, *j_array = NULL;
- int err;
- uint8_t cnt;
-
- j_query = json_object_new_object();
- j_array = json_object_new_array();
-
- if (!j_query || !j_array) {
- err = -1;
- AFB_ERROR("Failed to create writei2c json objects");
- goto OnErrorExit;
- }
-
- for (cnt = 0U; cnt < data_sz; cnt++) {
- json_object_array_add(j_array, json_object_new_int(data_ptr[cnt]));
- }
-
- json_object_object_add(j_query, "node", json_object_new_int(node));
- json_object_object_add(j_query, "data", j_array);
-
- err = afb_service_call_sync("UNICENS", "writei2c", j_query, &j_response);
-
- if (err) {
- AFB_ERROR("Failed to call writei2c_sync");
- goto OnErrorExit;
- }
- else {
- AFB_INFO("Called writei2c_sync, res=%s", json_object_to_json_string(j_response));
- json_object_put(j_response);
- }
-
- json_object_put(j_query);
- j_query = NULL;
-
-OnErrorExit:
- if (j_query)
- json_object_put(j_query);
- return err;
-}
-
-/* ------------------ ASYNCHRONOUS API ---------------------------------------*/
-
-static void wrap_ucs_i2cwrite_cb(void *closure, int status, struct json_object *j_result) {
-
- AFB_INFO("wrap_ucs_i2cwrite_cb: closure=%p status=%d, res=%s", closure, status, json_object_to_json_string(j_result));
-
- if (closure) {
- async_job_t *job_ptr = (async_job_t *)closure;
-
- if (job_ptr->result_fptr)
- job_ptr->result_fptr((uint8_t)abs(status), job_ptr->result_user_ptr);
-
- free(closure);
- }
-}
-
-/* Write I2C command to a network node.
- * \param node Node address
- * \param data_ptr Reference to command data
- * \param data_sz Size of the command data. Valid values: 1..32.
- * \return Returns 0 if successful, otherwise != 0".
- */
-extern int wrap_ucs_i2cwrite(uint16_t node, uint8_t *data_ptr, uint8_t data_sz,
- wrap_ucs_result_cb_t result_fptr,
- void *result_user_ptr) {
-
- json_object *j_query, *j_array = NULL;
- async_job_t *job_ptr = NULL;
- int err;
- uint8_t cnt;
-
- j_query = json_object_new_object();
- j_array = json_object_new_array();
-
- if (!j_query || !j_array) {
- err = -1;
- AFB_ERROR("Failed to create writei2c json objects");
- goto OnErrorExit;
- }
-
- for (cnt = 0U; cnt < data_sz; cnt++) {
- json_object_array_add(j_array, json_object_new_int(data_ptr[cnt]));
- }
-
- json_object_object_add(j_query, "node", json_object_new_int(node));
- json_object_object_add(j_query, "data", j_array);
-
- job_ptr = malloc(sizeof(async_job_t));
-
- if (!job_ptr) {
- err = -1;
- AFB_ERROR("Failed to create async job object");
- goto OnErrorExit;
- }
-
- job_ptr->result_fptr = result_fptr;
- job_ptr->result_user_ptr = result_user_ptr;
-
- afb_service_call("UNICENS", "writei2c", j_query, wrap_ucs_i2cwrite_cb, job_ptr);
- err = 0;
- j_query = NULL;
-
-OnErrorExit:
- if (j_query)
- json_object_put(j_query);
- return err;
-}
diff --git a/HAL-afb/HAL_MOST_UNICENS/wrap_unicens.h b/HAL-afb/HAL_MOST_UNICENS/wrap_unicens.h
deleted file mode 100644
index c28d13a..0000000
--- a/HAL-afb/HAL_MOST_UNICENS/wrap_unicens.h
+++ /dev/null
@@ -1,34 +0,0 @@
-/*
- * Copyright (C) 2017, Microchip Technology Inc. and its subsidiaries.
- * Author Tobias Jahnke
- *
- * 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.
- *
- */
-
-#pragma once
-#include <stdint.h>
-
-/* Asynchronous API: result callback */
-typedef void (*wrap_ucs_result_cb_t)(uint8_t result, void *user_ptr);
-
-/* Asynchronous API: functions */
-extern int wrap_ucs_i2cwrite(uint16_t node, uint8_t *data_ptr, uint8_t data_sz,
- wrap_ucs_result_cb_t result_fptr,
- void *result_user_ptr);
-
-/* Synchronous API: functions */
-extern int wrap_ucs_subscribe_sync();
-extern int wrap_ucs_getconfig_sync(const char *config_path, char **file_found);
-extern int wrap_ucs_initialize_sync(const char* file_name);
-extern int wrap_ucs_i2cwrite_sync(uint16_t node, uint8_t *data_ptr, uint8_t data_sz);
diff --git a/HAL-afb/HAL_MOST_UNICENS/wrap_volume.c b/HAL-afb/HAL_MOST_UNICENS/wrap_volume.c
deleted file mode 100644
index 5bc1e84..0000000
--- a/HAL-afb/HAL_MOST_UNICENS/wrap_volume.c
+++ /dev/null
@@ -1,132 +0,0 @@
-/*
- * Copyright (C) 2017, Microchip Technology Inc. and its subsidiaries.
- * Author Tobias Jahnke
- *
- * 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
-#define AFB_BINDING_VERSION 2
-
-#include <string.h>
-#include <time.h>
-#include <assert.h>
-#include <json-c/json.h>
-#include <afb/afb-binding.h>
-
-#include "wrap_volume.h"
-#include "wrap_unicens.h"
-#include "libmostvolume.h"
-
-static int wrap_volume_service_timeout_cb(sd_event_source* source,
- uint64_t timer __attribute__((__unused__)),
- void *userdata __attribute__((__unused__))) {
-
- uint8_t ret;
-
- sd_event_source_unref(source);
- ret = lib_most_volume_service();
-
- if (ret != 0U) {
- AFB_ERROR("lib_most_volume_service returns %d", ret);
- }
-
- return 0;
-}
-
-static void wrap_volume_service_cb(uint16_t timeout) {
- uint64_t usec;
- sd_event_now(afb_daemon_get_event_loop(), CLOCK_BOOTTIME, &usec);
- sd_event_add_time( afb_daemon_get_event_loop(), NULL, CLOCK_MONOTONIC,
- usec + (timeout*1000),
- 250,
- wrap_volume_service_timeout_cb,
- NULL);
-}
-
-/* Retrieves a new value adapted to a new maximum value. Minimum value is
- * always zero. */
-static int wrap_volume_calculate(int value, int max_old, int max_new) {
-
- if (value > max_old)
- value = max_old;
-
- value = (value * max_new) / max_old; /* calculate range: 0..255 */
- assert(value <= max_new);
-
- return value;
-}
-
-extern int wrap_volume_init(void) {
-
- uint8_t ret = 0U;
- lib_most_volume_init_t mv_init;
-
- mv_init.writei2c_cb = &wrap_ucs_i2cwrite;
- mv_init.service_cb = wrap_volume_service_cb;
-
- ret = lib_most_volume_init(&mv_init);
-
- return ret * (-1);
-}
-
-extern int wrap_volume_master(int volume) {
-
- int new_value, ret;
-
- new_value = wrap_volume_calculate(volume, 100, 255);
- ret = lib_most_volume_set(LIB_MOST_VOLUME_MASTER, (uint8_t)new_value);
-
- if (ret != 0) {
- AFB_ERROR("wrap_volume_master: volume library not ready.");
- ret = ret * (-1); /* make return value negative */
- }
-
- return ret;
-}
-
-extern int wrap_volume_pcm(int *volume_ptr, int volume_sz) {
-
- const int MAX_PCM_CHANNELS = 6;
- int cnt, ret;
- assert(volume_ptr != NULL);
- assert(volume_sz <= MAX_PCM_CHANNELS);
-
- for (cnt = 0; cnt < volume_sz; cnt ++) {
-
- int new_value = wrap_volume_calculate(volume_ptr[cnt], 100, 255);
- ret = lib_most_volume_set((enum lib_most_volume_channel_t)cnt, (uint8_t)new_value);
-
- if (ret != 0) {
- AFB_ERROR("wrap_volume_pcm: volume library not ready.");
- ret = ret * (-1); /* make return value negative */
- break;
- }
- }
-
- return ret;
-}
-
-extern int wrap_volume_node_avail(int node, int available) {
-
- int ret;
- ret = lib_most_volume_node_available((uint16_t)node, (uint8_t)available);
-
- if (ret != 0) {
- AFB_ERROR("wrap_volume_node_avail: volume library not ready.");
- ret = ret * (-1); /* make return value negative */
- }
-
- return ret;
-}
-
diff --git a/HAL-afb/HAL_MOST_UNICENS/wrap_volume.h b/HAL-afb/HAL_MOST_UNICENS/wrap_volume.h
deleted file mode 100644
index 099b70c..0000000
--- a/HAL-afb/HAL_MOST_UNICENS/wrap_volume.h
+++ /dev/null
@@ -1,26 +0,0 @@
-/*
- * Copyright (C) 2017, Microchip Technology Inc. and its subsidiaries.
- * Author Tobias Jahnke
- *
- * 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.
- *
- */
-
-#pragma once
-#include <stdint.h>
-#include <systemd/sd-event.h>
-
-extern int wrap_volume_init(void);
-extern int wrap_volume_master(int volume);
-extern int wrap_volume_pcm(int *volume_ptr, int volume_sz);
-extern int wrap_volume_node_avail(int node, int available);
diff --git a/HAL-afb/HDA-intel/CMakeLists.txt b/HAL-afb/HDA-intel/CMakeLists.txt
deleted file mode 100644
index 380e493..0000000
--- a/HAL-afb/HDA-intel/CMakeLists.txt
+++ /dev/null
@@ -1,39 +0,0 @@
-###########################################################################
-# Copyright 2015, 2016, 2017 IoT.bzh
-#
-# author: Fulup Ar Foll <fulup@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(hal-intel-hda)
-
- # Define project Targets
- ADD_LIBRARY(${TARGET_NAME} MODULE IntelHdaHAL.c)
-
- # Binder exposes a unique public entry point
- SET_TARGET_PROPERTIES(${TARGET_NAME} PROPERTIES
- PREFIX "afb-"
- LABELS "BINDING"
- LINK_FLAGS ${BINDINGS_LINK_FLAG}
- OUTPUT_NAME ${TARGET_NAME}
- )
-
- # Library dependencies (include updates automatically)
- TARGET_LINK_LIBRARIES(${TARGET_NAME}
- hal-interface
- audio-common
- )
-
diff --git a/HAL-afb/HDA-intel/IntelHdaHAL.c b/HAL-afb/HDA-intel/IntelHdaHAL.c
deleted file mode 100644
index d41b6ba..0000000
--- a/HAL-afb/HDA-intel/IntelHdaHAL.c
+++ /dev/null
@@ -1,123 +0,0 @@
-/*
- * Copyright (C) 2016 "IoT.bzh"
- * Author Fulup Ar Foll <fulup@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.
- *
- *
- * To find out which control your sound card uses
- * aplay -l # Check sndcard name name in between []
- * amixer -D hw:xx controls # get supported controls
- * amixer -D "hw:3" cget numid=xx # get control settings
- *
- */
-#define _GNU_SOURCE
-#include "hal-interface.h"
-#include "audio-common.h"
-
-
-// Define few private tag for not standard functions
-#define PCM_Volume_Multimedia 1000
-#define PCM_Volume_Navigation 1001
-#define PCM_Volume_Emergency 1002
-
-// Default Values for MasterVolume Ramping
-STATIC halVolRampT volRampMaster= {
- .mode = RAMP_VOL_NORMAL,
- .slave = Master_Playback_Volume,
- .delay = 100*1000, // ramping delay in us
- .stepDown=1,
- .stepUp =1,
-};
-
-STATIC halVolRampT volRampMultimedia= {
- .slave = PCM_Volume_Multimedia,
- .delay = 100*1000, // ramping delay in us
- .stepDown= 2,
- .stepUp = 1,
-};
-
-STATIC halVolRampT volRampNavigation= {
- .slave = PCM_Volume_Navigation,
- .delay = 100*1000, // ramping delay in us
- .stepDown= 4,
- .stepUp = 2,
-};
-// Default Values for MasterVolume Ramping
-STATIC halVolRampT volRampEmergency= {
- .slave = PCM_Volume_Emergency,
- .delay = 50*1000, // ramping delay in us
- .stepDown= 6,
- .stepUp = 3,
-};
-
-// Map HAL hight sndctl with Alsa numid and optionally with a custom callback for non Alsa supported functionalities.
-STATIC alsaHalMapT alsaHalMap[]= {
- { .tag=Master_Playback_Volume, . ctl={.name="PCM Playback Volume", .value=50 } },
- { .tag=PCM_Playback_Volume , .ctl={.name="PCM Playback Volume", .value=50 } },
- { .tag=PCM_Playback_Switch , .ctl={.name="PCM Playback Switch", .value=01 } },
- { .tag=Capture_Volume , .ctl={.name="Mic Capture Volume" } },
-
- // Sound card does not have hardware volume ramping
- { .tag=Master_Playback_Ramp , .cb={.callback=volumeRamp, .handle=&volRampMaster}, .info="ramp volume linearly according to current ramp setting",
- .ctl={.numid=CTL_AUTO, .type=SND_CTL_ELEM_TYPE_INTEGER, .count=1, .minval=0, .maxval=100, .step=1, .name="Rampup Master"}
- },
-
- // Implement Rampup Volume for Virtual Channels
- { .tag=Navigation_Playback_Volume, .cb={.callback=volumeRamp, .handle=&volRampNavigation}, .info="RampUp Navigation Volume",
- .ctl={.numid=CTL_AUTO, .type=SND_CTL_ELEM_TYPE_INTEGER,.name="Playback Navigation Ramp", .value=80 }
- },
- { .tag=Emergency_Playback_Volume, .cb={.callback=volumeRamp, .handle=&volRampEmergency}, .info="Rampup Emergency Volume",
- .ctl={.numid=CTL_AUTO, .type=SND_CTL_ELEM_TYPE_INTEGER,.name="Playback Emergency Ramp", .value=80 }
- },
-
- // Sound Card does not support hardware channel volume mixer (note softvol default range 0-256)
- { .tag=Multimedia_Playback_Volume, .cb={.callback=volumeRamp, .handle=&volRampMultimedia}, .info="Ramp-up Multimedia Volume",
- .ctl={.numid=CTL_AUTO, .type=SND_CTL_ELEM_TYPE_INTEGER, .name="Playback Multimedia Ramp", .value=80 }
- },
- { .tag=PCM_Volume_Multimedia, .info="Playback Multimedia Softvol",
- .ctl={.numid=CTL_AUTO, .type=SND_CTL_ELEM_TYPE_INTEGER, .count=2, .maxval=255, .value=200, .name="Playback Multimedia"}
- },
- { .tag=PCM_Volume_Navigation, .info="Playback Navigation Softvol",
- .ctl={.numid=CTL_AUTO, .type=SND_CTL_ELEM_TYPE_INTEGER, .count=2, .maxval=255,.value=200, .name="Playback Navigation"}
- },
- { .tag=PCM_Volume_Emergency, .info="Playback Emergency Softvol",
- .ctl={.numid=CTL_AUTO, .type=SND_CTL_ELEM_TYPE_INTEGER, .count=2, .maxval=255, .value=200, .name="Playback Emergency"}
- },
-
-
- { .tag=EndHalCrlTag} /* marker for end of the array */
-} ;
-
-// HAL sound card mapping info
-STATIC alsaHalSndCardT alsaHalSndCard = {
- .name = "HDA Intel PCH", // WARNING: name MUST match with 'aplay -l'
- .info = "Hardware Abstraction Layer for IntelHDA sound card",
- .ctls = alsaHalMap,
-};
-
-STATIC int sndServiceInit() {
- int err;
- AFB_DEBUG("IntelHal Binding Init");
-
- err = halServiceInit(afbBindingV2.api, &alsaHalSndCard);
- return err;
-}
-
-// API prefix should be unique for each snd card
-PUBLIC const struct afb_binding_v2 afbBindingV2 = {
- .api = "intel-hda",
- .init = sndServiceInit,
- .verbs = halServiceApi,
- .onevent = halServiceEvent,
-};
diff --git a/HAL-afb/Jabra-Solemate/CMakeLists.txt b/HAL-afb/Jabra-Solemate/CMakeLists.txt
deleted file mode 100644
index d2705b0..0000000
--- a/HAL-afb/Jabra-Solemate/CMakeLists.txt
+++ /dev/null
@@ -1,39 +0,0 @@
-###########################################################################
-# Copyright 2015, 2016, 2017 IoT.bzh
-#
-# author: Fulup Ar Foll <fulup@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(hal-jabra-usb)
-
- # Define project Targets
- ADD_LIBRARY(${TARGET_NAME} MODULE JabraUsbHAL.c)
-
- # Binder exposes a unique public entry point
- SET_TARGET_PROPERTIES(${TARGET_NAME} PROPERTIES
- PREFIX "afb-"
- LABELS "BINDING"
- LINK_FLAGS ${BINDINGS_LINK_FLAG}
- OUTPUT_NAME ${TARGET_NAME}
- )
-
- # Library dependencies (include updates automatically)
- TARGET_LINK_LIBRARIES(${TARGET_NAME}
- hal-interface
- audio-common
- ${link_libraries}
- )
diff --git a/HAL-afb/Jabra-Solemate/JabraUsbHAL.c b/HAL-afb/Jabra-Solemate/JabraUsbHAL.c
deleted file mode 100644
index a9c5c63..0000000
--- a/HAL-afb/Jabra-Solemate/JabraUsbHAL.c
+++ /dev/null
@@ -1,123 +0,0 @@
-/*
- * Copyright (C) 2016 "IoT.bzh"
- * Author Fulup Ar Foll <fulup@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.
- *
- *
- * To find out which control your sound card uses
- * aplay -l # Check sndcard name name in between []
- * amixer -D hw:v1340 controls # get supported controls
- * amixer -Dhw:v1340 cget name=Power-Switch
- * amixer -Dhw:v1340 cset name=Power-Switch true
- *
- */
-#define _GNU_SOURCE
-#include "hal-interface.h"
-#include "audio-common.h"
-
-// Define few private tag for not standard functions
-#define PCM_Volume_Multimedia 1000
-#define PCM_Volume_Navigation 1001
-#define PCM_Volume_Emergency 1002
-
-// Default Values for MasterVolume Ramping
-STATIC halVolRampT volRampMaster= {
- .mode = RAMP_VOL_NORMAL,
- .slave = Master_Playback_Volume,
- .delay = 100*1000, // ramping delay in us
- .stepDown=1,
- .stepUp =1,
-};
-
-STATIC halVolRampT volRampMultimedia= {
- .slave = PCM_Volume_Multimedia,
- .delay = 100*1000, // ramping delay in us
- .stepDown= 2,
- .stepUp = 1,
-};
-
-STATIC halVolRampT volRampNavigation= {
- .slave = PCM_Volume_Navigation,
- .delay = 100*1000, // ramping delay in us
- .stepDown= 4,
- .stepUp = 2,
-};
-// Default Values for MasterVolume Ramping
-STATIC halVolRampT volRampEmergency= {
- .slave = PCM_Volume_Emergency,
- .delay = 50*1000, // ramping delay in us
- .stepDown= 6,
- .stepUp = 3,
-};
-
-// Map HAL hight sndctl with Alsa numid and optionally with a custom callback for non Alsa supported functionalities.
-STATIC alsaHalMapT alsaHalMap[]= {
- { .tag=Master_Playback_Volume, . ctl={.name="PCM Playback Volume", .value=12 }},
- { .tag=PCM_Playback_Volume , .ctl={.name="PCM Playback Volume", .value=12 }},
- { .tag=PCM_Playback_Switch , .ctl={.name="PCM Playback Switch", .value=01 }},
- { .tag=Capture_Volume , .ctl={.name="Mic Capture Volume" }},
-
- // Sound card does not have hardware volume ramping
- { .tag=Master_Playback_Ramp , .cb={.callback=volumeRamp, .handle=&volRampMaster}, .info="ramp volume linearly according to current ramp setting",
- .ctl={.numid=CTL_AUTO, .type=SND_CTL_ELEM_TYPE_INTEGER, .count=1, .minval=0, .maxval=100, .step=1, .name="Rampup Master"}
- },
-
- // Implement Rampup Volume for Virtual Channels
- { .tag=Navigation_Playback_Volume, .cb={.callback=volumeRamp, .handle=&volRampNavigation}, .info="RampUp Navigation Volume",
- .ctl={.numid=CTL_AUTO, .type=SND_CTL_ELEM_TYPE_INTEGER,.name="Playback Navigation Ramp", .value=80 }
- },
- { .tag=Emergency_Playback_Volume, .cb={.callback=volumeRamp, .handle=&volRampEmergency}, .info="Rampup Emergency Volume",
- .ctl={.numid=CTL_AUTO, .type=SND_CTL_ELEM_TYPE_INTEGER,.name="Playback Emergency Ramp", .value=80 }
- },
-
- // Sound Card does not support hardware channel volume mixer (note softvol default range 0-256)
- { .tag=Multimedia_Playback_Volume, .cb={.callback=volumeRamp, .handle=&volRampMultimedia}, .info="Ramp-up Multimedia Volume",
- .ctl={.numid=CTL_AUTO, .type=SND_CTL_ELEM_TYPE_INTEGER, .name="Playback Multimedia Ramp", .value=80 }
- },
- { .tag=PCM_Volume_Multimedia, .info="Playback Multimedia Softvol",
- .ctl={.numid=CTL_AUTO, .type=SND_CTL_ELEM_TYPE_INTEGER, .count=2, .maxval=255, .value=200, .name="Playback Multimedia"}
- },
- { .tag=PCM_Volume_Navigation, .info="Playback Navigation Softvol",
- .ctl={.numid=CTL_AUTO, .type=SND_CTL_ELEM_TYPE_INTEGER, .count=2, .maxval=255,.value=200, .name="Playback Navigation"}
- },
- { .tag=PCM_Volume_Emergency, .info="Playback Emergency Softvol",
- .ctl={.numid=CTL_AUTO, .type=SND_CTL_ELEM_TYPE_INTEGER, .count=2, .maxval=255, .value=200, .name="Playback Emergency"}
- },
-
-
- { .tag=EndHalCrlTag} /* marker for end of the array */
-} ;
-
-// HAL sound card mapping info
-STATIC alsaHalSndCardT alsaHalSndCard = {
- .name = "Jabra SOLEMATE v1.34.0", // WARNING: name MUST match with 'aplay -l'
- .info = "Hardware Abstraction Layer for Jabra Solamte USB speakers",
- .ctls = alsaHalMap,
- .volumeCB = NULL, // use default volume normalisation function
-};
-
-
-STATIC int sndServiceInit () {
- int err;
- err = halServiceInit (afbBindingV2.api, &alsaHalSndCard);
- return err;
-}
-
-// API prefix should be unique for each snd card
-PUBLIC const struct afb_binding_v2 afbBindingV2 = {
- .api = "jabra-usb",
- .init = sndServiceInit,
- .verbs = halServiceApi,
- .onevent = halServiceEvent,
-};
diff --git a/HAL-afb/Scarlett-Focusrite/CMakeLists.txt b/HAL-afb/Scarlett-Focusrite/CMakeLists.txt
deleted file mode 100644
index d2a1742..0000000
--- a/HAL-afb/Scarlett-Focusrite/CMakeLists.txt
+++ /dev/null
@@ -1,38 +0,0 @@
-###########################################################################
-# Copyright 2015, 2016, 2017 IoT.bzh
-#
-# author: Fulup Ar Foll <fulup@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(hal-scalett-usb)
-
- # Define project Targets
- ADD_LIBRARY(${TARGET_NAME} MODULE ScarlettUsbHAL.c)
-
- # Binder exposes a unique public entry point
- SET_TARGET_PROPERTIES(${TARGET_NAME} PROPERTIES
- PREFIX "afb-"
- LABELS "BINDING"
- LINK_FLAGS ${BINDINGS_LINK_FLAG}
- OUTPUT_NAME ${TARGET_NAME}
- )
-
- # Library dependencies (include updates automatically)
- TARGET_LINK_LIBRARIES(${TARGET_NAME}
- hal-interface
- audio-common
- )
diff --git a/HAL-afb/Scarlett-Focusrite/ScarlettUsbHAL.c b/HAL-afb/Scarlett-Focusrite/ScarlettUsbHAL.c
deleted file mode 100644
index cff213c..0000000
--- a/HAL-afb/Scarlett-Focusrite/ScarlettUsbHAL.c
+++ /dev/null
@@ -1,90 +0,0 @@
-/*
- * Copyright (C) 2016 "IoT.bzh"
- * Author Fulup Ar Foll <fulup@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.
- *
- *
- * To find out which control your sound card uses
- * aplay -l # Check sndcard name name in between []
- * amixer -D hw:USB controls # get supported controls
- * amixer -Dhw:USB cget name=Power-Switch
- * amixer -Dhw:USB cset name=Power-Switch true
- *
- */
-#define _GNU_SOURCE
-#include "hal-interface.h"
-#include "audio-common.h"
-
-// Default Values for MasterVolume Ramping
-STATIC halVolRampT volRampMaster= {
- .mode = RAMP_VOL_NORMAL,
- .slave = Master_Playback_Volume,
- .delay = 100*1000, // ramping delay in us
- .stepDown=1,
- .stepUp =1,
-};
-
-// Map HAL hight sndctl with Alsa numid and optionally with a custom callback for non Alsa supported functionalities.
-STATIC alsaHalMapT alsaHalMap[]= {
- { .tag=Master_Playback_Volume, . ctl={.name="Master Playback Volume" } },
- { .tag=PCM_Playback_Volume , .ctl={.name="Master 1 (Monitor) Playback Volume" } },
- { .tag=PCM_Playback_Switch , .ctl={.numid=05 } },
- { .tag=Capture_Volume , .ctl={.numid=12 } },
-
- { .tag=Vol_Ramp_Set_Mode , .cb={.callback=volumeRamp, .handle=&volRampMaster}, .info="select volramp speed",
- .ctl={.numid=0, .type=SND_CTL_ELEM_TYPE_ENUMERATED, .count=1, .value=RAMP_VOL_NORMAL, .name="Hal-VolRamp-Mode", .enums=halVolRampModes}
- },
- { .tag=Vol_Ramp_Set_Slave , .cb={.callback=volumeRamp, .handle=&volRampMaster}, .info="set slave volume master numid",
- .ctl={.numid=0, .type=SND_CTL_ELEM_TYPE_INTEGER, .count=1, .value=Master_Playback_Volume, .name="Hal-VolRamp-Slave", .enums=halVolRampModes}
- },
- { .tag=Vol_Ramp_Set_Delay , .cb={.callback=volumeRamp, .handle=&volRampMaster}, .info="set ramp delay [default 250ms]",
- .ctl={.numid=0, .type=SND_CTL_ELEM_TYPE_INTEGER, .count=1, .minval=0, .maxval=1000, .step=100, .value=250, .name="Hal-VolRamp-Step-Down"}
- },
- { .tag=Vol_Ramp_Set_Down , .cb={.callback=volumeRamp, .handle=&volRampMaster}, .info="set linear step down ramp [default 10]",
- .ctl={.numid=0, .type=SND_CTL_ELEM_TYPE_INTEGER, .count=1, .minval=0, .maxval=100, .step=1, .value=10, .name="Hal-VolRamp-Step-Down"}
- },
- { .tag=Vol_Ramp_Set_Up , .cb={.callback=volumeRamp, .handle=&volRampMaster}, .info="set linear step up ramp [default 10]",
- .ctl={.numid=0, .type=SND_CTL_ELEM_TYPE_INTEGER, .count=1, .minval=0, .maxval=100, .step=1, .value=10, .name="Hal-VolRamp-Step-Up"}
- },
- { .tag=Master_Playback_Volume , .cb={.callback=volumeRamp, .handle=&volRampMaster}, .info="ramp volume linearly according to current ramp setting",
- .ctl={.numid=0, .type=SND_CTL_ELEM_TYPE_INTEGER, .count=1, .minval=0, .maxval=100, .step=1, .name="Hal-VolRamp"}
- },
-
- { .tag=EndHalCrlTag} /* marker for end of the array */
-} ;
-
-// HAL sound card mapping info
-STATIC alsaHalSndCardT alsaHalSndCard = {
- .name = "Scarlett 18i8 USB", // WARNING: name MUST match with 'aplay -l'
- .info = "Hardware Abstraction Layer for Scarlett Focusrite USB professional music sound card",
- .ctls = alsaHalMap,
- .volumeCB = NULL, // use default volume normalisation function
-};
-
-
-STATIC int sndServiceInit () {
- int err;
- AFB_DEBUG ("Scarlett Binding Init");
-
- err = halServiceInit (afbBindingV2.api, &alsaHalSndCard);
- return err;
-}
-
-// API prefix should be unique for each snd card
-PUBLIC const struct afb_binding_v2 afbBindingV2 = {
- .api = "scarlett-usb",
- .init = sndServiceInit,
- .verbs = halServiceApi,
- .onevent = halServiceEvent,
-};
diff --git a/afb-utilities b/afb-utilities
-Subproject be1205fd4ab6bd20dd9bc44ed63c35d999ece76
+Subproject fd86e75feab42c0d0676a80e9aa415fa507e9a5
diff --git a/Alsa-afb/Alsa-AddCtl.c b/alsa-binding/Alsa-AddCtl.c
index aaa9347..3f969c1 100644
--- a/Alsa-afb/Alsa-AddCtl.c
+++ b/alsa-binding/Alsa-AddCtl.c
@@ -83,7 +83,7 @@ static const unsigned int *allocate_int_linear_tlv(int max, int min) {
return tlv;
}
-STATIC json_object * addOneSndCtl(afb_req request, snd_ctl_t *ctlDev, json_object *ctlJ, halQueryMode queryMode) {
+STATIC json_object * addOneSndCtl(afb_req request, snd_ctl_t *ctlDev, json_object *ctlJ, queryModeE queryMode) {
int err, done, ctlNumid, ctlValue=0, shouldCreate;
json_object *tmpJ;
const char *ctlName;
@@ -356,7 +356,7 @@ PUBLIC void alsaAddCustomCtls(afb_req request) {
}
// get verbosity level
- halQueryMode queryMode = QUERY_QUIET;
+ queryModeE queryMode = QUERY_QUIET;
mode = afb_req_value(request, "mode");
if (mode != NULL) {
sscanf(mode, "%i", (int*) &queryMode);
diff --git a/Alsa-afb/Alsa-ApiHat.c b/alsa-binding/Alsa-ApiHat.c
index e5172de..6f27c84 100644
--- a/Alsa-afb/Alsa-ApiHat.c
+++ b/alsa-binding/Alsa-ApiHat.c
@@ -30,6 +30,11 @@
#include "Alsa-ApiHat.h"
+STATIC void pingtest(struct afb_req request) {
+ json_object *query = afb_req_json(request);
+ afb_req_success(request, query, NULL);
+}
+
STATIC int AlsaInit(void) {
int rc= prctl(PR_SET_NAME, "afb-aaaa-agent",NULL,NULL,NULL);
if (rc) AFB_ERROR("ERROR: AlsaCore fail to rename process");
diff --git a/Alsa-afb/Alsa-ApiHat.h b/alsa-binding/Alsa-ApiHat.h
index bd70740..c0e1a1a 100644
--- a/Alsa-afb/Alsa-ApiHat.h
+++ b/alsa-binding/Alsa-ApiHat.h
@@ -22,7 +22,25 @@
#include <alsa/asoundlib.h>
#include <systemd/sd-event.h>
-#include "audio-common.h"
+
+#define AFB_BINDING_VERSION 2
+#include <afb/afb-binding.h>
+#include <json-c/json.h>
+#include <filescan-utils.h>
+#include <wrap-json.h>
+
+// Waiting for official macro from José
+#define AFB_GET_VERBOSITY afb_get_verbosity_v2()
+
+// Soft control have dynamically allocated numid
+#define CTL_AUTO -1
+
+typedef enum {
+ QUERY_QUIET =0,
+ QUERY_COMPACT =1,
+ QUERY_VERBOSE =2,
+ QUERY_FULL =3,
+} queryModeE;
typedef enum {
ACTION_SET,
@@ -33,7 +51,7 @@ typedef enum {
typedef struct {
const char *devid;
json_object *numidsJ;
- halQueryMode mode;
+ queryModeE mode;
int count;
} queryValuesT;
@@ -50,7 +68,7 @@ extern const struct afb_binding_interface *afbIface;
PUBLIC json_object *alsaCheckQuery (struct afb_req request, queryValuesT *queryValues);
// AlseCoreSetGet exports
-PUBLIC int alsaGetSingleCtl (snd_ctl_t *ctlDev, snd_ctl_elem_id_t *elemId, ctlRequestT *ctlRequest, halQueryMode queryMode);
+PUBLIC int alsaGetSingleCtl (snd_ctl_t *ctlDev, snd_ctl_elem_id_t *elemId, ctlRequestT *ctlRequest, queryModeE queryMode);
PUBLIC void alsaGetInfo (struct afb_req request);
PUBLIC void alsaGetCtls(struct afb_req request);
PUBLIC void alsaSetCtls(struct afb_req request);
diff --git a/Alsa-afb/Alsa-RegEvt.c b/alsa-binding/Alsa-RegEvt.c
index 41db207..41db207 100644
--- a/Alsa-afb/Alsa-RegEvt.c
+++ b/alsa-binding/Alsa-RegEvt.c
diff --git a/Alsa-afb/Alsa-SetGet.c b/alsa-binding/Alsa-SetGet.c
index f70c5d6..2083a53 100644
--- a/Alsa-afb/Alsa-SetGet.c
+++ b/alsa-binding/Alsa-SetGet.c
@@ -520,7 +520,7 @@ OnErrorExit:
// process ALSA control and store then into ctlRequest
-PUBLIC int alsaGetSingleCtl(snd_ctl_t *ctlDev, snd_ctl_elem_id_t *elemId, ctlRequestT *ctlRequest, halQueryMode queryMode) {
+PUBLIC int alsaGetSingleCtl(snd_ctl_t *ctlDev, snd_ctl_elem_id_t *elemId, ctlRequestT *ctlRequest, queryModeE queryMode) {
snd_ctl_elem_type_t elemType;
snd_ctl_elem_value_t *elemData;
snd_ctl_elem_info_t *elemInfo;
diff --git a/Alsa-afb/Alsa-Ucm.c b/alsa-binding/Alsa-Ucm.c
index 0bfffc9..0bfffc9 100644
--- a/Alsa-afb/Alsa-Ucm.c
+++ b/alsa-binding/Alsa-Ucm.c
diff --git a/Alsa-afb/CMakeLists.txt b/alsa-binding/CMakeLists.txt
index a608a80..9e3129c 100644
--- a/Alsa-afb/CMakeLists.txt
+++ b/alsa-binding/CMakeLists.txt
@@ -17,7 +17,7 @@
###########################################################################
# Add target to project dependency list
-PROJECT_TARGET_ADD(alsa-lowlevel)
+PROJECT_TARGET_ADD(alsa-4a)
# Define project Targets
ADD_LIBRARY(${TARGET_NAME} MODULE Alsa-ApiHat.c Alsa-SetGet.c Alsa-Ucm.c Alsa-AddCtl.c Alsa-RegEvt.c)
@@ -32,7 +32,7 @@ PROJECT_TARGET_ADD(alsa-lowlevel)
# Library dependencies (include updates automatically)
TARGET_LINK_LIBRARIES(${TARGET_NAME}
- audio-common
+ afb-utilities
${link_libraries}
)
diff --git a/Alsa-afb/README.md b/alsa-binding/README.md
index 93d2d4d..93d2d4d 100644
--- a/Alsa-afb/README.md
+++ b/alsa-binding/README.md
diff --git a/conf.d/app-templates b/conf.d/app-templates
-Subproject b5fb4364e02d4d3db339e966c69cbe1177f4f52
+Subproject 6230618d8e66dc4902e43e7e85fa03317f209a0
diff --git a/conf.d/autobuild/agl/autobuild b/conf.d/autobuild/agl/autobuild
index 4811441..3a1ba5f 100755
--- a/conf.d/autobuild/agl/autobuild
+++ b/conf.d/autobuild/agl/autobuild
@@ -29,8 +29,9 @@ help:
@echo "- clean"
@echo "- distclean"
@echo "- configure"
- @echo "- build"
- @echo "- package"
+ @echo "- build: compilation, link and prepare files for package into a widget"
+ @echo "- package: output a widget file '*.wgt'"
+ @echo "- install: install in your ${CMAKE_INSTALL_DIR} directory"
@echo ""
@echo "Usage: ./conf.d/autobuild/agl/autobuild package DEST=${HOME}/opt"
@echo "Don't use your build dir as DEST as wgt file is generated at this location"
@@ -58,6 +59,9 @@ package: build
@cmake --build ${BUILD_DIR} --target widget
@mkdir -p ${DEST} && cp ${BUILD_DIR}/*wgt ${DEST}
+install: build
+ @cmake --build ${BUILD_DIR} --target install
+
${BUILD_DIR}/Makefile:
@[ -d ${BUILD_DIR} ] || mkdir -p ${BUILD_DIR}
@[ -f ${BUILD_DIR}/Makefile ] || (cd ${BUILD_DIR} && cmake ${CONFIGURE_ARGS} ..)
diff --git a/conf.d/autobuild/linux/autobuild b/conf.d/autobuild/linux/autobuild
index 4811441..3a1ba5f 100755
--- a/conf.d/autobuild/linux/autobuild
+++ b/conf.d/autobuild/linux/autobuild
@@ -29,8 +29,9 @@ help:
@echo "- clean"
@echo "- distclean"
@echo "- configure"
- @echo "- build"
- @echo "- package"
+ @echo "- build: compilation, link and prepare files for package into a widget"
+ @echo "- package: output a widget file '*.wgt'"
+ @echo "- install: install in your ${CMAKE_INSTALL_DIR} directory"
@echo ""
@echo "Usage: ./conf.d/autobuild/agl/autobuild package DEST=${HOME}/opt"
@echo "Don't use your build dir as DEST as wgt file is generated at this location"
@@ -58,6 +59,9 @@ package: build
@cmake --build ${BUILD_DIR} --target widget
@mkdir -p ${DEST} && cp ${BUILD_DIR}/*wgt ${DEST}
+install: build
+ @cmake --build ${BUILD_DIR} --target install
+
${BUILD_DIR}/Makefile:
@[ -d ${BUILD_DIR} ] || mkdir -p ${BUILD_DIR}
@[ -f ${BUILD_DIR}/Makefile ] || (cd ${BUILD_DIR} && cmake ${CONFIGURE_ARGS} ..)
diff --git a/conf.d/cmake/config.cmake b/conf.d/cmake/config.cmake
index 8157981..997a92a 100644
--- a/conf.d/cmake/config.cmake
+++ b/conf.d/cmake/config.cmake
@@ -81,10 +81,14 @@ set (PKG_REQUIRED_LIST
# ------------------------------------------------------
#set(CMAKE_INSTALL_PREFIX $ENV{HOME}/opt)
+
# Customize link option
# -----------------------------
list(APPEND link_libraries -lpthread -lm)
+# Alsa does not really like libEfence
+set(USE_EFENCE 0)
+
# Compilation options definition
# Use CMake generator expressions to specify only for a specific language
# Values are prefilled with default options that is currently used.
diff --git a/Alsa-Plugin/Alsa-Policy-Hook/CMakeLists.txt b/hook-plugin/CMakeLists.txt
index 329b2ef..329b2ef 100644
--- a/Alsa-Plugin/Alsa-Policy-Hook/CMakeLists.txt
+++ b/hook-plugin/CMakeLists.txt
diff --git a/Alsa-Plugin/Alsa-Policy-Hook/PolicyHookCb.c b/hook-plugin/PolicyHookCb.c
index 54fbe88..fdec61d 100644
--- a/Alsa-Plugin/Alsa-Policy-Hook/PolicyHookCb.c
+++ b/hook-plugin/PolicyHookCb.c
@@ -67,7 +67,8 @@ void OnRequestCB(void* UNUSED_ARG(handle) , const char* UNUSED_ARG(api), const c
typedef struct {
const char *api;
- const char *verb;
+ const char *openVerb;
+ const char *closeVerb;
long timeout;
char *query;
size_t length;
@@ -217,30 +218,27 @@ int OnTimeoutCB (sd_event_source* source, uint64_t timer, void* handle) {
// Call AGL binder asynchronously by with a timeout
static int CallWithTimeout(afbClientT *afbClient, afbRequestT *afbRequest, int count, hookActionT action) {
uint64_t usec;
+ const char * apiVerb;
int err;
// create a unique tag for request
- (void) asprintf(&afbRequest->callIdTag, "%d:%s/%s", count, afbRequest->api, afbRequest->verb);
+ (void) asprintf(&afbRequest->callIdTag, "%d:%s/%s", count, afbRequest->api, afbRequest->openVerb);
// create a timer with ~250us accuracy
sd_event_now(afbClient->sdLoop, CLOCK_MONOTONIC, &usec);
sd_event_add_time(afbClient->sdLoop, &afbRequest->evtSource, CLOCK_MONOTONIC, usec+afbRequest->timeout*1000, 250, OnTimeoutCB, afbClient);
- if (afbClient->verbose) printf("CALL-REQUEST api=%s/%s tag=%s\n", afbRequest->api, afbRequest->verb, afbRequest->callIdTag);
// on PCM close replace last '}' by CLOSING_MSG
- if (action == HOOK_CLOSE) {
- for (size_t index=afbRequest->length; index >0; index--) {
- if (afbRequest->query[index] == '}') {
- strcpy (&afbRequest->query[index], CLOSING_MSG);
- break;
- }
- }
+ if (action == HOOK_CLOSE) apiVerb= afbRequest->closeVerb;
+ else apiVerb= afbRequest->openVerb;
+
+ // release action is optional
+ if (apiVerb) {
+ if (afbClient->verbose) printf("CALL-REQUEST api=%s/%s tag=%s\n", afbRequest->api, apiVerb, afbRequest->callIdTag);
+ err = afb_wsj1_call_s(afbClient->wsj1, afbRequest->api, apiVerb, afbRequest->query, OnResponseCB, afbRequest);
+ if (err) goto OnErrorExit;
}
-
- err = afb_wsj1_call_s(afbClient->wsj1, afbRequest->api, afbRequest->verb, afbRequest->query, OnResponseCB, afbRequest);
- if (err) goto OnErrorExit;
-
// save client handle in request
afbRequest->afbClient = afbClient;
afbClient->count ++;
@@ -248,7 +246,8 @@ static int CallWithTimeout(afbClientT *afbClient, afbRequestT *afbRequest, int c
return 0;
OnErrorExit:
- return -1;
+ fprintf(stderr, "LaunchCallRequest: Fail call %s//%s/%s&%s", afbClient->uri, afbRequest->api, apiVerb, afbRequest->query);
+ return 1;
}
static int LaunchCallRequest(afbClientT *afbClient, hookActionT action) {
@@ -285,10 +284,7 @@ static int LaunchCallRequest(afbClientT *afbClient, hookActionT action) {
// send call request to audio-agent asynchronously (respond with thread mainloop context)
for (idx = 0; afbRequest[idx] != NULL; idx++) {
err = CallWithTimeout(afbClient, afbRequest[idx], idx, action);
- if (err) {
- fprintf(stderr, "LaunchCallRequest: Fail call %s//%s/%s&%s", afbClient->uri, afbRequest[idx]->api, afbRequest[idx]->verb, afbRequest[idx]->query);
- goto OnErrorExit;
- }
+ if (err) goto OnErrorExit;
}
// launch counter to keep track of waiting request call
@@ -314,7 +310,7 @@ static int AlsaCloseHook(snd_pcm_hook_t *hook) {
// wait for all call request to return
sem_wait(&afbClient->semaphore);
if (afbClient->error) {
- fprintf (stderr, "AlsaCloseHook: Audio Agent Fail to respond\n");
+ fprintf (stderr, "AlsaCloseHook: Notice exit before audio-4a response\n");
goto OnErrorExit;
}
@@ -412,14 +408,24 @@ int PLUGIN_ENTRY_POINT (snd_pcm_t *pcm, snd_config_t *conf) {
afbRequest[callCount]->api=strdup(api);
}
- err = snd_config_search(ctlconfig, "verb", &itemConf);
+ err = snd_config_search(ctlconfig, "request", &itemConf);
+ if (!err) {
+ const char *verb;
+ if (snd_config_get_string(itemConf, &verb) < 0) {
+ SNDERR("Invalid open verb string %s", id);
+ goto OnErrorExit;
+ }
+ afbRequest[callCount]->openVerb=strdup(verb);
+ }
+
+ err = snd_config_search(ctlconfig, "release", &itemConf);
if (!err) {
const char *verb;
if (snd_config_get_string(itemConf, &verb) < 0) {
- SNDERR("Invalid verb string %s", id);
+ SNDERR("Invalid close verb string %s", id);
goto OnErrorExit;
}
- afbRequest[callCount]->verb=strdup(verb);
+ afbRequest[callCount]->closeVerb=strdup(verb);
}
err = snd_config_search(ctlconfig, "timeout", &itemConf);
@@ -430,7 +436,7 @@ int PLUGIN_ENTRY_POINT (snd_pcm_t *pcm, snd_config_t *conf) {
}
}
- err = snd_config_search(ctlconfig, "query", &itemConf);
+ err = snd_config_search(ctlconfig, "args", &itemConf);
if (!err) {
const char *query;
if (snd_config_get_string(itemConf, &query) < 0) {
@@ -457,8 +463,8 @@ int PLUGIN_ENTRY_POINT (snd_pcm_t *pcm, snd_config_t *conf) {
// Simple check on call request validity
if (!afbRequest[callCount]->query) afbRequest[callCount]->query= "";
if (!afbRequest[callCount]->timeout) afbRequest[callCount]->timeout=REQUEST_DEFAULT_TIMEOUT ;
- if (!afbRequest[callCount]->verb || !afbRequest[callCount]->api) {
- SNDERR("Missing api/verb %s in asoundrc", callLabel);
+ if (!afbRequest[callCount]->openVerb || !afbRequest[callCount]->api) {
+ SNDERR("Missing api/open(verb)/close(verb) %s in asoundrc", callLabel);
goto OnErrorExit;
}
diff --git a/Alsa-Plugin/Alsa-Policy-Hook/README.md b/hook-plugin/README.md
index 20186db..0472c7b 100644
--- a/Alsa-Plugin/Alsa-Policy-Hook/README.md
+++ b/hook-plugin/README.md
@@ -42,16 +42,17 @@ pcm.MyNavigationHook {
# Every Call should return OK in order PCM to open (default timeout 100ms)
uri "ws://localhost:1234/api?token='audio-agent-token'"
request {
- # Request autorisation to write on navigation
+ # Request authorisation to write on navigation
navigation-ctl {
- api "control"
- verb "dispatch"
- args "{'target':'navigation', 'args':{'device':'Jabra SOLEMATE v1.34.0'}}"
+ api "pol4a"
+ request "navigation-role"
+ release "navigation-role"
+ args "{'uid':'alsa-hook-navigation'}"
}
# subscribe to Audio Agent Event map them to signal
subscribe-evt {
- api "control"
- verb "monitor"
+ api "pol4a"
+ verb "subscribe"
}
}
# map event reception to self generated signal
diff --git a/htdocs/alsa-core.html b/htdocs/alsa-core.html
deleted file mode 100644
index a61c28e..0000000
--- a/htdocs/alsa-core.html
+++ /dev/null
@@ -1,64 +0,0 @@
-<html>
-<head>
- <link rel="stylesheet" href="AudioBinding.css">
- <title>Alsa Low Level Simple Test</title>
-
- <script type="text/javascript" src="AFB-websock.js"></script>
- <script type="text/javascript" src="AudioBinding.js"></script>
-</head>
-
-<body onload="init('alsa_registry','alsacore', 'infoget')">
-
- <button id="connected" onclick="init('alsa_registry','alsacore', 'infoget');">Binder WS Fail</button>
- <button id="mnitoring" onclick="window.open('/monitoring/monitor.html','_monitor_audio')">Debug/Monitoring</a></button>
-
- <br><br>
- <b>Selected SndCard </b>
- <select id='alsa_registry'></select>
-
- <b>Select NUMID </b>
- <select id='alsa_ctl_list' onclick="refresh_list(this, 'alsacore', 'ctlget', {devid:sndcard, mode:1})">
- <option value='-1'>Refresh NUMID list</option>
- </select>
-
- <b>API Verbosity </b>
- <select id='api_verbosity' onclick='mode=this.value'>
- <option value='0'>Quiet</option>
- <option value='1'>Compact</option>
- <option value='2'>Verbose</option>
- <option value='3'>Full</option>
- </select>
-
-
- <br>
- <ol>
- <li><button onclick="callbinder('alsacore','ctlget', {devid:sndcard, mode:mode})">Get all Alsa Ctls</button></li>
- <li><button onclick="callbinder('alsacore','ctlget', {devid:sndcard, mode:mode, ctl:numid})">Get Alsa Ctls [numid]</button></li>
- <li><button onclick="callbinder('alsacore','ctlget', {devid:sndcard, mode:mode, ctl:[numid,numid+1]})">Get Alsa Ctls [numid,numid+1]</button></li>
- <br>
-
-
- <li><button onclick="callbinder('alsacore','ctlset', {devid:sndcard, mode:mode, ctl:[[9,20]]})">Set Alsa Ctl ctl:[[9,20]]</button></li>
- <li><button onclick="callbinder('alsacore','ctlset', {devid:sndcard, mode:mode, ctl:[{id:9,val:50}]})">Set Alsa Ctl ctl:[{id:9,val:50}]}</button></li>
- <li><button onclick="callbinder('alsacore','ctlset', {devid:sndcard, mode:mode, ctl:[[6,[20,20]]]})">Set Alsa Ctl ctl:[[6,[20,20]]]</button></li>
- <li><button onclick="callbinder('alsacore','ctlset', {devid:sndcard, mode:mode, ctl:[{id:6,val:[50,50]}]})">Set Alsa Ctl ctl:[{id:2,val:[50,50]}]</button></li>
- <li><button onclick="callbinder('alsacore','ctlset', {devid:sndcard, mode:mode, ctl:[{id:6,val:[50,50]}, {id:9,val:50,50}]})">Set Alsa Ctl ctl:[{id:6,val:[50,50]}, {id:9,val:50,50}]</button></li>
- <br>
- <li><button onclick="callbinder('alsacore','ucmquery', {devid:sndcard, mode:mode})">List UCM verbs</button></li>
- <li><button onclick="callbinder('alsacore','ucmset' , {devid:sndcard, mode:mode, verb:'HiFi'})">Set UCM HiFi</button></li>
- <li><button onclick="callbinder('alsacore','ucmset' , {devid:sndcard, mode:mode, verb:'HiFi', dev:'Headphone'})">Set UCM HiFi+Headphone</button></li>
- <li><button onclick="callbinder('alsacore','ucmset' , {devid:sndcard, mode:mode, verb:'HiFi', dev:'Headphone', mod:'RecordMedia'})">Set UCM HiFi+Headphone+RecordMedia</button></li>
- <br>
- <li><button onclick="callbinder('alsacore','ucmget' , {devid:sndcard, mode:mode, values:['OutputDspName','PlaybackPCM','CapturePCM']})">Get UCM OutputDspName+PlaybackPCM+CapturePCM (SET UCM)</button></li>
- <br>
- <li><button onclick="callbinder('alsacore','subscribe', {devid:sndcard})">Subscribe AlsaCtl Events</button></li>
- <br>
- </ol>
-
- <div id="main" style="visibility:hidden">
- <ol>
- <li>Question <pre id="question"></pre>
- <li>Response <pre id="output"></pre>
- <li>Events: <pre id="outevt"></pre>
- </ol>
- </div>
diff --git a/htdocs/alsa-hal.html b/htdocs/alsa-hal.html
deleted file mode 100644
index f41d37c..0000000
--- a/htdocs/alsa-hal.html
+++ /dev/null
@@ -1,56 +0,0 @@
-<html>
-<head>
- <title>Basic Audio Hardware Abstraction Layer Test</title>
- <link rel="stylesheet" href="AudioBinding.css">
- <script type="text/javascript" src="AFB-websock.js"></script>
- <script type="text/javascript" src="AudioBinding.js"></script>
-</head>
-
-
-<body onload="init('hal_registry','alsacore', 'hallist')">
-
- <h1>Simple AlsaHAL tests</h1>
- <button id="connected" onclick="init('hal_registry','alsacore', 'hallist')">Binder WS Fail</button>
- <button id="mnitoring" onclick="window.open('/monitoring/monitor.html','_monitor_audio')">Debug/Monitoring</a></button>
-
- <br><br>
- <b>Selected HAL </b>
- <select id='hal_registry'></select>
-
- <b>API Verbosity </b>
- <select id='api_verbosity' onclick='mode=this.value'>
- <option value='0'>Quiet</option>
- <option value='1'>Compact</option>
- <option value='2'>Verbose</option>
- <option value='3'>Full</option>
- </select>
- <br>
-
- <br>
- <ol>
-
- <li><button onclick="callbinder(sndcard,'ctllist')">List Selected HAL Controls </button></li>
- <li><button onclick="callbinder(sndcard,'ctlget', {label:'Master_Playback_Volume'})">Get {label:'Master_Playback_Volume'}</button></li>
- <li><button onclick="callbinder(sndcard,'ctlget', [{tag:4},{tag:5}])">Get[{tag:4},{tag:5}]</button></li>
- <li><button onclick="callbinder(sndcard,'ctlget', [4,5])">Get [4,5]</button></li>
- <br>
- <li><button onclick="callbinder(sndcard,'ctlset', {label:'Master_Playback_Volume', val:[50]})">Set {label:'Master_Playback_Volume', value=[50]}</button></li>
- <li><button onclick="callbinder(sndcard,'ctlset', {tag: 4, val:5})">Set {tag: 4, val:5}</button></li>
- <li><button onclick="callbinder(sndcard,'ctlset', [{tag:4, val:25},{tag:5, val:25}])">Set[{tag:4, val:25},{tag:5, val:25}]</button></li>
- <li><button onclick="callbinder(sndcard,'ctlset', [{tag:4, val:[55,45]},{tag:5, val:[45,55]}])">Set[{tag:4, val:[55,45]},{tag:5, val:[45,55]}]]</button></li>
- <br>
-
- <li>
- <label for="volramp">Volume Ramp</label>
- <input id="volramp" type="number" min=0 max=100 step=10 maxlength=3 placeholder="Enter 0-100" onChange="callbinder(sndcard,'ctl-set', {label:'Volume_Ramp', val:this.value})">
- </li>
- <br>
- </ol>
-
- <div id="main" style="visibility:hidden">
- <ol>
- <li>Question <pre id="question"></pre>
- <li>Response <pre id="output"></pre>
- <li>Events: <pre id="outevt"></pre>
- </ol>
- </div>
diff --git a/htdocs/audio-control.html b/htdocs/audio-control.html
deleted file mode 100644
index 8216601..0000000
--- a/htdocs/audio-control.html
+++ /dev/null
@@ -1,28 +0,0 @@
-<html>
-<head>
- <title>Basic Audio Hardware Abstraction Layer Test</title>
- <link rel="stylesheet" href="AudioBinding.css">
- <script type="text/javascript" src="AFB-websock.js"></script>
- <script type="text/javascript" src="AudioBinding.js"></script>
-</head>
-
-<body onload="init('hal_registry','alsacore', 'hallist')">
-
- <h1>Simple Audio Control Test</h1>
- <button id="connected" onclick="init('hal_registry','alsacore', 'hallist')">Binder WS Fail</button>
- <button id="mnitoring" onclick="window.open('/monitoring/monitor.html','_monitor_audio')">Debug/Monitoring</a></button>
- <ol>
-
- <li><button onclick="callbinder('control','dispatch' ,{'target':'navigation'});">Dispatch Navigation</button></li>
- <li><button onclick="callbinder('control','dispatch' ,{'target':'multimedia'});">Dispatch Multimedia</button></li>
- <li><button onclick="callbinder('control','dispatch' ,{'target':'emergency' });">Dispatch Emergency</button></li>
- <br>
- </ol>
-
- <div id="main" style="visibility:hidden">
- <ol>
- <li>Question <pre id="question"></pre>
- <li>Response <pre id="output"></pre>
- <li>Events: <pre id="outevt"></pre>
- </ol>
- </div>
diff --git a/htdocs/index.html b/htdocs/index.html
index e424feb..a61c28e 100644
--- a/htdocs/index.html
+++ b/htdocs/index.html
@@ -1,10 +1,64 @@
<html>
- <head>
- <title>AGL-AudioBindins tests</title>
- <body>
- <h1>audio-bindings test</h1>
+<head>
+ <link rel="stylesheet" href="AudioBinding.css">
+ <title>Alsa Low Level Simple Test</title>
+
+ <script type="text/javascript" src="AFB-websock.js"></script>
+ <script type="text/javascript" src="AudioBinding.js"></script>
+</head>
+
+<body onload="init('alsa_registry','alsacore', 'infoget')">
+
+ <button id="connected" onclick="init('alsa_registry','alsacore', 'infoget');">Binder WS Fail</button>
+ <button id="mnitoring" onclick="window.open('/monitoring/monitor.html','_monitor_audio')">Debug/Monitoring</a></button>
+
+ <br><br>
+ <b>Selected SndCard </b>
+ <select id='alsa_registry'></select>
+
+ <b>Select NUMID </b>
+ <select id='alsa_ctl_list' onclick="refresh_list(this, 'alsacore', 'ctlget', {devid:sndcard, mode:1})">
+ <option value='-1'>Refresh NUMID list</option>
+ </select>
+
+ <b>API Verbosity </b>
+ <select id='api_verbosity' onclick='mode=this.value'>
+ <option value='0'>Quiet</option>
+ <option value='1'>Compact</option>
+ <option value='2'>Verbose</option>
+ <option value='3'>Full</option>
+ </select>
+
+
+ <br>
<ol>
- <li><a href="alsa-core.html">AlsaCore Low Level Binding</a>
- <li><a href="alsa-hal.html" >AlsaHAL Hardware Abstraction Layer</a>
- <li><a href="audio-control.html">AudioControl Control/Policy API</a>
- <li><a href="/monitoring/monitor.html">Binding Monitoring Dashboard</a>
+ <li><button onclick="callbinder('alsacore','ctlget', {devid:sndcard, mode:mode})">Get all Alsa Ctls</button></li>
+ <li><button onclick="callbinder('alsacore','ctlget', {devid:sndcard, mode:mode, ctl:numid})">Get Alsa Ctls [numid]</button></li>
+ <li><button onclick="callbinder('alsacore','ctlget', {devid:sndcard, mode:mode, ctl:[numid,numid+1]})">Get Alsa Ctls [numid,numid+1]</button></li>
+ <br>
+
+
+ <li><button onclick="callbinder('alsacore','ctlset', {devid:sndcard, mode:mode, ctl:[[9,20]]})">Set Alsa Ctl ctl:[[9,20]]</button></li>
+ <li><button onclick="callbinder('alsacore','ctlset', {devid:sndcard, mode:mode, ctl:[{id:9,val:50}]})">Set Alsa Ctl ctl:[{id:9,val:50}]}</button></li>
+ <li><button onclick="callbinder('alsacore','ctlset', {devid:sndcard, mode:mode, ctl:[[6,[20,20]]]})">Set Alsa Ctl ctl:[[6,[20,20]]]</button></li>
+ <li><button onclick="callbinder('alsacore','ctlset', {devid:sndcard, mode:mode, ctl:[{id:6,val:[50,50]}]})">Set Alsa Ctl ctl:[{id:2,val:[50,50]}]</button></li>
+ <li><button onclick="callbinder('alsacore','ctlset', {devid:sndcard, mode:mode, ctl:[{id:6,val:[50,50]}, {id:9,val:50,50}]})">Set Alsa Ctl ctl:[{id:6,val:[50,50]}, {id:9,val:50,50}]</button></li>
+ <br>
+ <li><button onclick="callbinder('alsacore','ucmquery', {devid:sndcard, mode:mode})">List UCM verbs</button></li>
+ <li><button onclick="callbinder('alsacore','ucmset' , {devid:sndcard, mode:mode, verb:'HiFi'})">Set UCM HiFi</button></li>
+ <li><button onclick="callbinder('alsacore','ucmset' , {devid:sndcard, mode:mode, verb:'HiFi', dev:'Headphone'})">Set UCM HiFi+Headphone</button></li>
+ <li><button onclick="callbinder('alsacore','ucmset' , {devid:sndcard, mode:mode, verb:'HiFi', dev:'Headphone', mod:'RecordMedia'})">Set UCM HiFi+Headphone+RecordMedia</button></li>
+ <br>
+ <li><button onclick="callbinder('alsacore','ucmget' , {devid:sndcard, mode:mode, values:['OutputDspName','PlaybackPCM','CapturePCM']})">Get UCM OutputDspName+PlaybackPCM+CapturePCM (SET UCM)</button></li>
+ <br>
+ <li><button onclick="callbinder('alsacore','subscribe', {devid:sndcard})">Subscribe AlsaCtl Events</button></li>
+ <br>
+ </ol>
+
+ <div id="main" style="visibility:hidden">
+ <ol>
+ <li>Question <pre id="question"></pre>
+ <li>Response <pre id="output"></pre>
+ <li>Events: <pre id="outevt"></pre>
+ </ol>
+ </div>
diff --git a/nbproject/configurations.xml b/nbproject/configurations.xml
index 9700858..cc487a3 100644
--- a/nbproject/configurations.xml
+++ b/nbproject/configurations.xml
@@ -6,7 +6,7 @@
<in>filescan-utils.c</in>
<in>wrap-json.c</in>
</df>
- <df name="Alsa-afb">
+ <df name="alsa-binding">
<in>Alsa-AddCtl.c</in>
<in>Alsa-ApiHat.c</in>
<in>Alsa-RegEvt.c</in>
@@ -75,6 +75,9 @@
<in>HighLevelApiConf.c</in>
<in>HighLevelBinding.c</in>
</df>
+ <df name="hook-plugin">
+ <in>PolicyHookCb.c</in>
+ </df>
<df name="MostVolume">
<df name="external">
<in>ConnectionInfo.cpp</in>
@@ -140,94 +143,8 @@
<preBuildFirst>true</preBuildFirst>
</preBuild>
</makefileType>
- <item path="Alsa-Plugin/Alsa-Policy-Hook/PolicyHookCb.c"
- ex="false"
- tool="0"
- flavor2="3">
- <cTool flags="0">
- </cTool>
- </item>
- <item path="Alsa-afb/Alsa-AddCtl.c" ex="false" tool="0" flavor2="3">
- <cTool flags="2">
- <incDir>
- <pElem>../../../opt/include/afb</pElem>
- <pElem>Alsa-afb</pElem>
- <pElem>../../../opt/include/alsa</pElem>
- <pElem>/usr/include/json-c</pElem>
- <pElem>Audio-Common</pElem>
- <pElem>../../../opt/include</pElem>
- <pElem>build/Alsa-afb</pElem>
- </incDir>
- </cTool>
- </item>
- <item path="Alsa-afb/Alsa-ApiHat.c" ex="false" tool="0" flavor2="3">
+ <item path="Alsa-Policy-Hook/PolicyHookCb.c" ex="false" tool="0" flavor2="3">
<cTool flags="0">
- <incDir>
- <pElem>../../../opt/include</pElem>
- <pElem>../../../opt/include/alsa</pElem>
- <pElem>/usr/include/p11-kit-1</pElem>
- <pElem>/usr/include/json-c</pElem>
- <pElem>/usr/include/lua5.3</pElem>
- <pElem>Audio-Common</pElem>
- <pElem>build/Alsa-afb</pElem>
- </incDir>
- <preprocessorList>
- <Elem>CONTROL_CONFIG_PATH="/home/fulup/Workspace/AGL-AppFW/audio-bindings-dev/conf.d/project/config.d:/usr/local/controller/config.d"</Elem>
- <Elem>CONTROL_CONFIG_POST="control"</Elem>
- <Elem>CONTROL_CONFIG_PRE="onload"</Elem>
- <Elem>CONTROL_DOSCRIPT_PRE="doscript"</Elem>
- <Elem>CONTROL_LUA_EVENT="luaevt"</Elem>
- <Elem>CONTROL_LUA_PATH="/home/fulup/Workspace/AGL-AppFW/audio-bindings-dev/conf.d/project/lua.d:/usr/local/controller/ctl-lua.d"</Elem>
- <Elem>CONTROL_MAXPATH_LEN=255</Elem>
- <Elem>CONTROL_ONLOAD_DEFAULT="onload-default"</Elem>
- <Elem>CONTROL_PLUGIN_PATH="/home/fulup/Workspace/AGL-AppFW/audio-bindings-dev/build:/home/fulup/opt/audio-bindings/ctlplug:/usr/lib/afb/ctlplug"</Elem>
- <Elem>CONTROL_SUPPORT_LUA</Elem>
- <Elem>CTL_PLUGIN_MAGIC=2468013579</Elem>
- <Elem>MAX_LINEAR_DB_SCALE=24</Elem>
- <Elem>MAX_SND_CARD=16</Elem>
- <Elem>NATIVE_LINUX</Elem>
- <Elem>TLV_BYTE_SIZE=256</Elem>
- <Elem>alsa_lowlevel_EXPORTS</Elem>
- </preprocessorList>
- </cTool>
- </item>
- <item path="Alsa-afb/Alsa-RegEvt.c" ex="false" tool="0" flavor2="3">
- <cTool flags="2">
- <incDir>
- <pElem>../../../opt/include/afb</pElem>
- <pElem>Alsa-afb</pElem>
- <pElem>../../../opt/include/alsa</pElem>
- <pElem>/usr/include/json-c</pElem>
- <pElem>Audio-Common</pElem>
- <pElem>../../../opt/include</pElem>
- <pElem>build/Alsa-afb</pElem>
- </incDir>
- </cTool>
- </item>
- <item path="Alsa-afb/Alsa-SetGet.c" ex="false" tool="0" flavor2="3">
- <cTool flags="2">
- <incDir>
- <pElem>../../../opt/include/afb</pElem>
- <pElem>Alsa-afb</pElem>
- <pElem>../../../opt/include/alsa</pElem>
- <pElem>/usr/include/json-c</pElem>
- <pElem>Audio-Common</pElem>
- <pElem>../../../opt/include</pElem>
- <pElem>build/Alsa-afb</pElem>
- </incDir>
- </cTool>
- </item>
- <item path="Alsa-afb/Alsa-Ucm.c" ex="false" tool="0" flavor2="3">
- <cTool flags="2">
- <incDir>
- <pElem>../../../opt/include/afb</pElem>
- <pElem>Alsa-afb</pElem>
- <pElem>../../../opt/include/alsa</pElem>
- <pElem>/usr/include/json-c</pElem>
- <pElem>Audio-Common</pElem>
- <pElem>../../../opt/include</pElem>
- <pElem>build/Alsa-afb</pElem>
- </incDir>
</cTool>
</item>
<item path="Audio-Common/audio-common.c" ex="false" tool="0" flavor2="3">
@@ -558,6 +475,34 @@
</item>
<item path="MostVolume/libmostvolume.cpp" ex="false" tool="1" flavor2="4">
</item>
+ <item path="afb-utilities/filescan-utils.c" ex="false" tool="0" flavor2="3">
+ <cTool flags="0">
+ </cTool>
+ </item>
+ <item path="afb-utilities/wrap-json.c" ex="false" tool="0" flavor2="3">
+ <cTool flags="0">
+ </cTool>
+ </item>
+ <item path="alsa-binding/Alsa-AddCtl.c" ex="false" tool="0" flavor2="3">
+ <cTool flags="0">
+ </cTool>
+ </item>
+ <item path="alsa-binding/Alsa-ApiHat.c" ex="false" tool="0" flavor2="3">
+ <cTool flags="0">
+ </cTool>
+ </item>
+ <item path="alsa-binding/Alsa-RegEvt.c" ex="false" tool="0" flavor2="3">
+ <cTool flags="0">
+ </cTool>
+ </item>
+ <item path="alsa-binding/Alsa-SetGet.c" ex="false" tool="0" flavor2="3">
+ <cTool flags="0">
+ </cTool>
+ </item>
+ <item path="alsa-binding/Alsa-Ucm.c" ex="false" tool="0" flavor2="3">
+ <cTool flags="0">
+ </cTool>
+ </item>
<folder path="0/Alsa-Plugin">
<cTool>
<incDir>
@@ -787,6 +732,69 @@
</preprocessorList>
</cTool>
</folder>
+ <folder path="0/afb-utilities">
+ <cTool>
+ <incDir>
+ <pElem>/usr/include/json-c</pElem>
+ <pElem>../../../opt/include</pElem>
+ <pElem>/usr/include/p11-kit-1</pElem>
+ <pElem>../../../opt/include/alsa</pElem>
+ <pElem>afb-utilities</pElem>
+ <pElem>build/afb-utilities</pElem>
+ </incDir>
+ <preprocessorList>
+ <Elem>CONTROL_MAXPATH_LEN=255</Elem>
+ <Elem>MAX_LINEAR_DB_SCALE=24</Elem>
+ <Elem>MAX_SND_CARD=16</Elem>
+ <Elem>NATIVE_LINUX</Elem>
+ <Elem>TLV_BYTE_SIZE=256</Elem>
+ </preprocessorList>
+ </cTool>
+ </folder>
+ <folder path="0/alsa-binding">
+ <cTool>
+ <incDir>
+ <pElem>/usr/include/json-c</pElem>
+ <pElem>../../../opt/include</pElem>
+ <pElem>/usr/include/p11-kit-1</pElem>
+ <pElem>../../../opt/include/alsa</pElem>
+ <pElem>afb-utilities</pElem>
+ <pElem>build/alsa-binding</pElem>
+ </incDir>
+ <preprocessorList>
+ <Elem>CONTROL_MAXPATH_LEN=255</Elem>
+ <Elem>MAX_LINEAR_DB_SCALE=24</Elem>
+ <Elem>MAX_SND_CARD=16</Elem>
+ <Elem>NATIVE_LINUX</Elem>
+ <Elem>TLV_BYTE_SIZE=256</Elem>
+ <Elem>alsa_4a_EXPORTS</Elem>
+ </preprocessorList>
+ </cTool>
+ </folder>
+ <folder path="0/hook-plugin">
+ <cTool>
+ <incDir>
+ <pElem>/usr/include/json-c</pElem>
+ <pElem>../../../opt/include</pElem>
+ <pElem>/usr/include/p11-kit-1</pElem>
+ <pElem>../../../opt/include/alsa</pElem>
+ <pElem>build/hook-plugin</pElem>
+ </incDir>
+ <preprocessorList>
+ <Elem>CONTROL_MAXPATH_LEN=255</Elem>
+ <Elem>MAX_LINEAR_DB_SCALE=24</Elem>
+ <Elem>MAX_SND_CARD=16</Elem>
+ <Elem>NATIVE_LINUX</Elem>
+ <Elem>PIC</Elem>
+ <Elem>TLV_BYTE_SIZE=256</Elem>
+ <Elem>policy_hook_cb_EXPORTS</Elem>
+ </preprocessorList>
+ </cTool>
+ </folder>
+ <item path="hook-plugin/PolicyHookCb.c" ex="false" tool="0" flavor2="3">
+ <cTool flags="0">
+ </cTool>
+ </item>
</conf>
<conf name="Local_Alias" type="0">
<toolsSet>
@@ -819,62 +827,8 @@
<preBuildCommand>cmake ..</preBuildCommand>
</preBuild>
</makefileType>
- <item path="Alsa-Plugin/Alsa-Policy-Hook/PolicyHookCb.c"
- ex="false"
- tool="0"
- flavor2="3">
- <cTool flags="2">
- </cTool>
- </item>
- <item path="Alsa-afb/Alsa-AddCtl.c" ex="false" tool="0" flavor2="3">
- <cTool flags="2">
- <incDir>
- <pElem>../../../opt/include/alsa</pElem>
- <pElem>/usr/include/json-c</pElem>
- <pElem>Audio-Common</pElem>
- <pElem>../../../opt/include</pElem>
- <pElem>build/Alsa-afb</pElem>
- </incDir>
- </cTool>
- </item>
- <item path="Alsa-afb/Alsa-ApiHat.c" ex="false" tool="0" flavor2="3">
- <cTool flags="2">
- <incDir>
- <pElem>build/Alsa-afb</pElem>
- </incDir>
- </cTool>
- </item>
- <item path="Alsa-afb/Alsa-RegEvt.c" ex="false" tool="0" flavor2="3">
- <cTool flags="2">
- <incDir>
- <pElem>../../../opt/include/alsa</pElem>
- <pElem>/usr/include/json-c</pElem>
- <pElem>Audio-Common</pElem>
- <pElem>../../../opt/include</pElem>
- <pElem>build/Alsa-afb</pElem>
- </incDir>
- </cTool>
- </item>
- <item path="Alsa-afb/Alsa-SetGet.c" ex="false" tool="0" flavor2="3">
- <cTool flags="2">
- <incDir>
- <pElem>../../../opt/include/alsa</pElem>
- <pElem>/usr/include/json-c</pElem>
- <pElem>Audio-Common</pElem>
- <pElem>../../../opt/include</pElem>
- <pElem>build/Alsa-afb</pElem>
- </incDir>
- </cTool>
- </item>
- <item path="Alsa-afb/Alsa-Ucm.c" ex="false" tool="0" flavor2="3">
+ <item path="Alsa-Policy-Hook/PolicyHookCb.c" ex="false" tool="0" flavor2="3">
<cTool flags="2">
- <incDir>
- <pElem>../../../opt/include/alsa</pElem>
- <pElem>/usr/include/json-c</pElem>
- <pElem>Audio-Common</pElem>
- <pElem>../../../opt/include</pElem>
- <pElem>build/Alsa-afb</pElem>
- </incDir>
</cTool>
</item>
<item path="Audio-Common/audio-common.c" ex="false" tool="0" flavor2="3">
@@ -1193,6 +1147,57 @@
</incDir>
</cTool>
</item>
+ <item path="alsa-binding/Alsa-AddCtl.c" ex="false" tool="0" flavor2="3">
+ <cTool flags="2">
+ <incDir>
+ <pElem>../../../opt/include/alsa</pElem>
+ <pElem>/usr/include/json-c</pElem>
+ <pElem>Audio-Common</pElem>
+ <pElem>../../../opt/include</pElem>
+ <pElem>build/Alsa-afb</pElem>
+ </incDir>
+ </cTool>
+ </item>
+ <item path="alsa-binding/Alsa-ApiHat.c" ex="false" tool="0" flavor2="3">
+ <cTool flags="2">
+ <incDir>
+ <pElem>build/Alsa-afb</pElem>
+ </incDir>
+ </cTool>
+ </item>
+ <item path="alsa-binding/Alsa-RegEvt.c" ex="false" tool="0" flavor2="3">
+ <cTool flags="2">
+ <incDir>
+ <pElem>../../../opt/include/alsa</pElem>
+ <pElem>/usr/include/json-c</pElem>
+ <pElem>Audio-Common</pElem>
+ <pElem>../../../opt/include</pElem>
+ <pElem>build/Alsa-afb</pElem>
+ </incDir>
+ </cTool>
+ </item>
+ <item path="alsa-binding/Alsa-SetGet.c" ex="false" tool="0" flavor2="3">
+ <cTool flags="2">
+ <incDir>
+ <pElem>../../../opt/include/alsa</pElem>
+ <pElem>/usr/include/json-c</pElem>
+ <pElem>Audio-Common</pElem>
+ <pElem>../../../opt/include</pElem>
+ <pElem>build/Alsa-afb</pElem>
+ </incDir>
+ </cTool>
+ </item>
+ <item path="alsa-binding/Alsa-Ucm.c" ex="false" tool="0" flavor2="3">
+ <cTool flags="2">
+ <incDir>
+ <pElem>../../../opt/include/alsa</pElem>
+ <pElem>/usr/include/json-c</pElem>
+ <pElem>Audio-Common</pElem>
+ <pElem>../../../opt/include</pElem>
+ <pElem>build/Alsa-afb</pElem>
+ </incDir>
+ </cTool>
+ </item>
<folder path="0/Alsa-Plugin">
<cTool>
<incDir>
@@ -1214,14 +1219,6 @@
</preprocessorList>
</cTool>
</folder>
- <folder path="0/Alsa-afb">
- <cTool>
- <incDir>
- <pElem>../../../opt/include/afb</pElem>
- <pElem>Alsa-afb</pElem>
- </incDir>
- </cTool>
- </folder>
<folder path="0/Common">
<cTool>
<incDir>
@@ -1456,6 +1453,14 @@
</preprocessorList>
</cTool>
</folder>
+ <folder path="0/alsa-binding">
+ <cTool>
+ <incDir>
+ <pElem>../../../opt/include/afb</pElem>
+ <pElem>Alsa-afb</pElem>
+ </incDir>
+ </cTool>
+ </folder>
</conf>
<conf name="Local-Ctl" type="0">
<toolsSet>
@@ -1488,64 +1493,10 @@
<preBuildCommand>cmake ..</preBuildCommand>
</preBuild>
</makefileType>
- <item path="Alsa-Plugin/Alsa-Policy-Hook/PolicyHookCb.c"
- ex="false"
- tool="0"
- flavor2="3">
+ <item path="Alsa-Policy-Hook/PolicyHookCb.c" ex="false" tool="0" flavor2="3">
<cTool flags="2">
</cTool>
</item>
- <item path="Alsa-afb/Alsa-AddCtl.c" ex="false" tool="0" flavor2="3">
- <cTool flags="2">
- <incDir>
- <pElem>../../../opt/include/alsa</pElem>
- <pElem>/usr/include/json-c</pElem>
- <pElem>Audio-Common</pElem>
- <pElem>../../../opt/include</pElem>
- <pElem>build/Alsa-afb</pElem>
- </incDir>
- </cTool>
- </item>
- <item path="Alsa-afb/Alsa-ApiHat.c" ex="false" tool="0" flavor2="3">
- <cTool flags="2">
- <incDir>
- <pElem>build/Alsa-afb</pElem>
- </incDir>
- </cTool>
- </item>
- <item path="Alsa-afb/Alsa-RegEvt.c" ex="false" tool="0" flavor2="3">
- <cTool flags="2">
- <incDir>
- <pElem>../../../opt/include/alsa</pElem>
- <pElem>/usr/include/json-c</pElem>
- <pElem>Audio-Common</pElem>
- <pElem>../../../opt/include</pElem>
- <pElem>build/Alsa-afb</pElem>
- </incDir>
- </cTool>
- </item>
- <item path="Alsa-afb/Alsa-SetGet.c" ex="false" tool="0" flavor2="3">
- <cTool flags="2">
- <incDir>
- <pElem>../../../opt/include/alsa</pElem>
- <pElem>/usr/include/json-c</pElem>
- <pElem>Audio-Common</pElem>
- <pElem>../../../opt/include</pElem>
- <pElem>build/Alsa-afb</pElem>
- </incDir>
- </cTool>
- </item>
- <item path="Alsa-afb/Alsa-Ucm.c" ex="false" tool="0" flavor2="3">
- <cTool flags="2">
- <incDir>
- <pElem>../../../opt/include/alsa</pElem>
- <pElem>/usr/include/json-c</pElem>
- <pElem>Audio-Common</pElem>
- <pElem>../../../opt/include</pElem>
- <pElem>build/Alsa-afb</pElem>
- </incDir>
- </cTool>
- </item>
<item path="Audio-Common/audio-common.c" ex="false" tool="0" flavor2="3">
<cTool flags="2">
<incDir>
@@ -1862,6 +1813,57 @@
</incDir>
</cTool>
</item>
+ <item path="alsa-binding/Alsa-AddCtl.c" ex="false" tool="0" flavor2="3">
+ <cTool flags="2">
+ <incDir>
+ <pElem>../../../opt/include/alsa</pElem>
+ <pElem>/usr/include/json-c</pElem>
+ <pElem>Audio-Common</pElem>
+ <pElem>../../../opt/include</pElem>
+ <pElem>build/Alsa-afb</pElem>
+ </incDir>
+ </cTool>
+ </item>
+ <item path="alsa-binding/Alsa-ApiHat.c" ex="false" tool="0" flavor2="3">
+ <cTool flags="2">
+ <incDir>
+ <pElem>build/Alsa-afb</pElem>
+ </incDir>
+ </cTool>
+ </item>
+ <item path="alsa-binding/Alsa-RegEvt.c" ex="false" tool="0" flavor2="3">
+ <cTool flags="2">
+ <incDir>
+ <pElem>../../../opt/include/alsa</pElem>
+ <pElem>/usr/include/json-c</pElem>
+ <pElem>Audio-Common</pElem>
+ <pElem>../../../opt/include</pElem>
+ <pElem>build/Alsa-afb</pElem>
+ </incDir>
+ </cTool>
+ </item>
+ <item path="alsa-binding/Alsa-SetGet.c" ex="false" tool="0" flavor2="3">
+ <cTool flags="2">
+ <incDir>
+ <pElem>../../../opt/include/alsa</pElem>
+ <pElem>/usr/include/json-c</pElem>
+ <pElem>Audio-Common</pElem>
+ <pElem>../../../opt/include</pElem>
+ <pElem>build/Alsa-afb</pElem>
+ </incDir>
+ </cTool>
+ </item>
+ <item path="alsa-binding/Alsa-Ucm.c" ex="false" tool="0" flavor2="3">
+ <cTool flags="2">
+ <incDir>
+ <pElem>../../../opt/include/alsa</pElem>
+ <pElem>/usr/include/json-c</pElem>
+ <pElem>Audio-Common</pElem>
+ <pElem>../../../opt/include</pElem>
+ <pElem>build/Alsa-afb</pElem>
+ </incDir>
+ </cTool>
+ </item>
<folder path="0/Alsa-Plugin">
<cTool>
<incDir>
@@ -1883,14 +1885,6 @@
</preprocessorList>
</cTool>
</folder>
- <folder path="0/Alsa-afb">
- <cTool>
- <incDir>
- <pElem>../../../opt/include/afb</pElem>
- <pElem>Alsa-afb</pElem>
- </incDir>
- </cTool>
- </folder>
<folder path="0/Common">
<cTool>
<incDir>
@@ -2125,6 +2119,14 @@
</preprocessorList>
</cTool>
</folder>
+ <folder path="0/alsa-binding">
+ <cTool>
+ <incDir>
+ <pElem>../../../opt/include/afb</pElem>
+ <pElem>Alsa-afb</pElem>
+ </incDir>
+ </cTool>
+ </folder>
</conf>
</confs>
</configurationDescriptor>
diff --git a/nbproject/project.xml b/nbproject/project.xml
index 59b688d..fa21507 100644
--- a/nbproject/project.xml
+++ b/nbproject/project.xml
@@ -3,10 +3,10 @@
<type>org.netbeans.modules.cnd.makeproject</type>
<configuration>
<data xmlns="http://www.netbeans.org/ns/make-project/1">
- <name>AFB-aaaa</name>
+ <name>alsa-4a</name>
<c-extensions>c</c-extensions>
<cpp-extensions>cpp,cxx</cpp-extensions>
- <header-extensions>h</header-extensions>
+ <header-extensions>h,hpp</header-extensions>
<sourceEncoding>UTF-8</sourceEncoding>
<make-dep-projects/>
<sourceRootList>