diff --git a/conf/modules/video_thread.xml b/conf/modules/video_thread.xml index c57ec52298..b86ec4ce4c 100644 --- a/conf/modules/video_thread.xml +++ b/conf/modules/video_thread.xml @@ -29,6 +29,7 @@ + diff --git a/sw/airborne/arch/linux/mcu_periph/uart_arch.c b/sw/airborne/arch/linux/mcu_periph/uart_arch.c index 2f6176230b..d1fa9b2d49 100644 --- a/sw/airborne/arch/linux/mcu_periph/uart_arch.c +++ b/sw/airborne/arch/linux/mcu_periph/uart_arch.c @@ -48,8 +48,8 @@ static void uart_receive_handler(struct uart_periph *periph); static void *uart_thread(void *data __attribute__((unused))); static pthread_mutex_t uart_mutex = PTHREAD_MUTEX_INITIALIZER; -#define TRACE(fmt,args...) fprintf(stderr, fmt, args) -//#define TRACE(fmt,args...) +//#define TRACE(fmt,args...) fprintf(stderr, fmt, args) +#define TRACE(fmt,args...) void uart_arch_init(void) { diff --git a/sw/airborne/boards/bebop/board.c b/sw/airborne/boards/bebop/board.c index 9a334f2869..73154884e9 100644 --- a/sw/airborne/boards/bebop/board.c +++ b/sw/airborne/boards/bebop/board.c @@ -114,16 +114,16 @@ void board_init2(void) .row_speed_10_8 = 1, // Initial values - .target_fps = 30, + .target_fps = 5, .target_exposure = 30, .gain_green1 = 2.0, .gain_blue = 2.0, .gain_red = 2.0, .gain_green2 = 2.0, - .output_width = 640, - .output_height = 480, + .output_width = 2048, + .output_height = 3320, .output_scaler = 1.0, - .offset_x = 0, + .offset_x = 1000, .offset_y = 0, // I2C connection port diff --git a/sw/airborne/boards/bebop/mt9f002.c b/sw/airborne/boards/bebop/mt9f002.c index 6c796034c9..a65e0d913f 100644 --- a/sw/airborne/boards/bebop/mt9f002.c +++ b/sw/airborne/boards/bebop/mt9f002.c @@ -34,9 +34,26 @@ #include #include #include +#include +#include #define MAX(x,y) (((x) > (y)) ? (x) : (y)) +//FIXMEE! +#include "boards/bebop.h" +struct video_config_t front_camera = { + .w = 2048, + .h = 3320, + .sensor_w = 2048, + .sensor_h = 3320, + .dev_name = "/dev/video1", + .subdev_name = "/dev/v4l-subdev1", + .format = V4L2_PIX_FMT_UYVY, + .subdev_format = V4L2_MBUS_FMT_SGRBG10_1X10, + .buf_cnt = 3, + .filters = VIDEO_FILTER_ISP +}; + /** * Write multiple bytes to a single register */ @@ -545,7 +562,6 @@ static void mt9f002_set_blanking(struct mt9f002_t *mt) float subsampling_factor = (float)(1 + x_odd_inc) / 2.0f; // See page 52 uint16_t min_line_length = MAX(min_line_length_pck, mt->scaled_width/subsampling_factor + min_line_blanking_pck); // EQ 9 min_line_length = MAX(min_line_length, (mt->scaled_width-1 + x_odd_inc) / subsampling_factor/2 + min_line_blanking_pck); - if (mt->interface == MT9F002_MIPI || mt->interface == MT9F002_HiSPi) { min_line_length = MAX(min_line_length, ((uint16_t)((float)mt->scaled_width * mt->vt_pix_clk / mt->op_pix_clk)/2) + 0x005E); // 2 lanes, pll clocks @@ -565,7 +581,7 @@ static void mt9f002_set_blanking(struct mt9f002_t *mt) /* Calculate minimum horizontal blanking, since fpga line_length must be divideable by 2 */ uint32_t min_horizontal_blanking = clkRatio_num; - if((min_horizontal_blanking % 2) != 0) { + if((clkRatio_den % 2) != 0) { min_horizontal_blanking = 2 * clkRatio_num; } @@ -594,7 +610,7 @@ static void mt9f002_set_blanking(struct mt9f002_t *mt) new_fps = mt->vt_pix_clk * 1000000 / (float)(ll * fl); // Calculate FPS error and save if it is better - float fps_err = fabs(mt->target_fps - mt->real_fps); + float fps_err = fabs(mt->target_fps - new_fps); if(fps_err < min_fps_err) { min_fps_err = fps_err; mt->line_length = ll; @@ -683,7 +699,7 @@ static void mt9f002_set_exposure(struct mt9f002_t *mt) /* Set the registers */ mt->real_exposure = (float)(coarse_integration * mt->line_length + fine_integration) / (mt->vt_pix_clk * 1000); write_reg(mt, MT9F002_COARSE_INTEGRATION_TIME, coarse_integration, 2); - write_reg(mt, MT9F002_FINE_INTEGRATION_TIME, fine_integration, 2); + write_reg(mt, MT9F002_FINE_INTEGRATION_TIME_, fine_integration, 2); } /** @@ -739,7 +755,7 @@ static uint16_t mt9f002_calc_gain(float gain) { uint16_t analog_gain2 = gain / (float)digital_gain / (float)(1<interface == MT9F002_MIPI || mt->interface == MT9F002_HiSPi) { mt9f002_mipi_stage3(mt); } + + /* Turn the stream on */ + write_reg(mt, MT9F002_MODE_SELECT, 0x01, 1); } diff --git a/sw/airborne/boards/bebop/mt9v117.c b/sw/airborne/boards/bebop/mt9v117.c index 393024e06b..29e05e21fb 100644 --- a/sw/airborne/boards/bebop/mt9v117.c +++ b/sw/airborne/boards/bebop/mt9v117.c @@ -33,6 +33,8 @@ #include #include #include +#include +#include //FIXMEE! #include "boards/bebop.h" diff --git a/sw/airborne/modules/computer_vision/lib/isp/LICENSE b/sw/airborne/modules/computer_vision/lib/isp/LICENSE new file mode 100644 index 0000000000..6bcd3a9ea9 --- /dev/null +++ b/sw/airborne/modules/computer_vision/lib/isp/LICENSE @@ -0,0 +1,189 @@ + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. + + + Apache License + Version 2.0, January 2004 + http://www.apache.org/licenses/ + + TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + + 1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + + 2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + + 3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + + 4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + + 5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + + 6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + + 7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + + 8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + + 9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. + + END OF TERMS AND CONDITIONS + + + diff --git a/sw/airborne/modules/computer_vision/lib/isp/libisp.c b/sw/airborne/modules/computer_vision/lib/isp/libisp.c new file mode 100644 index 0000000000..5853574045 --- /dev/null +++ b/sw/airborne/modules/computer_vision/lib/isp/libisp.c @@ -0,0 +1,299 @@ +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include "libisp.h" + +#define AVI_BASE 0x400000 +#define AVI_SIZE 0x100000 +#define AVI_MASK (AVI_SIZE - 1) + +struct avi_isp_offsets +{ + uint32_t chain_bayer; + uint32_t gamma_corrector; + uint32_t chroma; + uint32_t statistics_yuv; + uint32_t chain_yuv; +}; + +/* IOCTL implemented in AVI drivers */ +#define AVI_ISP_IOGET_OFFSETS _IOR('F', 0x33, struct avi_isp_offsets) + +/* Raw accesses */ +#define readl(_addr) (*((volatile uint32_t *)(_addr))) +#define writel(_val, _addr) (*((volatile uint32_t *)(_addr)) = _val) + +static const unsigned isp_bases[] = { + AVI_ISP_CHAIN_BAYER_INTER, + AVI_ISP_VLFORMAT_32TO40, + AVI_ISP_PEDESTAL, + AVI_ISP_GREEN_IMBALANCE, + AVI_ISP_GREEN_IMBALANCE + AVI_ISP_GREEN_IMBALANCE_GREEN_RED_COEFF_MEM, + AVI_ISP_GREEN_IMBALANCE + AVI_ISP_GREEN_IMBALANCE_GREEN_BLUE_COEFF_MEM, + AVI_ISP_DEAD_PIXEL_CORRECTION + AVI_ISP_DEAD_PIXEL_CORRECTION_CFA, + AVI_ISP_DEAD_PIXEL_CORRECTION + AVI_ISP_DEAD_PIXEL_CORRECTION_LIST_MEM, + AVI_ISP_DENOISING, + AVI_ISP_STATISTICS_BAYER, + AVI_ISP_LENS_SHADING_CORRECTION, + AVI_ISP_LENS_SHADING_CORRECTION + AVI_ISP_LENS_SHADING_CORRECTION_RED_COEFF_MEM, + AVI_ISP_LENS_SHADING_CORRECTION + AVI_ISP_LENS_SHADING_CORRECTION_GREEN_COEFF_MEM, + AVI_ISP_LENS_SHADING_CORRECTION + AVI_ISP_LENS_SHADING_CORRECTION_BLUE_COEFF_MEM, + AVI_ISP_CHROMATIC_ABERRATION, + AVI_ISP_BAYER, + AVI_ISP_COLOR_CORRECTION, + AVI_ISP_VLFORMAT_40TO32, + 0, /* GAMMA conf */ + AVI_ISP_GAMMA_CORRECTOR_RY_LUT, + AVI_ISP_GAMMA_CORRECTOR_GU_LUT, + AVI_ISP_GAMMA_CORRECTOR_BV_LUT, + 0, /* CHROMA */ + 0, /* STATS YUV*/ + AVI_ISP_STATISTICS_YUV_AE_HISTOGRAM_Y, + AVI_ISP_CHAIN_YUV_INTER, + AVI_ISP_EDGE_ENHANCEMENT_COLOR_REDUCTION_FILTER + AVI_ISP_EDGE_ENHANCEMENT_COLOR_REDUCTION_FILTER_EE_KERNEL_COEFF, + AVI_ISP_EDGE_ENHANCEMENT_COLOR_REDUCTION_FILTER + AVI_ISP_EDGE_ENHANCEMENT_COLOR_REDUCTION_FILTER_EE_LUT, + AVI_ISP_I3D_LUT + AVI_ISP_I3D_LUT_CLIP_MODE, + AVI_ISP_I3D_LUT + AVI_ISP_I3D_LUT_LUT_OUTSIDE, + AVI_ISP_I3D_LUT + AVI_ISP_I3D_LUT_LUT_INSIDE, + AVI_ISP_DROP, +}; + +/** + * This is taken from libisp. Original function takes the videodev name and re-opens it, + * causing undefined behaviour. Here we reuse the already-opened file descriptor + */ +static int avi_isp_get_offsets_fd(int fd, struct avi_isp_offsets *off) +{ + if (ioctl(fd, AVI_ISP_IOGET_OFFSETS, off) < 0) { + printf("sizeof: %d, %X\n", sizeof(struct avi_isp_offsets), AVI_ISP_IOGET_OFFSETS); + perror("ioctl(AVI_ISP_IOGET_OFFSETS) failed"); + return -1; + } + + return 0; +} + +/** + * This is taken from libisp. Original function takes the videodev name and re-opens it, + * causing undefined behaviour. Here we reuse the already-opened file descriptor + */ +static int open_isp_fd(struct libisp_context *ctx, int fd) +{ + struct avi_isp_offsets off; + int i; + + ctx->devmem = open("/dev/mem", O_RDWR); + + if (ctx->devmem < 0) { + perror("Can't open /dev/mem"); + goto open_failed; + } + + ctx->avi_base = (unsigned long) mmap(NULL, AVI_SIZE, + PROT_READ | PROT_WRITE, + MAP_SHARED, ctx->devmem, AVI_BASE & ~AVI_MASK); + + if (ctx->avi_base == (unsigned long) MAP_FAILED) { + perror("mmap failed"); + goto mmap_failed; + } + + if (avi_isp_get_offsets_fd(fd, &off) < 0) + goto get_offsets_failed; + + /* Compute all the sub-modules offsets */ + /* Chain Bayer */ + for (i = chain_bayer_inter ; i < gamma_corrector ; i++) + ctx->offsets[i] = ctx->avi_base + isp_bases[i] + off.chain_bayer; + + ctx->offsets[gamma_corrector] = ctx->avi_base + isp_bases[i++] + off.gamma_corrector; + ctx->offsets[gamma_corrector_ry_lut] = ctx->avi_base + isp_bases[i++] + off.gamma_corrector; + ctx->offsets[gamma_corrector_gu_lut] = ctx->avi_base + isp_bases[i++] + off.gamma_corrector; + ctx->offsets[gamma_corrector_bv_lut] = ctx->avi_base + isp_bases[i++] + off.gamma_corrector; + ctx->offsets[chroma] = ctx->avi_base + isp_bases[i++] + off.chroma; + ctx->offsets[statistics_yuv] = ctx->avi_base + isp_bases[i++] + off.statistics_yuv; + ctx->offsets[statistics_yuv_ae_histogram_y] = ctx->avi_base + isp_bases[i++] + off.statistics_yuv; + + /* Chain YUV */ + for (i = chain_yuv_inter ; i < ISP_NODE_NR ; i++) + ctx->offsets[i] = ctx->avi_base + isp_bases[i] + off.chain_yuv; + + return 0; + +get_offsets_failed: + munmap((void *) ctx->avi_base, AVI_SIZE); + +mmap_failed: + close(ctx->devmem); + +open_failed: + return -1; +} + +static int close_isp(struct libisp_context *ctx) +{ + int ret = 0; + + if (munmap((void *) ctx->avi_base, AVI_SIZE) == -1) { + perror("munmap failed"); + ret = -1; + } + + close(ctx->devmem); + + return ret; +} + +int configure_isp(struct v4l2_device *dev) +{ + struct libisp_context isp_ctx; + + struct avi_isp_chain_bayer_inter_regs bayer_inter = {{ + .pedestal_bypass = 1, + .grim_bypass = 1, + .rip_bypass = 1, + .denoise_bypass = 0, + .lsc_bypass = 1, + .chroma_aber_bypass = 1, + .bayer_bypass = 0, + .color_matrix_bypass = 0, + }}; + + struct avi_isp_vlformat_32to40_regs vlf_32to40 = {{ + .format = 0x0, + }}; + + struct avi_isp_bayer_regs bay = { + .cfa = { ._register = 0x03 }, + .threshold_1 = { ._register = 0x19 }, + .threshold_2 = { ._register = 0xc8 }, + }; + + struct avi_isp_color_correction_regs cc = { + .coeff_01_00 = { ._register = 0xF3811477 }, + .coeff_10_02 = { ._register = 0xFDF0021d }, + .coeff_12_11 = { ._register = 0xFF9E0A33 }, + .coeff_21_20 = { ._register = 0xF4DFFE25 }, + .coeff_22 = { ._register = 0x00001B83 }, + .offset_ry = { ._register = 0x00000000 }, + .clip_ry = { ._register = 0x03FF0000 }, + .offset_gu = { ._register = 0x00000000 }, + .clip_gu = { ._register = 0x03FF0000 }, + .offset_bv = { ._register = 0x00000000 }, + .clip_bv = { ._register = 0x03FF0000 }, + }; + + struct avi_isp_vlformat_40to32_regs vlf_40to32 = {{ + .format = 0x4, + }}; + +#define COMPLEMENT_2(i, r) (((i) >= 0) ? (r) : (~(r) + 1) & 0x3fff) +#define Q311(i) (COMPLEMENT_2(i, (unsigned)(((ABS(i)) * (1 << 11)) + 0.5))) + +/* + * Chroma converter parameters to convert input stream from a given + * color space to another. + * See http://www.fourcc.org/fccyvrgb.php + */ + +#define AVI_CONV_MATRIX(_c00, _c01, _c02, \ + _c10, _c11, _c12, \ + _c20, _c21, _c22) \ + .coeff_01_00 = {{ .coeff_00 = Q311(_c00), .coeff_01 = Q311(_c01) }}, \ + .coeff_10_02 = {{ .coeff_02 = Q311(_c02), .coeff_10 = Q311(_c10) }}, \ + .coeff_12_11 = {{ .coeff_11 = Q311(_c11), .coeff_12 = Q311(_c12) }}, \ + .coeff_21_20 = {{ .coeff_20 = Q311(_c20), .coeff_21 = Q311(_c21) }}, \ + .coeff_22 = {{ .coeff_22 = Q311(_c22) }} + +#define AVI_CONV_OFFSETS(_ryin, _ryout, \ + _guin, _guout, \ + _bvin, _bvout) \ + .offset_ry = {{ .offset_in = _ryin, .offset_out = _ryout }}, \ + .offset_gu = {{ .offset_in = _guin, .offset_out = _guout }}, \ + .offset_bv = {{ .offset_in = _bvin, .offset_out = _bvout }} + +#define AVI_CONV_CLIPS(_rymin, _rymax, \ + _gumin, _gumax, \ + _bvmin, _bvmax) \ + .clip_ry = {{ .clip_min = _rymin, .clip_max = _rymax }}, \ + .clip_gu = {{ .clip_min = _gumin, .clip_max = _gumax }}, \ + .clip_bv = {{ .clip_min = _bvmin, .clip_max = _bvmax }} + + + struct avi_isp_chroma_regs chr = { + AVI_CONV_MATRIX( 0.213, 0.715, 0.072, + -0.100, -0.336, 0.436, + 0.615, -0.515, -0.100), + + AVI_CONV_OFFSETS(0, 16, + 0, 128, + 0, 128), + + AVI_CONV_CLIPS(16, 235, + 16, 240, + 16, 240), + }; + + if(open_isp_fd(&isp_ctx, dev->fd) < 0) + return -1; + + avi_isp_chain_bayer_inter_set_registers(&isp_ctx, &bayer_inter); + avi_isp_vlformat_32to40_set_registers(&isp_ctx, &vlf_32to40); + avi_isp_bayer_set_registers(&isp_ctx, &bay); + avi_isp_color_correction_set_registers(&isp_ctx, &cc); + avi_isp_vlformat_40to32_set_registers(&isp_ctx, &vlf_40to32); + avi_isp_chroma_set_registers(&isp_ctx, &chr); + + close_isp(&isp_ctx); + + return 0; +} + + +static inline void memcpy_to_registers(unsigned long addr, + const void *reg_base, + size_t s) +{ + const uint32_t *reg = reg_base; + unsigned i; + + s /= sizeof(uint32_t); /* we write one register at a time */ + + for (i = 0; i < s; i++) + writel(reg[i], addr + i * sizeof(uint32_t)); +} + +static inline void memcpy_from_registers(void *reg_base, + unsigned long addr, + size_t s) +{ + uint32_t *reg = reg_base; + unsigned i; + + s /= sizeof(uint32_t); /* we read one register at a time */ + + for (i = 0; i < s; i++) + reg[i] = readl(addr + i * sizeof(uint32_t)); +} + +#define EXPAND_AS_FUNCTION(_node) \ + void avi_isp_ ## _node ## _set_registers(struct libisp_context *c, \ + struct avi_isp_ ## _node ## _regs const *regs) \ + { \ + memcpy_to_registers(c->offsets[_node], regs, sizeof(*regs)); \ + } \ + \ + void avi_isp_ ## _node ## _get_registers(struct libisp_context *c, \ + struct avi_isp_ ## _node ## _regs *regs) \ + { \ + memcpy_from_registers(regs, c->offsets[_node], sizeof(*regs)); \ + } + +AVI_DEFINE_NODE(EXPAND_AS_FUNCTION) diff --git a/sw/airborne/modules/computer_vision/lib/isp/libisp.h b/sw/airborne/modules/computer_vision/lib/isp/libisp.h new file mode 100644 index 0000000000..eb5af1fe6b --- /dev/null +++ b/sw/airborne/modules/computer_vision/lib/isp/libisp.h @@ -0,0 +1,68 @@ +#ifndef _LIBISP_H +#define _LIBISP_H + +#include "reg_avi.h" +#include "modules/computer_vision/lib/v4l/v4l2.h" + +#define AVI_DEFINE_NODE(EXPANDER) \ + EXPANDER(chain_bayer_inter) \ + EXPANDER(vlformat_32to40) \ + EXPANDER(pedestal) \ + EXPANDER(green_imbalance) \ + EXPANDER(green_imbalance_green_red_coeff_mem) \ + EXPANDER(green_imbalance_green_blue_coeff_mem) \ + EXPANDER(dead_pixel_correction) \ + EXPANDER(dead_pixel_correction_list_mem) \ + EXPANDER(denoising) \ + EXPANDER(statistics_bayer) \ + EXPANDER(lens_shading_correction) \ + EXPANDER(lens_shading_correction_red_coeff_mem) \ + EXPANDER(lens_shading_correction_green_coeff_mem) \ + EXPANDER(lens_shading_correction_blue_coeff_mem) \ + EXPANDER(chromatic_aberration) \ + EXPANDER(bayer) \ + EXPANDER(color_correction) \ + EXPANDER(vlformat_40to32) \ + EXPANDER(gamma_corrector) \ + EXPANDER(gamma_corrector_ry_lut) \ + EXPANDER(gamma_corrector_gu_lut) \ + EXPANDER(gamma_corrector_bv_lut) \ + EXPANDER(chroma) \ + EXPANDER(statistics_yuv) \ + EXPANDER(statistics_yuv_ae_histogram_y) \ + EXPANDER(chain_yuv_inter) \ + EXPANDER(edge_enhancement_color_reduction_filter) \ + EXPANDER(edge_enhancement_color_reduction_filter_ee_lut) \ + EXPANDER(i3d_lut) \ + EXPANDER(i3d_lut_lut_outside) \ + EXPANDER(i3d_lut_lut_inside) \ + EXPANDER(drop) + +#define EXPAND_AS_ENUM(_node) \ + _node, + +enum { + AVI_DEFINE_NODE(EXPAND_AS_ENUM) + ISP_NODE_NR, +}; + +/* ISP Context */ +struct libisp_context +{ + int devmem; + unsigned long avi_base; + unsigned offsets[ISP_NODE_NR]; +}; + +int configure_isp(struct v4l2_device *dev); + +/* Registers access */ +#define EXPAND_AS_PROTOTYPE(_node) \ + void avi_isp_ ## _node ## _set_registers(struct libisp_context *, \ + struct avi_isp_ ## _node ## _regs const *regs); \ + void avi_isp_ ## _node ## _get_registers(struct libisp_context *, \ + struct avi_isp_ ## _node ## _regs *regs); + +AVI_DEFINE_NODE(EXPAND_AS_PROTOTYPE) + +#endif /* _LIBISP_H */ diff --git a/sw/airborne/modules/computer_vision/lib/isp/reg_avi.h b/sw/airborne/modules/computer_vision/lib/isp/reg_avi.h new file mode 100644 index 0000000000..2c15fb8725 --- /dev/null +++ b/sw/airborne/modules/computer_vision/lib/isp/reg_avi.h @@ -0,0 +1,51 @@ +#ifndef _REG_AVI_H +#define _REG_AVI_H + +#include + +/* Chain Bayer */ +#include "regmap/avi_isp_vlformat_32to40.h" +#include "regmap/avi_isp_chain_bayer_inter.h" +#include "regmap/avi_isp_pedestal.h" +#include "regmap/avi_isp_green_imbalance.h" +#include "regmap/avi_isp_dead_pixel_correction.h" +#include "regmap/avi_isp_statistics_bayer.h" +#include "regmap/avi_isp_denoising.h" +#include "regmap/avi_isp_lens_shading_correction.h" +#include "regmap/avi_isp_chromatic_aberration.h" +#include "regmap/avi_isp_bayer.h" +#include "regmap/avi_isp_color_correction.h" +#include "regmap/avi_isp_vlformat_40to32.h" + +/* Gamma + CSC */ +#include "regmap/avi_isp_gamma_corrector.h" +#include "regmap/avi_isp_chroma.h" +#include "regmap/avi_isp_statistics_yuv.h" + +/* Chain YUV */ +#include "regmap/avi_isp_chain_yuv_inter.h" +#include "regmap/avi_isp_edge_enhancement_color_reduction_filter.h" +#include "regmap/avi_isp_i3d_lut.h" +#include "regmap/avi_isp_drop.h" + +/* Sub modules of chain Bayer */ +#define AVI_ISP_CHAIN_BAYER_INTER 0x0000 +#define AVI_ISP_VLFORMAT_32TO40 0x1000 +#define AVI_ISP_PEDESTAL 0x2000 +#define AVI_ISP_GREEN_IMBALANCE 0x4000 +#define AVI_ISP_DEAD_PIXEL_CORRECTION 0x6000 +#define AVI_ISP_DENOISING 0x7000 +#define AVI_ISP_STATISTICS_BAYER 0x8000 +#define AVI_ISP_LENS_SHADING_CORRECTION 0xA000 +#define AVI_ISP_CHROMATIC_ABERRATION 0xC000 +#define AVI_ISP_BAYER 0xD000 +#define AVI_ISP_COLOR_CORRECTION 0xE000 +#define AVI_ISP_VLFORMAT_40TO32 0xF000 + +/* Sub modules of chain YUV */ +#define AVI_ISP_CHAIN_YUV_INTER 0x0000 +#define AVI_ISP_EDGE_ENHANCEMENT_COLOR_REDUCTION_FILTER 0x1000 +#define AVI_ISP_I3D_LUT 0x2000 +#define AVI_ISP_DROP 0x3000 + +#endif /* _REG_AVI_H */ diff --git a/sw/airborne/modules/computer_vision/lib/isp/regmap/avi_isp_bayer.h b/sw/airborne/modules/computer_vision/lib/isp/regmap/avi_isp_bayer.h new file mode 100644 index 0000000000..99d3a1b1fa --- /dev/null +++ b/sw/airborne/modules/computer_vision/lib/isp/regmap/avi_isp_bayer.h @@ -0,0 +1,55 @@ +/********************************************************************* + * avi_isp_bayer register map + * + * Vendor: Parrot + * Library: AVI + * Version: P7R3 + * Gen-date: (Date of generation of this C code, not the IP-Xact file) + * 2014-02-28 + * + * WARNING: This code is automatically generated from the hardware + * IP-Xact XML files. Do not edit directly. + *********************************************************************/ + +#ifndef _AVI_ISP_BAYER_H_ +#define _AVI_ISP_BAYER_H_ + +#define AVI_ISP_BAYER_CFA 0x00 +#define AVI_ISP_BAYER_THRESHOLD_1 0x04 +#define AVI_ISP_BAYER_THRESHOLD_2 0x08 + +union avi_isp_bayer_cfa +{ + struct + { + uint32_t cfa : 2; + }; + uint32_t _register; +}; + +union avi_isp_bayer_threshold_1 +{ + struct + { + uint32_t threshold_1 : 13; + }; + uint32_t _register; +}; + +union avi_isp_bayer_threshold_2 +{ + struct + { + uint32_t threshold_2 : 13; + }; + uint32_t _register; +}; + +struct avi_isp_bayer_regs +{ + union avi_isp_bayer_cfa cfa; /* 0x000 */ + union avi_isp_bayer_threshold_1 threshold_1; /* 0x004 */ + union avi_isp_bayer_threshold_2 threshold_2; /* 0x008 */ +}; + +#endif /* _AVI_ISP_BAYER_H_ */ diff --git a/sw/airborne/modules/computer_vision/lib/isp/regmap/avi_isp_chain_bayer_inter.h b/sw/airborne/modules/computer_vision/lib/isp/regmap/avi_isp_chain_bayer_inter.h new file mode 100644 index 0000000000..00c37166fa --- /dev/null +++ b/sw/airborne/modules/computer_vision/lib/isp/regmap/avi_isp_chain_bayer_inter.h @@ -0,0 +1,40 @@ +/********************************************************************* + * avi_isp_chain_bayer_inter register map + * + * Vendor: Parrot + * Library: AVI + * Version: P7R3 + * Gen-date: (Date of generation of this C code, not the IP-Xact file) + * 2014-02-28 + * + * WARNING: This code is automatically generated from the hardware + * IP-Xact XML files. Do not edit directly. + *********************************************************************/ + +#ifndef _AVI_ISP_CHAIN_BAYER_INTER_H_ +#define _AVI_ISP_CHAIN_BAYER_INTER_H_ + +#define AVI_ISP_CHAIN_BAYER_INTER_MODULE_BYPASS 0x00 + +union avi_isp_chain_bayer_inter_module_bypass +{ + struct + { + uint32_t pedestal_bypass : 1; + uint32_t grim_bypass : 1; + uint32_t rip_bypass : 1; + uint32_t denoise_bypass : 1; + uint32_t lsc_bypass : 1; + uint32_t chroma_aber_bypass : 1; + uint32_t bayer_bypass : 1; + uint32_t color_matrix_bypass : 1; + }; + uint32_t _register; +}; + +struct avi_isp_chain_bayer_inter_regs +{ + union avi_isp_chain_bayer_inter_module_bypass module_bypass; /* 0x000 */ +}; + +#endif /* _AVI_ISP_CHAIN_BAYER_INTER_H_ */ diff --git a/sw/airborne/modules/computer_vision/lib/isp/regmap/avi_isp_chain_yuv_inter.h b/sw/airborne/modules/computer_vision/lib/isp/regmap/avi_isp_chain_yuv_inter.h new file mode 100644 index 0000000000..e6dcee34dd --- /dev/null +++ b/sw/airborne/modules/computer_vision/lib/isp/regmap/avi_isp_chain_yuv_inter.h @@ -0,0 +1,35 @@ +/********************************************************************* + * avi_isp_chain_yuv_inter register map + * + * Vendor: Parrot + * Library: AVI + * Version: P7R3 + * Gen-date: (Date of generation of this C code, not the IP-Xact file) + * 2014-02-28 + * + * WARNING: This code is automatically generated from the hardware + * IP-Xact XML files. Do not edit directly. + *********************************************************************/ + +#ifndef _AVI_ISP_CHAIN_YUV_INTER_H_ +#define _AVI_ISP_CHAIN_YUV_INTER_H_ + +#define AVI_ISP_CHAIN_YUV_INTER_MODULE_BYPASS 0x00 + +union avi_isp_chain_yuv_inter_module_bypass +{ + struct + { + uint32_t ee_crf_bypass : 1; + uint32_t i3d_lut_bypass : 1; + uint32_t drop_bypass : 1; + }; + uint32_t _register; +}; + +struct avi_isp_chain_yuv_inter_regs +{ + union avi_isp_chain_yuv_inter_module_bypass module_bypass; /* 0x000 */ +}; + +#endif /* _AVI_ISP_CHAIN_YUV_INTER_H_ */ diff --git a/sw/airborne/modules/computer_vision/lib/isp/regmap/avi_isp_chroma.h b/sw/airborne/modules/computer_vision/lib/isp/regmap/avi_isp_chroma.h new file mode 100644 index 0000000000..84fc073eb6 --- /dev/null +++ b/sw/airborne/modules/computer_vision/lib/isp/regmap/avi_isp_chroma.h @@ -0,0 +1,163 @@ +/********************************************************************* + * avi_isp_chroma register map + * + * Vendor: Parrot + * Library: AVI + * Version: P7R3 + * Gen-date: (Date of generation of this C code, not the IP-Xact file) + * 2014-02-28 + * + * WARNING: This code is automatically generated from the hardware + * IP-Xact XML files. Do not edit directly. + *********************************************************************/ + +#ifndef _AVI_ISP_CHROMA_H_ +#define _AVI_ISP_CHROMA_H_ + +#define AVI_ISP_CHROMA_COEFF_01_00 0x00 +#define AVI_ISP_CHROMA_COEFF_10_02 0x04 +#define AVI_ISP_CHROMA_COEFF_12_11 0x08 +#define AVI_ISP_CHROMA_COEFF_21_20 0x0c +#define AVI_ISP_CHROMA_COEFF_22 0x10 +#define AVI_ISP_CHROMA_OFFSET_RY 0x14 +#define AVI_ISP_CHROMA_CLIP_RY 0x18 +#define AVI_ISP_CHROMA_OFFSET_GU 0x1c +#define AVI_ISP_CHROMA_CLIP_GU 0x20 +#define AVI_ISP_CHROMA_OFFSET_BV 0x24 +#define AVI_ISP_CHROMA_CLIP_BV 0x28 + +union avi_isp_chroma_coeff_01_00 +{ + struct + { + uint32_t coeff_00 : 14; + unsigned /*unused */ : 2; + uint32_t coeff_01 : 14; + }; + uint32_t _register; +}; + +union avi_isp_chroma_coeff_10_02 +{ + struct + { + uint32_t coeff_02 : 14; + unsigned /*unused */ : 2; + uint32_t coeff_10 : 14; + }; + uint32_t _register; +}; + +union avi_isp_chroma_coeff_12_11 +{ + struct + { + uint32_t coeff_11 : 14; + unsigned /*unused */ : 2; + uint32_t coeff_12 : 14; + }; + uint32_t _register; +}; + +union avi_isp_chroma_coeff_21_20 +{ + struct + { + uint32_t coeff_20 : 14; + unsigned /*unused */ : 2; + uint32_t coeff_21 : 14; + }; + uint32_t _register; +}; + +union avi_isp_chroma_coeff_22 +{ + struct + { + uint32_t coeff_22 : 14; + }; + uint32_t _register; +}; + +union avi_isp_chroma_offset_ry +{ + struct + { + uint32_t offset_in : 10; + unsigned /*unused */ : 6; + uint32_t offset_out : 10; + }; + uint32_t _register; +}; + +union avi_isp_chroma_clip_ry +{ + struct + { + uint32_t clip_min : 10; + unsigned /*unused */ : 6; + uint32_t clip_max : 10; + }; + uint32_t _register; +}; + +union avi_isp_chroma_offset_gu +{ + struct + { + uint32_t offset_in : 10; + unsigned /*unused */ : 6; + uint32_t offset_out : 10; + }; + uint32_t _register; +}; + +union avi_isp_chroma_clip_gu +{ + struct + { + uint32_t clip_min : 10; + unsigned /*unused */ : 6; + uint32_t clip_max : 10; + }; + uint32_t _register; +}; + +union avi_isp_chroma_offset_bv +{ + struct + { + uint32_t offset_in : 10; + unsigned /*unused */ : 6; + uint32_t offset_out : 10; + }; + uint32_t _register; +}; + +union avi_isp_chroma_clip_bv +{ + struct + { + uint32_t clip_min : 10; + unsigned /*unused */ : 6; + uint32_t clip_max : 10; + }; + uint32_t _register; +}; + +struct avi_isp_chroma_regs +{ + union avi_isp_chroma_coeff_01_00 coeff_01_00; /* 0x000 */ + union avi_isp_chroma_coeff_10_02 coeff_10_02; /* 0x004 */ + union avi_isp_chroma_coeff_12_11 coeff_12_11; /* 0x008 */ + union avi_isp_chroma_coeff_21_20 coeff_21_20; /* 0x00c */ + union avi_isp_chroma_coeff_22 coeff_22; /* 0x010 */ + union avi_isp_chroma_offset_ry offset_ry; /* 0x014 */ + union avi_isp_chroma_clip_ry clip_ry; /* 0x018 */ + union avi_isp_chroma_offset_gu offset_gu; /* 0x01c */ + union avi_isp_chroma_clip_gu clip_gu; /* 0x020 */ + union avi_isp_chroma_offset_bv offset_bv; /* 0x024 */ + union avi_isp_chroma_clip_bv clip_bv; /* 0x028 */ +}; + +#endif /* _AVI_ISP_CHROMA_H_ */ diff --git a/sw/airborne/modules/computer_vision/lib/isp/regmap/avi_isp_chromatic_aberration.h b/sw/airborne/modules/computer_vision/lib/isp/regmap/avi_isp_chromatic_aberration.h new file mode 100644 index 0000000000..9efb78c363 --- /dev/null +++ b/sw/airborne/modules/computer_vision/lib/isp/regmap/avi_isp_chromatic_aberration.h @@ -0,0 +1,162 @@ +/********************************************************************* + * avi_isp_chromatic_aberration register map + * + * Vendor: Parrot + * Library: AVI + * Version: P7R3 + * Gen-date: (Date of generation of this C code, not the IP-Xact file) + * 2014-02-28 + * + * WARNING: This code is automatically generated from the hardware + * IP-Xact XML files. Do not edit directly. + *********************************************************************/ + +#ifndef _AVI_ISP_CHROMATIC_ABERRATION_H_ +#define _AVI_ISP_CHROMATIC_ABERRATION_H_ + +#define AVI_ISP_CHROMATIC_ABERRATION_RADIUS_SQUARED 0x00 +#define AVI_ISP_CHROMATIC_ABERRATION_DISPLACEMENT_COEFFS 0x04 +#define AVI_ISP_CHROMATIC_ABERRATION_CIRCLE_POS_X_CENTER 0xa0 +#define AVI_ISP_CHROMATIC_ABERRATION_CIRCLE_POS_X_SQUARED 0xa4 +#define AVI_ISP_CHROMATIC_ABERRATION_CIRCLE_POS_Y_CENTER 0xa8 +#define AVI_ISP_CHROMATIC_ABERRATION_CIRCLE_POS_Y_SQUARED 0xac +#define AVI_ISP_CHROMATIC_ABERRATION_CFA 0xb0 +#define AVI_ISP_CHROMATIC_ABERRATION_GREEN_VARIATION 0xb4 +#define AVI_ISP_CHROMATIC_ABERRATION_INCREMENTS_LOG2 0xb8 + +union avi_isp_chromatic_aberration_radius_squared +{ + struct + { + uint32_t radius_squared : 24; + }; + uint32_t _register; +}; + +union avi_isp_chromatic_aberration_displacement_coeffs +{ + struct + { + uint32_t displacement_blue : 16; + uint32_t displacement_red : 16; + }; + uint32_t _register; +}; + +union avi_isp_chromatic_aberration_circle_pos_x_center +{ + struct + { + uint32_t x_center : 14; + }; + uint32_t _register; +}; + +union avi_isp_chromatic_aberration_circle_pos_x_squared +{ + struct + { + uint32_t x_squared : 26; + }; + uint32_t _register; +}; + +union avi_isp_chromatic_aberration_circle_pos_y_center +{ + struct + { + uint32_t y_center : 14; + }; + uint32_t _register; +}; + +union avi_isp_chromatic_aberration_circle_pos_y_squared +{ + struct + { + uint32_t y_squared : 26; + }; + uint32_t _register; +}; + +union avi_isp_chromatic_aberration_cfa +{ + struct + { + uint32_t cfa : 2; + }; + uint32_t _register; +}; + +union avi_isp_chromatic_aberration_green_variation +{ + struct + { + uint32_t green_var : 1; + }; + uint32_t _register; +}; + +union avi_isp_chromatic_aberration_increments_log2 +{ + struct + { + uint32_t x_log2_inc : 3; + unsigned /*unused */ : 13; + uint32_t y_log2_inc : 3; + }; + uint32_t _register; +}; + +struct avi_isp_chromatic_aberration_regs +{ + union avi_isp_chromatic_aberration_radius_squared radius_squared; /* 0x000 */ + union avi_isp_chromatic_aberration_displacement_coeffs displacement_coeffs; /* 0x004 */ + unsigned /*unused*/ : 32; /* 0x008 */ + unsigned /*unused*/ : 32; /* 0x00c */ + unsigned /*unused*/ : 32; /* 0x010 */ + unsigned /*unused*/ : 32; /* 0x014 */ + unsigned /*unused*/ : 32; /* 0x018 */ + unsigned /*unused*/ : 32; /* 0x01c */ + unsigned /*unused*/ : 32; /* 0x020 */ + unsigned /*unused*/ : 32; /* 0x024 */ + unsigned /*unused*/ : 32; /* 0x028 */ + unsigned /*unused*/ : 32; /* 0x02c */ + unsigned /*unused*/ : 32; /* 0x030 */ + unsigned /*unused*/ : 32; /* 0x034 */ + unsigned /*unused*/ : 32; /* 0x038 */ + unsigned /*unused*/ : 32; /* 0x03c */ + unsigned /*unused*/ : 32; /* 0x040 */ + unsigned /*unused*/ : 32; /* 0x044 */ + unsigned /*unused*/ : 32; /* 0x048 */ + unsigned /*unused*/ : 32; /* 0x04c */ + unsigned /*unused*/ : 32; /* 0x050 */ + unsigned /*unused*/ : 32; /* 0x054 */ + unsigned /*unused*/ : 32; /* 0x058 */ + unsigned /*unused*/ : 32; /* 0x05c */ + unsigned /*unused*/ : 32; /* 0x060 */ + unsigned /*unused*/ : 32; /* 0x064 */ + unsigned /*unused*/ : 32; /* 0x068 */ + unsigned /*unused*/ : 32; /* 0x06c */ + unsigned /*unused*/ : 32; /* 0x070 */ + unsigned /*unused*/ : 32; /* 0x074 */ + unsigned /*unused*/ : 32; /* 0x078 */ + unsigned /*unused*/ : 32; /* 0x07c */ + unsigned /*unused*/ : 32; /* 0x080 */ + unsigned /*unused*/ : 32; /* 0x084 */ + unsigned /*unused*/ : 32; /* 0x088 */ + unsigned /*unused*/ : 32; /* 0x08c */ + unsigned /*unused*/ : 32; /* 0x090 */ + unsigned /*unused*/ : 32; /* 0x094 */ + unsigned /*unused*/ : 32; /* 0x098 */ + unsigned /*unused*/ : 32; /* 0x09c */ + union avi_isp_chromatic_aberration_circle_pos_x_center circle_pos_x_center; /* 0x0a0 */ + union avi_isp_chromatic_aberration_circle_pos_x_squared circle_pos_x_squared; /* 0x0a4 */ + union avi_isp_chromatic_aberration_circle_pos_y_center circle_pos_y_center; /* 0x0a8 */ + union avi_isp_chromatic_aberration_circle_pos_y_squared circle_pos_y_squared; /* 0x0ac */ + union avi_isp_chromatic_aberration_cfa cfa; /* 0x0b0 */ + union avi_isp_chromatic_aberration_green_variation green_variation; /* 0x0b4 */ + union avi_isp_chromatic_aberration_increments_log2 increments_log2; /* 0x0b8 */ +}; + +#endif /* _AVI_ISP_CHROMATIC_ABERRATION_H_ */ diff --git a/sw/airborne/modules/computer_vision/lib/isp/regmap/avi_isp_color_correction.h b/sw/airborne/modules/computer_vision/lib/isp/regmap/avi_isp_color_correction.h new file mode 100644 index 0000000000..adfb30425f --- /dev/null +++ b/sw/airborne/modules/computer_vision/lib/isp/regmap/avi_isp_color_correction.h @@ -0,0 +1,163 @@ +/********************************************************************* + * avi_isp_color_correction register map + * + * Vendor: Parrot + * Library: AVI + * Version: P7R3 + * Gen-date: (Date of generation of this C code, not the IP-Xact file) + * 2014-02-28 + * + * WARNING: This code is automatically generated from the hardware + * IP-Xact XML files. Do not edit directly. + *********************************************************************/ + +#ifndef _AVI_ISP_COLOR_CORRECTION_H_ +#define _AVI_ISP_COLOR_CORRECTION_H_ + +#define AVI_ISP_COLOR_CORRECTION_COEFF_01_00 0x00 +#define AVI_ISP_COLOR_CORRECTION_COEFF_10_02 0x04 +#define AVI_ISP_COLOR_CORRECTION_COEFF_12_11 0x08 +#define AVI_ISP_COLOR_CORRECTION_COEFF_21_20 0x0c +#define AVI_ISP_COLOR_CORRECTION_COEFF_22 0x10 +#define AVI_ISP_COLOR_CORRECTION_OFFSET_RY 0x14 +#define AVI_ISP_COLOR_CORRECTION_CLIP_RY 0x18 +#define AVI_ISP_COLOR_CORRECTION_OFFSET_GU 0x1c +#define AVI_ISP_COLOR_CORRECTION_CLIP_GU 0x20 +#define AVI_ISP_COLOR_CORRECTION_OFFSET_BV 0x24 +#define AVI_ISP_COLOR_CORRECTION_CLIP_BV 0x28 + +union avi_isp_color_correction_coeff_01_00 +{ + struct + { + uint32_t coeff_00 : 14; + unsigned /*unused */ : 2; + uint32_t coeff_01 : 14; + }; + uint32_t _register; +}; + +union avi_isp_color_correction_coeff_10_02 +{ + struct + { + uint32_t coeff_02 : 14; + unsigned /*unused */ : 2; + uint32_t coeff_10 : 14; + }; + uint32_t _register; +}; + +union avi_isp_color_correction_coeff_12_11 +{ + struct + { + uint32_t coeff_11 : 14; + unsigned /*unused */ : 2; + uint32_t coeff_12 : 14; + }; + uint32_t _register; +}; + +union avi_isp_color_correction_coeff_21_20 +{ + struct + { + uint32_t coeff_20 : 14; + unsigned /*unused */ : 2; + uint32_t coeff_21 : 14; + }; + uint32_t _register; +}; + +union avi_isp_color_correction_coeff_22 +{ + struct + { + uint32_t coeff_22 : 14; + }; + uint32_t _register; +}; + +union avi_isp_color_correction_offset_ry +{ + struct + { + uint32_t offset_in : 10; + unsigned /*unused */ : 6; + uint32_t offset_out : 10; + }; + uint32_t _register; +}; + +union avi_isp_color_correction_clip_ry +{ + struct + { + uint32_t clip_min : 10; + unsigned /*unused */ : 6; + uint32_t clip_max : 10; + }; + uint32_t _register; +}; + +union avi_isp_color_correction_offset_gu +{ + struct + { + uint32_t offset_in : 10; + unsigned /*unused */ : 6; + uint32_t offset_out : 10; + }; + uint32_t _register; +}; + +union avi_isp_color_correction_clip_gu +{ + struct + { + uint32_t clip_min : 10; + unsigned /*unused */ : 6; + uint32_t clip_max : 10; + }; + uint32_t _register; +}; + +union avi_isp_color_correction_offset_bv +{ + struct + { + uint32_t offset_in : 10; + unsigned /*unused */ : 6; + uint32_t offset_out : 10; + }; + uint32_t _register; +}; + +union avi_isp_color_correction_clip_bv +{ + struct + { + uint32_t clip_min : 10; + unsigned /*unused */ : 6; + uint32_t clip_max : 10; + }; + uint32_t _register; +}; + +struct avi_isp_color_correction_regs +{ + union avi_isp_color_correction_coeff_01_00 coeff_01_00; /* 0x000 */ + union avi_isp_color_correction_coeff_10_02 coeff_10_02; /* 0x004 */ + union avi_isp_color_correction_coeff_12_11 coeff_12_11; /* 0x008 */ + union avi_isp_color_correction_coeff_21_20 coeff_21_20; /* 0x00c */ + union avi_isp_color_correction_coeff_22 coeff_22; /* 0x010 */ + union avi_isp_color_correction_offset_ry offset_ry; /* 0x014 */ + union avi_isp_color_correction_clip_ry clip_ry; /* 0x018 */ + union avi_isp_color_correction_offset_gu offset_gu; /* 0x01c */ + union avi_isp_color_correction_clip_gu clip_gu; /* 0x020 */ + union avi_isp_color_correction_offset_bv offset_bv; /* 0x024 */ + union avi_isp_color_correction_clip_bv clip_bv; /* 0x028 */ +}; + +#endif /* _AVI_ISP_COLOR_CORRECTION_H_ */ diff --git a/sw/airborne/modules/computer_vision/lib/isp/regmap/avi_isp_dead_pixel_correction.h b/sw/airborne/modules/computer_vision/lib/isp/regmap/avi_isp_dead_pixel_correction.h new file mode 100644 index 0000000000..930cc2cbe4 --- /dev/null +++ b/sw/airborne/modules/computer_vision/lib/isp/regmap/avi_isp_dead_pixel_correction.h @@ -0,0 +1,100 @@ +/********************************************************************* + * avi_isp_dead_pixel_correction register map + * + * Vendor: Parrot + * Library: AVI + * Version: P7R3 + * Gen-date: (Date of generation of this C code, not the IP-Xact file) + * 2014-02-28 + * + * WARNING: This code is automatically generated from the hardware + * IP-Xact XML files. Do not edit directly. + *********************************************************************/ + +#ifndef _AVI_ISP_DEAD_PIXEL_CORRECTION_H_ +#define _AVI_ISP_DEAD_PIXEL_CORRECTION_H_ + +#define AVI_ISP_DEAD_PIXEL_CORRECTION_LIST_MEM 0x00 + +union avi_isp_dead_pixel_correction_list_mem +{ + struct + { + uint32_t op_code : 3; + uint32_t coord_x : 11; + uint32_t coord_y : 12; + }; + uint32_t _register; +}; + +struct avi_isp_dead_pixel_correction_list_mem_regs +{ + union avi_isp_dead_pixel_correction_list_mem list_mem[256]; +}; + +#define AVI_ISP_DEAD_PIXEL_CORRECTION_CFA 0x400 +#define AVI_ISP_DEAD_PIXEL_CORRECTION_BYPASS 0x404 +#define AVI_ISP_DEAD_PIXEL_CORRECTION_THRESHOLD 0x408 +#define AVI_ISP_DEAD_PIXEL_CORRECTION_RGRIM_CONF 0x40c +#define AVI_ISP_DEAD_PIXEL_CORRECTION_RGRIM_GAIN 0x410 + +union avi_isp_dead_pixel_correction_cfa +{ + struct + { + uint32_t cfa : 2; + }; + uint32_t _register; +}; + +union avi_isp_dead_pixel_correction_bypass +{ + struct + { + uint32_t list : 1; + uint32_t auto_detection : 1; + uint32_t rgrim : 1; + }; + uint32_t _register; +}; + +union avi_isp_dead_pixel_correction_threshold +{ + struct + { + uint32_t threshold : 10; + }; + uint32_t _register; +}; + +union avi_isp_dead_pixel_correction_rgrim_conf +{ + struct + { + uint32_t tim_1 : 8; + uint32_t tim_2 : 8; + uint32_t tsat : 8; + uint32_t tcon : 8; + }; + uint32_t _register; +}; + +union avi_isp_dead_pixel_correction_rgrim_gain +{ + struct + { + uint32_t gain : 7; + }; + uint32_t _register; +}; + +struct avi_isp_dead_pixel_correction_regs +{ + union avi_isp_dead_pixel_correction_cfa cfa; /* 0x400 */ + union avi_isp_dead_pixel_correction_bypass bypass; /* 0x404 */ + union avi_isp_dead_pixel_correction_threshold threshold; /* 0x408 */ + union avi_isp_dead_pixel_correction_rgrim_conf rgrim_conf; /* 0x40c */ + union avi_isp_dead_pixel_correction_rgrim_gain rgrim_gain; /* 0x410 */ +}; + +#endif /* _AVI_ISP_DEAD_PIXEL_CORRECTION_H_ */ diff --git a/sw/airborne/modules/computer_vision/lib/isp/regmap/avi_isp_denoising.h b/sw/airborne/modules/computer_vision/lib/isp/regmap/avi_isp_denoising.h new file mode 100644 index 0000000000..d0d726bff3 --- /dev/null +++ b/sw/airborne/modules/computer_vision/lib/isp/regmap/avi_isp_denoising.h @@ -0,0 +1,198 @@ +/********************************************************************* + * avi_isp_denoising register map + * + * Vendor: Parrot + * Library: AVI + * Version: P7R3 + * Gen-date: (Date of generation of this C code, not the IP-Xact file) + * 2014-02-28 + * + * WARNING: This code is automatically generated from the hardware + * IP-Xact XML files. Do not edit directly. + *********************************************************************/ + +#ifndef _AVI_ISP_DENOISING_H_ +#define _AVI_ISP_DENOISING_H_ + +#define AVI_ISP_DENOISING_CFA 0x00 +#define AVI_ISP_DENOISING_LUMOCOEFF_R_03_00 0x10 +#define AVI_ISP_DENOISING_LUMOCOEFF_R_07_04 0x14 +#define AVI_ISP_DENOISING_LUMOCOEFF_R_11_08 0x18 +#define AVI_ISP_DENOISING_LUMOCOEFF_R_13_12 0x1c +#define AVI_ISP_DENOISING_LUMOCOEFF_B_03_00 0x20 +#define AVI_ISP_DENOISING_LUMOCOEFF_B_07_04 0x24 +#define AVI_ISP_DENOISING_LUMOCOEFF_B_11_08 0x28 +#define AVI_ISP_DENOISING_LUMOCOEFF_B_13_12 0x2c +#define AVI_ISP_DENOISING_LUMOCOEFF_G_03_00 0x30 +#define AVI_ISP_DENOISING_LUMOCOEFF_G_07_04 0x34 +#define AVI_ISP_DENOISING_LUMOCOEFF_G_11_08 0x38 +#define AVI_ISP_DENOISING_LUMOCOEFF_G_13_12 0x3c + +union avi_isp_denoising_cfa +{ + struct + { + uint32_t cfa : 2; + }; + uint32_t _register; +}; + +union avi_isp_denoising_lumocoeff_r_03_00 +{ + struct + { + uint32_t lumocoeff_r_00 : 8; + uint32_t lumocoeff_r_01 : 8; + uint32_t lumocoeff_r_02 : 8; + uint32_t lumocoeff_r_03 : 8; + }; + uint32_t _register; +}; + +union avi_isp_denoising_lumocoeff_r_07_04 +{ + struct + { + uint32_t lumocoeff_r_04 : 8; + uint32_t lumocoeff_r_05 : 8; + uint32_t lumocoeff_r_06 : 8; + uint32_t lumocoeff_r_07 : 8; + }; + uint32_t _register; +}; + +union avi_isp_denoising_lumocoeff_r_11_08 +{ + struct + { + uint32_t lumocoeff_r_08 : 8; + uint32_t lumocoeff_r_09 : 8; + uint32_t lumocoeff_r_10 : 8; + uint32_t lumocoeff_r_11 : 8; + }; + uint32_t _register; +}; + +union avi_isp_denoising_lumocoeff_r_13_12 +{ + struct + { + uint32_t lumocoeff_r_12 : 8; + uint32_t lumocoeff_r_13 : 8; + }; + uint32_t _register; +}; + +union avi_isp_denoising_lumocoeff_b_03_00 +{ + struct + { + uint32_t lumocoeff_b_00 : 8; + uint32_t lumocoeff_b_01 : 8; + uint32_t lumocoeff_b_02 : 8; + uint32_t lumocoeff_b_03 : 8; + }; + uint32_t _register; +}; + +union avi_isp_denoising_lumocoeff_b_07_04 +{ + struct + { + uint32_t lumocoeff_b_04 : 8; + uint32_t lumocoeff_b_05 : 8; + uint32_t lumocoeff_b_06 : 8; + uint32_t lumocoeff_b_07 : 8; + }; + uint32_t _register; +}; + +union avi_isp_denoising_lumocoeff_b_11_08 +{ + struct + { + uint32_t lumocoeff_b_08 : 8; + uint32_t lumocoeff_b_09 : 8; + uint32_t lumocoeff_b_10 : 8; + uint32_t lumocoeff_b_11 : 8; + }; + uint32_t _register; +}; + +union avi_isp_denoising_lumocoeff_b_13_12 +{ + struct + { + uint32_t lumocoeff_b_12 : 8; + uint32_t lumocoeff_b_13 : 8; + }; + uint32_t _register; +}; + +union avi_isp_denoising_lumocoeff_g_03_00 +{ + struct + { + uint32_t lumocoeff_g_00 : 8; + uint32_t lumocoeff_g_01 : 8; + uint32_t lumocoeff_g_02 : 8; + uint32_t lumocoeff_g_03 : 8; + }; + uint32_t _register; +}; + +union avi_isp_denoising_lumocoeff_g_07_04 +{ + struct + { + uint32_t lumocoeff_g_04 : 8; + uint32_t lumocoeff_g_05 : 8; + uint32_t lumocoeff_g_06 : 8; + uint32_t lumocoeff_g_07 : 8; + }; + uint32_t _register; +}; + +union avi_isp_denoising_lumocoeff_g_11_08 +{ + struct + { + uint32_t lumocoeff_g_08 : 8; + uint32_t lumocoeff_g_09 : 8; + uint32_t lumocoeff_g_10 : 8; + uint32_t lumocoeff_g_11 : 8; + }; + uint32_t _register; +}; + +union avi_isp_denoising_lumocoeff_g_13_12 +{ + struct + { + uint32_t lumocoeff_g_12 : 8; + uint32_t lumocoeff_g_13 : 8; + }; + uint32_t _register; +}; + +struct avi_isp_denoising_regs +{ + union avi_isp_denoising_cfa cfa; /* 0x000 */ + unsigned /*unused*/ : 32; /* 0x004 */ + unsigned /*unused*/ : 32; /* 0x008 */ + unsigned /*unused*/ : 32; /* 0x00c */ + union avi_isp_denoising_lumocoeff_r_03_00 lumocoeff_r_03_00; /* 0x010 */ + union avi_isp_denoising_lumocoeff_r_07_04 lumocoeff_r_07_04; /* 0x014 */ + union avi_isp_denoising_lumocoeff_r_11_08 lumocoeff_r_11_08; /* 0x018 */ + union avi_isp_denoising_lumocoeff_r_13_12 lumocoeff_r_13_12; /* 0x01c */ + union avi_isp_denoising_lumocoeff_b_03_00 lumocoeff_b_03_00; /* 0x020 */ + union avi_isp_denoising_lumocoeff_b_07_04 lumocoeff_b_07_04; /* 0x024 */ + union avi_isp_denoising_lumocoeff_b_11_08 lumocoeff_b_11_08; /* 0x028 */ + union avi_isp_denoising_lumocoeff_b_13_12 lumocoeff_b_13_12; /* 0x02c */ + union avi_isp_denoising_lumocoeff_g_03_00 lumocoeff_g_03_00; /* 0x030 */ + union avi_isp_denoising_lumocoeff_g_07_04 lumocoeff_g_07_04; /* 0x034 */ + union avi_isp_denoising_lumocoeff_g_11_08 lumocoeff_g_11_08; /* 0x038 */ + union avi_isp_denoising_lumocoeff_g_13_12 lumocoeff_g_13_12; /* 0x03c */ +}; + +#endif /* _AVI_ISP_DENOISING_H_ */ diff --git a/sw/airborne/modules/computer_vision/lib/isp/regmap/avi_isp_drop.h b/sw/airborne/modules/computer_vision/lib/isp/regmap/avi_isp_drop.h new file mode 100644 index 0000000000..8116411bf8 --- /dev/null +++ b/sw/airborne/modules/computer_vision/lib/isp/regmap/avi_isp_drop.h @@ -0,0 +1,44 @@ +/********************************************************************* + * avi_isp_drop register map + * + * Vendor: Parrot + * Library: AVI + * Version: P7R3 + * Gen-date: (Date of generation of this C code, not the IP-Xact file) + * 2014-02-28 + * + * WARNING: This code is automatically generated from the hardware + * IP-Xact XML files. Do not edit directly. + *********************************************************************/ + +#ifndef _AVI_ISP_DROP_H_ +#define _AVI_ISP_DROP_H_ + +#define AVI_ISP_DROP_OFFSET_X 0x00 +#define AVI_ISP_DROP_OFFSET_Y 0x04 + +union avi_isp_drop_offset_x +{ + struct + { + uint32_t offset_x : 16; + }; + uint32_t _register; +}; + +union avi_isp_drop_offset_y +{ + struct + { + uint32_t offset_y : 16; + }; + uint32_t _register; +}; + +struct avi_isp_drop_regs +{ + union avi_isp_drop_offset_x offset_x; /* 0x000 */ + union avi_isp_drop_offset_y offset_y; /* 0x004 */ +}; + +#endif /* _AVI_ISP_DROP_H_ */ diff --git a/sw/airborne/modules/computer_vision/lib/isp/regmap/avi_isp_edge_enhancement_color_reduction_filter.h b/sw/airborne/modules/computer_vision/lib/isp/regmap/avi_isp_edge_enhancement_color_reduction_filter.h new file mode 100644 index 0000000000..b81e7ec251 --- /dev/null +++ b/sw/airborne/modules/computer_vision/lib/isp/regmap/avi_isp_edge_enhancement_color_reduction_filter.h @@ -0,0 +1,93 @@ +/********************************************************************* + * avi_isp_edge_enhancement_color_reduction_filter register map + * + * Vendor: Parrot + * Library: AVI + * Version: P7R3 + * Gen-date: (Date of generation of this C code, not the IP-Xact file) + * 2014-02-28 + * + * WARNING: This code is automatically generated from the hardware + * IP-Xact XML files. Do not edit directly. + *********************************************************************/ + +#ifndef _AVI_ISP_EDGE_ENHANCEMENT_COLOR_REDUCTION_FILTER_H_ +#define _AVI_ISP_EDGE_ENHANCEMENT_COLOR_REDUCTION_FILTER_H_ + +#define AVI_ISP_EDGE_ENHANCEMENT_COLOR_REDUCTION_FILTER_EE_LUT 0x00 + +union avi_isp_edge_enhancement_color_reduction_filter_ee_lut +{ + struct + { + uint32_t ee_lut : 6; + }; + uint32_t _register; +}; + +struct avi_isp_edge_enhancement_color_reduction_filter_ee_lut_regs +{ + union avi_isp_edge_enhancement_color_reduction_filter_ee_lut ee_lut[256]; +}; + +#define AVI_ISP_EDGE_ENHANCEMENT_COLOR_REDUCTION_FILTER_EE_KERNEL_COEFF 0x400 +#define AVI_ISP_EDGE_ENHANCEMENT_COLOR_REDUCTION_FILTER_CRF_KERNEL_COEFF 0x420 +#define AVI_ISP_EDGE_ENHANCEMENT_COLOR_REDUCTION_FILTER_M_COEFF 0x440 +#define AVI_ISP_EDGE_ENHANCEMENT_COLOR_REDUCTION_FILTER_D_COEFF 0x460 + +union avi_isp_edge_enhancement_color_reduction_filter_ee_kernel_coeff +{ + struct + { + uint32_t ee_kernel_coeff : 11; + }; + uint32_t _register; +}; + +union avi_isp_edge_enhancement_color_reduction_filter_crf_kernel_coeff +{ + struct + { + uint32_t crf_kernel_coeff : 11; + }; + uint32_t _register; +}; + +union avi_isp_edge_enhancement_color_reduction_filter_m_coeff +{ + struct + { + uint32_t m_coeff : 8; + }; + uint32_t _register; +}; + +union avi_isp_edge_enhancement_color_reduction_filter_d_coeff +{ + struct + { + uint32_t d_coeff : 11; + }; + uint32_t _register; +}; + +struct avi_isp_edge_enhancement_color_reduction_filter_regs +{ + union avi_isp_edge_enhancement_color_reduction_filter_ee_kernel_coeff ee_kernel_coeff[6]; /* 0x400 - 0x414 */ + unsigned /*unused*/ : 32; /* 0x018 */ + unsigned /*unused*/ : 32; /* 0x01c */ + union avi_isp_edge_enhancement_color_reduction_filter_crf_kernel_coeff crf_kernel_coeff[6]; /* 0x420 - 0x434 */ + unsigned /*unused*/ : 32; /* 0x038 */ + unsigned /*unused*/ : 32; /* 0x03c */ + union avi_isp_edge_enhancement_color_reduction_filter_m_coeff m_coeff; /* 0x440 */ + unsigned /*unused*/ : 32; /* 0x044 */ + unsigned /*unused*/ : 32; /* 0x048 */ + unsigned /*unused*/ : 32; /* 0x04c */ + unsigned /*unused*/ : 32; /* 0x050 */ + unsigned /*unused*/ : 32; /* 0x054 */ + unsigned /*unused*/ : 32; /* 0x058 */ + unsigned /*unused*/ : 32; /* 0x05c */ + union avi_isp_edge_enhancement_color_reduction_filter_d_coeff d_coeff; /* 0x460 */ +}; + +#endif /* _AVI_ISP_EDGE_ENHANCEMENT_COLOR_REDUCTION_FILTER_H_ */ diff --git a/sw/airborne/modules/computer_vision/lib/isp/regmap/avi_isp_gamma_corrector.h b/sw/airborne/modules/computer_vision/lib/isp/regmap/avi_isp_gamma_corrector.h new file mode 100644 index 0000000000..5c02be586e --- /dev/null +++ b/sw/airborne/modules/computer_vision/lib/isp/regmap/avi_isp_gamma_corrector.h @@ -0,0 +1,83 @@ +/********************************************************************* + * avi_isp_gamma_corrector register map + * + * Vendor: Parrot + * Library: AVI + * Version: P7R3 + * Gen-date: (Date of generation of this C code, not the IP-Xact file) + * 2014-02-28 + * + * WARNING: This code is automatically generated from the hardware + * IP-Xact XML files. Do not edit directly. + *********************************************************************/ + +#ifndef _AVI_ISP_GAMMA_CORRECTOR_H_ +#define _AVI_ISP_GAMMA_CORRECTOR_H_ + +#define AVI_ISP_GAMMA_CORRECTOR_CONF 0x00 + +union avi_isp_gamma_corrector_conf +{ + struct + { + uint32_t bypass : 1; + uint32_t palette : 1; + uint32_t comp_width : 1; + }; + uint32_t _register; +}; + +struct avi_isp_gamma_corrector_regs +{ + union avi_isp_gamma_corrector_conf conf; /* 0x000 */ +}; + +#define AVI_ISP_GAMMA_CORRECTOR_RY_LUT 0x1000 + +union avi_isp_gamma_corrector_ry_lut +{ + struct + { + uint32_t ry_value : 8; + }; + uint32_t _register; +}; + +struct avi_isp_gamma_corrector_ry_lut_regs +{ + union avi_isp_gamma_corrector_ry_lut ry_lut[1024]; +}; + +#define AVI_ISP_GAMMA_CORRECTOR_GU_LUT 0x2000 + +union avi_isp_gamma_corrector_gu_lut +{ + struct + { + uint32_t gu_value : 8; + }; + uint32_t _register; +}; + +struct avi_isp_gamma_corrector_gu_lut_regs +{ + union avi_isp_gamma_corrector_gu_lut gu_lut[1024]; +}; + +#define AVI_ISP_GAMMA_CORRECTOR_BV_LUT 0x3000 + +union avi_isp_gamma_corrector_bv_lut +{ + struct + { + uint32_t bv_value : 8; + }; + uint32_t _register; +}; + +struct avi_isp_gamma_corrector_bv_lut_regs +{ + union avi_isp_gamma_corrector_bv_lut bv_lut[1024]; +}; + +#endif /* _AVI_ISP_GAMMA_CORRECTOR_H_ */ diff --git a/sw/airborne/modules/computer_vision/lib/isp/regmap/avi_isp_green_imbalance.h b/sw/airborne/modules/computer_vision/lib/isp/regmap/avi_isp_green_imbalance.h new file mode 100644 index 0000000000..16d4305e70 --- /dev/null +++ b/sw/airborne/modules/computer_vision/lib/isp/regmap/avi_isp_green_imbalance.h @@ -0,0 +1,157 @@ +/********************************************************************* + * avi_isp_green_imbalance register map + * + * Vendor: Parrot + * Library: AVI + * Version: P7R3 + * Gen-date: (Date of generation of this C code, not the IP-Xact file) + * 2014-02-28 + * + * WARNING: This code is automatically generated from the hardware + * IP-Xact XML files. Do not edit directly. + *********************************************************************/ + +#ifndef _AVI_ISP_GREEN_IMBALANCE_H_ +#define _AVI_ISP_GREEN_IMBALANCE_H_ + +#define AVI_ISP_GREEN_IMBALANCE_BAYER_CFA 0x00 +#define AVI_ISP_GREEN_IMBALANCE_OFFSET_X_Y 0x04 +#define AVI_ISP_GREEN_IMBALANCE_CELL_ID_X_Y 0x08 +#define AVI_ISP_GREEN_IMBALANCE_CELL_W 0x0c +#define AVI_ISP_GREEN_IMBALANCE_CELL_H 0x10 +#define AVI_ISP_GREEN_IMBALANCE_CELL_W_INV 0x14 +#define AVI_ISP_GREEN_IMBALANCE_CELL_H_INV 0x18 +#define AVI_ISP_GREEN_IMBALANCE_ALPHA 0x1c +#define AVI_ISP_GREEN_IMBALANCE_BETA 0x20 + +union avi_isp_green_imbalance_bayer_cfa +{ + struct + { + uint32_t cfa : 2; + }; + uint32_t _register; +}; + +union avi_isp_green_imbalance_offset_x_y +{ + struct + { + uint32_t offset_x : 9; + unsigned /*unused */ : 7; + uint32_t offset_y : 10; + }; + uint32_t _register; +}; + +union avi_isp_green_imbalance_cell_id_x_y +{ + struct + { + uint32_t cell_id_x : 4; + unsigned /*unused */ : 12; + uint32_t cell_id_y : 4; + }; + uint32_t _register; +}; + +union avi_isp_green_imbalance_cell_w +{ + struct + { + uint32_t cell_w : 9; + }; + uint32_t _register; +}; + +union avi_isp_green_imbalance_cell_h +{ + struct + { + uint32_t cell_h : 10; + }; + uint32_t _register; +}; + +union avi_isp_green_imbalance_cell_w_inv +{ + struct + { + uint32_t w_inv : 17; + }; + uint32_t _register; +}; + +union avi_isp_green_imbalance_cell_h_inv +{ + struct + { + uint32_t h_inv : 17; + }; + uint32_t _register; +}; + +union avi_isp_green_imbalance_alpha +{ + struct + { + uint32_t alpha : 17; + }; + uint32_t _register; +}; + +union avi_isp_green_imbalance_beta +{ + struct + { + uint32_t beta : 17; + }; + uint32_t _register; +}; + +struct avi_isp_green_imbalance_regs +{ + union avi_isp_green_imbalance_bayer_cfa bayer_cfa; /* 0x000 */ + union avi_isp_green_imbalance_offset_x_y offset_x_y; /* 0x004 */ + union avi_isp_green_imbalance_cell_id_x_y cell_id_x_y; /* 0x008 */ + union avi_isp_green_imbalance_cell_w cell_w; /* 0x00c */ + union avi_isp_green_imbalance_cell_h cell_h; /* 0x010 */ + union avi_isp_green_imbalance_cell_w_inv cell_w_inv; /* 0x014 */ + union avi_isp_green_imbalance_cell_h_inv cell_h_inv; /* 0x018 */ + union avi_isp_green_imbalance_alpha alpha; /* 0x01c */ + union avi_isp_green_imbalance_beta beta; /* 0x020 */ +}; + +#define AVI_ISP_GREEN_IMBALANCE_GREEN_RED_COEFF_MEM 0x1000 + +union avi_isp_green_imbalance_green_red_coeff_mem +{ + struct + { + uint32_t gr_coeff_value : 8; + }; + uint32_t _register; +}; + +struct avi_isp_green_imbalance_green_red_coeff_mem_regs +{ + union avi_isp_green_imbalance_green_red_coeff_mem red_coeff_mem[221]; +}; + +#define AVI_ISP_GREEN_IMBALANCE_GREEN_BLUE_COEFF_MEM 0x1400 + +union avi_isp_green_imbalance_green_blue_coeff_mem +{ + struct + { + uint32_t gb_coeff_value : 8; + }; + uint32_t _register; +}; + +struct avi_isp_green_imbalance_green_blue_coeff_mem_regs +{ + union avi_isp_green_imbalance_green_blue_coeff_mem green_coeff_mem[221]; +}; + +#endif /* _AVI_ISP_GREEN_IMBALANCE_H_ */ diff --git a/sw/airborne/modules/computer_vision/lib/isp/regmap/avi_isp_i3d_lut.h b/sw/airborne/modules/computer_vision/lib/isp/regmap/avi_isp_i3d_lut.h new file mode 100644 index 0000000000..4b95322e3e --- /dev/null +++ b/sw/airborne/modules/computer_vision/lib/isp/regmap/avi_isp_i3d_lut.h @@ -0,0 +1,69 @@ +/********************************************************************* + * avi_isp_i3d_lut register map + * + * Vendor: Parrot + * Library: AVI + * Version: P7R3 + * Gen-date: (Date of generation of this C code, not the IP-Xact file) + * 2014-02-28 + * + * WARNING: This code is automatically generated from the hardware + * IP-Xact XML files. Do not edit directly. + *********************************************************************/ + +#ifndef _AVI_ISP_I3D_LUT_H_ +#define _AVI_ISP_I3D_LUT_H_ + +#define AVI_ISP_I3D_LUT_LUT_OUTSIDE 0x00 + +union avi_isp_i3d_lut_lut_outside +{ + struct + { + uint32_t bv_value : 8; + uint32_t gu_value : 8; + uint32_t ry_value : 8; + }; + uint32_t _register; +}; + +struct avi_isp_i3d_lut_lut_outside_regs +{ + union avi_isp_i3d_lut_lut_outside lut_outside[125]; +}; + +#define AVI_ISP_I3D_LUT_LUT_INSIDE 0x200 + +union avi_isp_i3d_lut_lut_inside +{ + struct + { + uint32_t bv_value : 8; + uint32_t gu_value : 8; + uint32_t ry_value : 8; + }; + uint32_t _register; +}; + +struct avi_isp_i3d_lut_lut_inside_regs +{ + union avi_isp_i3d_lut_lut_inside lut_inside[125]; +}; + +#define AVI_ISP_I3D_LUT_CLIP_MODE 0x400 + +union avi_isp_i3d_lut_clip_mode +{ + struct + { + uint32_t clip_en : 1; + }; + uint32_t _register; +}; + +struct avi_isp_i3d_lut_regs +{ + union avi_isp_i3d_lut_clip_mode clip_mode; /* 0x400 */ +}; + +#endif /* _AVI_ISP_I3D_LUT_H_ */ diff --git a/sw/airborne/modules/computer_vision/lib/isp/regmap/avi_isp_lens_shading_correction.h b/sw/airborne/modules/computer_vision/lib/isp/regmap/avi_isp_lens_shading_correction.h new file mode 100644 index 0000000000..4158909e5e --- /dev/null +++ b/sw/airborne/modules/computer_vision/lib/isp/regmap/avi_isp_lens_shading_correction.h @@ -0,0 +1,199 @@ +/********************************************************************* + * avi_isp_lens_shading_correction register map + * + * Vendor: Parrot + * Library: AVI + * Version: P7R3 + * Gen-date: (Date of generation of this C code, not the IP-Xact file) + * 2014-02-28 + * + * WARNING: This code is automatically generated from the hardware + * IP-Xact XML files. Do not edit directly. + *********************************************************************/ + +#ifndef _AVI_ISP_LENS_SHADING_CORRECTION_H_ +#define _AVI_ISP_LENS_SHADING_CORRECTION_H_ + +#define AVI_ISP_LENS_SHADING_CORRECTION_BAYER_CFA 0x00 +#define AVI_ISP_LENS_SHADING_CORRECTION_OFFSET_X_Y 0x04 +#define AVI_ISP_LENS_SHADING_CORRECTION_CELL_ID_X_Y 0x08 +#define AVI_ISP_LENS_SHADING_CORRECTION_CELL_W 0x0c +#define AVI_ISP_LENS_SHADING_CORRECTION_CELL_H 0x10 +#define AVI_ISP_LENS_SHADING_CORRECTION_CELL_W_INV 0x14 +#define AVI_ISP_LENS_SHADING_CORRECTION_CELL_H_INV 0x18 +#define AVI_ISP_LENS_SHADING_CORRECTION_ALPHA 0x1c +#define AVI_ISP_LENS_SHADING_CORRECTION_BETA 0x20 +#define AVI_ISP_LENS_SHADING_CORRECTION_THRESHOLD 0x24 +#define AVI_ISP_LENS_SHADING_CORRECTION_GAIN 0x28 + +union avi_isp_lens_shading_correction_bayer_cfa +{ + struct + { + uint32_t cfa : 2; + }; + uint32_t _register; +}; + +union avi_isp_lens_shading_correction_offset_x_y +{ + struct + { + uint32_t offset_x : 9; + unsigned /*unused */ : 7; + uint32_t offset_y : 10; + }; + uint32_t _register; +}; + +union avi_isp_lens_shading_correction_cell_id_x_y +{ + struct + { + uint32_t cell_id_x : 4; + unsigned /*unused */ : 12; + uint32_t cell_id_y : 4; + }; + uint32_t _register; +}; + +union avi_isp_lens_shading_correction_cell_w +{ + struct + { + uint32_t cell_w : 9; + }; + uint32_t _register; +}; + +union avi_isp_lens_shading_correction_cell_h +{ + struct + { + uint32_t cell_h : 10; + }; + uint32_t _register; +}; + +union avi_isp_lens_shading_correction_cell_w_inv +{ + struct + { + uint32_t w_inv : 17; + }; + uint32_t _register; +}; + +union avi_isp_lens_shading_correction_cell_h_inv +{ + struct + { + uint32_t h_inv : 17; + }; + uint32_t _register; +}; + +union avi_isp_lens_shading_correction_alpha +{ + struct + { + uint32_t alpha : 17; + }; + uint32_t _register; +}; + +union avi_isp_lens_shading_correction_beta +{ + struct + { + uint32_t beta : 17; + }; + uint32_t _register; +}; + +union avi_isp_lens_shading_correction_threshold +{ + struct + { + uint32_t threshold_r : 10; + uint32_t threshold_g : 10; + uint32_t threshold_b : 10; + }; + uint32_t _register; +}; + +union avi_isp_lens_shading_correction_gain +{ + struct + { + uint32_t gain_r : 10; + uint32_t gain_g : 10; + uint32_t gain_b : 10; + }; + uint32_t _register; +}; + +struct avi_isp_lens_shading_correction_regs +{ + union avi_isp_lens_shading_correction_bayer_cfa bayer_cfa; /* 0x000 */ + union avi_isp_lens_shading_correction_offset_x_y offset_x_y; /* 0x004 */ + union avi_isp_lens_shading_correction_cell_id_x_y cell_id_x_y; /* 0x008 */ + union avi_isp_lens_shading_correction_cell_w cell_w; /* 0x00c */ + union avi_isp_lens_shading_correction_cell_h cell_h; /* 0x010 */ + union avi_isp_lens_shading_correction_cell_w_inv cell_w_inv; /* 0x014 */ + union avi_isp_lens_shading_correction_cell_h_inv cell_h_inv; /* 0x018 */ + union avi_isp_lens_shading_correction_alpha alpha; /* 0x01c */ + union avi_isp_lens_shading_correction_beta beta; /* 0x020 */ + union avi_isp_lens_shading_correction_threshold threshold; /* 0x024 */ + union avi_isp_lens_shading_correction_gain gain; /* 0x028 */ +}; + +#define AVI_ISP_LENS_SHADING_CORRECTION_RED_COEFF_MEM 0x1000 + +union avi_isp_lens_shading_correction_red_coeff_mem +{ + struct + { + uint32_t r_coeff_value : 8; + }; + uint32_t _register; +}; + +struct avi_isp_lens_shading_correction_red_coeff_mem_regs +{ + union avi_isp_lens_shading_correction_red_coeff_mem red_coeff_mem[221]; +}; + +#define AVI_ISP_LENS_SHADING_CORRECTION_GREEN_COEFF_MEM 0x1400 + +union avi_isp_lens_shading_correction_green_coeff_mem +{ + struct + { + uint32_t g_coeff_value : 8; + }; + uint32_t _register; +}; + +struct avi_isp_lens_shading_correction_green_coeff_mem_regs +{ + union avi_isp_lens_shading_correction_green_coeff_mem green_coeff_mem[221]; +}; + +#define AVI_ISP_LENS_SHADING_CORRECTION_BLUE_COEFF_MEM 0x1800 + +union avi_isp_lens_shading_correction_blue_coeff_mem +{ + struct + { + uint32_t b_coeff_value : 8; + }; + uint32_t _register; +}; + +struct avi_isp_lens_shading_correction_blue_coeff_mem_regs +{ + union avi_isp_lens_shading_correction_blue_coeff_mem blue_coeff_mem[221]; +}; + +#endif /* _AVI_ISP_LENS_SHADING_CORRECTION_H_ */ diff --git a/sw/airborne/modules/computer_vision/lib/isp/regmap/avi_isp_pedestal.h b/sw/airborne/modules/computer_vision/lib/isp/regmap/avi_isp_pedestal.h new file mode 100644 index 0000000000..01e5a446f7 --- /dev/null +++ b/sw/airborne/modules/computer_vision/lib/isp/regmap/avi_isp_pedestal.h @@ -0,0 +1,77 @@ +/********************************************************************* + * avi_isp_pedestal register map + * + * Vendor: Parrot + * Library: AVI + * Version: P7R3 + * Gen-date: (Date of generation of this C code, not the IP-Xact file) + * 2014-02-28 + * + * WARNING: This code is automatically generated from the hardware + * IP-Xact XML files. Do not edit directly. + *********************************************************************/ + +#ifndef _AVI_ISP_PEDESTAL_H_ +#define _AVI_ISP_PEDESTAL_H_ + +#define AVI_ISP_PEDESTAL_CFA 0x00 +#define AVI_ISP_PEDESTAL_SUB_R 0x04 +#define AVI_ISP_PEDESTAL_SUB_GB 0x08 +#define AVI_ISP_PEDESTAL_SUB_GR 0x0c +#define AVI_ISP_PEDESTAL_SUB_B 0x10 + +union avi_isp_pedestal_cfa +{ + struct + { + uint32_t cfa : 2; + }; + uint32_t _register; +}; + +union avi_isp_pedestal_sub_r +{ + struct + { + uint32_t sub_r : 10; + }; + uint32_t _register; +}; + +union avi_isp_pedestal_sub_gb +{ + struct + { + uint32_t sub_gb : 10; + }; + uint32_t _register; +}; + +union avi_isp_pedestal_sub_gr +{ + struct + { + uint32_t sub_gr : 10; + }; + uint32_t _register; +}; + +union avi_isp_pedestal_sub_b +{ + struct + { + uint32_t sub_b : 10; + }; + uint32_t _register; +}; + +struct avi_isp_pedestal_regs +{ + union avi_isp_pedestal_cfa cfa; /* 0x000 */ + union avi_isp_pedestal_sub_r sub_r; /* 0x004 */ + union avi_isp_pedestal_sub_gb sub_gb; /* 0x008 */ + union avi_isp_pedestal_sub_gr sub_gr; /* 0x00c */ + union avi_isp_pedestal_sub_b sub_b; /* 0x010 */ +}; + +#endif /* _AVI_ISP_PEDESTAL_H_ */ diff --git a/sw/airborne/modules/computer_vision/lib/isp/regmap/avi_isp_statistics_bayer.h b/sw/airborne/modules/computer_vision/lib/isp/regmap/avi_isp_statistics_bayer.h new file mode 100644 index 0000000000..86164cc433 --- /dev/null +++ b/sw/airborne/modules/computer_vision/lib/isp/regmap/avi_isp_statistics_bayer.h @@ -0,0 +1,162 @@ +/********************************************************************* + * avi_isp_statistics_bayer register map + * + * Vendor: Parrot + * Library: AVI + * Version: P7R3 + * Gen-date: (Date of generation of this C code, not the IP-Xact file) + * 2014-02-28 + * + * WARNING: This code is automatically generated from the hardware + * IP-Xact XML files. Do not edit directly. + *********************************************************************/ + +#ifndef _AVI_ISP_STATISTICS_BAYER_H_ +#define _AVI_ISP_STATISTICS_BAYER_H_ + +#define AVI_ISP_STATISTICS_BAYER_MEASURE_REQ 0x00 +#define AVI_ISP_STATISTICS_BAYER_WINDOW_X 0x04 +#define AVI_ISP_STATISTICS_BAYER_WINDOW_Y 0x08 +#define AVI_ISP_STATISTICS_BAYER_CIRCLE_POS_X_CENTER 0x0c +#define AVI_ISP_STATISTICS_BAYER_CIRCLE_POS_X_SQUARED 0x10 +#define AVI_ISP_STATISTICS_BAYER_CIRCLE_POS_Y_CENTER 0x14 +#define AVI_ISP_STATISTICS_BAYER_CIRCLE_POS_Y_SQUARED 0x18 +#define AVI_ISP_STATISTICS_BAYER_CIRCLE_RADIUS_SQUARED 0x1c +#define AVI_ISP_STATISTICS_BAYER_INCREMENTS_LOG2 0x20 +#define AVI_ISP_STATISTICS_BAYER_SAT_THRESHOLD 0x24 +#define AVI_ISP_STATISTICS_BAYER_CFA 0x28 +#define AVI_ISP_STATISTICS_BAYER_MAX_NB_WINDOWS 0x2c + +union avi_isp_statistics_bayer_measure_req +{ + struct + { + uint32_t clear : 1; + }; + uint32_t _register; +}; + +union avi_isp_statistics_bayer_window_x +{ + struct + { + uint32_t x_offset : 13; + unsigned /*unused */ : 3; + uint32_t x_width : 11; + }; + uint32_t _register; +}; + +union avi_isp_statistics_bayer_window_y +{ + struct + { + uint32_t y_offset : 13; + unsigned /*unused */ : 3; + uint32_t y_width : 11; + }; + uint32_t _register; +}; + +union avi_isp_statistics_bayer_circle_pos_x_center +{ + struct + { + uint32_t x_center : 14; + }; + uint32_t _register; +}; + +union avi_isp_statistics_bayer_circle_pos_x_squared +{ + struct + { + uint32_t x_squared : 26; + }; + uint32_t _register; +}; + +union avi_isp_statistics_bayer_circle_pos_y_center +{ + struct + { + uint32_t y_center : 14; + }; + uint32_t _register; +}; + +union avi_isp_statistics_bayer_circle_pos_y_squared +{ + struct + { + uint32_t y_squared : 26; + }; + uint32_t _register; +}; + +union avi_isp_statistics_bayer_circle_radius_squared +{ + struct + { + uint32_t radius_squared : 29; + }; + uint32_t _register; +}; + +union avi_isp_statistics_bayer_increments_log2 +{ + struct + { + uint32_t x_log2_inc : 3; + unsigned /*unused */ : 13; + uint32_t y_log2_inc : 3; + }; + uint32_t _register; +}; + +union avi_isp_statistics_bayer_sat_threshold +{ + struct + { + uint32_t threshold : 10; + }; + uint32_t _register; +}; + +union avi_isp_statistics_bayer_cfa +{ + struct + { + uint32_t cfa : 2; + }; + uint32_t _register; +}; + +union avi_isp_statistics_bayer_max_nb_windows +{ + struct + { + uint32_t x_window_count : 7; + unsigned /*unused */ : 9; + uint32_t y_window_count : 7; + }; + uint32_t _register; +}; + +struct avi_isp_statistics_bayer_regs +{ + union avi_isp_statistics_bayer_measure_req measure_req; /* 0x000 */ + union avi_isp_statistics_bayer_window_x window_x; /* 0x004 */ + union avi_isp_statistics_bayer_window_y window_y; /* 0x008 */ + union avi_isp_statistics_bayer_circle_pos_x_center circle_pos_x_center; /* 0x00c */ + union avi_isp_statistics_bayer_circle_pos_x_squared circle_pos_x_squared; /* 0x010 */ + union avi_isp_statistics_bayer_circle_pos_y_center circle_pos_y_center; /* 0x014 */ + union avi_isp_statistics_bayer_circle_pos_y_squared circle_pos_y_squared; /* 0x018 */ + union avi_isp_statistics_bayer_circle_radius_squared circle_radius_squared; /* 0x01c */ + union avi_isp_statistics_bayer_increments_log2 increments_log2; /* 0x020 */ + union avi_isp_statistics_bayer_sat_threshold sat_threshold; /* 0x024 */ + union avi_isp_statistics_bayer_cfa cfa; /* 0x028 */ + union avi_isp_statistics_bayer_max_nb_windows max_nb_windows; /* 0x02c */ +}; + +#endif /* _AVI_ISP_STATISTICS_BAYER_H_ */ diff --git a/sw/airborne/modules/computer_vision/lib/isp/regmap/avi_isp_statistics_yuv.h b/sw/airborne/modules/computer_vision/lib/isp/regmap/avi_isp_statistics_yuv.h new file mode 100644 index 0000000000..4eba8f0cab --- /dev/null +++ b/sw/airborne/modules/computer_vision/lib/isp/regmap/avi_isp_statistics_yuv.h @@ -0,0 +1,227 @@ +/********************************************************************* + * avi_isp_statistics_yuv register map + * + * Vendor: Parrot + * Library: AVI + * Version: P7R3 + * Gen-date: (Date of generation of this C code, not the IP-Xact file) + * 2014-02-28 + * + * WARNING: This code is automatically generated from the hardware + * IP-Xact XML files. Do not edit directly. + *********************************************************************/ + +#ifndef _AVI_ISP_STATISTICS_YUV_H_ +#define _AVI_ISP_STATISTICS_YUV_H_ + +#define AVI_ISP_STATISTICS_YUV_MEASURE_REQ 0x00 +#define AVI_ISP_STATISTICS_YUV_MEASURE_STATUS 0x04 +#define AVI_ISP_STATISTICS_YUV_WINDOW_POS_X 0x08 +#define AVI_ISP_STATISTICS_YUV_WINDOW_POS_Y 0x0c +#define AVI_ISP_STATISTICS_YUV_CIRCLE_POS_X_CENTER 0x10 +#define AVI_ISP_STATISTICS_YUV_CIRCLE_POS_X_SQUARED 0x14 +#define AVI_ISP_STATISTICS_YUV_CIRCLE_POS_Y_CENTER 0x18 +#define AVI_ISP_STATISTICS_YUV_CIRCLE_POS_Y_SQUARED 0x1c +#define AVI_ISP_STATISTICS_YUV_CIRCLE_RADIUS_SQUARED 0x20 +#define AVI_ISP_STATISTICS_YUV_INCREMENTS_LOG2 0x24 +#define AVI_ISP_STATISTICS_YUV_AE_NB_VALID_Y 0x30 +#define AVI_ISP_STATISTICS_YUV_AWB_THRESHOLD 0x40 +#define AVI_ISP_STATISTICS_YUV_AWB_SUM_Y 0x44 +#define AVI_ISP_STATISTICS_YUV_AWB_SUM_U 0x48 +#define AVI_ISP_STATISTICS_YUV_AWB_SUM_V 0x4c +#define AVI_ISP_STATISTICS_YUV_AWB_NB_GREY_PIXELS 0x50 + +union avi_isp_statistics_yuv_measure_req +{ + struct + { + uint32_t measure_req : 1; + uint32_t clear : 1; + }; + uint32_t _register; +}; + +union avi_isp_statistics_yuv_measure_status +{ + struct + { + uint32_t done : 1; + uint32_t error : 1; + }; + uint32_t _register; +}; + +union avi_isp_statistics_yuv_window_pos_x +{ + struct + { + uint32_t window_x_start : 13; + unsigned /*unused */ : 3; + uint32_t window_x_end : 13; + }; + uint32_t _register; +}; + +union avi_isp_statistics_yuv_window_pos_y +{ + struct + { + uint32_t window_y_start : 13; + unsigned /*unused */ : 3; + uint32_t window_y_end : 13; + }; + uint32_t _register; +}; + +union avi_isp_statistics_yuv_circle_pos_x_center +{ + struct + { + uint32_t x_center : 14; + }; + uint32_t _register; +}; + +union avi_isp_statistics_yuv_circle_pos_x_squared +{ + struct + { + uint32_t x_squared : 26; + }; + uint32_t _register; +}; + +union avi_isp_statistics_yuv_circle_pos_y_center +{ + struct + { + uint32_t y_center : 14; + }; + uint32_t _register; +}; + +union avi_isp_statistics_yuv_circle_pos_y_squared +{ + struct + { + uint32_t y_squared : 26; + }; + uint32_t _register; +}; + +union avi_isp_statistics_yuv_circle_radius_squared +{ + struct + { + uint32_t radius_squared : 29; + }; + uint32_t _register; +}; + +union avi_isp_statistics_yuv_increments_log2 +{ + struct + { + uint32_t x_log2_inc : 3; + unsigned /*unused */ : 13; + uint32_t y_log2_inc : 3; + }; + uint32_t _register; +}; + +union avi_isp_statistics_yuv_ae_nb_valid_y +{ + struct + { + uint32_t nb_valid_y : 22; + }; + uint32_t _register; +}; + +union avi_isp_statistics_yuv_awb_threshold +{ + struct + { + uint32_t awb_threshold : 8; + }; + uint32_t _register; +}; + +union avi_isp_statistics_yuv_awb_sum_y +{ + struct + { + uint32_t awb_sum_y : 30; + }; + uint32_t _register; +}; + +union avi_isp_statistics_yuv_awb_sum_u +{ + struct + { + uint32_t awb_sum_u : 30; + }; + uint32_t _register; +}; + +union avi_isp_statistics_yuv_awb_sum_v +{ + struct + { + uint32_t awb_sum_v : 30; + }; + uint32_t _register; +}; + +union avi_isp_statistics_yuv_awb_nb_grey_pixels +{ + struct + { + uint32_t nb_grey_pixels : 22; + }; + uint32_t _register; +}; + +struct avi_isp_statistics_yuv_regs +{ + union avi_isp_statistics_yuv_measure_req measure_req; /* 0x000 */ + union avi_isp_statistics_yuv_measure_status measure_status; /* 0x004 */ + union avi_isp_statistics_yuv_window_pos_x window_pos_x; /* 0x008 */ + union avi_isp_statistics_yuv_window_pos_y window_pos_y; /* 0x00c */ + union avi_isp_statistics_yuv_circle_pos_x_center circle_pos_x_center; /* 0x010 */ + union avi_isp_statistics_yuv_circle_pos_x_squared circle_pos_x_squared; /* 0x014 */ + union avi_isp_statistics_yuv_circle_pos_y_center circle_pos_y_center; /* 0x018 */ + union avi_isp_statistics_yuv_circle_pos_y_squared circle_pos_y_squared; /* 0x01c */ + union avi_isp_statistics_yuv_circle_radius_squared circle_radius_squared; /* 0x020 */ + union avi_isp_statistics_yuv_increments_log2 increments_log2; /* 0x024 */ + unsigned /*unused*/ : 32; /* 0x028 */ + unsigned /*unused*/ : 32; /* 0x02c */ + union avi_isp_statistics_yuv_ae_nb_valid_y ae_nb_valid_y; /* 0x030 */ + unsigned /*unused*/ : 32; /* 0x034 */ + unsigned /*unused*/ : 32; /* 0x038 */ + unsigned /*unused*/ : 32; /* 0x03c */ + union avi_isp_statistics_yuv_awb_threshold awb_threshold; /* 0x040 */ + union avi_isp_statistics_yuv_awb_sum_y awb_sum_y; /* 0x044 */ + union avi_isp_statistics_yuv_awb_sum_u awb_sum_u; /* 0x048 */ + union avi_isp_statistics_yuv_awb_sum_v awb_sum_v; /* 0x04c */ + union avi_isp_statistics_yuv_awb_nb_grey_pixels awb_nb_grey_pixels; /* 0x050 */ +}; + +#define AVI_ISP_STATISTICS_YUV_AE_HISTOGRAM_Y 0x400 + +union avi_isp_statistics_yuv_ae_histogram_y +{ + struct + { + uint32_t histogram_y : 22; + }; + uint32_t _register; +}; + +struct avi_isp_statistics_yuv_ae_histogram_y_regs +{ + union avi_isp_statistics_yuv_ae_histogram_y ae_histogram_y[256]; +}; + +#endif /* _AVI_ISP_STATISTICS_YUV_H_ */ diff --git a/sw/airborne/modules/computer_vision/lib/isp/regmap/avi_isp_vlformat_32to40.h b/sw/airborne/modules/computer_vision/lib/isp/regmap/avi_isp_vlformat_32to40.h new file mode 100644 index 0000000000..43e8fe8ed8 --- /dev/null +++ b/sw/airborne/modules/computer_vision/lib/isp/regmap/avi_isp_vlformat_32to40.h @@ -0,0 +1,33 @@ +/********************************************************************* + * avi_isp_vlformat_32to40 register map + * + * Vendor: Parrot + * Library: AVI + * Version: P7R3 + * Gen-date: (Date of generation of this C code, not the IP-Xact file) + * 2014-02-28 + * + * WARNING: This code is automatically generated from the hardware + * IP-Xact XML files. Do not edit directly. + *********************************************************************/ + +#ifndef _AVI_ISP_VLFORMAT_32TO40_H_ +#define _AVI_ISP_VLFORMAT_32TO40_H_ + +#define AVI_ISP_VLFORMAT_32TO40_FORMAT 0x00 + +union avi_isp_vlformat_32to40_format +{ + struct + { + uint32_t format : 3; + }; + uint32_t _register; +}; + +struct avi_isp_vlformat_32to40_regs +{ + union avi_isp_vlformat_32to40_format format; /* 0x000 */ +}; + +#endif /* _AVI_ISP_VLFORMAT_32TO40_H_ */ diff --git a/sw/airborne/modules/computer_vision/lib/isp/regmap/avi_isp_vlformat_40to32.h b/sw/airborne/modules/computer_vision/lib/isp/regmap/avi_isp_vlformat_40to32.h new file mode 100644 index 0000000000..2d636e69cb --- /dev/null +++ b/sw/airborne/modules/computer_vision/lib/isp/regmap/avi_isp_vlformat_40to32.h @@ -0,0 +1,33 @@ +/********************************************************************* + * avi_isp_vlformat_40to32 register map + * + * Vendor: Parrot + * Library: AVI + * Version: P7R3 + * Gen-date: (Date of generation of this C code, not the IP-Xact file) + * 2014-02-28 + * + * WARNING: This code is automatically generated from the hardware + * IP-Xact XML files. Do not edit directly. + *********************************************************************/ + +#ifndef _AVI_ISP_VLFORMAT_40TO32_H_ +#define _AVI_ISP_VLFORMAT_40TO32_H_ + +#define AVI_ISP_VLFORMAT_40TO32_FORMAT 0x00 + +union avi_isp_vlformat_40to32_format +{ + struct + { + uint32_t format : 3; + }; + uint32_t _register; +}; + +struct avi_isp_vlformat_40to32_regs +{ + union avi_isp_vlformat_40to32_format format; /* 0x000 */ +}; + +#endif /* _AVI_VLFORMAT_40TO32_H_ */ diff --git a/sw/airborne/modules/computer_vision/lib/v4l/v4l2.c b/sw/airborne/modules/computer_vision/lib/v4l/v4l2.c index 45269232f5..f0955692c0 100644 --- a/sw/airborne/modules/computer_vision/lib/v4l/v4l2.c +++ b/sw/airborne/modules/computer_vision/lib/v4l/v4l2.c @@ -80,9 +80,9 @@ static void *v4l2_capture_thread(void *data) return (void *) - 1; } else if (sr == 0) { printf("[v4l2-capture] Select timeout on %s\n", dev->name); - //continue; - dev->thread = (pthread_t) NULL; - return (void *) - 2; + continue; + //dev->thread = (pthread_t) NULL; + //return (void *) - 2; } // Dequeue a buffer @@ -151,6 +151,8 @@ bool v4l2_init_subdev(char *subdev_name, uint8_t pad, uint8_t which, uint16_t co return false; } + printf("Got format pad: %d width: %d height: %d which: %d code: %d\n", sfmt.pad, sfmt.format.width, sfmt.format.height, sfmt.which, sfmt.format.code); + // Set the new settings sfmt.pad = pad; sfmt.which = which; @@ -160,12 +162,16 @@ bool v4l2_init_subdev(char *subdev_name, uint8_t pad, uint8_t which, uint16_t co sfmt.format.field = V4L2_FIELD_NONE; sfmt.format.colorspace = 1; + printf("set format pad: %d width: %d height: %d which: %d code: %d\n", sfmt.pad, sfmt.format.width, sfmt.format.height, sfmt.which, sfmt.format.code); + if (ioctl(fd, VIDIOC_SUBDEV_S_FMT, &sfmt) < 0) { printf("[v4l2] Could not set subdevice data format settings of %s\n", subdev_name); close(fd); return false; } + printf("new format pad: %d width: %d height: %d which: %d code: %d\n", sfmt.pad, sfmt.format.width, sfmt.format.height, sfmt.which, sfmt.format.code); + // Close the device close(fd); return true; diff --git a/sw/airborne/modules/computer_vision/video_thread.c b/sw/airborne/modules/computer_vision/video_thread.c index 3f1c00f849..0b5389328d 100644 --- a/sw/airborne/modules/computer_vision/video_thread.c +++ b/sw/airborne/modules/computer_vision/video_thread.c @@ -38,6 +38,7 @@ #include "lib/v4l/v4l2.h" #include "lib/vision/image.h" #include "lib/vision/bayer.h" +#include "lib/isp/libisp.h" #include "mcu_periph/sys_time.h" @@ -64,7 +65,9 @@ struct video_config_t *cameras[VIDEO_THREAD_MAX_CAMERAS]; // Main thread static void *video_thread_function(void *data); - +static bool initialize_camera(struct video_config_t *camera); +static void start_video_thread(struct video_config_t *camera); +static void stop_video_thread(struct video_config_t *device);; void video_thread_periodic(void) { @@ -86,7 +89,7 @@ static void *video_thread_function(void *data) struct image_t img_color; // create the images - if (vid->filters) { + if (vid->filters & VIDEO_FILTER_DEBAYER) { // fixme: don't hardcode size, works for bebop front camera for now #define IMG_FLT_SIZE 272 image_create(&img_color, IMG_FLT_SIZE, IMG_FLT_SIZE, IMAGE_YUV422); @@ -98,6 +101,11 @@ static void *video_thread_function(void *data) return 0; } + // Configure ISP if needed + if (vid->filters & VIDEO_FILTER_ISP) { + configure_isp(vid->thread.dev); + } + // be nice to the more important stuff set_nice_level(VIDEO_THREAD_NICE_LEVEL); fprintf(stdout, "[%s] Set nice level to %i.\n", print_tag, VIDEO_THREAD_NICE_LEVEL); @@ -134,10 +142,8 @@ static void *video_thread_function(void *data) struct image_t *img_final = &img; // run selected filters - if (vid->filters) { - if (vid->filters & VIDEO_FILTER_DEBAYER) { - BayerToYUV(&img, &img_color, 0, 0); - } + if (vid->filters & VIDEO_FILTER_DEBAYER) { + BayerToYUV(&img, &img_color, 0, 0); // use color image for further processing img_final = &img_color; } @@ -154,14 +160,12 @@ static void *video_thread_function(void *data) return 0; } - -bool initialize_camera(struct video_config_t *camera); -bool initialize_camera(struct video_config_t *camera) +static bool initialize_camera(struct video_config_t *camera) { // Initialize the V4L2 subdevice if needed if (camera->subdev_name != NULL) { // FIXME! add subdev format to config, only needed on bebop front camera so far - if (!v4l2_init_subdev(camera->subdev_name, 0, 0, camera->subdev_format, camera->w, camera->h)) { + if (!v4l2_init_subdev(camera->subdev_name, 0, 0, camera->subdev_format, camera->sensor_w, camera->sensor_h)) { printf("[video_thread] Could not initialize the %s subdevice.\n", camera->subdev_name); return false; } @@ -178,7 +182,9 @@ bool initialize_camera(struct video_config_t *camera) return true; } - +/* + * Add a new video device to the list + */ bool add_video_device(struct video_config_t *device) { // Loop over camera array @@ -212,8 +218,10 @@ bool add_video_device(struct video_config_t *device) return false; } -void start_video_thread(struct video_config_t *camera); -void start_video_thread(struct video_config_t *camera) +/* + * Start a new video thread for a camera + */ +static void start_video_thread(struct video_config_t *camera) { if (!camera->thread.is_running) { // Start the streaming thread for a camera @@ -225,8 +233,10 @@ void start_video_thread(struct video_config_t *camera) } } -void stop_video_thread(struct video_config_t *device); -void stop_video_thread(struct video_config_t *device) +/* + * Stop a video thread for a camera + */ +static void stop_video_thread(struct video_config_t *device) { if (device->thread.is_running) { // Stop the streaming thread diff --git a/sw/airborne/peripherals/video_device.h b/sw/airborne/peripherals/video_device.h index 16ec4f0a4d..a39153031e 100644 --- a/sw/airborne/peripherals/video_device.h +++ b/sw/airborne/peripherals/video_device.h @@ -30,7 +30,9 @@ #include #include "modules/computer_vision/lib/vision/image.h" -#define VIDEO_FILTER_DEBAYER 0x01 +/* Different video filters */ +#define VIDEO_FILTER_DEBAYER (0x1 << 0) ///