Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

I2S output left/right channels swapped (IDFGH-1078) #3399

Closed
redchenjs opened this issue May 1, 2019 · 2 comments
Closed

I2S output left/right channels swapped (IDFGH-1078) #3399

redchenjs opened this issue May 1, 2019 · 2 comments

Comments

@redchenjs
Copy link
Contributor

redchenjs commented May 1, 2019

Environment

  • Development Kit: Widora AIR v6.0
  • Module or chip used: ESP32 Rev.1
  • IDF version: v3.2
  • Build System: CMake
  • Compiler version: 1.22.0-80-g6c4433a
  • Operating System: Linux
  • Power Supply: USB

Problem Description

When ESP32 is used for A2DP streaming, the I2S output left/right channels are swapped.

When playing left channel only audio, the LA output is:

left

When playing right channel only audio, the LA output is:

right

The expected left/right channel behavior according to TRM:

trm

Steps to repropduce

  1. Get the a2dp_sink example from esp-idf v3.2.
  2. Build the example and flash it to esp32.
  3. Connect to esp32 with your phone and play the test files.
    test_files.zip

Code to reproduce this issue

The a2dp_sink example from esp-idf v3.2

@github-actions github-actions bot changed the title A2DP sink output left/right channel swapped A2DP sink output left/right channel swapped (IDFGH-1078) May 1, 2019
@redchenjs
Copy link
Contributor Author

Well, the a2d_data_cb() is just a wrapper for i2s_write(), so the problem might be SBC decoding output:

void bt_app_a2d_data_cb(const uint8_t *data, uint32_t len)
{
    size_t bytes_written;
    i2s_write(0, data, len, &bytes_written, portMAX_DELAY);
    if (++s_pkt_cnt % 100 == 0) {
        ESP_LOGI(BT_AV_TAG, "Audio packet count %u", s_pkt_cnt);
    }
}

redchenjs added a commit to redchenjs/esp-idf that referenced this issue May 1, 2019
Modify the SBC SynthFrame output pointer to swap the channel data output.
@redchenjs redchenjs changed the title A2DP sink output left/right channel swapped (IDFGH-1078) A2DP sink output left/right channels swapped (IDFGH-1078) May 1, 2019
@blueMoodBHD
Copy link
Collaborator

Hi @redchenjs, We have do some test, and the PCM decoded by the SBC actually has the correct left and right channel order.
And the problem appear on the I2S side, our Drvier code defaults to the left channel in the high position, only need to set I2S_CONF_REG (0x0008) when I2S configuration the I2S_TX_MSB_RIGHT bit of the register, L/R, can be flipped over.

@redchenjs redchenjs changed the title A2DP sink output left/right channels swapped (IDFGH-1078) I2S output left/right channels swapped (IDFGH-1078) May 13, 2019
redchenjs added a commit to redchenjs/esp-idf that referenced this issue Jul 1, 2019
The right channel data is in the high position, so the I2S_TX_MSB_RIGHT & I2S_RX_MSB_RIGHT bits should be set.
@igrr igrr closed this as completed in ff325e8 Aug 5, 2019
trombik pushed a commit to trombik/esp-idf that referenced this issue Aug 9, 2019
The right channel data is in the high position, so the I2S_TX_MSB_RIGHT & I2S_RX_MSB_RIGHT bits should be set.

Merges espressif#3717

closes espressif#3399
andySigler added a commit to oda-inc/esp-idf that referenced this issue Apr 15, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants