> For the complete documentation index, see [llms.txt](https://amobile-solutions.gitbook.io/yocto-developer-guide/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://amobile-solutions.gitbook.io/yocto-developer-guide/test-and-use-the-interface/camera/camera-iot-800n-g420.md).

# Camera - IOT-800N-G420

## Overview

|             |                                |
| ----------- | ------------------------------ |
| Sensor      | Samsung S5K3L6, 13 MP          |
| Interface   | MIPI CSI, 4 lane, I2C7 at 0x2D |
| Driver      | `s5k3l6`, V4L2 subdev          |
| Bayer order | GRBG                           |

{% hint style="warning" %}
IoT Yocto on Genio 520/720 supports only the V4L2 sensor architecture. There is no ISP path, so what arrives is unprocessed Bayer RAW. Demosaic, white balance and exposure all have to be done in userspace.

The `camera-tools` package provides that userspace side.
{% endhint %}

## Supported modes

| Resolution | Format                      | Frame rate |
| ---------- | --------------------------- | ---------- |
| 2104×1560  | MTISP packed RAW10 (`MBgA`) | 30 fps     |
| 4208×3120  | MTISP packed RAW10 (`MBgA`) | 30 fps     |
| 1920×1080  | MTISP packed RAW10 (`MBgA`) | 30 fps     |

## Checking the sensor

```
dmesg | grep -i s5k3l6
```

```
s5k3l6 7-002d: chip id 0x30c6
```

```
ls /dev/video*
media-ctl -p -d /dev/media0 | head -40
```

## Setting up the pipeline

```
camera-setup.sh
```

Defaults to 2104×1560 in `MBgA`. For full resolution:

```
camera-setup.sh 4208 3120 MBgA
```

The script links the sensor to seninf and seninf to camsv, sets the format on every pad, and records the result in `/run/camera.conf` for the other tools to read.

{% hint style="info" %}
Do not use the 8-bit `GRBG` format. `STREAMON` succeeds and frames arrive, but the data is not valid Bayer: camsv writes two bytes per pixel rather than converting 10 bits to 8, so the effective width is halved and the brightness alternates by column instead of diagonally.
{% endhint %}

## Live preview

```
camera-gst.sh
```

The pipeline is:

```
v4l2-ctl → mtisp2rgb → gst-launch (rawvideoparse → videoconvert → waylandsink)
```

`mtisp2rgb` unpacks the MediaTek packed RAW10, demosaics at half resolution and applies grey-world white balance, emitting plain RGB24.

Environment variables:

| Variable       | Effect                                           |
| -------------- | ------------------------------------------------ |
| `BAYER=grbg`   | Bayer order; `grbg` is correct for this sensor   |
| `WB=none`      | Disable automatic white balance                  |
| `HALF=0`       | Full resolution; four times slower, for analysis |
| `SINK=kmssink` | Change the sink from the default `waylandsink`   |

## Capturing a still

```
camera-gst.sh jpeg /tmp/capture.png
```

A `.png` extension saves PNG; anything else saves JPEG.

## Measuring frame rate

```
camera-gst.sh fake 100
```

Around 30 fps is expected at 2104×1560 in half-resolution mode.

{% hint style="info" %}
Do not use `fpsdisplaysink` for a preview. It contains a text overlay rendered every frame, which costs about nine times the throughput: 7.9 fps against 0.85 in measurements at this resolution.
{% endhint %}

## Exposure and gain

```
camera-exp.sh                 show current values and ranges
camera-exp.sh 1200            set exposure
camera-exp.sh 1200 64         set exposure and analogue gain
camera-exp.sh +               brighter
camera-exp.sh -               darker
camera-exp.sh auto            meter once and derive a value
camera-exp.sh save            store in /etc/amobile/camera-exp.conf
```

`camera-exp.sh` issues controls on the v4l2 subdev rather than the video device, so it can be used while a preview is running and the change shows immediately.

{% hint style="info" %}
There is no continuous auto-exposure. Without an ISP it would have to capture frames in userspace, which competes with the preview for the video device. Industrial units usually have a fixed scene and fixed lighting, so one value tuned on site and saved is steadier.
{% endhint %}

## Verifying colour

{% hint style="danger" %}
Do not judge Bayer order from photographs of real scenes. In low-saturation images the four channels differ by only a few percent and noise flips the result.
{% endhint %}

Use the sensor's built-in colour bars:

```
v4l2-ctl -d /dev/v4l-subdev1 -c test_pattern=2
camera-gst.sh jpeg /tmp/bars.png
v4l2-ctl -d /dev/v4l-subdev1 -c test_pattern=0
```

The bars must read **white, yellow, cyan, green, magenta, red, blue, black**. Anything else means the Bayer order is wrong.

## Production self-test

```
camera-selftest.sh
```

It checks that the sensor probed, the pipeline builds, frames arrive, the MIPI lane count is 4, the mean brightness is sane, and produces a colour bar image for visual confirmation. Exit code 0 means pass.

## What is not implemented

The driver covers what a RAW dump needs and deliberately omits:

* PDAF
* OTP and EEPROM reads for lens shading and AWB calibration
* 3A — auto exposure, white balance and focus

None of it would be consumed without an ISP.
