void
ia_css_wb_debug_dtrace(const struct ia_css_wb_config *config, unsigned level)
{
	ia_css_debug_dtrace(level,
		"config.integer_bits=%d, "
		"config.gr=%d, config.r=%d, "
		"config.b=%d, config.gb=%d\n",
		config->integer_bits,
		config->gr, config->r,
		config->b, config->gb);
}
void
ia_css_ecd_debug_dtrace(
	const struct ia_css_ecd_config *config,
	unsigned level)
{
	ia_css_debug_dtrace(level,
		"config.zip_strength=%d, "
		"config.fc_strength=%d, config.fc_debias=%d\n",
		config->zip_strength,
		config->fc_strength, config->fc_debias);
}
static int isyspoc_validate_output_pin(const struct ia_css_isys_output_pin *output_pin)
{
	assert(output_pin);

	/* Verify output pin */
	if (output_pin->info.pt >= N_IA_CSS_ISYS_PIN_TYPE) {
		ia_css_debug_dtrace(IA_CSS_DEBUG_ERROR,
			"isyspoc_validate_output_pin(): invalid pintype %d\n",
			output_pin->info.pt);
		return EINVAL;
	}

	if (output_pin->info.pt == IA_CSS_ISYS_PIN_TYPE_MIPI) {
		ia_css_debug_dtrace(IA_CSS_DEBUG_ERROR,
			"isyspoc_validate_output_pin(): mipi pintype not supported\n");
		return EINVAL;
	}

	if (output_pin->info.pt == IA_CSS_ISYS_PIN_TYPE_RAW_S) {
		ia_css_debug_dtrace(IA_CSS_DEBUG_ERROR,
			"isyspoc_validate_output_pin(): raws pintype not supported\n");
		return EINVAL;
	}

	if (output_pin->info.pt == IA_CSS_ISYS_PIN_TYPE_RAW_NS) {
		if (output_pin->info.type_specifics.ft >= N_IA_CSS_ISYS_FRAME_FORMAT) {
			ia_css_debug_dtrace(IA_CSS_DEBUG_ERROR,
				"isyspoc_validate_output_pin(): invalid frametype %d\n",
				output_pin->info.type_specifics.ft);
			return EINVAL;
		}
	}

	if ((output_pin->info.output_res.width < output_min_width)
	     && (output_pin->info.output_res.width > output_max_width)) {
		ia_css_debug_dtrace(IA_CSS_DEBUG_ERROR,
			"isyspoc_validate_output_pin(): unsupported width=%d\n",
			output_pin->info.output_res.width);
	}

	if ((output_pin->info.output_res.height < output_min_height)
	     && (output_pin->info.output_res.height > output_max_height)) {
		ia_css_debug_dtrace(IA_CSS_DEBUG_ERROR,
			"isyspoc_validate_output_pin(): unsupported res height=%d\n",
			output_pin->info.output_res.height);
		return EINVAL;
	}

	if(output_pin->payload.addr == (hrt_vaddress)NULL) {
		ia_css_debug_dtrace(IA_CSS_DEBUG_ERROR,
			"isyspoc_validate_output_pin(): invalid payload.addr\n");
		return EINVAL;
	}

	return 0;
}
void ia_css_refcount_clear(int32_t id, clear_func clear_func_ptr)
{
	struct ia_css_refcount_entry *entry;
	uint32_t i;
	uint32_t count = 0;

	assert(clear_func_ptr != NULL);
	ia_css_debug_dtrace(IA_CSS_DEBUG_TRACE, "ia_css_refcount_clear(%x)\n",
			    id);

	for (i = 0; i < myrefcount.size; i++) {
		/* driver verifier tool has issues with &arr[i]
		   and prefers arr + i; as these are actually equivalent
		   the line below uses + i
		*/
		entry = myrefcount.items + i;
		if ((entry->data != mmgr_NULL) && (entry->id == id)) {
			ia_css_debug_dtrace(IA_CSS_DEBUG_TRACE,
					    "ia_css_refcount_clear:"
					    " %x: 0x%x\n", id, entry->data);
			if (clear_func_ptr) {
				/* clear using provided function */
				clear_func_ptr(entry->data);
			} else {
				ia_css_debug_dtrace(IA_CSS_DEBUG_TRACE,
						    "ia_css_refcount_clear: "
						    "using mmgr_free: "
						    "no clear_func\n");
				mmgr_free(entry->data);
			}
			assert(entry->count == 0);
			entry->data = mmgr_NULL;
			entry->count = 0;
			entry->id = 0;
			count++;
		}
	}
	ia_css_debug_dtrace(IA_CSS_DEBUG_TRACE,
			    "ia_css_refcount_clear(%x): cleared %d\n", id,
			    count);
}
void ia_css_frame_info_set_format(struct ia_css_frame_info *info,
	enum ia_css_frame_format format)
{
	assert(info != NULL);
	ia_css_debug_dtrace(IA_CSS_DEBUG_TRACE,
		"ia_css_frame_info_set_format() enter:\n");
	/* yuv_line has 2*NWAY alignment */
	info->format = format;
	/* HACK: this resets the padded width incorrectly.
	   Lex needs to fix this in the vf_veceven module. */
	info->padded_width = CEIL_MUL(info->padded_width, 2 * ISP_VEC_NELEMS);
}
void ia_css_pipe_get_pre_de_binarydesc(
	struct ia_css_pipe const * const pipe,
	struct ia_css_binary_descr *pre_de_descr,
	struct ia_css_frame_info *in_info,
	struct ia_css_frame_info *out_info)
{
	unsigned int i;
	struct ia_css_frame_info *out_infos[IA_CSS_BINARY_MAX_OUTPUT_PORTS];

