enum ia_css_err ia_css_bufq_dequeue_buffer(
	int queue_id,
	uint32_t *item)
{
	enum ia_css_err return_err;
	int error = 0;
	ia_css_queue_t *q;

	IA_CSS_ENTER_PRIVATE("queue_id=%d", queue_id);
	if ((item == NULL) ||
	    (queue_id <= SH_CSS_INVALID_QUEUE_ID) ||
	    (queue_id >= SH_CSS_MAX_NUM_QUEUES)
	   )
		return IA_CSS_ERR_INVALID_ARGUMENTS;

	q = bufq_get_qhandle(sh_css_sp2host_buffer_queue,
		queue_id,
		-1);
	if (q != NULL) {
		error = ia_css_queue_dequeue(q, item);
		return_err = ia_css_convert_errno(error);
	} else {
		IA_CSS_ERROR("queue is not initialized");
		return_err = IA_CSS_ERR_RESOURCE_NOT_AVAILABLE;
	}

	IA_CSS_LEAVE_ERR_PRIVATE(return_err);
	return return_err;
}
void ia_css_pipe_get_vfpp_binarydesc(
	struct ia_css_pipe const * const pipe,
	struct ia_css_binary_descr *vf_pp_descr,
	struct ia_css_frame_info *in_info,
	struct ia_css_frame_info *out_info)
{
	struct ia_css_frame_info *out_infos[IA_CSS_BINARY_MAX_OUTPUT_PORTS];
	unsigned int i;
	/* out_info can be NULL ??? */
	assert(pipe != NULL);
	assert(in_info != NULL);
	IA_CSS_ENTER_PRIVATE("");

