aboutsummaryrefslogtreecommitdiffstats
path: root/HAL-afb
diff options
context:
space:
mode:
authorfulup <fulup.arfoll@iot.bzh>2017-07-21 23:46:49 +0200
committerfulup <fulup.arfoll@iot.bzh>2017-07-21 23:46:49 +0200
commit044828c43097362973c82088a7afee760eab06ec (patch)
tree140522d19e9adea8286f377a53098566c0ee7b89 /HAL-afb
parentdb4d63597b22b63eb73b5c0558476652ed4988bb (diff)
Added HAL selection in HTML page
Started SetCtl implementation WIP Only
Diffstat (limited to 'HAL-afb')
-rw-r--r--HAL-afb/HAL-interface/CMakeLists.txt8
-rw-r--r--HAL-afb/HAL-interface/hal-interface.c233
-rw-r--r--HAL-afb/HAL-plugin/HalPlugCtl.c2
-rw-r--r--HAL-afb/HDA-intel/CMakeLists.txt8
-rw-r--r--HAL-afb/Scarlett-Focusrite/CMakeLists.txt6
-rw-r--r--HAL-afb/Scarlett-Focusrite/ScarlettUsbHAL.c2
-rw-r--r--HAL-afb/Unicens-USB/CMakeLists.txt42
-rw-r--r--HAL-afb/Unicens-USB/UnicensHAL.c73
-rw-r--r--HAL-afb/Unicens-USB/UnicensVol.c37
9 files changed, 338 insertions, 73 deletions
diff --git a/HAL-afb/HAL-interface/CMakeLists.txt b/HAL-afb/HAL-interface/CMakeLists.txt
index 0ea298f..d4dba4b 100644
--- a/HAL-afb/HAL-interface/CMakeLists.txt
+++ b/HAL-afb/HAL-interface/CMakeLists.txt
@@ -21,17 +21,17 @@
PROJECT_TARGET_ADD(hal-interface)
# Define targets
- ADD_LIBRARY(hal-interface STATIC hal-interface.c)
+ ADD_LIBRARY(${TARGET_NAME} STATIC hal-interface.c)
# Library properties
- SET_TARGET_PROPERTIES(hal-interface PROPERTIES OUTPUT_NAME halinterface)
+ SET_TARGET_PROPERTIES(${TARGET_NAME} PROPERTIES OUTPUT_NAME halinterface)
# Library dependencies (include updates automatically)
- TARGET_LINK_LIBRARIES(hal-interface
+ TARGET_LINK_LIBRARIES(${TARGET_NAME}
audio-interface
)
# Define target includes
- TARGET_INCLUDE_DIRECTORIES(hal-interface
+ TARGET_INCLUDE_DIRECTORIES(${TARGET_NAME}
PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}
)
diff --git a/HAL-afb/HAL-interface/hal-interface.c b/HAL-afb/HAL-interface/hal-interface.c
index 19fe191..dd00d1c 100644
--- a/HAL-afb/HAL-interface/hal-interface.c
+++ b/HAL-afb/HAL-interface/hal-interface.c
@@ -61,15 +61,14 @@ STATIC void halSubscribe(afb_req request) {
}
}
-
// HAL normalise volume values to 0-100%
-STATIC struct json_object *NormaliseValue(const alsaHalCtlMapT *halCtls, struct json_object *valuesJ) {
+STATIC struct json_object *UnNormaliseValue(const alsaHalCtlMapT *halCtls, struct json_object *valuesJ) {
int length;
// assert response as the right length
length = json_object_array_length(valuesJ);
if (length != halCtls->count) {
- AFB_WARNING ("NormaliseValue invalid ctl=%s values count=%d len=%d", halCtls->name, halCtls->count, length);
+ AFB_WARNING ("NormaliseValue invalid ctl='%s' values count=%d len=%d", halCtls->name, halCtls->count, length);
return NULL;
}
@@ -93,56 +92,41 @@ STATIC struct json_object *NormaliseValue(const alsaHalCtlMapT *halCtls, struct
return (normalisedJ);
}
-// Remap low level controls into HAL hight level ones
-STATIC json_object *CtlGetPrepareResponse(afb_req request, struct json_object *ctlsJ) {
- struct json_object *halResponseJ;
- // make sure return controls have a valid type
- if (json_object_get_type(ctlsJ) != json_type_array) {
- afb_req_fail_f(request, "ctls-notarray", "Invalid Controls return from alsa/getcontrol ctlsJ=%s", json_object_get_string(ctlsJ));
- goto OnErrorExit;
- }
-
- // responseJ is a JSON array
- halResponseJ = json_object_new_array();
- // loop on array and store values into client context
- for (int idx = 0; idx < json_object_array_length(ctlsJ); idx++) {
- struct json_object *sndCtlJ, *valJ, *numidJ;
- int numid;
+// HAL normalise volume values to 0-100%
+STATIC struct json_object *NormaliseValue(const alsaHalCtlMapT *halCtls, struct json_object *valuesJ) {
+ int length;
- sndCtlJ = json_object_array_get_idx(ctlsJ, idx);
- if (!json_object_object_get_ex(sndCtlJ, "numid", &numidJ) || !json_object_object_get_ex(sndCtlJ, "val", &valJ)) {
- afb_req_fail_f(request, "ctl-invalid", "Invalid Control return from alsa/getcontrol ctl=%s", json_object_get_string(sndCtlJ));
- goto OnErrorExit;
- }
+ // assert response as the right length
+ length = json_object_array_length(valuesJ);
+ if (length != halCtls->count) {
+ AFB_WARNING ("NormaliseValue invalid ctl=%s values count=%d len=%d", halCtls->name, halCtls->count, length);
+ return NULL;
+ }
+
+ json_object *normalisedJ= json_object_new_array();
+ for (int idx=0; idx <length; idx++) {
+ json_object *valueJ = json_object_array_get_idx (valuesJ, idx);
+ int value = json_object_get_int(valueJ);
- // HAL and Business logic use the same AlsaMixerHal.h direct conversion
- numid= (halCtlsEnumT) json_object_get_int(numidJ);
-
- for (int idx = 0; halCtls[idx].ctl.numid; idx++) {
- if (halCtls[idx].ctl.numid == numid) {
-
- // translate low level numid to HAL one and normalise values
- struct json_object *halCtlJ = json_object_new_object();
- json_object_object_add(halCtlJ, "label", json_object_new_string(halCtls[idx].label)); // idx+1 == HAL/NUMID
- json_object_object_add(halCtlJ, "tag" , json_object_new_int(halCtls[idx].tag)); // idx+1 == HAL/NUMID
- json_object_object_add(halCtlJ, "val" , NormaliseValue(&halCtls[idx].ctl, valJ));
- json_object_array_add(halResponseJ, halCtlJ);
- break;
- }
- }
- if ( halCtls[idx].ctl.numid == 0) {
- afb_req_fail_f(request, "ctl-invalid", "Invalid Control numid=%d from alsa/getcontrol ctlJ=%s", numid, json_object_get_string(sndCtlJ));
- goto OnErrorExit;
- }
+ // cleanup and normalise value
+ if (value > halCtls->maxval) value= halCtls->maxval;
+ if (value < halCtls->minval) value= halCtls->minval;
+
+ // If Integer scale to 0/100
+ if (halCtls->type == SND_CTL_ELEM_TYPE_INTEGER) {
+ value = (value * 100) / (halCtls->maxval - halCtls->minval);
+ }
+
+ json_object_array_add(normalisedJ, json_object_new_int(value));
}
- return halResponseJ;
- OnErrorExit:
- return NULL;
+ return (normalisedJ);
}
+
+
// Return ALL HAL snd controls
PUBLIC void halListCtls(afb_req request) {
struct json_object *ctlsHalJ = json_object_new_array();
@@ -181,7 +165,7 @@ STATIC int halCtlTagToIndex (halCtlsEnumT tag) {
return -1;
}
-STATIC int halGetOneCtls (afb_req request, struct json_object*ctlInJ) {
+STATIC int halGetCtlIndex (afb_req request, struct json_object*ctlInJ) {
struct json_object *tmpJ;
int tag, index;
@@ -205,20 +189,149 @@ STATIC int halGetOneCtls (afb_req request, struct json_object*ctlInJ) {
}
if (index < 0) {
- afb_req_fail_f(request, "ctl-invalid", "No Label/Tag given ctl=[%s]", json_object_get_string(ctlInJ));
+ afb_req_fail_f(request, "ctl-invalid", "No Label/Tag given ctl='%s'", json_object_get_string(ctlInJ));
goto OnErrorExit;
}
// return corresponding lowlevel numid to querylist
- return halCtls[index].ctl.numid;
+ return index;
OnErrorExit:
return -1;
}
+
+// Translate high level control to low level and call lower layer
+PUBLIC void halSetCtls(afb_req request) {
+ int err, index;
+ struct json_object *ctlsInJ, *ctlsOutJ, *queryJ, *valuesJ, *responseJ;
+
+ // get query from request
+ ctlsInJ = afb_req_json(request);
+ ctlsOutJ = json_object_new_array();
+
+ switch (json_object_get_type(ctlsInJ)) {
+ case json_type_object: {
+ // control is in literal form {tag=xxx, label=xxx, val=xxxx}
+ index = halGetCtlIndex (request, ctlsInJ);
+ if (index <=0) goto OnErrorExit;
+
+ err= json_object_object_get_ex (ctlsInJ, "val" , &valuesJ);
+ if (err) {
+ afb_req_fail_f(request, "ctl-invalid", "No val=[val1, ...] ctl='%s'", json_object_get_string(ctlsInJ));
+ goto OnErrorExit;
+ }
+
+ json_object_array_add (ctlsOutJ, json_object_new_int(halCtls[index].ctl.numid));
+ json_object_array_add (ctlsOutJ, UnNormaliseValue (&halCtls[index].ctl, valuesJ));
+ break;
+ }
+
+ case json_type_array: {
+
+ for (int idx= 0; idx < json_object_array_length (ctlsInJ); idx++) {
+ struct json_object *ctlInJ = json_object_array_get_idx (ctlsInJ, idx);
+ index= halGetCtlIndex (request, ctlInJ);
+ if (index<=0) goto OnErrorExit;
+
+ err= json_object_object_get_ex (ctlInJ, "val" , &valuesJ);
+ if (err) {
+ afb_req_fail_f(request, "ctl-invalid", "No val=[val1, ...] ctl='%s'", json_object_get_string(ctlsInJ));
+ goto OnErrorExit;
+ }
+ // let's create alsa low level set control request
+ struct json_object *ctlOutJ = json_object_new_array();
+ json_object_array_add (ctlOutJ, json_object_new_int(halCtls[index].ctl.numid));
+ json_object_array_add (ctlOutJ, UnNormaliseValue (&halCtls[index].ctl, valuesJ));
+
+ json_object_array_add (ctlsOutJ, ctlOutJ);
+ }
+ break;
+ }
+
+ default:
+ afb_req_fail_f(request, "ctl-invalid", "Not a valid JSON ctl='%s'", json_object_get_string(ctlsInJ));
+ goto OnErrorExit;
+ }
+
+ // Call now level CTL
+ queryJ = json_object_new_object();
+ json_object_object_add(queryJ, "devid", json_object_new_string (halDevid));
+ json_object_object_add(queryJ, "numids", ctlsOutJ);
+
+ err= afb_service_call_sync("alsacore", "setctls", queryJ, &responseJ);
+ if (err) {
+ afb_req_fail_f(request, "subcall:alsacore/setctl", "%s", json_object_get_string(responseJ));
+ goto OnErrorExit;
+ }
+
+ // Let ignore info data if any and keep on response
+ json_object_object_get_ex (responseJ, "response", &responseJ);
+
+ // map back low level response to HAL ctl with normalised values
+ //struct json_object *halResponse = CtlSetPrepareResponse(request, responseJ);
+ //if (!halResponse) goto OnErrorExit;
+
+ afb_req_success (request, NULL, NULL);
+ return;
+
+OnErrorExit:
+ return;
+};
+
+// Remap low level controls into HAL hight level ones
+STATIC json_object *CtlGetPrepareResponse(afb_req request, struct json_object *ctlsJ) {
+ struct json_object *halResponseJ;
+
+ // make sure return controls have a valid type
+ if (json_object_get_type(ctlsJ) != json_type_array) {
+ afb_req_fail_f(request, "ctls-notarray", "Invalid Controls return from alsa/getcontrol ctlsJ=%s", json_object_get_string(ctlsJ));
+ goto OnErrorExit;
+ }
+
+ // responseJ is a JSON array
+ halResponseJ = json_object_new_array();
+
+ // loop on array and store values into client context
+ for (int idx = 0; idx < json_object_array_length(ctlsJ); idx++) {
+ struct json_object *sndCtlJ, *valJ, *numidJ;
+ int numid;
+
+ sndCtlJ = json_object_array_get_idx(ctlsJ, idx);
+ if (!json_object_object_get_ex(sndCtlJ, "numid", &numidJ) || !json_object_object_get_ex(sndCtlJ, "val", &valJ)) {
+ afb_req_fail_f(request, "ctl-invalid", "Invalid Control return from alsa/getcontrol ctl=%s", json_object_get_string(sndCtlJ));
+ goto OnErrorExit;
+ }
+
+ // HAL and Business logic use the same AlsaMixerHal.h direct conversion
+ numid= (halCtlsEnumT) json_object_get_int(numidJ);
+
+ for (int idx = 0; halCtls[idx].ctl.numid; idx++) {
+ if (halCtls[idx].ctl.numid == numid) {
+
+ // translate low level numid to HAL one and normalise values
+ struct json_object *halCtlJ = json_object_new_object();
+ json_object_object_add(halCtlJ, "label", json_object_new_string(halCtls[idx].label)); // idx+1 == HAL/NUMID
+ json_object_object_add(halCtlJ, "tag" , json_object_new_int(halCtls[idx].tag)); // idx+1 == HAL/NUMID
+ json_object_object_add(halCtlJ, "val" , NormaliseValue(&halCtls[idx].ctl, valJ));
+ json_object_array_add(halResponseJ, halCtlJ);
+ break;
+ }
+ }
+ if ( halCtls[idx].ctl.numid == 0) {
+ afb_req_fail_f(request, "ctl-invalid", "Invalid Control numid=%d from alsa/getcontrol ctlJ=%s", numid, json_object_get_string(sndCtlJ));
+ goto OnErrorExit;
+ }
+ }
+ return halResponseJ;
+
+ OnErrorExit:
+ return NULL;
+}
+
// Translate high level control to low level and call lower layer
PUBLIC void halGetCtls(afb_req request) {
- int err, numid;
+ int err, index;
struct json_object *ctlsInJ, *ctlsOutJ, *queryJ, *responseJ;
// get query from request
@@ -228,9 +341,9 @@ PUBLIC void halGetCtls(afb_req request) {
switch (json_object_get_type(ctlsInJ)) {
case json_type_object: {
- numid = halGetOneCtls (request, ctlsInJ);
- if (numid <=0) goto OnErrorExit;
- json_object_array_add (ctlsOutJ, json_object_new_int(numid));
+ index = halGetCtlIndex (request, ctlsInJ);
+ if (index <=0) goto OnErrorExit;
+ json_object_array_add (ctlsOutJ, json_object_new_int(halCtls[index].ctl.numid));
break;
}
@@ -238,15 +351,15 @@ PUBLIC void halGetCtls(afb_req request) {
for (int idx= 0; idx < json_object_array_length (ctlsInJ); idx++) {
struct json_object *ctlInJ = json_object_array_get_idx (ctlsInJ, idx);
- numid= halGetOneCtls (request, ctlInJ);
- if (numid<=0) goto OnErrorExit;
- json_object_array_add (ctlsOutJ, json_object_new_int(numid));
+ index= halGetCtlIndex (request, ctlInJ);
+ if (index<=0) goto OnErrorExit;
+ json_object_array_add (ctlsOutJ, json_object_new_int(halCtls[index].ctl.numid));
}
break;
}
default:
- afb_req_fail_f(request, "ctl-invalid", "Not a valid JSON ctl=[%s]", json_object_get_string(ctlsInJ));
+ afb_req_fail_f(request, "ctl-invalid", "Not a valid JSON ctl='%s'", json_object_get_string(ctlsInJ));
goto OnErrorExit;
}
@@ -355,13 +468,13 @@ PUBLIC int halServiceInit (const char *apiPrefix, alsaHalSndCardT *alsaHalSndCar
err= afb_service_call_sync ("alsacore", "halregister", queryurl, &responseJ);
json_object_put(queryurl);
if (err) {
- AFB_NOTICE ("Fail to register HAL to ALSA lowlevel binding Response=[%s]", json_object_get_string(responseJ));
+ AFB_NOTICE ("Fail to register HAL to ALSA lowlevel binding Response='%s'", json_object_get_string(responseJ));
goto OnErrorExit;
}
// extract sound devidJ from HAL registration
if (!json_object_object_get_ex(responseJ, "response", &tmpJ) || !json_object_object_get_ex(tmpJ, "devid", &devidJ)) {
- AFB_ERROR ("Ooops: Internal error no devidJ return from HAL registration Response=[%s]", json_object_get_string(responseJ));
+ AFB_ERROR ("Ooops: Internal error no devidJ return from HAL registration Response='%s'", json_object_get_string(responseJ));
goto OnErrorExit;
}
@@ -400,7 +513,7 @@ PUBLIC int halServiceInit (const char *apiPrefix, alsaHalSndCardT *alsaHalSndCar
json_object_object_add(queryurl, "ctls",ctlsJ);
err= afb_service_call_sync ("alsacore", "addcustomctl", queryurl, &responseJ);
if (err) {
- AFB_ERROR ("Fail creating HAL Custom ALSA ctls Response=[%s]", json_object_get_string(responseJ));
+ AFB_ERROR ("Fail creating HAL Custom ALSA ctls Response='%s'", json_object_get_string(responseJ));
goto OnErrorExit;
}
}
@@ -408,7 +521,7 @@ PUBLIC int halServiceInit (const char *apiPrefix, alsaHalSndCardT *alsaHalSndCar
// Make sure response is valid
json_object_object_get_ex (responseJ, "response" , &ctlsJ);
if (json_object_get_type(ctlsJ) != json_type_array) {
- AFB_ERROR ("Response Invalid JSON array ctls Response=[%s]", json_object_get_string(responseJ));
+ AFB_ERROR ("Response Invalid JSON array ctls Response='%s'", json_object_get_string(responseJ));
goto OnErrorExit;
}
diff --git a/HAL-afb/HAL-plugin/HalPlugCtl.c b/HAL-afb/HAL-plugin/HalPlugCtl.c
index 01feedd..181d4f8 100644
--- a/HAL-afb/HAL-plugin/HalPlugCtl.c
+++ b/HAL-afb/HAL-plugin/HalPlugCtl.c
@@ -48,7 +48,7 @@
static snd_ctl_ext_key_t AfbHalElemFind(snd_ctl_ext_t *ext, const snd_ctl_elem_id_t *id) {
snd_ctl_hal_t *plughandle = (snd_ctl_hal_t*) ext->private_data;
- snd_ctl_ext_key_t key;
+ snd_ctl_ext_key_t key=NULL;
int numid = snd_ctl_elem_id_get_numid(id);
if (numid > 0) {
diff --git a/HAL-afb/HDA-intel/CMakeLists.txt b/HAL-afb/HDA-intel/CMakeLists.txt
index 4a12aee..efe244d 100644
--- a/HAL-afb/HDA-intel/CMakeLists.txt
+++ b/HAL-afb/HDA-intel/CMakeLists.txt
@@ -21,10 +21,10 @@
PROJECT_TARGET_ADD(hal-intel-hda)
# Define project Targets
- ADD_LIBRARY(hal-intel-hda MODULE IntelHdaHAL.c)
+ ADD_LIBRARY(${TARGET_NAME} MODULE IntelHdaHAL.c)
# Binder exposes a unique public entry point
- SET_TARGET_PROPERTIES(hal-intel-hda PROPERTIES
+ SET_TARGET_PROPERTIES(${TARGET_NAME} PROPERTIES
PREFIX "afb-"
LABELS "BINDING"
LINK_FLAGS ${BINDINGS_LINK_FLAG}
@@ -32,11 +32,11 @@ PROJECT_TARGET_ADD(hal-intel-hda)
)
# Library dependencies (include updates automatically)
- TARGET_LINK_LIBRARIES(hal-intel-hda
+ TARGET_LINK_LIBRARIES(${TARGET_NAME}
hal-interface
audio-interface
)
# installation directory
- INSTALL(TARGETS hal-intel-hda
+ INSTALL(TARGETS ${TARGET_NAME}
LIBRARY DESTINATION ${BINDINGS_INSTALL_DIR}) \ No newline at end of file
diff --git a/HAL-afb/Scarlett-Focusrite/CMakeLists.txt b/HAL-afb/Scarlett-Focusrite/CMakeLists.txt
index a2ca912..4cbac19 100644
--- a/HAL-afb/Scarlett-Focusrite/CMakeLists.txt
+++ b/HAL-afb/Scarlett-Focusrite/CMakeLists.txt
@@ -24,7 +24,7 @@ PROJECT_TARGET_ADD(hal-scalett-usb)
ADD_LIBRARY(hal-scalett-usb MODULE ScarlettUsbHAL.c)
# Binder exposes a unique public entry point
- SET_TARGET_PROPERTIES(hal-scalett-usb PROPERTIES
+ SET_TARGET_PROPERTIES(${TARGET_NAME} PROPERTIES
PREFIX "afb-"
LABELS "BINDING"
LINK_FLAGS ${BINDINGS_LINK_FLAG}
@@ -32,11 +32,11 @@ PROJECT_TARGET_ADD(hal-scalett-usb)
)
# Library dependencies (include updates automatically)
- TARGET_LINK_LIBRARIES(hal-scalett-usb
+ TARGET_LINK_LIBRARIES(${TARGET_NAME}
hal-interface
audio-interface
)
# installation directory
- INSTALL(TARGETS hal-scalett-usb
+ INSTALL(TARGETS ${TARGET_NAME}
LIBRARY DESTINATION ${BINDINGS_INSTALL_DIR}) \ No newline at end of file
diff --git a/HAL-afb/Scarlett-Focusrite/ScarlettUsbHAL.c b/HAL-afb/Scarlett-Focusrite/ScarlettUsbHAL.c
index 99db443..cc62be1 100644
--- a/HAL-afb/Scarlett-Focusrite/ScarlettUsbHAL.c
+++ b/HAL-afb/Scarlett-Focusrite/ScarlettUsbHAL.c
@@ -58,7 +58,7 @@ STATIC alsaHalSndCardT alsaHalSndCard = {
STATIC int sndServiceInit () {
int err;
AFB_DEBUG ("IntelHalBinding Init");
-
+
err = halServiceInit (afbBindingV2.api, &alsaHalSndCard);
return err;
}
diff --git a/HAL-afb/Unicens-USB/CMakeLists.txt b/HAL-afb/Unicens-USB/CMakeLists.txt
new file mode 100644
index 0000000..5ca563b
--- /dev/null
+++ b/HAL-afb/Unicens-USB/CMakeLists.txt
@@ -0,0 +1,42 @@
+###########################################################################
+# Copyright 2015, 2016, 2017 IoT.bzh
+#
+# author: Fulup Ar Foll <fulup@iot.bzh>
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+###########################################################################
+
+
+# Add target to project dependency list
+PROJECT_TARGET_ADD(hal-unicens-usb)
+
+ # Define project Targets
+ ADD_LIBRARY(${TARGET_NAME} MODULE UnicensHAL.c UnicensVol.c)
+
+ # Binder exposes a unique public entry point
+ SET_TARGET_PROPERTIES(${TARGET_NAME} PROPERTIES
+ PREFIX "afb-"
+ LABELS "BINDING"
+ LINK_FLAGS ${BINDINGS_LINK_FLAG}
+ OUTPUT_NAME ${TARGET_NAME}
+ )
+
+ # Library dependencies (include updates automatically)
+ TARGET_LINK_LIBRARIES(${TARGET_NAME}
+ hal-interface
+ audio-interface
+ )
+
+ # installation directory
+ INSTALL(TARGETS ${TARGET_NAME}
+ LIBRARY DESTINATION ${BINDINGS_INSTALL_DIR}) \ No newline at end of file
diff --git a/HAL-afb/Unicens-USB/UnicensHAL.c b/HAL-afb/Unicens-USB/UnicensHAL.c
new file mode 100644
index 0000000..66f241f
--- /dev/null
+++ b/HAL-afb/Unicens-USB/UnicensHAL.c
@@ -0,0 +1,73 @@
+/*
+ * Copyright (C) 2016 "IoT.bzh"
+ * Author Fulup Ar Foll <fulup@iot.bzh>
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ *
+ * To find out which control your sound card uses
+ * aplay -l # Check sndcard name name in between []
+ * amixer -D hw:xx controls # get supported controls
+ * amixer -D "hw:3" cget numid=xx # get control settings
+ *
+ */
+#define _GNU_SOURCE
+#include "hal-interface.h"
+#include "audio-interface.h"
+
+STATIC struct json_object* MasterOnOff (alsaHalCtlMapT *control, void* handle, struct json_object *valJ) {
+ struct json_object *reponseJ;
+
+ AFB_INFO ("Power Set value=%s", json_object_get_string(valJ));
+
+ reponseJ=json_object_new_object();
+ json_object_object_add (reponseJ, "Callback", json_object_new_string("Hello From HAL"));
+
+ return reponseJ;
+}
+
+// Map HAL hight sndctl with Alsa numid and optionally with a custom callback for non Alsa supported functionalities.
+STATIC alsaHalMapT alsaHalMap[]= {
+ { .tag=Master_Playback_Volume, .ctl={.numid=04 } },
+ { .tag=PCM_Playback_Volume , .ctl={.numid=06 } },
+ { .tag=PCM_Playback_Switch , .ctl={.numid=05 } },
+ { .tag=Capture_Volume , .ctl={.numid=12 } },
+ { .tag=Master_OnOff_Switch , .ctl={.numid=0, .type=SND_CTL_ELEM_TYPE_BOOLEAN, .count=1, .name="Power-Switch"}, .cb={.callback=MasterOnOff, .handle=NULL}},
+ { .tag=Master_Playback_Ramp , .ctl={.numid=0, .type=SND_CTL_ELEM_TYPE_INTEGER, .count=2, .name="Volume-Switch"}, .cb={.callback=MasterOnOff, .handle=NULL}},
+
+ { .tag=EndHalCrlTag} /* marker for end of the array */
+} ;
+
+// HAL sound card mapping info
+STATIC alsaHalSndCardT alsaHalSndCard = {
+ .name = "HDA Intel PCH", // WARNING: name MUST match with 'aplay -l'
+ .info = "Hardware Abstraction Layer for IntelHDA sound card",
+ .ctls = alsaHalMap,
+};
+
+
+STATIC int sndServiceInit () {
+ int err;
+ AFB_DEBUG ("IntelHalBinding Init");
+
+ err = halServiceInit (afbBindingV2.api, &alsaHalSndCard);
+ return err;
+}
+
+// API prefix should be unique for each snd card
+PUBLIC const struct afb_binding_v2 afbBindingV2 = {
+ .api = "intel-hda",
+ .init = sndServiceInit,
+ .verbs = halServiceApi,
+ .onevent = halServiceEvent,
+};
diff --git a/HAL-afb/Unicens-USB/UnicensVol.c b/HAL-afb/Unicens-USB/UnicensVol.c
new file mode 100644
index 0000000..ab9787d
--- /dev/null
+++ b/HAL-afb/Unicens-USB/UnicensVol.c
@@ -0,0 +1,37 @@
+/*
+ * Copyright (C) 2016 "IoT.bzh"
+ * Author Fulup Ar Foll <fulup@iot.bzh>
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ *
+ * To find out which control your sound card uses
+ * aplay -l # Check sndcard name name in between []
+ * amixer -D hw:xx controls # get supported controls
+ * amixer -D "hw:3" cget numid=xx # get control settings
+ *
+ */
+#define _GNU_SOURCE
+#include "hal-interface.h"
+#include "audio-interface.h"
+
+STATIC struct json_object* MasterOnOff (alsaHalCtlMapT *control, void* handle, struct json_object *valJ) {
+ struct json_object *reponseJ;
+
+ AFB_INFO ("Power Set value=%s", json_object_get_string(valJ));
+
+ reponseJ=json_object_new_object();
+ json_object_object_add (reponseJ, "Callback", json_object_new_string("Hello From HAL"));
+
+ return reponseJ;
+}