	assert(pipe != NULL);
	assert(in_info != NULL);
	assert(out_info != NULL);
	ia_css_debug_dtrace(IA_CSS_DEBUG_TRACE_PRIVATE,
			    "ia_css_pipe_get_pre_de_binarydesc() enter:\n");

	*in_info = *out_info;
	in_info->format = IA_CSS_FRAME_FORMAT_RAW;
	in_info->raw_bit_depth = ia_css_pipe_util_pipe_input_format_bpp(pipe);
	out_infos[0] = out_info;
	for (i = 1; i < IA_CSS_BINARY_MAX_OUTPUT_PORTS; i++) {
		out_infos[i] = NULL;
	}

	if (pipe->config.isp_pipe_version == 1)
		/*
		 * [email protected]
		 *
		 * TODO
		 * - Check with the ISP engineers to see whether "pre_de" needs
		 *   the valid input argument "original_in_info" or not.
		 */
		pipe_binarydesc_get_offline(pipe, IA_CSS_BINARY_MODE_PRE_ISP,
				       pre_de_descr, NULL, in_info, out_infos, NULL);
	else {
		/*
		 * [email protected]
		 *
		 * TODO
		 * - Check with the ISP engineers to see whether "pre_de" needs
		 *   the valid input argument "original_in_info" or not.
		 */
		pipe_binarydesc_get_offline(pipe, IA_CSS_BINARY_MODE_PRE_DE,
				       pre_de_descr, NULL, in_info, out_infos, NULL);
	}