	in_info->raw_bit_depth = 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 "vf_pp" needs
	 *   the valid input argument "original_in_info" or not.
	 */
	pipe_binarydesc_get_offline(pipe, IA_CSS_BINARY_MODE_VF_PP,
			       vf_pp_descr, NULL, in_info, out_infos, NULL);
	vf_pp_descr->enable_fractional_ds = true;
	IA_CSS_LEAVE_PRIVATE("");
}
void ia_css_pipe_get_gdc_binarydesc(
	struct ia_css_pipe const * const pipe,
	struct ia_css_binary_descr *gdc_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_ENTER_PRIVATE("");

	*in_info = *out_info;
	in_info->format = IA_CSS_FRAME_FORMAT_QPLANE6;
	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 "gdc" needs
	 *   the valid input argument "original_in_info" or not.
	 */
	pipe_binarydesc_get_offline(pipe, IA_CSS_BINARY_MODE_GDC,
			       gdc_descr, NULL, in_info, out_infos, NULL);
	IA_CSS_LEAVE_PRIVATE("");
}
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)
{
	struct ia_css_frame_info *out_infos[IA_CSS_BINARY_MAX_OUTPUT_PORTS];
	unsigned int i;
	/* out_info can be NULL */
	assert(pipe != NULL);
	assert(in_info != NULL);
	IA_CSS_ENTER_PRIVATE("");

	*in_info = *out_info;
	out_infos[0] = out_info;
	for (i = 1; i < IA_CSS_BINARY_MAX_OUTPUT_PORTS; i++)
		out_infos[i] = NULL;
	pipe_binarydesc_get_offline(pipe, IA_CSS_BINARY_MODE_COPY,
				    copy_descr, NULL, in_info, out_infos, vf_info);
	copy_descr->online = true;
	copy_descr->continuous = false;
	copy_descr->two_ppc = (pipe->stream->config.pixels_per_clock == 2);
	copy_descr->enable_dz = false;
	copy_descr->isp_pipe_version = 1;
	IA_CSS_LEAVE_PRIVATE("");
}
enum ia_css_err ia_css_bufq_enqueue_buffer(
	int thread_index,
	int queue_id,
	uint32_t item)
{
	enum ia_css_err return_err = IA_CSS_SUCCESS;
	ia_css_queue_t *q;
	int error;

	IA_CSS_ENTER_PRIVATE("queue_id=%d", queue_id);
	if ((thread_index >= SH_CSS_MAX_SP_THREADS) || (thread_index < 0) ||
			(queue_id == SH_CSS_INVALID_QUEUE_ID))
		return IA_CSS_ERR_INVALID_ARGUMENTS;

	/* Get the queue for communication */
	q = bufq_get_qhandle(sh_css_host2sp_buffer_queue,
		queue_id,
		thread_index);
	if (q != NULL) {
		error = ia_css_queue_enqueue(q, item);
		return_err = ia_css_convert_errno(error);
	} else {
		IA_CSS_ERROR("queue is not initialized");
		return_err = IA_CSS_ERR_RESOURCE_NOT_AVAILABLE;
	}

	IA_CSS_LEAVE_ERR_PRIVATE(return_err);
	return return_err;
}
void ia_css_pipe_get_anr_binarydesc(
	struct ia_css_pipe const * const pipe,
	struct ia_css_binary_descr *anr_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_ENTER_PRIVATE("");

	*in_info = *out_info;
	in_info->format = IA_CSS_FRAME_FORMAT_RAW;
	in_info->raw_bit_depth = ANR_ELEMENT_BITS;
	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 "anr" needs
	 *   the valid input argument "original_in_info" or not.
	 */
	pipe_binarydesc_get_offline(pipe, IA_CSS_BINARY_MODE_ANR,
			       anr_descr, NULL, in_info, out_infos, NULL);

	anr_descr->isp_pipe_version = pipe->config.isp_pipe_version;
	IA_CSS_LEAVE_PRIVATE("");
}
void ia_css_bufq_init(void)
{
	int i, j;

	IA_CSS_ENTER_PRIVATE("");

	/* Setup all the local queue descriptors for Host2SP Buffer Queues */
	for (i = 0; i < SH_CSS_MAX_SP_THREADS; i++)
		for (j = 0; j < SH_CSS_MAX_NUM_QUEUES; j++) {
			init_bufq((uint32_t)offsetof(struct host_sp_queues, host2sp_buffer_queues_desc[i][j]),
				  (uint32_t)offsetof(struct host_sp_queues, host2sp_buffer_queues_elems[i][j]),
				  &css_queues.host2sp_buffer_queue_handles[i][j]);
		}

	/* Setup all the local queue descriptors for SP2Host Buffer Queues */
	for (i = 0; i < SH_CSS_MAX_NUM_QUEUES; i++) {
		init_bufq(offsetof(struct host_sp_queues, sp2host_buffer_queues_desc[i]),
			  offsetof(struct host_sp_queues, sp2host_buffer_queues_elems[i]),
			  &css_queues.sp2host_buffer_queue_handles[i]);
	}

	/* Host2SP event queue*/
	init_bufq((uint32_t)offsetof(struct host_sp_queues, host2sp_psys_event_queue_desc),
		  (uint32_t)offsetof(struct host_sp_queues, host2sp_psys_event_queue_elems),
		  &css_queues.host2sp_psys_event_queue_handle);

	/* SP2Host event queue */
	init_bufq((uint32_t)offsetof(struct host_sp_queues, sp2host_psys_event_queue_desc),
		  (uint32_t)offsetof(struct host_sp_queues, sp2host_psys_event_queue_elems),
		  &css_queues.sp2host_psys_event_queue_handle);

#if !defined(HAS_NO_INPUT_SYSTEM)
	/* Host2SP ISYS event queue */
	init_bufq((uint32_t)offsetof(struct host_sp_queues, host2sp_isys_event_queue_desc),
		  (uint32_t)offsetof(struct host_sp_queues, host2sp_isys_event_queue_elems),
		  &css_queues.host2sp_isys_event_queue_handle);

	/* SP2Host ISYS event queue*/
	init_bufq((uint32_t)offsetof(struct host_sp_queues, sp2host_isys_event_queue_desc),
		  (uint32_t)offsetof(struct host_sp_queues, sp2host_isys_event_queue_elems),
		  &css_queues.sp2host_isys_event_queue_handle);
#endif

	/* Host2SP tagger command queue */
	init_bufq((uint32_t)offsetof(struct host_sp_queues, host2sp_tag_cmd_queue_desc),
		  (uint32_t)offsetof(struct host_sp_queues, host2sp_tag_cmd_queue_elems),
		  &css_queues.host2sp_tag_cmd_queue_handle);

	/* Host2SP Unlock Raw Buffer message queue */
	init_bufq((uint32_t)offsetof(struct host_sp_queues, host2sp_unlock_raw_buff_msg_queue_desc),
		  (uint32_t)offsetof(struct host_sp_queues, host2sp_unlock_raw_buff_msg_queue_elems),
		  &css_queues.host2sp_unlock_raw_buff_msg_queue_handle);

	IA_CSS_LEAVE_PRIVATE("");
}
void ia_css_frame_free(struct ia_css_frame *frame)
{
	IA_CSS_ENTER_PRIVATE("frame = %p", frame);

	if (frame != NULL) {
		mmgr_free(frame->data);
		sh_css_free(frame);
	}

	IA_CSS_LEAVE_PRIVATE("void");
}
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_ENTER_PRIVATE("");

	*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;
	IA_CSS_LEAVE_PRIVATE("");
}
Пример #10
0
void ia_css_pipeline_map(unsigned int pipe_num, bool map)
{
	assert(pipe_num < IA_CSS_PIPELINE_NUM_MAX);
	IA_CSS_ENTER_PRIVATE("pipe_num = %d, map = %d", pipe_num, map);

	if (pipe_num >= IA_CSS_PIPELINE_NUM_MAX) {
		IA_CSS_ERROR("Invalid pipe number");
		IA_CSS_LEAVE_PRIVATE("void");
		return;
	}
	if (map)
		pipeline_map_num_to_sp_thread(pipe_num);
	else
		pipeline_unmap_num_to_sp_thread(pipe_num);
	IA_CSS_LEAVE_PRIVATE("void");
}
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_ENTER_PRIVATE("");


	/* 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;
	IA_CSS_LEAVE_PRIVATE("");
}
Пример #12
0
bool ia_css_pipeline_is_mapped(unsigned int key)
{
	bool ret = false;

	IA_CSS_ENTER_PRIVATE("key = %d", key);

	if ((key >= IA_CSS_PIPELINE_NUM_MAX) || (key >= IA_CSS_PIPE_ID_NUM)) {
		IA_CSS_ERROR("Invalid key!!");
		IA_CSS_LEAVE_PRIVATE("return = %d", false);
		return false;
	}

	ret = (bool)(pipeline_num_to_sp_thread_map[key] != (unsigned)PIPELINE_NUM_UNMAPPED);

	IA_CSS_LEAVE_PRIVATE("return = %d", ret);
	return ret;
}
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_ENTER_PRIVATE("");

	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->res.width == 0 && vf_info->res.height == 0) ? NULL : vf_info);

	yuv_scaler_descr->enable_fractional_ds = true;
	IA_CSS_LEAVE_PRIVATE("");
}
enum ia_css_err
ia_css_binary_3a_grid_info(const struct ia_css_binary *binary,
			   struct ia_css_grid_info *info,
			   struct ia_css_pipe *pipe)
{
	struct ia_css_3a_grid_info *s3a_info;
	enum ia_css_err err = IA_CSS_SUCCESS;

	IA_CSS_ENTER_PRIVATE("binary=%p, info=%p, pipe=%p",
			     binary, info, pipe);

	assert(binary != NULL);
	assert(info != NULL);
	s3a_info = &info->s3a_grid;


#if !defined(IS_ISP_2500_SYSTEM)
	/* 3A statistics grid */
	s3a_info->enable            = binary->info->sp.enable.s3a;
	s3a_info->width             = binary->s3atbl_width;
	s3a_info->height            = binary->s3atbl_height;
	s3a_info->aligned_width     = binary->s3atbl_isp_width;
	s3a_info->aligned_height    = binary->s3atbl_isp_height;
	s3a_info->bqs_per_grid_cell = (1 << binary->deci_factor_log2);
	s3a_info->deci_factor_log2  = binary->deci_factor_log2;
	s3a_info->elem_bit_depth    = SH_CSS_BAYER_BITS;
	s3a_info->use_dmem          = binary->info->sp.s3a.s3atbl_use_dmem;
