13 #define AVI_BASE 0x400000
14 #define AVI_SIZE 0x100000
15 #define AVI_MASK (AVI_SIZE - 1)
27 #define AVI_ISP_IOGET_OFFSETS _IOR('F', 0x33, struct avi_isp_offsets)
30 #define readl(_addr) (*((volatile uint32_t *)(_addr)))
31 #define writel(_val, _addr) (*((volatile uint32_t *)(_addr)) = _val)
76 perror(
"ioctl(AVI_ISP_IOGET_OFFSETS) failed");
92 ctx->
devmem = open(
"/dev/mem", O_RDWR);
95 perror(
"Can't open /dev/mem");
100 PROT_READ | PROT_WRITE,
103 if (ctx->
avi_base == (
unsigned long) MAP_FAILED) {
104 perror(
"mmap failed");
109 goto get_offsets_failed;
145 perror(
"munmap failed");
159 .pedestal_bypass = 1,
164 .chroma_aber_bypass = 1,
166 .color_matrix_bypass = 0,
175 .threshold_1 = { ._register = 0x19 },
176 .threshold_2 = { ._register = 0xc8 },
181 .coeff_10_02 = { ._register = 0xFDF0021d },
182 .coeff_12_11 = { ._register = 0xFF9E0A33 },
183 .coeff_21_20 = { ._register = 0xF4DFFE25 },
184 .coeff_22 = { ._register = 0x00001B83 },
185 .offset_ry = { ._register = 0x00000000 },
186 .clip_ry = { ._register = 0x03FF0000 },
187 .offset_gu = { ._register = 0x00000000 },
188 .clip_gu = { ._register = 0x03FF0000 },
189 .offset_bv = { ._register = 0x00000000 },
190 .clip_bv = { ._register = 0x03FF0000 },
197 #define COMPLEMENT_2(i, r) (((i) >= 0) ? (r) : (~(r) + 1) & 0x3fff)
198 #define Q311(i) (COMPLEMENT_2(i, (unsigned)(((ABS(i)) * (1 << 11)) + 0.5)))
206 #define AVI_CONV_MATRIX(_c00, _c01, _c02, \
209 .coeff_01_00 = {{ .coeff_00 = Q311(_c00), .coeff_01 = Q311(_c01) }}, \
210 .coeff_10_02 = {{ .coeff_02 = Q311(_c02), .coeff_10 = Q311(_c10) }}, \
211 .coeff_12_11 = {{ .coeff_11 = Q311(_c11), .coeff_12 = Q311(_c12) }}, \
212 .coeff_21_20 = {{ .coeff_20 = Q311(_c20), .coeff_21 = Q311(_c21) }}, \
213 .coeff_22 = {{ .coeff_22 = Q311(_c22) }}
215 #define AVI_CONV_OFFSETS(_ryin, _ryout, \
218 .offset_ry = {{ .offset_in = _ryin, .offset_out = _ryout }}, \
219 .offset_gu = {{ .offset_in = _guin, .offset_out = _guout }}, \
220 .offset_bv = {{ .offset_in = _bvin, .offset_out = _bvout }}
222 #define AVI_CONV_CLIPS(_rymin, _rymax, \
225 .clip_ry = {{ .clip_min = _rymin, .clip_max = _rymax }}, \
226 .clip_gu = {{ .clip_min = _gumin, .clip_max = _gumax }}, \
227 .clip_bv = {{ .clip_min = _bvmin, .clip_max = _bvmax }}
232 -0.100, -0.336, 0.436,
233 0.615, -0.515, -0.100),
247 avi_isp_chain_bayer_inter_set_registers(&isp_ctx, &bayer_inter);
248 avi_isp_vlformat_32to40_set_registers(&isp_ctx, &vlf_32to40);
249 avi_isp_bayer_set_registers(&isp_ctx, &bay);
250 avi_isp_color_correction_set_registers(&isp_ctx, &cc);
251 avi_isp_vlformat_40to32_set_registers(&isp_ctx, &vlf_40to32);
252 avi_isp_chroma_set_registers(&isp_ctx, &chr);
261 const void *reg_base,
269 for (i = 0; i < s; i++)
282 for (i = 0; i < s; i++)
286 #define EXPAND_AS_FUNCTION(_node) \
287 void avi_isp_ ## _node ## _set_registers(struct libisp_context *c, \
288 struct avi_isp_ ## _node ## _regs const *regs) \
290 memcpy_to_registers(c->offsets[_node], regs, sizeof(*regs)); \
293 void avi_isp_ ## _node ## _get_registers(struct libisp_context *c, \
294 struct avi_isp_ ## _node ## _regs *regs) \
296 memcpy_from_registers(regs, c->offsets[_node], sizeof(*regs)); \
#define AVI_ISP_GREEN_IMBALANCE_GREEN_RED_COEFF_MEM
static int close_isp(struct libisp_context *ctx)
#define AVI_CONV_CLIPS(_rymin, _rymax,_gumin, _gumax,_bvmin, _bvmax)
static const unsigned isp_bases[]
#define AVI_ISP_EDGE_ENHANCEMENT_COLOR_REDUCTION_FILTER_EE_KERNEL_COEFF
#define AVI_ISP_STATISTICS_BAYER
#define AVI_ISP_LENS_SHADING_CORRECTION_BLUE_COEFF_MEM
#define AVI_CONV_MATRIX(_c00, _c01, _c02,_c10, _c11, _c12,_c20, _c21, _c22)
#define AVI_ISP_LENS_SHADING_CORRECTION_RED_COEFF_MEM
static void memcpy_to_registers(unsigned long addr, const void *reg_base, size_t s)
#define AVI_ISP_CHAIN_BAYER_INTER
#define AVI_ISP_VLFORMAT_32TO40
#define AVI_ISP_CHAIN_YUV_INTER
static int avi_isp_get_offsets_fd(int fd, struct avi_isp_offsets *off)
This is taken from libisp.
#define AVI_ISP_DENOISING
int configure_isp(struct v4l2_device *dev)
#define AVI_ISP_EDGE_ENHANCEMENT_COLOR_REDUCTION_FILTER
#define AVI_ISP_DEAD_PIXEL_CORRECTION_LIST_MEM
#define AVI_ISP_EDGE_ENHANCEMENT_COLOR_REDUCTION_FILTER_EE_LUT
#define AVI_ISP_IOGET_OFFSETS
#define AVI_ISP_GREEN_IMBALANCE_GREEN_BLUE_COEFF_MEM
#define AVI_ISP_DEAD_PIXEL_CORRECTION
#define AVI_ISP_DEAD_PIXEL_CORRECTION_CFA
static void memcpy_from_registers(void *reg_base, unsigned long addr, size_t s)
#define writel(_val, _addr)
#define AVI_ISP_CHROMATIC_ABERRATION
unsigned offsets[ISP_NODE_NR]
#define AVI_ISP_GAMMA_CORRECTOR_GU_LUT
static const struct usb_device_descriptor dev
#define AVI_CONV_OFFSETS(_ryin, _ryout,_guin, _guout,_bvin, _bvout)
union avi_isp_color_correction_coeff_01_00 coeff_01_00
#define AVI_ISP_GAMMA_CORRECTOR_BV_LUT
#define AVI_ISP_COLOR_CORRECTION
static int open_isp_fd(struct libisp_context *ctx, int fd)
This is taken from libisp.
#define AVI_DEFINE_NODE(EXPANDER)
#define AVI_ISP_I3D_LUT_CLIP_MODE
#define AVI_ISP_LENS_SHADING_CORRECTION_GREEN_COEFF_MEM
#define AVI_ISP_LENS_SHADING_CORRECTION
#define AVI_ISP_VLFORMAT_40TO32
#define AVI_ISP_I3D_LUT_LUT_OUTSIDE
#define AVI_ISP_GREEN_IMBALANCE
#define EXPAND_AS_FUNCTION(_node)
#define AVI_ISP_STATISTICS_YUV_AE_HISTOGRAM_Y
#define AVI_ISP_I3D_LUT_LUT_INSIDE
union avi_isp_bayer_cfa cfa
#define AVI_ISP_GAMMA_CORRECTOR_RY_LUT
int fd
The file pointer to the device.