pcm: add support for pcm_ioctl() api

Tinyalsa doesn't expose an api to call ioctls exposed by
the audio drivers. Add pcm_ioctl() api.

Bug: 18137488.

Change-Id: I6218580dbf4b2f31cb95d246ed79f0d2ac28b0b1
diff --git a/include/tinyalsa/asoundlib.h b/include/tinyalsa/asoundlib.h
index 75e5cda..809e02d 100644
--- a/include/tinyalsa/asoundlib.h
+++ b/include/tinyalsa/asoundlib.h
@@ -239,6 +239,9 @@
 int pcm_start(struct pcm *pcm);
 int pcm_stop(struct pcm *pcm);
 
+/* ioctl function for PCM driver */
+int pcm_ioctl(struct pcm *pcm, int request, ...);
+
 /* Interrupt driven API */
 int pcm_wait(struct pcm *pcm, int timeout);
 
diff --git a/pcm.c b/pcm.c
index a25428e..d8af58a 100644
--- a/pcm.c
+++ b/pcm.c
@@ -1283,3 +1283,18 @@
 
     return pcm_mmap_transfer(pcm, data, count);
 }
+
+int pcm_ioctl(struct pcm *pcm, int request, ...)
+{
+    va_list ap;
+    void * arg;
+
+    if (!pcm_is_ready(pcm))
+        return -1;
+
+    va_start(ap, request);
+    arg = va_arg(ap, void *);
+    va_end(ap);
+
+    return ioctl(pcm->fd, request, arg);
+}