#if defined(HAS_NO_HMEM)
	s3a_info->has_histogram     = 1;
#else
	s3a_info->has_histogram     = 0;
#endif
#else	/* IS_ISP_2500_SYSTEM defined */
	assert(pipe != NULL);
	s3a_info->ae_enable         = binary->info->sp.enable.ae;
	s3a_info->af_enable         = binary->info->sp.enable.af;
	s3a_info->awb_fr_enable     = binary->info->sp.enable.awb_fr_acc;
	s3a_info->awb_enable        = binary->info->sp.enable.awb_acc;
	s3a_info->elem_bit_depth    = SH_CSS_BAYER_BITS;

	err = ia_css_3a_stat_grid_calculate(s3a_info, pipe);
#endif
	IA_CSS_LEAVE_ERR_PRIVATE(err);
	return err;
}
Пример #15
0
/** @brief destroy a pipeline
 *
 * @param[in] pipeline
 * @return    None
 *
 */
void ia_css_pipeline_destroy(struct ia_css_pipeline *pipeline)
{
	assert(pipeline != NULL);
	IA_CSS_ENTER_PRIVATE("pipeline = %p", pipeline);

	if (pipeline == NULL) {
		IA_CSS_ERROR("NULL input parameter");
		IA_CSS_LEAVE_PRIVATE("void");
		return;
	}

	IA_CSS_LOG("pipe_num = %d", pipeline->pipe_num);

	/* Free the pipeline number */
	ia_css_pipeline_clean(pipeline);

	IA_CSS_LEAVE_PRIVATE("void");
}
enum ia_css_err ia_css_bufq_enqueue_unlock_raw_buff_msg(
	uint32_t exp_id)
{
	enum ia_css_err return_err;
	int error = 0;
	ia_css_queue_t *q;

	IA_CSS_ENTER_PRIVATE("exposure ID=%d", exp_id);
	q = bufq_get_qhandle(sh_css_host2sp_unlock_buff_msg_queue, -1, -1);
	if (NULL == q) {
		IA_CSS_ERROR("queue is not initialized");
		return IA_CSS_ERR_RESOURCE_NOT_AVAILABLE;
	}
	error = ia_css_queue_enqueue(q, exp_id);

	return_err = ia_css_convert_errno(error);
	IA_CSS_LEAVE_ERR_PRIVATE(return_err);
	return return_err;
}
Пример #17
0
enum ia_css_err ia_css_pipeline_create(
	struct ia_css_pipeline *pipeline,
	enum ia_css_pipe_id pipe_id,
	unsigned int pipe_num,
	unsigned int dvs_frame_delay)
{
	assert(pipeline != NULL);
	IA_CSS_ENTER_PRIVATE("pipeline = %p, pipe_id = %d, pipe_num = %d, dvs_frame_delay = %d",
		     pipeline, pipe_id, pipe_num, dvs_frame_delay);
	if (pipeline == NULL) {
		IA_CSS_LEAVE_ERR_PRIVATE(IA_CSS_ERR_INVALID_ARGUMENTS);
		return IA_CSS_ERR_INVALID_ARGUMENTS;
	}

	pipeline_init_defaults(pipeline, pipe_id, pipe_num, dvs_frame_delay);

	IA_CSS_LEAVE_ERR_PRIVATE(IA_CSS_SUCCESS);
	return IA_CSS_SUCCESS;
}
enum ia_css_err ia_css_bufq_enqueue_tag_cmd(
	uint32_t item)
{
	enum ia_css_err return_err;
	int error = 0;
	ia_css_queue_t *q;

	IA_CSS_ENTER_PRIVATE("item=%d", item);
	q = bufq_get_qhandle(sh_css_host2sp_tag_cmd_queue, -1, -1);
	if (NULL == q) {
		IA_CSS_ERROR("queue is not initialized");
		return IA_CSS_ERR_RESOURCE_NOT_AVAILABLE;
	}
	error = ia_css_queue_enqueue(q, item);

	return_err = ia_css_convert_errno(error);
	IA_CSS_LEAVE_ERR_PRIVATE(return_err);
	return return_err;
}
Пример #19
0
void ia_css_pipeline_clean(struct ia_css_pipeline *pipeline)
{
	struct ia_css_pipeline_stage *s;

	assert(pipeline != NULL);
	IA_CSS_ENTER_PRIVATE("pipeline = %p", pipeline);

	if (pipeline == NULL) {
		IA_CSS_ERROR("NULL input parameter");
		IA_CSS_LEAVE_PRIVATE("void");
		return;
	}
	s = pipeline->stages;

	while (s) {
		struct ia_css_pipeline_stage *next = s->next;
		pipeline_stage_destroy(s);
		s = next;
	}
	pipeline_init_defaults(pipeline, pipeline->pipe_id, pipeline->pipe_num, pipeline->dvs_frame_delay);

	IA_CSS_LEAVE_PRIVATE("void");
}
enum ia_css_err ia_css_bufq_enqueue_isys_event(uint8_t evt_id)
{
#if !defined(HAS_NO_INPUT_SYSTEM)
	enum ia_css_err return_err;
	int error = 0;
	ia_css_queue_t *q;

