Make atomisp driver to be generic
Subsystems (4)
cover Make atomisp driver to be generic
This batch of work removed all the #ifdef and made the driver able to drive both ISP2400 and ISP2401. The changes include:
1. #ifdef were removed and the driver execution flow is determined in runtime.
2. ia_css_mipi_frame_enable_check_on_size() wasn't used so it also removed.
3. sh_css_config_input_network() for ISP2400 and ISP2401 was determined in compiler time. This was also renamed to sh_css_config_input_network_2400() and sh_css_config_input_network_2401() for both types of atomisp.
4. The atomisp type test at the begining of the driver was removed so this driver can drive both types of atomisp.
Kate Hsuan (12):
media: atomisp: ia_css_raw.host: Remove #ifdef ISP2401 to make the
driver generic
media: atomisp: binary: Removed #ifdef ISP2401 to make driver generic
media: atomisp: hive_isp_css_include: Removed #ifdef ISP2401 to make
driver generic
media: atomisp: atomisp_compat_css20: Removed #ifdef ISP2401 to make
driver generic
media: atomisp: sh_css_mipi: Removed unused code
ia_css_mipi_frame_enable_check_on_size()
media: atomisp: sh_css: Removed #ifdef ISP2401 to make the driver
generic
media: atomisp: sh_css_sp: Remove #ifdef ISP2401 to make driver
generic
media: atomisp: sh_css: Removed #ifdef ISP2401 to make driver generic
media: atomisp: sh_css: Renamed sh_css_config_input_network()
media: atomisp: sh_css: Removed #ifdef ISP2401 to make code generic
media: atomisp: sh_css: Removed #ifdef ISP2401 to make the driver
generic
media: atomisp: atomisp_v4l2: Removed unnecessary code
.../media/atomisp/pci/atomisp_compat_css20.c | 14 +- .../staging/media/atomisp/pci/atomisp_v4l2.c | 19 -- .../hive_isp_css_include/host/csi_rx_public.h | 2 - .../host/pixelgen_public.h | 2 - .../staging/media/atomisp/pci/ia_css_mipi.h | 16 -- .../isp/kernels/raw/raw_1.0/ia_css_raw.host.c | 21 +- .../atomisp/pci/runtime/binary/src/binary.c | 15 +- drivers/staging/media/atomisp/pci/sh_css.c | 232 ++++++++---------- .../staging/media/atomisp/pci/sh_css_mipi.c | 29 --- drivers/staging/media/atomisp/pci/sh_css_sp.c | 60 ++--- drivers/staging/media/atomisp/pci/sh_css_sp.h | 2 - 11 files changed, 143 insertions(+), 269 deletions(-)
Signature · 1 line
2.41.0
PATCH 1/12 media: atomisp: ia_css_raw.host: Remove #ifdef ISP2401 to make the driver generic
Remove #ifdef from the code and made the code generic. The raw image configuration was determined during runtime.
--- .../isp/kernels/raw/raw_1.0/ia_css_raw.host.c | 21 +++++++------------ 1 file changed, 7 insertions(+), 14 deletions(-)
drivers/staging/media/atomisp/pci/isp/kernels/raw/raw_1.0/ia_css_raw.host.c +7 -14
@@ -73,17 +73,9 @@ int ia_css_raw_config(struct sh_css_isp_raw_isp_config *to,const struct ia_css_frame_info *internal_info = from->internal_info;int ret; -#if !defined(ISP2401 ) -/* 2401 input system uses input width width */ - in_info = internal_info; -#else -/*in some cases, in_info is NULL*/ -if (in_info) - (void )internal_info; -else +if (!IS_ISP2401 || !in_info) in_info = internal_info; -#endif ret =ia_css_dma_configure_from_info (&to->port_b, in_info);if (ret)return ret;
@@ -99,11 +91,12 @@ int ia_css_raw_config(struct sh_css_isp_raw_isp_config *to, to->two_ppc = from->two_ppc; to->stream_format =css2isp_stream_format (from->stream_format); to->deinterleaved = from->deinterleaved; -#if defined(ISP2401 ) - to->start_column = in_info->crop_info.start_column; - to->start_line = in_info->crop_info.start_line; - to->enable_left_padding = from->enable_left_padding; -#endif + +if (IS_ISP2401 ) { + to->start_column = in_info->crop_info.start_column; + to->start_line = in_info->crop_info.start_line; + to->enable_left_padding = from->enable_left_padding; + }return 0 ; }
Signature · 1 line
2.41.0
PATCH 2/12 media: atomisp: binary: Removed #ifdef ISP2401 to make driver generic
In reply to Kate HsuanRemoved #ifdef ISP2401 to make the driver generic. The driver flow is determined in runtime.
--- .../media/atomisp/pci/runtime/binary/src/binary.c | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-)
drivers/staging/media/atomisp/pci/runtime/binary/src/binary.c +8 -7
@@ -604,13 +604,14 @@ binary_in_frame_padded_width(int in_frame_width,int rval;int nr_of_left_paddings;/* number of paddings pixels on the left of an image line */ -#if defined(ISP2401 ) -/* the output image line of Input System 2401 does not have the left paddings */ - nr_of_left_paddings =0 ; -#else -/* in other cases, the left padding pixels are always 128 */ - nr_of_left_paddings =2 *ISP_VEC_NELEMS ; -#endif +if (IS_ISP2401 ) { +/* the output image line of Input System 2401 does not have the left paddings */ + nr_of_left_paddings =0 ; + }else { +/* in other cases, the left padding pixels are always 128 */ + nr_of_left_paddings =2 *ISP_VEC_NELEMS ; + } +if (need_scaling) {/* In SDV use-case, we need to match left-padding of * primary and the video binary. */
Signature · 1 line
2.41.0
PATCH 3/12 media: atomisp: hive_isp_css_include: Removed #ifdef ISP2401 to make driver generic
In reply to Kate HsuanRemoved #ifdef ISP2401 to make the driver generic.
--- .../media/atomisp/pci/hive_isp_css_include/host/csi_rx_public.h | 2 -- .../atomisp/pci/hive_isp_css_include/host/pixelgen_public.h | 2 -- 2 files changed, 4 deletions(-)
drivers/staging/media/atomisp/pci/hive_isp_css_include/host/csi_rx_public.h +0 -2
@@ -16,7 +16,6 @@#ifndef __CSI_RX_PUBLIC_H_INCLUDED__#define __CSI_RX_PUBLIC_H_INCLUDED__ -#ifdef ISP2401 /***************************************************** * * Native command interface (NCI).
@@ -132,5 +131,4 @@ void csi_rx_be_ctrl_reg_store(const hrt_address reg, const hrt_data value);/* end of DLI */ -#endif /* ISP2401 */ #endif /* __CSI_RX_PUBLIC_H_INCLUDED__ */
drivers/staging/media/atomisp/pci/hive_isp_css_include/host/pixelgen_public.h +0 -2
@@ -16,7 +16,6 @@#ifndef __PIXELGEN_PUBLIC_H_INCLUDED__#define __PIXELGEN_PUBLIC_H_INCLUDED__ -#ifdef ISP2401 /***************************************************** * * Native command interface (NCI).
@@ -76,5 +75,4 @@ STORAGE_CLASS_PIXELGEN_H void pixelgen_ctrl_reg_store( const hrt_data value);/* end of DLI */ -#endif /* ISP2401 */ #endif /* __PIXELGEN_PUBLIC_H_INCLUDED__ */
Signature · 1 line
2.41.0
PATCH 4/12 media: atomisp: atomisp_compat_css20: Removed #ifdef ISP2401 to make driver generic
In reply to Kate HsuanRemoved #ifdef ISP2401 to make code to be generic. The driver flow if determined in runtime.
--- .../media/atomisp/pci/atomisp_compat_css20.c | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-)
drivers/staging/media/atomisp/pci/atomisp_compat_css20.c +6 -8
@@ -850,19 +850,17 @@ int atomisp_css_irq_translate(struct atomisp_device *isp,void atomisp_css_rx_get_irq_info (enum mipi_port_id port,unsigned int *infos) { -#ifndef ISP2401 -ia_css_isys_rx_get_irq_info (port, infos); -#else - *infos =0 ; -#endif +if (IS_ISP2401 ) + *infos =0 ; +else +ia_css_isys_rx_get_irq_info (port, infos); }void atomisp_css_rx_clear_irq_info (enum mipi_port_id port,unsigned int infos) { -#ifndef ISP2401 -ia_css_isys_rx_clear_irq_info (port, infos); -#endif +if (!IS_ISP2401 ) +ia_css_isys_rx_clear_irq_info (port, infos); } int atomisp_css_irq_enable(struct atomisp_device *isp,
Signature · 1 line
2.41.0
PATCH 5/12 media: atomisp: sh_css_mipi: Removed unused code ia_css_mipi_frame_enable_check_on_size()
In reply to Kate Hsuania_css_mipi_frame_enable_check_on_size() wasn't used by any functions. So, it can be removed.
--- .../staging/media/atomisp/pci/ia_css_mipi.h | 16 ---------- .../staging/media/atomisp/pci/sh_css_mipi.c | 29 ------------------- 2 files changed, 45 deletions(-)
drivers/staging/media/atomisp/pci/ia_css_mipi.h +0 -16
@@ -25,22 +25,6 @@#include "ia_css_stream_format.h" #include "ia_css_input_port.h" -/* @brief Register size of a CSS MIPI frame for check during capturing. -* -* @param[in] port CSI-2 port this check is registered. -* @param[in] size_mem_words The frame size in memory words (32B). -* @return Return the error in case of failure. E.g. MAX_NOF_ENTRIES REACHED -* -* Register size of a CSS MIPI frame to check during capturing. Up to -* IA_CSS_MIPI_SIZE_CHECK_MAX_NOF_ENTRIES entries per port allowed. Entries are reset -* when stream is stopped. -* -* -*/ -int -ia_css_mipi_frame_enable_check_on_size (const enum mipi_port_id port, -const unsigned int size_mem_words); -/* @brief Calculate the size of a mipi frame. * * @param[in] width The width (in pixels) of the frame.
drivers/staging/media/atomisp/pci/sh_css_mipi.c +0 -29
@@ -185,35 +185,6 @@ ia_css_mipi_frame_calculate_size(const unsigned int width,return err; } -/* -* Check if a source port or TPG/PRBS ID is valid -*/ - -#if !defined(ISP2401 ) -int -ia_css_mipi_frame_enable_check_on_size (const enum mipi_port_id port, -const unsigned int size_mem_words) -{ -u32 idx; - -int err = -EBUSY ; - -OP___assert (port <N_CSI_PORTS ); -OP___assert (size_mem_words !=0 ); - -for (idx =0 ; idx <IA_CSS_MIPI_SIZE_CHECK_MAX_NOF_ENTRIES_PER_PORT && - my_css.mipi_sizes_for_check[port][idx] !=0 ; - idx++) {/* do nothing */ - } -if (idx <IA_CSS_MIPI_SIZE_CHECK_MAX_NOF_ENTRIES_PER_PORT ) { - my_css.mipi_sizes_for_check[port][idx] = size_mem_words; - err =0 ; - } - -return err; -} -#endif -void mipi_init (void ) {
Signature · 1 line
2.41.0
PATCH 6/12 media: atomisp: sh_css: Removed #ifdef ISP2401 to make the driver generic
In reply to Kate HsuanRemoved #ifdef ISP2401 to expose the necessary functions for ISP2401 and also make the driver generic.
--- drivers/staging/media/atomisp/pci/sh_css.c | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-)
drivers/staging/media/atomisp/pci/sh_css.c +5 -7
@@ -2957,7 +2957,6 @@ init_vf_frameinfo_defaults(struct ia_css_pipe *pipe,return err; } -#ifdef ISP2401 static unsigned int get_crop_lines_for_bayer_order (const struct ia_css_stream_config *config) {
@@ -3059,11 +3058,11 @@ ia_css_get_crop_offsets( pipe->config.input_effective_res.height); input_res = &pipe->stream->config.input_config.input_res; -#ifndef ISP2401 - effective_res = &pipe->stream->config.input_config.effective_res; -#else - effective_res = &pipe->config.input_effective_res; -#endif + +if (IS_ISP2401 ) + effective_res = &pipe->config.input_effective_res; +else + effective_res = &pipe->stream->config.input_config.effective_res;get_pipe_extra_pixel (pipe, &extra_row, &extra_col);
@@ -3101,7 +3100,6 @@ ia_css_get_crop_offsets(return ; } -#endif static int init_in_frameinfo_memory_defaults(struct ia_css_pipe *pipe,
Signature · 1 line
2.41.0
PATCH 7/12 media: atomisp: sh_css_sp: Remove #ifdef ISP2401 to make driver generic
In reply to Kate HsuanRemoved #ifdef ISP2401 to make the driver generic. The uncessary codes were removed and the types of the ISP is determines in runtime.
--- drivers/staging/media/atomisp/pci/sh_css_sp.c | 60 +++++++------------ drivers/staging/media/atomisp/pci/sh_css_sp.h | 2 - 2 files changed, 21 insertions(+), 41 deletions(-)
drivers/staging/media/atomisp/pci/sh_css_sp.c +21 -39
@@ -17,9 +17,7 @@#include "sh_css_sp.h" -#if !defined(ISP2401 )#include "input_formatter.h" -#endif #include "dma.h" /* N_DMA_CHANNEL_ID */
@@ -227,11 +225,8 @@ sh_css_sp_start_binary_copy(unsigned int pipe_num,IA_CSS_LOG ("pipe_id %d port_config %08x" , pipe->pipe_id, pipe->inout_port_config); -#if !defined(ISP2401 ) - sh_css_sp_group.config.input_formatter.isp_2ppc = (uint8_t )two_ppc; -#else - (void )two_ppc; -#endif +if (!IS_ISP2401 ) + sh_css_sp_group.config.input_formatter.isp_2ppc = (uint8_t )two_ppc; sh_css_sp_stage.num = stage_num; sh_css_sp_stage.stage_type =SH_CSS_SP_STAGE_TYPE ;
@@ -305,11 +300,8 @@ sh_css_sp_start_raw_copy(struct ia_css_frame *out_frame,IA_CSS_LOG ("pipe_id %d port_config %08x" , pipe->pipe_id, pipe->inout_port_config); -#if !defined(ISP2401 ) - sh_css_sp_group.config.input_formatter.isp_2ppc = (uint8_t )two_ppc; -#else - (void )two_ppc; -#endif +if (!IS_ISP2401 ) + sh_css_sp_group.config.input_formatter.isp_2ppc = (uint8_t )two_ppc; sh_css_sp_stage.num = stage_num; sh_css_sp_stage.xmem_bin_addr =0x0 ;
@@ -654,7 +646,6 @@ void sh_css_sp_set_if_configs(return ; } -#if !defined(ISP2401 ) void sh_css_sp_program_input_circuit(int fmt_type, int ch_id,
@@ -671,9 +662,7 @@ sh_css_sp_program_input_circuit(int fmt_type, sh_css_sp_group.config.input_circuit_cfg_changed = true; sh_css_sp_stage.program_input_circuit = true; } -#endif -#if !defined(ISP2401 ) void sh_css_sp_configure_sync_gen(int width, int height, int hblank_cycles,
@@ -704,7 +693,6 @@ sh_css_sp_configure_prbs(int seed) { sh_css_sp_group.config.prbs.seed = seed; } -#endif void sh_css_sp_configure_enable_raw_pool_locking (bool lock_all)
@@ -754,22 +742,18 @@ sh_css_sp_init_group(bool two_ppc, bool no_isp_sync, uint8_t if_config_index) { -#if !defined(ISP2401 ) - sh_css_sp_group.config.input_formatter.isp_2ppc = two_ppc; -#else - (void )two_ppc; -#endif +if (!IS_ISP2401 ) + sh_css_sp_group.config.input_formatter.isp_2ppc = two_ppc; sh_css_sp_group.config.no_isp_sync = (uint8_t )no_isp_sync;/* decide whether the frame is processed online or offline */ if (if_config_index ==SH_CSS_IF_CONFIG_NOT_NEEDED )return ; -#if !defined(ISP2401 ) -assert (if_config_index <SH_CSS_MAX_IF_CONFIGS ); - sh_css_sp_group.config.input_formatter.set[if_config_index].stream_format = - input_format; -#else - (void )input_format; -#endif + +if (!IS_ISP2401 ) { +assert (if_config_index <SH_CSS_MAX_IF_CONFIGS ); + sh_css_sp_group.config.input_formatter.set[if_config_index].stream_format = + input_format; + } }void
@@ -1028,18 +1012,16 @@ sh_css_sp_init_stage(struct ia_css_binary *binary,if (err)return err; -#ifdef ISP2401 - pipe =find_pipe_by_num (sh_css_sp_group.pipe[thread_id].pipe_num); -if (!pipe) -return -EINVAL ; +if (IS_ISP2401 ) { + pipe =find_pipe_by_num (sh_css_sp_group.pipe[thread_id].pipe_num); +if (!pipe) +return -EINVAL ; -if (args->in_frame) -ia_css_get_crop_offsets (pipe, &args->in_frame->frame_info); -else -ia_css_get_crop_offsets (pipe, &binary->in_frame_info); -#else - (void )pipe;/*avoid build warning*/ -#endif +if (args->in_frame) +ia_css_get_crop_offsets (pipe, &args->in_frame->frame_info); +else +ia_css_get_crop_offsets (pipe, &binary->in_frame_info); + } err =configure_isp_from_args (&sh_css_sp_group.pipe[thread_id], binary, args, two_ppc, sh_css_sp_stage.deinterleaved);
drivers/staging/media/atomisp/pci/sh_css_sp.h +0 -2
@@ -18,9 +18,7 @@#include <system_global.h> #include <type_support.h> -#if !defined(ISP2401 )#include "input_formatter.h" -#endif #include "ia_css_binary.h" #include "ia_css_types.h"
Signature · 1 line
2.41.0
PATCH 8/12 media: atomisp: sh_css: Removed #ifdef ISP2401 to make driver generic
In reply to Kate HsuanRemoved #ifdef ISP2401 to expose ia_css_stream_configure_rx() for ISP2400.
--- drivers/staging/media/atomisp/pci/sh_css.c | 54 +++++++++------------- 1 file changed, 22 insertions(+), 32 deletions(-)
drivers/staging/media/atomisp/pci/sh_css.c +22 -32
@@ -56,9 +56,7 @@#include "assert_support.h" #include "math_support.h" #include "sw_event_global.h" /* Event IDs.*/ -#if !defined(ISP2401 )#include "ia_css_ifmtr.h" -#endif #include "input_system.h" #include "mmu_device.h" /* mmu_set_page_table_base_index(), ... */ #include "ia_css_mmu_private.h" /* sh_css_mmu_set_page_table_base_index() */
@@ -345,7 +343,6 @@ static struct sh_css_hmm_buffer_record *sh_css_hmm_buffer_record_validate(ia_css_ptr ddr_buffer_addr, enum ia_css_buffer_type type); -#ifdef ISP2401 static unsigned int get_crop_lines_for_bayer_order (const struct ia_css_stream_config *config); static unsigned int get_crop_columns_for_bayer_order(const struct
@@ -353,8 +350,6 @@ static unsigned int get_crop_columns_for_bayer_order(const structstatic void get_pipe_extra_pixel (struct ia_css_pipe *pipe,unsigned int *extra_row,unsigned int *extra_column); -#endif -static void sh_css_pipe_free_shading_table (struct ia_css_pipe *pipe) {
@@ -7971,7 +7966,6 @@ ia_css_pipe_override_frame_format(struct ia_css_pipe *pipe,return err; } -#if !defined(ISP2401 )/* Configuration of INPUT_SYSTEM_VERSION_2401 is done on SP */ static int ia_css_stream_configure_rx (struct ia_css_stream *stream)
@@ -8014,7 +8008,6 @@ ia_css_stream_configure_rx(struct ia_css_stream *stream) stream->reconfigure_css_rx = true;return 0 ; } -#endif static struct ia_css_pipe * find_pipe(struct ia_css_pipe *pipes[], unsigned int num_pipes,
@@ -8100,9 +8093,7 @@ ia_css_stream_create(const struct ia_css_stream_config *stream_config,/* check if mipi size specified */ if (stream_config->mode ==IA_CSS_INPUT_MODE_BUFFERED_SENSOR ) -#ifdef ISP2401 - if (!stream_config->online) -#endif +if (!IS_ISP2401 || (IS_ISP2401 && !stream_config->online)) {unsigned int port = (unsigned int )stream_config->source.port.port;
@@ -8203,32 +8194,31 @@ ia_css_stream_create(const struct ia_css_stream_config *stream_config,switch (curr_stream->config.mode) {case IA_CSS_INPUT_MODE_SENSOR :case IA_CSS_INPUT_MODE_BUFFERED_SENSOR : -#if !defined(ISP2401 ) -ia_css_stream_configure_rx (curr_stream); -#endif +if (!IS_ISP2401 ) +ia_css_stream_configure_rx (curr_stream);break ;case IA_CSS_INPUT_MODE_TPG : -#if !defined(ISP2401 ) -IA_CSS_LOG ("tpg_configuration: x_mask=%d, y_mask=%d, x_delta=%d, y_delta=%d, xy_mask=%d" , - curr_stream->config.source.tpg.x_mask, - curr_stream->config.source.tpg.y_mask, - curr_stream->config.source.tpg.x_delta, - curr_stream->config.source.tpg.y_delta, - curr_stream->config.source.tpg.xy_mask); - -sh_css_sp_configure_tpg ( - curr_stream->config.source.tpg.x_mask, - curr_stream->config.source.tpg.y_mask, - curr_stream->config.source.tpg.x_delta, - curr_stream->config.source.tpg.y_delta, - curr_stream->config.source.tpg.xy_mask); -#endif +if (!IS_ISP2401 ) { +IA_CSS_LOG ("tpg_configuration: x_mask=%d, y_mask=%d, x_delta=%d, y_delta=%d, xy_mask=%d" , + curr_stream->config.source.tpg.x_mask, + curr_stream->config.source.tpg.y_mask, + curr_stream->config.source.tpg.x_delta, + curr_stream->config.source.tpg.y_delta, + curr_stream->config.source.tpg.xy_mask); + +sh_css_sp_configure_tpg ( + curr_stream->config.source.tpg.x_mask, + curr_stream->config.source.tpg.y_mask, + curr_stream->config.source.tpg.x_delta, + curr_stream->config.source.tpg.y_delta, + curr_stream->config.source.tpg.xy_mask); + }break ;case IA_CSS_INPUT_MODE_PRBS : -#if !defined(ISP2401 ) -IA_CSS_LOG ("mode prbs" ); -sh_css_sp_configure_prbs (curr_stream->config.source.prbs.seed); -#endif +if (!IS_ISP2401 ) { +IA_CSS_LOG ("mode prbs" ); +sh_css_sp_configure_prbs (curr_stream->config.source.prbs.seed); + }break ;case IA_CSS_INPUT_MODE_MEMORY :IA_CSS_LOG ("mode memory" );
Signature · 1 line
2.41.0
PATCH 9/12 media: atomisp: sh_css: Renamed sh_css_config_input_network()
In reply to Kate Hsuansh_css_config_input_network() is renamed to sh_css_config_input_network_2400() and sh_css_config_input_network_2401() since a generic driver should cover the implementation for both types.
--- drivers/staging/media/atomisp/pci/sh_css.c | 52 +++++++++------------- 1 file changed, 21 insertions(+), 31 deletions(-)
drivers/staging/media/atomisp/pci/sh_css.c +21 -31
@@ -467,9 +467,8 @@ ia_css_stream_input_format_bits_per_pixel(struct ia_css_stream *stream)/* TODO: move define to proper file in tools */ #define GP_ISEL_TPG_MODE 0x90058 -#if !defined(ISP2401 )static int -sh_css_config_input_network (struct ia_css_stream *stream) +sh_css_config_input_network_2400 (struct ia_css_stream *stream) {unsigned int fmt_type;struct ia_css_pipe *pipe = stream->last_pipe;
@@ -523,7 +522,7 @@ sh_css_config_input_network(struct ia_css_stream *stream) "sh_css_config_input_network() leave:\n");return 0 ; } -#elif defined(ISP2401) +static unsigned int csi2_protocol_calculate_max_subpixels_per_line (enum atomisp_input_format format,unsigned int pixels_per_line)
@@ -819,9 +818,10 @@ static bool sh_css_translate_stream_cfg_to_input_system_input_port_attr( stream_cfg->source.port.num_lanes; isys_stream_descr->csi_port_attr.fmt_type = fmt_type; isys_stream_descr->csi_port_attr.ch_id = stream_cfg->channel_id; -#ifdef ISP2401 - isys_stream_descr->online = stream_cfg->online; -#endif + +if (IS_ISP2401 ) + isys_stream_descr->online = stream_cfg->online; + err |=ia_css_isys_convert_compressed_format ( &stream_cfg->source.port.compression, isys_stream_descr);
@@ -844,15 +844,15 @@ static bool sh_css_translate_stream_cfg_to_input_system_input_port_attr( stream_cfg->metadata_config.resolution.width; isys_stream_descr->metadata.lines_per_frame = stream_cfg->metadata_config.resolution.height; -#ifdef ISP2401 +/* * For new input system, number of str2mmio requests must be even. * So we round up number of metadata lines to be even. */ -if (isys_stream_descr->metadata.lines_per_frame >0 ) +if (IS_ISP2401 && isys_stream_descr->metadata.lines_per_frame >0 ) isys_stream_descr->metadata.lines_per_frame += (isys_stream_descr->metadata.lines_per_frame &1 ); -#endif + isys_stream_descr->metadata.align_req_in_bytes =ia_css_csi2_calculate_input_system_alignment ( stream_cfg->metadata_config.data_type);
@@ -967,7 +967,7 @@ static bool sh_css_translate_binary_info_to_input_system_output_port_attr( }static int -sh_css_config_input_network (struct ia_css_stream *stream) +sh_css_config_input_network_2401 (struct ia_css_stream *stream) {bool rc;ia_css_isys_descr_t isys_stream_descr;
@@ -1176,7 +1176,6 @@ static inline int stream_unregister_with_csi_rx( {return stream_csi_rx_helper (stream, ia_css_isys_csi_rx_unregister_stream); } -#endif static void
@@ -1189,14 +1188,11 @@ start_binary(struct ia_css_pipe *pipe,if (binary)sh_css_metrics_start_binary (&binary->metrics); - -#if !defined(ISP2401 ) -if (pipe->stream->reconfigure_css_rx) { +if (!IS_ISP2401 && pipe->stream->reconfigure_css_rx) {ia_css_isys_rx_configure (&pipe->stream->csi_rx_config, pipe->stream->config.mode); pipe->stream->reconfigure_css_rx = false; } -#endif }/* start the copy function on the SP */
@@ -1209,22 +1205,18 @@ start_copy_on_sp(struct ia_css_pipe *pipe,if ((!pipe) || (!pipe->stream))return -EINVAL ; -#if !defined(ISP2401 ) -if (pipe->stream->reconfigure_css_rx) +if (!IS_ISP2401 && pipe->stream->reconfigure_css_rx)ia_css_isys_rx_disable (); -#endif if (pipe->stream->config.input_config.format !=ATOMISP_INPUT_FORMAT_BINARY_8 )return -EINVAL ;sh_css_sp_start_binary_copy (ia_css_pipe_get_pipe_num (pipe), out_frame, pipe->stream->config.pixels_per_clock ==2 ); -#if !defined(ISP2401 ) -if (pipe->stream->reconfigure_css_rx) { +if (!IS_ISP2401 && pipe->stream->reconfigure_css_rx) {ia_css_isys_rx_configure (&pipe->stream->csi_rx_config, pipe->stream->config.mode); pipe->stream->reconfigure_css_rx = false; } -#endif return 0 ; }
@@ -4466,7 +4458,6 @@ ia_css_stream_get_buffer_depth(struct ia_css_stream *stream,return 0 ; } -#if !defined(ISP2401 )unsigned int sh_css_get_mipi_sizes_for_check (const unsigned int port,const unsigned int idx) {
@@ -4477,7 +4468,6 @@ sh_css_get_mipi_sizes_for_check(const unsigned int port, const unsigned int idx) port, idx, my_css.mipi_sizes_for_check[port][idx]);return my_css.mipi_sizes_for_check[port][idx]; } -#endif static int sh_css_pipe_configure_output( struct ia_css_pipe *pipe,
@@ -8592,15 +8582,13 @@ ia_css_stream_start(struct ia_css_stream *stream)return err; } -#if defined(ISP2401 ) -if ((stream->config.mode ==IA_CSS_INPUT_MODE_SENSOR ) || - (stream->config.mode ==IA_CSS_INPUT_MODE_BUFFERED_SENSOR )) +if (IS_ISP2401 && + ((stream->config.mode ==IA_CSS_INPUT_MODE_SENSOR ) || + (stream->config.mode ==IA_CSS_INPUT_MODE_BUFFERED_SENSOR )))stream_register_with_csi_rx (stream); -#endif -#if !defined(ISP2401 )/* Initialize mipi size checks */ -if (stream->config.mode ==IA_CSS_INPUT_MODE_BUFFERED_SENSOR ) { +if (!IS_ISP2401 && stream->config.mode ==IA_CSS_INPUT_MODE_BUFFERED_SENSOR ) {unsigned int idx;unsigned int port = (unsigned int )(stream->config.source.port.port);
@@ -8609,10 +8597,12 @@ ia_css_stream_start(struct ia_css_stream *stream)sh_css_get_mipi_sizes_for_check (port, idx); } } -#endif if (stream->config.mode !=IA_CSS_INPUT_MODE_MEMORY ) { - err =sh_css_config_input_network (stream); +if (IS_ISP2401 ) + err =sh_css_config_input_network_2401 (stream); +else + err =sh_css_config_input_network_2400 (stream);if (err)return err; }
Signature · 1 line
2.41.0
PATCH 10/12 media: atomisp: sh_css: Removed #ifdef ISP2401 to make code generic
In reply to Kate HsuanRemoved #ifdef ISP2401 to allow the destroy function can destroy the data of both types of ISP.
--- drivers/staging/media/atomisp/pci/sh_css.c | 72 +++++++++++----------- 1 file changed, 36 insertions(+), 36 deletions(-)
drivers/staging/media/atomisp/pci/sh_css.c +36 -36
@@ -8450,46 +8450,46 @@ ia_css_stream_destroy(struct ia_css_stream *stream)if ((stream->last_pipe) &&ia_css_pipeline_is_mapped (stream->last_pipe->pipe_num)) { -#if defined(ISP2401 ) -for (i =0 ; i < stream->num_pipes; i++) { -struct ia_css_pipe *entry = stream->pipes[i]; -unsigned int sp_thread_id; -struct sh_css_sp_pipeline_terminal *sp_pipeline_input_terminal; - -assert (entry); -if (entry) { -/* get the SP thread id */ -if (!ia_css_pipeline_get_sp_thread_id ( -ia_css_pipe_get_pipe_num (entry), &sp_thread_id)) -return -EINVAL ; -/* get the target input terminal */ - sp_pipeline_input_terminal = - &sh_css_sp_group.pipe_io[sp_thread_id].input; - -for (i =0 ; i <IA_CSS_STREAM_MAX_ISYS_STREAM_PER_CH ; i++) { -ia_css_isys_stream_h isys_stream = - &sp_pipeline_input_terminal->context.virtual_input_system_stream[i]; -if (stream->config.isys_config[i].valid && isys_stream->valid) -ia_css_isys_stream_destroy (isys_stream); - } - } - } -if (stream->config.mode ==IA_CSS_INPUT_MODE_BUFFERED_SENSOR ) { +if (IS_ISP2401 ) {for (i =0 ; i < stream->num_pipes; i++) {struct ia_css_pipe *entry = stream->pipes[i]; -/* -* free any mipi frames that are remaining: -* some test stream create-destroy cycles do -* not generate output frames -* and the mipi buffer is not freed in the -* deque function -*/ -if (entry) -free_mipi_frames (entry); +unsigned int sp_thread_id; +struct sh_css_sp_pipeline_terminal *sp_pipeline_input_terminal; + +assert (entry); +if (entry) { +/* get the SP thread id */ +if (!ia_css_pipeline_get_sp_thread_id ( +ia_css_pipe_get_pipe_num (entry), &sp_thread_id)) +return -EINVAL ; +/* get the target input terminal */ + sp_pipeline_input_terminal = + &sh_css_sp_group.pipe_io[sp_thread_id].input; + +for (i =0 ; i <IA_CSS_STREAM_MAX_ISYS_STREAM_PER_CH ; i++) { +ia_css_isys_stream_h isys_stream = + &sp_pipeline_input_terminal->context.virtual_input_system_stream[i]; +if (stream->config.isys_config[i].valid && isys_stream->valid) +ia_css_isys_stream_destroy (isys_stream); + } + } } +if (stream->config.mode ==IA_CSS_INPUT_MODE_BUFFERED_SENSOR ) { +for (i =0 ; i < stream->num_pipes; i++) { +struct ia_css_pipe *entry = stream->pipes[i]; +/* +* free any mipi frames that are remaining: +* some test stream create-destroy cycles do +* not generate output frames +* and the mipi buffer is not freed in the +* deque function +*/ +if (entry) +free_mipi_frames (entry); + } + } +stream_unregister_with_csi_rx (stream); } -stream_unregister_with_csi_rx (stream); -#endif for (i =0 ; i < stream->num_pipes; i++) {struct ia_css_pipe *curr_pipe = stream->pipes[i];
Signature · 1 line
2.41.0
PATCH 11/12 media: atomisp: sh_css: Removed #ifdef ISP2401 to make the driver generic
In reply to Kate HsuanRemoved #ifdef ISP2401 to make the driver generic.
--- drivers/staging/media/atomisp/pci/sh_css.c | 42 +++++++++------------- 1 file changed, 17 insertions(+), 25 deletions(-)
drivers/staging/media/atomisp/pci/sh_css.c +17 -25
@@ -1298,9 +1298,7 @@ sh_css_invalidate_shading_tables(struct ia_css_stream *stream)static void enable_interrupts (enum ia_css_irq_type irq_type) { -#ifndef ISP2401 enum mipi_port_id port; -#endif bool enable_pulse = irq_type !=IA_CSS_IRQ_TYPE_EDGE ;IA_CSS_ENTER_PRIVATE ("" );
@@ -1321,10 +1319,10 @@ enable_interrupts(enum ia_css_irq_type irq_type) (enum virq_id )(IRQ_SW_CHANNEL1_ID +IRQ_SW_CHANNEL_OFFSET ), true); -#ifndef ISP2401 -for (port =0 ; port <N_MIPI_PORT_ID ; port++) -ia_css_isys_rx_enable_all_interrupts (port); -#endif +if (!IS_ISP2401 ) { +for (port =0 ; port <N_MIPI_PORT_ID ; port++) +ia_css_isys_rx_enable_all_interrupts (port); + }IA_CSS_LEAVE_PRIVATE ("" ); }
@@ -2160,10 +2158,10 @@ ia_css_uninit(void)ia_css_rmgr_uninit (); -#if !defined(ISP2401 ) -/* needed for reprogramming the inputformatter after power cycle of css */ - ifmtr_set_if_blocking_mode_reset = true; -#endif +if (!IS_ISP2401 ) { +/* needed for reprogramming the inputformatter after power cycle of css */ + ifmtr_set_if_blocking_mode_reset = true; + }if (!fw_explicitly_loaded)ia_css_unload_firmware ();
@@ -3117,9 +3115,10 @@ init_in_frameinfo_memory_defaults(struct ia_css_pipe *pipe,ia_css_query_internal_queue_id (IA_CSS_BUFFER_TYPE_INPUT_FRAME , thread_id, &queue_id); in_frame->dynamic_queue_id = queue_id; in_frame->buf_type =IA_CSS_BUFFER_TYPE_INPUT_FRAME ; -#ifdef ISP2401 -ia_css_get_crop_offsets (pipe, &in_frame->frame_info); -#endif + +if (IS_ISP2401 ) +ia_css_get_crop_offsets (pipe, &in_frame->frame_info); + err =ia_css_frame_init_planes (in_frame); ia_css_debug_dtrace(IA_CSS_DEBUG_TRACE_PRIVATE, "%s() bayer_order = %d\n",
@@ -7365,19 +7364,18 @@ static int capture_start(struct ia_css_pipe *pipe)start_pipe (pipe, copy_ovrd, pipe->stream->config.mode); -#if !defined(ISP2401 )/* * old isys: for IA_CSS_PIPE_MODE_COPY pipe, isys rx has to be configured, * which is currently done in start_binary(); but COPY pipe contains no binary, * and does not call start_binary(); so we need to configure the rx here. */ -if (pipe->config.mode ==IA_CSS_PIPE_MODE_COPY && +if (!IS_ISP2401 && + pipe->config.mode ==IA_CSS_PIPE_MODE_COPY && pipe->stream->reconfigure_css_rx) {ia_css_isys_rx_configure (&pipe->stream->csi_rx_config, pipe->stream->config.mode); pipe->stream->reconfigure_css_rx = false; } -#endif IA_CSS_LEAVE_ERR_PRIVATE (err);return err;
@@ -7599,11 +7597,8 @@ void ia_css_stream_request_flash(struct ia_css_stream *stream)ia_css_debug_dtrace (IA_CSS_DEBUG_TRACE ,"ia_css_stream_request_flash() enter: void\n" ); -#ifndef ISP2401 -sh_css_write_host2sp_command (host2sp_cmd_start_flash); -#else -if (sh_css_sp_is_running ()) { -if (!sh_css_write_host2sp_command (host2sp_cmd_start_flash)) { +if (!IS_ISP2401 ||sh_css_sp_is_running ()) { +if (!sh_css_write_host2sp_command (host2sp_cmd_start_flash) &&IS_ISP2401 ) {IA_CSS_ERROR ("Call to 'sh-css_write_host2sp_command()' failed" );ia_css_debug_dump_sp_sw_debug_info (); }
@@ -7611,7 +7606,6 @@ void ia_css_stream_request_flash(struct ia_css_stream *stream)IA_CSS_LOG ("SP is not running!" ); } -#endif ia_css_debug_dtrace (IA_CSS_DEBUG_TRACE ,"ia_css_stream_request_flash() leave: return_void\n" ); }
@@ -8623,16 +8617,14 @@ ia_css_stream_stop(struct ia_css_stream *stream)ia_css_debug_dtrace (IA_CSS_DEBUG_TRACE ,"ia_css_stream_stop: stopping %d\n" , stream->last_pipe->mode); -#if !defined(ISP2401 )/* De-initialize mipi size checks */ -if (stream->config.mode ==IA_CSS_INPUT_MODE_BUFFERED_SENSOR ) { +if (!IS_ISP2401 && stream->config.mode ==IA_CSS_INPUT_MODE_BUFFERED_SENSOR ) {unsigned int idx;unsigned int port = (unsigned int )(stream->config.source.port.port);for (idx =0 ; idx <IA_CSS_MIPI_SIZE_CHECK_MAX_NOF_ENTRIES_PER_PORT ; idx++) sh_css_sp_group.config.mipi_sizes_for_check[port][idx] =0 ; } -#endif err =ia_css_pipeline_request_stop (&stream->last_pipe->pipeline);if (err)
Signature · 1 line
2.41.0
PATCH 12/12 media: atomisp: atomisp_v4l2: Removed unnecessary code
In reply to Kate HsuanHere is the last step of #ifdef ISP2401 removal work. Since the driver became generic, this part of the code was no longer needed and can be removed.
--- .../staging/media/atomisp/pci/atomisp_v4l2.c | 19 ------------------- 1 file changed, 19 deletions(-)
drivers/staging/media/atomisp/pci/atomisp_v4l2.c +0 -19
@@ -1206,25 +1206,6 @@ static bool is_valid_device(struct pci_dev *pdev, const struct pci_device_id *idreturn false; } -/* -* FIXME: -* remove the if once the driver become generic -*/ - -#ifndef ISP2401 -if (IS_ISP2401 ) { -dev_err (&pdev->dev,"Support for %s (ISP2401) was disabled at compile time\n" , - name); -return false; - } -#else -if (!IS_ISP2401 ) { -dev_err (&pdev->dev,"Support for %s (ISP2400) was disabled at compile time\n" , - name); -return false; - } -#endif -dev_info (&pdev->dev,"Detected %s version %d (ISP240%c) on %s\n" , name, pdev->revision,IS_ISP2401 ?'1' :'0' , product);
Signature · 1 line
2.41.0
Hi Kate,
Quoted 13 lines · Kate Hsuan
This batch of work removed all the #ifdef and made the driver able to drive both ISP2400 and ISP2401. The changes include:
1. #ifdef were removed and the driver execution flow is determined in runtime.
2.ia_css_mipi_frame_enable_check_on_size()wasn't used so it also removed.
3.sh_css_config_input_network()for ISP2400 and ISP2401 was determined in compiler time. This was also renamed tosh_css_config_input_network_2400()andsh_css_config_input_network_2401()for both types of atomisp.
4. The atomisp type test at the begining of the driver was removed so this driver can drive both types of atomisp.
Thank you, all 12 patches look good to me:
for the series.
And I have merged this into my hansg/media-atomisp branch now.
Regards,
Hans
Quoted 34 lines
Kate Hsuan (12):
media: atomisp: ia_css_raw.host: Remove #ifdef ISP2401 to make the
driver generic
media: atomisp: binary: Removed #ifdef ISP2401 to make driver generic
media: atomisp:hive_isp_css_include: Removed #ifdef ISP2401 to make
driver generic
media: atomisp:atomisp_compat_css20: Removed #ifdef ISP2401 to make
driver generic
media: atomisp:sh_css_mipi: Removed unused code
ia_css_mipi_frame_enable_check_on_size()
media: atomisp:sh_css: Removed #ifdef ISP2401 to make the driver
generic
media: atomisp:sh_css_sp: Remove #ifdef ISP2401 to make driver
generic
media: atomisp:sh_css: Removed #ifdef ISP2401 to make driver generic
media: atomisp:sh_css: Renamedsh_css_config_input_network()
media: atomisp:sh_css: Removed #ifdef ISP2401 to make code generic
media: atomisp:sh_css: Removed #ifdef ISP2401 to make the driver
generic
media: atomisp:atomisp_v4l2: Removed unnecessary code.../media/atomisp/pci/atomisp_compat_css20.c | 14 +- .../staging/media/atomisp/pci/atomisp_v4l2.c | 19 -- .../hive_isp_css_include/host/csi_rx_public.h | 2 - .../host/pixelgen_public.h | 2 - .../staging/media/atomisp/pci/ia_css_mipi.h | 16 -- .../isp/kernels/raw/raw_1.0/ia_css_raw.host.c | 21 +- .../atomisp/pci/runtime/binary/src/binary.c | 15 +- drivers/staging/media/atomisp/pci/sh_css.c | 232 ++++++++---------- .../staging/media/atomisp/pci/sh_css_mipi.c | 29 --- drivers/staging/media/atomisp/pci/sh_css_sp.c | 60 ++--- drivers/staging/media/atomisp/pci/sh_css_sp.h | 2 - 11 files changed, 143 insertions(+), 269 deletions(-)