Skip to content

Staging/adrv903x ram capture - #3445

Merged
stefpopa merged 2 commits into
mainfrom
staging/adrv903x_ram_capture
Nov 17, 2026
Merged

stefpopa merged 2 commits into
mainfrom
staging/adrv903x_ram_capture

Conversation

@stefpopa

@stefpopa stefpopa commented Jul 20, 2026 •

Copy link
Copy Markdown
Collaborator

PR Description

  • Add debugfs interface for quick single-shot RX/ORx RAM captures
  • Add full IIO device (adrv903x-ramc) with I/Q channel support and buffer infrastructure

PR Type

  • Bug fix (a change that fixes an issue)
  • New feature (a change that adds new functionality)
  • Breaking change (a change that affects other repos or cause CIs to fail)

PR Checklist

  • I have conducted a self-review of my own code changes
  • I have compiled my changes, including the documentation
  • I have tested the changes on the relevant hardware
  • I have updated the documentation outside this repo accordingly
  • I have provided links for the relevant upstream lore

@nunojsa nunojsa left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It seems this is very similar to #3448 so I guess whatever we end up with in that one should be brought here...

static inline void adrv903x_register_debugfs(struct iio_dev *indio_dev) { }
#endif

int adrv903x_ramc_probe(struct adrv903x_rf_phy *phy);

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Seems not to belong to this patch

}

kvfree(phy->rx_capture_data);
phy->rx_capture_data = capture_buf;

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Seems like the above memory might never be freed (you do handle it in the other PR). But the same comment as in koror maintains!

Add a full IIO device (adrv903x-ramc) for RX/ORx RAM capture with proper
I/Q channel support and IIO buffer infrastructure.

Features:
- 10 I/Q channel pairs: voltage0_i/q through voltage9_q (RX0-7, ORX0-1)
- Single-shot capture triggered by buffer enable
- Hardware constraint enforcement via available_scan_masks (one channel
  pair at a time)
- Configurable sample count via sample_count sysfs attribute
- 28-bit signed I/Q data with proper sign extension and bank demuxing

The capture hardware can only sample one RX/ORX channel at a time, which
is enforced through available_scan_masks. Users can capture data using
iio_readdev or IIO Oscilloscope.

Example usage:
  iio_readdev -u local: -s 1024 adrv903x-ramc voltage0_i voltage0_q

Signed-off-by: Stefan Popa <stefan.popa@analog.com>
Add a debugfs interface for quick single-shot RX/ORx data captures from
the ADRV903x RAM capture hardware. This provides a simple way to capture
raw ADC samples for debugging and signal analysis.

Usage:
  echo "<channel> <length>" > /sys/kernel/debug/iio/iio:deviceX/rx_data_capture
  cat /sys/kernel/debug/iio/iio:deviceX/rx_data_capture

Where channel is 0-7 for RX0-RX7 or 8-9 for ORX0-ORX1, and length is one
of the hardware-supported capture sizes (32 to 32768 samples).

The capture buffer is sized for the largest capture and allocated once
when the debugfs entries are registered, so it is reused across captures
and released together with the device.

Signed-off-by: Stefan Popa <stefan.popa@analog.com>
@stefpopa
stefpopa force-pushed the staging/adrv903x_ram_capture branch from 2bd271d to ac5396a Compare November 16, 2026 12:16
@stefpopa

stefpopa commented Nov 16, 2026 •

Copy link
Copy Markdown
Collaborator Author

@nunojsa changelog v2:

Brought in line with what was merged for adrv904x in #3448.

  • Rebased on current main
  • Swapped patch order (IIO device first, debugfs second)
  • Added select IIO_KFIFO_BUF to ADRV903X
  • Dropped the RAMC-private lock; phy->lock now covers sample_count, the active channel and the whole capture
  • Re-check the ORx 12K limit at capture time
  • Used IIO_DECLARE_DMA_BUFFER_WITH_TS() and iio_push_to_buffers_with_ts(); factored the push code into adrv903x_ramc_push_sample() and removed the scan_data cast
  • Style: include order, { } terminator, unsigned int loop counters in loop scope, joined unnecessary line breaks
  • debugfs: capture buffer (max 128KB) allocated once with devm_kcalloc() at registration, so nothing is allocated or leaked per capture
  • debugfs: moved the capture read into adrv903x_debugfs_read_rx_capture(), with __free() on the allocation line
  • debugfs: the capture is handled as a case in the existing write switch

@stefpopa
stefpopa merged commit 0dd9c02 into main Nov 17, 2026
21 checks passed
@stefpopa
stefpopa deleted the staging/adrv903x_ram_capture branch November 17, 2026 07:31
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

Successfully merging this pull request may close these issues.

2 participants