	IA_CSS_ENTER_PRIVATE("event_id=%d", evt_id);
	q = bufq_get_qhandle(sh_css_host2sp_isys_event_queue, -1, -1);
	if (q == NULL) {
		IA_CSS_ERROR("queue is not initialized");
		return IA_CSS_ERR_RESOURCE_NOT_AVAILABLE;
	}

	error = ia_css_eventq_send(q, evt_id, 0, 0, 0);
	return_err = ia_css_convert_errno(error);
	IA_CSS_LEAVE_ERR_PRIVATE(return_err);
	return return_err;
#else
	(void)evt_id;
	return IA_CSS_ERR_RESOURCE_NOT_AVAILABLE;
#endif
}
enum ia_css_err ia_css_bufq_enqueue_psys_event(
	uint8_t evt_id,
	uint8_t evt_payload_0,
	uint8_t evt_payload_1,
	uint8_t evt_payload_2)
{
	enum ia_css_err return_err;
	int error = 0;
	ia_css_queue_t *q;

	IA_CSS_ENTER_PRIVATE("evt_id=%d", evt_id);
	q = bufq_get_qhandle(sh_css_host2sp_psys_event_queue, -1, -1);
	if (NULL == q) {
		IA_CSS_ERROR("queue is not initialized");
		return IA_CSS_ERR_RESOURCE_NOT_AVAILABLE;
	}

	error = ia_css_eventq_send(q,
			evt_id, evt_payload_0, evt_payload_1, evt_payload_2);

	return_err = ia_css_convert_errno(error);
	IA_CSS_LEAVE_ERR_PRIVATE(return_err);
	return return_err;
}
void ia_css_pipe_get_primary_binarydesc(
	struct ia_css_pipe const * const pipe,
	struct ia_css_binary_descr *prim_descr,
	struct ia_css_frame_info *in_info,
	struct ia_css_frame_info *out_info,
	struct ia_css_frame_info *vf_info)
{
	int mode = IA_CSS_BINARY_MODE_PRIMARY;
	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);
	/* vf_info can be NULL - example video_binarydescr */
	/*assert(vf_info != NULL);*/
	IA_CSS_ENTER_PRIVATE("");

	if (ia_css_util_is_input_format_yuv(pipe->stream->config.input_config.format))
		mode = IA_CSS_BINARY_MODE_COPY;

	in_info->res = pipe->config.input_effective_res;
	in_info->padded_width = in_info->res.width;