	if (pipe->stream->config.online) {
		pre_de_descr->online = true;
		pre_de_descr->two_ppc =
		    (pipe->stream->config.pixels_per_clock == 2);
		pre_de_descr->stream_format = pipe->stream->config.input_config.format;
	}
	pre_de_descr->isp_pipe_version = pipe->config.isp_pipe_version;
}
int ia_css_isys_device_close(
	HANDLE context,
	unsigned int nof_streams
) {
	struct ia_css_isys_context *ctx = (struct ia_css_isys_context *)context;
	unsigned int i;
	int ret = 0;

	ia_css_debug_dtrace(IA_CSS_DEBUG_TRACE, "ia_css_isys_device_close() enter: void\n");

	for (i=0; i < nof_streams; i++) {
		if (ctx->stream_state_array[i] != IA_CSS_ISYS_STREAM_STATE_IDLE) {
			return EPERM;
		}
	}

	ret = ia_css_fwctrl_device_close();
	HOST_FREE(context);

	ia_css_debug_dtrace(IA_CSS_DEBUG_TRACE, "ia_css_isys_device_close() return: return_err=%d\n", ret);
	return ret;
}
enum ia_css_err ia_css_frame_create_from_info(struct ia_css_frame **frame,
	const struct ia_css_frame_info *info)
{
	enum ia_css_err err = IA_CSS_SUCCESS;
	struct ia_css_frame *me;
	ia_css_debug_dtrace(IA_CSS_DEBUG_TRACE,
		"ia_css_frame_create_from_info() enter:\n");
	if (frame == NULL || info == NULL) {
		ia_css_debug_dtrace(IA_CSS_DEBUG_TRACE,
			"ia_css_frame_create_from_info() leave:"
			" invalid arguments\n");
		return IA_CSS_ERR_INVALID_ARGUMENTS;
	}

	me = frame_create(info->res.width,
		info->res.height,
		info->format,
		info->padded_width,
		info->raw_bit_depth,
		false,
		false);
	if (me == NULL) {
		ia_css_debug_dtrace(IA_CSS_DEBUG_TRACE,
			"ia_css_frame_create_from_info() leave:"
			" frame create failed\n");
		return IA_CSS_ERR_CANNOT_ALLOCATE_MEMORY;
	}

	err = ia_css_frame_init_planes(me);

	if (err == IA_CSS_SUCCESS)
		*frame = me;
	else
		sh_css_free(me);

	ia_css_debug_dtrace(IA_CSS_DEBUG_TRACE, "ia_css_frame_create_from_info() leave:\n");

	return err;
}
bool ia_css_frame_is_same_type(const struct ia_css_frame *frame_a,
	const struct ia_css_frame *frame_b)
{
	bool is_equal = false;
	const struct ia_css_frame_info *info_a = &frame_a->info,
	    *info_b = &frame_b->info;

	ia_css_debug_dtrace(IA_CSS_DEBUG_TRACE,
		      "ia_css_frame_is_same_type() enter:\n");

	if (!info_a || !info_b)
		return false;
	if (info_a->format != info_b->format)
		return false;
	if (info_a->padded_width != info_b->padded_width)
		return false;
	is_equal = ia_css_frame_info_is_same_resolution(info_a, info_b);

	ia_css_debug_dtrace(IA_CSS_DEBUG_TRACE,
		      "ia_css_frame_is_same_type() leave:\n");

	return is_equal;
}
enum ia_css_err ia_css_frame_allocate_contiguous(struct ia_css_frame **frame,
	unsigned int width,
	unsigned int height,
	enum ia_css_frame_format format,
	unsigned int padded_width,
	unsigned int raw_bit_depth)
{
	enum ia_css_err err = IA_CSS_SUCCESS;

	ia_css_debug_dtrace(IA_CSS_DEBUG_TRACE,
		"ia_css_frame_allocate_contiguous() "
		"enter: width=%d, height=%d, format=%d\n",
		width, height, format);

	err = frame_allocate_with_data(frame, width, height, format,
			padded_width, raw_bit_depth, true);

	ia_css_debug_dtrace(IA_CSS_DEBUG_TRACE,
		"ia_css_frame_allocate_contiguous() leave: frame=%p\n",
		frame ? *frame : (void *)-1);

	return err;
}
/**************************************************
 *
 * Public Methods
 *
 **************************************************/
ia_css_isys_error_t ia_css_isys_stream_create(
	ia_css_isys_descr_t	*isys_stream_descr,
	ia_css_isys_stream_h	isys_stream)
{
	ia_css_isys_error_t rc;

	if (isys_stream_descr == NULL || isys_stream == NULL)
		return	false;

	ia_css_debug_dtrace(IA_CSS_DEBUG_TRACE_PRIVATE,
		"ia_css_isys_stream_create() enter:\n");

	isys_stream->linked_isys_stream_id = isys_stream_descr->linked_isys_stream_id;
	rc = create_input_system_input_port(isys_stream_descr, &(isys_stream->input_port));
	if (rc == false)
		return false;

	rc = create_input_system_channel(isys_stream_descr, false, &(isys_stream->channel));
	if (rc == false) {
		destroy_input_system_input_port(&(isys_stream->input_port));
		return false;
	}

	/* create metadata channel */
	if (isys_stream_descr->metadata.enable) {
		rc = create_input_system_channel(isys_stream_descr, true, &isys_stream->md_channel);
		if (rc == false) {
			destroy_input_system_input_port(&isys_stream->input_port);
			destroy_input_system_channel(&isys_stream->channel);
			return false;
		}
	}
	ia_css_debug_dtrace(IA_CSS_DEBUG_TRACE_PRIVATE,
		"ia_css_isys_stream_create() leave:\n");

	return true;
}
Esempio n. 12
0
enum ia_css_err ia_css_pipeline_request_stop(struct ia_css_pipeline *pipeline)
{
	enum ia_css_err err = IA_CSS_SUCCESS;
	unsigned int thread_id;

	assert(pipeline != NULL);

	if (pipeline == NULL)
		return IA_CSS_ERR_INVALID_ARGUMENTS;

