You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@nuttx.apache.org by "eren-terzioglu (via GitHub)" <gi...@apache.org> on 2025/02/17 16:40:48 UTC
[PR] Feature/esp i2s support [nuttx]
eren-terzioglu opened a new pull request, #15852:
URL: https://github.com/apache/nuttx/pull/15852
## Summary
Add I2S support for RISC-V based esp devices
* esp32[c3|c6|h2]: Update common layer
* esp32[c3|c6|h2]: Add I2S support
* esp32[c3|c6|h2]: Add DMA function to have more capabilites
## Impact
ESP32-C3, ESP32-C6, ESP32-H2
## Testing
Used configs:
```
esp32c3-generic:i2schar
esp32c6-devkitc:i2schar
esp32h2-devkit:i2schar
```
After build step Dout (C6/C3: 18, H2: 10 default) and Din (C6/C3: 19, H2: 11 default) pins connected together via wire (or pointed to the same pin in menuconfig). After that `i2schar` command used to test it and expected output should be like this:
```
nsh> i2schar
i2schar_main: Start receiver thread
i2schar_read: buffer=0x40815678 buflen=57
i2s_receive: Prepared 5 bytes to receive DMA buffers
Recieved Audio pipeline buffer: (0x408156ac):
i2schar_read: buffer=0x408156b8 buflen=57
i2s_receive: Prepared 5 bytes to receive DMA buffers
Recieved Audio pipeline buffer: (0x408156ec):
i2schar_write: buffer=0x408134b8 buflen=57
i2s_tx_worker: tx.act.head=0 tx.done.head=0x4080bce0
i2schar_txcallback: apb=0x408134b8 nbytes=5 result=0
i2schar_txcallback: Freeing apb=0x408134b8 crefs=2
i2s_send: Queued 5 bytes into DMA buffers
Audio pipeline buffer: (0x408134ec):
0000 00 01 02 03 04 .....
i2schar_write: buffer=0x408134f8 buflen=57
i2s_tx_worker: tx.act.head=0 tx.done.head=0x4080bce0
i2schar_txcallback: apb=0x408134f8 nbytes=5 result=0
i2schar_txcallback: Freeing apb=0x408134f8 crefs=2
i2s_send: Queued 5 bytes into DMA buffers
Audio pipeline buffer: (0x4081352c):
0000 05 06 07 08 09 .....
i2schar_main: Start transmitter thread
i2schar_receiver: Received buffer 1
i2schar_receiver: Received buffer 2
i2schar_main: Waiting for the transmitter thread
i2schar_transmitter: Send buffer 1
i2schar_transmitter: Send buffer 2
i2schar_main: Waiting for the receiver thread
```
Note: Default pins for devices:
| Device/Pin | MCLK | BCLK | WS | DIN | DOUT |
|------------|------|------|----|-----|------|
| ESP32-C3 | 0 | 4 | 5 | 19 | 18 |
| ESP32-C6 | 0 | 4 | 5 | 19 | 18 |
| ESP32-H2 | 0 | 4 | 5 | 11 | 10 |
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@nuttx.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] I2S Support for RISC-V Based Espressif Devices [nuttx]
Posted by "nuttxpr (via GitHub)" <gi...@apache.org>.
nuttxpr commented on PR #15852:
URL: https://github.com/apache/nuttx/pull/15852#issuecomment-2663645659
[**\[Experimental Bot, please feedback here\]**](https://github.com/search?q=repo%3Aapache%2Fnuttx+13552&type=issues)
__Fill In The Commit Message:__ This PR contains a Commit with an Empty Commit Message. Please fill in the Commit Message with the PR Summary.
This PR summary does not fully meet the NuttX requirements. Here's a breakdown and suggested improvements:
**What's Missing/Needs Improvement:**
* **Summary:** While it mentions adding I2S support and DMA, it lacks crucial details:
* **Necessity:** *Why* is this change needed? Is there no I2S support currently? Are existing solutions inadequate? What benefits does this implementation bring (e.g., performance, features)?
* **Functional Change Description:** Be more specific. Which files were modified? Did you create new drivers? Were existing drivers extended? Mentioning "common layer" is too vague. What common layer?
* **How it works:** Explain the interaction between I2S, DMA, and the ESP32 hardware at a high level. What are the key data flow paths?
* **Issue References:** Link any related NuttX or NuttX Apps issues. This is essential for traceability.
* **Impact:** Listing ESP32-C3, ESP32-C6, and ESP32-H2 is insufficient. You must explicitly answer the impact questions with YES/NO and provide descriptions where necessary. For example:
* **New Feature?** YES (I2S support)
* **User Impact?** Potentially YES. If users want to use I2S, they will need to configure the driver and potentially write applications to utilize it. Explain how users interact with the new feature.
* **Build Impact?** Potentially YES. Will any new Kconfig options be introduced? Will users need to select new build configurations?
* **Hardware Impact?** YES. Clearly state the affected architectures (RISC-V), boards (esp32c3-generic, esp32c6-devkitc, esp32h2-devkit), and the drivers involved (I2S, DMA).
* **Documentation Impact?** YES. You *must* update the documentation to describe how to use the new I2S and DMA features. State that documentation is included in the PR.
* **Security Impact?** Consider potential security implications. Are there any new attack surfaces introduced by this feature? Even if the answer is NO, explicitly state it.
* **Compatibility Impact?** Does this break any existing functionality? Does it impact future development in any way?
* **Testing:**
* **Build Host(s):** Specify your build host details (OS, CPU architecture, compiler version).
* **Target(s):** While you listed the boards and configurations, be explicit about the architecture (RISC-V).
* **Testing Logs _Before_ Change:** You need to provide logs demonstrating the *lack* of I2S functionality before your changes. This shows that your changes actually address a gap.
* **Testing Logs _After_ Change:** The logs provided are a good start, but explain what each part demonstrates. For instance, mention that the loopback test shows data integrity. Consider adding logs showing different configurations or use cases.
**Revised Summary Example:**
This PR adds I2S support for the ESP32-C3, ESP32-C6, and ESP32-H2 RISC-V platforms in NuttX. Currently, these platforms lack I2S functionality. This implementation provides a new I2S driver leveraging the ESP32's DMA capabilities for efficient data transfer. The driver interacts with the `audio` framework and exposes a standard interface for applications to use. The `arch/riscv/src/esp32` directory contains the core driver implementation, and modifications were made to the common ESP32 HAL to support I2S initialization. This change is related to [NuttX Issue #XYZ] (if applicable).
**Revised Impact Example:**
* **New feature added?** YES (I2S support)
* **Impact on user?** YES. Users will need to configure the I2S driver using Kconfig options and utilize the provided APIs in their applications to access I2S functionality. Documentation is provided in this PR.
* **Impact on build?** YES. New Kconfig options are introduced to configure the I2S driver (e.g., DMA channel selection, clock settings). Users will need to select these options to enable I2S support for their target board.
* **Impact on hardware?** YES. This affects the RISC-V architecture, specifically the ESP32-C3, ESP32-C6, and ESP32-H2 boards. The I2S and DMA peripherals are utilized.
* **Impact on documentation?** YES. Documentation is included in this PR to describe the driver configuration and usage.
* **Impact on security?** NO. This implementation does not introduce any new security vulnerabilities.
* **Impact on compatibility?** NO. This change does not impact backward compatibility or introduce any known compatibility issues.
By providing more comprehensive information and addressing all the required points, you'll significantly improve the quality of your PR and make it easier for reviewers to understand and approve your changes. Remember to replace the placeholders like `[NuttX Issue #XYZ]` with actual issue numbers.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@nuttx.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] I2S Support for RISC-V Based Espressif Devices [nuttx]
Posted by "lupyuen (via GitHub)" <gi...@apache.org>.
lupyuen merged PR #15852:
URL: https://github.com/apache/nuttx/pull/15852
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@nuttx.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] I2S Support for RISC-V Based Espressif Devices [nuttx]
Posted by "tmedicci (via GitHub)" <gi...@apache.org>.
tmedicci commented on PR #15852:
URL: https://github.com/apache/nuttx/pull/15852#issuecomment-2674460320
Is anything else missing here? If not, can it be merged?
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@nuttx.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] I2S Support for RISC-V Based Espressif Devices [nuttx]
Posted by "acassis (via GitHub)" <gi...@apache.org>.
acassis commented on code in PR #15852:
URL: https://github.com/apache/nuttx/pull/15852#discussion_r1958679911
##########
arch/risc-v/src/common/espressif/Kconfig:
##########
@@ -1647,6 +1660,125 @@ endif # PWM_MULTICHAN && PWM_NCHANNELS > 1
endmenu # LEDC configuration
+menu "I2S Configuration"
+ depends on ESPRESSIF_I2S
+
+config ESPRESSIF_I2S_MAXINFLIGHT
+ int "I2S queue size"
+ default 4
+ ---help---
+ This is the total number of transfers, both RX and TX, that can be
+ enqueued before the caller is required to wait. This setting
+ determines the number certain queue data structures that will be
+ pre-allocated.
+
+if ESPRESSIF_I2S0
+
+config ESPRESSIF_I2S0_RX
+ bool "Enable I2S receiver"
+ default y
+ ---help---
+ Enable I2S receiver (port 0)
+
+config ESPRESSIF_I2S0_TX
+ bool "Enable I2S transmitter"
+ default y
+ ---help---
+ Enable I2S transmitter (port 0)
+
+choice ESPRESSIF_I2S0_ROLE
+ prompt "I2S0 role"
+ default ESPRESSIF_I2S0_ROLE_MASTER
+ ---help---
+ Selects the operation role of the I2S0.
+
+config ESPRESSIF_I2S0_ROLE_MASTER
+ bool "Master"
+
+config ESPRESSIF_I2S0_ROLE_SLAVE
+ bool "Slave"
+
+endchoice # I2S0 role
+
+choice ESPRESSIF_I2S0_DATA_BIT_WIDTH
+ prompt "Bit width"
+ default ESPRESSIF_I2S0_DATA_BIT_WIDTH_16BIT
+ ---help---
+ Selects the valid data bits per sample.
+ Note that this option may be overwritten by the audio
+ according to the bit width of the file being played
+
+config ESPRESSIF_I2S0_DATA_BIT_WIDTH_8BIT
+ bool "8 bits"
+
+config ESPRESSIF_I2S0_DATA_BIT_WIDTH_16BIT
+ bool "16 bits"
+
+config ESPRESSIF_I2S0_DATA_BIT_WIDTH_24BIT
+ bool "24 bits"
+
+config ESPRESSIF_I2S0_DATA_BIT_WIDTH_32BIT
+ bool "32 bits"
+
+endchoice # Bit width
+
+config ESPRESSIF_I2S0_SAMPLE_RATE
+ int "I2S0 sample rate"
+ default 44100
+ range 8000 48000
+ ---help---
+ Selects the sample rate.
+ Note that this option may be overwritten by the audio
+ according to the bit width of the file being played
+
+config ESPRESSIF_I2S0_BCLKPIN
+ int "I2S0 BCLK pin"
+ default 4
+ range 0 48
+
+config ESPRESSIF_I2S0_WSPIN
+ int "I2S0 WS pin"
+ default 5
+ range 0 48
+
+config ESPRESSIF_I2S0_DINPIN
+ int "I2S0 DIN pin"
+ depends on ESPRESSIF_I2S0_RX
+ default 19 if !ESPRESSIF_ESP32H2
+ default 11 if ESPRESSIF_ESP32H2
+ range 0 48
+
+config ESPRESSIF_I2S0_DOUTPIN
+ int "I2S0 DOUT pin"
+ depends on ESPRESSIF_I2S0_TX
+ default 18 if !ESPRESSIF_ESP32H2
+ default 10 if ESPRESSIF_ESP32H2
+ range 0 48
+
+config ESPRESSIF_I2S0_MCLK
+ bool "Enable I2S Master Clock"
+ depends on ESPRESSIF_I2S0_ROLE_MASTER
+ default n
+ ---help---
+ Enable I2S master clock
+
+config ESPRESSIF_I2S0_MCLKPIN
+ int "I2S MCLK pin"
+ depends on ESPRESSIF_I2S0_MCLK
+ default 0
+ range 0 48
+
+endif # ESPRESSIF_I2S0
+
+config I2S_DMADESC_NUM
+ int "I2S DMA maximum number of descriptors"
+ default 2
+ ---help---
+ Configure the maximum number of out-link/in-link descriptors to
+ be chained for a I2S DMA transfer.
Review Comment:
```suggestion
be chained for an I2S DMA transfer.
##########
boards/risc-v/esp32h2/common/src/esp_board_i2s.c:
##########
@@ -0,0 +1,204 @@
+/****************************************************************************
+ * boards/risc-v/esp32h2/common/src/esp_board_i2s.c
+ *
+ * SPDX-License-Identifier: Apache-2.0
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership. The
+ * ASF licenses this file to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance with the
+ * License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+ * License for the specific language governing permissions and limitations
+ * under the License.
+ *
+ ****************************************************************************/
+
+/****************************************************************************
+ * Included Files
+ ****************************************************************************/
+
+#include <nuttx/config.h>
+
+#include <debug.h>
+#include <errno.h>
+#include <sys/types.h>
+#include <stdio.h>
+
+#include <nuttx/audio/audio.h>
+#include <nuttx/audio/audio_i2s.h>
+#include <nuttx/audio/i2s.h>
+#include <nuttx/audio/pcm.h>
+
+#include <arch/board/board.h>
+
+#include "espressif/esp_i2s.h"
+
+/****************************************************************************
+ * Public Functions
+ ****************************************************************************/
+
+/****************************************************************************
+ * Name: board_i2sdev_initialize
+ *
+ * Description:
+ * This function is called by platform-specific, setup logic to configure
+ * and register the generic I2S audio driver. This function will register
+ * the driver as /dev/audio/pcm[x] where x is determined by the I2S port
+ * number.
+ *
+ * Input Parameters:
+ * port - The I2S port used for the device
+ * enable_tx - Register device as TX if true
+ * enable_rx - Register device as RX if true
+ *
+ * Returned Value:
+ * Zero is returned on success. Otherwise, a negated errno value is
+ * returned to indicate the nature of the failure.
+ *
+ ****************************************************************************/
+
+int board_i2sdev_initialize(int port, bool enable_tx, bool enable_rx)
+{
+ struct audio_lowerhalf_s *audio_i2s;
+ struct i2s_dev_s *i2s;
+ char devname[8];
+ int ret;
+
+ audinfo("Initializing I2S\n");
+
+ i2s = esp_i2sbus_initialize(port);
+
+#ifdef CONFIG_AUDIO_I2SCHAR
+ ret = i2schar_register(i2s, port);
+ if (ret < 0)
+ {
+ aerr("ERROR: i2schar_register failed: %d\n", ret);
+ return ret;
+ }
+#endif
+
+ if (enable_tx)
+ {
+ /* Initialize audio output */
+
+ audio_i2s = audio_i2s_initialize(i2s, true);
+
+ if (audio_i2s == NULL)
+ {
+ auderr("ERROR: Failed to initialize I2S audio output\n");
+ return -ENODEV;
+ }
+
+ snprintf(devname, sizeof(devname), "pcm%d", port);
+
+ /* If nxlooper is selected, the playback buffer is not rendered as
+ * a WAV file. Therefore, PCM decode will fail while processing such
+ * output buffer. In such a case, we bypass the PCM decode.
+ */
+
+#ifdef CONFIG_SYSTEM_NXLOOPER
+ ret = audio_register(devname, audio_i2s);
+#else
+ struct audio_lowerhalf_s *pcm;
+
+ pcm = pcm_decode_initialize(audio_i2s);
+
+ if (pcm == NULL)
+ {
+ auderr("ERROR: Failed create the PCM decoder\n");
+ return -ENODEV;
+ }
+
+ ret = audio_register(devname, pcm);
+#endif /* CONFIG_SYSTEM_NXLOOPER */
+
+ if (ret < 0)
+ {
+ auderr("ERROR: Failed to register /dev/%s device: %d\n",
+ devname, ret);
+ return ret;
+ }
+ }
+
+ if (enable_rx)
+ {
+ /* Initialize audio input */
+
+ audio_i2s = audio_i2s_initialize(i2s, false);
+
+ if (audio_i2s == NULL)
+ {
+ auderr("ERROR: Failed to initialize I2S audio input\n");
+ return -ENODEV;
+ }
+
+ snprintf(devname, sizeof(devname), "pcm_in%d", port);
+
+ ret = audio_register(devname, audio_i2s);
+
Review Comment:
Please remove empty line
##########
boards/risc-v/esp32c6/esp32c6-devkitc/src/esp32c6_bringup.c:
##########
@@ -270,6 +274,17 @@ int esp_bringup(void)
}
#endif
+#if defined(CONFIG_ESPRESSIF_I2S)
+ /* Configure I2S peripheral interfaces */
+
+ ret = board_i2s_init();
+
Review Comment:
please remove empty line
##########
boards/risc-v/esp32c3/common/src/esp_board_i2s.c:
##########
@@ -0,0 +1,204 @@
+/****************************************************************************
+ * boards/risc-v/esp32c3/common/src/esp_board_i2s.c
+ *
+ * SPDX-License-Identifier: Apache-2.0
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership. The
+ * ASF licenses this file to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance with the
+ * License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+ * License for the specific language governing permissions and limitations
+ * under the License.
+ *
+ ****************************************************************************/
+
+/****************************************************************************
+ * Included Files
+ ****************************************************************************/
+
+#include <nuttx/config.h>
+
+#include <debug.h>
+#include <errno.h>
+#include <sys/types.h>
+#include <stdio.h>
+
+#include <nuttx/audio/audio.h>
+#include <nuttx/audio/audio_i2s.h>
+#include <nuttx/audio/i2s.h>
+#include <nuttx/audio/pcm.h>
+
+#include <arch/board/board.h>
+
+#include "espressif/esp_i2s.h"
+
+/****************************************************************************
+ * Public Functions
+ ****************************************************************************/
+
+/****************************************************************************
+ * Name: board_i2sdev_initialize
+ *
+ * Description:
+ * This function is called by platform-specific, setup logic to configure
+ * and register the generic I2S audio driver. This function will register
+ * the driver as /dev/audio/pcm[x] where x is determined by the I2S port
+ * number.
+ *
+ * Input Parameters:
+ * port - The I2S port used for the device
+ * enable_tx - Register device as TX if true
+ * enable_rx - Register device as RX if true
+ *
+ * Returned Value:
+ * Zero is returned on success. Otherwise, a negated errno value is
+ * returned to indicate the nature of the failure.
+ *
+ ****************************************************************************/
+
+int board_i2sdev_initialize(int port, bool enable_tx, bool enable_rx)
+{
+ struct audio_lowerhalf_s *audio_i2s;
+ struct i2s_dev_s *i2s;
+ char devname[8];
+ int ret;
+
+ audinfo("Initializing I2S\n");
+
+ i2s = esp_i2sbus_initialize(port);
+
+#ifdef CONFIG_AUDIO_I2SCHAR
+ ret = i2schar_register(i2s, port);
+ if (ret < 0)
+ {
+ aerr("ERROR: i2schar_register failed: %d\n", ret);
+ return ret;
+ }
+#endif
+
+ if (enable_tx)
+ {
+ /* Initialize audio output */
+
+ audio_i2s = audio_i2s_initialize(i2s, true);
+
+ if (audio_i2s == NULL)
+ {
+ auderr("ERROR: Failed to initialize I2S audio output\n");
+ return -ENODEV;
+ }
+
+ snprintf(devname, sizeof(devname), "pcm%d", port);
+
+ /* If nxlooper is selected, the playback buffer is not rendered as
+ * a WAV file. Therefore, PCM decode will fail while processing such
+ * output buffer. In such a case, we bypass the PCM decode.
+ */
+
+#ifdef CONFIG_SYSTEM_NXLOOPER
+ ret = audio_register(devname, audio_i2s);
+#else
+ struct audio_lowerhalf_s *pcm;
+
+ pcm = pcm_decode_initialize(audio_i2s);
+
+ if (pcm == NULL)
+ {
+ auderr("ERROR: Failed create the PCM decoder\n");
+ return -ENODEV;
+ }
+
+ ret = audio_register(devname, pcm);
+#endif /* CONFIG_SYSTEM_NXLOOPER */
+
+ if (ret < 0)
+ {
+ auderr("ERROR: Failed to register /dev/%s device: %d\n",
+ devname, ret);
+ return ret;
+ }
+ }
+
+ if (enable_rx)
+ {
+ /* Initialize audio input */
+
+ audio_i2s = audio_i2s_initialize(i2s, false);
+
+ if (audio_i2s == NULL)
+ {
+ auderr("ERROR: Failed to initialize I2S audio input\n");
+ return -ENODEV;
+ }
+
+ snprintf(devname, sizeof(devname), "pcm_in%d", port);
+
+ ret = audio_register(devname, audio_i2s);
+
Review Comment:
please remove empty line
##########
boards/risc-v/esp32h2/common/src/esp_board_i2s.c:
##########
@@ -0,0 +1,204 @@
+/****************************************************************************
+ * boards/risc-v/esp32h2/common/src/esp_board_i2s.c
+ *
+ * SPDX-License-Identifier: Apache-2.0
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership. The
+ * ASF licenses this file to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance with the
+ * License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+ * License for the specific language governing permissions and limitations
+ * under the License.
+ *
+ ****************************************************************************/
+
+/****************************************************************************
+ * Included Files
+ ****************************************************************************/
+
+#include <nuttx/config.h>
+
+#include <debug.h>
+#include <errno.h>
+#include <sys/types.h>
+#include <stdio.h>
+
+#include <nuttx/audio/audio.h>
+#include <nuttx/audio/audio_i2s.h>
+#include <nuttx/audio/i2s.h>
+#include <nuttx/audio/pcm.h>
+
+#include <arch/board/board.h>
+
+#include "espressif/esp_i2s.h"
+
+/****************************************************************************
+ * Public Functions
+ ****************************************************************************/
+
+/****************************************************************************
+ * Name: board_i2sdev_initialize
+ *
+ * Description:
+ * This function is called by platform-specific, setup logic to configure
+ * and register the generic I2S audio driver. This function will register
+ * the driver as /dev/audio/pcm[x] where x is determined by the I2S port
+ * number.
+ *
+ * Input Parameters:
+ * port - The I2S port used for the device
+ * enable_tx - Register device as TX if true
+ * enable_rx - Register device as RX if true
+ *
+ * Returned Value:
+ * Zero is returned on success. Otherwise, a negated errno value is
+ * returned to indicate the nature of the failure.
+ *
+ ****************************************************************************/
+
+int board_i2sdev_initialize(int port, bool enable_tx, bool enable_rx)
+{
+ struct audio_lowerhalf_s *audio_i2s;
+ struct i2s_dev_s *i2s;
+ char devname[8];
+ int ret;
+
+ audinfo("Initializing I2S\n");
+
+ i2s = esp_i2sbus_initialize(port);
+
+#ifdef CONFIG_AUDIO_I2SCHAR
+ ret = i2schar_register(i2s, port);
+ if (ret < 0)
+ {
+ aerr("ERROR: i2schar_register failed: %d\n", ret);
+ return ret;
+ }
+#endif
+
+ if (enable_tx)
+ {
+ /* Initialize audio output */
+
+ audio_i2s = audio_i2s_initialize(i2s, true);
+
Review Comment:
please remove empty line
##########
boards/risc-v/esp32h2/esp32h2-devkit/src/esp32h2_bringup.c:
##########
@@ -264,6 +268,17 @@ int esp_bringup(void)
}
#endif
+#if defined(CONFIG_ESPRESSIF_I2S)
+ /* Configure I2S peripheral interfaces */
+
+ ret = board_i2s_init();
+
Review Comment:
please remove empty line
##########
boards/risc-v/esp32c6/common/src/esp_board_i2s.c:
##########
@@ -0,0 +1,204 @@
+/****************************************************************************
+ * boards/risc-v/esp32c6/common/src/esp_board_i2s.c
+ *
+ * SPDX-License-Identifier: Apache-2.0
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership. The
+ * ASF licenses this file to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance with the
+ * License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+ * License for the specific language governing permissions and limitations
+ * under the License.
+ *
+ ****************************************************************************/
+
+/****************************************************************************
+ * Included Files
+ ****************************************************************************/
+
+#include <nuttx/config.h>
+
+#include <debug.h>
+#include <errno.h>
+#include <sys/types.h>
+#include <stdio.h>
+
+#include <nuttx/audio/audio.h>
+#include <nuttx/audio/audio_i2s.h>
+#include <nuttx/audio/i2s.h>
+#include <nuttx/audio/pcm.h>
+
+#include <arch/board/board.h>
+
+#include "espressif/esp_i2s.h"
+
+/****************************************************************************
+ * Public Functions
+ ****************************************************************************/
+
+/****************************************************************************
+ * Name: board_i2sdev_initialize
+ *
+ * Description:
+ * This function is called by platform-specific, setup logic to configure
+ * and register the generic I2S audio driver. This function will register
+ * the driver as /dev/audio/pcm[x] where x is determined by the I2S port
+ * number.
+ *
+ * Input Parameters:
+ * port - The I2S port used for the device
+ * enable_tx - Register device as TX if true
+ * enable_rx - Register device as RX if true
+ *
+ * Returned Value:
+ * Zero is returned on success. Otherwise, a negated errno value is
+ * returned to indicate the nature of the failure.
+ *
+ ****************************************************************************/
+
+int board_i2sdev_initialize(int port, bool enable_tx, bool enable_rx)
+{
+ struct audio_lowerhalf_s *audio_i2s;
+ struct i2s_dev_s *i2s;
+ char devname[8];
+ int ret;
+
+ audinfo("Initializing I2S\n");
+
+ i2s = esp_i2sbus_initialize(port);
+
+#ifdef CONFIG_AUDIO_I2SCHAR
+ ret = i2schar_register(i2s, port);
+ if (ret < 0)
+ {
+ aerr("ERROR: i2schar_register failed: %d\n", ret);
+ return ret;
+ }
+#endif
+
+ if (enable_tx)
+ {
+ /* Initialize audio output */
+
+ audio_i2s = audio_i2s_initialize(i2s, true);
+
Review Comment:
please remove empty line, they are part of same logic, testing the returned variable
##########
boards/risc-v/esp32c6/esp32c6-devkitm/src/esp32c6_bringup.c:
##########
@@ -266,6 +270,17 @@ int esp_bringup(void)
}
#endif
+#if defined(CONFIG_ESPRESSIF_I2S)
+ /* Configure I2S peripheral interfaces */
+
+ ret = board_i2s_init();
+
Review Comment:
please remove empty line
##########
boards/risc-v/esp32c3/esp32c3-generic/src/esp32c3_bringup.c:
##########
@@ -317,6 +321,17 @@ int esp_bringup(void)
}
#endif
+#if defined(CONFIG_ESPRESSIF_I2S)
+ /* Configure I2S peripheral interfaces */
+
+ ret = board_i2s_init();
+
Review Comment:
please remove empty line
##########
boards/risc-v/esp32c6/common/src/esp_board_i2s.c:
##########
@@ -0,0 +1,204 @@
+/****************************************************************************
+ * boards/risc-v/esp32c6/common/src/esp_board_i2s.c
+ *
+ * SPDX-License-Identifier: Apache-2.0
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership. The
+ * ASF licenses this file to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance with the
+ * License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+ * License for the specific language governing permissions and limitations
+ * under the License.
+ *
+ ****************************************************************************/
+
+/****************************************************************************
+ * Included Files
+ ****************************************************************************/
+
+#include <nuttx/config.h>
+
+#include <debug.h>
+#include <errno.h>
+#include <sys/types.h>
+#include <stdio.h>
+
+#include <nuttx/audio/audio.h>
+#include <nuttx/audio/audio_i2s.h>
+#include <nuttx/audio/i2s.h>
+#include <nuttx/audio/pcm.h>
+
+#include <arch/board/board.h>
+
+#include "espressif/esp_i2s.h"
+
+/****************************************************************************
+ * Public Functions
+ ****************************************************************************/
+
+/****************************************************************************
+ * Name: board_i2sdev_initialize
+ *
+ * Description:
+ * This function is called by platform-specific, setup logic to configure
+ * and register the generic I2S audio driver. This function will register
+ * the driver as /dev/audio/pcm[x] where x is determined by the I2S port
+ * number.
+ *
+ * Input Parameters:
+ * port - The I2S port used for the device
+ * enable_tx - Register device as TX if true
+ * enable_rx - Register device as RX if true
+ *
+ * Returned Value:
+ * Zero is returned on success. Otherwise, a negated errno value is
+ * returned to indicate the nature of the failure.
+ *
+ ****************************************************************************/
+
+int board_i2sdev_initialize(int port, bool enable_tx, bool enable_rx)
+{
+ struct audio_lowerhalf_s *audio_i2s;
+ struct i2s_dev_s *i2s;
+ char devname[8];
+ int ret;
+
+ audinfo("Initializing I2S\n");
+
+ i2s = esp_i2sbus_initialize(port);
+
+#ifdef CONFIG_AUDIO_I2SCHAR
+ ret = i2schar_register(i2s, port);
+ if (ret < 0)
+ {
+ aerr("ERROR: i2schar_register failed: %d\n", ret);
+ return ret;
+ }
+#endif
+
+ if (enable_tx)
+ {
+ /* Initialize audio output */
+
+ audio_i2s = audio_i2s_initialize(i2s, true);
+
+ if (audio_i2s == NULL)
+ {
+ auderr("ERROR: Failed to initialize I2S audio output\n");
+ return -ENODEV;
+ }
+
+ snprintf(devname, sizeof(devname), "pcm%d", port);
+
+ /* If nxlooper is selected, the playback buffer is not rendered as
+ * a WAV file. Therefore, PCM decode will fail while processing such
+ * output buffer. In such a case, we bypass the PCM decode.
+ */
+
+#ifdef CONFIG_SYSTEM_NXLOOPER
+ ret = audio_register(devname, audio_i2s);
+#else
+ struct audio_lowerhalf_s *pcm;
+
+ pcm = pcm_decode_initialize(audio_i2s);
+
+ if (pcm == NULL)
+ {
+ auderr("ERROR: Failed create the PCM decoder\n");
+ return -ENODEV;
+ }
+
+ ret = audio_register(devname, pcm);
+#endif /* CONFIG_SYSTEM_NXLOOPER */
+
+ if (ret < 0)
+ {
+ auderr("ERROR: Failed to register /dev/%s device: %d\n",
+ devname, ret);
+ return ret;
+ }
+ }
+
+ if (enable_rx)
+ {
+ /* Initialize audio input */
+
+ audio_i2s = audio_i2s_initialize(i2s, false);
+
+ if (audio_i2s == NULL)
+ {
+ auderr("ERROR: Failed to initialize I2S audio input\n");
+ return -ENODEV;
+ }
+
+ snprintf(devname, sizeof(devname), "pcm_in%d", port);
+
+ ret = audio_register(devname, audio_i2s);
+
Review Comment:
please remove empty line
##########
boards/risc-v/esp32c3/common/src/esp_board_i2s.c:
##########
@@ -0,0 +1,204 @@
+/****************************************************************************
+ * boards/risc-v/esp32c3/common/src/esp_board_i2s.c
+ *
+ * SPDX-License-Identifier: Apache-2.0
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership. The
+ * ASF licenses this file to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance with the
+ * License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+ * License for the specific language governing permissions and limitations
+ * under the License.
+ *
+ ****************************************************************************/
+
+/****************************************************************************
+ * Included Files
+ ****************************************************************************/
+
+#include <nuttx/config.h>
+
+#include <debug.h>
+#include <errno.h>
+#include <sys/types.h>
+#include <stdio.h>
+
+#include <nuttx/audio/audio.h>
+#include <nuttx/audio/audio_i2s.h>
+#include <nuttx/audio/i2s.h>
+#include <nuttx/audio/pcm.h>
+
+#include <arch/board/board.h>
+
+#include "espressif/esp_i2s.h"
+
+/****************************************************************************
+ * Public Functions
+ ****************************************************************************/
+
+/****************************************************************************
+ * Name: board_i2sdev_initialize
+ *
+ * Description:
+ * This function is called by platform-specific, setup logic to configure
+ * and register the generic I2S audio driver. This function will register
+ * the driver as /dev/audio/pcm[x] where x is determined by the I2S port
+ * number.
+ *
+ * Input Parameters:
+ * port - The I2S port used for the device
+ * enable_tx - Register device as TX if true
+ * enable_rx - Register device as RX if true
+ *
+ * Returned Value:
+ * Zero is returned on success. Otherwise, a negated errno value is
+ * returned to indicate the nature of the failure.
+ *
+ ****************************************************************************/
+
+int board_i2sdev_initialize(int port, bool enable_tx, bool enable_rx)
+{
+ struct audio_lowerhalf_s *audio_i2s;
+ struct i2s_dev_s *i2s;
+ char devname[8];
+ int ret;
+
+ audinfo("Initializing I2S\n");
+
+ i2s = esp_i2sbus_initialize(port);
+
+#ifdef CONFIG_AUDIO_I2SCHAR
+ ret = i2schar_register(i2s, port);
+ if (ret < 0)
+ {
+ aerr("ERROR: i2schar_register failed: %d\n", ret);
+ return ret;
+ }
+#endif
+
+ if (enable_tx)
+ {
+ /* Initialize audio output */
+
+ audio_i2s = audio_i2s_initialize(i2s, true);
+
+ if (audio_i2s == NULL)
+ {
+ auderr("ERROR: Failed to initialize I2S audio output\n");
+ return -ENODEV;
+ }
+
+ snprintf(devname, sizeof(devname), "pcm%d", port);
+
+ /* If nxlooper is selected, the playback buffer is not rendered as
+ * a WAV file. Therefore, PCM decode will fail while processing such
+ * output buffer. In such a case, we bypass the PCM decode.
+ */
+
+#ifdef CONFIG_SYSTEM_NXLOOPER
+ ret = audio_register(devname, audio_i2s);
+#else
+ struct audio_lowerhalf_s *pcm;
+
+ pcm = pcm_decode_initialize(audio_i2s);
+
Review Comment:
please remove empty line
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@nuttx.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] I2S Support for RISC-V Based Espressif Devices [nuttx]
Posted by "eren-terzioglu (via GitHub)" <gi...@apache.org>.
eren-terzioglu commented on PR #15852:
URL: https://github.com/apache/nuttx/pull/15852#issuecomment-2671644993
> @eren-terzioglu Please remember to fill in the Commit Description, and sign-off each commit: `git commit -s`. Thanks :-)
>
> * [a6169b4](https://github.com/apache/nuttx/commit/a6169b433f3ef4e00aca8ab010372c674330a6a4)
> * [7c30681](https://github.com/apache/nuttx/commit/7c306811cfd15b8fd346861364d52da0bcb7bcf9)
> * [860b7c6](https://github.com/apache/nuttx/commit/860b7c6213d0f929bd565f531963930ae648eefa)
Thanks, updated.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@nuttx.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] I2S Support for RISC-V Based Espressif Devices [nuttx]
Posted by "eren-terzioglu (via GitHub)" <gi...@apache.org>.
eren-terzioglu commented on PR #15852:
URL: https://github.com/apache/nuttx/pull/15852#issuecomment-2665976671
Thanks @acassis, updated
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@nuttx.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] I2S Support for RISC-V Based Espressif Devices [nuttx]
Posted by "lupyuen (via GitHub)" <gi...@apache.org>.
lupyuen commented on PR #15852:
URL: https://github.com/apache/nuttx/pull/15852#issuecomment-2671616430
@eren-terzioglu Please remember to fill in the Commit Description, and sign-off each commit: `git commit -s`. Thanks :-)
- https://github.com/apache/nuttx/pull/15852/commits/a6169b433f3ef4e00aca8ab010372c674330a6a4
- https://github.com/apache/nuttx/pull/15852/commits/7c306811cfd15b8fd346861364d52da0bcb7bcf9
- https://github.com/apache/nuttx/pull/15852/commits/860b7c6213d0f929bd565f531963930ae648eefa
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@nuttx.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org