#if !defined(HAS_NO_PACKED_RAW_PIXELS)
	if (pipe->stream->config.pack_raw_pixels)
		in_info->format = IA_CSS_FRAME_FORMAT_RAW_PACKED;
	else
#endif
		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;

	/*
	 * [email protected]
	 *
	 * TODO
	 * - Pass "prim" the valid input argument "original_in_info".
	 */
	pipe_binarydesc_get_offline(pipe, mode,
			       prim_descr, NULL, in_info, out_infos, vf_info);

	if (pipe->stream->config.online &&
	    pipe->stream->config.mode != IA_CSS_INPUT_MODE_MEMORY) {
		prim_descr->online = true;
		prim_descr->two_ppc =
		    (pipe->stream->config.pixels_per_clock == 2);
		prim_descr->stream_format = pipe->stream->config.input_config.format;
	}
	if (mode == IA_CSS_BINARY_MODE_PRIMARY) {
		prim_descr->isp_pipe_version = pipe->config.isp_pipe_version;
		prim_descr->enable_fractional_ds =
		    pipe->extra_config.enable_fractional_ds;
		/* We have both striped and non-striped primary binaries,
		 * if continuous viewfinder is required, then we must select
		 * a striped one. Otherwise we prefer to use a non-striped
		 * since it has better performance. */
		prim_descr->striped = prim_descr->continuous && !pipe->stream->stop_copy_preview;
	}
	IA_CSS_LEAVE_PRIVATE("");
}
enum ia_css_err ia_css_pipe_get_video_binarydesc(
	struct ia_css_pipe * const pipe,
	struct ia_css_binary_descr *video_descr,
	struct ia_css_frame_info *in_info,
	struct ia_css_frame_info *bds_out_info,
	struct ia_css_frame_info *out_info,
	struct ia_css_frame_info *vf_info,
	int stream_config_left_padding)
{
	int mode = IA_CSS_BINARY_MODE_VIDEO;
	unsigned int i;
	struct ia_css_frame_info *out_infos[IA_CSS_BINARY_MAX_OUTPUT_PORTS];
	enum ia_css_err err = IA_CSS_SUCCESS;
	bool stream_dz_config = false;

	/* vf_info can be NULL */
	assert(pipe != NULL);
	assert(in_info != NULL);
	/* assert(vf_info != NULL); */
	IA_CSS_ENTER_PRIVATE("");

#if !defined(IS_ISP_2500_SYSTEM)
	/* The solution below is not optimal; we should move to using ia_css_pipe_get_copy_binarydesc()
	 * But for now this fixes things; this code used to be there but was removed
	 * with gerrit 8908 as this was wrong for Skycam; however 240x still needs this
	 */
	if (ia_css_util_is_input_format_yuv(pipe->stream->config.input_config.format))
		mode = IA_CSS_BINARY_MODE_COPY;
#endif

	in_info->res = pipe->config.input_effective_res;
	in_info->padded_width = in_info->res.width;
	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;

	/*
	 * [email protected]
	 *
	 * TODO
	 * - Pass "video" the valid input argument
	 *   "original_in_info".
	 */
	pipe_binarydesc_get_offline(pipe, mode,
	       video_descr, NULL, in_info, out_infos, vf_info);

	if (pipe->stream->config.online) {
		video_descr->online = pipe->stream->config.online;
		video_descr->two_ppc =
		    (pipe->stream->config.pixels_per_clock == 2);
	}

	if (mode == IA_CSS_BINARY_MODE_VIDEO) {
		stream_dz_config =
		    ((pipe->stream->isp_params_configs->dz_config.dx !=
		      HRT_GDC_N)
		     || (pipe->stream->isp_params_configs->dz_config.dy !=
			 HRT_GDC_N));

		video_descr->enable_dz = pipe->config.enable_dz
		    || stream_dz_config;
		video_descr->dvs_env = pipe->config.dvs_envelope;
		video_descr->enable_yuv_ds = pipe->extra_config.enable_yuv_ds;
		video_descr->enable_high_speed =
		    pipe->extra_config.enable_high_speed;
		video_descr->enable_dvs_6axis =
		    pipe->extra_config.enable_dvs_6axis;
		video_descr->enable_reduced_pipe =
		    pipe->extra_config.enable_reduced_pipe;
		video_descr->isp_pipe_version = pipe->config.isp_pipe_version;
		video_descr->enable_fractional_ds =
		    pipe->extra_config.enable_fractional_ds;

#if defined(IS_ISP_2500_SYSTEM)
/*
 ignoring enable_raw_binning, as it is obsolete and setting it gives problems finding the binary
*/
		if (pipe->config.bayer_ds_out_res.width != 0 &&
			pipe->config.bayer_ds_out_res.height != 0) {
			bds_out_info->res.width = pipe->config.bayer_ds_out_res.width;
			bds_out_info->res.height = pipe->config.bayer_ds_out_res.height;
			bds_out_info->padded_width = pipe->config.bayer_ds_out_res.width;
/* the set of supported scaling factors seems to small for skylake
			err = calculate_bds_factor(in_info->res, bds_out_info->res,
					&video_descr.required_bds_factor);
			if (err != IA_CSS_SUCCESS)
				return err;
*/
		}
#else
		if (pipe->extra_config.enable_raw_binning) {
			if (pipe->config.bayer_ds_out_res.width != 0 &&
			    pipe->config.bayer_ds_out_res.height != 0) {
				bds_out_info->res.width =
				    pipe->config.bayer_ds_out_res.width;
				bds_out_info->res.height =
				    pipe->config.bayer_ds_out_res.height;
				bds_out_info->padded_width =
				    pipe->config.bayer_ds_out_res.width;
				err =
				binarydesc_calculate_bds_factor(
					in_info->res, bds_out_info->res,
					&video_descr->required_bds_factor);
				if (err != IA_CSS_SUCCESS)
					return err;
			} else {
				bds_out_info->res.width =
				    in_info->res.width / 2;
				bds_out_info->res.height =
				    in_info->res.height / 2;
				bds_out_info->padded_width =
				    in_info->padded_width / 2;
				video_descr->required_bds_factor =
				    SH_CSS_BDS_FACTOR_2_00;
			}
		} else {
			bds_out_info->res.width = in_info->res.width;
			bds_out_info->res.height = in_info->res.height;
			bds_out_info->padded_width = in_info->padded_width;
			video_descr->required_bds_factor =
			    SH_CSS_BDS_FACTOR_1_00;
		}
#endif
		pipe->required_bds_factor = video_descr->required_bds_factor;

		/* bayer ds and fractional ds cannot be enabled
		at the same time, so we disable bds_out_info when
		fractional ds is used */
		if (!pipe->extra_config.enable_fractional_ds)
			video_descr->bds_out_info = bds_out_info;
		else
			video_descr->bds_out_info = NULL;

		video_descr->enable_fractional_ds =
		    pipe->extra_config.enable_fractional_ds;
		video_descr->stream_config_left_padding = stream_config_left_padding;
	}
	IA_CSS_LEAVE_ERR_PRIVATE(err);
	return err;
}
enum ia_css_err ia_css_pipe_get_preview_binarydesc(
	struct ia_css_pipe * const pipe,
	struct ia_css_binary_descr *preview_descr,
	struct ia_css_frame_info *original_in_info,
	struct ia_css_frame_info *in_info,
	struct ia_css_frame_info *bds_out_info,
	struct ia_css_frame_info *out_info,
	struct ia_css_frame_info *vf_info)
{
	enum ia_css_err err;
	struct ia_css_frame_info *out_infos[IA_CSS_BINARY_MAX_OUTPUT_PORTS];
	int mode = IA_CSS_BINARY_MODE_PREVIEW;
	unsigned int i;

