summaryrefslogtreecommitdiff
path: root/include/i2s.h
diff options
context:
space:
mode:
authorSimon Glass <sjg@chromium.org>2018-12-10 20:37:34 +0300
committerSimon Glass <sjg@chromium.org>2018-12-14 02:32:49 +0300
commite96fa6c91177d0aa81119d1d24cc0aa2dd663581 (patch)
tree333d54a1f9349c5e238f836675d49dbe5b59bc4b /include/i2s.h
parentce6d99a056ebc9ad329521ca3660f6cb298a7666 (diff)
downloadu-boot-e96fa6c91177d0aa81119d1d24cc0aa2dd663581.tar.xz
dm: sound: Create a uclass for i2s
The i2s bus is commonly used with audio codecs. It provides a way to stream digital data sychronously in both directions. U-Boot only supports audio output, so this uclass is very simple, with a single tx_data() method. Add a uclass and a test for i2s. Signed-off-by: Simon Glass <sjg@chromium.org>
Diffstat (limited to 'include/i2s.h')
-rw-r--r--include/i2s.h32
1 files changed, 28 insertions, 4 deletions
diff --git a/include/i2s.h b/include/i2s.h
index f23862ca04..28f6184811 100644
--- a/include/i2s.h
+++ b/include/i2s.h
@@ -87,17 +87,41 @@ struct i2s_uc_priv {
unsigned int id; /* I2S controller id */
};
+/* Operations for i2s devices */
+struct i2s_ops {
+ /**
+ * tx_data() - Transmit audio data
+ *
+ * @dev: I2C device
+ * @data: Data buffer to play
+ * @data_size: Size of data buffer in bytes
+ * @return 0 if OK, -ve on error
+ */
+ int (*tx_data)(struct udevice *dev, void *data, uint data_size);
+};
+
+#define i2s_get_ops(dev) ((struct i2s_ops *)(dev)->driver->ops)
+
+/**
+ * i2s_tx_data() - Transmit audio data
+ *
+ * @dev: I2C device
+ * @data: Data buffer to play
+ * @data_size: Size of data buffer in bytes
+ * @return 0 if OK, -ve on error
+ */
+int i2s_tx_data(struct udevice *dev, void *data, uint data_size);
+
/*
* Sends the given data through i2s tx
*
* @param pi2s_tx pointer of i2s transmitter parameter structure.
* @param data address of the data buffer
- * @param data_size array size of the int buffer (total size / size of int)
- *
+ * @param data_size size of the data (in bytes)
* @return int value 0 for success, -1 in case of error
*/
-int i2s_transfer_tx_data(struct i2s_uc_priv *pi2s_tx, unsigned int *data,
- unsigned long data_size);
+int i2s_transfer_tx_data(struct i2s_uc_priv *pi2s_tx, void *data,
+ uint data_size);
/*
* Initialise i2s transmiter