A sigrok protocol decoder for MIPI Camera Serial Interface 2 (CSI-2) using D-PHY physical layer.
This decoder implements support for MIPI CSI-2 D-PHY protocol, which is commonly used in camera applications for high-speed serial data transmission. The decoder can parse:
- D-PHY lane signals (clock + data lanes)
- CSI-2 packet structure
- Start/End of Transmission (SoT/EoT) markers
- Short and long packet types
- Lane synchronization
- Various data types (YUV, RGB, RAW, JPEG)
- Multi-lane support: Configurable 1-4 data lanes
- Packet parsing: Short packets (control) and long packets (image data)
- Data type recognition: Common CSI-2 data types
- Virtual channel support: Multiple virtual channels
- Comprehensive annotations: Detailed protocol analysis
- Binary output: Raw packet data export
- Python 3.x
- Sigrok (libsigrokdecode)
-
Clone or copy the
mipi_csi2_dphydirectory to your sigrok decoders directory:cp -r mipi_csi2_dphy /path/to/libsigrokdecode/decoders/
-
Restart your sigrok frontend (PulseView, etc.)
Connect your signals as follows:
- CLK: Clock lane (required)
- DATA0: Data lane 0 (required)
- DATA1: Data lane 1 (optional)
- DATA2: Data lane 2 (optional)
- DATA3: Data lane 3 (optional)
- Number of data lanes: 1-4 (default: 1)
- Expected bitrate: 500-2500 Mbps (default: 1000)
The decoder provides several annotation types:
- SOT: Start of Transmission
- EOT: End of Transmission
- SYNC: Lane synchronization
- Short packet: Control packets
- Long packet: Image data packets
- Payload: Packet payload data
- Footer: Packet footer/checksum
- Data type: YUV, RGB, RAW, JPEG formats
- Virtual channel: Channel number
- Frame count: Frame identifier
- Line count: Line number
- Pixel count: Pixel count
- Protocol error: Decoding errors
MIPI CSI-2 D-PHY is a high-speed serial interface that uses:
- D-PHY physical layer: Differential signaling
- CSI-2 protocol: Packet-based data transmission
- Multiple lanes: Parallel data transmission for higher bandwidth
- SoT (Start of Transmission): 0xB8 marker
- Packet Header: Data type, virtual channel, metadata
- Payload: Image or control data
- EoT (End of Transmission): 0x9C marker
Common CSI-2 data types supported:
- YUV formats: YUV420, YUV422 (8-bit, 10-bit)
- RGB formats: RGB444, RGB555, RGB565, RGB666, RGB888
- RAW formats: RAW6, RAW7, RAW8, RAW10, RAW12, RAW14
- JPEG: JPEG compressed data
Run the test script to verify the decoder structure:
python3 test_decoder_mock.pyThis will test:
- Decoder import and instantiation
- Channel configuration
- Annotation definitions
- Method functionality
mipi_csi2_dphy/
├── __init__.py # Module metadata and imports
├── pd.py # Main decoder implementation
└── README.md # This file
- Decoder class: Main decoder implementation
- Channel definitions: Signal input configuration
- Annotation system: Protocol analysis output
- Binary output: Raw data export
- State machine: Protocol state tracking
The decoder is designed to be extensible:
- Add new data types: Extend the
DATA_TYPE_NAMESdictionary - Enhance packet parsing: Modify the decode methods
- Add new annotations: Extend the annotations tuple
- Improve lane handling: Enhance multi-lane support
Current implementation includes:
- Basic packet detection framework
- Simplified lane synchronization
- Core CSI-2 data type support
Future enhancements could include:
- Advanced lane synchronization
- Error detection and recovery
- Timing analysis
- Performance optimization
- Fork the repository
- Create a feature branch
- Make your changes
- Test thoroughly
- Submit a pull request
This decoder is licensed under GPLv2+ (GNU General Public License v2 or later).
- Implement advanced lane synchronization
- Add error detection and recovery
- Enhance timing analysis
- Add performance optimization
- Create unit tests with real signal data
- Add documentation for advanced features