void
ia_css_raw_config(
	struct sh_css_isp_raw_isp_config *to,
	const struct ia_css_raw_configuration  *from)
{
	unsigned elems_a = ISP_VEC_NELEMS;
	const struct ia_css_frame_info *in_info = from->in_info;
	const struct ia_css_frame_info *internal_info = from->internal_info;
#if !defined(USE_INPUT_SYSTEM_VERSION_2401)
	/* 2401 input system uses input width width */
	in_info = internal_info;
#else
	(void)internal_info;
#endif
	ia_css_dma_configure_from_info(&to->port_b, in_info);
	to->width_a_over_b = elems_a / to->port_b.elems;

	/* Assume divisiblity here, may need to generalize to fixed point. */
	assert (in_info->format == IA_CSS_FRAME_FORMAT_RAW_PACKED ||
		elems_a % to->port_b.elems == 0);

	to->inout_port_config       = from->pipe->inout_port_config;
	to->format = in_info->format;
	to->required_bds_factor = from->pipe->required_bds_factor;
}
void
ia_css_fpn_config(
	struct sh_css_isp_fpn_isp_config *to,
	const struct ia_css_fpn_configuration *from,
	unsigned size)
{
	unsigned elems_a = ISP_VEC_NELEMS;

	(void)size;
	ia_css_dma_configure_from_info(&to->port_b, from->info);
	to->width_a_over_b = elems_a / to->port_b.elems;

	/* Assume divisiblity here, may need to generalize to fixed point. */
	assert (elems_a % to->port_b.elems == 0);
}
void
ia_css_qplane_config(
	struct sh_css_isp_qplane_isp_config *to,
	const struct ia_css_qplane_configuration  *from)
{
	unsigned elems_a = ISP_VEC_NELEMS;
	ia_css_dma_configure_from_info(&to->port_b, from->info);
	to->width_a_over_b = elems_a / to->port_b.elems;

	/* Assume divisiblity here, may need to generalize to fixed point. */
	assert (elems_a % to->port_b.elems == 0);

	to->inout_port_config       = from->pipe->inout_port_config;
	to->format = from->info->format;
}
void
ia_css_raw_config(
	struct sh_css_isp_raw_isp_config *to,
	const struct ia_css_raw_configuration  *from,
	unsigned size)
{
	unsigned elems_a = ISP_VEC_NELEMS;
	const struct ia_css_frame_info *in_info = from->in_info;
	const struct ia_css_frame_info *internal_info = from->internal_info;

	(void)size;
#if !defined(USE_INPUT_SYSTEM_VERSION_2401)
	/* 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
		in_info = internal_info;

#endif
	ia_css_dma_configure_from_info(&to->port_b, in_info);

	/* Assume divisiblity here, may need to generalize to fixed point. */
	assert((in_info->format == IA_CSS_FRAME_FORMAT_RAW_PACKED) ||
		   (elems_a % to->port_b.elems == 0));

	to->width_a_over_b      = elems_a / to->port_b.elems;
	to->inout_port_config   = from->pipe->inout_port_config;
	to->format              = in_info->format;
	to->required_bds_factor = from->pipe->required_bds_factor;
	to->two_ppc             = from->two_ppc;
	to->stream_format       = css2isp_stream_format(from->stream_format);
	to->deinterleaved       = from->deinterleaved;
#if (defined(USE_INPUT_SYSTEM_VERSION_2401) || defined(CONFIG_CSI2_PLUS))
	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
}
void
ia_css_bayer_io_config(
	const struct ia_css_binary      *binary,
	const struct sh_css_binary_args *args)
{
	const struct ia_css_frame *in_frame = args->in_frame;
	const struct ia_css_frame **out_frames = (const struct ia_css_frame **)& args->out_frame;
	const struct ia_css_frame_info *in_frame_info = (in_frame) ? &in_frame->info : &binary->in_frame_info;

	const unsigned ddr_bits_per_element = sizeof(short) * 8;
	const unsigned ddr_elems_per_word = ceil_div(HIVE_ISP_DDR_WORD_BITS, ddr_bits_per_element);
	unsigned size_get = 0, size_put = 0;
	unsigned offset = 0;

	if (binary->info->mem_offsets.offsets.param) {
		size_get = binary->info->mem_offsets.offsets.param->dmem.get.size;
		offset = binary->info->mem_offsets.offsets.param->dmem.get.offset;
	}

	if (size_get) {
		struct ia_css_common_io_config *to = (struct ia_css_common_io_config *)&binary->mem_params.params[IA_CSS_PARAM_CLASS_PARAM][IA_CSS_ISP_DMEM].address[offset];
		struct dma_port_config config;
#ifndef IA_CSS_NO_DEBUG
		ia_css_debug_dtrace(IA_CSS_DEBUG_TRACE_PRIVATE, "ia_css_bayer_io_config() get part enter:\n");
#endif

		ia_css_dma_configure_from_info(&config, in_frame_info);
		// The base_address of the input frame will be set in the ISP
		to->width = in_frame_info->res.width;
		to->height = in_frame_info->res.height;
		to->stride = config.stride;
		to->ddr_elems_per_word = ddr_elems_per_word;
#ifndef IA_CSS_NO_DEBUG
		ia_css_debug_dtrace(IA_CSS_DEBUG_TRACE_PRIVATE, "ia_css_bayer_io_config() get part leave:\n");
#endif
	}

	if (binary->info->mem_offsets.offsets.param) {
		size_put = binary->info->mem_offsets.offsets.param->dmem.put.size;
		offset = binary->info->mem_offsets.offsets.param->dmem.put.offset;
	}

	if (size_put) {
		struct ia_css_common_io_config *to = (struct ia_css_common_io_config *)&binary->mem_params.params[IA_CSS_PARAM_CLASS_PARAM][IA_CSS_ISP_DMEM].address[offset];
		struct dma_port_config config;
#ifndef IA_CSS_NO_DEBUG
		ia_css_debug_dtrace(IA_CSS_DEBUG_TRACE_PRIVATE, "ia_css_bayer_io_config() put part enter:\n");
#endif

		ia_css_dma_configure_from_info(&config, &out_frames[0]->info);
		to->base_address = out_frames[0]->data;
		to->width = out_frames[0]->info.res.width;
		to->height = out_frames[0]->info.res.height;
		to->stride = config.stride;
		to->ddr_elems_per_word = ddr_elems_per_word;

#ifndef IA_CSS_NO_DEBUG
		ia_css_debug_dtrace(IA_CSS_DEBUG_TRACE_PRIVATE, "ia_css_bayer_io_config() put part leave:\n");
#endif
	}
}