linux/drivers/staging/media/atomisp/pci/atomisp2/css2400/hive_isp_css_common/host/input_formatter.c
<<
>>
Prefs
   1/*
   2 * Support for Intel Camera Imaging ISP subsystem.
   3 * Copyright (c) 2010-2015, Intel Corporation.
   4 *
   5 * This program is free software; you can redistribute it and/or modify it
   6 * under the terms and conditions of the GNU General Public License,
   7 * version 2, as published by the Free Software Foundation.
   8 *
   9 * This program is distributed in the hope it will be useful, but WITHOUT
  10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  11 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for
  12 * more details.
  13 */
  14
  15#include "system_global.h"
  16
  17#ifdef USE_INPUT_SYSTEM_VERSION_2
  18
  19#include "input_formatter.h"
  20#include <type_support.h>
  21#include "gp_device.h"
  22
  23#include "assert_support.h"
  24
  25#ifndef __INLINE_INPUT_FORMATTER__
  26#include "input_formatter_private.h"
  27#endif /* __INLINE_INPUT_FORMATTER__ */
  28
  29const hrt_address HIVE_IF_SRST_ADDRESS[N_INPUT_FORMATTER_ID] = {
  30        INPUT_FORMATTER0_SRST_OFFSET,
  31        INPUT_FORMATTER1_SRST_OFFSET,
  32        INPUT_FORMATTER2_SRST_OFFSET,
  33        INPUT_FORMATTER3_SRST_OFFSET};
  34
  35const hrt_data HIVE_IF_SRST_MASK[N_INPUT_FORMATTER_ID] = {
  36        INPUT_FORMATTER0_SRST_MASK,
  37        INPUT_FORMATTER1_SRST_MASK,
  38        INPUT_FORMATTER2_SRST_MASK,
  39        INPUT_FORMATTER3_SRST_MASK};
  40
  41const uint8_t HIVE_IF_SWITCH_CODE[N_INPUT_FORMATTER_ID] = {
  42        HIVE_INPUT_SWITCH_SELECT_IF_PRIM,
  43        HIVE_INPUT_SWITCH_SELECT_IF_PRIM,
  44        HIVE_INPUT_SWITCH_SELECT_IF_SEC,
  45        HIVE_INPUT_SWITCH_SELECT_STR_TO_MEM};
  46
  47/* MW Should be part of system_global.h, where we have the main enumeration */
  48static const bool HIVE_IF_BIN_COPY[N_INPUT_FORMATTER_ID] = {
  49        false, false, false, true
  50};
  51
  52void input_formatter_rst(
  53        const input_formatter_ID_t              ID)
  54{
  55        hrt_address     addr;
  56        hrt_data        rst;
  57
  58        assert(ID < N_INPUT_FORMATTER_ID);
  59
  60        addr = HIVE_IF_SRST_ADDRESS[ID];
  61        rst = HIVE_IF_SRST_MASK[ID];
  62
  63        /* TEMPORARY HACK: THIS RESET BREAKS THE METADATA FEATURE
  64         * WICH USES THE STREAM2MEMRY BLOCK.
  65         * MUST BE FIXED PROPERLY
  66         */
  67        if (!HIVE_IF_BIN_COPY[ID]) {
  68                input_formatter_reg_store(ID, addr, rst);
  69        }
  70
  71        return;
  72}
  73
  74unsigned int input_formatter_get_alignment(
  75        const input_formatter_ID_t              ID)
  76{
  77        assert(ID < N_INPUT_FORMATTER_ID);
  78
  79        return input_formatter_alignment[ID];
  80}
  81
  82void input_formatter_set_fifo_blocking_mode(
  83        const input_formatter_ID_t              ID,
  84        const bool                                              enable)
  85{
  86        assert(ID < N_INPUT_FORMATTER_ID);
  87
  88        /* cnd_input_formatter_reg_store() */
  89        if (!HIVE_IF_BIN_COPY[ID]) {
  90                input_formatter_reg_store(ID,
  91                         HIVE_IF_BLOCK_FIFO_NO_REQ_ADDRESS, enable);
  92        }
  93        return;
  94}
  95
  96void input_formatter_get_switch_state(
  97        const input_formatter_ID_t              ID,
  98        input_formatter_switch_state_t  *state)
  99{
 100        assert(ID < N_INPUT_FORMATTER_ID);
 101        assert(state != NULL);
 102
 103        /* We'll change this into an intelligent function to get switch info per IF */
 104        (void)ID;
 105
 106        state->if_input_switch_lut_reg[0] = gp_device_reg_load(GP_DEVICE0_ID, _REG_GP_IFMT_input_switch_lut_reg0);
 107        state->if_input_switch_lut_reg[1] = gp_device_reg_load(GP_DEVICE0_ID, _REG_GP_IFMT_input_switch_lut_reg1);
 108        state->if_input_switch_lut_reg[2] = gp_device_reg_load(GP_DEVICE0_ID, _REG_GP_IFMT_input_switch_lut_reg2);
 109        state->if_input_switch_lut_reg[3] = gp_device_reg_load(GP_DEVICE0_ID, _REG_GP_IFMT_input_switch_lut_reg3);
 110        state->if_input_switch_lut_reg[4] = gp_device_reg_load(GP_DEVICE0_ID, _REG_GP_IFMT_input_switch_lut_reg4);
 111        state->if_input_switch_lut_reg[5] = gp_device_reg_load(GP_DEVICE0_ID, _REG_GP_IFMT_input_switch_lut_reg5);
 112        state->if_input_switch_lut_reg[6] = gp_device_reg_load(GP_DEVICE0_ID, _REG_GP_IFMT_input_switch_lut_reg6);
 113        state->if_input_switch_lut_reg[7] = gp_device_reg_load(GP_DEVICE0_ID, _REG_GP_IFMT_input_switch_lut_reg7);
 114        state->if_input_switch_fsync_lut = gp_device_reg_load(GP_DEVICE0_ID, _REG_GP_IFMT_input_switch_fsync_lut);
 115        state->if_input_switch_ch_id_fmt_type = gp_device_reg_load(GP_DEVICE0_ID, _REG_GP_IFMT_input_switch_ch_id_fmt_type);
 116
 117        return;
 118}
 119
 120void input_formatter_get_state(
 121        const input_formatter_ID_t              ID,
 122        input_formatter_state_t                 *state)
 123{
 124        assert(ID < N_INPUT_FORMATTER_ID);
 125        assert(state != NULL);
 126/*
 127        state->reset = input_formatter_reg_load(ID,
 128                HIVE_IF_RESET_ADDRESS);
 129 */
 130        state->start_line = input_formatter_reg_load(ID,
 131                HIVE_IF_START_LINE_ADDRESS);
 132        state->start_column = input_formatter_reg_load(ID,
 133                HIVE_IF_START_COLUMN_ADDRESS);
 134        state->cropped_height = input_formatter_reg_load(ID,
 135                HIVE_IF_CROPPED_HEIGHT_ADDRESS);
 136        state->cropped_width = input_formatter_reg_load(ID,
 137                HIVE_IF_CROPPED_WIDTH_ADDRESS);
 138        state->ver_decimation = input_formatter_reg_load(ID,
 139                HIVE_IF_VERTICAL_DECIMATION_ADDRESS);
 140        state->hor_decimation = input_formatter_reg_load(ID,
 141                HIVE_IF_HORIZONTAL_DECIMATION_ADDRESS);
 142        state->hor_deinterleaving = input_formatter_reg_load(ID,
 143                HIVE_IF_H_DEINTERLEAVING_ADDRESS);
 144        state->left_padding = input_formatter_reg_load(ID,
 145                HIVE_IF_LEFTPADDING_WIDTH_ADDRESS);
 146        state->eol_offset = input_formatter_reg_load(ID,
 147                HIVE_IF_END_OF_LINE_OFFSET_ADDRESS);
 148        state->vmem_start_address = input_formatter_reg_load(ID,
 149                HIVE_IF_VMEM_START_ADDRESS_ADDRESS);
 150        state->vmem_end_address = input_formatter_reg_load(ID,
 151                HIVE_IF_VMEM_END_ADDRESS_ADDRESS);
 152        state->vmem_increment = input_formatter_reg_load(ID,
 153                HIVE_IF_VMEM_INCREMENT_ADDRESS);
 154        state->is_yuv420 = input_formatter_reg_load(ID,
 155                HIVE_IF_YUV_420_FORMAT_ADDRESS);
 156        state->vsync_active_low = input_formatter_reg_load(ID,
 157                HIVE_IF_VSYNCK_ACTIVE_LOW_ADDRESS);
 158        state->hsync_active_low = input_formatter_reg_load(ID,
 159                HIVE_IF_HSYNCK_ACTIVE_LOW_ADDRESS);
 160        state->allow_fifo_overflow = input_formatter_reg_load(ID,
 161                HIVE_IF_ALLOW_FIFO_OVERFLOW_ADDRESS);
 162        state->block_fifo_when_no_req = input_formatter_reg_load(ID,
 163                HIVE_IF_BLOCK_FIFO_NO_REQ_ADDRESS);
 164        state->ver_deinterleaving = input_formatter_reg_load(ID,
 165                HIVE_IF_V_DEINTERLEAVING_ADDRESS);
 166/* FSM */
 167        state->fsm_sync_status = input_formatter_reg_load(ID,
 168                HIVE_IF_FSM_SYNC_STATUS);
 169        state->fsm_sync_counter = input_formatter_reg_load(ID,
 170                HIVE_IF_FSM_SYNC_COUNTER);
 171        state->fsm_crop_status = input_formatter_reg_load(ID,
 172                HIVE_IF_FSM_CROP_STATUS);
 173        state->fsm_crop_line_counter = input_formatter_reg_load(ID,
 174                HIVE_IF_FSM_CROP_LINE_COUNTER);
 175        state->fsm_crop_pixel_counter = input_formatter_reg_load(ID,
 176                HIVE_IF_FSM_CROP_PIXEL_COUNTER);
 177        state->fsm_deinterleaving_index = input_formatter_reg_load(ID,
 178                HIVE_IF_FSM_DEINTERLEAVING_IDX);
 179        state->fsm_dec_h_counter = input_formatter_reg_load(ID,
 180                HIVE_IF_FSM_DECIMATION_H_COUNTER);
 181        state->fsm_dec_v_counter = input_formatter_reg_load(ID,
 182                HIVE_IF_FSM_DECIMATION_V_COUNTER);
 183        state->fsm_dec_block_v_counter = input_formatter_reg_load(ID,
 184                HIVE_IF_FSM_DECIMATION_BLOCK_V_COUNTER);
 185        state->fsm_padding_status = input_formatter_reg_load(ID,
 186                HIVE_IF_FSM_PADDING_STATUS);
 187        state->fsm_padding_elem_counter = input_formatter_reg_load(ID,
 188                HIVE_IF_FSM_PADDING_ELEMENT_COUNTER);
 189        state->fsm_vector_support_error = input_formatter_reg_load(ID,
 190                HIVE_IF_FSM_VECTOR_SUPPORT_ERROR);
 191        state->fsm_vector_buffer_full = input_formatter_reg_load(ID,
 192                HIVE_IF_FSM_VECTOR_SUPPORT_BUFF_FULL);
 193        state->vector_support = input_formatter_reg_load(ID,
 194                HIVE_IF_FSM_VECTOR_SUPPORT);
 195        state->sensor_data_lost = input_formatter_reg_load(ID,
 196                HIVE_IF_FIFO_SENSOR_STATUS);
 197
 198        return;
 199}
 200
 201void input_formatter_bin_get_state(
 202        const input_formatter_ID_t              ID,
 203        input_formatter_bin_state_t             *state)
 204{
 205        assert(ID < N_INPUT_FORMATTER_ID);
 206        assert(state != NULL);
 207
 208        state->reset = input_formatter_reg_load(ID,
 209                HIVE_STR2MEM_SOFT_RESET_REG_ADDRESS);
 210        state->input_endianness = input_formatter_reg_load(ID,
 211                HIVE_STR2MEM_INPUT_ENDIANNESS_REG_ADDRESS);
 212        state->output_endianness = input_formatter_reg_load(ID,
 213                HIVE_STR2MEM_OUTPUT_ENDIANNESS_REG_ADDRESS);
 214        state->bitswap = input_formatter_reg_load(ID,
 215                HIVE_STR2MEM_BIT_SWAPPING_REG_ADDRESS);
 216        state->block_synch = input_formatter_reg_load(ID,
 217                HIVE_STR2MEM_BLOCK_SYNC_LEVEL_REG_ADDRESS);
 218        state->packet_synch = input_formatter_reg_load(ID,
 219                HIVE_STR2MEM_PACKET_SYNC_LEVEL_REG_ADDRESS);
 220        state->readpostwrite_synch = input_formatter_reg_load(ID,
 221                HIVE_STR2MEM_READ_POST_WRITE_SYNC_ENABLE_REG_ADDRESS);
 222        state->is_2ppc = input_formatter_reg_load(ID,
 223                HIVE_STR2MEM_DUAL_BYTE_INPUTS_ENABLED_REG_ADDRESS);
 224        state->en_status_update = input_formatter_reg_load(ID,
 225                HIVE_STR2MEM_EN_STAT_UPDATE_ADDRESS);
 226        return;
 227}
 228#endif
 229