irq_infos & SH_CSS_IRQ_INFO_START_NEXT_STAGE) {
/* Wake up sleep thread for next binary */
signal_worker = true;
- if (irq_infos & SH_CSS_IRQ_INFO_STATISTICS_READY)
+ if (irq_infos & SH_CSS_IRQ_INFO_STATISTICS_READY) {
signal_statistics = true;
- if (irq_infos & SH_CSS_IRQ_INFO_FW_ACC_DONE)
+ isp->isp3a_stat_ready = true;
+ }
+ if (irq_infos & SH_CSS_IRQ_INFO_FW_ACC_DONE) {
signal_acceleration = true;
+ }
} else if (irq_infos & SH_CSS_IRQ_INFO_CSS_RECEIVER_ERROR) {
/* handle mipi receiver error*/
u32 rx_infos;
/* proc interrupt */
INIT_COMPLETION(isp->wq_frame_complete);
- if (irq_infos & SH_CSS_IRQ_INFO_START_NEXT_STAGE)
+ if (irq_infos & SH_CSS_IRQ_INFO_START_NEXT_STAGE) {
sh_css_start_next_stage();
+
+ /* Getting 3A statistics if ready */
+ if (isp->isp3a_stat_ready) {
+ mutex_lock(&isp->isp3a_lock);
+ ret = sh_css_get_3a_statistics
+ (isp->params.s3a_output_buf);
+ mutex_unlock(&isp->isp3a_lock);
+
+ isp->isp3a_stat_ready = false;
+ if (ret != sh_css_success)
+ v4l2_err(&atomisp_dev,
+ "get 3a statistics"
+ " failed, not "
+ "enough memory.\n");
+ }
+ }
} while (!(irq_infos & SH_CSS_IRQ_INFO_FRAME_DONE));
mutex_unlock(&isp->isp_lock);
sizeof(isp->params.curr_grid_info)) != 0)
return -EAGAIN;
- ret = sh_css_get_3a_statistics(isp->params.s3a_output_buf);
- if (ret) {
- v4l2_err(&atomisp_dev, "failed to get 3A statistics\n");
- return -EFAULT;
- }
+ mutex_lock(&isp->isp3a_lock);
ret = copy_to_user(arg->data, isp->params.s3a_output_buf,
isp->params.s3a_output_bytes);
+ mutex_unlock(&isp->isp3a_lock);
if (ret) {
v4l2_err(&atomisp_dev,
"copy to user failed: copied %lu bytes\n", ret);
infos |= SH_CSS_IRQ_INFO_FRAME_DONE;
else
infos |= SH_CSS_IRQ_INFO_START_NEXT_STAGE;
- if (sh_css_statistics_ready()) {
+ if (sh_css_statistics_ready())
infos |= SH_CSS_IRQ_INFO_STATISTICS_READY;
- sh_css_params_swap_3a_buffers();
- }
if (acceleration_done())
infos |= SH_CSS_IRQ_INFO_FW_ACC_DONE;
my_css.state = sh_css_state_idle;
return err;
}
-bool
-sh_css_preview_next_stage_needs_alloc(void)
-{
- return my_css.invalidate ||
- my_css.preview_settings.pipeline.reload ||
- my_css.preview_settings.zoom_changed ||
- my_css.preview_settings.preview_binary.info == NULL ||
- my_css.preview_settings.shading_table == NULL;
-}
-
static void
init_video_descr(struct sh_css_frame_info *in_info,
struct sh_css_frame_info *vf_info)
*height = my_css.video_settings.dvs_envelope_height;
}
-bool
-sh_css_video_next_stage_needs_alloc(void)
-{
- return my_css.invalidate ||
- my_css.video_settings.pipeline.reload ||
- my_css.video_settings.zoom_changed ||
- my_css.video_settings.video_binary.info == NULL ||
- my_css.video_settings.shading_table == NULL;
-}
-
void
sh_css_set_zoom_factor(unsigned int dx, unsigned int dy)
{
my_css.capture_settings.online = enable;
}
-bool
-sh_css_capture_next_stage_needs_alloc(void)
-{
- struct sh_css_binary *main_binary;
-
- main_binary = &my_css.capture_settings.primary_binary;
- if (my_css.capture_settings.mode == SH_CSS_CAPTURE_MODE_RAW)
- main_binary = &my_css.capture_settings.copy_binary;
- else if (my_css.capture_settings.mode == SH_CSS_CAPTURE_MODE_ADVANCED)
- main_binary = &my_css.capture_settings.pre_isp_binary;
-
- return my_css.invalidate ||
- my_css.capture_settings.pipeline.reload ||
- my_css.capture_settings.zoom_changed ||
- main_binary->info == NULL ||
- my_css.capture_settings.shading_table == NULL;
-}
-
enum sh_css_err
sh_css_histogram_allocate(unsigned int num_elements,
struct sh_css_histogram **histogram)
tetra_ratb_x_size,
tetra_ratb_y_size;
-/* Double buffering for 3A */
-static void *s3a_tables[2],
- *s3a_tables_hi[2],
- *s3a_tables_lo[2],
- *dis_hor_projections[2],
- *dis_ver_projections[2];
-static unsigned int curr_valid_buffer;
-
/* local buffers, used to re-order the 3a statistics in vmem-format */
static unsigned short s3a_tbl_hi_buf[ISP_S3ATBL_HI_LO_STRIDE *
SH_CSS_MAX_BQ_GRID_HEIGHT],
hor_num_3a, ver_num_3a, i;
int *hor_ptr_3a = horizontal_projections,
*ver_ptr_3a = vertical_projections,
- *hor_ptr_isp = dis_hor_projections[curr_valid_buffer],
- *ver_ptr_isp = dis_ver_projections[curr_valid_buffer];
+ *hor_ptr_isp = ddr_ptrs.sdis_hor_proj,
+ *ver_ptr_isp = ddr_ptrs.sdis_ver_proj;
if (current_3a_binary == NULL)
return;
out_height = current_3a_binary->s3atbl_height,
i;
struct sh_css_3a_output
- *ddr_ptr = s3a_tables[curr_valid_buffer],
+ *ddr_ptr = ddr_ptrs.s3a_tbl,
*out_ptr = output;
for (i = 0; i < out_height; i++) {
chunk = max(chunk, 1);
bytes = ISP_S3ATBL_HI_LO_STRIDE_BYTES * out_height;
- hrt_isp_css_mm_load(s3a_tables_hi[curr_valid_buffer], hi, bytes);
- hrt_isp_css_mm_load(s3a_tables_lo[curr_valid_buffer], lo, bytes);
+ hrt_isp_css_mm_load(ddr_ptrs.s3a_tbl_hi, hi, bytes);
+ hrt_isp_css_mm_load(ddr_ptrs.s3a_tbl_lo, lo, bytes);
for (y = 0; y < out_height; y++) {
elm_start = y * ISP_S3ATBL_HI_LO_STRIDE;
SCTBL_BYTES(binary), &err);
}
if (binary->info->enable_s3a && binary->info->s3atbl_use_dmem) {
- unsigned int size = s3a_tbl_size;
- changed |= reallocate_cached_buffer(&s3a_tables[0],
- &size,
- S3ATBL_BYTES(binary), &err);
- changed |= reallocate_cached_buffer(&s3a_tables[1],
+ changed |= reallocate_cached_buffer(&ddr_ptrs.s3a_tbl,
&s3a_tbl_size,
S3ATBL_BYTES(binary), &err);
}
if (binary->info->enable_s3a && !binary->info->s3atbl_use_dmem) {
- unsigned int hi_size = s3a_tbl_hi_size,
- lo_size = s3a_tbl_lo_size;
- changed |= reallocate_cached_buffer(&s3a_tables_hi[0],
- &hi_size,
- S3ATBL_HI_LO_BYTES(binary),
- &err);
- changed |= reallocate_cached_buffer(&s3a_tables_hi[1],
+ changed |= reallocate_cached_buffer(&ddr_ptrs.s3a_tbl_hi,
&s3a_tbl_hi_size,
S3ATBL_HI_LO_BYTES(binary),
&err);
- changed |= reallocate_cached_buffer(&s3a_tables_lo[0],
- &lo_size,
- S3ATBL_HI_LO_BYTES(binary),
- &err);
- changed |= reallocate_cached_buffer(&s3a_tables_lo[1],
+ changed |= reallocate_cached_buffer(&ddr_ptrs.s3a_tbl_lo,
&s3a_tbl_lo_size,
S3ATBL_HI_LO_BYTES(binary),
&err);
}
if (binary->info->enable_dis) {
- unsigned int hor_size = sdis_hor_proj_size,
- ver_size = sdis_ver_proj_size;
changed |= reallocate_buffer(&ddr_ptrs.sdis_hor_coef,
&sdis_hor_coef_size,
SDIS_HOR_COEF_TBL_BYTES(binary),
&sdis_ver_coef_size,
SDIS_VER_COEF_TBL_BYTES(binary),
&err);
- changed |= reallocate_buffer(&dis_hor_projections[0],
- &hor_size,
- SDIS_HOR_PROJ_TBL_BYTES(binary),
- &err);
- changed |= reallocate_buffer(&dis_hor_projections[1],
+ changed |= reallocate_buffer(&ddr_ptrs.sdis_hor_proj,
&sdis_hor_proj_size,
SDIS_HOR_PROJ_TBL_BYTES(binary),
&err);
- changed |= reallocate_buffer(&dis_ver_projections[0],
- &ver_size,
- SDIS_VER_PROJ_TBL_BYTES(binary),
- &err);
- changed |= reallocate_buffer(&dis_ver_projections[1],
+ changed |= reallocate_buffer(&ddr_ptrs.sdis_ver_proj,
&sdis_ver_proj_size,
SDIS_VER_PROJ_TBL_BYTES(binary),
&err);
return err;
}
-void
-sh_css_params_swap_3a_buffers(void)
-{
- curr_valid_buffer = 1-curr_valid_buffer;
-}
-
enum sh_css_err
sh_css_params_init(void)
{
return sh_css_err_cannot_allocate_memory;
}
/* Copy XMEM address map to XMEM for SP access */
+ hrt_isp_css_mm_store(sp_ddr_ptrs, &ddr_ptrs, sizeof(ddr_ptrs));
sh_css_set_3a_config(&default_3a_config);
sh_css_set_wb_config(&default_wb_config);
sh_css_set_cc_config(&default_cc_config);
morph_table_changed = true;
sc_table = NULL;
sc_table_changed = false;
- curr_valid_buffer = 0;
return sh_css_success;
}
safe_free(ddr_ptrs.macc_tbl);
safe_free(ddr_ptrs.fpn_tbl);
safe_free(ddr_ptrs.sc_tbl);
- safe_free(s3a_tables[0]);
- safe_free(s3a_tables[1]);
- safe_free(s3a_tables_hi[0]);
- safe_free(s3a_tables_hi[1]);
- safe_free(s3a_tables_lo[0]);
- safe_free(s3a_tables_lo[1]);
- safe_free(dis_hor_projections[0]);
- safe_free(dis_hor_projections[1]);
- safe_free(dis_ver_projections[0]);
- safe_free(dis_ver_projections[1]);
+ safe_free(ddr_ptrs.s3a_tbl);
+ safe_free(ddr_ptrs.s3a_tbl_hi);
+ safe_free(ddr_ptrs.s3a_tbl_lo);
safe_free(ddr_ptrs.sdis_hor_coef);
safe_free(ddr_ptrs.sdis_ver_coef);
+ safe_free(ddr_ptrs.sdis_hor_proj);
+ safe_free(ddr_ptrs.sdis_ver_proj);
safe_free(ddr_ptrs.tetra_r_x);
safe_free(ddr_ptrs.tetra_r_y);
safe_free(ddr_ptrs.tetra_gr_x);
sh_css_params_write_to_ddr(const struct sh_css_binary *binary)
{
enum sh_css_err err;
- unsigned int free_buffer = 1-curr_valid_buffer;
err = reallocate_buffers(binary);
if (err != sh_css_success)
return err;
- /* Make sure the SP firmware uses the right (free) buffer */
- ddr_ptrs.s3a_tbl = s3a_tables[free_buffer];
- ddr_ptrs.s3a_tbl_hi = s3a_tables_hi[free_buffer];
- ddr_ptrs.s3a_tbl_lo = s3a_tables_lo[free_buffer];
- ddr_ptrs.sdis_hor_proj = dis_hor_projections[free_buffer];
- ddr_ptrs.sdis_ver_proj = dis_ver_projections[free_buffer];
-
- hrt_isp_css_mm_store(sp_ddr_ptrs, &ddr_ptrs, sizeof(ddr_ptrs));
-
if (fpn_table_changed && binary->info->enable_fpnr) {
if (isp_parameters.fpn_enabled) {
store_fpntbl(ddr_ptrs.fpn_tbl);
unsigned int hor_num_isp, ver_num_isp, i;
int *hor_ptr = horizontal_projections,
*ver_ptr = vertical_projections,
- *hor_ptr_isp = dis_hor_projections[curr_valid_buffer],
- *ver_ptr_isp = dis_ver_projections[curr_valid_buffer];
+ *hor_ptr_isp = ddr_ptrs.sdis_hor_proj,
+ *ver_ptr_isp = ddr_ptrs.sdis_ver_proj;
if (current_3a_binary == NULL)
return;
sh_css_store_sp_group_to_ddr(void)
{
hrt_isp_css_mm_store(xmem_sp_group_ptrs,
- &sh_css_sp_group,
- sizeof(struct sh_css_sp_group));
+ &sh_css_sp_group,
+ sizeof(struct sh_css_sp_group));
return xmem_sp_group_ptrs;
}