+#include <stdint.h>
+#include <fcntl.h>
+#include <alsa/asoundlib.h>
+#include <alsa/hwdep.h>
+#include <stdio.h>
+
+struct iir_coeffs {
+ int16_t N0, N1, N2, D1, D2;
+ int16_t N3, N4, N5, D4, D5;
+};
+
+int main(){
+ struct iir_coeffs coeffs = {
+ .N0 = 32767, .N1 = 4265, .N2 = -10472, .D1 = -6269, .D2 = 0,
+ .N3 = 32027, .N4 = -31187, .N5 = 30352, .D4 = 31187, .D5 = -29613
+ };
+
+ snd_hwdep_t *hwdep;
+ int ret; int arg;
+
+ ret = snd_hwdep_open(&hwdep, "hw:0,0", SND_HWDEP_OPEN_DUPLEX);
+ printf("open: %i\n", ret);
+ if(ret) return 1;
+
+ ret = snd_hwdep_write(hwdep, (void*)&coeffs, sizeof(coeffs));
+ printf("write: %i\n", ret);
+
+ /* Set state to 2, which is 'Custom'. This writes coeffs to hardware
+ * and enables filter */
+ arg = 2;
+ ret = snd_hwdep_ioctl(hwdep, 1, &arg);
+ printf("ioctl: %i\n", ret);
+ return 0;
+}