	ia_css_debug_dtrace(IA_CSS_DEBUG_TRACE,
		"ia_css_pipeline_request_stop() enter: pipeline=%p\n",
		pipeline);
	pipeline->stop_requested = true;

	/* Send stop event to the sp*/
	/* This needs improvement, stop on all the pipes available
	 * in the stream*/
	ia_css_pipeline_get_sp_thread_id(pipeline->pipe_num, &thread_id);
	if (!sh_css_sp_is_running())
	{
		ia_css_debug_dtrace(IA_CSS_DEBUG_TRACE,
		"ia_css_pipeline_request_stop() leaving\n");
		/* queues are invalid */
		return IA_CSS_ERR_RESOURCE_NOT_AVAILABLE;
	}
	ia_css_bufq_enqueue_psys_event(IA_CSS_PSYS_SW_EVENT_STOP_STREAM,
				       (uint8_t)thread_id,
				       0,
				       0);
	sh_css_sp_uninit_pipeline(pipeline->pipe_num);

	ia_css_debug_dtrace(IA_CSS_DEBUG_TRACE,
		      "ia_css_pipeline_request_stop() leave: return_err=%d\n",
		      err);
	return err;
}
hrt_vaddress ia_css_refcount_increment(int32_t id, hrt_vaddress ptr)
{
	struct ia_css_refcount_entry *entry;

	if (ptr == mmgr_NULL)
		return ptr;

	entry = refcount_find_entry(ptr, false);

	ia_css_debug_dtrace(IA_CSS_DEBUG_TRACE,
			    "ia_css_refcount_increment(%x) 0x%x\n", id, ptr);

	if (!entry) {
		entry = refcount_find_entry(ptr, true);
		assert(entry != NULL);
		if (entry == NULL)
			return mmgr_NULL;
		entry->id = id;
	}

	if (entry->id != id) {
		ia_css_debug_dtrace(IA_CSS_DEBUG_ERROR,
			    "ia_css_refcount_increment(): Ref count IDS do not match!\n");
		return mmgr_NULL;
	}

	if (entry->data == ptr)
		entry->count += 1;
	else if (entry->data == mmgr_NULL) {
		entry->data = ptr;
		entry->count = 1;
	} else
		return mmgr_NULL;

	return ptr;
}
void
ia_css_cnr_debug_dtrace(
	const struct ia_css_cnr_config *config,
	unsigned level)
{
	ia_css_debug_dtrace(level,
		"config.coring_u=%d, config.coring_v=%d, "
		"config.sense_gain_vy=%d, config.sense_gain_hy=%d, "
		"config.sense_gain_vu=%d, config.sense_gain_hu=%d, "
		"config.sense_gain_vv=%d, config.sense_gain_hv=%d\n",
		config->coring_u, config->coring_v,
		config->sense_gain_vy, config->sense_gain_hy,
		config->sense_gain_vu, config->sense_gain_hu,
		config->sense_gain_vv, config->sense_gain_hv);
}
static void construct_sppipeline(
	struct sh_css_sp_pipeline *sp_pipeline,
	hrt_vaddress sp_stage_addr,
	uint32_t required_bds_factor,
	uint32_t dvs_frame_delay)
{
	struct sh_css_sp_pipeline *this_pipeline = sp_pipeline;
	ia_css_debug_dtrace(IA_CSS_DEBUG_TRACE, "construct_sppipeline(): enter\n");
	assert(this_pipeline != NULL);

	memset(this_pipeline, 0 , sizeof(struct sh_css_sp_pipeline));
	this_pipeline->num_stages = 1;
	this_pipeline->pipe_qos_config = QOS_INVALID;
	SH_CSS_PIPE_PORT_CONFIG_SET(this_pipeline->inout_port_config,
		(uint8_t)SH_CSS_PORT_INPUT,
		(uint8_t)SH_CSS_HOST_TYPE,1);
	SH_CSS_PIPE_PORT_CONFIG_SET(this_pipeline->inout_port_config,
		(uint8_t)SH_CSS_PORT_OUTPUT,
		(uint8_t)SH_CSS_HOST_TYPE,1);
	this_pipeline->required_bds_factor = required_bds_factor;
	this_pipeline->sp_stage_addr[0] = sp_stage_addr;
	ia_css_debug_dtrace(IA_CSS_DEBUG_TRACE, "construct_sppipeline(): exit\n");
	this_pipeline->dvs_frame_delay = dvs_frame_delay;
}
void ia_css_pipe_get_capturepp_binarydesc(
	struct ia_css_pipe * const pipe,
	struct ia_css_binary_descr *capture_pp_descr,
	struct ia_css_frame_info *in_info,
	struct ia_css_frame_info *out_info,
	struct ia_css_frame_info *vf_info)
{
	unsigned int i;
	struct ia_css_frame_info *out_infos[IA_CSS_BINARY_MAX_OUTPUT_PORTS];

