12#ifndef ZEPHYR_INCLUDE_DRIVERS_I2S_H_
13#define ZEPHYR_INCLUDE_DRIVERS_I2S_H_
43#define I2S_FMT_DATA_FORMAT_SHIFT 0
45#define I2S_FMT_DATA_FORMAT_MASK (0x7 << I2S_FMT_DATA_FORMAT_SHIFT)
64#define I2S_FMT_DATA_FORMAT_I2S (0 << I2S_FMT_DATA_FORMAT_SHIFT)
83#define I2S_FMT_DATA_FORMAT_PCM_SHORT (1 << I2S_FMT_DATA_FORMAT_SHIFT)
103#define I2S_FMT_DATA_FORMAT_PCM_LONG (2 << I2S_FMT_DATA_FORMAT_SHIFT)
124#define I2S_FMT_DATA_FORMAT_LEFT_JUSTIFIED (3 << I2S_FMT_DATA_FORMAT_SHIFT)
145#define I2S_FMT_DATA_FORMAT_RIGHT_JUSTIFIED (4 << I2S_FMT_DATA_FORMAT_SHIFT)
148#define I2S_FMT_DATA_ORDER_MSB (0 << 3)
150#define I2S_FMT_DATA_ORDER_LSB BIT(3)
152#define I2S_FMT_DATA_ORDER_INV I2S_FMT_DATA_ORDER_LSB
155#define I2S_FMT_CLK_FORMAT_SHIFT 4
157#define I2S_FMT_CLK_FORMAT_MASK (0x3 << I2S_FMT_CLK_FORMAT_SHIFT)
160#define I2S_FMT_BIT_CLK_INV BIT(4)
162#define I2S_FMT_FRAME_CLK_INV BIT(5)
165#define I2S_FMT_CLK_NF_NB (0 << I2S_FMT_CLK_FORMAT_SHIFT)
167#define I2S_FMT_CLK_NF_IB (1 << I2S_FMT_CLK_FORMAT_SHIFT)
169#define I2S_FMT_CLK_IF_NB (2 << I2S_FMT_CLK_FORMAT_SHIFT)
171#define I2S_FMT_CLK_IF_IB (3 << I2S_FMT_CLK_FORMAT_SHIFT)
177#define I2S_OPT_BIT_CLK_CONT (0 << 0)
179#define I2S_OPT_BIT_CLK_GATED BIT(0)
181#define I2S_OPT_BIT_CLK_MASTER (0 << 1)
183#define I2S_OPT_BIT_CLK_SLAVE BIT(1)
185#define I2S_OPT_FRAME_CLK_MASTER (0 << 2)
187#define I2S_OPT_FRAME_CLK_SLAVE BIT(2)
194#define I2S_OPT_LOOPBACK BIT(7)
204#define I2S_OPT_PINGPONG BIT(6)
321__subsystem
struct i2s_driver_api {
326 int (*read)(
const struct device *dev,
void **mem_block,
size_t *size);
327 int (*write)(
const struct device *dev,
void *mem_block,
size_t size);
360static inline int z_impl_i2s_configure(
const struct device *dev,
364 const struct i2s_driver_api *api =
365 (
const struct i2s_driver_api *)dev->
api;
367 return api->configure(dev, dir, cfg);
381 const struct i2s_driver_api *api =
382 (
const struct i2s_driver_api *)dev->
api;
384 return api->config_get(dev, dir);
421 const struct i2s_driver_api *api =
422 (
const struct i2s_driver_api *)dev->
api;
424 return api->read(dev, mem_block, size);
482 const struct i2s_driver_api *api =
483 (
const struct i2s_driver_api *)dev->
api;
485 return api->write(dev, mem_block, size);
529static inline int z_impl_i2s_trigger(
const struct device *dev,
533 const struct i2s_driver_api *api =
534 (
const struct i2s_driver_api *)dev->
api;
536 return api->trigger(dev, dir,
cmd);
547#include <zephyr/syscalls/i2s.h>
static void cmd(uint32_t command)
Execute a display list command by co-processor engine.
Definition ft8xx_reference_api.h:153
static int i2s_write(const struct device *dev, void *mem_block, size_t size)
Write data to the TX queue.
Definition i2s.h:479
uint8_t i2s_fmt_t
I2S data stream format options.
Definition i2s.h:40
int i2s_configure(const struct device *dev, enum i2s_dir dir, const struct i2s_config *cfg)
Configure operation of a host I2S controller.
int i2s_buf_read(const struct device *dev, void *buf, size_t *size)
Read data from the RX queue into a provided buffer.
static int i2s_read(const struct device *dev, void **mem_block, size_t *size)
Read data from the RX queue.
Definition i2s.h:418
i2s_dir
I2C Direction.
Definition i2s.h:209
i2s_state
Interface state.
Definition i2s.h:219
int i2s_buf_write(const struct device *dev, void *buf, size_t size)
Write data to the TX queue from a provided buffer.
int i2s_trigger(const struct device *dev, enum i2s_dir dir, enum i2s_trigger_cmd cmd)
Send a trigger command.
i2s_trigger_cmd
Trigger command.
Definition i2s.h:238
static const struct i2s_config * i2s_config_get(const struct device *dev, enum i2s_dir dir)
Fetch configuration information of a host I2S controller.
Definition i2s.h:378
uint8_t i2s_opt_t
I2S configuration options.
Definition i2s.h:174
@ I2S_DIR_BOTH
Both receive and transmit data.
Definition i2s.h:215
@ I2S_DIR_TX
Transmit data.
Definition i2s.h:213
@ I2S_DIR_RX
Receive data.
Definition i2s.h:211
@ I2S_STATE_ERROR
TX buffer underrun or RX buffer overrun has occurred.
Definition i2s.h:234
@ I2S_STATE_NOT_READY
The interface is not ready.
Definition i2s.h:226
@ I2S_STATE_STOPPING
The interface is draining its transmit queue.
Definition i2s.h:232
@ I2S_STATE_RUNNING
The interface is receiving / transmitting data.
Definition i2s.h:230
@ I2S_STATE_READY
The interface is ready to receive / transmit data.
Definition i2s.h:228
@ I2S_TRIGGER_STOP
Stop the transmission / reception of data.
Definition i2s.h:255
@ I2S_TRIGGER_PREPARE
Prepare the queues after underrun/overrun error has occurred.
Definition i2s.h:277
@ I2S_TRIGGER_START
Start the transmission / reception of data.
Definition i2s.h:245
@ I2S_TRIGGER_DRAIN
Empty the transmit queue.
Definition i2s.h:264
@ I2S_TRIGGER_DROP
Discard the transmit / receive queue.
Definition i2s.h:271
__UINT32_TYPE__ uint32_t
Definition stdint.h:90
__INT32_TYPE__ int32_t
Definition stdint.h:74
__UINT8_TYPE__ uint8_t
Definition stdint.h:88
Runtime device structure (in ROM) per driver instance.
Definition device.h:412
const void * api
Address of the API structure exposed by the device instance.
Definition device.h:418
Interface configuration options.
Definition i2s.h:295
struct k_mem_slab * mem_slab
Memory slab to store RX/TX data.
Definition i2s.h:307
i2s_opt_t options
Configuration options as defined by I2S_OPT_* constants.
Definition i2s.h:303
uint8_t word_size
Number of bits representing one data word.
Definition i2s.h:297
size_t block_size
Size of one RX/TX memory block (buffer) in bytes.
Definition i2s.h:309
i2s_fmt_t format
Data stream format as defined by I2S_FMT_* constants.
Definition i2s.h:301
int32_t timeout
Read/Write timeout.
Definition i2s.h:313
uint32_t frame_clk_freq
Frame clock (WS) frequency, this is sampling rate.
Definition i2s.h:305
uint8_t channels
Number of words per frame.
Definition i2s.h:299