User Tools

This is an old revision of the document!


FX3/FPGA API spec

FX3 API specification has been moved to this location

FPGA I²C bridge (registers' map)

The following tables provide information on how to access the camera's functionality for an FPGA I²C bridge.

Here's a sample code (skipping all error checking) that sets the LED to bright-yellow color FIXME:

S2R::FX3 dev; // auto-open device #0
using S2R::FX3;
dev.vrCmd(FX3Cmd::i2c_bridge, VrCmdOpType::write, 255, 0x08); // red
dev.vrCmd(FX3Cmd::i2c_bridge, VrCmdOpType::write, 255, 0x0A); // green
dev.vrCmd(FX3Cmd::i2c_bridge, VrCmdOpType::write, 0, 0x0C);   // blue

The address space is broken down into smaller chunks, grouped by common functionality:

FPGA basic status and controls

Name Offset Bytes Access Bit mapping Notes
:!: FPGA Version0x00 4 R/O see Firmware Version Info
:!: FPGA status0x01 1 R/O7:2 reserved
:!: 1 DPC calibration done 1 indicates that DPC calibration is completed
:!: 0 SFP+ 1 indicates there is an active device in SFP+ cage
:!: FPGA control0x02 1 R/W7:2 reserved
:!: 1 enable DPC enable DPC correction
:!: 0 FPGA config enableif set to 1, the GPIF becomes read only and waits for an FPGA update bitstream
:!: FPGA config status0x03 2 R/Osee SPI codes for details
:!: FPGA core temperature0x04 1 R/O 7:0 - temperature in Farenheits Reading of the FPGA's internal temperature sensor in degrees of Farenheits
:!: LED RED0x05 2 R/W LED's red intensity in range \([0..65535]\)
:!: LED GREEN0x06 2 R/W LED's green intensity in range \([0..65535]\)
:!: LED BLUE0x07 2 R/W LED's blue intensity in range \([0..65535]\)

AWB

Info for performing Auto White-Balance adjustments on the image

Name Offset Bytes Access Notes
:!: AWB Red adjustment0x08 2 R/Wa signed 16-bit value of an adjustment to apply to every pixel in Red channel. Default is \(0\)
:!: AWB Green adjustment0x09 2 R/Wa signed 16-bit value of an adjustment to apply to every pixel in Green channel. Default is \(0\)
:!: AWB Blue adjustment0x0A 2 R/Wa signed 16-bit value of an adjustment to apply to every pixel in Blue channel. Default is \(0\)
Reserved 0x0B
:!: AWB Red total 0x0C 4 R/O
:!: AWB Green total 0x0D 4 R/O
:!: AWB Blue total 0x0E 4 R/O
:!: AWB count total 0x0F 4 R/O A count of pixels that were used to calculate the \(R/G/B\) totals

Basic UVC controls

Name Offset Bytes Access Range Range description Neutral value
:!: Brightness0x10 2 R/W\([-1024..1023]\) \(-1024\) makes the image very dark
\(1023\) makes the image very bright
\(0\)
:!: Contrast0x11 2 R/W\([1..2047]\) \(1\) turns image into grayscale
\(2047\) makes all pixels either black or white
\(1023\)
:!: Saturation0x12 2 R/W\([0..900]\) \([0\%..900\%]\) or grayscale to 9x \(100\)
:!: Sharpness0x13 1 R/W\([0..255]\) \(0\)
:!: Gamma0x14 1 R/W\([0..15]\) \(0\)
:!: Hue0x15 2 R/W\([-8192..8191]\) \([-180°..180°)\) \(0\)
Reserved0x16-0x1F

General image stats and adjustments

Defective pixel cancellation
Name Offset Bytes Access Notes
:!: DPC Threshold0x20 2 R/W A write into this register triggers the start of DPC calibration
:!: DPC count0x21 2 R/OOnce the DPC calibration is done the 16-bit value is stored in here
General image stats
:!: flags0x22 1 R/O 7:2 reserved
:!: 1 - indicates whether a red overexposure is detected
:!: 0 - set if there is a general overexposure detected
:!: FPS0x23 2 R/O16-bit unsigned value representing number of 10μs units between frame start signals from the image sensor, e.g. a value of \(1000\) means it took 10ms between 2 frame start signals, which corresponds to 100FPS
:!: Y average0x24 2 R/OAverage “brightness” value

Color Correction Matrix (a.k.a. CCM or CMX)

See Color correction matrix article in this Wiki's ISP section for more details. The 16-bit (MSB-LSB) value is defined as 7+9 bits, where MSB[7:1] are the integer part and MSB[0]LSB[7:0] is the fractional part (effectively that value is 512 times larger than the original fractional part)

Name Offset Bytes Access Notes
:!: CCM_000x25 2 R/W\(CCM_{00}\)
:!: CCM_010x26 2 R/W\(CCM_{01}\)
:!: CCM_020x27 2 R/W\(CCM_{02}\)
:!: CCM_100x28 2 R/W\(CCM_{10}\)
:!: CCM_110x29 2 R/W\(CCM_{11}\)
:!: CCM_120x2A 2 R/W\(CCM_{12}\)
:!: CCM_200x2B 2 R/W\(CCM_{20}\)
:!: CCM_210x2C 2 R/W\(CCM_{21}\)
:!: CCM_220x2D 2 R/W\(CCM_{22}\)

Color grading

Name Offset Access Bit mapping Notes
:!: switch0x2EW15:10 reserved Controls what information is being read/written by accessing the register 0x002F
9:7 table switch000 - Hue vs. Hue (14 bits)
001 - Hue vs. Saturation (12 bits)
010 - Lightness vs. Saturation (12 bits)
011 - Saturation vs. Saturation (12 bits)
100 - Lightness vs. Lightness (12 bits)
101 - Hue vs. Lightness (12 bits)
110-111 - reserved
6:1 index LSB index into a page in the table
0 access mode 0: “normal mode”, in which all the subsequent accesses to the register 0x002F are governed by the values in 0x002E
1: “bulk access”, where after a read or write access to register 0x002F the “Index” value will auto-increment by one so that the next read/wrie will access the subsequent table slot
:!: Value0x2FR/W15:0 value 16 bits of either signed or unsigned integer value
- for a “Hue vs. Hue” table the 14 bits signed value is in range [-8192..+8192] which maps linearly into a Hue angle range -180°..+180°
- for a “Hue vs. Saturation” table (as well as for similar tables LvS and SvS) the 12 bit unsigned value in range [0..+1280] maps linearly into a Saturation range [0%..1000%] where 100% is the neutral position and 0% produces a greyscale image
- (until FPGA v.72) for a “Lightness vs. Lightness” table (as well as for similar table HvL) the 12 bit unsigned value in range [0..+4095] maps linearly into a Lightness absolute range [0..255] where 0 is pitch black and 255 is the maximum possible pixel luminosity value
- (starting with FPGA v.73) for a “Lightness vs. Lightness” table (as well as for similar table HvL) the 13 bit signed value in range [-4096..+4095] maps linearly into a Lightness *relative* (adjustment) range [-256..255] where 0 is no adjustment to pixel luminosity value

Media setup

Media output and transform blocks

Name Offset Access Bit mapping Notes
:!: Media output modules0x30R/W7 - res
6 - res (headphones)
5 - res (UAC)
4 - res
:!: 3 - HDMI video
:!: 2 - SDI video
:!: 1 - SFP+ video
:!: 0 - UVC
Enable/disable state of individual media output modules for video and audio streams
:!: Video transform blocks0x31R/W:!: 7 - sharpness
6 - res
5 - res
4 - res
3 - res
2 - res
:!: 1 - CCM
:!: 0 - (UVC Gamma)
Enable/disable individual transformation blocks in video pipeline

Video output formats

Name Offset Access Bit mapping Notes
:!: Video output format0x32R/W:!: 7:4 - UVC
:!: 3:0 - FPS code for SDI, SFP+, SDI
Bit depth for all video formats is set in register 0x49
UVC video formats:
:!:0 - “RAW” greyscale pre-debayer pixels
:!:1 - 4:4:4 RGB
:!:2 - (res) packed YCbCr 4:4:4
:!:3 - packed YCbCr 4:2:2
:!:4 - (res) packed YCbCr 4:2:0
:!:5 - (res) planar YCbCr 4:4:4
:!:6 - (res) planar YCbCr 4:2:2
:!:7 - planar YCbCr 4:2:0
:!:8-15 - (res) MJPEG, MPEG-x/H.26x, etc

SDI/HDMI and SFP+ video output formats/FPS are always in unison. See SDI FPS table below for codes. SDI output is always in a packed (not planar) YUV 4:2:2 format
:!: Video output pixel bit depth0x33R/W:!: 7:6 - HDMI
:!: 5:4 - SDI
:!: 3:2 - SFP+
:!: 1:0 - UVC
Pixel bit depths \(d_p\) is calculated from a 2-bit value \(N\) as: \[d_p = (N+4)*2\] Not all values are valid, for example SDI and SFP+ both do not support 8-bit output and UVC only supports 8-bit color depth, at least for now

Image sensor config

Name Offset Access Bit mapping Notes
:!: Image sensor configuration0x34R/W7:2 - res
:!: 1:0 - de-mosaicing strategy
De-mosaicing strategy directs the use of a specific implementation of color reconstruction:
3, 2 - reserved
1 - use “branching 5×5”, for example the one described here
0 - use “branchless 5×5”, like the one described in here
Reserved0x35-0x39

Audio setup

Name Offset Access Bit mapping Notes
:!: Audio transform blocks0x3AR/W7:0 - resEnable/disable individual transformation blocks in audio pipeline
Reserved0x3B-0x3F

FOURCC formats (for UVC)

A combination of data in 0x0033[1:0] (pixel bit depth) and 0x32[7:4] (video format) used for UVC is mapped into standard FOURCC codes as summarized in the following table:

0x0033[1:0]\0x0032[7:4] 0 (RAW) 1 (RGB) 2 (packed YUV 4:4:41)) 3 (packed YUV 4:2:22)) 7 (planar YUV 4:2:03))
0 (8 bit) :!: BA81/BYR1/GREY/Y8/Y800 (8bpp):!: BI_RGB/RGB (24bpp) :!: Y444/IYU2 (24bpp) :!: YUY2/YUYV (16 bpp):!: NV12 (12bpp)
1 (10 bit) :!: Y104) (16bpp5)):!: BI_BITFIELDS (48bpp) :!: Y410 (32bpp6)) :!: Y210 (32bpp)
YUVP?/Y42T (24bpp?)
:!: P010 (32bpp)
2 (12 bit) :!: BYR2 (16pbb7)):!: BI_BITFIELDS (48bpp) :!: Y4128) (40bpp9)) :!: Y21210) (32bpp11)) :!: P01212) (32bpp13))
3 (14 bit) :!: Y1614) (16bpp15)):!: BI_BITFIELDS (48bpp) :!: Y41416) (48bpp17)) :!: Y21418) (32bpp19)) :!: P01420) (32bpp21))

SDI FPS

Below is the table that lists codes for supported SDI FPS settings set in 0x0032[3:0]:

FPS code
23.98 0x01
24 0x02
25 0x04
29.97 0x05
30 0x06
50 0x08
59.94 0x09
60 0x0A
120 0x0C

SDI pixel clock frequency

Frame geometry MHz FPS
1920×1080 74.18 23.98
29.97
74.25 24
25
30
148.35 59.94
148.5 50
60
297 120
3840×2160 296.70 23.98
29.97
297 24
25
30
593.41 59.94
594 50
60
1188 120
7680×4320 1188 24
30

Green Screen enhancer

“Green screen”, a.k.a. “Chroma Key” on-board optimization is designed to replace a range of colors with a single solid one

band #0

If enabled these setting take precedence over other 3 bands

Name Offset Bytes Access Notes
:!: CK control0x80 1 R/W7:1 reserved
0 enable/disable Chroma Key control
:!: CK saturation min0x81 1 R/W[0..255] to specify the minimum saturation threshold
:!: CK saturation max0x82 1 R/W[0..255] to specify the maximum saturation threshold
:!: CK luma min0x83 1 R/W[0..255] to specify the minimum brightness threshold
:!: CK luma max0x84 1 R/W[0..255] to specify the maximum brightness threshold
:!: CK hue0x85 2 R/W14 bits of a signed hue value, its [-8K..+8K] range is mapped into [-180°..+180°]
:!: CK tolerance0x86 2 R/W13 bits of an unsigned hue tolerance value, valid range is [0..8K], which is mapped into [0°..180°].
That value specifies how far to stretch the CK hue value both ways (symmetrically). If the CK tolerance is above 90° the covered color space is over 50% of values
:!: CK red0x87 2 R/W
:!: CK green0x88 2 R/W
:!: CK blue0x89 2 R/W
Reserved0x8A-0x8F

band #1

Color substitution (if enabled) takes place after the first band had a chance to process the pixels

The layout of the settings is identical to that of band #0 just shifted down by a paragraph and occupying address block 0x0090-0x009F

band #2

Color substitution (if enabled) takes place after the first and second bands had a chance to process the pixels

The layout of the settings is identical to that of band #0 just shifted down by 2 paragraphs and occupying address block 0x00A0-0x00AF

band #3

Color substitution (if enabled) takes place after other bands had a chance to process the pixels

The layout of the settings is identical to that of band #0 just shifted down by 3 paragraphs and occupying address block 0xB0-0xBF

mFT lense access

Name Offset Bytes Access Notes
:!: mFT control register0xC0 1 R/W7:2 returned data count
1: (R/O) command completion flag
0: (W/O) setting this to 1 sends the command to mFT
:!: mFT command setup0xC1 1 W/OSee below for the 32-bit command structure
:!: mFT returned data0xC2 1 R/OOnce the command completion flag is set in control register returned data can be retrieved through this register

FPGA “register” 0xC1 serves as a service point to access mFT protocol and allows FX3 to communicate with the mFT by forwarding requests and replies between the two.

Micro Four Thirds System (mFT) defines a communication protocol in which the “body” (host) issues 4 bytes of data (command type, command code, and two 1-byte parameters) and gets a response of variable number of bytes, depending on the command (including a 0-length data response). See the mFT spec for each individual command's request/response.

FPGA acts as a two-way command repeater and in such capacity it expects a 4 byte command supplied to it as part of an I²C “write” operation and responds with the appropriate return data buffer to a subsequent “read” I²C operation on the same address.

The 4 bytes of the command are laid out as follows:

struct MftCmd{
  uint8_t cmd_type;
  uint8_t cmd_code;
  uint8_t param1, param2;
};

or in a more visual format (taking into consideration the little-endian memory layout typical of the architectures we use):

MSW LSW
MSB LSB MSB LSB
param2 param1 cmd_code cmd_type

which is the equivalent of this code:

MftCmd cmd{1, 2, 3, 4};
static_assert(std::bit_cast<uint32_t>(cmd) == 0x04030201);
1)
ordering is UYV
2)
macropixel byte ordering: Y0U0Y1V0
3)
chroma plane is a interleaved set of U/V samples
4) , 8) , 10) , 12) , 16) , 18) , 20)
need to register with MS
5)
not 10
6)
includes 2 bit alpha at [31:30]
7)
not 12
9)
or 36?
11)
or 24?
13)
or 24, or 18?
14)
yes, 16, not 14
15)
not 14
17)
or 42?
19)
or 28?
21)
or 21?

This website uses cookies. By using the website, you agree with storing cookies on your computer. Also, you acknowledge that you have read and understand our Privacy Policy. If you do not agree, please leave the website.

More information