Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 10 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -218,9 +218,12 @@ sensor driver found online came from — see
| | IMX335 | | | | | | x | x | x |
| | IMX385 | | | | x | x | | | |
| | IMX390 | | | | | | x | | |
| | IMX415 | | | | | | x | | |
| | IMX415 | | | | | | x | | x |
| | IMX458 | | | | | | x | | |
| | IMX662 | | | | | | | | x |
| | IMX664 | | | | | | | | x |
| | IMX675 | | | | | | | | x |
| | IMX678 | | | | | | | | x |
| | ICX692 | x | | | | | | | |
| **Aptina** | AR0130 | x | x | | | | | | |
| | AR0230 | | x | x | | | | | |
Expand Down Expand Up @@ -249,6 +252,7 @@ sensor driver found online came from — see
| | SC4336P | | | | | | | | x |
| | SC450AI | | | | | | | | x |
| | SC500AI | | | | | | | | x |
| | SC850SL | | | | | | | | x |
| **Panasonic** | MN34031 | x | | | | | | | |
| | MN34041 | x | | | | | | | |
| | MN34220 | | | x | | | x | | |
Expand All @@ -260,9 +264,14 @@ sensor driver found online came from — see
| | JXF23 | | x | | | | | | |
| | JXF37 | | | | | | | x | |
| **GalaxyCore** | GC2053 | | | | | | x | x | |
| | GC2063 | | | | | | | | x |
| | GC2083 | | | | | | | | x |
| | GC4023 | | | | | | | | x |
| | GC4653 | | | | | | | | x |
| **SuperPix** | SP2308 | | | | | | | x | x |
| **ImageDesign** | MIS20S1 | | | | | | | | x |
| **CVSENS** | CV2003 | | | | | | | | x |
| **ViSemi** | VS4388 | | | | | | | | x |

Each sensor has `.so` (shared) and `.a` (static) library builds. The goal is to eventually unify sensor drivers across platforms where the same sensor model is used.

