Commit 406ae760 authored by Mauro Carvalho Chehab's avatar Mauro Carvalho Chehab
Browse files

media: atomisp: sh_css: detect ISP version at runtime



Get rid of all those ifdefs that were checking for ISP2401 inside
sh_css.c.

Signed-off-by: default avatarMauro Carvalho Chehab <mchehab+huawei@kernel.org>
parent 7535c68d
Loading
Loading
Loading
Loading
+4040 −4165
Original line number Diff line number Diff line
@@ -187,7 +187,7 @@ allocate_delay_frames(struct ia_css_pipe *pipe);
static enum ia_css_err
sh_css_pipe_start(struct ia_css_stream *stream);

#ifdef ISP2401
/* ISP 2401 */
/*
 * @brief Stop all "ia_css_pipe" instances in the target
 * "ia_css_stream" instance.
@@ -219,18 +219,19 @@ sh_css_pipes_stop(struct ia_css_stream *stream);
 *   instance have ben stopped.
 * - false, otherwise.
 */
/* ISP 2401 */
static bool
sh_css_pipes_have_stopped(struct ia_css_stream *stream);

/* ISP 2401 */
static enum ia_css_err
ia_css_pipe_check_format(struct ia_css_pipe *pipe,
			 enum ia_css_frame_format format);

/* ISP 2401 */
static enum ia_css_err
check_pipe_resolutions(const struct ia_css_pipe *pipe);

#endif

static enum ia_css_err
ia_css_pipe_load_extension(struct ia_css_pipe *pipe,
			   struct ia_css_fw_info *firmware);
@@ -402,10 +403,6 @@ static unsigned int get_crop_columns_for_bayer_order(const struct
	ia_css_stream_config *config);
static void get_pipe_extra_pixel(struct ia_css_pipe *pipe,
				 unsigned int *extra_row, unsigned int *extra_column);
#endif

