Skip to content

I2S API should support hardware that is enforcing specific physical width of the RX/TX data samples #34303

@mnkp

Description

@mnkp

During the development of the I2S driver for NXP LPC devices #32054 it was identified that the design of I2S API does not match well hardware limitations imposed by the platform.

When the user sends data to the I2S driver they are placed in one large buffer and passed to the driver via i2s_write system call. So far the I2S API assumed that the data are always packed in an optimum way. E.g. an 8-bit sample will require one byte of storage. That is, to send 16 8-bit samples we will need a buffer of size 16. However, the NXP LPC device is not able to cope with such data. Its DMA engine can do 32-bit transfers only. It can transfer one 32-bit sample or two 16-bit samples at minimum. To support such case each 8-bit data sample in the buffer passed to i2s_write system call would need to occupy 2 bytes.

One possible solution would be to let the application determine the physical size of a single data sample expected by the driver via a new function call. ALSA library has snd_pcm_format_physical_width() which lets the application figure out the sizeof single data sample.

Alternatively we would need to add an extra configuration parameter telling the driver the format that the data is provided in. Or handle such cases via a dedicated driver specific read/write functions.

The initial discussion related to this issue took place in #32054.

API meeting 2021.03.23:

  • No firm conclusion, though options would be:
  • Add a format parameter of sorts to the config function, or a function that returns the required sample size in bytes
  • Treat the read/write functions in this driver as device-specific and so add i2s_lpc_read/write
  • Reach out to the SoF folks to try and see how common this occurrence may be: cc @lgirdwood and @lyakh and @marc-hb: is it common that i2s peripherals require data in formats that do not match the output I2S stream?

Originally posted by @carlescufi in #32054 (comment)

Metadata

Metadata

Assignees

Labels

EnhancementChanges/Updates/Additions to existing featuresarea: I2S

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions