[ARM] tegra: tegra_i2s_audio: allow preloading of the tx fifo with data
authorIliyan Malchev <malchev@google.com>
Fri, 20 Aug 2010 22:11:48 +0000 (15:11 -0700)
committerColin Cross <ccross@android.com>
Wed, 6 Oct 2010 23:27:50 +0000 (16:27 -0700)
Add an ioctl to allow the TX fifo to be loaded with data before playback
starts.  Playback can then be started by calling write() on the FIFO, even
with a length of 0.  This will cause the pending data to be played out.

Signed-off-by: Iliyan Malchev <malchev@google.com>
arch/arm/mach-tegra/tegra_i2s_audio.c
include/linux/tegra_audio.h

index 40653570f87ab4ce6b7e733e6f3c5906d14847dd..47626e103e8d44545ce21810704a42907a7bc91d 100644 (file)
@@ -1262,6 +1262,26 @@ static long tegra_audio_out_ioctl(struct file *file,
                if (!rc)
                        aos->errors = 0;
                break;
+       case TEGRA_AUDIO_OUT_PRELOAD_FIFO: {
+               struct tegra_audio_out_preload preload;
+               if (copy_from_user(&preload, (void __user *)arg,
+                               sizeof(preload))) {
+                       rc = -EFAULT;
+                       break;
+               }
+               rc = kfifo_from_user(&ads->out.fifo,
+                               (void __user *)preload.data, preload.len,
+                               &preload.len_written);
+               if (rc < 0) {
+                       pr_err("%s: error copying from user\n", __func__);
+                       break;
+               }
+               if (copy_to_user((void __user *)arg, &preload, sizeof(preload)))
+                       rc = -EFAULT;
+               pr_info("%s: preloaded output fifo with %d bytes\n", __func__,
+                       preload.len_written);
+       }
+               break;
        default:
                rc = -EINVAL;
        }
index 48590daa06a5f1e399e205b8f331a30c288e78a4..15139cc31d84e69a5469cd5b39cc161034499c4b 100644 (file)
@@ -58,5 +58,13 @@ struct tegra_audio_buf_config {
 #define TEGRA_AUDIO_OUT_GET_ERROR_COUNT        _IOR(TEGRA_AUDIO_MAGIC, 9, \
                        unsigned *)
 
+struct tegra_audio_out_preload {
+       void *data;
+       size_t len;
+       size_t len_written;
+};
+
+#define TEGRA_AUDIO_OUT_PRELOAD_FIFO   _IOWR(TEGRA_AUDIO_MAGIC, 10, \
+                       struct tegra_audio_out_preload *)
 
 #endif/*_CPCAP_AUDIO_H*/