	assert(pipe != NULL);
	assert(in_info != NULL);
	assert(vf_info != NULL);
	ia_css_debug_dtrace(IA_CSS_DEBUG_TRACE_PRIVATE,
			    "ia_css_pipe_get_capturepp_binarydesc() enter:\n");


	/* the in_info is only used for resolution to enable
	   bayer down scaling. */
	if (pipe->out_yuv_ds_input_info.res.width)
		*in_info = pipe->out_yuv_ds_input_info;
	else
		*in_info = *out_info;
	in_info->format = IA_CSS_FRAME_FORMAT_YUV420;
	in_info->raw_bit_depth = 0;
	ia_css_frame_info_set_width(in_info, in_info->res.width, 0);

	out_infos[0] = out_info;
	for (i = 1; i < IA_CSS_BINARY_MAX_OUTPUT_PORTS; i++) {
		out_infos[i] = NULL;
	}

	/*
	 * [email protected]
	 *
	 * TODO
	 * - Check with the ISP engineers to see whether "capture_pp" needs
	 *   the valid input argument "original_in_info" or not.
	 */
	pipe_binarydesc_get_offline(pipe,
			       IA_CSS_BINARY_MODE_CAPTURE_PP,
			       capture_pp_descr,
			       NULL, in_info, out_infos, vf_info);

	capture_pp_descr->enable_fractional_ds = true;
	capture_pp_descr->enable_xnr =
		pipe->config.default_capture_config.enable_xnr != 0;
}
Esempio n. 17
0
enum ia_css_err ia_css_pipeline_get_stage_from_fw(struct ia_css_pipeline *pipeline,
			  uint32_t fw_handle,
			  struct ia_css_pipeline_stage **stage)
{
	struct ia_css_pipeline_stage *s;
	assert(pipeline != NULL);
	assert(stage != NULL);
	ia_css_debug_dtrace(IA_CSS_DEBUG_TRACE,"%s() \n",__func__);
	for (s = pipeline->stages; s; s = s->next) {
		if ((s->firmware) && (s->firmware->handle == fw_handle)) {
			*stage = s;
			return IA_CSS_SUCCESS;
		}
	}
	return IA_CSS_ERR_INTERNAL_ERROR;
}
/**
 * @brief Release the reference count for a handle (host, vbuf)
 *
 * @param handle	The pointer to the handle
 */
