summaryrefslogtreecommitdiffstats
path: root/4a-hal
diff options
context:
space:
mode:
authorJonathan Aillet <jonathan.aillet@iot.bzh>2018-06-08 15:30:46 +0200
committerJonathan Aillet <jonathan.aillet@iot.bzh>2018-10-08 15:52:51 +0200
commitdddb442d4a5208c0ad63479daca3e3c7a3946ee0 (patch)
tree53f079c8833bd2657ddcc3399a69a34e5a0dc03d /4a-hal
parent7297c6b5d2dc47574e981c76a282e67fcef230c0 (diff)
Get alsa controls properties at control get
Get alsa controls properties by parsing the response sent by balsacore when we search for an existing alsa control. Change-Id: I9d13327ae2ef79c793dbd227589740f7e336e46c Signed-off-by: Jonathan Aillet <jonathan.aillet@iot.bzh>
Diffstat (limited to '4a-hal')
-rw-r--r--4a-hal/4a-hal-controllers/4a-hal-controllers-alsacore-link.c37
-rw-r--r--4a-hal/4a-hal-controllers/4a-hal-controllers-alsacore-link.h2
2 files changed, 28 insertions, 11 deletions
diff --git a/4a-hal/4a-hal-controllers/4a-hal-controllers-alsacore-link.c b/4a-hal/4a-hal-controllers/4a-hal-controllers-alsacore-link.c
index 462994a..230cddd 100644
--- a/4a-hal/4a-hal-controllers/4a-hal-controllers-alsacore-link.c
+++ b/4a-hal/4a-hal-controllers/4a-hal-controllers-alsacore-link.c
@@ -185,10 +185,10 @@ int HalCtlsGetAlsaCtlInfo(AFB_ApiT apiHandle, char *cardId, struct CtlHalAlsaCtl
return -4;
}
else if(currentAlsaCtl->name) {
- wrap_json_pack(&queryJ, "{s:s s:s}", "devid", cardId, "ctl", currentAlsaCtl->name);
+ wrap_json_pack(&queryJ, "{s:s s:s s:i}", "devid", cardId, "ctl", currentAlsaCtl->name, "mode", 3);
}
else if(currentAlsaCtl->numid > 0) {
- wrap_json_pack(&queryJ, "{s:s s:i}", "devid", cardId, "ctl", currentAlsaCtl->numid);
+ wrap_json_pack(&queryJ, "{s:s s:i s:i}", "devid", cardId, "ctl", currentAlsaCtl->numid, "mode", 3);
}
else {
AFB_ApiError(apiHandle, "%s: Need at least a control name or a control uid", __func__);
@@ -216,6 +216,23 @@ int HalCtlsGetAlsaCtlInfo(AFB_ApiT apiHandle, char *cardId, struct CtlHalAlsaCtl
return -8;
}
+ // TBD JAI : get dblinear/dbminmax/... values
+ if(wrap_json_unpack(returnedJ, "{s:{s:{s?:i s?:i s?:i s?:i s?:i}}}",
+ "response",
+ "ctl",
+ "type", (snd_ctl_elem_type_t) &currentAlsaCtl->alsaCtlProperties.type,
+ "count", &currentAlsaCtl->alsaCtlProperties.count,
+ "min", &currentAlsaCtl->alsaCtlProperties.minval,
+ "max", &currentAlsaCtl->alsaCtlProperties.maxval,
+ "step", &currentAlsaCtl->alsaCtlProperties.step)) {
+ AFB_ApiError(apiHandle,
+ "Didn't succeed to get control %i properties on device '%s' : '%s'",
+ currentAlsaCtl->numid,
+ cardId,
+ json_object_get_string(returnedJ));
+ return -9;
+ }
+
return 0;
}
@@ -301,16 +318,16 @@ int HalCtlsCreateAlsaCtl(AFB_ApiT apiHandle, char *cardId, struct CtlHalAlsaCtl
return -4;
}
- wrap_json_pack(&queryJ, "{s:s s:{s:i s:s s:i s:i s:i s:i s:i s:i} s:i}",
+ wrap_json_pack(&queryJ, "{s:s s:{s:i s:s s:i s:i s:i s:i s:i}}",
"devid", cardId,
"ctl",
- "ctl", -1,
- "name", alsaCtlToCreate->name,
- "min", alsaCtlToCreate->alsaCtlCreation->minval,
- "max", alsaCtlToCreate->alsaCtlCreation->maxval,
- "step", alsaCtlToCreate->alsaCtlCreation->step,
- "type", (int) alsaCtlToCreate->alsaCtlCreation->type,
- "count", alsaCtlToCreate->alsaCtlCreation->count);
+ "ctl", -1,
+ "name", alsaCtlToCreate->name,
+ "min", alsaCtlToCreate->alsaCtlCreation->minval,
+ "max", alsaCtlToCreate->alsaCtlCreation->maxval,
+ "step", alsaCtlToCreate->alsaCtlCreation->step,
+ "type", (int) alsaCtlToCreate->alsaCtlCreation->type,
+ "count", alsaCtlToCreate->alsaCtlCreation->count);
if(AFB_ServiceSync(apiHandle, ALSACORE_API, ALSACORE_ADDCTL_VERB, queryJ, &returnedJ)) {
returnedError = HalUtlHandleAppFwCallError(apiHandle, ALSACORE_API, ALSACORE_ADDCTL_VERB, returnedJ, &returnedStatus, &returnedInfo);
diff --git a/4a-hal/4a-hal-controllers/4a-hal-controllers-alsacore-link.h b/4a-hal/4a-hal-controllers/4a-hal-controllers-alsacore-link.h
index d2687eb..1776c80 100644
--- a/4a-hal/4a-hal-controllers/4a-hal-controllers-alsacore-link.h
+++ b/4a-hal/4a-hal-controllers/4a-hal-controllers-alsacore-link.h
@@ -49,7 +49,7 @@ struct CtlHalAlsaCtlProperties {
int step;
// TBD JAI : use them
const char **enums;
- struct CtlHalAlsaDBScale *dbscale;
+ struct CtlHalAlsaDBScale dbscale;
};
struct CtlHalAlsaCtl {