[ARM] tegra: cpcap-audio: enable turning off audio-output paths
authorIliyan Malchev <malchev@google.com>
Thu, 12 Aug 2010 00:43:34 +0000 (17:43 -0700)
committerColin Cross <ccross@android.com>
Wed, 6 Oct 2010 23:33:37 +0000 (16:33 -0700)
Signed-off-by: Iliyan Malchev <malchev@google.com>
drivers/mfd/cpcap-audio.c
include/linux/cpcap_audio.h

index 7cb3bc51fa27b56ca7545707299350f4001448ac..d335083899bf07839e39336f4c5cf1fe439c4a2a 100644 (file)
@@ -126,35 +126,41 @@ static long cpcap_audio_ctl_ioctl(struct file *file, unsigned int cmd,
                        unsigned long arg)
 {
        int rc = 0;
+       struct cpcap_audio_output out;
 
        mutex_lock(&cpcap_lock);
 
        switch (cmd) {
        case CPCAP_AUDIO_OUT_SET_OUTPUT:
-               if (arg > CPCAP_AUDIO_OUT_MAX) {
-                       pr_err("%s: invalid audio-output selector %ld\n",
-                               __func__, arg);
+               if (copy_from_user(&out, (const void __user *)arg,
+                               sizeof(out))) {
+                       rc = -EFAULT;
+                       goto done;
+               }
+               if (out.id > CPCAP_AUDIO_OUT_MAX) {
+                       pr_err("%s: invalid audio-output selector %d\n",
+                               __func__, out.id);
                        rc = -EINVAL;
                        goto done;
                }
-               switch (arg) {
+               switch (out.id) {
                case CPCAP_AUDIO_OUT_SPEAKER:
                        pr_info("%s: setting output path to %s\n", __func__,
                                        pdata->speaker->name);
                        cpcap_audio_set(pdata->headset, 0);
-                       cpcap_audio_set(pdata->speaker, 1);
+                       cpcap_audio_set(pdata->speaker, out.on);
                        break;
                case CPCAP_AUDIO_OUT_HEADSET:
                        pr_info("%s: setting output path to %s\n", __func__,
                                        pdata->headset->name);
                        cpcap_audio_set(pdata->speaker, 0);
-                       cpcap_audio_set(pdata->headset, 1);
+                       cpcap_audio_set(pdata->headset, out.on);
                        break;
                }
-               current_output = arg;
+               current_output = out.id;
                break;
        case CPCAP_AUDIO_OUT_GET_OUTPUT:
-               if (copy_to_user((void *)arg, &current_output,
+               if (copy_to_user((void __user *)arg, &current_output,
                                        sizeof(unsigned int)))
                        rc = -EFAULT;
                break;
@@ -187,7 +193,7 @@ static long cpcap_audio_ctl_ioctl(struct file *file, unsigned int cmd,
                current_input = arg;
                break;
        case CPCAP_AUDIO_IN_GET_INPUT:
-               if (copy_to_user((void *)arg, &current_input,
+               if (copy_to_user((void __user *)arg, &current_input,
                                        sizeof(unsigned int)))
                        rc = -EFAULT;
                break;
@@ -222,14 +228,14 @@ static long cpcap_audio_ctl_ioctl(struct file *file, unsigned int cmd,
                current_in_volume = arg;
                break;
        case CPCAP_AUDIO_OUT_GET_VOLUME:
-               if (copy_to_user((void *)arg, &current_volume,
+               if (copy_to_user((void __user *)arg, &current_volume,
                                        sizeof(unsigned int))) {
                        rc = -EFAULT;
                        goto done;
                }
                break;
        case CPCAP_AUDIO_IN_GET_VOLUME:
-               if (copy_to_user((void *)arg, &current_in_volume,
+               if (copy_to_user((void __user *)arg, &current_in_volume,
                                        sizeof(unsigned int))) {
                        rc = -EFAULT;
                        goto done;
index 12b219325a1ab7e4b06a5a7df680f9f1883bd936..50097231b276df7df35dea857d8ce21b4689322e 100644 (file)
 #define CPCAP_AUDIO_OUT_HEADSET                1
 #define CPCAP_AUDIO_OUT_MAX            1
 
-#define CPCAP_AUDIO_OUT_SET_OUTPUT _IOW(CPCAP_AUDIO_MAGIC, 0, unsigned int)
+struct cpcap_audio_output {
+       int id; /* e.g., CPCAP_AUDIO_OUT_SPEAKER */
+       int on;
+};
+
+#define CPCAP_AUDIO_OUT_SET_OUTPUT _IOW(CPCAP_AUDIO_MAGIC, 0, \
+                       struct cpcap_audio_output *)
 
 #define CPCAP_AUDIO_OUT_VOL_MIN 0
 #define CPCAP_AUDIO_OUT_VOL_MAX 15