From 8ef79c4fe380e590a7050f76605f304726eca664 Mon Sep 17 00:00:00 2001 From: Tobias Jahnke Date: Mon, 17 Dec 2018 16:51:56 +0100 Subject: 4a-hal-unicens: prepare import of plugin Bug-AGL: SPEC-1505 - remove all files from legacy hal binding Change-Id: I69e6d170cfa6a16d116f63263a1a5f75e2098d5b Signed-off-by: Tobias Jahnke --- .gitignore | 6 - .gitmodules | 12 - Apache-2.0 | 204 ------------ CMakeLists.txt | 21 -- MOST_UNICENS/CMakeLists.txt | 45 --- MOST_UNICENS/README.md | 51 --- MOST_UNICENS/hal_most_unicens.c | 240 -------------- MOST_UNICENS/ucs2-vol/CMakeLists.txt | 26 -- MOST_UNICENS/ucs2-vol/inc/device_container.h | 59 ---- MOST_UNICENS/ucs2-vol/inc/device_value.h | 104 ------ MOST_UNICENS/ucs2-vol/inc/libmostvolume.h | 114 ------- MOST_UNICENS/ucs2-vol/inc/setup.h | 73 ---- MOST_UNICENS/ucs2-vol/src/CMakeLists.txt | 39 --- MOST_UNICENS/ucs2-vol/src/device_container.cpp | 194 ----------- MOST_UNICENS/ucs2-vol/src/device_value.cpp | 175 ---------- MOST_UNICENS/ucs2-vol/src/libmostvolume.cpp | 101 ------ MOST_UNICENS/ucs2-vol/src/setup.cpp | 96 ------ MOST_UNICENS/wrap_unicens.c | 368 --------------------- MOST_UNICENS/wrap_unicens.h | 35 -- MOST_UNICENS/wrap_volume.c | 133 -------- MOST_UNICENS/wrap_volume.h | 26 -- README.md | 264 --------------- afb-utilities | 1 - conf.d/autobuild/agl/autobuild | 67 ---- conf.d/autobuild/linux/autobuild | 67 ---- conf.d/cmake/config.cmake | 232 ------------- conf.d/packaging/agl-afb-aaaa_0.1.orig.tar.gz | Bin 589231 -> 0 bytes conf.d/project/CMakeLists.txt | 24 -- conf.d/project/alsa.d/README.md | 175 ---------- conf.d/project/alsa.d/asoundrc.sample | 140 -------- .../project/alsa.d/ucm.sample/HDA Intel PCH.conf | 6 - conf.d/project/alsa.d/ucm.sample/HiFi.conf | 84 ----- conf.d/project/alsa.d/ucm.sample/README | 2 - conf.d/project/json.d/CMakeLists.txt | 32 -- conf.d/project/json.d/README.md | 22 -- conf.d/project/json.d/onload-aaaa-sample.json | 118 ------- conf.d/project/lua.d/CMakeLists.txt | 34 -- conf.d/project/lua.d/README.md | 36 -- conf.d/project/lua.d/netbeans-aaaa-run-config.png | Bin 145969 -> 0 bytes conf.d/project/lua.d/onload-aaaa-00-utils.lua | 86 ----- conf.d/project/lua.d/onload-aaaa-01-init.lua | 48 --- conf.d/project/lua.d/onload-aaaa-03-controls.lua | 158 --------- conf.d/project/lua.d/onload-aaaa-10-event.lua | 74 ----- hal-utilities-4a | 1 - htdocs/AFB-websock.js | 177 ---------- htdocs/AudioBinding.css | 7 - htdocs/AudioBinding.js | 197 ----------- htdocs/CMakeLists.txt | 34 -- htdocs/README.md | 7 - htdocs/alsa-core.html | 64 ---- htdocs/alsa-hal.html | 56 ---- htdocs/audio-control.html | 28 -- htdocs/docs/AAAA-architecture.odg | Bin 28177 -> 0 bytes htdocs/docs/AAAA-architecture.pdf | Bin 36596 -> 0 bytes htdocs/index.html | 10 - nbproject/configurations.xml | 201 ----------- nbproject/project.xml | 26 -- 57 files changed, 4600 deletions(-) delete mode 100644 .gitignore delete mode 100644 .gitmodules delete mode 100644 Apache-2.0 delete mode 100644 CMakeLists.txt delete mode 100644 MOST_UNICENS/CMakeLists.txt delete mode 100644 MOST_UNICENS/README.md delete mode 100644 MOST_UNICENS/hal_most_unicens.c delete mode 100644 MOST_UNICENS/ucs2-vol/CMakeLists.txt delete mode 100644 MOST_UNICENS/ucs2-vol/inc/device_container.h delete mode 100644 MOST_UNICENS/ucs2-vol/inc/device_value.h delete mode 100644 MOST_UNICENS/ucs2-vol/inc/libmostvolume.h delete mode 100644 MOST_UNICENS/ucs2-vol/inc/setup.h delete mode 100644 MOST_UNICENS/ucs2-vol/src/CMakeLists.txt delete mode 100644 MOST_UNICENS/ucs2-vol/src/device_container.cpp delete mode 100644 MOST_UNICENS/ucs2-vol/src/device_value.cpp delete mode 100644 MOST_UNICENS/ucs2-vol/src/libmostvolume.cpp delete mode 100644 MOST_UNICENS/ucs2-vol/src/setup.cpp delete mode 100644 MOST_UNICENS/wrap_unicens.c delete mode 100644 MOST_UNICENS/wrap_unicens.h delete mode 100644 MOST_UNICENS/wrap_volume.c delete mode 100644 MOST_UNICENS/wrap_volume.h delete mode 100644 README.md delete mode 160000 afb-utilities delete mode 100755 conf.d/autobuild/agl/autobuild delete mode 100755 conf.d/autobuild/linux/autobuild delete mode 100644 conf.d/cmake/config.cmake delete mode 100644 conf.d/packaging/agl-afb-aaaa_0.1.orig.tar.gz delete mode 100644 conf.d/project/CMakeLists.txt delete mode 100644 conf.d/project/alsa.d/README.md delete mode 100644 conf.d/project/alsa.d/asoundrc.sample delete mode 100644 conf.d/project/alsa.d/ucm.sample/HDA Intel PCH.conf delete mode 100644 conf.d/project/alsa.d/ucm.sample/HiFi.conf delete mode 100644 conf.d/project/alsa.d/ucm.sample/README delete mode 100644 conf.d/project/json.d/CMakeLists.txt delete mode 100644 conf.d/project/json.d/README.md delete mode 100644 conf.d/project/json.d/onload-aaaa-sample.json delete mode 100644 conf.d/project/lua.d/CMakeLists.txt delete mode 100644 conf.d/project/lua.d/README.md delete mode 100644 conf.d/project/lua.d/netbeans-aaaa-run-config.png delete mode 100644 conf.d/project/lua.d/onload-aaaa-00-utils.lua delete mode 100644 conf.d/project/lua.d/onload-aaaa-01-init.lua delete mode 100644 conf.d/project/lua.d/onload-aaaa-03-controls.lua delete mode 100644 conf.d/project/lua.d/onload-aaaa-10-event.lua delete mode 160000 hal-utilities-4a delete mode 100644 htdocs/AFB-websock.js delete mode 100644 htdocs/AudioBinding.css delete mode 100644 htdocs/AudioBinding.js delete mode 100644 htdocs/CMakeLists.txt delete mode 100644 htdocs/README.md delete mode 100644 htdocs/alsa-core.html delete mode 100644 htdocs/alsa-hal.html delete mode 100644 htdocs/audio-control.html delete mode 100644 htdocs/docs/AAAA-architecture.odg delete mode 100644 htdocs/docs/AAAA-architecture.pdf delete mode 100644 htdocs/index.html delete mode 100644 nbproject/configurations.xml delete mode 100644 nbproject/project.xml diff --git a/.gitignore b/.gitignore deleted file mode 100644 index 8b1cf74..0000000 --- a/.gitignore +++ /dev/null @@ -1,6 +0,0 @@ -build/ -CMakeCache.txt -Makefile -*.so -nbproject/private -.~lock* diff --git a/.gitmodules b/.gitmodules deleted file mode 100644 index 5b5c829..0000000 --- a/.gitmodules +++ /dev/null @@ -1,12 +0,0 @@ -[submodule "conf.d/app-templates"] - path = conf.d/app-templates - url = https://gerrit.automotivelinux.org/gerrit/apps/app-templates - branch=. -[submodule "afb-utilities"] - path = afb-utilities - url = https://gerrit.automotivelinux.org/gerrit/apps/app-afb-helpers-submodule - branch=. -[submodule "hal-utilities-4a"] - path = hal-utilities-4a - url = https://gerrit.automotivelinux.org/gerrit/src/4a-hal-utilities - branch=. diff --git a/Apache-2.0 b/Apache-2.0 deleted file mode 100644 index b3201ab..0000000 --- a/Apache-2.0 +++ /dev/null @@ -1,204 +0,0 @@ - - - Apache License - Version 2.0, January 2004 - http://www.apache.org/licenses/ - - TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION - - 1. Definitions. - - "License" shall mean the terms and conditions for use, reproduction, - and distribution as defined by Sections 1 through 9 of this document. - - "Licensor" shall mean the copyright owner or entity authorized by - the copyright owner that is granting the License. - - "Legal Entity" shall mean the union of the acting entity and all - other entities that control, are controlled by, or are under common - control with that entity. For the purposes of this definition, - "control" means (i) the power, direct or indirect, to cause the - direction or management of such entity, whether by contract or - otherwise, or (ii) ownership of fifty percent (50%) or more of the - outstanding shares, or (iii) beneficial ownership of such entity. - - "You" (or "Your") shall mean an individual or Legal Entity - exercising permissions granted by this License. - - "Source" form shall mean the preferred form for making modifications, - including but not limited to software source code, documentation - source, and configuration files. - - "Object" form shall mean any form resulting from mechanical - transformation or translation of a Source form, including but - not limited to compiled object code, generated documentation, - and conversions to other media types. - - "Work" shall mean the work of authorship, whether in Source or - Object form, made available under the License, as indicated by a - copyright notice that is included in or attached to the work - (an example is provided in the Appendix below). - - "Derivative Works" shall mean any work, whether in Source or Object - form, that is based on (or derived from) the Work and for which the - editorial revisions, annotations, elaborations, or other modifications - represent, as a whole, an original work of authorship. For the purposes - of this License, Derivative Works shall not include works that remain - separable from, or merely link (or bind by name) to the interfaces of, - the Work and Derivative Works thereof. - - "Contribution" shall mean any work of authorship, including - the original version of the Work and any modifications or additions - to that Work or Derivative Works thereof, that is intentionally - submitted to Licensor for inclusion in the Work by the copyright owner - or by an individual or Legal Entity authorized to submit on behalf of - the copyright owner. For the purposes of this definition, "submitted" - means any form of electronic, verbal, or written communication sent - to the Licensor or its representatives, including but not limited to - communication on electronic mailing lists, source code control systems, - and issue tracking systems that are managed by, or on behalf of, the - Licensor for the purpose of discussing and improving the Work, but - excluding communication that is conspicuously marked or otherwise - designated in writing by the copyright owner as "Not a Contribution." - - "Contributor" shall mean Licensor and any individual or Legal Entity - on behalf of whom a Contribution has been received by Licensor and - subsequently incorporated within the Work. - - 2. Grant of Copyright License. Subject to the terms and conditions of - this License, each Contributor hereby grants to You a perpetual, - worldwide, non-exclusive, no-charge, royalty-free, irrevocable - copyright license to reproduce, prepare Derivative Works of, - publicly display, publicly perform, sublicense, and distribute the - Work and such Derivative Works in Source or Object form. - - 3. Grant of Patent License. Subject to the terms and conditions of - this License, each Contributor hereby grants to You a perpetual, - worldwide, non-exclusive, no-charge, royalty-free, irrevocable - (except as stated in this section) patent license to make, have made, - use, offer to sell, sell, import, and otherwise transfer the Work, - where such license applies only to those patent claims licensable - by such Contributor that are necessarily infringed by their - Contribution(s) alone or by combination of their Contribution(s) - with the Work to which such Contribution(s) was submitted. If You - institute patent litigation against any entity (including a - cross-claim or counterclaim in a lawsuit) alleging that the Work - or a Contribution incorporated within the Work constitutes direct - or contributory patent infringement, then any patent licenses - granted to You under this License for that Work shall terminate - as of the date such litigation is filed. - - 4. Redistribution. You may reproduce and distribute copies of the - Work or Derivative Works thereof in any medium, with or without - modifications, and in Source or Object form, provided that You - meet the following conditions: - - (a) You must give any other recipients of the Work or - Derivative Works a copy of this License; and - - (b) You must cause any modified files to carry prominent notices - stating that You changed the files; and - - (c) You must retain, in the Source form of any Derivative Works - that You distribute, all copyright, patent, trademark, and - attribution notices from the Source form of the Work, - excluding those notices that do not pertain to any part of - the Derivative Works; and - - (d) If the Work includes a "NOTICE" text file as part of its - distribution, then any Derivative Works that You distribute must - include a readable copy of the attribution notices contained - within such NOTICE file, excluding those notices that do not - pertain to any part of the Derivative Works, in at least one - of the following places: within a NOTICE text file distributed - as part of the Derivative Works; within the Source form or - documentation, if provided along with the Derivative Works; or, - within a display generated by the Derivative Works, if and - wherever such third-party notices normally appear. The contents - of the NOTICE file are for informational purposes only and - do not modify the License. You may add Your own attribution - notices within Derivative Works that You distribute, alongside - or as an addendum to the NOTICE text from the Work, provided - that such additional attribution notices cannot be construed - as modifying the License. - - You may add Your own copyright statement to Your modifications and - may provide additional or different license terms and conditions - for use, reproduction, or distribution of Your modifications, or - for any such Derivative Works as a whole, provided Your use, - reproduction, and distribution of the Work otherwise complies with - the conditions stated in this License. - - 5. Submission of Contributions. Unless You explicitly state otherwise, - any Contribution intentionally submitted for inclusion in the Work - by You to the Licensor shall be under the terms and conditions of - this License, without any additional terms or conditions. - Notwithstanding the above, nothing herein shall supersede or modify - the terms of any separate license agreement you may have executed - with Licensor regarding such Contributions. - - 6. Trademarks. This License does not grant permission to use the trade - names, trademarks, service marks, or product names of the Licensor, - except as required for reasonable and customary use in describing the - origin of the Work and reproducing the content of the NOTICE file. - - 7. Disclaimer of Warranty. Unless required by applicable law or - agreed to in writing, Licensor provides the Work (and each - Contributor provides its Contributions) on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or - implied, including, without limitation, any warranties or conditions - of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A - PARTICULAR PURPOSE. You are solely responsible for determining the - appropriateness of using or redistributing the Work and assume any - risks associated with Your exercise of permissions under this License. - - 8. Limitation of Liability. In no event and under no legal theory, - whether in tort (including negligence), contract, or otherwise, - unless required by applicable law (such as deliberate and grossly - negligent acts) or agreed to in writing, shall any Contributor be - liable to You for damages, including any direct, indirect, special, - incidental, or consequential damages of any character arising as a - result of this License or out of the use or inability to use the - Work (including but not limited to damages for loss of goodwill, - work stoppage, computer failure or malfunction, or any and all - other commercial damages or losses), even if such Contributor - has been advised of the possibility of such damages. - - 9. Accepting Warranty or Additional Liability. While redistributing - the Work or Derivative Works thereof, You may choose to offer, - and charge a fee for, acceptance of support, warranty, indemnity, - or other liability obligations and/or rights consistent with this - License. However, in accepting such obligations, You may act only - on Your own behalf and on Your sole responsibility, not on behalf - of any other Contributor, and only if You agree to indemnify, - defend, and hold each Contributor harmless for any liability - incurred by, or claims asserted against, such Contributor by reason - of your accepting any such warranty or additional liability. - - END OF TERMS AND CONDITIONS - - APPENDIX: How to apply the Apache License to your work. - - To apply the Apache License to your work, attach the following - boilerplate notice, with the fields enclosed by brackets "[]" - replaced with your own identifying information. (Don`t include - the brackets!) The text should be enclosed in the appropriate - comment syntax for the file format. We also recommend that a - file or class name and description of purpose be included on the - same "printed page" as the copyright notice for easier - identification within third-party archives. - - Copyright [yyyy] [name of copyright owner] - - 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. - diff --git a/CMakeLists.txt b/CMakeLists.txt deleted file mode 100644 index 22adb2a..0000000 --- a/CMakeLists.txt +++ /dev/null @@ -1,21 +0,0 @@ -########################################################################### -# Copyright 2015, 2016, 2017 IoT.bzh -# -# author: Fulup Ar Foll -# -# 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. -########################################################################### -CMAKE_MINIMUM_REQUIRED(VERSION 3.5) - -# Do not change this file, config is located into conf.d -include(${CMAKE_CURRENT_SOURCE_DIR}/conf.d/cmake/config.cmake) diff --git a/MOST_UNICENS/CMakeLists.txt b/MOST_UNICENS/CMakeLists.txt deleted file mode 100644 index 5d91d1e..0000000 --- a/MOST_UNICENS/CMakeLists.txt +++ /dev/null @@ -1,45 +0,0 @@ -########################################################################### -# Copyright 2015, 2016, 2017 IoT.bzh -# -# author: Fulup Ar Foll -# -# 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_unicens.c wrap_volume.c) - - # Binder exposes a unique public entry point - SET_TARGET_PROPERTIES(${TARGET_NAME} PROPERTIES - PREFIX "afb-" - LABELS "BINDING" - OUTPUT_NAME ${TARGET_NAME} - ) - - # Library dependencies (include updates automatically) - TARGET_LINK_LIBRARIES(${TARGET_NAME} - hal-utilities-4a - afb-helpers - 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/MOST_UNICENS/README.md b/MOST_UNICENS/README.md deleted file mode 100644 index 4ce4261..0000000 --- a/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/MOST_UNICENS/hal_most_unicens.c b/MOST_UNICENS/hal_most_unicens.c deleted file mode 100644 index d106d6e..0000000 --- a/MOST_UNICENS/hal_most_unicens.c +++ /dev/null @@ -1,240 +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 -#include "hal-interface.h" -#include "wrap-json.h" -#include "wrap_unicens.h" -#include "wrap_volume.h" - -#define ALSA_CARD_NAME "ep016ch" -#define ALSA_DEVICE_ID "hw:ep016ch" -#define PCM_MAX_CHANNELS 6 - -/* Define few private tag for not standard functions */ -#define PCM_Volume_Multimedia 1000 -#define PCM_Volume_Navigation 1001 -#define PCM_Volume_Emergency 1002 - -static int master_volume = 80; -static json_bool master_switch; -static int pcm_volume[PCM_MAX_CHANNELS] = {100,100,100,100,100,100}; - -static void unicens_apply_card_value(void *closure, struct json_object *j_obj){ - - int num_id = 0; - int values[6]; - - /* apply master volume */ - if (wrap_json_unpack(j_obj, "{s:i, s:[i!]}", "id", &num_id, "val", - &values[0]) - == 0) { - if (num_id == 1) { - AFB_NOTICE("unicens_apply_card_value: num_id: %d, value: %d", - num_id, - values[0]); - wrap_volume_master(values[0]); - 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) { - if (num_id == 2) { - AFB_NOTICE("unicens_apply_card_value: success, num_id: %d", num_id); - wrap_volume_pcm(&values[0], 6); - return; - } - } - - AFB_ERROR("unicens_apply_card_value: no card value applied"); -} - - -static void unicens_request_card_values_cb(void *closure, int status, struct json_object *j_response) { - - json_object *j_obj; - - AFB_INFO("unicens_request_card_values_cb: closure=%p status=%d, res=%s", closure, status, json_object_to_json_string(j_response)); - - if (json_object_object_get_ex(j_response, "response", &j_obj)) { - - wrap_json_optarray_for_all(j_obj, &unicens_apply_card_value, NULL); - } -} - -static __attribute__((unused)) 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); - -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=80, .name="Master Playback Volume"} - }, -#if 0 - /*{ .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"} - }, -#endif - { .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; - AFB_NOTICE("Initializing HAL-MOST-UNICENS-BINDING"); - - err = wrap_volume_init(); - if (err) { - AFB_ERROR("Failed to initialize wrapper for volume library"); - goto OnErrorExit; - } - - /* Step 1: Set output volume to pre-defined level */ - /* in order to avoid muted volume to be persistent after boot. */ - wrap_volume_master(80); - wrap_volume_pcm(pcm_volume, PCM_MAX_CHANNELS/*array size*/); - - /* Step 2: risk to have influence on mixer controls init */ - /* request of initial card values */ - /* unicens_request_card_values(ALSA_DEVICE_ID); */ - - 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_subscribe_sync(); - if (err) { - AFB_ERROR("Failed to subscribe to UNICENS binding"); - goto OnErrorExit; - } - -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/MOST_UNICENS/ucs2-vol/CMakeLists.txt b/MOST_UNICENS/ucs2-vol/CMakeLists.txt deleted file mode 100644 index c734639..0000000 --- a/MOST_UNICENS/ucs2-vol/CMakeLists.txt +++ /dev/null @@ -1,26 +0,0 @@ -########################################################################### -# Copyright 2015, 2016, 2017 IoT.bzh -# -# author: Fulup Ar Foll -# -# 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/MOST_UNICENS/ucs2-vol/inc/device_container.h b/MOST_UNICENS/ucs2-vol/inc/device_container.h deleted file mode 100644 index 9fabdb5..0000000 --- a/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 . - * - * 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/MOST_UNICENS/ucs2-vol/inc/device_value.h b/MOST_UNICENS/ucs2-vol/inc/device_value.h deleted file mode 100644 index c2fe0b1..0000000 --- a/MOST_UNICENS/ucs2-vol/inc/device_value.h +++ /dev/null @@ -1,104 +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 . - * - * 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 -#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, - DEVICE_VAL_FIBERDYNE_MASTER = 3 - -}; - -class CDeviceValue { -public: - CDeviceValue(uint16_t address, DeviceValueType type, uint16_t key, bool is_i2c); - 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 - bool FireControlMessage(lib_most_volume_sendmessage_cb_t sendmsg_fptr); - - 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 - bool _is_i2c; - 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/MOST_UNICENS/ucs2-vol/inc/libmostvolume.h b/MOST_UNICENS/ucs2-vol/inc/libmostvolume.h deleted file mode 100644 index 5335754..0000000 --- a/MOST_UNICENS/ucs2-vol/inc/libmostvolume.h +++ /dev/null @@ -1,114 +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 . - * - * 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 - - -#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 int (*lib_most_volume_sendmessage_cb_t)(uint16_t node, uint16_t msgid, uint8_t *data_ptr, uint8_t data_sz); - -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_sendmessage_cb_t sendmsg_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/MOST_UNICENS/ucs2-vol/inc/setup.h b/MOST_UNICENS/ucs2-vol/inc/setup.h deleted file mode 100644 index 3be8bf4..0000000 --- a/MOST_UNICENS/ucs2-vol/inc/setup.h +++ /dev/null @@ -1,73 +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 . - * - * 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; - - CDeviceValue _volume_amp_510_m; - - 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/MOST_UNICENS/ucs2-vol/src/CMakeLists.txt b/MOST_UNICENS/ucs2-vol/src/CMakeLists.txt deleted file mode 100644 index 1be7184..0000000 --- a/MOST_UNICENS/ucs2-vol/src/CMakeLists.txt +++ /dev/null @@ -1,39 +0,0 @@ -########################################################################### -# Copyright 2015, 2016, 2017 IoT.bzh -# -# author: Fulup Ar Foll -# -# 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/MOST_UNICENS/ucs2-vol/src/device_container.cpp b/MOST_UNICENS/ucs2-vol/src/device_container.cpp deleted file mode 100644 index 3448a23..0000000 --- a/MOST_UNICENS/ucs2-vol/src/device_container.cpp +++ /dev/null @@ -1,194 +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 . - * - * You may also obtain this software under a propriety license from Microchip. - * Please contact Microchip for further information. - * - */ - -#include -#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]->GetType() == DEVICE_VAL_FIBERDYNE_MASTER) - { - _values_pptr[_idx_processing]->FireControlMessage(this->_init_ptr->sendmsg_cb); - } - else - { - 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/MOST_UNICENS/ucs2-vol/src/device_value.cpp b/MOST_UNICENS/ucs2-vol/src/device_value.cpp deleted file mode 100644 index 22b8dfb..0000000 --- a/MOST_UNICENS/ucs2-vol/src/device_value.cpp +++ /dev/null @@ -1,175 +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 . - * - * You may also obtain this software under a propriety license from Microchip. - * Please contact Microchip for further information. - * - */ -#include -#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, bool is_i2c) -{ - this->_is_available = false; - this->_is_busy = false; - this->_address = address; - this->_is_i2c = is_i2c; - 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 - - if (type == DEVICE_VAL_FIBERDYNE_MASTER) - _tx_payload_sz = 2u; - else - _tx_payload_sz = 3u; -} - -CDeviceValue::~CDeviceValue() -{ -} - -void CDeviceValue::ApplyMostValue(uint8_t value, DeviceValueType type, uint8_t tx_payload[]) -{ - uint16_t tmp = MUTE_VALUE; - - if (type == DEVICE_VAL_FIBERDYNE_MASTER) - { - tx_payload[0] = 0x00U; - tx_payload[1] = value; - - return; - } - - 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::FireControlMessage(lib_most_volume_sendmessage_cb_t sendmsg_fptr) -{ - ApplyMostValue(this->_target_value, _type, _tx_payload); - - if (this->_is_available && !this->_is_busy) - { - sendmsg_fptr(this->_address, 0x100U, _tx_payload, _tx_payload_sz); - - this->_actual_value = this->_target_value; - } - - return true; -} - -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/MOST_UNICENS/ucs2-vol/src/libmostvolume.cpp b/MOST_UNICENS/ucs2-vol/src/libmostvolume.cpp deleted file mode 100644 index 35f769f..0000000 --- a/MOST_UNICENS/ucs2-vol/src/libmostvolume.cpp +++ /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 . - * - * 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 -/*#include */ - -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;*/ - AFB_NOTICE("lib_most_volume_set"); - - 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/MOST_UNICENS/ucs2-vol/src/setup.cpp b/MOST_UNICENS/ucs2-vol/src/setup.cpp deleted file mode 100644 index ad841ab..0000000 --- a/MOST_UNICENS/ucs2-vol/src/setup.cpp +++ /dev/null @@ -1,96 +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 . - * - * You may also obtain this software under a propriety license from Microchip. - * Please contact Microchip for further information. - * - */ -#include -#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, true), - _volume_amp_270_l(0x270U, DEVICE_VAL_LEFT, LIB_MOST_VOLUME_CH_FRONT_LEFT, true), - _volume_amp_270_r(0x270U, DEVICE_VAL_RIGHT, LIB_MOST_VOLUME_CH_FRONT_RIGHT, true), - _volume_amp_271_m(0x271U, DEVICE_VAL_MASTER, LIB_MOST_VOLUME_MASTER, true), - _volume_amp_271_l(0x271U, DEVICE_VAL_LEFT, LIB_MOST_VOLUME_CH_REAR_LEFT, true), - _volume_amp_271_r(0x271U, DEVICE_VAL_RIGHT, LIB_MOST_VOLUME_CH_REAR_RIGHT, true), - _volume_amp_272_m(0x272U, DEVICE_VAL_MASTER, LIB_MOST_VOLUME_MASTER, true), - _volume_amp_272_l(0x272U, DEVICE_VAL_LEFT, LIB_MOST_VOLUME_CH_CENTER, true), - _volume_amp_272_r(0x272U, DEVICE_VAL_RIGHT, LIB_MOST_VOLUME_CH_SUB, true), - _volume_amp_510_m(0x510U, DEVICE_VAL_FIBERDYNE_MASTER, LIB_MOST_VOLUME_MASTER, false), - _value_container() -{ - static CDeviceValue* value_list[10] = { &_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, - &_volume_amp_510_m}; - - _value_container.RegisterValues(value_list, 10U); -} - -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/MOST_UNICENS/wrap_unicens.c b/MOST_UNICENS/wrap_unicens.c deleted file mode 100644 index 4b75780..0000000 --- a/MOST_UNICENS/wrap_unicens.c +++ /dev/null @@ -1,368 +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 -#include -#include -#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; -} - -extern int wrap_ucs_sendmessage(uint16_t src_addr, uint16_t msg_id, uint8_t *data_ptr, uint8_t data_sz) { - - json_object *j_query, *j_response = NULL; - int err; - int node = (int)src_addr; - int msgid = (int)msg_id; - size_t data_size = (size_t)data_sz; - - /* skip data attribute if possible, wrap_json_unpack may fail to deal with - * an empty Base64 string */ - if (data_size > 0) - wrap_json_pack(&j_query, "{s:i, s:i, s:Y}", "node", node, "msgid", msgid, "data", data_ptr, data_size); - else - wrap_json_pack(&j_query, "{s:i, s:i}", "node", node, "msgid", msgid); - - err = afb_service_call_sync("UNICENS", "sendmessage", j_query, &j_response); - - if (err) { - AFB_ERROR("Failed to call wrap_ucs_sendmessage"); - goto OnErrorExit; - } - else { - AFB_INFO("Called wrap_ucs_sendmessage, res=%s", json_object_to_json_string(j_response)); - json_object_put(j_response); - } - - j_query = NULL; - -OnErrorExit: - return err; -} diff --git a/MOST_UNICENS/wrap_unicens.h b/MOST_UNICENS/wrap_unicens.h deleted file mode 100644 index 734ea5d..0000000 --- a/MOST_UNICENS/wrap_unicens.h +++ /dev/null @@ -1,35 +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 - -/* 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); -extern int wrap_ucs_sendmessage(uint16_t src_addr, uint16_t msg_id, uint8_t *data_ptr, uint8_t data_sz); diff --git a/MOST_UNICENS/wrap_volume.c b/MOST_UNICENS/wrap_volume.c deleted file mode 100644 index 9f9ceff..0000000 --- a/MOST_UNICENS/wrap_volume.c +++ /dev/null @@ -1,133 +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 -#include -#include -#include -#include - -#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; - mv_init.sendmsg_cb = &wrap_ucs_sendmessage; - - 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/MOST_UNICENS/wrap_volume.h b/MOST_UNICENS/wrap_volume.h deleted file mode 100644 index 099b70c..0000000 --- a/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 -#include - -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/README.md b/README.md deleted file mode 100644 index c3d75a1..0000000 --- a/README.md +++ /dev/null @@ -1,264 +0,0 @@ ------------------------------------------------------------------------- - AGL-Advanced-Audio-Agent ------------------------------------------------------------------------- - -# Cloning Audio-Binding from Git - -```bash -# Initial clone with submodules -git clone --recurse-submodules https://github.com/iotbzh/afb-aaaa -cd audio-binding - -# Do not forget submodules with pulling -git pull --recurse-submodules https://github.com/iotbzh/afb-aaaa -git submodule update -``` - -# AFB-daemon dependencies - -OpenSuse >=42.2, Fedora>=25, Ubuntu>=16.4 AGL Binary packages installation from -[this wiki](https://en.opensuse.org/LinuxAutomotive) - -For other distro see chapter [# Building AFB-daemon from source on Standard Linux Distribution](#Build) - -# Specific Dependencies - -* alsa-devel >= 1.1.3 Warning some distro like Fedora 25 still ship version 1.1.1 as default - -> **NOTE**: On Ubuntu 16.4 you should recompile AlsaLib from [source](ftp://ftp.alsa-project.org/pub/lib/) -> as today latest stable is 1.1.4. - - OpenSuse - - Alsa-devel ```zypper install alsa-devel # 42.3 is shipped default with 1.1.4``` - - Fedora 26 (out of the box) - - Alsa-devel 1.1.4 - - Ubuntu-16.4 - - Alsa should be recompiled from source - -```bash -wget ftp://ftp.alsa-project.org/pub/lib/alsa-lib-1.1.4.1.tar.bz2 -tar -xjf alsa-lib-1.1.4.1.tar.bz2 -cd alsa-lib-1.1.4.1 -./configure --prefix=/opt -``` - - Ubuntu-17.04 (out of the box) - - Alsa 1.1.4 - -> **WARNING**: do not forget to upgrade your PKG_CONFIG_PATH=/opt/lib/pkgconfig -> or whatever is the place where your installed alsa. - -# Compile AGL-Advanced-Audio-Agent - -* Edit your ~/.config/app-templates/cmake.d/00-common-userconf.cmake to reflect - your local configuration - -```cmake - message(STATUS "*** Fulup Local Config For Native Linux ***") - add_compile_options(-DNATIVE_LINUX) - - set (RSYNC_TARGET "10.20.101.198") - set (RSYNC_PREFIX "opt") - - set(CMAKE_INSTALL_PREFIX $ENV{HOME}/opt) - set(BINDINGS_INSTALL_PREFIX $ENV{HOME}/opt) - - set(CMAKE_PREFIX_PATH ${CMAKE_INSTALL_PREFIX}/lib64/pkgconfig ${CMAKE_INSTALL_PREFIX}/lib/pkgconfig) - set(LD_LIBRARY_PATH ${CMAKE_INSTALL_PREFIX}/lib64 ${CMAKE_INSTALL_PREFIX}/lib) - -``` - -```bash - mkdir -p build - cd build - cmake -DCMAKE_INSTALL_PREFIX=$INSTALL_PREFIX .. - make - - # Note: - 1) Controller is now a standalone project and should added on top of project bindings - 2) If you want monitoring add '--alias=/monitoring:$HOME/opt/afb-monitoring' (should point to monitoring HTML5 pages) - 3) To expose AAAA control interface add '--ws-server=unix:/var/tmp/afb-ws/ctl-aaaa' - - afb-daemon --workdir=. --ldpaths=. --binding=../../afb-controller/build/afb-source/afb-control-afb.so --port=1234 --roothttp=../htdocs --token="" --verbose - - - Warning: See below net on GDB requiring (--workdir=.) -``` - -# Note: GDB Source Debug limits/features - -Warning: technically AGL bindings are shared libraries loaded thought 'dlopen'. GDB supports source debug of dynamically -loaded libraries, but user should be warn that the actual path to sharelib symbols is directly inherited from DLOPEN. -As a result if you change your directory after binder start with --workdir=xxx then GDB will stop working. - -Conclusion: double-check that --workdir=. and run debug session from ./build directory. Any IDEs like Netbeans or VisualCode should work out of the box. - -```bash - Examples: - - # WORK when running in direct - afb-daemon --workdir=.. --ldpaths=build --port=1234 --roothttp=./htdocs - - # FAIL when using GDB with warning: Could not load shared library .... - gdb -args afb-daemon --workdir=.. --ldpaths=build --port=1234 --roothttp=./htdocs - ... - warning: Could not load shared library symbols for ./build/ucs2-afb/afb-ucs2.so. - Do you need "set solib-search-path" or "set sysroot"? - ... -``` - -To debug sharelib symbol path: start your binder under GDB. Then break your session after the binder has -loaded its bindings. Finally use "info sharedlibrary" and check 'SymsRead'. If equal to 'No' then either you start GDB -from the wrong relative directory, either you have to use 'set solib-search-path' to force the path. - -```bash - gdb -args afb-daemon --workdir=.. --ldpaths=build --port=1234 --roothttp=./htdocs - run - ... - NOTICE: API UNICENS added - NOTICE: Waiting port=1234 rootdir=. - NOTICE: Browser URL= http://localhost:1234 - (hit Ctrl-C to break the execution) - info sharedlibrary afb-* -``` - -# Running an debugging on a target - -```bash -export RSYNC_TARGET=root@xx.xx.xx.xx -export RSYNC_PREFIX=/opt # WARNING: installation directory should exist - -mkdir $RSYNC_TARGET -cd $RSYNC_TARGET - -cmake -DRSYNC_TARGET=$RSYNC_TARGET -DRSYNC_PREFIX=$RSYNC_PREFIX .. -make remote-target-populate - - ./build/target/start-${RSYNC_TARGET}.sh - firefox http://localhost:1234 # WARNING: do not forget firewall if any - - ssh -tt ${RSYNC_TARGET} speaker-test -twav -D hw:ep01 -c 2 -``` - -Note: remote-target-populate will - -* create a script to remotely start the binder on the target in ./build/target/start-on-target-name.sh -* create a gdbinit file to transparently debug remotely in source code with gdb -x ./build/target/gdb-on-target-name.ini -* to run and debug directly from your IDE just configure the run and debug properties with the corresponding filename -* run a generic control and pass virtual channel as a parameter (check remaning PCM in plugin) - -Note that Netbeans impose to set debug directory to ./build/pkgout or it won't find binding symbols for source debugging - -# Building AFB-daemon from source on Standard Linux Distribution - -## Handle dependencies using packager > (OpenSuse-42.2, Fedora-25, Ubuntu 16.04.2LTS) - -Using system package repositories: - -* gcc > 4.8 -* systemd-devel (libsystemd-dev>=222) -* libuuid-devel (OpenSuse) or uuid-dev (Ubuntu) -* file-devel(OpenSuSe) or libmagic-dev(Ubuntu) -* libjson-c-devel -* ElectricFence (BUG should not be mandatory) -* libopenssl-devel libgcrypt-devel libgnutls-devel (optional but requested by libmicrohttpd for https) - -Using [AGL repositories](https://en.opensuse.org/LinuxAutomotive): - -* libmicrohttpd>=0.9.55 (as today OpenSuse-42.2, 42.3 or Ubuntu-16.4 ship older versions) -* afb-daemon from AGL Gerrit ```git clone https://gerrit.automotivelinux.org/gerrit/src/app-framework-binder``` - -OpenSuse >= 42.2: - -```bash -export DISTRO="openSUSE_Leap_42.2" -sudo zypper ar http://download.opensuse.org/repositories/isv:/LinuxAutomotive:/app-Framework/${DISTRO}/isv:LinuxAutomotive:app-Framework.repo -sudo zypper ref -#For openSUSE_Leap_42.2 gcc config -sudo zypper install agl-gcc5-setup -#For openSUSE_Leap_42.3 gcc config -#sudo zypper install agl-gcc6-setup -#Install application framework -sudo zypper install agl-app-framework-binder - -# Other needed system devel packages: -zypper in gcc5 gdb gcc5-c++ git cmake make ElectricFence systemd-devel libopenssl-devel libuuid-devel alsa-devel libgcrypt-devel libgnutls-devel libjson-c-devel file-devel mxml-devel -``` - -Fedora >= 26: - -```bash -export DISTRO="Fedora_26" -sudo dnf config-manager --add-repo http://download.opensuse.org/repositories/isv:/LinuxAutomotive:/app-Framework/${DISTRO}/isv:LinuxAutomotive:app-Framework.repo -#Install application framework -sudo zypper install agl-app-framework-binder - -# Other needed system devel packages: -dnf install gdb git cmake make ElectricFence systemd-devel libopenssl-devel libuuid-devel alsa-devel libgcrypt-devel libgnutls-devel libjson-c-devel file-devel mxml-devel -``` - -Ubuntu >= 16.4: - -```bash -export DISTRO="xUbuntu_16.04" -wget -O - http://download.opensuse.org/repositories/isv:/LinuxAutomotive:/app-Framework/${DISTRO}/Release.key | sudo apt-key add - -sudo bash -c "cat >> /etc/apt/sources.list.d/AGL.list <>~/.bashrc - echo "# Object: AGL cmake option for binder/bindings" >>~/.bashrc - echo "# Date: `date`" >>~/.bashrc - echo 'export CC=gcc-5; export CXX=g++-5' >>~/.bashrc # if using gcc5 - echo 'export INSTALL_PREFIX=$HOME/opt' >>~/.bashrc - echo 'export LD_LIBRARY_PATH=$INSTALL_PREFIX/lib64:$INSTALL_PREFIX/lib' >>~/.bashrc - echo 'export LIBRARY_PATH=$INSTALL_PREFIX/lib64:$INSTALL_PREFIX/lib' >>~/.bashrc - echo 'export PKG_CONFIG_PATH=$INSTALL_PREFIX/lib64/pkgconfig:$INSTALL_PREFIX/lib/pkgconfig' >>~/.bashrc - echo 'export PATH=$INSTALL_PREFIX/bin:$PATH' >>~/.bashrc - echo 'export RSYNC_TARGET=MY_TARGET_HOSTNAME' >>~/.bashrc - echo 'export RSYNC_PREFIX=./opt' >>~/.bashrc - - echo "#---------- AGL options End ---------" >>~/.bashrc - source ~/.bashrc -``` - -## Handle dependencies from sources - -Install devel packages from your system official repositories and use the -following instructions to install `libmicrohttpd` and `app-framework-binder`: - -```bash - # install LibMicroHttpd - LIB_MH_VERSION=0.9.55 - wget https://ftp.gnu.org/gnu/libmicrohttpd/libmicrohttpd-${LIB_MH_VERSION}.tar.gz - tar -xzf libmicrohttpd-${LIB_MH_VERSION}.tar.gz - cd libmicrohttpd-${LIB_MH_VERSION} - ./configure --prefix=${INSTALL_PREFIX} - make - sudo make install-strip - - # retrieve last AFB_daemon from AGL - git clone https://gerrit.automotivelinux.org/gerrit/src/app-framework-binder - - # Warning: previous GCC options should be set before initial cmake (clean Build/*) - cd app-framework-binder; mkdir -p build; cd build - cmake -DCMAKE_INSTALL_PREFIX=$INSTALL_PREFIX .. - make - make install -``` diff --git a/afb-utilities b/afb-utilities deleted file mode 160000 index f0ce5b6..0000000 --- a/afb-utilities +++ /dev/null @@ -1 +0,0 @@ -Subproject commit f0ce5b665dd33b285d723720c16ac0542cde4e6e diff --git a/conf.d/autobuild/agl/autobuild b/conf.d/autobuild/agl/autobuild deleted file mode 100755 index 3a1ba5f..0000000 --- a/conf.d/autobuild/agl/autobuild +++ /dev/null @@ -1,67 +0,0 @@ -#!/usr/bin/make -f -# Copyright (C) 2015, 2016 "IoT.bzh" -# Author "Romain Forlot" -# -# 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. - -THISFILE := $(lastword $(MAKEFILE_LIST)) -BUILD_DIR := $(abspath $(dir $(THISFILE)/../../../../..)/build) -DEST := ${BUILD_DIR}/target - -.PHONY: all clean distclean configure build package help update - -all: help - -help: - @echo "List of targets available:" - @echo "" - @echo "- all" - @echo "- clean" - @echo "- distclean" - @echo "- configure" - @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" - -update: configure - @cmake --build ${BUILD_DIR} --target autobuild - -clean: - @([ -d ${BUILD_DIR} ] && make -C ${BUILD_DIR} clean) || echo Nothing to clean - -distclean: - @rm -rf ${BUILD_DIR} - -configure: ${BUILD_DIR}/Makefile - -build: configure - @cmake --build ${BUILD_DIR} ${BUILD_ARGS} --target all - -package: build - @mkdir -p ${BUILD_DIR}/$@/bin - @mkdir -p ${BUILD_DIR}/$@/etc - @mkdir -p ${BUILD_DIR}/$@/lib - @mkdir -p ${BUILD_DIR}/$@/htdocs - @mkdir -p ${BUILD_DIR}/$@/data - @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 deleted file mode 100755 index 3a1ba5f..0000000 --- a/conf.d/autobuild/linux/autobuild +++ /dev/null @@ -1,67 +0,0 @@ -#!/usr/bin/make -f -# Copyright (C) 2015, 2016 "IoT.bzh" -# Author "Romain Forlot" -# -# 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. - -THISFILE := $(lastword $(MAKEFILE_LIST)) -BUILD_DIR := $(abspath $(dir $(THISFILE)/../../../../..)/build) -DEST := ${BUILD_DIR}/target - -.PHONY: all clean distclean configure build package help update - -all: help - -help: - @echo "List of targets available:" - @echo "" - @echo "- all" - @echo "- clean" - @echo "- distclean" - @echo "- configure" - @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" - -update: configure - @cmake --build ${BUILD_DIR} --target autobuild - -clean: - @([ -d ${BUILD_DIR} ] && make -C ${BUILD_DIR} clean) || echo Nothing to clean - -distclean: - @rm -rf ${BUILD_DIR} - -configure: ${BUILD_DIR}/Makefile - -build: configure - @cmake --build ${BUILD_DIR} ${BUILD_ARGS} --target all - -package: build - @mkdir -p ${BUILD_DIR}/$@/bin - @mkdir -p ${BUILD_DIR}/$@/etc - @mkdir -p ${BUILD_DIR}/$@/lib - @mkdir -p ${BUILD_DIR}/$@/htdocs - @mkdir -p ${BUILD_DIR}/$@/data - @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 deleted file mode 100644 index 4bb272f..0000000 --- a/conf.d/cmake/config.cmake +++ /dev/null @@ -1,232 +0,0 @@ -########################################################################### -# Copyright 2015, 2016, 2017 IoT.bzh -# -# author: Fulup Ar Foll -# -# 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. -########################################################################### - -# Project Info -# ------------------ -set(PROJECT_NAME afb-aaaa) -set(PROJECT_VERSION "0.1") -set(PROJECT_PRETTY_NAME "Audio Agent") -set(PROJECT_DESCRIPTION "Expose Alsa through AGL AppFw") -set(PROJECT_URL "https://github.com/iotbzh/audio-bindings") -set(PROJECT_ICON "icon.png") -set(PROJECT_AUTHOR "Fulup, Ar Foll") -set(PROJECT_AUTHOR_MAIL "fulup@iot.bzh") -set(PROJECT_LICENSE "Apache-V2") -set(PROJECT_LANGUAGES,"C") - -# Where are stored the project configuration files -# relative to the root project directory -set(PROJECT_CMAKE_CONF_DIR "conf.d") - -# Where are stored your external libraries for your project. This is 3rd party library that you don't maintain -# but used and must be built and linked. -# set(PROJECT_LIBDIR "libs") - -# Where are stored data for your application. Pictures, static resources must be placed in that folder. -# set(PROJECT_RESOURCES "data") - -# Which directories inspect to find CMakeLists.txt target files -set(PROJECT_SRC_DIR_PATTERN "[^_]*") - -# Compilation Mode (DEBUG, RELEASE) -# ---------------------------------- -set(CMAKE_BUILD_TYPE "DEBUG") - -# Kernel selection if needed. You can choose between a -# mandatory version to impose a minimal version. -# Or check Kernel minimal version and just print a Warning -# about missing features and define a preprocessor variable -# to be used as preprocessor condition in code to disable -# incompatibles features. Preprocessor define is named -# KERNEL_MINIMAL_VERSION_OK. -# -# NOTE*** FOR NOW IT CHECKS KERNEL Yocto environment and -# Yocto SDK Kernel version. -# ----------------------------------------------- -#set (kernel_mandatory_version 4.8) -#set (kernel_minimal_version 4.8) - -# Compiler selection if needed. Impose a minimal version. -# ----------------------------------------------- -set (gcc_minimal_version 4.9) - -# PKG_CONFIG required packages -# ----------------------------- -set (PKG_REQUIRED_LIST - json-c - libsystemd>=222 - afb-daemon - libmicrohttpd>=0.9.55 - libafbwsc - alsa>=1.1.2 -) - -# Prefix path where will be installed the files -# Default: /usr/local (need root permission to write in) -# ------------------------------------------------------ -#set(CMAKE_INSTALL_PREFIX $ENV{HOME}/opt) - -# Customize link option -# ----------------------------- -list(APPEND link_libraries -lpthread -lm) - -# Compilation options definition -# Use CMake generator expressions to specify only for a specific language -# Values are prefilled with default options that is currently used. -# Either separate options with ";", or each options must be quoted separately -# DO NOT PUT ALL OPTION QUOTED AT ONCE , COMPILATION COULD FAILED ! -# ---------------------------------------------------------------------------- -#set(COMPILE_OPTIONS -#-Wall -#-Wextra -#-Wconversion -#-Wno-unused-parameter -#-Wno-sign-compare -#-Wno-sign-conversion -#-Werror=maybe-uninitialized -#-Werror=implicit-function-declaration -#-ffunction-sections -#-fdata-sections -#-fPIC -# Personal compilation options -#-DMAX_SND_CARD=16 # should be more than enough even in luxury vehicule -#-DMAX_LINEAR_DB_SCALE=24 # until 24db volume normalisation use a simple linear scale -#-DTLV_BYTE_SIZE=256 # Alsa use 4096 as default but 256 should fit most sndcards -#-DCONTROL_MAXPATH_LEN=255 -# CACHE STRING "Compilation flags") - -add_compile_options(-DAFB_BINDING_VERSION=2) -add_compile_options(-DMAX_SND_CARD=16) # should be more than enough even in luxury vehicule -add_compile_options(-DMAX_LINEAR_DB_SCALE=24) # until 24db volume normalisation use a simple linear scale -add_compile_options(-DTLV_BYTE_SIZE=256) # Alsa use 4096 as default but 256 should fit most sndcards -add_compile_options(-DCONTROL_MAXPATH_LEN=255) - -#set(C_COMPILE_OPTIONS "" CACHE STRING "Compilation flags for C language.") -#set(CXX_COMPILE_OPTIONS "" CACHE STRING "Compilation flags for C++ language.") -#set(PROFILING_COMPILE_OPTIONS -# -g -# -O0 -# -pg -# -Wp,-U_FORTIFY_SOURCE -# CACHE STRING "Compilation flags for PROFILING build type.") -#set(DEBUG_COMPILE_OPTIONS -# -g -# -ggdb -# -Wp,-U_FORTIFY_SOURCE -# CACHE STRING "Compilation flags for DEBUG build type.") -#set(CCOV_COMPILE_OPTIONS -# -g -# -O2 -# --coverage -# CACHE STRING "Compilation flags for CCOV build type.") -#set(RELEASE_COMPILE_OPTIONS -# -g -# -O2 -# CACHE STRING "Compilation flags for RELEASE build type.") - -# (BUG!!!) as PKG_CONFIG_PATH does not work [should be an env variable] -# --------------------------------------------------------------------- -set(CMAKE_PREFIX_PATH ${CMAKE_INSTALL_PREFIX}/lib64/pkgconfig ${CMAKE_INSTALL_PREFIX}/lib/pkgconfig) -set(LD_LIBRARY_PATH ${CMAKE_INSTALL_PREFIX}/lib64 ${CMAKE_INSTALL_PREFIX}/lib) -set(HTTPDIR unicens CACHE PATH "Directory holding HTML5 files") - -# Optional location for config.xml.in -# ----------------------------------- -#set(WIDGET_ICON conf.d/wgt/${PROJECT_ICON} CACHE PATH "Path to the widget icon") -#set(WIDGET_CONFIG_TEMPLATE ${CMAKE_CURRENT_SOURCE_DIR}/conf.d/wgt/config.xml.in CACHE PATH "Path to widget config file template (config.xml.in)") - -# Mandatory widget Mimetype specification of the main unit -# -------------------------------------------------------------------------- -# Choose between : -#- text/html : HTML application, -# content.src designates the home page of the application -# -#- application/vnd.agl.native : AGL compatible native, -# content.src designates the relative path of the binary. -# -# - application/vnd.agl.service: AGL service, content.src is not used. -# -#- ***application/x-executable***: Native application, -# content.src designates the relative path of the binary. -# For such application, only security setup is made. -# -set(WIDGET_TYPE MimeType_Not_Set) - -# Mandatory Widget entry point file of the main unit -# -------------------------------------------------------------- -# This is the file that will be executed, loaded, -# at launch time by the application framework. -# -set(WIDGET_ENTRY_POINT EntryPoint_Path_Not_Set) - -# Optional dependencies order -# --------------------------- -#set(EXTRA_DEPENDENCIES_ORDER) - -# Optional Extra global include path -# ----------------------------------- -#set(EXTRA_INCLUDE_DIRS) - -# Optional extra libraries -# ------------------------- -#set(EXTRA_LINK_LIBRARIES) - -# Optional force binding Linking flag -# ------------------------------------ -# set(BINDINGS_LINK_FLAG LinkOptions ) - -# Optional force package prefix generation, like widget -# ----------------------------------------------------- -# set(PKG_PREFIX DestinationPath) - -# Optional Application Framework security token -# and port use for remote debugging. -#------------------------------------------------------------ -set(AFB_TOKEN "" CACHE PATH "Default binder security token") -set(AFB_REMPORT "1234" CACHE PATH "Default binder listening port") - -# Print a helper message when every thing is finished -# ---------------------------------------------------- -if(IS_DIRECTORY $ENV{HOME}/opt/afb-monitoring) -set(MONITORING_ALIAS "--alias=/monitoring:$ENV{HOME}/opt/afb-monitoring") -endif() - -if(EXISTS ${CMAKE_SOURCE_DIR}/../afb-controller/build/afb-source/afb-control-afb.so) -set(CTL_BUILD_PATH "--binding=../../afb-controller/build/afb-source/afb-control-afb.so") -endif() -set(CLOSING_MESSAGE "Debug from afb-daemon --port=1234 ${MONITORING_ALIAS} --ldpaths=. ${CTL_BUILD_PATH} --workdir=. --roothttp=../htdocs --tracereq=common --token= --verbose ") -set(PACKAGE_MESSAGE "Install widget file using in the target : afm-util install ${PROJECT_NAME}.wgt") - -# When Present LUA is used by the controller -# --------------------------------------------------------------- -set(CONTROL_SUPPORT_LUA 1 CACHE BOOL "Active or not LUA Support") - -# Optional schema validator about now only XML, LUA and JSON -# are supported -#------------------------------------------------------------ -#set(LUA_CHECKER "luac" "-p" CACHE STRING "LUA compiler") -#set(XML_CHECKER "xmllint" CACHE STRING "XML linter") -#set(JSON_CHECKER "json_verify" CACHE STRING "JSON linter") - -# This include is mandatory and MUST happens at the end -# of this file, else you expose you to unexpected behavior -# -# This CMake module could be found at the following url: -# https://gerrit.automotivelinux.org/gerrit/#/admin/projects/src/cmake-apps-module -# ----------------------------------------------------------- -include(CMakeAfbTemplates) diff --git a/conf.d/packaging/agl-afb-aaaa_0.1.orig.tar.gz b/conf.d/packaging/agl-afb-aaaa_0.1.orig.tar.gz deleted file mode 100644 index 6a5980d..0000000 Binary files a/conf.d/packaging/agl-afb-aaaa_0.1.orig.tar.gz and /dev/null differ diff --git a/conf.d/project/CMakeLists.txt b/conf.d/project/CMakeLists.txt deleted file mode 100644 index fd4d454..0000000 --- a/conf.d/project/CMakeLists.txt +++ /dev/null @@ -1,24 +0,0 @@ -########################################################################### -# Copyright 2015, 2016, 2017 IoT.bzh -# -# author: Fulup Ar Foll -# -# 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 anything not starting with _ -PROJECT_SUBDIRS_ADD(${PROJECT_SRC_DIR_PATTERN}) - - diff --git a/conf.d/project/alsa.d/README.md b/conf.d/project/alsa.d/README.md deleted file mode 100644 index aa2a54e..0000000 --- a/conf.d/project/alsa.d/README.md +++ /dev/null @@ -1,175 +0,0 @@ - -Alsa Configuration is not complex, but it's heavy and every except intuitive. - -In order to set your configuration move step by step. And verify at each new step that you did not introduce a regression. - -### Make sure your board is not taken by PulseAudio - -* Pavucontrol is your friend. Go in device configuration and switch to off the device you want to make available to ALSA. -* Check for your device list with 'play -l'. Note that just after card number your get an alias for your sound card. - it is simpler to use this alias, card number will change depending on plug/unplug of device when this alias name - is more stable (except for few stupid driver who use 'USB' as sound card name. -* When your know your sound alias (eg:v1340 in mu case) you can test it with 'speaker-test -D v1340 -c2 -twav'. You may also - use sound card number with 'speaker-test -D hw:0 -c2 -twav'. Nevertheless as said previously this number is not stable. -* you are now ready to write your $HOME/.asoundrc config - -Note that $HOME/.asoundrc is loaded within libasound client and not by Alsa kernel, this is the reason why you do not need -to activate any control or restart a daemon for modifications to be taken in account. - -To use ALSA with AAAA and the controller you need to write 1 section in your ALSA config - -* Sound Card Mixer: Allows multiple audio stream to be played on the same sound card. If hardware support mixer, Alsa will use it. If - not it will provide mixing by software. -* Audio Role Volume: They provide independent volume for each audio role. For reference, we use Alsa softvolume, depending on - your hardware you may have this directly avaliable from your sound card. -* Authorised Audio PCM: those channel are designed for applications we do not trust and then enforce AAAA control check - before granting the access to a given channel. - -### Sound Card Mixer - -``` -pcm.SoundCardMixer { - type dmix - ipc_key 1024 - ipc_key_add_uid false - ipc_perm 0666 # mixing for all users - - # Define target effective sound card (cannot be a plugin) - slave { pcm "hw:v1340" } #Jabra Solmate - - # DMIX can only map two channels - bindings { - 0 0 - 1 1 - } -} -``` - -Warning: if you have more than one Mixer each of them should have a unique ipc_key. You sound card alias move in the slave section. -When this is done you may try your mixer with: - -``` - speaker-test -D MyMixerPCM -c2 -twav -``` - - -### Audio Role - -``` -pcm.NavigationRole { - type softvol - - # Point Slave on HOOK for policies control - slave.pcm "SoundCardMixer" - - # name should match with HAL but do not set card=xx - control.name "Playback Navigation" - -} - -``` - -The slave you point to your SoundCardMixer, and the control.name should be EXACTLY the same as the one defined in your HAL. - - -WARNING: The control here "Playback Navigation" is a user defined kernel control. It means that this kernel is created in -kernel space, but that its action happen in user space. When create those control remains visible until you reset your -sound card (eg: unplug USB), but they are save each time you reboot. It is recommended to start AAAA binder before testing -your softvol audio role channel. If you do the opposite the control will be create by Alsa Plugin and this will not inherit -of the default value you have in your HAL. - -When in place you should test it with: -``` - speaker-test -D NavigationRole -c2 -twav -``` - -IMPORTANT: control volume are attache to your physical hardware and not to intermediary level (Softvol or Mixer). To see the -newly created channel you should use -``` - amixer -Dhw:v1340 controls | grep -i playback -``` - -## Authorised Audio PCM - -This PCM is supervised with the AAAA audio hook plugin. The pluging and will any application request on this PCM and will -1st request an autorisation from AAAA controller to grant access for the client application. To do so, two things: -* the plugin should be declared (only once) -* you should declare as many authorized PCM as you need. - -### Plugin declaration - -``` -pcm_hook_type.MyHookPlugin { - install "AlsaInstallHook" - lib "/home/fulup/Workspace/AGL-AppFW/audio-bindings-dev/build/Alsa-Plugin/Alsa-Policy-Hook/policy_hook_cb.so" -} - -``` - -Lib is the path where to find AAAA Alsa hook plugin, install is the name of the init function it should not be changed. - - -When your plugin is defined you may declare your authorised PCM. Those PCM like softvol will take a slave, typically a lower -level of the audio role, or directly a mixer if your goal is to protect directly the Mixer. The AAAA Plugin hook take as - -``` -pcm.AuthorisedToNavigationOnly { - type hooks - slave.pcm "NavigationRole" - # Defined used hook sharelib and provide arguments/config to install func - hooks.0 { - type "MyHookPlugin" - hook_args { - verbose true # print few log messages (default false); - - # Every Call should return OK in order PCM to open (default timeout 100ms) - uri "ws://localhost:1234/api?token=audio-agent-token&uuid=audio-agent-session" - request { - # Request autorisation to write on navigation - RequestNavigation { - api "control" - verb "dispatch" - query "{'target':'navigation', 'args':{'device':'Jabra SOLEMATE v1.34.0'}}" - } - } - # map event reception to self generated signal - event { - pause 30 - resume 31 - stop 3 - } - } - } -} - -``` - - * The slave is the PCM that application will be transfer to if access to control is granted. - * Request is a suite à control action that respond to AGL standard application framework API - * Event is the mapping of signal an appplication will receive in case AAAA controller push event to the audio application. - -When using AAAA controller, most action should be transfert to the controller that will take action to authorise/deny the access. -Nevertheless it is also possible to directly access a lower level (e.g. call alsa Use Case Manager). People may also have their -own audio policy engine and request it directly from here. - -To test this last part your need to have a controller ready to respond to your request. Otherwise control will systematically -be denied. When your AAAA controller is ready to serve your request you may check this with -``` - amixer -Dhw:AuthorisedToMusicOnly controls | grep -i playback - amixer -Dhw:AuthorisedToNavigationOnly controls | grep -i playback -``` - -IMPORTANT: you need at least to audio role to really test this part. While you may assert with one channel that your flow -to accept/deny application works. You need two simultaneous audio stream to really play with the control. Typically when playing -music if you send a navigation message then the audio will be lower during the rendering of the navigation message. - -The action on how you lower an audio role when an other one with a higger level of priority come in place not defined at the -plugin level, but in the AAAA controller, where the API control/dispatch?target=xxxxx will execute a set of actions corresponding -the set/unset accept/deny of requested control. - -Remark: to understand what is happening it is a good idea to have an alxamixer option on the your soundcard -``` - amixer -Dhw:v1340 -``` - -(!) Do not forget to replace 'hw:v1340' by what ever is the alias of your sound card. \ No newline at end of file diff --git a/conf.d/project/alsa.d/asoundrc.sample b/conf.d/project/alsa.d/asoundrc.sample deleted file mode 100644 index 0716b11..0000000 --- a/conf.d/project/alsa.d/asoundrc.sample +++ /dev/null @@ -1,140 +0,0 @@ -# -# Author: Fulup Ar Foll -# Object: PCM hook type -# -# Test : Note: Jabra_USB=hw:v1340 -# Check SoundCard speaker-test -Dhw:v1340 -c2 -twav -# Check MixerPCM speaker-test -DMyMixerPCM -c2 -twav -# Check HookPCM speaker-test -DMyNavigationHook -c2 -twav -# Check NavPCM speaker-test -DMyNavPCM -c2 -twav -# MultiMedia aplay -DDMyNavPCM /usr/share/sounds/alsa/test.wav -# -# Bug/Feature: when softvol control is initialised from plugin and not -# from AGL binding. At 1st run ctl has invalid TLV and cannot be -# use. Bypass Solution: -# * start audio-binder before playing sound (binding create control before softvol plugin) -# * run a dummy aplay -DMyNavPCM "" to get a clean control -# -# References: https://www.spinics.net/lists/alsa-devel/msg54235.html -# -------------------------------------------------------------------- - -# Mixer PCM allow to play multiple stream simultaneously -# ------------------------------------------------------ -pcm.MyMixerPCM { - type dmix - ipc_key 1024 - ipc_key_add_uid false - ipc_perm 0666 # mixing for all users - - # Define target effective sound card (cannot be a plugin) - slave { pcm "hw:v1340" } #Jabra Solmate - - # DMIX can only map two channels - bindings { - 0 0 - 1 1 - } -} - -# Define a Hook_type with a private sharelib -# ------------------------------------------- -pcm_hook_type.MyHookPlugin { - install "AlsaInstallHook" - lib "/home/fulup/Workspace/AGL-AppFW/audio-bindings-dev/build/Alsa-Plugin/Alsa-Policy-Hook/policy_hook_cb.so" -} - - -# Define a HookedPCM that point to Hook_type sharelib -# ---------------------------------------------------- -pcm.MyNavigationHook { - type hooks - slave.pcm "MyMixerPCM" - # Defined used hook sharelib and provide arguments/config to install func - hooks.0 { - type "MyHookPlugin" - hook_args { - verbose true # print few log messages (default false); - - # Every Call should return OK in order PCM to open (default timeout 100ms) - uri "ws://localhost:1234/api?token=audio-agent-token&uuid=audio-agent-session" - request { - # Request autorisation to write on navigation - RequestNavigation { - api "control" - verb "dispatch" - query "{'target':'navigation', 'args':{'device':'Jabra SOLEMATE v1.34.0'}}" - } - } - # map event reception to self generated signal - event { - pause 30 - resume 31 - stop 3 - } - } - } -} - -# If hardware does not support mixer emulate it with softvol -# ----------------------------------------------------------- -pcm.MyMultimediaPCM { - type softvol - - # Point Slave on HOOK for policies control - slave.pcm "MyNavigationHook" - - # resolution=HAL(valMax+1) (default=256) - resolution 256 - - # name should match with HAL but do not set card=xx - control.name "Playback Navigation" - - # Make this plugin visible from aplay -L - hint { - show on - description "Navigation SolftVol PCM" - } -} - -# If hardware does not support mixer emulate it with softvol -# ----------------------------------------------------------- -pcm.MyNavPCM { - type softvol - - # Point Slave on HOOK for policies control - slave.pcm "MyNavigationHook" - - # resolution=HAL(valMax+1) (default=256) - resolution 256 - - # name should match with HAL but do not set card=xx - control.name "Playback Navigation" - - # Make this plugin visible from aplay -L - hint { - show on - description "Navigation SolftVol PCM" - } -} - -# If hardware does not support mixer emulate it with softvol -# ----------------------------------------------------------- -pcm.MyAlarmPCM { - type softvol - - # Point Slave on HOOK for policies control - slave.pcm "MyNavigationHook" - - # resolution=HAL(valMax+1) (default=256) - resolution 256 - - # name should match with HAL but do not set card=xx - control.name "Playback Navigation" - - # Make this plugin visible from aplay -L - hint { - show on - description "Navigation SolftVol PCM" - } -} - diff --git a/conf.d/project/alsa.d/ucm.sample/HDA Intel PCH.conf b/conf.d/project/alsa.d/ucm.sample/HDA Intel PCH.conf deleted file mode 100644 index f6608a0..0000000 --- a/conf.d/project/alsa.d/ucm.sample/HDA Intel PCH.conf +++ /dev/null @@ -1,6 +0,0 @@ -Comment "Leon internal card" - -SectionUseCase."HiFi" { - File "HiFi.conf" - Comment "Default" -} diff --git a/conf.d/project/alsa.d/ucm.sample/HiFi.conf b/conf.d/project/alsa.d/ucm.sample/HiFi.conf deleted file mode 100644 index 9a53c8c..0000000 --- a/conf.d/project/alsa.d/ucm.sample/HiFi.conf +++ /dev/null @@ -1,84 +0,0 @@ -SectionVerb { - EnableSequence [ - cdev "hw:PCH" - - cset "name='Master Playback Switch' on" - cset "name='Headphone Playback Switch' off" - cset "name='Speaker Playback Switch' on" - - cset "name='Capture Switch' on" - cset "name='Capture Volume' 39" - cset "name='Mic Boost Volume' 2" - cset "name='Internal Mic Boost Volume' 0" - #cset "name='Capture Source' 0" - ] - DisableSequence [ - ] - Value { - TQ "Music" - OutputDspName "speaker_eq" - PlaybackPCM "hw:PCH,0" - } -} - -SectionDevice."Headphone".0 { - Value { - JackName "Headphone Jack" - OutputDspName "Jheadphone" - } - EnableSequence [ - cdev "hw:PCH" - - cset "name='Speaker Playback Switch' off" - cset "name='Headphone Playback Switch' on" - ] - DisableSequence [ - cdev "hw:PCH" - - cset "name='Headphone Playback Switch' off" - cset "name='Speaker Playback Switch' on" - ] -} - -SectionDevice."Mic".0 { - Value { - JackName "Mic Jack" - } - EnableSequence [ - cdev "hw:PCH" - - #cset "name='Capture Source' 1" - ] - DisableSequence [ - cdev "hw:PCH" - - cset "name='Capture Source' 0" - ] -} - -SectionModifier."RecordMedia".0 { - SupportedDevice [ - "Headphone" - ] - EnableSequence [ - cdev "hw:PCH" - ] - - DisableSequence [ - cdev "hw:PCH" - ] - - TransitionSequence."ToModifierName" [ - cdev "hw:PCH" - ] - - # Optional TQ and ALSA PCMs - Value { - TQ Voice - CapturePCM "hw:1" - PlaybackVolume "name='Master Playback Volume',index=2" - PlaybackSwitch "name='Master Playback Switch',index=2" - } - -} - diff --git a/conf.d/project/alsa.d/ucm.sample/README b/conf.d/project/alsa.d/ucm.sample/README deleted file mode 100644 index e7f08ae..0000000 --- a/conf.d/project/alsa.d/ucm.sample/README +++ /dev/null @@ -1,2 +0,0 @@ -Should match sound card name ex: "HDA Intel PCH" -cp -r . /usr/share/alsa/ucm diff --git a/conf.d/project/json.d/CMakeLists.txt b/conf.d/project/json.d/CMakeLists.txt deleted file mode 100644 index 8070997..0000000 --- a/conf.d/project/json.d/CMakeLists.txt +++ /dev/null @@ -1,32 +0,0 @@ -########################################################################### -# Copyright 2017 IoT.bzh -# -# author: Fulup Ar Foll -# -# 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. -########################################################################### - - -################################################## -# Control Policy Config file -################################################## -PROJECT_TARGET_ADD(ctl-config.d) - - file(GLOB XML_FILES "*.json") - - add_input_files("${XML_FILES}") - - SET_TARGET_PROPERTIES(${TARGET_NAME} PROPERTIES - LABELS "DATA" - OUTPUT_NAME ${TARGET_NAME} - ) diff --git a/conf.d/project/json.d/README.md b/conf.d/project/json.d/README.md deleted file mode 100644 index 0f4967d..0000000 --- a/conf.d/project/json.d/README.md +++ /dev/null @@ -1,22 +0,0 @@ -By default controller searches for a config filename with the same 'middlename' as daemon process. As an example if your process name is afb-daemon then middle name is 'daemon'. - -``` - onload-middlename-xxxxx.json - - # Middlename is taken from process middlename. -``` - -You may overload config search path with environement variables - * AFB_BINDER_NAME: change patern config search path. 'export AFB_BINDER_NAME=sample' will make controller to search for a configfile name 'onload-sample-xxx.json'. - * CONTROL_CONFIG_PATH: change default reserch path for configuration. You may provide multiple directories separated by ':'. - * CONTROL_LUA_PATH: same as CONTROL_CONFIG_PATH but for Lua script files. - -Example to load a config name 'onload-myconfig-test.json' do -``` - AFB_BINDER_NAME='myconfig' afb-daemon --verbose ...' -``` - -Note: you may change search pattern for Lua script by adding 'ctlname=afb-middlename-xxx' in the metadata section of your config 'onload-*.json' - -WARNING: Audio Control are the one from the HAL and not from Alsa LowLevel - diff --git a/conf.d/project/json.d/onload-aaaa-sample.json b/conf.d/project/json.d/onload-aaaa-sample.json deleted file mode 100644 index 2b0ad7f..0000000 --- a/conf.d/project/json.d/onload-aaaa-sample.json +++ /dev/null @@ -1,118 +0,0 @@ -{ - "$schema": "ToBeDone", - "metadata": { - "label": "sample-aaaa-control", - "info": "Sample of Video AAAA controls", - "name": "afb-sample-controller", - "version": "1.0" - }, - "onload": [{ - "label": "onload-default", - "info": "onload initialisation config", - "require": ["alsacore","jabra-usb","intel-hda","hal-most-unicens"], - "actions": - { - "label": "control-init", - "lua": "_Audio_Controller_Init", - "args": { - "evtname": "agl-audio" - } - } - }], - "controls": - [ - { - "label": "Volume", - "permissions": "urn:AGL:permission:audio:public:multimedia", - "actions": { - "label": "adjust-master-volume", - "info" : "volume value should be provided by requesting client", - "lua": "_Permament_Control", - "args": { - "ctl" : "Master_Playback_Volume" - } - } - },{ - "label": "Multimedia", - "permissions": "urn:AGL:permission:audio:public:multimedia", - "actions": { - "label": "authorize-multimedia", - "lua": "_Temporarily_Control", - "args": { - "ctl" : "Multimedia_Playback_Volume", - "val": 80 - } - } - }, { - "label": "Navigation", - "permissions": "urn:AGL:permission:audio:public:navigation", - "actions": { - "label": "authorize-navigation", - "lua": "_Temporarily_Control", - "args": { - "ctl" : "Multimedia_Playback_Volume", - "val": 40 - } - } - }, { - "label": "Telephony", - "permissions": "urn:AGL:permission:audio:public:telephony", - "actions": { - "label": "authorize-multimedia", - "lua": "_Temporarily_Control", - "args": { - "ctl" : "Multimedia_Playback_Volume", - "val": 20 - } - } - }, { - "label": "Emergency", - "permissions": "urn:AGL:permission:audio:public:emergency", - "actions": { - "label": "authorize-multimedia", - "lua": "_Temporarily_Control", - "args": { - "ctl" : "Multimedia_Playback_Switch", - "val": 0 - }, - "label": "authorize-multimedia", - "lua": "_Temporarily_Control", - "args": { - "ctl" : "Navigation_Playback_Switch", - "val": 0 - } - } - } - ], - "events": - [ - { - "label": "ReverseEngage", - "actions": [{ - "label": "adjust_volume-reverse", - "lua": "_Temporarily_Control", - "args": { - "ctl": "Multimedia_Playback_Volume", - "val": 20 - } - }, - { - "label": "prevent-telephony", - "lua": "_Temporarily_Control", - "args": { - "ctl": "Telephony_Playback_Switch", - "val": 0 - } - } - ] - }, - { - "label": "SpeedChanged", - "actions": { - "label": "adjust_volume", - "lua": "_Adjust_Volume" - } - } - ] -} - diff --git a/conf.d/project/lua.d/CMakeLists.txt b/conf.d/project/lua.d/CMakeLists.txt deleted file mode 100644 index 71b3371..0000000 --- a/conf.d/project/lua.d/CMakeLists.txt +++ /dev/null @@ -1,34 +0,0 @@ -########################################################################### -# Copyright 2017 IoT.bzh -# -# author: Fulup Ar Foll -# -# 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. -########################################################################### - - -################################################## -# Control Policy Config file -################################################## -PROJECT_TARGET_ADD(ctl-lua.d) - file(GLOB LUA_FILES "*.lua") - - # Romain work around to activate lua compilation - set(LUA_LIST "${LUA_FILES}" CACHE STRING "") - - add_input_files("${LUA_FILES}") - - SET_TARGET_PROPERTIES(${TARGET_NAME} PROPERTIES - LABELS "DATA" - OUTPUT_NAME ${TARGET_NAME} - ) \ No newline at end of file diff --git a/conf.d/project/lua.d/README.md b/conf.d/project/lua.d/README.md deleted file mode 100644 index fc3548b..0000000 --- a/conf.d/project/lua.d/README.md +++ /dev/null @@ -1,36 +0,0 @@ -WARNING: controller is now independent from AAAA and thus should be imported by your binder before requesting it. - -For this your only have to provide the path where to find your controller you are in your development tree probably with something -like --binding=../../afb-controller/build/ctl-binding/afb-controller.so on the other hand if you controller was installed you -should import it from where ever you install it. - -To run this controller sample from your developpement environement use -``` - -export BUILD_DIR=build - -# with an internal MPDC (Pusic Player Daemon Client) API -afb-daemon --port=1234 --workdir=. --roothttp=../htdocs --token= --verbose \ ---alias=/monitoring:$HOME/opt/afb-monitoring \ ---ldpaths=package/lib \ ---alias=/monitoring:/home/fulup/opt/afb-monitoring \ ---binding=../../afb-controller/$BUILD_DIR/package/lib/afb-controller.so \ ---binding=../../afb-mpdc/$BUILD_DIR/package/lib/afb-mpdc-api.so \ ---ws-server=unix:/var/tmp/afb-ws/mpdc - -# with an exernal MPDC API -afb-daemon --port=1234 --workdir=. --roothttp=../htdocs --token= --verbose \ ---alias=/monitoring:$HOME/opt/afb-monitoring \ ---ldpaths=. \ ---alias=/monitoring:/home/fulup/opt/afb-monitoring \ ---binding=../../afb-controller/$BUILD_DIR/ctl-binding/afb-controller.so \ ---ws-client=unix:/var/tmp/afb-ws/mpdc - -# Note: - - Both sample make the assumption the monitoring HTML5 app is avaliable at $HOME/opt/afb-monitoring - - With second sample you should obviously have your MPDC service exposing its API with --ws-server=unix:/var/tmp/afb-ws/mpdc - - Should use 'make populate' to get ./build/package/lib to be uptodate - -``` - -Running AAAA from you IDE ![Sample config](netbeans-aaaa-run-config.png) diff --git a/conf.d/project/lua.d/netbeans-aaaa-run-config.png b/conf.d/project/lua.d/netbeans-aaaa-run-config.png deleted file mode 100644 index ffb0e5d..0000000 Binary files a/conf.d/project/lua.d/netbeans-aaaa-run-config.png and /dev/null differ diff --git a/conf.d/project/lua.d/onload-aaaa-00-utils.lua b/conf.d/project/lua.d/onload-aaaa-00-utils.lua deleted file mode 100644 index 29d2c70..0000000 --- a/conf.d/project/lua.d/onload-aaaa-00-utils.lua +++ /dev/null @@ -1,86 +0,0 @@ ---[[ - Copyright (C) 2016 "IoT.bzh" - Author Fulup Ar Foll - - 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. - - Note: this file should be called before any other to assert declare function - is loaded before anything else. - - References: - http://lua-users.org/wiki/DetectingUndefinedVariables - ---]] - - ---=================================================== ---= Niklas Frykholm --- basically if user tries to create global variable --- the system will not let them!! --- call GLOBAL_lock(_G) --- ---=================================================== -function GLOBAL_lock(t) - local mt = getmetatable(t) or {} - mt.__newindex = lock_new_index - setmetatable(t, mt) -end - ---=================================================== --- call GLOBAL_unlock(_G) --- to change things back to normal. ---=================================================== -function GLOBAL_unlock(t) - local mt = getmetatable(t) or {} - mt.__newindex = unlock_new_index - setmetatable(t, mt) -end - -function lock_new_index(t, k, v) - if (string.sub(k,1,1) ~= "_") then - GLOBAL_unlock(_G) - error("GLOBALS are locked -- " .. k .. - " must be declared local or prefix with '_' for globals.", 2) - else - rawset(t, k, v) - end -end - -function unlock_new_index(t, k, v) - rawset(t, k, v) -end - --- return serialised version of printable table -function Dump_Table(o) - if type(o) == 'table' then - local s = '{ ' - for k,v in pairs(o) do - if type(k) ~= 'number' then k = '"'..k..'"' end - s = s .. '['..k..'] = ' .. Dump_Table(v) .. ',' - end - return s .. '} ' - else - return tostring(o) - end -end - - --- simulate C prinf function -printf = function(s,...) - io.write(s:format(...)) - io.write("\n") - return -end - --- lock global variable -GLOBAL_lock(_G) diff --git a/conf.d/project/lua.d/onload-aaaa-01-init.lua b/conf.d/project/lua.d/onload-aaaa-01-init.lua deleted file mode 100644 index 5ebc695..0000000 --- a/conf.d/project/lua.d/onload-aaaa-01-init.lua +++ /dev/null @@ -1,48 +0,0 @@ ---[[ - Copyright (C) 2016 "IoT.bzh" - Author Fulup Ar Foll - - 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. ---]] - --- Global variable SHOULD start with _ -_Global_Context={} - ---[[ - This function is call during controller init phase as describe in onload-daemon-sample.json - It receives two argument 1st one is the source (here on load) second one is the arguments - as expose in config file. - - In this sample we create an event that take the name of args["zzzz"], the resulting handle - is save into _Global_Context for further use. - - Note: init functions are not call from a client and thus do not receive query - ---]] -function _Audio_Controller_Init(source, control) - - printf ("[--> Audio_Controller_Init -->] source=%d control=%s", source, Dump_Table(control)) - - -- create an event from configuration name - _Global_Context["event"]=AFB:evtmake(control["evtname"]) - - -- query HAL to retrieve sound card. - local err,result= AFB:servsync ("alsacore", "hallist", {}) - - if (err) then - AFB:error("Fail to retrieve Audio HAL") - else - _Global_Context["registry"]=result["response"] - printf("[<-- Audio_Controller_Init <--] Active HAL=%s", Dump_Table(result["response"])) - end -end diff --git a/conf.d/project/lua.d/onload-aaaa-03-controls.lua b/conf.d/project/lua.d/onload-aaaa-03-controls.lua deleted file mode 100644 index ae1269b..0000000 --- a/conf.d/project/lua.d/onload-aaaa-03-controls.lua +++ /dev/null @@ -1,158 +0,0 @@ ---[[ - Copyright (C) 2016 "IoT.bzh" - Author Fulup Ar Foll - - 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. - - Following function are called when a control activate a label with - labeller api -> APi=label VERB=dispatch - arguments are - - source (0) when requesting the label (-1) when releasing - - label comme from config given with 'control' in onload-middlename-xxxxx.json - - control is the argument part of the query as providing by control requesting the label. - ---]] - -_CurrentHalVolume={} - - - ---[[ Apply control - * source=1 permanent change requested - * source=0 temporally request control - * source=-1 temporally release control --- ------------------------------------ --]] -local function Apply_Hal_Control(source, label, adjustment) - local HAL = _Global_Context["registry"] - - -- check we really got some data - if (adjustment == nil) then - AFB:error ("--* (Hoops) Control should provide volume adjustment") - return 1 - end - - -- loop on each HAL save current volume and push adjustment - for key,hal in pairs(_Global_Context["registry"]) do - printf ("--- HAL=%s", Dump_Table(hal)) - - -- action set loop on active HAL and get current volume - -- if label respond then do volume adjustment - - if (source >= 0) then - - -- get current volume for each HAL - local err,result= AFB:servsync(hal["api"],"ctlget", {["label"]=label}) - - -- if no error save current volume and set adjustment - if (err ~= nil) then - local response= result["response"] - printf ("--- Response %s=%s", hal["api"], Dump_Table(response)) - - if (response == nil) then - printf ("--- Fail to Activate '%s'='%s' result=%s", hal["api"], label, Dump_Table(result)) - return 1 -- unhappy - end - - -- save response in global space - _CurrentHalVolume [hal["api"]] = response - - -- finally set the new value - local query= { - ["tag"]= response["tag"], - ["val"]= adjustment - } - - -- best effort to set adjustment value - AFB:servsync(hal["api"],"ctlset",query) - end - - else -- when label is release reverse action at preempt time - - if (_CurrentHalVolume [hal["api"]] ~= nil) then - - printf("--- Restoring initial volume HAL=%s Control=%s", hal["api"], _CurrentHalVolume [hal["api"]]) - - AFB:servsync(hal["api"],"ctlset", _CurrentHalVolume [hal["api"]]) - end - end - - end - return 0 -- happy end -end - - --- Temporally adjust volume -function _Temporarily_Control(source, control, client) - - printf ("[--> _Temporarily_Control -->] source=%d control=%s client=%s", source, Dump_Table(control), Dump_Table(client)) - - -- Init should have been properly done - if (_Global_Context["registry"] == nil) then - AFB:error ("--* (Hoops) No Hal in _Global_Context=%s", Dump_Table(_Global_Context)) - return 1 - end - - -- make sure label as valid - if (control["ctl"] == nil or control["val"] == nil) then - AFB:error ("--* Action Ignore no/invalid control=%s", Dump_Table(control)) - return 1 -- unhappy - end - - if (source == 0) then - AFB:info("-- Adjust %s=%d", control["ctl"], control["val"]) - local error=Apply_Hal_Control(source, control["ctl"], control["val"]) - if (error == nil) then - return 1 -- unhappy - end - AFB:notice ("[<-- _Temporarily_Control Granted<--]") - else - Apply_Hal_Control(source, control["ctl"],0) - AFB:notice ("[<-- _Temporarily_Control Restore--]") - end - - return 0 -- happy return -end - - --- Permanent Adjust volume -function _Permanent_Control(source, control, client) - - printf ("[--> _Permanent_Control -->] source=%d control=%s client=%s", source, Dump_Table(control), Dump_Table(client)) - - -- Init should have been properly done - if (_Global_Context["registry"] == nil) then - AFB:error ("--* (Hoops) No Hal in _Global_Context=%s", Dump_Table(_Global_Context)) - return 1 - end - - -- make sure label as valid - if (control["ctl"] == nil or control["val"] == nil) then - AFB:error ("--* Action Ignore no/invalid control=%s", Dump_Table(control)) - return 1 -- unhappy - end - - if (source == 0) then - AFB:info("-- Adjust %s=%d", control["ctl"], control["val"]) - local error=Apply_Hal_Control(1, control["ctl"], control["val"]) - if (error == nil) then - return 1 -- unhappy - end - AFB:notice ("[<-- _Permanent_Control Granted<--]") - else - Apply_Hal_Control(source, control["ctl"],0) - AFB:notice ("[<-- _Permanent_Control Restore--]") - end - - return 0 -- happy return -end - diff --git a/conf.d/project/lua.d/onload-aaaa-10-event.lua b/conf.d/project/lua.d/onload-aaaa-10-event.lua deleted file mode 100644 index 474ebe0..0000000 --- a/conf.d/project/lua.d/onload-aaaa-10-event.lua +++ /dev/null @@ -1,74 +0,0 @@ ---[[ - Copyright (C) 2016 "IoT.bzh" - Author Fulup Ar Foll - - 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. - - - Provide Sample Timer Handing to push event from LUA ---]] - --- Create event on Lua script load -_MyContext={} - --- WARNING: call back are global and should start with '_' -function _Timer_Test_CB (timer, context) - - local evtinfo= AFB:timerget(timer) - printf ("[-- _Timer_Test_C --] evtInfo=%s", Dump_Table(evtinfo)) - - --send an event an event with count as value - AFB:evtpush (_MyContext["event"], {["label"]= evtinfo["label"], ["count"]=evtinfo["count"], ["info"]=context["info"]}) - - -- note when timerCB return!=0 timer is kill - return 0 - -end - --- sendback event depending on count and delay -function _Simple_Timer_Test (request, client) - - local context = { - ["info"]="My 1st private Event", - } - - -- if event does not exit create it now. - if (_MyContext["event"] == nil) then - _MyContext["event"]= AFB:evtmake(client["label"]) - end - - -- if delay not defined default is 5s - if (client["delay"]==nil) then client["delay"]=5000 end - - -- if count is not defined default is 10 - if (client["count"]==nil) then client["count"]=10 end - - -- we could use directly client but it is a sample - local myTimer = { - ["label"]=client["label"], - ["delay"]=client["delay"], - ["count"]=client["count"], - } - AFB:notice ("Test_Timer myTimer=%s", myTimer) - - -- subscribe to event - AFB:subscribe (request, _MyContext["event"]) - - -- settimer take a table with delay+count as input (count==0 means infinite) - AFB:timerset (myTimer, "_Timer_Test_CB", context) - - -- nothing special to return send back - AFB:success (request, myTimer) - - return 0 -end diff --git a/hal-utilities-4a b/hal-utilities-4a deleted file mode 160000 index 78af225..0000000 --- a/hal-utilities-4a +++ /dev/null @@ -1 +0,0 @@ -Subproject commit 78af225941f9014d4a387ed7ae0f69f47d262e58 diff --git a/htdocs/AFB-websock.js b/htdocs/AFB-websock.js deleted file mode 100644 index 99ab3b8..0000000 --- a/htdocs/AFB-websock.js +++ /dev/null @@ -1,177 +0,0 @@ -var urlws; -var urlhttp; - -AFB = function(base, initialtoken){ - -urlws = "ws://"+window.location.host+"/"+base; -urlhttp = "http://"+window.location.host+"/"+base; - -/*********************************************/ -/**** ****/ -/**** AFB_context ****/ -/**** ****/ -/*********************************************/ -var AFB_context; -{ - var UUID = undefined; - var TOKEN = initialtoken; - - var context = function(token, uuid) { - this.token = token; - this.uuid = uuid; - } - - context.prototype = { - get token() {return TOKEN;}, - set token(tok) {if(tok) TOKEN=tok;}, - get uuid() {return UUID;}, - set uuid(id) {if(id) UUID=id;} - }; - - AFB_context = new context(); -} -/*********************************************/ -/**** ****/ -/**** AFB_websocket ****/ -/**** ****/ -/*********************************************/ -var AFB_websocket; -{ - var CALL = 2; - var RETOK = 3; - var RETERR = 4; - var EVENT = 5; - - var PROTO1 = "x-afb-ws-json1"; - - AFB_websocket = function(onopen, onabort) { - var u = urlws; - if (AFB_context.token) { - u = u + '?x-afb-token=' + AFB_context.token; - if (AFB_context.uuid) - u = u + '&x-afb-uuid=' + AFB_context.uuid; - } - this.ws = new WebSocket(u, [ PROTO1 ]); - this.pendings = {}; - this.awaitens = {}; - this.counter = 0; - this.ws.onopen = onopen.bind(this); - this.ws.onerror = onerror.bind(this); - this.ws.onclose = onclose.bind(this); - this.ws.onmessage = onmessage.bind(this); - this.onopen = onopen; - this.onabort = onabort; - this.onclose = onabort; - } - - function onerror(event) { - var f = this.onabort; - if (f) { - delete this.onopen; - delete this.onabort; - f && f(this); - } - this.onerror && this.onerror(this); - } - - function onopen(event) { - var f = this.onopen; - delete this.onopen; - delete this.onabort; - f && f(this); - } - - function onclose(event) { - for (var id in this.pendings) { - var ferr = this.pendings[id].onerror; - ferr && ferr(null, this); - } - this.pendings = {}; - this.onclose && this.onclose(); - } - - function fire(awaitens, name, data) { - var a = awaitens[name]; - if (a) - a.forEach(function(handler){handler(data);}); - var i = name.indexOf("/"); - if (i >= 0) { - a = awaitens[name.substring(0,i)]; - if (a) - a.forEach(function(handler){handler(data);}); - } - a = awaitens["*"]; - if (a) - a.forEach(function(handler){handler(data);}); - } - - function reply(pendings, id, ans, offset) { - if (id in pendings) { - var p = pendings[id]; - delete pendings[id]; - var f = p[offset]; - f(ans); - } - } - - function onmessage(event) { - var obj = JSON.parse(event.data); - var code = obj[0]; - var id = obj[1]; - var ans = obj[2]; - AFB_context.token = obj[3]; - switch (code) { - case RETOK: - reply(this.pendings, id, ans, 0); - break; - case RETERR: - reply(this.pendings, id, ans, 1); - break; - case EVENT: - default: - fire(this.awaitens, id, ans); - break; - } - } - - function close() { - this.ws.close(); - this.onabort(); - } - - function call(method, request) { - return new Promise((function(resolve, reject){ - var id, arr; - do { - id = String(this.counter = 4095 & (this.counter + 1)); - } while (id in this.pendings); - this.pendings[id] = [ resolve, reject ]; - arr = [CALL, id, method, request ]; - if (AFB_context.token) arr.push(AFB_context.token); - this.ws.send(JSON.stringify(arr)); - }).bind(this)); - } - - function onevent(name, handler) { - var id = name; - var list = this.awaitens[id] || (this.awaitens[id] = []); - list.push(handler); - } - - AFB_websocket.prototype = { - close: close, - call: call, - onevent: onevent - }; -} -/*********************************************/ -/**** ****/ -/**** ****/ -/**** ****/ -/*********************************************/ -return { - context: AFB_context, - ws: AFB_websocket -}; -}; - diff --git a/htdocs/AudioBinding.css b/htdocs/AudioBinding.css deleted file mode 100644 index 1052aa7..0000000 --- a/htdocs/AudioBinding.css +++ /dev/null @@ -1,7 +0,0 @@ -pre {outline: 1px solid #ccc; padding: 5px; margin: 5px; } -.string { color: green; } -.number { color: darkorange; } -.boolean { color: blue; } -.null { color: magenta; } -.key { color: red; } - diff --git a/htdocs/AudioBinding.js b/htdocs/AudioBinding.js deleted file mode 100644 index 0f5caf9..0000000 --- a/htdocs/AudioBinding.js +++ /dev/null @@ -1,197 +0,0 @@ - var afb = new AFB("api", "mysecret"); - var ws; - var sndcard="HALNotSelected"; - var evtidx=0; - var numid=0; - - function syntaxHighlight(json) { - if (typeof json !== 'string') { - json = JSON.stringify(json, undefined, 2); - } - json = json.replace(/&/g, '&').replace(//g, '>'); - return json.replace(/("(\\u[a-zA-Z0-9]{4}|\\[^u]|[^\\"])*"(\s*:)?|\b(true|false|null)\b|-?\d+(?:\.\d*)?(?:[eE][+\-]?\d+)?)/g, function (match) { - var cls = 'number'; - if (/^"/.test(match)) { - if (/:$/.test(match)) { - cls = 'key'; - } else { - cls = 'string'; - } - } else if (/true|false/.test(match)) { - cls = 'boolean'; - } else if (/null/.test(match)) { - cls = 'null'; - } - return '' + match + ''; - }); - } - - function getParameterByName(name, url) { - if (!url) { - url = window.location.href; - } - name = name.replace(/[\[\]]/g, "\\$&"); - var regex = new RegExp("[?&]" + name + "(=([^&#]*)|&|#|$)"), - results = regex.exec(url); - if (!results) return null; - if (!results[2]) return ''; - return decodeURIComponent(results[2].replace(/\+/g, " ")); - } - - // default soundcard is "PCH" - var devid=getParameterByName("devid"); - if (!devid) devid="hw:1"; - - var haldev=getParameterByName("haldev"); - if (!haldev) haldev="scarlett-usb"; - - var sndname=getParameterByName("sndname"); - if (!sndname) sndname="PCH"; - - var mode=getParameterByName("mode"); - if (!mode) mode="0"; - - - - - function replyok(obj) { - console.log("replyok:" + JSON.stringify(obj)); - document.getElementById("output").innerHTML = "OK: "+ syntaxHighlight(obj); - } - - function replyerr(obj) { - console.log("replyerr:" + JSON.stringify(obj)); - document.getElementById("output").innerHTML = "ERROR: "+ syntaxHighlight(obj); - } - - function gotevent(obj) { - console.log("gotevent:" + JSON.stringify(obj)); - document.getElementById("outevt").innerHTML = (evtidx++) +": "+JSON.stringify(obj); - } - - function send(message) { - var api = document.getElementById("api").value; - var verb = document.getElementById("verb").value; - document.getElementById("question").innerHTML = "subscribe: "+api+"/"+verb + " (" + JSON.stringify(message) +")"; - ws.call(api+"/"+verb, {data:message}).then(replyok, replyerr); - } - - - // On button click from HTML page - function callbinder(api, verb, query) { - console.log ("subscribe api="+api+" verb="+verb+" query=" +query); - var question = urlws +"/" +api +"/" +verb + "?query=" + JSON.stringify(query); - document.getElementById("question").innerHTML = syntaxHighlight(question); - ws.call(api+"/"+verb, query).then(replyok, replyerr); - } - - - // Retreive Select value and Text from the binder - // Note: selection of value/text for a given context is huggly!!! - function querySelectList (elemid, api, verb, query) { - - console.log("querySelectList elemid=%s api=%s verb=%s query=%s", elemid, api, verb, query); - - var selectobj = document.getElementById(elemid); - if (!selectobj) { - return; - } - - // onlick update selected HAL api - selectobj.onclick=function(){ - sndcard= this.value; - console.log ("Default Selection=" + sndcard); - }; - - function gotit (result) { - - // display response as for normal onclick action - replyok(result); - var response=result.response; - - // fulfill select with avaliable active HAL - for (idx=0; idx 0) return; - - // onlick update selected HAL api - self.onclick=function(){ - numid = parseInt(self.value); - console.log ("Default numid=%d", numid); - }; - - function gotit (result) { - - // display response as for normal onclick action - replyok(result); - var response=result.response; - - - - // fulfill select with avaliable active HAL - for (idx=0; idx - - - - -

