Commit 62596705 authored by Mauro Carvalho Chehab's avatar Mauro Carvalho Chehab

media: atomisp: return errors from ia_css_dma_configure_from_info()

Now that the pipeline config functions can return errors, change
ia_css_dma_configure_from_info() and callers in order for them
to return errors at pipelines instead of using assert().
Signed-off-by: default avatarMauro Carvalho Chehab <mchehab+huawei@kernel.org>
parent 874da1fd
...@@ -41,13 +41,18 @@ int ia_css_crop_config(struct sh_css_isp_crop_isp_config *to, ...@@ -41,13 +41,18 @@ int ia_css_crop_config(struct sh_css_isp_crop_isp_config *to,
unsigned int size) unsigned int size)
{ {
unsigned int elems_a = ISP_VEC_NELEMS; unsigned int elems_a = ISP_VEC_NELEMS;
int ret;
ret = ia_css_dma_configure_from_info(&to->port_b, from->info);
if (ret)
return ret;
(void)size;
ia_css_dma_configure_from_info(&to->port_b, from->info);
to->width_a_over_b = elems_a / to->port_b.elems; to->width_a_over_b = elems_a / to->port_b.elems;
/* Assume divisiblity here, may need to generalize to fixed point. */ /* Assume divisiblity here, may need to generalize to fixed point. */
assert(elems_a % to->port_b.elems == 0); if (elems_a % to->port_b.elems != 0)
return -EINVAL;
return 0; return 0;
} }
......
...@@ -56,13 +56,18 @@ int ia_css_fpn_config(struct sh_css_isp_fpn_isp_config *to, ...@@ -56,13 +56,18 @@ int ia_css_fpn_config(struct sh_css_isp_fpn_isp_config *to,
unsigned int size) unsigned int size)
{ {
unsigned int elems_a = ISP_VEC_NELEMS; unsigned int elems_a = ISP_VEC_NELEMS;
int ret;
ret = ia_css_dma_configure_from_info(&to->port_b, from->info);
if (ret)
return ret;
(void)size;
ia_css_dma_configure_from_info(&to->port_b, from->info);
to->width_a_over_b = elems_a / to->port_b.elems; to->width_a_over_b = elems_a / to->port_b.elems;
/* Assume divisiblity here, may need to generalize to fixed point. */ /* Assume divisiblity here, may need to generalize to fixed point. */
assert(elems_a % to->port_b.elems == 0); if (elems_a % to->port_b.elems != 0)
return -EINVAL;
return 0; return 0;
} }
......
...@@ -36,6 +36,7 @@ int ia_css_bayer_io_config(const struct ia_css_binary *binary, ...@@ -36,6 +36,7 @@ int ia_css_bayer_io_config(const struct ia_css_binary *binary,
ddr_bits_per_element); ddr_bits_per_element);
unsigned int size_get = 0, size_put = 0; unsigned int size_get = 0, size_put = 0;
unsigned int offset = 0; unsigned int offset = 0;
int ret;
if (binary->info->mem_offsets.offsets.param) { if (binary->info->mem_offsets.offsets.param) {
size_get = binary->info->mem_offsets.offsets.param->dmem.get.size; size_get = binary->info->mem_offsets.offsets.param->dmem.get.size;
...@@ -51,7 +52,9 @@ int ia_css_bayer_io_config(const struct ia_css_binary *binary, ...@@ -51,7 +52,9 @@ int ia_css_bayer_io_config(const struct ia_css_binary *binary,
"ia_css_bayer_io_config() get part enter:\n"); "ia_css_bayer_io_config() get part enter:\n");
#endif #endif
ia_css_dma_configure_from_info(&config, in_frame_info); ret = ia_css_dma_configure_from_info(&config, in_frame_info);
if (ret)
return ret;
// The base_address of the input frame will be set in the ISP // The base_address of the input frame will be set in the ISP
to->width = in_frame_info->res.width; to->width = in_frame_info->res.width;
to->height = in_frame_info->res.height; to->height = in_frame_info->res.height;
...@@ -77,7 +80,9 @@ int ia_css_bayer_io_config(const struct ia_css_binary *binary, ...@@ -77,7 +80,9 @@ int ia_css_bayer_io_config(const struct ia_css_binary *binary,
"ia_css_bayer_io_config() put part enter:\n"); "ia_css_bayer_io_config() put part enter:\n");
#endif #endif
ia_css_dma_configure_from_info(&config, &out_frames[0]->info); ret = ia_css_dma_configure_from_info(&config, &out_frames[0]->info);
if (ret)
return ret;
to->base_address = out_frames[0]->data; to->base_address = out_frames[0]->data;
to->width = out_frames[0]->info.res.width; to->width = out_frames[0]->info.res.width;
to->height = out_frames[0]->info.res.height; to->height = out_frames[0]->info.res.height;
......
...@@ -36,6 +36,7 @@ int ia_css_yuv444_io_config(const struct ia_css_binary *binary, ...@@ -36,6 +36,7 @@ int ia_css_yuv444_io_config(const struct ia_css_binary *binary,
ddr_bits_per_element); ddr_bits_per_element);
unsigned int size_get = 0, size_put = 0; unsigned int size_get = 0, size_put = 0;
unsigned int offset = 0; unsigned int offset = 0;
int ret;
if (binary->info->mem_offsets.offsets.param) { if (binary->info->mem_offsets.offsets.param) {
size_get = binary->info->mem_offsets.offsets.param->dmem.get.size; size_get = binary->info->mem_offsets.offsets.param->dmem.get.size;
...@@ -51,7 +52,10 @@ int ia_css_yuv444_io_config(const struct ia_css_binary *binary, ...@@ -51,7 +52,10 @@ int ia_css_yuv444_io_config(const struct ia_css_binary *binary,
"ia_css_yuv444_io_config() get part enter:\n"); "ia_css_yuv444_io_config() get part enter:\n");
#endif #endif
ia_css_dma_configure_from_info(&config, in_frame_info); ret = ia_css_dma_configure_from_info(&config, in_frame_info);
if (ret)
return ret;
// The base_address of the input frame will be set in the ISP // The base_address of the input frame will be set in the ISP
to->width = in_frame_info->res.width; to->width = in_frame_info->res.width;
to->height = in_frame_info->res.height; to->height = in_frame_info->res.height;
...@@ -77,7 +81,10 @@ int ia_css_yuv444_io_config(const struct ia_css_binary *binary, ...@@ -77,7 +81,10 @@ int ia_css_yuv444_io_config(const struct ia_css_binary *binary,
"ia_css_yuv444_io_config() put part enter:\n"); "ia_css_yuv444_io_config() put part enter:\n");
#endif #endif
ia_css_dma_configure_from_info(&config, &out_frames[0]->info); ret = ia_css_dma_configure_from_info(&config, &out_frames[0]->info);
if (ret)
return ret;
to->base_address = out_frames[0]->data; to->base_address = out_frames[0]->data;
to->width = out_frames[0]->info.res.width; to->width = out_frames[0]->info.res.width;
to->height = out_frames[0]->info.res.height; to->height = out_frames[0]->info.res.height;
......
...@@ -57,16 +57,21 @@ int ia_css_output_config(struct sh_css_isp_output_isp_config *to, ...@@ -57,16 +57,21 @@ int ia_css_output_config(struct sh_css_isp_output_isp_config *to,
unsigned int size) unsigned int size)
{ {
unsigned int elems_a = ISP_VEC_NELEMS; unsigned int elems_a = ISP_VEC_NELEMS;
int ret;
ret = ia_css_dma_configure_from_info(&to->port_b, from->info);
if (ret)
return ret;
(void)size;
ia_css_dma_configure_from_info(&to->port_b, from->info);
to->width_a_over_b = elems_a / to->port_b.elems; to->width_a_over_b = elems_a / to->port_b.elems;
to->height = from->info ? from->info->res.height : 0; to->height = from->info ? from->info->res.height : 0;
to->enable = from->info != NULL; to->enable = from->info != NULL;
ia_css_frame_info_to_frame_sp_info(&to->info, from->info); ia_css_frame_info_to_frame_sp_info(&to->info, from->info);
/* Assume divisiblity here, may need to generalize to fixed point. */ /* Assume divisiblity here, may need to generalize to fixed point. */
assert(elems_a % to->port_b.elems == 0); if (elems_a % to->port_b.elems != 0)
return -EINVAL;
return 0; return 0;
} }
......
...@@ -33,16 +33,21 @@ int ia_css_qplane_config(struct sh_css_isp_qplane_isp_config *to, ...@@ -33,16 +33,21 @@ int ia_css_qplane_config(struct sh_css_isp_qplane_isp_config *to,
unsigned int size) unsigned int size)
{ {
unsigned int elems_a = ISP_VEC_NELEMS; unsigned int elems_a = ISP_VEC_NELEMS;
int ret;
ret = ia_css_dma_configure_from_info(&to->port_b, from->info);
if (ret)
return ret;
(void)size;
ia_css_dma_configure_from_info(&to->port_b, from->info);
to->width_a_over_b = elems_a / to->port_b.elems; to->width_a_over_b = elems_a / to->port_b.elems;
/* Assume divisiblity here, may need to generalize to fixed point. */ /* Assume divisiblity here, may need to generalize to fixed point. */
assert(elems_a % to->port_b.elems == 0); if (elems_a % to->port_b.elems != 0)
return -EINVAL;
to->inout_port_config = from->pipe->inout_port_config; to->inout_port_config = from->pipe->inout_port_config;
to->format = from->info->format; to->format = from->info->format;
return 0; return 0;
} }
......
...@@ -71,8 +71,8 @@ int ia_css_raw_config(struct sh_css_isp_raw_isp_config *to, ...@@ -71,8 +71,8 @@ int ia_css_raw_config(struct sh_css_isp_raw_isp_config *to,
unsigned int elems_a = ISP_VEC_NELEMS; unsigned int elems_a = ISP_VEC_NELEMS;
const struct ia_css_frame_info *in_info = from->in_info; const struct ia_css_frame_info *in_info = from->in_info;
const struct ia_css_frame_info *internal_info = from->internal_info; const struct ia_css_frame_info *internal_info = from->internal_info;
int ret;
(void)size;
#if !defined(ISP2401) #if !defined(ISP2401)
/* 2401 input system uses input width width */ /* 2401 input system uses input width width */
in_info = internal_info; in_info = internal_info;
...@@ -84,7 +84,9 @@ int ia_css_raw_config(struct sh_css_isp_raw_isp_config *to, ...@@ -84,7 +84,9 @@ int ia_css_raw_config(struct sh_css_isp_raw_isp_config *to,
in_info = internal_info; in_info = internal_info;
#endif #endif
ia_css_dma_configure_from_info(&to->port_b, in_info); ret = ia_css_dma_configure_from_info(&to->port_b, in_info);
if (ret)
return ret;
/* Assume divisiblity here, may need to generalize to fixed point. */ /* Assume divisiblity here, may need to generalize to fixed point. */
assert((in_info->format == IA_CSS_FRAME_FORMAT_RAW_PACKED) || assert((in_info->format == IA_CSS_FRAME_FORMAT_RAW_PACKED) ||
......
...@@ -27,9 +27,12 @@ int ia_css_ref_config(struct sh_css_isp_ref_isp_config *to, ...@@ -27,9 +27,12 @@ int ia_css_ref_config(struct sh_css_isp_ref_isp_config *to,
unsigned int size) unsigned int size)
{ {
unsigned int elems_a = ISP_VEC_NELEMS, i; unsigned int elems_a = ISP_VEC_NELEMS, i;
int ret;
if (from->ref_frames[0]) { if (from->ref_frames[0]) {
ia_css_dma_configure_from_info(&to->port_b, &from->ref_frames[0]->info); ret = ia_css_dma_configure_from_info(&to->port_b, &from->ref_frames[0]->info);
if (ret)
return ret;
to->width_a_over_b = elems_a / to->port_b.elems; to->width_a_over_b = elems_a / to->port_b.elems;
to->dvs_frame_delay = from->dvs_frame_delay; to->dvs_frame_delay = from->dvs_frame_delay;
} else { } else {
...@@ -50,7 +53,9 @@ int ia_css_ref_config(struct sh_css_isp_ref_isp_config *to, ...@@ -50,7 +53,9 @@ int ia_css_ref_config(struct sh_css_isp_ref_isp_config *to,
} }
/* Assume divisiblity here, may need to generalize to fixed point. */ /* Assume divisiblity here, may need to generalize to fixed point. */
assert(elems_a % to->port_b.elems == 0); if (elems_a % to->port_b.elems != 0)
return -EINVAL;
return 0; return 0;
} }
......
...@@ -77,9 +77,11 @@ int ia_css_tnr_config(struct sh_css_isp_tnr_isp_config *to, ...@@ -77,9 +77,11 @@ int ia_css_tnr_config(struct sh_css_isp_tnr_isp_config *to,
{ {
unsigned int elems_a = ISP_VEC_NELEMS; unsigned int elems_a = ISP_VEC_NELEMS;
unsigned int i; unsigned int i;
int ret;
(void)size; ret = ia_css_dma_configure_from_info(&to->port_b, &from->tnr_frames[0]->info);
ia_css_dma_configure_from_info(&to->port_b, &from->tnr_frames[0]->info); if (ret)
return ret;
to->width_a_over_b = elems_a / to->port_b.elems; to->width_a_over_b = elems_a / to->port_b.elems;
to->frame_height = from->tnr_frames[0]->info.res.height; to->frame_height = from->tnr_frames[0]->info.res.height;
for (i = 0; i < NUM_TNR_FRAMES; i++) { for (i = 0; i < NUM_TNR_FRAMES; i++) {
...@@ -88,7 +90,9 @@ int ia_css_tnr_config(struct sh_css_isp_tnr_isp_config *to, ...@@ -88,7 +90,9 @@ int ia_css_tnr_config(struct sh_css_isp_tnr_isp_config *to,
} }
/* Assume divisiblity here, may need to generalize to fixed point. */ /* Assume divisiblity here, may need to generalize to fixed point. */
assert(elems_a % to->port_b.elems == 0); if (elems_a % to->port_b.elems != 0)
return -EINVAL;
return 0; return 0;
} }
......
...@@ -31,18 +31,21 @@ int ia_css_vf_config(struct sh_css_isp_vf_isp_config *to, ...@@ -31,18 +31,21 @@ int ia_css_vf_config(struct sh_css_isp_vf_isp_config *to,
unsigned int size) unsigned int size)
{ {
unsigned int elems_a = ISP_VEC_NELEMS; unsigned int elems_a = ISP_VEC_NELEMS;
int ret;
(void)size;
to->vf_downscale_bits = from->vf_downscale_bits; to->vf_downscale_bits = from->vf_downscale_bits;
to->enable = from->info != NULL; to->enable = from->info != NULL;
if (from->info) { if (from->info) {
ia_css_frame_info_to_frame_sp_info(&to->info, from->info); ia_css_frame_info_to_frame_sp_info(&to->info, from->info);
ia_css_dma_configure_from_info(&to->dma.port_b, from->info); ret = ia_css_dma_configure_from_info(&to->dma.port_b, from->info);
if (ret)
return ret;
to->dma.width_a_over_b = elems_a / to->dma.port_b.elems; to->dma.width_a_over_b = elems_a / to->dma.port_b.elems;
/* Assume divisiblity here, may need to generalize to fixed point. */ /* Assume divisiblity here, may need to generalize to fixed point. */
assert(elems_a % to->dma.port_b.elems == 0); if (elems_a % to->dma.port_b.elems != 0)
return -EINVAL;
} }
return 0; return 0;
} }
......
...@@ -608,7 +608,12 @@ int ia_css_dma_configure_from_info(struct dma_port_config *config, ...@@ -608,7 +608,12 @@ int ia_css_dma_configure_from_info(struct dma_port_config *config,
config->elems = (uint8_t)elems_b; config->elems = (uint8_t)elems_b;
config->width = (uint16_t)info->res.width; config->width = (uint16_t)info->res.width;
config->crop = 0; config->crop = 0;
assert(config->width <= info->padded_width);
if (config->width > info->padded_width) {
dev_err(atomisp_dev, "internal error: padded_width is too small!\n");
return -EINVAL;
}
return 0; return 0;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment