Add pcm_params_set_min/max and update comments

Change-Id: I40040a7e94689dcf6bf9d0bf0d182f66b151d530
diff --git a/pcm.c b/pcm.c
index 7c05a87..662e8a1 100644
--- a/pcm.c
+++ b/pcm.c
@@ -102,6 +102,14 @@
     return 0;
 }
 
+static void param_set_max(struct snd_pcm_hw_params *p, int n, unsigned int val)
+{
+    if (param_is_interval(n)) {
+        struct snd_interval *i = param_to_interval(p, n);
+        i->max = val;
+    }
+}
+
 static unsigned int param_get_max(struct snd_pcm_hw_params *p, int n)
 {
     if (param_is_interval(n)) {
@@ -595,6 +603,22 @@
     return param_get_min(params, p);
 }
 
+void pcm_params_set_min(struct pcm_params *pcm_params,
+                                enum pcm_param param, unsigned int val)
+{
+    struct snd_pcm_hw_params *params = (struct snd_pcm_hw_params *)pcm_params;
+    int p;
+
+    if (!params)
+        return;
+
+    p = pcm_param_to_alsa(param);
+    if (p < 0)
+        return;
+
+    param_set_min(params, p, val);
+}
+
 unsigned int pcm_params_get_max(struct pcm_params *pcm_params,
                                 enum pcm_param param)
 {
@@ -611,6 +635,22 @@
     return param_get_max(params, p);
 }
 
+void pcm_params_set_max(struct pcm_params *pcm_params,
+                                enum pcm_param param, unsigned int val)
+{
+    struct snd_pcm_hw_params *params = (struct snd_pcm_hw_params *)pcm_params;
+    int p;
+
+    if (!params)
+        return;
+
+    p = pcm_param_to_alsa(param);
+    if (p < 0)
+        return;
+
+    param_set_max(params, p, val);
+}
+
 int pcm_close(struct pcm *pcm)
 {
     if (pcm == &bad_pcm)
@@ -679,7 +719,6 @@
     param_set_int(&params, SNDRV_PCM_HW_PARAM_RATE, config->rate);
 
     if (flags & PCM_NOIRQ) {
-
         if (!(flags & PCM_MMAP)) {
             oops(pcm, -EINVAL, "noirq only currently supported with mmap().");
             goto fail;
@@ -691,10 +730,10 @@
 
     if (flags & PCM_MMAP)
         param_set_mask(&params, SNDRV_PCM_HW_PARAM_ACCESS,
-                   SNDRV_PCM_ACCESS_MMAP_INTERLEAVED);
+                       SNDRV_PCM_ACCESS_MMAP_INTERLEAVED);
     else
         param_set_mask(&params, SNDRV_PCM_HW_PARAM_ACCESS,
-                   SNDRV_PCM_ACCESS_RW_INTERLEAVED);
+                       SNDRV_PCM_ACCESS_RW_INTERLEAVED);
 
     if (ioctl(pcm->fd, SNDRV_PCM_IOCTL_HW_PARAMS, &params)) {
         oops(pcm, errno, "cannot set hw params");
@@ -716,7 +755,6 @@
         }
     }
 
-
     memset(&sparams, 0, sizeof(sparams));
     sparams.tstamp_mode = SNDRV_PCM_TSTAMP_ENABLE;
     sparams.period_step = 1;
@@ -756,7 +794,7 @@
     pcm->boundary = sparams.boundary = pcm->buffer_size;
 
     while (pcm->boundary * 2 <= INT_MAX - pcm->buffer_size)
-		pcm->boundary *= 2;
+        pcm->boundary *= 2;
 
     if (ioctl(pcm->fd, SNDRV_PCM_IOCTL_SW_PARAMS, &sparams)) {
         oops(pcm, errno, "cannot set sw params");