This chapter introduces the GK7206 video input (VI) sample, sample_vio. It demonstrates the various VI/VPSS working modes, including online/offline mode, single/dual sensor, WDR, LDC, and AHD.
The source lives in sample/vio/ in the SDK and serves as a reference template for video capture applications.
| Parameter | Value |
|---|---|
work_mode |
0~11 (see the table below) |
Output mode |
0 = VO output, 1 = VENC output |
Resolution |
depends on the sensor configuration |
Frame rate |
determined by the sensor |
Memory use |
high (heavy modes are prone to OOM) |
| work_mode | Meaning | Example |
|---|---|---|
| 0 | vi online vpss online | ./sample_vio 0 |
| 1 | vi offline vpss online (for 4K) | ./sample_vio 1 |
| 2 | vi offline vpss offline | ./sample_vio 2 |
| 3 | online/offline + WDR | ./sample_vio 3 |
| 4 | offline, switch linear/WDR | ./sample_vio 4 |
| 5 | offline, switch resolution | ./sample_vio 5 |
| 6 | dual sensor | ./sample_vio 6 |
| 7 | dual-sensor stitching | ./sample_vio 7 |
| 10 | offline online LDC | ./sample_vio 10 |
| 11 | ahd mipi | ./sample_vio 11 |
sample/vio/
├── Makefile # build script
└── sample_vio.c # main program
Before building this application, make sure the following are ready:
# enter the sample directory
cd <SDK_PATH>/sample
# build the vio sample
make -C vio clean && make -C vio
# mount the SD card (recommended)
mkdir -p /sd_card
mount -t vfat /dev/mmcblk1p1 /sd_card
# transfer to the board over SCP
scp sample/vio/sample_vio root@<board-IP>:/sd_card/
Important
Heavy modes (dual sensor, 4K) are prone to OOM. Mount an SD card and run from there.
# make it executable
chmod +x /sd_card/sample_vio
# enter the SD card directory
cd /sd_card
# run it (work_mode 0, stream_mode 1)
./sample_vio 0 1
# or VENC output (RTSP stream available)
./sample_vio 0 1
# or VO output (needs a display device)
./sample_vio 0 0
After a successful start (stream_mode=1) the terminal prints output like this:
sample_vio running
work_mode: 0
stream_mode: 1
...
rtsp://192.168.1.100:554/livestream/0
...
This application uses the following architecture:
Sensor → VI → VPSS → VO/VENC
| Mode | Description | When to use |
|---|---|---|
| Online | VI outputs directly to VPSS with no memory copy | Real-time critical paths |
| Offline | VI writes to memory and VPSS reads from it | When buffering or post-processing is needed |
// Step 1: system initialization
sample_comm_sys_init(&sys_config);
// Step 2: ISP initialization
sample_comm_isp_init();
// Step 3: start VI
sample_comm_vi_start(...);
// Step 4: start VPSS
sample_comm_vpss_start(...);
// Step 5: pick the output according to stream_mode
if (stream_mode == 0) {
// VO output
sample_comm_vo_start(...);
xmedia_bind_vpss_to_vo(...);
} else {
// VENC output
sample_comm_venc_start(...);
xmedia_bind_vpss_to_venc(...);
}
switch(work_mode) {
case 0: // vi online vpss online
sys_config.sys_conf.pipe_mode[0].vicap_viproc_mode = XMEDIA_WORK_MODE_ONLINE;
sys_config.sys_conf.pipe_mode[0].viproc_vpss_mode = XMEDIA_WORK_MODE_ONLINE;
break;
case 1: // vi offline vpss online
sys_config.sys_conf.pipe_mode[0].vicap_viproc_mode = XMEDIA_WORK_MODE_OFFLINE;
sys_config.sys_conf.pipe_mode[0].viproc_vpss_mode = XMEDIA_WORK_MODE_ONLINE;
break;
// ... other modes
}
// configure both sensors
sys_config.sensor_num = 2;
sys_config.sensor_type[0] = SENSOR0_TYPE;
sys_config.sensor_type[1] = SENSOR1_TYPE;
| Problem | Likely cause | Fix |
|---|---|---|
Killed (OOM) |
Heavy mode on 26 MB | Mount an SD card and use the lightweight mode |
sample_comm_vi_init failed! |
Sensor initialization failed | Check the sensor connection and configuration |
open vo err |
No display device | Use stream_mode=1 or attach a display |