- Selected SndCard - - - Select NUMID - - - API Verbosity - - - -
-
    -
  1. -
  2. -
  3. -
    - - -
  4. -
  5. -
  6. -
  7. -
  8. -
    -
  9. -
  10. -
  11. -
  12. -
    -
  13. -
    -
  14. -
    -
- - 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 @@ - - - Basic Audio Hardware Abstraction Layer Test - - - - - - - - -

Simple AlsaHAL tests

- - - -

- Selected HAL - - - API Verbosity - -
- -
-
    - -
  1. -
  2. -
  3. -
  4. -
    -
  5. -
  6. -
  7. -
  8. -
    - -
  9. - - -
  10. -
    -
- - 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 @@ - - - Basic Audio Hardware Abstraction Layer Test - - - - - - - -

Simple Audio Control Test

- - -
    - -
  1. -
  2. -
  3. -
    -
- - diff --git a/htdocs/docs/AAAA-architecture.odg b/htdocs/docs/AAAA-architecture.odg deleted file mode 100644 index 90a2486..0000000 Binary files a/htdocs/docs/AAAA-architecture.odg and /dev/null differ diff --git a/htdocs/docs/AAAA-architecture.pdf b/htdocs/docs/AAAA-architecture.pdf deleted file mode 100644 index 3b6280d..0000000 Binary files a/htdocs/docs/AAAA-architecture.pdf and /dev/null differ diff --git a/htdocs/index.html b/htdocs/index.html deleted file mode 100644 index e424feb..0000000 --- a/htdocs/index.html +++ /dev/null @@ -1,10 +0,0 @@ - - - AGL-AudioBindins tests - -