void ia_css_rmgr_refcount_release_vbuf(struct ia_css_rmgr_vbuf_handle **handle)
{
    if ((handle == NULL) || ((*handle) == NULL) || (((*handle)->count) == 0)) {
        ia_css_debug_dtrace(IA_CSS_DEBUG_ERROR,
                            "ia_css_rmgr_refcount_release_vbuf() invalid arguments!\n");
        return;
    }
    /* decrease reference count */
    (*handle)->count--;
    /* remove from admin */
    if ((*handle)->count == 0) {
        (*handle)->vptr = 0x0;
        (*handle)->size = 0;
        *handle = NULL;
    }
}
void ia_css_queue_map(
	unsigned int thread_id,
	enum ia_css_buffer_type buf_type,
	bool map)
{
	assert(buf_type < IA_CSS_NUM_DYNAMIC_BUFFER_TYPE);
	assert(thread_id < SH_CSS_MAX_SP_THREADS);

	ia_css_debug_dtrace(IA_CSS_DEBUG_TRACE,
		"ia_css_queue_map() enter: buf_type=%d, thread_id=%d\n", buf_type, thread_id);

	if (map)
		map_buffer_type_to_queue_id(thread_id, buf_type);
	else
		unmap_buffer_type_to_queue_id(thread_id, buf_type);
}
Esempio n. 20
0
enum ia_css_err ia_css_pipeline_get_stage(struct ia_css_pipeline *pipeline,
					  int mode,
					  struct ia_css_pipeline_stage **stage)
{
	struct ia_css_pipeline_stage *s;
	assert(pipeline != NULL);
	assert(stage != NULL);
	ia_css_debug_dtrace(IA_CSS_DEBUG_TRACE,
		      "ia_css_pipeline_get_stage() enter:\n");
	for (s = pipeline->stages; s; s = s->next) {
		if (s->mode == mode) {
			*stage = s;
			return IA_CSS_SUCCESS;
		}
	}
	return IA_CSS_ERR_INTERNAL_ERROR;
}
void
ia_css_ctc_debug_dtrace(
	const struct ia_css_ctc_config *config,
	unsigned level)
{
	ia_css_debug_dtrace(level,
		"config.ce_gain_exp=%d, config.y0=%d, "
		"config.x1=%d, config.y1=%d, "
		"config.x2=%d, config.y2=%d, "
		"config.x3=%d, config.y3=%d, "
		"config.x4=%d, config.y4=%d\n",
		config->ce_gain_exp, config->y0,
		config->x1, config->y1,
		config->x2, config->y2,
		config->x3, config->y3,
		config->x4, config->y4);
}
Esempio n. 22
0
enum ia_css_err ia_css_pipeline_get_fw_from_stage(struct ia_css_pipeline *pipeline,
			  uint32_t stage_num,
			  uint32_t *fw_handle)
{
	struct ia_css_pipeline_stage *s;

	ia_css_debug_dtrace(IA_CSS_DEBUG_TRACE,"%s() \n",__func__);
	if ((pipeline == NULL) || (fw_handle == NULL))
		return IA_CSS_ERR_INVALID_ARGUMENTS;

	for (s = pipeline->stages; s; s = s->next) {
		if((s->stage_num == stage_num) && (s->firmware)) {
			*fw_handle = s->firmware->handle;
			return IA_CSS_SUCCESS;
		}
	}
	return IA_CSS_ERR_INTERNAL_ERROR;
}
void ia_css_pipe_get_yuvscaler_binarydesc(
	struct ia_css_pipe * const pipe,
	struct ia_css_binary_descr *yuv_scaler_descr,
	struct ia_css_frame_info *in_info,
	struct ia_css_frame_info *out_info,
	struct ia_css_frame_info *internal_out_info,
	struct ia_css_frame_info *vf_info)
{
	struct ia_css_frame_info *out_infos[IA_CSS_BINARY_MAX_OUTPUT_PORTS];

	assert(pipe != NULL);
	assert(in_info != NULL);
	/* Note: if the following assert fails, the number of ports has been
	 * changed; in that case an additional initializer must be added
	 * a few lines below after which this assert can be updated.
	 */
	assert(IA_CSS_BINARY_MAX_OUTPUT_PORTS == 2);
	ia_css_debug_dtrace(IA_CSS_DEBUG_TRACE_PRIVATE,
			    "ia_css_pipe_get_yuvscaler_binarydesc() enter:\n");

	in_info->padded_width = in_info->res.width;
	in_info->raw_bit_depth = 0;
	ia_css_frame_info_set_width(in_info, in_info->res.width, 0);
	out_infos[0] = out_info;
	out_infos[1] = internal_out_info;
	/* add initializers here if
	 * assert(IA_CSS_BINARY_MAX_OUTPUT_PORTS == ...);
	 * fails
	 */

	/*
	 * [email protected]
	 *
	 * TODO
	 * - Check with the ISP engineers to see whether "yuv_scalar"
	 *   needs the valid input argument "original_in_info" or not.
	 */
	pipe_binarydesc_get_offline(pipe,
			       IA_CSS_BINARY_MODE_CAPTURE_PP,
			       yuv_scaler_descr,
			       NULL, in_info, out_infos, vf_info);

	yuv_scaler_descr->enable_fractional_ds = true;
}
void
ia_css_fc_debug_dtrace(const struct ia_css_fc_config *config, unsigned level)
{
	ia_css_debug_dtrace(level,
		"config.gain_exp=%d, "
		"config.coring_pos_0=%d, config.coring_pos_1=%d, "
		"config.coring_neg_0=%d, config.coring_neg_1=%d, "
		"config.gain_pos_0=%d, config.gain_pos_1=%d, "
		"config.gain_neg_0=%d, config.gain_neg_1=%d, "
		"config.crop_pos_0=%d, config.crop_pos_1=%d, "
		"config.crop_neg_0=%d, config.crop_neg_1=%d\n",
		config->gain_exp,
		config->coring_pos_0, config->coring_pos_1,
		config->coring_neg_0, config->coring_neg_1,
		config->gain_pos_0, config->gain_pos_1,
		config->gain_neg_0, config->gain_neg_1,
		config->crop_pos_0, config->crop_pos_1,
		config->crop_neg_0, config->crop_neg_1);
}
/* This module provides a binary descriptions to used to find a binary. Since,
 * every stage is associated with a binary, it implicity helps stage
 * description. Apart from providing a binary description, this module also
 * populates the frame info's when required.*/
