/****************************************************************************
* Pre-processor Definitions
****************************************************************************/
-#define s5j_dmasetup(a, b) if ((b)->setup) { (b)->setup(a, b) };
+#define s5j_dmasetup(a, b) \
+do { \
+ if ((b)->setup) { \
+ (b)->setup(a, b); \
+ } \
+} while (0)
/************************************************************************************
* Public Types
}
/* Call s5j_i2s_initialize() to get an instance of the I2S interface */
- i2s = s5j_i2s_initialize();
+ i2s = s5j_i2s_initialize(0);
if (!i2s) {
auddbg("ERROR: Failed to get the S5J I2S driver\n");
return -ENODEV;
if (!initialized) {
/* Call s5j_i2s_initialize() to get an instance of the I2S interface */
- i2s = s5j_i2s_initialize();
+ i2s = s5j_i2s_initialize(0);
if (!i2s) {
auddbg("ERROR: Failed to get the S5J I2S driver\n");
return -ENODEV;
#error CONFIG_AUDIO required by this driver
#endif
+#define S5J_I2S_MAXPORTS 1
+
#ifndef CONFIG_S5J_I2S_MAXINFLIGHT
#define CONFIG_S5J_I2S_MAXINFLIGHT 16
#endif
.i2s_send = i2s_send,
};
+static struct s5j_i2s_s *g_i2sdevice[S5J_I2S_MAXPORTS];
+
/****************************************************************************
* Public Data
****************************************************************************/
*
****************************************************************************/
-struct i2s_dev_s *s5j_i2s_initialize(void)
+struct i2s_dev_s *s5j_i2s_initialize(uint16_t port)
{
+ if (port >= S5J_I2S_MAXPORTS) {
+ lldbg("ERROR: Port number outside the allowed port number range\n");
+ return NULL;
+ }
+ if (g_i2sdevice[port] != NULL) {
+ return &g_i2sdevice[port]->dev;
+ }
+
struct s5j_i2s_s *priv;
int ret;
irq_attach(priv->isr_num, priv->isr_handler, priv);
up_enable_irq(priv->isr_num);
+ g_i2sdevice[port] = priv;
+
/* Success exit */
return &priv->dev;
*
****************************************************************************/
-FAR struct i2s_dev_s *s5j_i2s_initialize(void);
+FAR struct i2s_dev_s *s5j_i2s_initialize(uint16_t port);
#undef EXTERN
#if defined(__cplusplus)