@geastack/targets 0.1.86 → 0.1.87

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@geastack/targets",
3
- "version": "0.1.86",
3
+ "version": "0.1.87",
4
4
  "description": "Native embedded build targets (ESP32-IDF, RP2350) for geastack apps: board sources, target catalog, and CMake glue driven by the gea CLI.",
5
5
  "license": "GPL-3.0-only",
6
6
  "repository": {
@@ -33,6 +33,16 @@ static_assert(GEA_AUDIO_FULL_DUPLEX == 0 || GEA_AUDIO_FULL_DUPLEX == 1);
33
33
  // Capture is raw microphone PCM. Full duplex does not imply acoustic echo
34
34
  // cancellation; the application must supply any required echo processing.
35
35
 
36
+ // Applications with a continuous low-latency source can use smaller DMA queues.
37
+ #ifndef GEA_AUDIO_DMA_DESCRIPTORS
38
+ #define GEA_AUDIO_DMA_DESCRIPTORS 6
39
+ #endif
40
+ #ifndef GEA_AUDIO_DMA_FRAMES
41
+ #define GEA_AUDIO_DMA_FRAMES 240
42
+ #endif
43
+ static_assert(GEA_AUDIO_DMA_DESCRIPTORS >= 2);
44
+ static_assert(GEA_AUDIO_DMA_FRAMES >= 8 && GEA_AUDIO_DMA_FRAMES <= 511);
45
+
36
46
  namespace gea::platform::esp32::chip_bindings::es8311 {
37
47
 
38
48
  // IDF 6.0: i2s_port_t is gone; i2s_chan_config_t.id (and I2S_CHANNEL_DEFAULT_CONFIG) take a plain int.
@@ -189,6 +199,9 @@ private:
189
199
 
190
200
  void applySpeakerVolumeLocked() {
191
201
  if (!speakerCodec_) return;
202
+ #if GEA_BOARD_SPEAKER_POWER
203
+ gea::platform::board::setSpeakerPower(speakerVolume_ > 0);
204
+ #endif
192
205
  if (kPaPin != GPIO_NUM_NC) gpio_set_level(kPaPin, 1);
193
206
  const int codecVolume = codecVolumeFromUserPercent(speakerVolume_);
194
207
  const int err = esp_codec_dev_set_out_vol(speakerCodec_, codecVolume);
@@ -202,6 +215,9 @@ private:
202
215
  esp_codec_dev_close(speakerCodec_);
203
216
  i2sChannelEnabled_ = false;
204
217
  }
218
+ #if GEA_BOARD_SPEAKER_POWER
219
+ gea::platform::board::setSpeakerPower(false);
220
+ #endif
205
221
  if (kPaPin != GPIO_NUM_NC) gpio_set_level(kPaPin, 0);
206
222
  speakerOpen_ = false;
207
223
  speakerSampleRate_ = 0;
@@ -280,19 +296,19 @@ private:
280
296
  // mic samples (recording plays back "sped up"); on TX any scheduling jitter
281
297
  // starves the codec and the playback clicks/underruns. Six descriptors give
282
298
  // the headroom that makes pala_note's record/playback smooth on this codec.
283
- channelConfig.dma_desc_num = 6;
284
- channelConfig.dma_frame_num = 240;
299
+ channelConfig.dma_desc_num = GEA_AUDIO_DMA_DESCRIPTORS;
300
+ channelConfig.dma_frame_num = GEA_AUDIO_DMA_FRAMES;
285
301
  esp_err_t err = i2s_new_channel(&channelConfig, &txChannel_, &rxChannel_);
286
302
  if (err != ESP_OK) {
287
303
  ESP_LOGE(kTag, "I2S channel creation failed: %s", esp_err_to_name(err));
288
304
  return err;
289
305
  }
290
306
 
291
- // esp_codec_dev_open() reconfigures each channel's slots to Philips I2S (the format the ES8311 and
292
- // ES7210 use) before any data moves, so this initial slot format is only a placeholder.
307
+ // Start with the codec's actual 16-bit stereo slots. A 32-bit placeholder
308
+ // doubles DMA storage and forces allocation again during codec open.
293
309
  i2s_std_config_t stdConfig = {};
294
310
  stdConfig.clk_cfg = I2S_STD_CLK_DEFAULT_CONFIG(static_cast<std::uint32_t>(sampleRate));
295
- stdConfig.slot_cfg = I2S_STD_MSB_SLOT_DEFAULT_CONFIG(I2S_DATA_BIT_WIDTH_32BIT, I2S_SLOT_MODE_STEREO);
311
+ stdConfig.slot_cfg = I2S_STD_PHILIPS_SLOT_DEFAULT_CONFIG(I2S_DATA_BIT_WIDTH_16BIT, I2S_SLOT_MODE_STEREO);
296
312
  stdConfig.gpio_cfg.mclk = kMclkPin;
297
313
  stdConfig.gpio_cfg.bclk = kBclkPin;
298
314
  stdConfig.gpio_cfg.ws = kWsPin;
@@ -428,6 +444,9 @@ private:
428
444
  gpio_set_level(kPaPin, 1);
429
445
  }
430
446
 
447
+ #if GEA_BOARD_SPEAKER_POWER
448
+ if (!gea::platform::board::setSpeakerPower(speakerVolume_ > 0)) return ESP_FAIL;
449
+ #endif
431
450
  if (!codecIf_) {
432
451
  auto i2cBus = gea::platform::i2c::Bus::primary();
433
452
  if (!i2cBus.available()) {
@@ -575,7 +575,7 @@ if(NOT GEA_APP_CANVAS_ONLY)
575
575
  "${GEA_HOST}/audio_runtime.cpp"
576
576
  )
577
577
  list(APPEND GEA_EMBEDDED_TARGET_REQUIRES esp_driver_i2s esp_codec_dev)
578
- list(APPEND GEA_EMBEDDED_CAPABILITY_COMPILE_DEFINITIONS GEA_EMBEDDED_APP_USES_AUDIO=1)
578
+ list(APPEND GEA_EMBEDDED_CAPABILITY_COMPILE_DEFINITIONS GEA_EMBEDDED_APP_USES_AUDIO=1 GEA_BOARD_HAS_SPEAKER=1)
579
579
  else()
580
580
  list(APPEND GEA_EMBEDDED_TARGET_HOST_SOURCES
581
581
  "${GEA_EMBEDDED_ROOT}/targets/esp32/services/audio_runtime_stub.cpp"
@@ -9,6 +9,16 @@ dependencies:
9
9
  registry_url: https://components.espressif.com
10
10
  type: service
11
11
  version: 0.5.3
12
+ espressif/esp_codec_dev:
13
+ component_hash: 4779f31a3ba3f9b38aee1afe6ccb9ba8f6108dc3a6e77d39d7d714e9a215371b
14
+ dependencies:
15
+ - name: idf
16
+ require: private
17
+ version: '>=4.0'
18
+ source:
19
+ registry_url: https://components.espressif.com/
20
+ type: service
21
+ version: 1.6.2
12
22
  espressif/esp_lcd_axs15231b:
13
23
  component_hash: 62afe3c46789d7a13e3807c5d7a3a734870cd6375a28f14b12498c3382ad43b4
14
24
  dependencies:
@@ -42,8 +52,9 @@ dependencies:
42
52
  type: idf
43
53
  version: 6.0.2
44
54
  direct_dependencies:
55
+ - espressif/esp_codec_dev
45
56
  - espressif/esp_lcd_axs15231b
46
57
  - idf
47
- manifest_hash: cfad2492c50218eed0e2358c2025bb905712d957d84a725ee1d97a28672a0bf0
58
+ manifest_hash: 012cbd8ec7ab85135fe0eb3ac425f4397eac4030eb43783e48c375d3d0ef7868
48
59
  target: esp32s3
49
60
  version: 3.0.0
@@ -12,12 +12,14 @@ set(GEA_BOARD_FRAMEBUFFER_STREAM_FLUSH 1)
12
12
  set(GEA_BOARD_PARTIAL_PAD_X 0)
13
13
  set(GEA_BOARD_PARTIAL_PAD_Y 0)
14
14
  set(GEA_BOARD_STREAM_PACE_CHUNKS 0)
15
- set(GEA_BOARD_EXTRA_REQUIRES esp_driver_ledc)
15
+ set(GEA_BOARD_EXTRA_REQUIRES esp_driver_ledc esp_codec_dev)
16
16
  set(GEA_BOARD_EXTRA_COMPILE_DEFINITIONS
17
17
  GEA_EMBEDDED_AXS15231B_PANEL=1
18
18
  GEA_EMBEDDED_AXS15231B_BACKLIGHT_GPIO=6
19
19
  GEA_BOARD_AXS15231B_INIT_HEADER="axs15231b_panel_init.h"
20
20
  GEA_BOARD_HAS_SDMMC=1
21
+ GEA_BOARD_HAS_SPEAKER=1
22
+ GEA_BOARD_SPEAKER_POWER=1
21
23
  GEA_EMBEDDED_DISPLAY_FULL_FRAME_TRANSFERS=1
22
24
  )
23
25
  set(GEA_BOARD_PLATFORM_SOURCES
@@ -26,6 +28,8 @@ set(GEA_BOARD_PLATFORM_SOURCES
26
28
  "${CMAKE_CURRENT_LIST_DIR}/../../esp32-s3-touch-amoled-1.8/main/launcher_button.cpp"
27
29
  "${CMAKE_CURRENT_LIST_DIR}/touch.cpp"
28
30
  "${CMAKE_CURRENT_LIST_DIR}/platform_stubs.cpp"
31
+ "${CMAKE_CURRENT_LIST_DIR}/speaker_power.cpp"
32
+ "${GEA_EMBEDDED_ROOT}/targets/esp32/chip_bindings/audio/es8311.cpp"
29
33
  "${GEA_CHIPS}/power/axp2101/axp2101.cpp"
30
34
  "${GEA_EMBEDDED_ROOT}/targets/esp32/chip_bindings/power/axp2101.cpp"
31
35
  "${GEA_CHIPS}/displays/sh8601/sh8601.cpp"
@@ -6,8 +6,9 @@
6
6
  # direct `idf.py` build keeps everything (and so the component manager never
7
7
  # sees an unset variable, which it treats as an error).
8
8
  #
9
- # No esp_codec_dev: this board carries no audio codec.
9
+ # The ES8311 provides the onboard speaker output.
10
10
  dependencies:
11
+ espressif/esp_codec_dev: '^1.4.0'
11
12
  espressif/esp_lcd_axs15231b: '^2.1.0'
12
13
  # host/websocket.cpp
13
14
  espressif/esp_websocket_client:
@@ -10,6 +10,8 @@ struct QspiDisplayConfig {
10
10
  spi_host_device_t spiHost;
11
11
  gpio_num_t cs, pclk, data0, data1, data2, data3, reset, te;
12
12
  };
13
+ struct Es8311AudioConfig { int i2sPort; gpio_num_t mclk, bclk, ws, dout, din, powerAmplifier; };
14
+ bool setSpeakerPower(bool enabled);
13
15
  struct TouchConfig { gpio_num_t reset, interrupt; };
14
16
  struct SdMmcConfig { gpio_num_t clk, cmd, data0; };
15
17
  struct LauncherButtonConfig { gpio_num_t pin; int activeLevel; };
@@ -17,6 +19,7 @@ inline constexpr I2cBusConfig i2c{GPIO_NUM_8, GPIO_NUM_7};
17
19
  inline constexpr QspiDisplayConfig display{
18
20
  SPI2_HOST, GPIO_NUM_12, GPIO_NUM_5, GPIO_NUM_1, GPIO_NUM_2,
19
21
  GPIO_NUM_3, GPIO_NUM_4, GPIO_NUM_NC, GPIO_NUM_NC};
22
+ inline constexpr Es8311AudioConfig audio{0, GPIO_NUM_44, GPIO_NUM_13, GPIO_NUM_15, GPIO_NUM_16, GPIO_NUM_14, GPIO_NUM_NC};
20
23
  inline constexpr TouchConfig touch{GPIO_NUM_NC, GPIO_NUM_NC};
21
24
  inline constexpr SdMmcConfig storage{GPIO_NUM_11, GPIO_NUM_10, GPIO_NUM_9};
22
25
  inline constexpr LauncherButtonConfig launcherButton{GPIO_NUM_0, 0};
@@ -1,4 +1,4 @@
1
- // Onboard codec and IMU are not exposed yet; USB audio is app-owned.
1
+ // The IMU is not exposed yet.
2
2
  #include "imu.h"
3
3
  #include "power.h"
4
4
 
@@ -22,20 +22,3 @@ double Accelerometer::gyroscopeZ() { return 0.0; }
22
22
  void Accelerometer::setWebTilt(int, int) {}
23
23
 
24
24
  } // namespace gea::platform::sensors
25
-
26
- namespace gea::platform::audio {
27
-
28
- bool OutputDriver::open(int, int, int) { return false; }
29
- bool OutputDriver::write(const std::int16_t *, std::size_t, int) { return false; }
30
- void OutputDriver::close() {}
31
- int OutputDriver::volume() { return 0; }
32
- void OutputDriver::setVolume(int) {}
33
-
34
- } // namespace gea::platform::audio
35
-
36
- namespace gea::host::media {
37
-
38
- void platform_attach_track(NativeMediaTrackHandle) {}
39
- void platform_detach_track(NativeMediaTrackHandle) {}
40
-
41
- } // namespace gea::host::media
@@ -0,0 +1,27 @@
1
+ #include <cstdint>
2
+ #include "board.h"
3
+ #include "i2c.h"
4
+ #include "driver/i2c_master.h"
5
+
6
+ namespace gea::platform::board {
7
+ // The amplifier's enable is EXIO7 on the TCA9554 at 0x20. Preserve every
8
+ // other output, including the panel reset and SD card signals.
9
+ bool setSpeakerPower(bool enabled) {
10
+ static i2c_master_dev_handle_t device{};
11
+ if (!device) {
12
+ const auto bus = gea::platform::i2c::Bus::primary();
13
+ if (!bus.available()) return false;
14
+ i2c_device_config_t config{};
15
+ config.device_address = 0x20;
16
+ config.scl_speed_hz = 100000;
17
+ if (i2c_master_bus_add_device(static_cast<i2c_master_bus_handle_t>(bus.nativeHandle()), &config, &device) != ESP_OK) return false;
18
+ }
19
+ const auto update = [](std::uint8_t reg, bool high) {
20
+ std::uint8_t value{};
21
+ if (i2c_master_transmit_receive(device, &reg, 1, &value, 1, 100) != ESP_OK) return false;
22
+ const std::uint8_t bytes[]{reg, static_cast<std::uint8_t>(high ? value | 0x80 : value & ~0x80)};
23
+ return i2c_master_transmit(device, bytes, sizeof(bytes), 100) == ESP_OK;
24
+ };
25
+ return update(1, enabled) && update(3, false);
26
+ }
27
+ }