void ia_css_pipe_get_copy_binarydesc(
	struct ia_css_pipe const * const pipe,
	struct ia_css_binary_descr *copy_descr,
	struct ia_css_frame_info *in_info,
	struct ia_css_frame_info *out_info,
	struct ia_css_frame_info *vf_info)
{
	unsigned int i;
	/* out_info can be NULL */
	assert(pipe != NULL);
	assert(in_info != NULL);

	ia_css_debug_dtrace(IA_CSS_DEBUG_TRACE_PRIVATE,
			    "ia_css_pipe_get_copy_binarydesc() enter:\n");

	*in_info = *out_info;

	copy_descr->mode = IA_CSS_BINARY_MODE_COPY;
	copy_descr->online = true;
	copy_descr->continuous = false;
	copy_descr->two_ppc = (pipe->stream->config.pixels_per_clock == 2);
	copy_descr->enable_yuv_ds = false;
	copy_descr->enable_high_speed = false;
	copy_descr->enable_dvs_6axis = false;
	copy_descr->enable_reduced_pipe = false;
	copy_descr->enable_dz = false;
	copy_descr->enable_xnr = false;
	copy_descr->enable_fractional_ds = false;
	copy_descr->dvs_env.width = 0;
	copy_descr->dvs_env.height = 0;
	copy_descr->stream_format = pipe->stream->config.input_config.format;
	copy_descr->in_info = in_info;
	copy_descr->bds_out_info = NULL;
	copy_descr->out_info[0] = out_info;
	for (i = 1; i < IA_CSS_BINARY_MAX_OUTPUT_PORTS; i++) {
		copy_descr->out_info[i] = NULL;
	}
	copy_descr->vf_info = vf_info;
	copy_descr->isp_pipe_version = 1;
	copy_descr->required_bds_factor = SH_CSS_BDS_FACTOR_1_00;
	copy_descr->stream_config_left_padding = -1;
}
void ia_css_pipe_get_acc_stage_desc(
	struct ia_css_pipeline_stage_desc *stage_desc,
	struct ia_css_binary *binary,
	struct ia_css_fw_info *fw)
{
	unsigned int i;

	ia_css_debug_dtrace(IA_CSS_DEBUG_TRACE_PRIVATE, "ia_css_pipe_get_acc_stage_desc() enter:\n");
	stage_desc->binary = binary;
	stage_desc->firmware = fw;
	stage_desc->sp_func = IA_CSS_PIPELINE_NO_FUNC;
	stage_desc->max_input_width = 0;
	stage_desc->mode = IA_CSS_BINARY_MODE_VF_PP;
	stage_desc->cc_frame = NULL;
	stage_desc->in_frame = NULL;
	for (i = 0; i < IA_CSS_BINARY_MAX_OUTPUT_PORTS; i++) {
		stage_desc->out_frame[i] = NULL;
	}
	stage_desc->vf_frame = NULL;
}
/* Generic descriptor for offline binaries. Internal function. */
static void pipe_binarydesc_get_offline(
	struct ia_css_pipe const * const pipe,
	const int mode,
	struct ia_css_binary_descr *descr,
	struct ia_css_frame_info *original_in_info,
	struct ia_css_frame_info *in_info,
	struct ia_css_frame_info *out_info[],
	struct ia_css_frame_info *vf_info)
{
	unsigned int i;
	/* in_info, out_info, vf_info can be NULL */
	assert(pipe != NULL);
	assert(descr != NULL);
	ia_css_debug_dtrace(IA_CSS_DEBUG_TRACE_PRIVATE,
			    "pipe_binarydesc_get_offline() enter:\n");