audio-bindings test

-
    -
  1. AlsaCore Low Level Binding -
  2. AlsaHAL Hardware Abstraction Layer -
  3. AudioControl Control/Policy API -
  4. Binding Monitoring Dashboard diff --git a/nbproject/configurations.xml b/nbproject/configurations.xml deleted file mode 100644 index 3d0270e..0000000 --- a/nbproject/configurations.xml +++ /dev/null @@ -1,201 +0,0 @@ - - - - - - escape.c - filescan-utils.c - wrap-json.c - - - hal-interface.c - hal-statics.c - hal-volramp.c - hal-volume.c - - - - - device_container.cpp - device_value.cpp - libmostvolume.cpp - setup.cpp - - - hal_most_unicens.c - wrap_unicens.c - wrap_volume.c - - - - CMakeLists.txt - Makefile - nbproject/private/launcher.properties - - - ^(nbproject)$ - - . - - Makefile - - - - default - false - false - - - - - - - - - - ./build - ${MAKE} -f Makefile - ${MAKE} -f Makefile clean - - - - /usr/include/json-c - /opt/AGL/include - /usr/include/p11-kit-1 - /usr/include/alsa - - - AFB_BINDING_VERSION=2 - CONTROL_MAXPATH_LEN=255 - MAX_LINEAR_DB_SCALE=24 - MAX_SND_CARD=16 - TLV_BYTE_SIZE=256 - - - - - /usr/include/json-c - /opt/AGL/include - /usr/include/p11-kit-1 - /usr/include/alsa - MOST_UNICENS/ucs2-vol/inc - build/MOST_UNICENS/ucs2-vol/src - - - AFB_BINDING_VERSION=2 - CONTROL_MAXPATH_LEN=255 - MAX_LINEAR_DB_SCALE=24 - MAX_SND_CARD=16 - TLV_BYTE_SIZE=256 - - - - - ./build - cmake .. - true - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - MOST_UNICENS/ucs2-vol/inc - afb-utilities - hal-utilities-4a - build/MOST_UNICENS - - - hal_most_unicens_EXPORTS - - - - - - - afb-utilities - build/afb-utilities - - - - - - - hal-utilities-4a - build/hal-utilities-4a - - - - - - - - - - - - - - - - - - - - - - diff --git a/nbproject/project.xml b/nbproject/project.xml deleted file mode 100644 index 1ef2f4f..0000000 --- a/nbproject/project.xml +++ /dev/null @@ -1,26 +0,0 @@ - - - org.netbeans.modules.cnd.makeproject - - - 4a-hal-unicens - c - cpp,cxx - h,hpp - UTF-8 - - - . - - - - Default - 0 - - - - false - - - - -- cgit 1.2.3-korg