JianyuWang0623 opened a new pull request, #18703:
URL: https://github.com/apache/nuttx/pull/18703

   ## Summary
   
   As suggested by @eren-terzioglu in 
https://github.com/apache/nuttx/pull/18692#discussion_r3062857373,
   refactor the ESP32-S3 CAM driver to use Espressif's `cam_ll_*` HAL 
abstraction
   layer instead of direct `putreg32`/`getreg32` register manipulation.
   
   Replace all raw register accesses in `esp32s3_cam.c` with `cam_ll_*` inline
   functions from the `esp_hal_cam` component in `esp-hal-3rdparty`. This 
reduces
   maintenance burden and aligns with Espressif's recommended driver 
architecture.
   
   Changes:
   - Add `lcd_cam_dev_t *hw` pointer to the driver private struct
   - Use `cam_ll_start/stop/reset/fifo_reset` for CAM control
   - Use `cam_ll_get_interrupt_status/clear_interrupt_status` for ISR handling
   - Use `cam_ll_set_recv_data_bytelen` for DMA buffer length configuration
   - Use `cam_ll_select_clk_src/set_group_clock_coeff` for clock setup
   - Use `cam_ll_enable_vsync_filter/set_vsync_filter_thres` for VSYNC filtering
   - Use `cam_ll_enable_vsync_generate_eof/enable_rgb_yuv_convert` for capture 
config
   - Use struct field access for interrupt enable (`cam_ll_enable_interrupt`
     requires `__DECLARE_RCC_ATOMIC_ENV` which is not available in NuttX)
   - Add `esp_hal_cam` include paths to `hal.mk`
   
   Net result: 68 insertions, 155 deletions — eliminates all 
`putreg32`/`getreg32`
   calls from the CAM driver.
   
   ## Impact
   
   - No functional change — the driver behavior is identical, only the register
     access method changes from raw addresses to the vendor HAL layer.
   - No impact on build process, documentation, security, or compatibility.
   - Only affects `arch/xtensa/src/esp32s3/esp32s3_cam.c` and `hal.mk`.
   
   ## Testing
   
   Host: Ubuntu 22.04 x86\_64, xtensa-esp32s3-elf-gcc
   
   Target: ESP32-S3 (lckfb-szpi-esp32s3, ESP32-S3-WROOM-1-N16R8, PSRAM 8MB OCT)
   with GC0308 DVP camera and ST7789 LCD
   
   Build and flash:
   
   ```
   $ cd nuttx
   $ make -j$(nproc) flash ESPTOOL_PORT=/dev/ttyUSB0
   ...
   Generated: nuttx.bin
   ...
   Hard resetting via RTS pin...
   ```
   
   Runtime test — continuous preview:
   
   ```
   nsh> camera 0
   nximage_listener: Connected
   nximage_initialize: Screen resolution (320,240)
   Start video this mode is eternal. (Non stop, non save files.)
   ```
   
   Runtime test — mirrored preview:
   
   ```
   nsh> camera 0 -m
   nximage_listener: Connected
   nximage_initialize: Screen resolution (320,240)
   Start video this mode is eternal. (Non stop, non save files.)
   ```
   
   Verified:
   - LCD preview displays correct colors (RGB565X byte-swap path active)
   - Hardware mirror (`-m`) works correctly
   - MMAP buffers allocated with GDMA alignment (3 video buffers in RING mode)
   - Repeated start/stop cycles — no crash, no resource leak


-- 
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: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to