#ifdef ISP2401
#ifdef USE_INPUT_SYSTEM_VERSION_2401
static enum ia_css_err
aspect_ratio_crop_init(struct ia_css_stream *curr_stream,
		       struct ia_css_pipe *pipes[],
@@ -419,7 +416,6 @@ aspect_ratio_crop(struct ia_css_pipe *curr_pipe,
		  struct ia_css_resolution *effective_res);
#endif

#endif
static void
sh_css_pipe_free_shading_table(struct ia_css_pipe *pipe)
{
@@ -3054,7 +3050,7 @@ load_preview_binaries(struct ia_css_pipe *pipe) {
	if (err != IA_CSS_SUCCESS)
		return err;

#ifdef ISP2401
	if (atomisp_hw_is_isp2401) {
		/* The delay latency determines the number of invalid frames after
		* a stream is started. */
		pipe->num_invalid_frames = pipe->dvs_frame_delay;
@@ -3063,8 +3059,8 @@ load_preview_binaries(struct ia_css_pipe *pipe) {
		ia_css_debug_dtrace(IA_CSS_DEBUG_TRACE,
				    "load_preview_binaries() num_invalid_frames=%d dvs_frame_delay=%d\n",
				    pipe->num_invalid_frames, pipe->dvs_frame_delay);
	}

#endif
	/* The vf_pp binary is needed when (further) YUV downscaling is required */
	need_vf_pp |= mycs->preview_binary.out_frame_info[0].res.width != pipe_out_info->res.width;
	need_vf_pp |= mycs->preview_binary.out_frame_info[0].res.height != pipe_out_info->res.height;
@@ -3119,17 +3115,16 @@ load_preview_binaries(struct ia_css_pipe *pipe) {
	 * Offline Preview uses the ISP copy binary.
	 */
	need_isp_copy_binary = !online && sensor;
#else
#ifndef ISP2401
	need_isp_copy_binary = !online && !continuous;
#else
	/* About pipe->stream->config.mode == IA_CSS_INPUT_MODE_MEMORY:
	 * This is typical the case with SkyCam (which has no input system) but it also applies to all cases
	 * where the driver chooses for memory based input frames. In these cases, a copy binary (which typical
	 * copies sensor data to DDR) does not have much use.
	 */
	if (!atomisp_hw_is_isp2401)
		need_isp_copy_binary = !online && !continuous;
	else
		need_isp_copy_binary = !online && !continuous && !(pipe->stream->config.mode == IA_CSS_INPUT_MODE_MEMORY);
#endif
#endif

	/* Copy */
@@ -5148,7 +5143,7 @@ sh_css_pipe_start(struct ia_css_stream *stream) {
	return err;
}

#ifndef ISP2401
/* ISP2400 */
void
sh_css_enable_cont_capt(bool enable, bool stop_copy_preview)
{
@@ -5160,40 +5155,13 @@ sh_css_enable_cont_capt(bool enable, bool stop_copy_preview)

bool
sh_css_continuous_is_enabled(uint8_t pipe_num)
#else
/*
 * @brief Stop all "ia_css_pipe" instances in the target
 * "ia_css_stream" instance.
 *
 * Refer to "Local prototypes" for more info.
 */
static enum ia_css_err
sh_css_pipes_stop(struct ia_css_stream *stream)
#endif
{
#ifndef ISP2401
	struct ia_css_pipe *pipe;
	bool continuous;
#else
	enum ia_css_err err = IA_CSS_SUCCESS;
	struct ia_css_pipe *main_pipe;
	enum ia_css_pipe_id main_pipe_id;
	int i;
#endif

#ifndef ISP2401
	ia_css_debug_dtrace(IA_CSS_DEBUG_TRACE, "sh_css_continuous_is_enabled() enter: pipe_num=%d\n", pipe_num);
#else
	assert(stream);
	if (!stream)
	{
		IA_CSS_LOG("stream does NOT exist!");
		err = IA_CSS_ERR_INTERNAL_ERROR;
		goto ERR;
	}
#endif
	ia_css_debug_dtrace(IA_CSS_DEBUG_TRACE,
			    "sh_css_continuous_is_enabled() enter: pipe_num=%d\n", pipe_num);

#ifndef ISP2401
	pipe = find_pipe_by_num(pipe_num);
	continuous = pipe && pipe->stream->config.continuous;
	ia_css_debug_dtrace(IA_CSS_DEBUG_TRACE,
@@ -5201,18 +5169,8 @@ sh_css_pipes_stop(struct ia_css_stream *stream)
			    continuous);
	return continuous;
}
#else
	main_pipe = stream->last_pipe;
	assert(main_pipe);
	if (!main_pipe)
	{
		IA_CSS_LOG("main_pipe does NOT exist!");
		err = IA_CSS_ERR_INTERNAL_ERROR;
		goto ERR;
	}
#endif

#ifndef ISP2401
/* ISP2400 */
enum ia_css_err
ia_css_stream_get_max_buffer_depth(struct ia_css_stream *stream,
				   int *buffer_depth) {
@@ -5223,12 +5181,7 @@ ia_css_stream_get_max_buffer_depth(struct ia_css_stream *stream,
	*buffer_depth = NUM_CONTINUOUS_FRAMES;
	return IA_CSS_SUCCESS;
}
#else
main_pipe_id = main_pipe->mode;
IA_CSS_ENTER_PRIVATE("main_pipe_id=%d", main_pipe_id);
#endif

#ifndef ISP2401
enum ia_css_err
ia_css_stream_set_buffer_depth(struct ia_css_stream *stream, int buffer_depth) {
	ia_css_debug_dtrace(IA_CSS_DEBUG_TRACE, "ia_css_stream_set_buffer_depth() enter: num_frames=%d\n", buffer_depth);
@@ -5240,7 +5193,54 @@ ia_css_stream_set_buffer_depth(struct ia_css_stream *stream, int buffer_depth) {
	/* TODO: check what to regarding initialization */
	return IA_CSS_SUCCESS;
}
#else

/* ISP2401 */
enum ia_css_err
ia_css_stream_get_buffer_depth(struct ia_css_stream *stream,
			       int *buffer_depth) {
	if (!buffer_depth)
		return IA_CSS_ERR_INVALID_ARGUMENTS;
	ia_css_debug_dtrace(IA_CSS_DEBUG_TRACE, "ia_css_stream_get_buffer_depth() enter: void\n");
	(void)stream;
	*buffer_depth = stream->config.target_num_cont_raw_buf;
	return IA_CSS_SUCCESS;
}

/*
 * @brief Stop all "ia_css_pipe" instances in the target
 * "ia_css_stream" instance.
 *
 * Refer to "Local prototypes" for more info.
 */
/* ISP2401 */
static enum ia_css_err
sh_css_pipes_stop(struct ia_css_stream *stream)
{
	enum ia_css_err err = IA_CSS_SUCCESS;
	struct ia_css_pipe *main_pipe;
	enum ia_css_pipe_id main_pipe_id;
	int i;

	assert(stream);
	if (!stream)
	{
		IA_CSS_LOG("stream does NOT exist!");
		err = IA_CSS_ERR_INTERNAL_ERROR;
		goto ERR;
	}

	main_pipe = stream->last_pipe;
	assert(main_pipe);
	if (!main_pipe)
	{
		IA_CSS_LOG("main_pipe does NOT exist!");
		err = IA_CSS_ERR_INTERNAL_ERROR;
		goto ERR;
	}

	main_pipe_id = main_pipe->mode;
	IA_CSS_ENTER_PRIVATE("main_pipe_id=%d", main_pipe_id);

	/*
	 * Stop all "ia_css_pipe" instances in this target
	 * "ia_css_stream" instance.
@@ -5251,16 +5251,7 @@ for (i = 0; i < stream->num_pipes; i++)
		IA_CSS_LOG("Send the stop-request to the pipe: pipe_id=%d",
			stream->pipes[i]->pipeline.pipe_id);
		err = ia_css_pipeline_request_stop(&stream->pipes[i]->pipeline);
#endif

#ifndef ISP2401
enum ia_css_err
ia_css_stream_get_buffer_depth(struct ia_css_stream *stream,
			       int *buffer_depth) {
	if (!buffer_depth)
		return IA_CSS_ERR_INVALID_ARGUMENTS;
	ia_css_debug_dtrace(IA_CSS_DEBUG_TRACE, "ia_css_stream_get_buffer_depth() enter: void\n");
#else
	/*
	 * Exit this loop if "ia_css_pipeline_request_stop()"
	 * returns the error code.
@@ -5325,6 +5316,7 @@ return err;
 *
 * Refer to "Local prototypes" for more info.
 */
/* ISP2401 */
static bool
sh_css_pipes_have_stopped(struct ia_css_stream *stream)
{
@@ -5404,58 +5396,6 @@ sh_css_pipes_have_stopped(struct ia_css_stream *stream)
	return rval;
}

bool
sh_css_continuous_is_enabled(uint8_t pipe_num)
{
	struct ia_css_pipe *pipe;
	bool continuous;

	ia_css_debug_dtrace(IA_CSS_DEBUG_TRACE,
			    "sh_css_continuous_is_enabled() enter: pipe_num=%d\n", pipe_num);

	pipe = find_pipe_by_num(pipe_num);
	continuous = pipe && pipe->stream->config.continuous;
	ia_css_debug_dtrace(IA_CSS_DEBUG_TRACE,
			    "sh_css_continuous_is_enabled() leave: enable=%d\n",
			    continuous);
	return continuous;
}

enum ia_css_err
ia_css_stream_get_max_buffer_depth(struct ia_css_stream *stream,
				   int *buffer_depth) {
	if (!buffer_depth)
		return IA_CSS_ERR_INVALID_ARGUMENTS;
	ia_css_debug_dtrace(IA_CSS_DEBUG_TRACE, "ia_css_stream_get_max_buffer_depth() enter: void\n");
	(void)stream;
	*buffer_depth = NUM_CONTINUOUS_FRAMES;
	return IA_CSS_SUCCESS;
}

enum ia_css_err
ia_css_stream_set_buffer_depth(struct ia_css_stream *stream, int buffer_depth) {
	ia_css_debug_dtrace(IA_CSS_DEBUG_TRACE, "ia_css_stream_set_buffer_depth() enter: num_frames=%d\n", buffer_depth);
	(void)stream;
	if (buffer_depth > NUM_CONTINUOUS_FRAMES || buffer_depth < 1)
		return IA_CSS_ERR_INVALID_ARGUMENTS;
	/* ok, value allowed */
	stream->config.target_num_cont_raw_buf = buffer_depth;
	/* TODO: check what to regarding initialization */
	return IA_CSS_SUCCESS;
}

enum ia_css_err
ia_css_stream_get_buffer_depth(struct ia_css_stream *stream,
			       int *buffer_depth) {
	if (!buffer_depth)
		return IA_CSS_ERR_INVALID_ARGUMENTS;
	ia_css_debug_dtrace(IA_CSS_DEBUG_TRACE, "ia_css_stream_get_buffer_depth() enter: void\n");
#endif
	(void)stream;
	*buffer_depth = stream->config.target_num_cont_raw_buf;
	return IA_CSS_SUCCESS;
}

#if !defined(HAS_NO_INPUT_SYSTEM) && defined(USE_INPUT_SYSTEM_VERSION_2)
unsigned int
sh_css_get_mipi_sizes_for_check(const unsigned int port, const unsigned int idx)
@@ -5596,7 +5536,7 @@ ERR :
	return err;
}

#ifdef ISP2401
/* ISP2401 */
/*
 * @brief Check if a format is supported by the pipe.
 *
@@ -5639,7 +5579,6 @@ ia_css_pipe_check_format(struct ia_css_pipe *pipe,
		return IA_CSS_SUCCESS;
	}
}
#endif

static enum ia_css_err load_video_binaries(struct ia_css_pipe *pipe)
{
@@ -5895,13 +5834,12 @@ static enum ia_css_err load_video_binaries(struct ia_css_pipe *pipe)
		return err;

	if (mycs->video_binary.info->sp.enable.block_output) {
#ifdef ISP2401
		unsigned int tnr_width;
		unsigned int tnr_height;
#endif

		tnr_info = mycs->video_binary.out_frame_info[0];
#ifdef ISP2401

		if (atomisp_hw_is_isp2401) {
			/* Select resolution for TNR. If
			* output_system_in_resolution(GDC_out_resolution) is
			* being used, then select that as it will also be in resolution for
@@ -5916,33 +5854,23 @@ static enum ia_css_err load_video_binaries(struct ia_css_pipe *pipe)
			}

			/* Make tnr reference buffers output block width(in pix) align */
		tnr_info.res.width  =
		    CEIL_MUL(tnr_width,
			tnr_info.res.width  = CEIL_MUL(tnr_width,
						       (mycs->video_binary.info->sp.block.block_width * ISP_NWAY));
			tnr_info.padded_width = tnr_info.res.width;
		} else {
			tnr_height = tnr_info.res.height;
		}

#endif
		/* Make tnr reference buffers output block height align */
#ifndef ISP2401
		tnr_info.res.height =
		    CEIL_MUL(tnr_info.res.height,
		tnr_info.res.height = CEIL_MUL(tnr_height,
					       mycs->video_binary.info->sp.block.output_block_height);
#else
		tnr_info.res.height =
		    CEIL_MUL(tnr_height,
			     mycs->video_binary.info->sp.block.output_block_height);
#endif
	} else {
		tnr_info = mycs->video_binary.internal_frame_info;
	}
	tnr_info.format = IA_CSS_FRAME_FORMAT_YUV_LINE;
	tnr_info.raw_bit_depth = SH_CSS_TNR_BIT_DEPTH;

#ifndef ISP2401
	for (i = 0; i < NUM_TNR_FRAMES; i++) {
#else
	for (i = 0; i < NUM_TNR_FRAMES; i++) {
#endif
		if (mycs->tnr_frames[i]) {
			ia_css_frame_free(mycs->tnr_frames[i]);
			mycs->tnr_frames[i] = NULL;
@@ -5971,9 +5899,6 @@ unload_video_binaries(struct ia_css_pipe *pipe) {
	ia_css_binary_unload(&pipe->pipe_settings.video.copy_binary);
	ia_css_binary_unload(&pipe->pipe_settings.video.video_binary);
	ia_css_binary_unload(&pipe->pipe_settings.video.vf_pp_binary);
#ifndef ISP2401
	ia_css_binary_unload(&pipe->pipe_settings.video.vf_pp_binary);
#endif

	for (i = 0; i < pipe->pipe_settings.video.num_yuv_scaler; i++)
		ia_css_binary_unload(&pipe->pipe_settings.video.yuv_scaler_binary[i]);
@@ -6192,12 +6117,13 @@ static bool need_capture_pp(
	IA_CSS_ENTER_LEAVE_PRIVATE("");
	assert(pipe);
	assert(pipe->mode == IA_CSS_PIPE_ID_CAPTURE);
#ifdef ISP2401

	if (atomisp_hw_is_isp2401) {
		/* ldc and capture_pp are not supported in the same pipeline */
		if (need_capt_ldc(pipe) == true)
			return false;
#endif
	}

	/* determine whether we need to use the capture_pp binary.
	 * This is needed for:
	 *   1. XNR or
@@ -6269,12 +6195,8 @@ static enum ia_css_err load_primary_binaries(
		       prim_out_info,
		       capt_pp_out_info, vf_info,
		       *vf_pp_in_info, *pipe_out_info,
#ifndef ISP2401
		       *pipe_vf_out_info, *capt_pp_in_info,
		       capt_ldc_out_info;
#else
		       *pipe_vf_out_info;
#endif
	enum ia_css_err err = IA_CSS_SUCCESS;
	struct ia_css_capture_settings *mycs;
	unsigned int i;
@@ -6413,41 +6335,35 @@ static enum ia_css_err load_primary_binaries(

	/* TODO Do we disable ldc for skycam */
	need_ldc = need_capt_ldc(pipe);
#ifdef ISP2401

	if (atomisp_hw_is_isp2401 && need_ldc) {
		/* ldc and capt_pp are not supported in the same pipeline */
	if (need_ldc) {
		struct ia_css_binary_descr capt_ldc_descr;

		ia_css_pipe_get_ldc_binarydesc(pipe,
					    &capt_ldc_descr, &prim_out_info,
					    &capt_pp_out_info);
#endif

#ifdef ISP2401
		err = ia_css_binary_find(&capt_ldc_descr,
					&mycs->capture_ldc_binary);
		if (err != IA_CSS_SUCCESS) {
			IA_CSS_LEAVE_ERR_PRIVATE(err);
			return err;
		}
	} else if (need_pp) {
#endif
		/* we build up the pipeline starting at the end */
		/* Capture post-processing */
#ifndef ISP2401
		need_pp = 0;
		need_ldc = 0;
	}
	if (need_pp) {
#endif
		struct ia_css_binary_descr capture_pp_descr;
#ifndef ISP2401
		struct ia_css_binary_descr prim_descr[MAX_NUM_PRIMARY_STAGES];

		if (!atomisp_hw_is_isp2401)
			capt_pp_in_info = need_ldc ? &capt_ldc_out_info : &prim_out_info;
#endif
		else
			capt_pp_in_info = &prim_out_info;

		ia_css_pipe_get_capturepp_binarydesc(pipe,
#ifndef ISP2401
							&capture_pp_descr, capt_pp_in_info,
#else
							     &capture_pp_descr, &prim_out_info,
#endif
							&capt_pp_out_info, &vf_info);
		err = ia_css_binary_find(&capture_pp_descr,
					    &mycs->capture_pp_binary);
@@ -6455,7 +6371,6 @@ static enum ia_css_err load_primary_binaries(
			IA_CSS_LEAVE_ERR_PRIVATE(err);
			return err;
		}
#ifndef ISP2401

		if (need_ldc) {
			struct ia_css_binary_descr capt_ldc_descr;
@@ -6470,16 +6385,11 @@ static enum ia_css_err load_primary_binaries(
				IA_CSS_LEAVE_ERR_PRIVATE(err);
				return err;
			}
			}
#endif
		} else {
			prim_out_info = *pipe_out_info;
		}

		/* Primary */
		{
			struct ia_css_binary_descr prim_descr[MAX_NUM_PRIMARY_STAGES];

		for (i = 0; i < mycs->num_primary_stage; i++) {
			struct ia_css_frame_info *local_vf_info = NULL;

@@ -6494,16 +6404,12 @@ static enum ia_css_err load_primary_binaries(
				return err;
			}
		}
		}

		/* Viewfinder post-processing */
		if (need_pp) {
			vf_pp_in_info =
			    &mycs->capture_pp_binary.vf_frame_info;
		} else {
			vf_pp_in_info =
			    &mycs->primary_binary[mycs->num_primary_stage - 1].vf_frame_info;
		}
		if (need_pp)
			vf_pp_in_info = &mycs->capture_pp_binary.vf_frame_info;
		else
			vf_pp_in_info = &mycs->primary_binary[mycs->num_primary_stage - 1].vf_frame_info;

		/*
		 * WARNING: The #if def flag has been added below as a
@@ -6550,6 +6456,7 @@ static enum ia_css_err load_primary_binaries(
				return err;
			}
		}
	}

	return IA_CSS_SUCCESS;
}
@@ -9304,7 +9211,6 @@ static enum ia_css_err load_primary_binaries(
	return false;
}

#ifdef ISP2401
enum ia_css_err
ia_css_pipe_override_frame_format(struct ia_css_pipe *pipe,
				    int pin_index,
@@ -9348,7 +9254,6 @@ static enum ia_css_err load_primary_binaries(
	return err;
}

#endif
#if defined(USE_INPUT_SYSTEM_VERSION_2)
/* Configuration of INPUT_SYSTEM_VERSION_2401 is done on SP */
static enum ia_css_err
@@ -9483,7 +9388,7 @@ static enum ia_css_err load_primary_binaries(
	return IA_CSS_SUCCESS;
}

#ifdef ISP2401
/* ISP2401 */
static enum ia_css_err check_pipe_resolutions(const struct ia_css_pipe *pipe) {
	enum ia_css_err err = IA_CSS_SUCCESS;

@@ -9525,8 +9430,6 @@ static enum ia_css_err load_primary_binaries(
	return err;
}

#endif

enum ia_css_err
ia_css_stream_create(const struct ia_css_stream_config *stream_config,
			int num_pipes,
@@ -9733,7 +9636,6 @@ static enum ia_css_err load_primary_binaries(
		IA_CSS_LOG("mode sensor/default");
	}

#ifdef ISP2401
#ifdef USE_INPUT_SYSTEM_VERSION_2401
	err = aspect_ratio_crop_init(curr_stream,
					pipes,
@@ -9743,14 +9645,11 @@ static enum ia_css_err load_primary_binaries(
		IA_CSS_LEAVE_ERR(err);
		return err;
	}
#endif

#endif
	for (i = 0; i < num_pipes; i++)
	{
#ifdef ISP2401
		struct ia_css_resolution effective_res;
#endif

		curr_pipe = pipes[i];
		/* set current stream */
		curr_pipe->stream = curr_stream;
@@ -9759,7 +9658,6 @@ static enum ia_css_err load_primary_binaries(
		effective_res = curr_pipe->config.input_effective_res;
		if (effective_res.height == 0 || effective_res.width == 0) {
			effective_res = curr_pipe->stream->config.input_config.effective_res;
#ifdef ISP2401

#if defined(USE_INPUT_SYSTEM_VERSION_2401)
			/* The aspect ratio cropping is currently only
@@ -9776,7 +9674,6 @@ static enum ia_css_err load_primary_binaries(
					IA_CSS_LOG("aspect_ratio_crop() failed with err(%d)", err);
				}
			}
#endif
#endif
			curr_pipe->config.input_effective_res = effective_res;
		}
@@ -9785,9 +9682,8 @@ static enum ia_css_err load_primary_binaries(
			    effective_res.height);
	}

#ifdef ISP2401
		for (i = 0; i < num_pipes; i++)
		{
	if (atomisp_hw_is_isp2401) {
		for (i = 0; i < num_pipes; i++) {
			if (pipes[i]->config.mode != IA_CSS_PIPE_MODE_ACC &&
			    pipes[i]->config.mode != IA_CSS_PIPE_MODE_COPY) {
				err = check_pipe_resolutions(pipes[i]);
@@ -9796,8 +9692,8 @@ static enum ia_css_err load_primary_binaries(
				}
			}
		}
	}

#endif
	err = ia_css_stream_isp_parameters_init(curr_stream);
	if (err != IA_CSS_SUCCESS)
		goto ERR;
@@ -9839,9 +9735,9 @@ static enum ia_css_err load_primary_binaries(
		if (num_pipes >= 2) {
			curr_stream->cont_capt = true;
			curr_stream->disable_cont_vf = curr_stream->config.disable_cont_viewfinder;
#ifndef ISP2401

			if (!atomisp_hw_is_isp2401)
				curr_stream->stop_copy_preview = my_css.stop_copy_preview;
#endif
		}

		/* Create copy pipe here, since it may not be exposed to the driver */
@@ -9899,7 +9795,8 @@ static enum ia_css_err load_primary_binaries(
		curr_pipe = pipes[i];
		/* set current stream */
		curr_pipe->stream = curr_stream;
#ifndef ISP2401

		if (!atomisp_hw_is_isp2401) {
			/* take over effective info */

			effective_res = curr_pipe->config.input_effective_res;
@@ -9908,7 +9805,7 @@ static enum ia_css_err load_primary_binaries(
				effective_res.height);
			if (err != IA_CSS_SUCCESS)
				goto ERR;
#endif
		}
		/* sensor binning per pipe */
		if (sensor_binning_changed)
			sh_css_pipe_free_shading_table(curr_pipe);
@@ -9990,12 +9887,10 @@ static enum ia_css_err load_primary_binaries(
	*stream = curr_stream;

ERR:
#ifndef ISP2401
		if (err == IA_CSS_SUCCESS)
		{
	if (err == IA_CSS_SUCCESS) {
		/* working mode: enter into the seed list */
		if (my_css_save.mode == sh_css_mode_working) {
				for (i = 0; i < MAX_ACTIVE_STREAMS; i++)
			for (i = 0; i < MAX_ACTIVE_STREAMS; i++) {
				if (!my_css_save.stream_seeds[i].stream) {
					IA_CSS_LOG("entered stream into loc=%d", i);
					my_css_save.stream_seeds[i].orig_stream = stream;
@@ -10010,20 +9905,13 @@ static enum ia_css_err load_primary_binaries(
					break;
				}
			}
#else
		if (err == IA_CSS_SUCCESS)
		{
			err = ia_css_save_stream(curr_stream);
#endif
		} else
		{
		} else {
			ia_css_stream_destroy(curr_stream);
		}
	} else {
		ia_css_stream_destroy(curr_stream);
	}
#ifndef ISP2401
	IA_CSS_LEAVE("return_err=%d mode=%d", err, my_css_save.mode);
#else
		IA_CSS_LEAVE("return_err=%d", err);
#endif
	return err;
}

@@ -10031,10 +9919,6 @@ static enum ia_css_err load_primary_binaries(
ia_css_stream_destroy(struct ia_css_stream *stream) {
	int i;
	enum ia_css_err err = IA_CSS_SUCCESS;
#ifdef ISP2401
		enum ia_css_err err1 = IA_CSS_SUCCESS;
		enum ia_css_err err2 = IA_CSS_SUCCESS;
#endif

	IA_CSS_ENTER_PRIVATE("stream = %p", stream);
	if (!stream)
@@ -10073,13 +9957,13 @@ static enum ia_css_err load_primary_binaries(
				}
			}
		}
#ifndef ISP2401
			if (stream->config.mode == IA_CSS_INPUT_MODE_BUFFERED_SENSOR) {
#else
			if (stream->config.mode == IA_CSS_INPUT_MODE_BUFFERED_SENSOR ||
			    stream->config.mode == IA_CSS_INPUT_MODE_TPG ||
			    stream->config.mode == IA_CSS_INPUT_MODE_PRBS) {
#endif
		free_mpi = stream->config.mode == IA_CSS_INPUT_MODE_BUFFERED_SENSOR;
		if (atomisp_hw_is_isp2401) {
			free_mpi |= stream->config.mode == IA_CSS_INPUT_MODE_TPG;
			free_mpi |= stream->config.mode == IA_CSS_INPUT_MODE_PRBS;
		}

		if (free_mpi) {
			for (i = 0; i < stream->num_pipes; i++) {
				struct ia_css_pipe *entry = stream->pipes[i];
				/* free any mipi frames that are remaining:
@@ -10134,33 +10018,23 @@ static enum ia_css_err load_primary_binaries(
	kfree(stream->pipes);
	stream->pipes = NULL;
	stream->num_pipes = 0;
#ifndef ISP2401

	/* working mode: take out of the seed list */
		if (my_css_save.mode == sh_css_mode_working)
			for (i = 0; i < MAX_ACTIVE_STREAMS; i++)
	if (my_css_save.mode == sh_css_mode_working) {
		for (i = 0; i < MAX_ACTIVE_STREAMS; i++) {
			if (my_css_save.stream_seeds[i].stream == stream)
			{
				IA_CSS_LOG("took out stream %d", i);
				my_css_save.stream_seeds[i].stream = NULL;
				break;
			}
#else
		err2 = ia_css_save_restore_remove_stream(stream);
		}
	}

		err1 = (err != IA_CSS_SUCCESS) ? err : err2;
#endif
	kfree(stream);
#ifndef ISP2401
	IA_CSS_LEAVE_ERR(err);
#else
		IA_CSS_LEAVE_ERR(err1);
#endif

#ifndef ISP2401
	return err;
#else
		return err1;
#endif
}

enum ia_css_err
@@ -10182,7 +10056,8 @@ static enum ia_css_err load_primary_binaries(
    */
enum ia_css_err
ia_css_stream_load(struct ia_css_stream *stream) {
#ifndef ISP2401

	if (!atomisp_hw_is_isp2401) {
		int i;
		enum ia_css_err err;

@@ -10220,11 +10095,11 @@ static enum ia_css_err load_primary_binaries(
		}
		ia_css_debug_dtrace(IA_CSS_DEBUG_TRACE,	"ia_css_stream_load() exit,\n");
		return IA_CSS_SUCCESS;
#else
	} else {
		/* TODO remove function - DEPRECATED */
		(void)stream;
		return IA_CSS_ERR_NOT_SUPPORTED;
#endif
	}
}

enum ia_css_err
@@ -10307,12 +10182,13 @@ static enum ia_css_err load_primary_binaries(
		}
	}
#endif
#ifndef ISP2401
		err = ia_css_pipeline_request_stop(&stream->last_pipe->pipeline);
#else

	if (!atomisp_hw_is_isp2401) {
		err = ia_css_pipeline_request_stop(&stream->last_pipe->pipeline);
	} else {
		err = sh_css_pipes_stop(stream);
#endif
	}

	if (err != IA_CSS_SUCCESS)
		return err;

@@ -10329,16 +10205,16 @@ static enum ia_css_err load_primary_binaries(

	assert(stream);

#ifndef ISP2401
	if (!atomisp_hw_is_isp2401) {
		stopped = ia_css_pipeline_has_stopped(&stream->last_pipe->pipeline);
#else
	} else {
		stopped = sh_css_pipes_have_stopped(stream);
#endif
	}

	return stopped;
}

#ifndef ISP2401
/* ISP2400 */
/*
    * Destroy the stream and all the pipes related to it.
    * The stream handle is used to identify the correct entry in the css_save struct
@@ -10371,7 +10247,6 @@ static enum ia_css_err load_primary_binaries(
	return IA_CSS_SUCCESS;
}

#endif
enum ia_css_err
ia_css_temp_pipe_to_pipe_id(const struct ia_css_pipe *pipe,
			    enum ia_css_pipe_id *pipe_id) {
@@ -10676,16 +10551,17 @@ static enum ia_css_err load_primary_binaries(
	}

	/* For now, stop whole SP */
#ifndef ISP2401
	if (!atomisp_hw_is_isp2401) {
		sh_css_write_host2sp_command(host2sp_cmd_terminate);
#else
	} else {
		if (!sh_css_write_host2sp_command(host2sp_cmd_terminate))
		{
			IA_CSS_ERROR("Call to 'sh-css_write_host2sp_command()' failed");
			ia_css_debug_dump_sp_sw_debug_info();
			ia_css_debug_dump_debug_info(NULL);
		}
#endif
	}

	sh_css_sp_set_sp_running(false);

	timeout = SP_SHUTDOWN_TIMEOUT_US;
@@ -11017,7 +10893,7 @@ static enum ia_css_err load_primary_binaries(
	return err;
}

#ifdef ISP2401
/* ISP2401 */
enum ia_css_err
ia_css_pipe_update_qos_ext_mapped_arg(struct ia_css_pipe *pipe,
					uint32_t fw_handle,
@@ -11231,7 +11107,6 @@ static enum ia_css_err load_primary_binaries(
}
#endif

#endif
static void
sh_css_hmm_buffer_record_init(void) {
	int i;