1 /* 2 * 3 * SPDX-License-Identifier: GPL-2.0 4 * 5 * Copyright (C) 2011-2018 ARM or its affiliates 6 * 7 * This program is free software; you can redistribute it and/or modify 8 * it under the terms of the GNU General Public License as published by 9 * the Free Software Foundation; version 2. 10 * This program is distributed in the hope that it will be useful, but 11 * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY 12 * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 13 * for more details. 14 * You should have received a copy of the GNU General Public License along 15 * with this program; if not, write to the Free Software Foundation, Inc., 16 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 17 * 18 */ 19 20 #if !defined( __MATRIX_YUV_FSM_H__ ) 21 #define __MATRIX_YUV_FSM_H__ 22 23 24 25 typedef struct _matrix_yuv_fsm_t matrix_yuv_fsm_t; 26 typedef struct _matrix_yuv_fsm_t *matrix_yuv_fsm_ptr_t; 27 typedef const struct _matrix_yuv_fsm_t *matrix_yuv_fsm_const_ptr_t; 28 29 #include "acamera_command_api.h" 30 #define PIPE_OUT_YUV444 1 31 #define PIPE_OUT_YUV422 2 32 #define PIPE_OUT_YUV420 3 33 #define PIPE_OUT_RGB 4 34 #ifndef AWB_LIGHT_SOURCE_D50 35 #define AWB_LIGHT_SOURCE_D50 0x03 36 #endif 37 void calculate_saturation_matrix( matrix_yuv_fsm_ptr_t p_fsm ); 38 void calculate_brightness_matrix( matrix_yuv_fsm_ptr_t p_fsm ); 39 void calculate_contrast_matrix( matrix_yuv_fsm_ptr_t p_fsm ); 40 void matrix_multiply( int16_t *a1, int16_t *a2, int16_t *result, int dim1, int dim2, int dim3 ); 41 uint16_t color_matrix_complement_to_direct( int16_t v ); 42 void matrix_identity( int16_t *m, int dim ); 43 int16_t color_matrix_direct_to_complement( uint16_t v ); 44 void matrix_yuv_initialize( matrix_yuv_fsm_ptr_t p_fsm ); 45 void matrix_yuv_update( matrix_yuv_fsm_ptr_t p_fsm ); 46 void matrix_yuv_recompute( matrix_yuv_fsm_ptr_t p_fsm ); 47 void matrix_yuv_coefft_write_to_hardware( matrix_yuv_fsm_ptr_t p_fsm ); 48 void matrix_yuv_set_FR_mode( uint16_t v ); 49 void matrix_yuv_set_DS1_mode( uint16_t v ); 50 51 struct _matrix_yuv_fsm_t { 52 fsm_common_t cmn; 53 54 acamera_fsm_mgr_t *p_fsm_mgr; 55 fsm_irq_mask_t mask; 56 int16_t saturation_matrix[12]; 57 int16_t contrast_matrix[12]; 58 int16_t brightness_matrix[12]; 59 int16_t hue_correction_matrix[12]; 60 int16_t color_mode_matrix[12]; 61 int16_t rgb2yuv_matrix[12]; 62 uint32_t hue_theta; 63 uint32_t saturation_strength; 64 uint32_t contrast_strength; 65 uint32_t brightness_strength; 66 uint32_t fr_pipe_output_format; 67 int16_t fr_composite_yuv_matrix[12]; 68 #if ISP_HAS_DS1 69 uint32_t ds1_pipe_output_format; 70 int16_t ds1_composite_yuv_matrix[12]; 71 #endif 72 uint32_t color_mode; 73 uint8_t manual_saturation_enabled; 74 uint8_t saturation_target; 75 int16_t manual_matrix_yuv[9]; 76 int32_t temperature_threshold[8]; 77 uint16_t fr_format; 78 }; 79 80 81 void matrix_yuv_fsm_clear( matrix_yuv_fsm_ptr_t p_fsm ); 82 83 void matrix_yuv_fsm_init( void *fsm, fsm_init_param_t *init_param ); 84 int matrix_yuv_fsm_set_param( void *fsm, uint32_t param_id, void *input, uint32_t input_size ); 85 int matrix_yuv_fsm_get_param( void *fsm, uint32_t param_id, void *input, uint32_t input_size, void *output, uint32_t output_size ); 86 87 uint8_t matrix_yuv_fsm_process_event( matrix_yuv_fsm_ptr_t p_fsm, event_id_t event_id ); 88 89 void matrix_yuv_fsm_process_interrupt( matrix_yuv_fsm_const_ptr_t p_fsm, uint8_t irq_event ); 90 91 void matrix_yuv_request_interrupt( matrix_yuv_fsm_ptr_t p_fsm, system_fw_interrupt_mask_t mask ); 92 93 #endif /* __MATRIX_YUV_FSM_H__ */ 94