Expand Down
17 changes: 16 additions & 1 deletion kernel/sys_config/hi3516cv6xx/sys_cfg.c
Original file line number Diff line number Diff line change
Expand Up @@ -23,12 +23,21 @@
#define SENSOR_NAME_SC4336P "sc4336p"
#define SENSOR_NAME_GC4023 "gc4023"
#define SENSOR_NAME_GC2083 "gc2083"
/* GC2063, 27 MHz: "gc2063 27Mclk 2M30fps(MIPI)" in the vendor's CV610 firmware */
#define SENSOR_NAME_GC2063 "gc2063"
/* GC4653, 27 MHz: "gc4653 27Mclk 4M30fps(MIPI)" in the vendor's CV610 firmware */
#define SENSOR_NAME_GC4653 "gc4653"
#define SENSOR_NAME_IMX335 "imx335"
#define SENSOR_NAME_IMX662 "imx662"
/* IMX415, IMX664, IMX675, IMX678: 37.125 MHz, INCK_SEL in each init table */
#define SENSOR_NAME_IMX415 "imx415"
#define SENSOR_NAME_IMX664 "imx664"
#define SENSOR_NAME_IMX675 "imx675"
#define SENSOR_NAME_IMX678 "imx678"
#define SENSOR_NAME_SC450AI "sc450ai"
#define SENSOR_NAME_SC500AI "sc500ai"
/* SC850SL, 27 MHz: "27MInput_4lane_1080Mbps_12bit" in the vendor's CV610 firmware */
#define SENSOR_NAME_SC850SL "sc850sl"
#define SENSOR_NAME_SC431HAI "sc431hai"
#define SENSOR_NAME_OS04D10 "os04d10"
#define SENSOR_NAME_OS02M10 "os02m10"
Expand Down Expand Up @@ -304,11 +313,13 @@ static unsigned int parse_sensor_clock(const char *name, unsigned int name_len)
if ((strncmp(SENSOR_NAME_SC4336P, name, len) == 0) ||
(strncmp(SENSOR_NAME_GC4023, name, len) == 0) ||
(strncmp(SENSOR_NAME_GC2083, name, len) == 0) ||
(strncmp(SENSOR_NAME_GC2063, name, len) == 0) ||
(strncmp(SENSOR_NAME_GC4653, name, len) == 0) ||
(strncmp(SENSOR_NAME_MIS20S1, name, len) == 0) ||
(strncmp(SENSOR_NAME_SC431HAI, name, len) == 0) ||
(strncmp(SENSOR_NAME_SC450AI, name, len) == 0) ||
(strncmp(SENSOR_NAME_SC500AI, name, len) == 0)) {
(strncmp(SENSOR_NAME_SC500AI, name, len) == 0) ||
(strncmp(SENSOR_NAME_SC850SL, name, len) == 0)) {
clock = 0xA001; /* 27M */
} else if ((strncmp(SENSOR_NAME_OS04D10, name, len) == 0) ||
(strncmp(SENSOR_NAME_OS02M10, name, len) == 0) ||
Expand All @@ -318,6 +329,10 @@ static unsigned int parse_sensor_clock(const char *name, unsigned int name_len)
clock = 0x4001; /* 24M */
} else if ((strncmp(SENSOR_NAME_IMX335, name, len) == 0) ||
(strncmp(SENSOR_NAME_IMX662, name, len) == 0) ||
(strncmp(SENSOR_NAME_IMX415, name, len) == 0) ||
(strncmp(SENSOR_NAME_IMX664, name, len) == 0) ||
(strncmp(SENSOR_NAME_IMX675, name, len) == 0) ||
(strncmp(SENSOR_NAME_IMX678, name, len) == 0) ||
(strncmp(MIPI_AD, name, len) == 0)) {
clock = 0x8010; /* 37.125M */
} else if ((strncmp("bt656", name, len) == 0) ||
Expand Down
35 changes: 35 additions & 0 deletions libraries/sensor/hi3516cv6xx/galaxycore_gc2063/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
LIB_NAME := libsns_gc2063

ISP_DIR := $(CURDIR)/../../../isp
KO_DIR := $(CURDIR)/../../../../kernel
COMMON := $(CURDIR)/../common

override CFLAGS += -fPIC -Wall -O2 \
-I$(ISP_DIR)/include/hi3516cv6xx \
-I$(ISP_DIR)/include/hi3516cv6xx/3a \
-I$(ISP_DIR)/include/hi3516cv6xx/ext_inc \
-I$(KO_DIR)/include/hi3516cv6xx \
-I$(KO_DIR)/include/hi3516cv6xx/exp_inc \
-I$(KO_DIR)/include/hi3516cv6xx/module \
-I$(COMMON) \
-I.

SRCS := $(wildcard *.c) $(COMMON)/sensor_common.c
OBJS := $(notdir $(SRCS:%.c=%.o))

all: $(LIB_NAME).so $(LIB_NAME).a

%.o: %.c
$(CC) $(CFLAGS) -c $< -o $@

%.o: $(COMMON)/%.c
$(CC) $(CFLAGS) -c $< -o $@

$(LIB_NAME).so: $(OBJS)
$(CC) -shared -o $@ $(OBJS) -lm

$(LIB_NAME).a: $(OBJS)
$(AR) -rcs $@ $(OBJS)

clean:
-rm -f $(OBJS) $(LIB_NAME).so $(LIB_NAME).a
53 changes: 53 additions & 0 deletions libraries/sensor/hi3516cv6xx/galaxycore_gc2063/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
# GalaxyCore GC2063 for Hi3516CV610

A source driver for the GalaxyCore GC2063 (2M, I2C 0x6e, 8-bit paged
registers) on Hi3516CV610/CV608. The SIP-K662C6S module's stock firmware (xipc)
has a GC2063 among its sensor types, but no SDK has a GC2063 driver for this SoC.

One mode: 1920x1080 linear at 30 fps in RAW10, 2-lane MIPI, at a 27 MHz sensor
clock ("gc2063 27Mclk 2M30fps(MIPI)"; `sys_config` gives `gc2063` 27 MHz).

## Where it comes from

- `gc2063_cfg.h`: the firmware's GC2063 bring-up, read out of xipc, 80 writes.
These are, write for write, the Hi3516CV500 `galaxycore_gc2053` driver's
1080p30 sequence in this tree; the firmware writes the closing stream-on
(0x3e = 0x91) twice. The GC2063 takes the GC2053's register map, so the rest
of the sensor side is that driver's:
- exposure 0x03/0x04, in lines;
- analog gain as 29 steps, each a row of 0xb4/0xb3/0xb8/0xb9, 1x..110.5x;
- digital gain 1x..8x in 1/64 steps through the pre-gain 0xb1/0xb2;
- VMAX 0x41/0x42, 1125 lines at 30 fps, at most 0x3fff, down to 6 fps;
- exposure up to 2 lines short of the frame;
- shutter and gains one frame after the frame length;
- standby and restart through 0xf2/0xfc.
- AWB calibration: the GC2053 driver's (R 388, B 519 at 4908 K).
- `gc2063_cmos_param.h`: `galaxycore_gc4023`'s ISP tables, unchanged and
untuned for the GC2063. The firmware has no ISP defaults of its own for it.
- Black level 0x400, as every CV610 GalaxyCore driver here has it: the CV610
ISP takes black level on a fixed 12-bit scale whatever the sensor's depth.
The 0x100 of the CV500 driver is a different ISP's.
- CFA RGGB, which is what the DNG metadata says. OpenIPC's hi3516cv500 and
hi3516ev200 GC2053 profiles run this same register sequence with
`Isp_Bayer=BAYER_RGGB`.

## Orientation

0x17 on page 0: bit 0 mirrors, bit 1 flips, over a base of 0x80, as the
Hi3516CV500 GC2053 driver writes it. Neither GC2053 driver in this tree moves
the window with it, and the XMedia one (`gk7206v100/galaxycore_gc2053`) gives
one Bayer order for all four orientations, so the phase is taken not to move.
Unverified on a GC2063. The orientation is kept per pipe, written by the
callback and again by every bring-up, both under `cis->mutex`. The bring-up
writes it after the table has turned the stream on, so the first frame or two
may come out upright.

## What was added to the recovered driver

- The AE registers the bring-up replays are seeded when AE has not filled them
yet. They hold the mode's frame length, the table's own exposure and 1x, not
zeros, so the first frames are not black.
- Bring-up errors are returned and stop `init` from being marked done.
- The I2C bus defaults to 0 until `pfn_set_bus_info`, as in `galaxycore_gc4653`.

Not run on a GC2063 yet.
103 changes: 103 additions & 0 deletions libraries/sensor/hi3516cv6xx/galaxycore_gc2063/gc2063_cfg.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,103 @@
/*
* GC2063 (GalaxyCore, 2M) power-on register table — EXTRACTED byte-exact from
* xipc (K662C6S GC2063 bring-up sub_AE770) via capstone. 8-bit paged registers
* (0xFE = page select). 2M 1920x1080 30fps 10bit MIPI, 27MHz. Ends stream-on 0x3e=0x91.
*/
#ifndef GC2063_CFG_H
#define GC2063_CFG_H
#include "sensor_common.h"
#ifdef __cplusplus
#if __cplusplus
extern "C" {
#endif
#endif

static cis_reg_cfg gc2063_linear_2m30_10bit[] = {
{0xfe, 0x80},
{0xfe, 0x80},
{0xfe, 0x80},
{0xfe, 0x00},
{0xf2, 0x00},
{0xf3, 0x00},
{0xf4, 0x36},
{0xf5, 0xc0},
{0xf6, 0x44},
{0xf7, 0x01},
{0xf8, 0x2c},
{0xf9, 0x42},
{0xfc, 0x8e},
{0xfe, 0x00},
{0x87, 0x18},
{0xee, 0x30},
{0xd0, 0xb7},
{0x03, 0x04},
{0x04, 0x60},
{0x05, 0x04},
{0x06, 0x4c},
{0x07, 0x00},
{0x08, 0x11},
{0x0a, 0x02},
{0x0c, 0x02},
{0x0d, 0x04},
{0x0e, 0x40},
{0x12, 0xe2},
{0x13, 0x16},
{0x19, 0x0a},
{0x28, 0x0a},
{0x2b, 0x04},
{0x37, 0x03},
{0x43, 0x07},
{0x44, 0x40},
{0x46, 0x0b},
{0x4b, 0x20},
{0x4e, 0x08},
{0x55, 0x20},
{0x77, 0x01},
{0x78, 0x00},
{0x7c, 0x93},
{0x8d, 0x92},
{0x90, 0x00},
{0x41, 0x04},
{0x42, 0x65},
{0xce, 0x7c},
{0xd2, 0x41},
{0xd3, 0xdc},
{0xe6, 0x50},
{0xb6, 0xc0},
{0xb0, 0x70},
{0x26, 0x30},
{0xfe, 0x01},
{0x55, 0x07},
{0x58, 0x00},
{0xfe, 0x04},
{0x14, 0x78},
{0x15, 0x78},
{0x16, 0x78},
{0x17, 0x78},
{0xfe, 0x01},
{0x04, 0x00},
{0x94, 0x03},
{0x97, 0x07},
{0x98, 0x80},
{0x9a, 0x06},
{0xfe, 0x00},
{0x7b, 0x2a},
{0x23, 0x2d},
{0xfe, 0x03},
{0x01, 0x27},
{0x02, 0x56},
{0x03, 0xb6},
{0x12, 0x80},
{0x13, 0x07},
{0x15, 0x12},
{0xfe, 0x00},
{0x3e, 0x91},
{0x3e, 0x91},
};

#ifdef __cplusplus
#if __cplusplus
}
#endif
#endif
#endif
Loading
Loading