	assert(pipe != NULL);
	assert(in_info != NULL);
	assert(out_info != NULL);
	assert(vf_info != NULL);
	IA_CSS_ENTER_PRIVATE("");

	/*
	 * Set up the info of the input frame with
	 * the original resolution
	 */
	original_in_info->res = pipe->stream->config.input_config.input_res;
	original_in_info->padded_width = original_in_info->res.width;
	original_in_info->raw_bit_depth = ia_css_pipe_util_pipe_input_format_bpp(pipe);

	/*
	 * Set up the info of the input frame with
	 * the ISP required resolution
	 */
	in_info->res = pipe->config.input_effective_res;
	in_info->padded_width = in_info->res.width;
	in_info->raw_bit_depth = ia_css_pipe_util_pipe_input_format_bpp(pipe);

	if (ia_css_util_is_input_format_yuv(pipe->stream->config.input_config.format))
		mode = IA_CSS_BINARY_MODE_COPY;
	else {
		original_in_info->format = IA_CSS_FRAME_FORMAT_RAW;
		in_info->format = IA_CSS_FRAME_FORMAT_RAW;
	}

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

	/*
	 * [email protected]
	 *
	 * TODO
	 * - Pass "preview" the valid input argument "original_in_info".
	 */
	pipe_binarydesc_get_offline(pipe, mode,
			       preview_descr, original_in_info, in_info, out_infos, vf_info);
	if (pipe->stream->config.online) {
		preview_descr->online = pipe->stream->config.online;
		preview_descr->two_ppc =
		    (pipe->stream->config.pixels_per_clock == 2);
	}
	preview_descr->stream_format = pipe->stream->config.input_config.format;

