summaryrefslogtreecommitdiffstats
path: root/HAL-afb/HDA-intel/IntelHdaHAL.c
diff options
context:
space:
mode:
authorfulup <fulup.arfoll@iot.bzh>2017-07-01 00:22:00 +0200
committerfulup <fulup.arfoll@iot.bzh>2017-07-01 00:22:00 +0200
commitc326a053cdf8a4a9ce0fb02448293b45083d553c (patch)
treeaa1209094f735e96ad506615fe04d375b773543a /HAL-afb/HDA-intel/IntelHdaHAL.c
parent10c42e135b22bf323836100ede042ec47ddb22a1 (diff)
Ongoing work
Diffstat (limited to 'HAL-afb/HDA-intel/IntelHdaHAL.c')
-rw-r--r--HAL-afb/HDA-intel/IntelHdaHAL.c73
1 files changed, 32 insertions, 41 deletions
diff --git a/HAL-afb/HDA-intel/IntelHdaHAL.c b/HAL-afb/HDA-intel/IntelHdaHAL.c
index 98ac442..f394fd6 100644
--- a/HAL-afb/HDA-intel/IntelHdaHAL.c
+++ b/HAL-afb/HDA-intel/IntelHdaHAL.c
@@ -13,42 +13,33 @@
* 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"
-// Init is call after all binding are loaded
-STATIC int IntelHalInit (void) {
- DEBUG ("IntelHalBinding Initialised");
-
- return 0; // 0=OK
-}
-
-STATIC void MasterOnOff (alsaHalCtlMapT *control, void* handle) {
+STATIC struct json_object* MasterOnOff (alsaHalCtlMapT *control, void* handle) {
static int powerStatus=0;
if (! powerStatus) {
powerStatus = 1;
- DEBUG ("Power Set to On");
+ AFB_DEBUG ("Power Set to On");
} else {
powerStatus = 0;
- DEBUG ("Power Set to Off");
+ AFB_DEBUG ("Power Set to Off");
}
+
+ return NULL;
}
-/******************************************************************************************
- * alsaCtlsMap link hight level sound control with low level Alsa numid ctls.
- *
- * To find out which control your sound card uses
- * aplay -l
- * amixer -D hw:xx controls
- * amixer -D hw:xx contents
- * amixer -D "hw:3" cget numid=xx
- *
- * When automatic mapping to Alsa numid is not enough a custom callback might be used
- * .cb={.handle=xxxx, .callback=(json_object)MyCtlFunction(struct afb_service service, int controle, int value, const struct alsaHalCtlMapS *map)};
- ********************************************************************************************/
+// Map HAL hight sndctl with Alsa numid and optionally with a custom callback for non Alsa supported functionalities.
STATIC alsaHalMapT alsaHalMap[]= {
{ .alsa={.control=Master_Playback_Volume,.numid=16, .name="Master-Vol" , .values=1,.minval=0,.maxval= 87 ,.step=0}, .info= "Master Playback Volume" },
{ .alsa={.control=PCM_Playback_Volume ,.numid=27, .name="Play-Vol" , .values=2,.minval=0,.maxval= 255,.step=0}, .info= "PCM Playback Volume" },
@@ -58,26 +49,26 @@ STATIC alsaHalMapT alsaHalMap[]= {
{ .alsa={.numid=0}, .cb={.callback=NULL, .handle=NULL}} /* marker for end of the array */
} ;
-/***********************************************************************************
- * AlsaHalSndT provides
- * - cardname used to map a given card to its HAL
- * - ctls previously defined AlsaHalMapT control maps
- * - info free text
- *
- * WARNING: name should fit with 'aplay -l' as it used to map from devid to HAL
- * you may also retreive shortname when AudioBinder is running from a browser
- * http://localhost:1234/api/alsacore/getcardid?devid=hw:xxx
- *
- ***********************************************************************************/
-
-// API prefix should be unique for each snd card
-PUBLIC const char sndCardApiPrefix[] = "intel-hda";
-
-// HAL sound card controls mapping
-PUBLIC alsaHalSndCardT alsaHalSndCard = {
- .name = "HDA Intel PCH",
+// 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,
- .initCB=IntelHalInit, // if NULL no initcallback
};
+
+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,
+};