14 #define PRINT(string,...) fprintf(stderr, "[libisp->%s()] " string,__FUNCTION__ , ##__VA_ARGS__)
17 #define VERBOSE_PRINT PRINT
19 #define VERBOSE_PRINT(...)
22 #define AVI_BASE 0x400000
23 #define AVI_SIZE 0x100000
24 #define AVI_MASK (AVI_SIZE - 1)
34 #define AVI_ISP_STAT_YUV_MAX_WAIT 3
38 #define AVI_ISP_IOGET_OFFSETS _IOR('F', 0x33, struct avi_isp_offsets)
41 #define readl(_addr) (*((volatile uint32_t *)(_addr)))
42 #define writel(_val, _addr) (*((volatile uint32_t *)(_addr)) = _val)
94 perror(
"ioctl(AVI_ISP_IOGET_OFFSETS) failed");
110 ctx->
devmem = open(
"/dev/mem", O_RDWR);
113 perror(
"Can't open /dev/mem");
118 PROT_READ | PROT_WRITE,
121 if (ctx->
avi_base == (
unsigned long) MAP_FAILED) {
122 perror(
"mmap failed");
127 goto get_offsets_failed;
145 for (i = chain_yuv_inter ; i <
ISP_NODE_NR ; i++) {
187 avi_isp_green_imbalance_green_red_coeff_mem_set_registers(&isp_ctx, &
isp_config.
grim_gr);
188 avi_isp_green_imbalance_green_blue_coeff_mem_set_registers(&isp_ctx, &
isp_config.
grim_gb);
205 avi_isp_edge_enhancement_color_reduction_filter_set_registers(&isp_ctx, &
isp_config.
eecrf);
206 avi_isp_edge_enhancement_color_reduction_filter_ee_lut_set_registers(&isp_ctx, &
isp_config.
eecrf_lut);
224 VERBOSE_PRINT(
"[YUV-STAT] Requesting window: [%d %d],[%d %d], [%d %d]\n",
232 VERBOSE_PRINT(
"[YUV-STAT] Setting window: [%d %d],[%d %d]\n",
242 VERBOSE_PRINT(
"[YUV-STAT] Current settings: [%d %d] [%d %d] [%d %d] [%d %d] [%d] [%d %d] [%d]\n",
266 fprintf(stderr,
"[YUV-STAT] Error isp_ctx.devmem < 0\n");
271 avi_isp_statistics_yuv_get_registers(&isp_ctx, &stats_yuv);
286 fprintf(stderr,
"[YUV-STAT] Error requesting YUV stats\n");
304 avi_isp_statistics_yuv_ae_histogram_y_get_registers(&isp_ctx, &histogram);
306 for (i = 0; i < 256; ++i) {
316 const void *reg_base,
324 for (i = 0; i <
s; i++) {
338 for (i = 0; i <
s; i++) {
343 #define EXPAND_AS_FUNCTION(_node) \
344 void avi_isp_ ## _node ## _set_registers(struct libisp_context *c, \
345 struct avi_isp_ ## _node ## _regs const *regs) \
347 memcpy_to_registers(c->offsets[_node], regs, sizeof(*regs)); \
350 void avi_isp_ ## _node ## _get_registers(struct libisp_context *c, \
351 struct avi_isp_ ## _node ## _regs *regs) \
353 memcpy_from_registers(regs, c->offsets[_node], sizeof(*regs)); \
#define AVI_ISP_GREEN_IMBALANCE_GREEN_RED_COEFF_MEM
struct avi_isp_gamma_corrector_bv_lut_regs gc_bv_lut
Gamma corrector BV lut.
struct avi_isp_green_imbalance_green_blue_coeff_mem_regs grim_gb
Green imbalance GB coefficients.
struct avi_isp_pedestal_regs pedestal
Pedestral parameters (substract from pixels)
union avi_isp_statistics_yuv_circle_pos_y_center circle_pos_y_center
union avi_isp_statistics_yuv_measure_status measure_status
union avi_isp_statistics_yuv_increments_log2 increments_log2
static const unsigned isp_bases[]
struct avi_isp_dead_pixel_correction_regs dead_pixel_correction
Dead pixel correction (disabled)
#define VERBOSE_PRINT(...)
#define AVI_ISP_EDGE_ENHANCEMENT_COLOR_REDUCTION_FILTER_EE_KERNEL_COEFF
#define AVI_ISP_STATISTICS_BAYER
#define AVI_ISP_STAT_YUV_MAX_WAIT
union avi_isp_statistics_yuv_circle_pos_y_squared circle_pos_y_squared
#define AVI_ISP_LENS_SHADING_CORRECTION_BLUE_COEFF_MEM
#define AVI_ISP_LENS_SHADING_CORRECTION_RED_COEFF_MEM
struct avi_isp_gamma_corrector_ry_lut_regs gc_ry_lut
Gamma corrector RY lut.
struct avi_isp_chain_yuv_inter_regs chain_yuv_inter
YUV chain bypass configuration (enable/disable features)
static void memcpy_to_registers(unsigned long addr, const void *reg_base, size_t s)
struct avi_isp_green_imbalance_green_red_coeff_mem_regs grim_gr
Green imbalance GR coefficients.
#define AVI_ISP_CHAIN_BAYER_INTER
struct avi_isp_lens_shading_correction_red_coeff_mem_regs lsc_red_coeffs
Lens shade correction red coefficients.
#define AVI_ISP_VLFORMAT_32TO40
union avi_isp_statistics_yuv_circle_pos_x_squared circle_pos_x_squared
#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.
union avi_isp_statistics_yuv_circle_radius_squared circle_radius_squared
static int isp_set_statistics_yuv_window(void)
int isp_get_statistics_yuv(struct isp_yuv_stats_t *yuv_stats)
union avi_isp_statistics_yuv_awb_sum_u awb_sum_u
struct avi_isp_lens_shading_correction_regs lens_shading_correction
Lens shade correction.
union avi_isp_statistics_yuv_measure_req measure_req
union avi_isp_statistics_yuv_circle_pos_x_center circle_pos_x_center
struct libisp_config isp_config
uint32_t awb_nb_grey_pixels
union avi_isp_statistics_yuv_ae_nb_valid_y ae_nb_valid_y
#define AVI_ISP_DENOISING
struct avi_isp_edge_enhancement_color_reduction_filter_ee_lut_regs eecrf_lut
Edge enhancement + Color correction lut.
int configure_isp(struct v4l2_device *dev)
struct avi_isp_vlformat_40to32_regs vlformat_40to32
Conversion factor (10bit to 10bit default)
#define AVI_ISP_EDGE_ENHANCEMENT_COLOR_REDUCTION_FILTER
union avi_isp_statistics_yuv_awb_sum_y awb_sum_y
struct avi_isp_vlformat_32to40_regs vlformat_32to40
Conversion factor (10bit to 10bit default)
#define AVI_ISP_DEAD_PIXEL_CORRECTION_LIST_MEM
#define AVI_ISP_EDGE_ENHANCEMENT_COLOR_REDUCTION_FILTER_EE_LUT
#define AVI_ISP_IOGET_OFFSETS
struct avi_isp_edge_enhancement_color_reduction_filter_regs eecrf
Edge enhancement + Color reduction.
static struct libisp_context isp_ctx
#define AVI_ISP_GREEN_IMBALANCE_GREEN_BLUE_COEFF_MEM
#define AVI_ISP_DEAD_PIXEL_CORRECTION
#define AVI_ISP_DEAD_PIXEL_CORRECTION_CFA
struct avi_isp_color_correction_regs color_correction
Color correction parameters.
static void memcpy_from_registers(void *reg_base, unsigned long addr, size_t s)
struct avi_isp_chain_bayer_inter_regs bayer_inter
Enable or disable bayer ISP functions by bypassing them.
#define writel(_val, _addr)
#define AVI_ISP_CHROMATIC_ABERRATION
union avi_isp_statistics_yuv_window_pos_y window_pos_y
struct avi_isp_bayer_regs bayer
< Chromatic abberation (Disabled for now)
unsigned offsets[ISP_NODE_NR]
#define AVI_ISP_GAMMA_CORRECTOR_GU_LUT
static const struct usb_device_descriptor dev
struct avi_isp_lens_shading_correction_blue_coeff_mem_regs lsc_blue_coeffs
Lens shade correction blue coefficients.
struct avi_isp_gamma_corrector_regs gamma_corrector
Gamma corrector (Curves)
union avi_isp_statistics_yuv_awb_nb_grey_pixels awb_nb_grey_pixels
union avi_isp_statistics_yuv_awb_threshold awb_threshold
struct avi_isp_statistics_yuv_regs statistics_yuv
YUV statistics parameters.
int isp_request_statistics_yuv_window(uint16_t x_start, uint16_t x_end, uint16_t y_start, uint16_t y_end, uint16_t x_odd_inc, uint16_t y_odd_inc)
#define AVI_ISP_GAMMA_CORRECTOR_BV_LUT
struct avi_isp_gamma_corrector_gu_lut_regs gc_gu_lut
Gamma corrector GU lut.
union avi_isp_statistics_yuv_awb_sum_v awb_sum_v
struct avi_isp_chroma_regs chroma
Color space conversion.
struct avi_isp_statistics_bayer_regs statistics_bayer
Statistics bayer parameters.
#define AVI_ISP_COLOR_CORRECTION
static int open_isp_fd(struct libisp_context *ctx, int fd)
This is taken from libisp.
struct avi_isp_denoising_regs denoising
Denoising parameters.
#define AVI_DEFINE_NODE(EXPANDER)
#define AVI_ISP_I3D_LUT_CLIP_MODE
struct avi_isp_green_imbalance_regs green_imbalance
Green imbalance correction.
union avi_isp_statistics_yuv_ae_histogram_y ae_histogram_y[256]
#define AVI_ISP_LENS_SHADING_CORRECTION_GREEN_COEFF_MEM
#define AVI_ISP_LENS_SHADING_CORRECTION
union avi_isp_statistics_yuv_window_pos_x window_pos_x
uint16_t requestWindow[6]
#define AVI_ISP_VLFORMAT_40TO32
uint32_t ae_histogram_Y[256]
#define AVI_ISP_I3D_LUT_LUT_OUTSIDE
struct avi_isp_lens_shading_correction_green_coeff_mem_regs lsc_green_coeffs
Lens shade correction green coefficients.
#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
#define AVI_ISP_GAMMA_CORRECTOR_RY_LUT
int fd
The file pointer to the device.