summaryrefslogtreecommitdiffstats
path: root/HAL-afb
diff options
context:
space:
mode:
authorRomain Forlot <romain.forlot@iot.bzh>2017-08-23 10:54:30 +0200
committerRomain Forlot <romain.forlot@iot.bzh>2017-08-23 10:54:30 +0200
commitd0dae04c2ae6e4219e0ebac205dd05fa7e9427cf (patch)
tree80c6fc84f56afedc4fb02a097ae3e464bd792828 /HAL-afb
parent606ccd2405a55eab4c909160c951c083bccd825d (diff)
Format: remove blank space at EOL
Change-Id: I786ac8d5be68bdf09d5bb6c883959d6e1963c1fe Signed-off-by: Romain Forlot <romain.forlot@iot.bzh>
Diffstat (limited to 'HAL-afb')
-rw-r--r--HAL-afb/HAL-interface/CMakeLists.txt4
-rw-r--r--HAL-afb/HAL-interface/hal-interface.c10
-rw-r--r--HAL-afb/HAL-interface/hal-volramp.c12
-rw-r--r--HAL-afb/HAL-interface/hal-volume.c6
-rw-r--r--HAL-afb/HAL_MOST_UNICENS/CMakeLists.txt2
-rw-r--r--HAL-afb/HAL_MOST_UNICENS/README.md2
-rw-r--r--HAL-afb/HAL_MOST_UNICENS/hal_most_unicens.c48
-rw-r--r--HAL-afb/HAL_MOST_UNICENS/ucs2-vol/CMakeLists.txt2
-rw-r--r--HAL-afb/HAL_MOST_UNICENS/ucs2-vol/inc/device_value.h2
-rw-r--r--HAL-afb/HAL_MOST_UNICENS/ucs2-vol/inc/libmostvolume.h4
-rw-r--r--HAL-afb/HAL_MOST_UNICENS/ucs2-vol/src/device_container.cpp2
-rw-r--r--HAL-afb/HAL_MOST_UNICENS/ucs2-vol/src/device_value.cpp4
-rw-r--r--HAL-afb/HAL_MOST_UNICENS/ucs2-vol/src/libmostvolume.cpp4
-rw-r--r--HAL-afb/HAL_MOST_UNICENS/wrap_unicens.c140
-rw-r--r--HAL-afb/HAL_MOST_UNICENS/wrap_volume.c50
-rw-r--r--HAL-afb/HDA-intel/IntelHdaHAL.c12
-rw-r--r--HAL-afb/Jabra-Solemate/CMakeLists.txt2
-rw-r--r--HAL-afb/Jabra-Solemate/JabraUsbHAL.c24
-rw-r--r--HAL-afb/Scarlett-Focusrite/CMakeLists.txt2
-rw-r--r--HAL-afb/Scarlett-Focusrite/ScarlettUsbHAL.c26
20 files changed, 179 insertions, 179 deletions
diff --git a/HAL-afb/HAL-interface/CMakeLists.txt b/HAL-afb/HAL-interface/CMakeLists.txt
index 37d82de..bbe2e94 100644
--- a/HAL-afb/HAL-interface/CMakeLists.txt
+++ b/HAL-afb/HAL-interface/CMakeLists.txt
@@ -20,7 +20,7 @@
# Add target to project dependency list
PROJECT_TARGET_ADD(hal-interface)
- # Define targets
+ # Define targets
ADD_LIBRARY(${TARGET_NAME} STATIC hal-volume.c hal-volramp.c hal-interface.c)
# Library properties
@@ -30,7 +30,7 @@ PROJECT_TARGET_ADD(hal-interface)
TARGET_LINK_LIBRARIES(${TARGET_NAME}
audio-common
)
-
+
# Define target includes
TARGET_INCLUDE_DIRECTORIES(${TARGET_NAME}
PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}
diff --git a/HAL-afb/HAL-interface/hal-interface.c b/HAL-afb/HAL-interface/hal-interface.c
index 0abe67e..ad5eabb 100644
--- a/HAL-afb/HAL-interface/hal-interface.c
+++ b/HAL-afb/HAL-interface/hal-interface.c
@@ -13,10 +13,10 @@
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
- *
- * reference:
+ *
+ * reference:
* amixer contents; amixer controls;
- * http://www.tldp.org/HOWTO/Alsa-sound-6.html
+ * http://www.tldp.org/HOWTO/Alsa-sound-6.html
*/
#define _GNU_SOURCE // needed for vasprintf
#include <string.h>
@@ -553,7 +553,7 @@ PUBLIC int halServiceInit(const char *apiPrefix, alsaHalSndCardT *alsaHalSndCard
}
}
- // Make sure response is valid
+ // 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));
@@ -587,7 +587,7 @@ OnErrorExit:
};
-// This receive all event this binding subscribe to
+// This receive all event this binding subscribe to
PUBLIC void halServiceEvent(const char *evtname, json_object *eventJ) {
int numid;
diff --git a/HAL-afb/HAL-interface/hal-volramp.c b/HAL-afb/HAL-interface/hal-volramp.c
index eb39aae..60e91d6 100644
--- a/HAL-afb/HAL-interface/hal-volramp.c
+++ b/HAL-afb/HAL-interface/hal-volramp.c
@@ -13,7 +13,7 @@
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
- *
+ *
*/
#define _GNU_SOURCE // needed for vasprintf
@@ -36,14 +36,14 @@ STATIC int RampTimerCB(sd_event_source* source, uint64_t timer, void* handle) {
if (volRamp->current > volRamp->target) volRamp->current = volRamp->target;
}
- // request current Volume Level
+ // request current Volume Level
err = halSetCtlByTag(volRamp->slave, volRamp->current);
if (err) goto OnErrorExit;
// we reach target stop volram event
if (volRamp->current == volRamp->target) sd_event_source_unref(source);
else {
- // otherwise validate timer for a new run
+ // otherwise validate timer for a new run
sd_event_now(afb_daemon_get_event_loop(), CLOCK_MONOTONIC, &usec);
sd_event_source_set_enabled(source, SD_EVENT_ONESHOT);
err = sd_event_source_set_time(source, usec + volRamp->delay);
@@ -60,8 +60,8 @@ OnErrorExit:
STATIC void SetRampTimer(void *handle) {
halVolRampT *volRamp = (halVolRampT*) handle;
uint64_t usec;
-
- // set a timer with ~250us accuracy
+
+ // set a timer with ~250us accuracy
sd_event_now(afb_daemon_get_event_loop(), CLOCK_MONOTONIC, &usec);
sd_event_add_time(afb_daemon_get_event_loop(), &volRamp->evtsrc, CLOCK_MONOTONIC, usec, 250, RampTimerCB, volRamp);
}
@@ -69,7 +69,7 @@ STATIC void SetRampTimer(void *handle) {
STATIC int volumeDoRamp(halVolRampT *volRamp, int numid, json_object *volumeJ) {
json_object *responseJ;
- // request current Volume Level
+ // request current Volume Level
responseJ = halGetCtlByTag(volRamp->slave);
if (!responseJ) {
AFB_WARNING("volumeDoRamp Fail to get HAL ctl tag=%d", Master_Playback_Volume);
diff --git a/HAL-afb/HAL-interface/hal-volume.c b/HAL-afb/HAL-interface/hal-volume.c
index ad2b9a1..997ce98 100644
--- a/HAL-afb/HAL-interface/hal-volume.c
+++ b/HAL-afb/HAL-interface/hal-volume.c
@@ -13,8 +13,8 @@
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
- *
- * references:
+ *
+ * references:
* alsa-util/amixer.c + alsa-lib/simple.c
* snd_tlv_convert_from_dB
* nt snd_tlv_convert_to_dB
@@ -80,7 +80,7 @@ PUBLIC json_object *volumeNormalise(ActionSetGetT action, const alsaHalCtlMapT *
} else { // db_scale looks OK let's use it
if ((halCtls->dbscale->max - halCtls->dbscale->min) <= MAX_LINEAR_DB_SCALE * 100) useNormalizeDB = NORMALIZE_DB_LINEAR;
- else useNormalizeDB = NORMALIZE_LINEAR; // Fulup not sure how to handle this useNormalizeDB=NORMALIZE_DB_MATH;
+ else useNormalizeDB = NORMALIZE_LINEAR; // Fulup not sure how to handle this useNormalizeDB=NORMALIZE_DB_MATH;
}
} else useNormalizeDB = NORMALIZE_NONE;
diff --git a/HAL-afb/HAL_MOST_UNICENS/CMakeLists.txt b/HAL-afb/HAL_MOST_UNICENS/CMakeLists.txt
index eb4d1d6..5935b72 100644
--- a/HAL-afb/HAL_MOST_UNICENS/CMakeLists.txt
+++ b/HAL-afb/HAL_MOST_UNICENS/CMakeLists.txt
@@ -33,7 +33,7 @@ PROJECT_TARGET_ADD(hal-most-unicens)
)
# Library dependencies (include updates automatically)
- TARGET_LINK_LIBRARIES(${TARGET_NAME}
+ TARGET_LINK_LIBRARIES(${TARGET_NAME}
hal-interface
audio-common
ucs2-volume
diff --git a/HAL-afb/HAL_MOST_UNICENS/README.md b/HAL-afb/HAL_MOST_UNICENS/README.md
index a0cc190..4ce4261 100644
--- a/HAL-afb/HAL_MOST_UNICENS/README.md
+++ b/HAL-afb/HAL_MOST_UNICENS/README.md
@@ -42,7 +42,7 @@ card 2: ep022ch [Microchip MOST:2], device 0: ep02-2ch []
Subdevice #0: subdevice #0
```
-Choose the first sound card with 6 channels, e.g. if you see ```ep01-6ch``` just
+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:
diff --git a/HAL-afb/HAL_MOST_UNICENS/hal_most_unicens.c b/HAL-afb/HAL_MOST_UNICENS/hal_most_unicens.c
index 4405e61..2eb96b8 100644
--- a/HAL-afb/HAL_MOST_UNICENS/hal_most_unicens.c
+++ b/HAL-afb/HAL_MOST_UNICENS/hal_most_unicens.c
@@ -13,9 +13,9 @@
* 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 _GNU_SOURCE
#include <string.h>
#include "hal-interface.h"
#include "audio-common.h"
@@ -37,32 +37,32 @@ static int pcm_volume[PCM_MAX_CHANNELS];
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);
@@ -74,15 +74,15 @@ void unicens_pcm_vol_cb(halCtlsTagT tag, alsaHalCtlMapT *control, void* handle,
}
/* declare ALSA mixer controls */
-STATIC alsaHalMapT alsaHalMap[]= {
+STATIC alsaHalMapT alsaHalMap[]= {
{ .tag=Master_Playback_Volume, .cb={.callback=unicens_master_vol_cb, .handle=&master_volume}, .info="Sets master playback volume",
- .ctl={.numid=1, .type=SND_CTL_ELEM_TYPE_INTEGER, .count=1, .minval=0, .maxval=100, .step=1, .value=50, .name="Master Playback Volume"}
+ .ctl={.numid=1, .type=SND_CTL_ELEM_TYPE_INTEGER, .count=1, .minval=0, .maxval=100, .step=1, .value=50, .name="Master Playback Volume"}
},
/*{ .tag=Master_OnOff_Switch, .cb={.callback=unicens_master_switch_cb, .handle=&master_switch}, .info="Sets master playback switch",
- .ctl={.numid=2, .type=SND_CTL_ELEM_TYPE_BOOLEAN, .count=1, .minval=0, .maxval=1, .step=1, .value=1, .name="Master Playback Switch"}
+ .ctl={.numid=2, .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=3, .type=SND_CTL_ELEM_TYPE_INTEGER, .count=6, .minval=0, .maxval=100, .step=1, .value=100, .name="PCM Playback Volume"}
+ .ctl={.numid=3, .type=SND_CTL_ELEM_TYPE_INTEGER, .count=6, .minval=0, .maxval=100, .step=1, .value=100, .name="PCM Playback Volume"}
},
{ .tag=EndHalCrlTag} /* marker for end of the array */
} ;
@@ -100,19 +100,19 @@ STATIC int unicens_service_init() {
int err = 0;
char *config_file = NULL;
AFB_NOTICE("Initializing HAL-MOST-UNICENS-BINDING");
-
+
err = halServiceInit(afbBindingV2.api, &alsaHalSndCard);
if (err) {
AFB_ERROR("Cannot initialize ALSA soundcard.");
goto OnErrorExit;
- }
-
+ }
+
err= afb_daemon_require_api("UNICENS", 1);
if (err) {
AFB_ERROR("Failed to access UNICENS API");
goto OnErrorExit;
}
-
+
err = wrap_ucs_getconfig_sync(UCS2_CFG_PATH, &config_file);
if (err || (config_file == NULL)) {
AFB_ERROR("Failed to retrieve configuration");
@@ -121,46 +121,46 @@ STATIC int unicens_service_init() {
else {
AFB_NOTICE("Found configuration: %s", config_file);
}
-
+
err = wrap_ucs_subscribe_sync();
if (err) {
AFB_ERROR("Failed to subscribe to UNICENS binding");
goto OnErrorExit;
}
-
+
err = wrap_ucs_initialize_sync(config_file);
free(config_file);
config_file = NULL;
-
+
if (err) {
AFB_ERROR("Failed to initialize UNICENS binding");
goto OnErrorExit;
}
-
+
err = wrap_volume_init();
if (err) {
AFB_ERROR("Failed to initialize wrapper for volume library");
goto OnErrorExit;
}
-
+
OnErrorExit:
AFB_NOTICE("Initializing HAL-MOST-UNICENS-BINDING done..");
return err;
}
-// This receive all event this binding subscribe to
+// 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 [msg=%s]", evtname, json_object_get_string(j_event));
return;
}
-
+
AFB_NOTICE("unicens_event_cb: UNHANDLED EVENT, evtname=%s [msg=%s]", evtname, json_object_get_string(j_event));
}
diff --git a/HAL-afb/HAL_MOST_UNICENS/ucs2-vol/CMakeLists.txt b/HAL-afb/HAL_MOST_UNICENS/ucs2-vol/CMakeLists.txt
index 8735677..c734639 100644
--- a/HAL-afb/HAL_MOST_UNICENS/ucs2-vol/CMakeLists.txt
+++ b/HAL-afb/HAL_MOST_UNICENS/ucs2-vol/CMakeLists.txt
@@ -18,7 +18,7 @@
-# Define subproject targets
+# Define subproject targets
ADD_SUBDIRECTORY(src)
diff --git a/HAL-afb/HAL_MOST_UNICENS/ucs2-vol/inc/device_value.h b/HAL-afb/HAL_MOST_UNICENS/ucs2-vol/inc/device_value.h
index 21fdbdc..5364662 100644
--- a/HAL-afb/HAL_MOST_UNICENS/ucs2-vol/inc/device_value.h
+++ b/HAL-afb/HAL_MOST_UNICENS/ucs2-vol/inc/device_value.h
@@ -69,7 +69,7 @@ public:
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,
+ 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
diff --git a/HAL-afb/HAL_MOST_UNICENS/ucs2-vol/inc/libmostvolume.h b/HAL-afb/HAL_MOST_UNICENS/ucs2-vol/inc/libmostvolume.h
index 1d7249d..94d5a1c 100644
--- a/HAL-afb/HAL_MOST_UNICENS/ucs2-vol/inc/libmostvolume.h
+++ b/HAL-afb/HAL_MOST_UNICENS/ucs2-vol/inc/libmostvolume.h
@@ -60,13 +60,13 @@ typedef void (*lib_most_volume_writei2c_result_cb_t)(uint8_t result, void *user_
* \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,
+ lib_most_volume_writei2c_result_cb_t result_fptr,
void *result_user_ptr);
typedef struct lib_most_volume_init_ {
lib_most_volume_service_cb_t service_cb;
lib_most_volume_writei2c_cb_t writei2c_cb;
-
+
} lib_most_volume_init_t;
diff --git a/HAL-afb/HAL_MOST_UNICENS/ucs2-vol/src/device_container.cpp b/HAL-afb/HAL_MOST_UNICENS/ucs2-vol/src/device_container.cpp
index cef25b1..40177fc 100644
--- a/HAL-afb/HAL_MOST_UNICENS/ucs2-vol/src/device_container.cpp
+++ b/HAL-afb/HAL_MOST_UNICENS/ucs2-vol/src/device_container.cpp
@@ -112,7 +112,7 @@ void CDeviceContainer::Update()
{
return;
}
-
+
for (cnt = 0u; cnt < this->_values_sz; cnt++) /* just run one cycle */
{
IncrementProcIndex();
diff --git a/HAL-afb/HAL_MOST_UNICENS/ucs2-vol/src/device_value.cpp b/HAL-afb/HAL_MOST_UNICENS/ucs2-vol/src/device_value.cpp
index b8c681e..5a74354 100644
--- a/HAL-afb/HAL_MOST_UNICENS/ucs2-vol/src/device_value.cpp
+++ b/HAL-afb/HAL_MOST_UNICENS/ucs2-vol/src/device_value.cpp
@@ -93,14 +93,14 @@ bool CDeviceValue::RequiresUpdate()
return false;
}
-bool CDeviceValue::FireUpdateMessage(lib_most_volume_writei2c_cb_t writei2c_fptr,
+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;
ApplyMostValue(this->_target_value, _type, _tx_payload);
- ret = writei2c_fptr(this->_address, &_tx_payload[0], _tx_payload_sz,
+ ret = writei2c_fptr(this->_address, &_tx_payload[0], _tx_payload_sz,
result_fptr,
result_user_ptr);
diff --git a/HAL-afb/HAL_MOST_UNICENS/ucs2-vol/src/libmostvolume.cpp b/HAL-afb/HAL_MOST_UNICENS/ucs2-vol/src/libmostvolume.cpp
index a90b5b1..72d2b04 100644
--- a/HAL-afb/HAL_MOST_UNICENS/ucs2-vol/src/libmostvolume.cpp
+++ b/HAL-afb/HAL_MOST_UNICENS/ucs2-vol/src/libmostvolume.cpp
@@ -72,7 +72,7 @@ extern "C" uint8_t lib_most_volume_set(enum lib_most_volume_channel_t channel, u
}
extern "C" uint8_t lib_most_volume_service(void)
-{
+{
uint8_t success = 1U;
/*std::cerr << "lib_most_volume_service(): called" << std::endl;*/
@@ -81,6 +81,6 @@ extern "C" uint8_t lib_most_volume_service(void)
CSetup::GetInstance()->Update();
success = 0U;
}
-
+
return success;
}
diff --git a/HAL-afb/HAL_MOST_UNICENS/wrap_unicens.c b/HAL-afb/HAL_MOST_UNICENS/wrap_unicens.c
index dc82568..0923c26 100644
--- a/HAL-afb/HAL_MOST_UNICENS/wrap_unicens.c
+++ b/HAL-afb/HAL_MOST_UNICENS/wrap_unicens.c
@@ -13,9 +13,9 @@
* 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 _GNU_SOURCE
#define AFB_BINDING_VERSION 2
#include <string.h>
@@ -31,24 +31,24 @@ typedef struct async_job_ {
typedef struct parse_result_ {
int done;
- char *str_result;
-} parse_result_t;
+ 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;
+ goto OnErrorExit;
}
-
+
err = afb_service_call_sync("UNICENS", "subscribe", j_query, &j_response);
if (err) {
AFB_ERROR("Fail subscribing to UNICENS events");
@@ -60,7 +60,7 @@ extern int wrap_ucs_subscribe_sync() {
}
json_object_put(j_query);
j_query = NULL;
-
+
OnErrorExit:
if (j_query)
json_object_put(j_query);
@@ -69,52 +69,52 @@ OnErrorExit:
/* 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.
+ * 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;
+
+ 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;
}
@@ -127,24 +127,24 @@ static void wrap_ucs_find_xml_cb(void *closure, struct json_object *j_obj) {
* \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;
+ goto OnErrorExit;
}
-
+
err = afb_service_call_sync("UNICENS", "listconfig", j_query, &j_response);
if (err) {
AFB_ERROR("Failed to call listconfig");
@@ -152,13 +152,13 @@ extern int wrap_ucs_getconfig_sync(const char *config_path, char **file_found) {
}
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);
@@ -169,12 +169,12 @@ extern int wrap_ucs_getconfig_sync(const char *config_path, char **file_found) {
err = -1;
}
}
-
+
json_object_put(j_response);
}
json_object_put(j_query);
j_query = NULL;
-
+
OnErrorExit:
if (j_query)
json_object_put(j_query);
@@ -183,22 +183,22 @@ OnErrorExit:
/* Initializes the unicens2-binding.
* \param file_name Path to XML configuration file or \c NULL for
- * first found file in default path.
+ * 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)
+ 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;
+ goto OnErrorExit;
}
err = afb_service_call_sync("UNICENS", "initialise", j_query, &j_response);
if (err) {
@@ -209,10 +209,10 @@ extern int wrap_ucs_initialize_sync(const char *file_name) {
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);
@@ -221,7 +221,7 @@ OnErrorExit:
/* Write I2C command to a network node.
* \param node Node address
- * \param data_ptr Reference to command data
+ * \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".
*/
@@ -233,22 +233,22 @@ extern int wrap_ucs_i2cwrite_sync(uint16_t node, uint8_t *data_ptr, uint8_t data
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;
- }
-
+ 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;
@@ -257,40 +257,40 @@ extern int wrap_ucs_i2cwrite_sync(uint16_t node, uint8_t *data_ptr, uint8_t data
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;
+ 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(0U, 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_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,
+ wrap_ucs_result_cb_t result_fptr,
void *result_user_ptr) {
json_object *j_query, *j_array = NULL;
@@ -300,31 +300,31 @@ extern int wrap_ucs_i2cwrite(uint16_t node, uint8_t *data_ptr, uint8_t data_sz,
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;
- }
-
+ 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;
+ 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;
@@ -332,5 +332,5 @@ extern int wrap_ucs_i2cwrite(uint16_t node, uint8_t *data_ptr, uint8_t data_sz,
OnErrorExit:
if (j_query)
json_object_put(j_query);
- return err;
+ return err;
}
diff --git a/HAL-afb/HAL_MOST_UNICENS/wrap_volume.c b/HAL-afb/HAL_MOST_UNICENS/wrap_volume.c
index cf70647..8087a04 100644
--- a/HAL-afb/HAL_MOST_UNICENS/wrap_volume.c
+++ b/HAL-afb/HAL_MOST_UNICENS/wrap_volume.c
@@ -13,9 +13,9 @@
* 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 _GNU_SOURCE
#define AFB_BINDING_VERSION 2
#include <string.h>
@@ -31,88 +31,88 @@
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,
+ sd_event_add_time( afb_daemon_get_event_loop(), NULL, CLOCK_MONOTONIC,
+ usec + (timeout*1000),
+ 250,
+ wrap_volume_service_timeout_cb,
NULL);
}
/* Retrieves a new value adapted to a new maximum value. Minimum value is
* always zero. */
static int wrap_volume_calculate(int value, int max_old, int max_new) {
-
+
if (value > max_old)
value = max_old;
-
+
value = (value * max_new) / max_old; /* calculate range: 0..255 */
assert(value <= max_new);
-
+
return value;
}
extern int wrap_volume_init(void) {
-
+
uint8_t ret = 0U;
lib_most_volume_init_t mv_init;
-
+
mv_init.writei2c_cb = &wrap_ucs_i2cwrite;
mv_init.service_cb = wrap_volume_service_cb;
-
+
ret = lib_most_volume_init(&mv_init);
-
+
return ret * (-1);
}
extern int wrap_volume_master(int volume) {
-
+
int new_value, ret;
-
+
new_value = wrap_volume_calculate(volume, 100, 255);
ret = lib_most_volume_set(LIB_MOST_VOLUME_MASTER, (uint8_t)new_value);
-
+
if (ret != 0) {
AFB_ERROR("wrap_volume_master: volume library not ready.");
ret = ret * (-1); /* make return value negative */
}
-
+
return ret;
}
extern int wrap_volume_pcm(int *volume_ptr, int volume_sz) {
-
+
const int MAX_PCM_CHANNELS = 6;
int cnt, ret;
assert(volume_ptr != NULL);
assert(volume_sz <= MAX_PCM_CHANNELS);
-
+
for (cnt = 0; cnt < volume_sz; cnt ++) {
-
+
int new_value = wrap_volume_calculate(volume_ptr[cnt], 100, 255);
ret = lib_most_volume_set((enum lib_most_volume_channel_t)cnt, (uint8_t)new_value);
-
+
if (ret != 0) {
AFB_ERROR("wrap_volume_pcm: volume library not ready.");
ret = ret * (-1); /* make return value negative */
break;
}
}
-
+
return ret;
}
diff --git a/HAL-afb/HDA-intel/IntelHdaHAL.c b/HAL-afb/HDA-intel/IntelHdaHAL.c
index ab822ca..e169baa 100644
--- a/HAL-afb/HDA-intel/IntelHdaHAL.c
+++ b/HAL-afb/HDA-intel/IntelHdaHAL.c
@@ -13,17 +13,17 @@
* 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
+#define _GNU_SOURCE
#include "hal-interface.h"
-#include "audio-common.h"
+#include "audio-common.h"
// Default Values for MasterVolume Ramping
@@ -35,7 +35,7 @@ STATIC halVolRampT volRampMaster = {
.stepUp = 1,
};
-// Map HAL hight sndctl with Alsa numid and optionally with a custom callback for non Alsa supported functionalities.
+// Map HAL hight sndctl with Alsa numid and optionally with a custom callback for non Alsa supported functionalities.
STATIC alsaHalMapT alsaHalMap[] = {
{ .tag = Master_Playback_Volume, . ctl =
{ .name = "Master Playback Volume"}},
diff --git a/HAL-afb/Jabra-Solemate/CMakeLists.txt b/HAL-afb/Jabra-Solemate/CMakeLists.txt
index 41d6915..25c2626 100644
--- a/HAL-afb/Jabra-Solemate/CMakeLists.txt
+++ b/HAL-afb/Jabra-Solemate/CMakeLists.txt
@@ -32,7 +32,7 @@ PROJECT_TARGET_ADD(hal-jabra-usb)
)
# Library dependencies (include updates automatically)
- TARGET_LINK_LIBRARIES(${TARGET_NAME}
+ TARGET_LINK_LIBRARIES(${TARGET_NAME}
hal-interface
audio-common
)
diff --git a/HAL-afb/Jabra-Solemate/JabraUsbHAL.c b/HAL-afb/Jabra-Solemate/JabraUsbHAL.c
index 7eeab90..03d53d8 100644
--- a/HAL-afb/Jabra-Solemate/JabraUsbHAL.c
+++ b/HAL-afb/Jabra-Solemate/JabraUsbHAL.c
@@ -13,18 +13,18 @@
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
- *
- *
+ *
+ *
* To find out which control your sound card uses
* aplay -l # Check sndcard name name in between []
* amixer -D hw:USB controls # get supported controls
* amixer -Dhw:USB cget name=Power-Switch
* amixer -Dhw:USB cset name=Power-Switch true
- *
+ *
*/
-#define _GNU_SOURCE
+#define _GNU_SOURCE
#include "hal-interface.h"
-#include "audio-common.h"
+#include "audio-common.h"
// Define few private tag for not standard functions
#define PCM_Volume_Multimedia 1000
@@ -61,8 +61,8 @@ STATIC halVolRampT volRampEmergency= {
.stepUp = 3,
};
-// Map HAL hight sndctl with Alsa numid and optionally with a custom callback for non Alsa supported functionalities.
-STATIC alsaHalMapT alsaHalMap[]= {
+// Map HAL hight sndctl with Alsa numid and optionally with a custom callback for non Alsa supported functionalities.
+STATIC alsaHalMapT alsaHalMap[]= {
{ .tag=Master_Playback_Volume, . ctl={.name="PCM Playback Volume" } },
{ .tag=PCM_Playback_Volume , .ctl={.name="PCM Playback Volume" } },
{ .tag=PCM_Playback_Switch , .ctl={.name="PCM Playback Switch" } },
@@ -74,7 +74,7 @@ STATIC alsaHalMapT alsaHalMap[]= {
},
// Implement Rampup Volume for Virtual Channels
- { .tag=Multimedia_Playback_Volume, .cb={.callback=volumeRamp, .handle=&volRampMultimedia}, .info="Rampup Multimedia Volume",
+ { .tag=Multimedia_Playback_Volume, .cb={.callback=volumeRamp, .handle=&volRampMultimedia}, .info="Rampup Multimedia Volume",
.ctl={.numid=CTL_AUTO, .type=SND_CTL_ELEM_TYPE_INTEGER, .name="Playback Multimedia Ramp"}
},
{ .tag=Navigation_Playback_Volume, .cb={.callback=volumeRamp, .handle=&volRampNavigation}, .info="RampUp Navigation Volume",
@@ -83,9 +83,9 @@ STATIC alsaHalMapT alsaHalMap[]= {
{ .tag=Emergency_Playback_Volume, .cb={.callback=volumeRamp, .handle=&volRampEmergency}, .info="Rampup Emergency Volume",
.ctl={.numid=CTL_AUTO, .type=SND_CTL_ELEM_TYPE_INTEGER,.name="Playback Emergency Ramp"}
},
-
+
// Sound Card does not support hardware channel volume mixer (note softvol default range 0-256)
- { .tag=PCM_Volume_Multimedia, .info="Playback Multimedia Softvol",
+ { .tag=PCM_Volume_Multimedia, .info="Playback Multimedia Softvol",
.ctl={.numid=CTL_AUTO, .type=SND_CTL_ELEM_TYPE_INTEGER, .count=2, .maxval=255, .value=200, .name="Playback Multimedia"}
},
{ .tag=PCM_Volume_Navigation, .info="Playback Navigation Softvol",
@@ -94,8 +94,8 @@ STATIC alsaHalMapT alsaHalMap[]= {
{ .tag=PCM_Volume_Emergency, .info="Playback Emergency Softvol",
.ctl={.numid=CTL_AUTO, .type=SND_CTL_ELEM_TYPE_INTEGER, .count=2, .maxval=255, .value=200, .name="Playback Emergency"}
},
-
-
+
+
{ .tag=EndHalCrlTag} /* marker for end of the array */
} ;
diff --git a/HAL-afb/Scarlett-Focusrite/CMakeLists.txt b/HAL-afb/Scarlett-Focusrite/CMakeLists.txt
index 90ee92a..d2a1742 100644
--- a/HAL-afb/Scarlett-Focusrite/CMakeLists.txt
+++ b/HAL-afb/Scarlett-Focusrite/CMakeLists.txt
@@ -32,7 +32,7 @@ PROJECT_TARGET_ADD(hal-scalett-usb)
)
# Library dependencies (include updates automatically)
- TARGET_LINK_LIBRARIES(${TARGET_NAME}
+ TARGET_LINK_LIBRARIES(${TARGET_NAME}
hal-interface
audio-common
)
diff --git a/HAL-afb/Scarlett-Focusrite/ScarlettUsbHAL.c b/HAL-afb/Scarlett-Focusrite/ScarlettUsbHAL.c
index 94bfa4f..cff213c 100644
--- a/HAL-afb/Scarlett-Focusrite/ScarlettUsbHAL.c
+++ b/HAL-afb/Scarlett-Focusrite/ScarlettUsbHAL.c
@@ -13,18 +13,18 @@
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
- *
- *
+ *
+ *
* To find out which control your sound card uses
* aplay -l # Check sndcard name name in between []
* amixer -D hw:USB controls # get supported controls
* amixer -Dhw:USB cget name=Power-Switch
* amixer -Dhw:USB cset name=Power-Switch true
- *
+ *
*/
-#define _GNU_SOURCE
+#define _GNU_SOURCE
#include "hal-interface.h"
-#include "audio-common.h"
+#include "audio-common.h"
// Default Values for MasterVolume Ramping
STATIC halVolRampT volRampMaster= {
@@ -35,19 +35,19 @@ STATIC halVolRampT volRampMaster= {
.stepUp =1,
};
-// Map HAL hight sndctl with Alsa numid and optionally with a custom callback for non Alsa supported functionalities.
-STATIC alsaHalMapT alsaHalMap[]= {
+// Map HAL hight sndctl with Alsa numid and optionally with a custom callback for non Alsa supported functionalities.
+STATIC alsaHalMapT alsaHalMap[]= {
{ .tag=Master_Playback_Volume, . ctl={.name="Master Playback Volume" } },
{ .tag=PCM_Playback_Volume , .ctl={.name="Master 1 (Monitor) Playback Volume" } },
{ .tag=PCM_Playback_Switch , .ctl={.numid=05 } },
{ .tag=Capture_Volume , .ctl={.numid=12 } },
{ .tag=Vol_Ramp_Set_Mode , .cb={.callback=volumeRamp, .handle=&volRampMaster}, .info="select volramp speed",
- .ctl={.numid=0, .type=SND_CTL_ELEM_TYPE_ENUMERATED, .count=1, .value=RAMP_VOL_NORMAL, .name="Hal-VolRamp-Mode", .enums=halVolRampModes}
- },
+ .ctl={.numid=0, .type=SND_CTL_ELEM_TYPE_ENUMERATED, .count=1, .value=RAMP_VOL_NORMAL, .name="Hal-VolRamp-Mode", .enums=halVolRampModes}
+ },
{ .tag=Vol_Ramp_Set_Slave , .cb={.callback=volumeRamp, .handle=&volRampMaster}, .info="set slave volume master numid",
- .ctl={.numid=0, .type=SND_CTL_ELEM_TYPE_INTEGER, .count=1, .value=Master_Playback_Volume, .name="Hal-VolRamp-Slave", .enums=halVolRampModes}
- },
+ .ctl={.numid=0, .type=SND_CTL_ELEM_TYPE_INTEGER, .count=1, .value=Master_Playback_Volume, .name="Hal-VolRamp-Slave", .enums=halVolRampModes}
+ },
{ .tag=Vol_Ramp_Set_Delay , .cb={.callback=volumeRamp, .handle=&volRampMaster}, .info="set ramp delay [default 250ms]",
.ctl={.numid=0, .type=SND_CTL_ELEM_TYPE_INTEGER, .count=1, .minval=0, .maxval=1000, .step=100, .value=250, .name="Hal-VolRamp-Step-Down"}
},
@@ -60,7 +60,7 @@ STATIC alsaHalMapT alsaHalMap[]= {
{ .tag=Master_Playback_Volume , .cb={.callback=volumeRamp, .handle=&volRampMaster}, .info="ramp volume linearly according to current ramp setting",
.ctl={.numid=0, .type=SND_CTL_ELEM_TYPE_INTEGER, .count=1, .minval=0, .maxval=100, .step=1, .name="Hal-VolRamp"}
},
-
+
{ .tag=EndHalCrlTag} /* marker for end of the array */
} ;
@@ -76,7 +76,7 @@ STATIC alsaHalSndCardT alsaHalSndCard = {
STATIC int sndServiceInit () {
int err;
AFB_DEBUG ("Scarlett Binding Init");
-
+
err = halServiceInit (afbBindingV2.api, &alsaHalSndCard);
return err;
}