	/* TODO: Remove this when bds_out_info is available! */
	*bds_out_info = *in_info;

	if (pipe->extra_config.enable_raw_binning) {
		if (pipe->config.bayer_ds_out_res.width != 0 &&
		    pipe->config.bayer_ds_out_res.height != 0) {
			bds_out_info->res.width =
			    pipe->config.bayer_ds_out_res.width;
			bds_out_info->res.height =
			    pipe->config.bayer_ds_out_res.height;
			bds_out_info->padded_width =
			    pipe->config.bayer_ds_out_res.width;
			err =
			    binarydesc_calculate_bds_factor(in_info->res,
				    bds_out_info->res,
				    &preview_descr->required_bds_factor);
			if (err != IA_CSS_SUCCESS)
				return err;
		} else {
			bds_out_info->res.width = in_info->res.width / 2;
			bds_out_info->res.height = in_info->res.height / 2;
			bds_out_info->padded_width = in_info->padded_width / 2;
			preview_descr->required_bds_factor =
			    SH_CSS_BDS_FACTOR_2_00;
		}
	} else {
		/* TODO: Remove this when bds_out_info->is available! */
		bds_out_info->res.width = in_info->res.width;
		bds_out_info->res.height = in_info->res.height;
		bds_out_info->padded_width = in_info->padded_width;
		preview_descr->required_bds_factor = SH_CSS_BDS_FACTOR_1_00;
	}
	pipe->required_bds_factor = preview_descr->required_bds_factor;