	descr->mode = mode;
	descr->online = false;
	descr->continuous = pipe->stream->config.continuous;
	descr->striped = false;
	descr->two_ppc = false;
	descr->enable_yuv_ds = false;
	descr->enable_high_speed = false;
	descr->enable_dvs_6axis = false;
	descr->enable_reduced_pipe = false;
	descr->enable_dz = true;
	descr->enable_xnr = false;
	descr->enable_fractional_ds = false;
	descr->dvs_env.width = 0;
	descr->dvs_env.height = 0;
	descr->stream_format = pipe->stream->config.input_config.format;
	descr->original_in_info = original_in_info;
	descr->in_info = in_info;
	descr->bds_out_info = NULL;
	for (i = 0; i < IA_CSS_BINARY_MAX_OUTPUT_PORTS; i++)
		descr->out_info[i] = out_info[i];
	descr->vf_info = vf_info;
	descr->isp_pipe_version = pipe->config.isp_pipe_version;
	descr->required_bds_factor = SH_CSS_BDS_FACTOR_1_00;
	descr->stream_config_left_padding = -1;
}
void
ia_css_wb_dump(const struct sh_css_isp_wb_params *wb, unsigned level)
{
	ia_css_debug_dtrace(level, "White Balance:\n");
	ia_css_debug_dtrace(level, "\t%-32s = %d\n",
			"wb_gain_shift", wb->gain_shift);
	ia_css_debug_dtrace(level, "\t%-32s = %d\n",
			"wb_gain_gr", wb->gain_gr);
	ia_css_debug_dtrace(level, "\t%-32s = %d\n",
			"wb_gain_r", wb->gain_r);
	ia_css_debug_dtrace(level, "\t%-32s = %d\n",
			"wb_gain_b", wb->gain_b);
	ia_css_debug_dtrace(level, "\t%-32s = %d\n",
			"wb_gain_gb", wb->gain_gb);
}
void ia_css_pipe_get_sp_func_stage_desc(
	struct ia_css_pipeline_stage_desc *stage_desc,
	struct ia_css_frame *out_frame,
	enum ia_css_pipeline_stage_sp_func sp_func,
	unsigned max_input_width)
{
	unsigned int i;

	ia_css_debug_dtrace(IA_CSS_DEBUG_TRACE_PRIVATE, "ia_css_pipe_get_sp_func_stage_desc() enter:\n");
	stage_desc->binary = NULL;
	stage_desc->firmware = NULL;
	stage_desc->sp_func = sp_func;
	stage_desc->max_input_width = max_input_width;
	stage_desc->mode = (unsigned int)-1;
	stage_desc->cc_frame = NULL;
	stage_desc->in_frame = NULL;
	stage_desc->out_frame[0] = out_frame;
	for (i = 1; i < IA_CSS_BINARY_MAX_OUTPUT_PORTS; i++) {
		stage_desc->out_frame[i] = NULL;
	}
	stage_desc->vf_frame = NULL;
}
void ia_css_frame_info_set_width(struct ia_css_frame_info *info,
	unsigned int width,
	unsigned int min_padded_width)
{
	unsigned int align;

	assert(info != NULL);
	ia_css_debug_dtrace(IA_CSS_DEBUG_TRACE,
		"ia_css_frame_info_set_width() enter: "
		"width=%d, min_padded_width=%d\n",
		width, min_padded_width);

	if (min_padded_width > width)
		align = min_padded_width;
	else
		align = width;

	info->res.width = width;
	/* frames with a U and V plane of 8 bits per pixel need to have
	   all planes aligned, this means double the alignment for the
	   Y plane if the horizontal decimation is 2. */
	if (info->format == IA_CSS_FRAME_FORMAT_YUV420 ||
	    info->format == IA_CSS_FRAME_FORMAT_YV12 ||
	    info->format == IA_CSS_FRAME_FORMAT_NV12 ||
	    info->format == IA_CSS_FRAME_FORMAT_NV21 ||
	    info->format == IA_CSS_FRAME_FORMAT_BINARY_8 ||
	    info->format == IA_CSS_FRAME_FORMAT_YUV_LINE)
		info->padded_width =
		    CEIL_MUL(align, 2 * HIVE_ISP_DDR_WORD_BYTES);
	else if (info->format == IA_CSS_FRAME_FORMAT_NV12_TILEY)
		info->padded_width = CEIL_MUL(align, NV12_TILEY_TILE_WIDTH);
	else if (info->format == IA_CSS_FRAME_FORMAT_RAW ||
		 info->format == IA_CSS_FRAME_FORMAT_RAW_PACKED)
		info->padded_width = CEIL_MUL(align, 2 * ISP_VEC_NELEMS);
	else {
		info->padded_width = CEIL_MUL(align, HIVE_ISP_DDR_WORD_BYTES);
	}
}