	/* bayer ds and fractional ds cannot be enabled at the same time,
	so we disable bds_out_info when fractional ds is used */
	if (!pipe->extra_config.enable_fractional_ds)
		preview_descr->bds_out_info = bds_out_info;
	else
		preview_descr->bds_out_info = NULL;
	/*
	   ----Preview binary-----
	   --in-->|--out->|vf_veceven|--|--->vf
	   -----------------------
	   * Preview binary normally doesn't have a vf_port but
	   * instead it has an output port. However, the output is
	   * generated by vf_veceven module in which we might have
	   * a downscaling (by 1x, 2x, or 4x). Because the resolution
	   * might change, we need two different info, namely out_info
	   * & vf_info. In fill_binary_info we use out&vf info to
	   * calculate vf decimation factor.
	 */
	*out_info = *vf_info;

	/* In case of preview_ds binary, we can do any fractional amount
	 * of downscale, so there is no DS needed in vf_veceven. Therefore,
	 * out and vf infos will be the same. Otherwise, we set out resolution
	 * equal to in resolution. */
	if (!pipe->extra_config.enable_fractional_ds) {
		/* TODO: Change this when bds_out_info is available! */
		out_info->res.width = bds_out_info->res.width;
		out_info->res.height = bds_out_info->res.height;
		out_info->padded_width = bds_out_info->padded_width;
	}
	preview_descr->enable_fractional_ds =
	    pipe->extra_config.enable_fractional_ds;

	preview_descr->isp_pipe_version = pipe->config.isp_pipe_version;
	IA_CSS_LEAVE_ERR_PRIVATE(IA_CSS_SUCCESS);
	return IA_CSS_SUCCESS;
}