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

media: atomisp: sh_css_defs.h: get rid of build time dependencies

There are several #ifdefs checking for ISP version there. Some
of them are just two different ways to represent the same contants,
while 3 parameters are actually different, depending on the ISP
version.

Change the header in a way that it will be compatible with both
versions, and change dependent code to keep running, removing
ifdefs there only when possible.
Signed-off-by: default avatarMauro Carvalho Chehab <mchehab+huawei@kernel.org>
parent 483f5215
......@@ -3605,11 +3605,19 @@ int atomisp_cp_lsc_table(struct atomisp_sub_device *asd,
}
/* Shading table size per color */
if (st->width > SH_CSS_MAX_SCTBL_WIDTH_PER_COLOR ||
st->height > SH_CSS_MAX_SCTBL_HEIGHT_PER_COLOR) {
if (!atomisp_hw_is_isp2401) {
if (st->width > ISP2400_SH_CSS_MAX_SCTBL_WIDTH_PER_COLOR ||
st->height > ISP2400_SH_CSS_MAX_SCTBL_HEIGHT_PER_COLOR) {
dev_err(asd->isp->dev, "shading table w/h validate failed!");
return -EINVAL;
}
} else {
if (st->width > ISP2401_SH_CSS_MAX_SCTBL_WIDTH_PER_COLOR ||
st->height > ISP2401_SH_CSS_MAX_SCTBL_HEIGHT_PER_COLOR) {
dev_err(asd->isp->dev, "shading table w/h validate failed!");
return -EINVAL;
}
}
shading_table = atomisp_css_shading_table_alloc(st->width, st->height);
if (!shading_table)
......@@ -6078,9 +6086,15 @@ int atomisp_set_shading_table(struct atomisp_sub_device *asd,
}
/* Shading table size per color */
if (user_shading_table->width > SH_CSS_MAX_SCTBL_WIDTH_PER_COLOR ||
user_shading_table->height > SH_CSS_MAX_SCTBL_HEIGHT_PER_COLOR)
if (!atomisp_hw_is_isp2401) {
if (user_shading_table->width > ISP2400_SH_CSS_MAX_SCTBL_WIDTH_PER_COLOR ||
user_shading_table->height > ISP2400_SH_CSS_MAX_SCTBL_HEIGHT_PER_COLOR)
return -EINVAL;
} else {
if (user_shading_table->width > ISP2401_SH_CSS_MAX_SCTBL_WIDTH_PER_COLOR ||
user_shading_table->height > ISP2401_SH_CSS_MAX_SCTBL_HEIGHT_PER_COLOR)
return -EINVAL;
}
shading_table = atomisp_css_shading_table_alloc(
user_shading_table->width, user_shading_table->height);
......
......@@ -82,11 +82,7 @@ struct ia_css_video_settings {
struct ia_css_binary vf_pp_binary;
struct ia_css_binary *yuv_scaler_binary;
struct ia_css_frame *delay_frames[MAX_NUM_VIDEO_DELAY_FRAMES];
#ifndef ISP2401
struct ia_css_frame *tnr_frames[NUM_VIDEO_TNR_FRAMES];
#else
struct ia_css_frame *tnr_frames[NUM_TNR_FRAMES];
#endif
struct ia_css_frame *vf_pp_in_frame;
struct ia_css_pipe *copy_pipe;
struct ia_css_pipe *capture_pipe;
......
......@@ -17,7 +17,6 @@
#include "type_support.h"
#ifdef ISP2401
/* To position the shading center grid point on the center of output image,
* one more grid cell is needed as margin. */
#define SH_CSS_SCTBL_CENTERING_MARGIN 1
......@@ -25,6 +24,7 @@
/* The shading table width and height are the number of grids, not cells. The last grid should be counted. */
#define SH_CSS_SCTBL_LAST_GRID_COUNT 1
#ifdef ISP2401
/* Number of horizontal grids per color in the shading table. */
#define _ISP_SCTBL_WIDTH_PER_COLOR(input_width, deci_factor_log2) \
(ISP_BQ_GRID_WIDTH(input_width, deci_factor_log2) + \
......@@ -34,6 +34,7 @@
#define _ISP_SCTBL_HEIGHT(input_height, deci_factor_log2) \
(ISP_BQ_GRID_HEIGHT(input_height, deci_factor_log2) + \
SH_CSS_SCTBL_CENTERING_MARGIN + SH_CSS_SCTBL_LAST_GRID_COUNT)
#endif
/* Legacy API: Number of horizontal grids per color in the shading table. */
#define _ISP_SCTBL_LEGACY_WIDTH_PER_COLOR(input_width, deci_factor_log2) \
......@@ -43,13 +44,11 @@
#define _ISP_SCTBL_LEGACY_HEIGHT(input_height, deci_factor_log2) \
(ISP_BQ_GRID_HEIGHT(input_height, deci_factor_log2) + SH_CSS_SCTBL_LAST_GRID_COUNT)
#endif
/* SC (Shading Corrction) */
struct sh_css_isp_sc_params {
s32 gain_shift;
};
#ifdef ISP2401
/* Number of horizontal slice times for interpolated gain:
*
* The start position of the internal frame does not match the start position of the shading table.
......@@ -67,5 +66,4 @@ struct sh_css_isp_sc_isp_config {
u32 internal_frame_origin_y_bqs_on_sctbl;
};
#endif
#endif /* __IA_CSS_SC_PARAM_H */
......@@ -83,11 +83,7 @@ ia_css_tnr_config(
ia_css_dma_configure_from_info(&to->port_b, &from->tnr_frames[0]->info);
to->width_a_over_b = elems_a / to->port_b.elems;
to->frame_height = from->tnr_frames[0]->info.res.height;
#ifndef ISP2401
for (i = 0; i < NUM_VIDEO_TNR_FRAMES; i++) {
#else
for (i = 0; i < NUM_TNR_FRAMES; i++) {
#endif
to->tnr_frame_addr[i] = from->tnr_frames[i]->data +
from->tnr_frames[i]->planes.yuyv.offset;
}
......@@ -104,11 +100,7 @@ ia_css_tnr_configure(
struct ia_css_tnr_configuration config;
unsigned int i;
#ifndef ISP2401
for (i = 0; i < NUM_VIDEO_TNR_FRAMES; i++)
#else
for (i = 0; i < NUM_TNR_FRAMES; i++)
#endif
config.tnr_frames[i] = frames[i];
ia_css_configure_tnr(binary, &config);
......@@ -121,9 +113,7 @@ ia_css_init_tnr_state(
{
(void)size;
#ifndef ISP2401
assert(NUM_VIDEO_TNR_FRAMES >= 2);
#endif
assert(NUM_TNR_FRAMES >= 2);
assert(sizeof(*state) == size);
state->tnr_in_buf_idx = 0;
state->tnr_out_buf_idx = 1;
......
......@@ -27,22 +27,14 @@ struct sh_css_isp_tnr_params {
};
struct ia_css_tnr_configuration {
#ifndef ISP2401
const struct ia_css_frame *tnr_frames[NUM_VIDEO_TNR_FRAMES];
#else
const struct ia_css_frame *tnr_frames[NUM_TNR_FRAMES];
#endif
};
struct sh_css_isp_tnr_isp_config {
u32 width_a_over_b;
u32 frame_height;
struct dma_port_config port_b;
#ifndef ISP2401
hrt_vaddress tnr_frame_addr[NUM_VIDEO_TNR_FRAMES];
#else
hrt_vaddress tnr_frame_addr[NUM_TNR_FRAMES];
#endif
};
#endif /* __IA_CSS_TNR_PARAM_H */
......@@ -463,8 +463,10 @@ more details.
/* [isp vmem] table size[vectors] per line per color (GR,R,B,GB),
multiples of NWAY */
#define SCTBL_VECTORS_PER_LINE_PER_COLOR \
CEIL_DIV(SH_CSS_MAX_SCTBL_WIDTH_PER_COLOR, ISP_VEC_NELEMS)
#define ISP2400_SCTBL_VECTORS_PER_LINE_PER_COLOR \
CEIL_DIV(ISP2400_SH_CSS_MAX_SCTBL_WIDTH_PER_COLOR, ISP_VEC_NELEMS)
#define ISP2401_SCTBL_VECTORS_PER_LINE_PER_COLOR \
CEIL_DIV(ISP2401_SH_CSS_MAX_SCTBL_WIDTH_PER_COLOR, ISP_VEC_NELEMS)
/* [isp vmem] table size[vectors] per line for 4colors (GR,R,B,GB),
multiples of NWAY */
#define SCTBL_VECTORS_PER_LINE \
......
......@@ -145,10 +145,8 @@ struct ia_css_binary {
int sctbl_width_per_color;
int sctbl_aligned_width_per_color;
int sctbl_height;
#ifdef ISP2401
int sctbl_legacy_width_per_color;
int sctbl_legacy_height;
#endif
struct ia_css_sdis_info dis;
struct ia_css_resolution dvs_envelope;
bool online;
......
......@@ -1360,34 +1360,28 @@ ia_css_binary_fill_info(const struct ia_css_binary_xinfo *xinfo,
if (info->enable.sc)
{
binary->sctbl_width_per_color =
#ifndef ISP2401
_ISP_SCTBL_WIDTH_PER_COLOR(sc_3a_dis_padded_width,
s3a_log_deci);
#else
_ISP_SCTBL_WIDTH_PER_COLOR(isp_internal_width, s3a_log_deci);
#endif
binary->sctbl_aligned_width_per_color =
SH_CSS_MAX_SCTBL_ALIGNED_WIDTH_PER_COLOR;
binary->sctbl_height =
#ifndef ISP2401
_ISP_SCTBL_HEIGHT(sc_3a_dis_height, s3a_log_deci);
#else
_ISP_SCTBL_HEIGHT(isp_internal_height, s3a_log_deci);
binary->sctbl_legacy_width_per_color =
_ISP_SCTBL_LEGACY_WIDTH_PER_COLOR(sc_3a_dis_padded_width, s3a_log_deci);
binary->sctbl_legacy_height =
_ISP_SCTBL_LEGACY_HEIGHT(sc_3a_dis_height, s3a_log_deci);
if (!atomisp_hw_is_isp2401) {
binary->sctbl_width_per_color = _ISP_SCTBL_WIDTH_PER_COLOR(sc_3a_dis_padded_width, s3a_log_deci);
binary->sctbl_aligned_width_per_color = ISP2400_SH_CSS_MAX_SCTBL_ALIGNED_WIDTH_PER_COLOR;
binary->sctbl_height = _ISP_SCTBL_HEIGHT(sc_3a_dis_height, s3a_log_deci);
} else {
binary->sctbl_width_per_color = _ISP_SCTBL_WIDTH_PER_COLOR(isp_internal_width, s3a_log_deci);
binary->sctbl_aligned_width_per_color = ISP2401_SH_CSS_MAX_SCTBL_ALIGNED_WIDTH_PER_COLOR;
binary->sctbl_height = _ISP_SCTBL_HEIGHT(isp_internal_height, s3a_log_deci);
#ifdef ISP2401
binary->sctbl_legacy_width_per_color = _ISP_SCTBL_LEGACY_WIDTH_PER_COLOR(sc_3a_dis_padded_width, s3a_log_deci);
binary->sctbl_legacy_height = _ISP_SCTBL_LEGACY_HEIGHT(sc_3a_dis_height, s3a_log_deci);
#endif
}
} else
{
binary->sctbl_width_per_color = 0;
binary->sctbl_aligned_width_per_color = 0;
binary->sctbl_height = 0;
#ifdef ISP2401
if (atomisp_hw_is_isp2401) {
binary->sctbl_legacy_width_per_color = 0;
binary->sctbl_legacy_height = 0;
#endif
}
}
ia_css_sdis_init_info(&binary->dis,
sc_3a_dis_width,
......
......@@ -2945,11 +2945,7 @@ ia_css_debug_pipe_graph_dump_stage(
"in", true);
}
#ifndef ISP2401
for (i = 0; i < NUM_VIDEO_TNR_FRAMES; i++) {
#else
for (i = 0; i < NUM_TNR_FRAMES; i++) {
#endif
if (stage->args.tnr_frames[i]) {
ia_css_debug_pipe_graph_dump_frame(
stage->args.tnr_frames[i], id,
......
......@@ -1440,11 +1440,7 @@ void sh_css_binary_args_reset(struct sh_css_binary_args *args)
{
unsigned int i;
#ifndef ISP2401
for (i = 0; i < NUM_VIDEO_TNR_FRAMES; i++)
#else
for (i = 0; i < NUM_TNR_FRAMES; i++)
#endif
args->tnr_frames[i] = NULL;
for (i = 0; i < MAX_NUM_VIDEO_DELAY_FRAMES; i++)
args->delay_frames[i] = NULL;
......@@ -2581,7 +2577,7 @@ ia_css_pipe_destroy(struct ia_css_pipe *pipe) {
}
}
#ifndef ISP2401
ia_css_frame_free_multiple(NUM_VIDEO_TNR_FRAMES,
ia_css_frame_free_multiple(NUM_TNR_FRAMES,
pipe->pipe_settings.video.tnr_frames);
#else
ia_css_frame_free_multiple(NUM_TNR_FRAMES,
......@@ -3805,7 +3801,7 @@ static enum ia_css_err create_host_video_pipeline(struct ia_css_pipe *pipe)
if (video_stage) {
int frm;
#ifndef ISP2401
for (frm = 0; frm < NUM_VIDEO_TNR_FRAMES; frm++) {
for (frm = 0; frm < NUM_TNR_FRAMES; frm++) {
#else
for (frm = 0; frm < NUM_TNR_FRAMES; frm++) {
#endif
......@@ -5986,7 +5982,7 @@ static enum ia_css_err load_video_binaries(struct ia_css_pipe *pipe)
tnr_info.raw_bit_depth = SH_CSS_TNR_BIT_DEPTH;
#ifndef ISP2401
for (i = 0; i < NUM_VIDEO_TNR_FRAMES; i++) {
for (i = 0; i < NUM_TNR_FRAMES; i++) {
#else
for (i = 0; i < NUM_TNR_FRAMES; i++) {
#endif
......
......@@ -163,15 +163,6 @@ RGB[0,8191],coef[-8192,8191] -> RGB[0,8191]
#define SH_CSS_MIN_SENSOR_WIDTH 2
#define SH_CSS_MIN_SENSOR_HEIGHT 2
#if defined(IS_ISP_2400_SYSTEM)
/* MAX width and height set to the same to allow for rotated
* resolutions. */
#define SH_CSS_MAX_VF_WIDTH 1920
#define SH_CSS_MAX_VF_HEIGHT 1920
#else
#define SH_CSS_MAX_VF_WIDTH 1280
#define SH_CSS_MAX_VF_HEIGHT 960
#endif
/*
#define SH_CSS_MAX_VF_WIDTH_DEC 1920
#define SH_CSS_MAX_VF_HEIGHT_DEC 1080
......@@ -186,34 +177,24 @@ RGB[0,8191],coef[-8192,8191] -> RGB[0,8191]
#define SH_CSS_MORPH_TABLE_ELEMS_PER_DDR_WORD \
(HIVE_ISP_DDR_WORD_BYTES / SH_CSS_MORPH_TABLE_ELEM_BYTES)
#ifndef ISP2401
#define SH_CSS_MAX_SCTBL_WIDTH_PER_COLOR (SH_CSS_MAX_BQ_GRID_WIDTH + 1)
#define SH_CSS_MAX_SCTBL_HEIGHT_PER_COLOR (SH_CSS_MAX_BQ_GRID_HEIGHT + 1)
#else
#define ISP2400_SH_CSS_MAX_SCTBL_WIDTH_PER_COLOR (SH_CSS_MAX_BQ_GRID_WIDTH + 1)
#define ISP2400_SH_CSS_MAX_SCTBL_HEIGHT_PER_COLOR (SH_CSS_MAX_BQ_GRID_HEIGHT + 1)
#define ISP2400_SH_CSS_MAX_SCTBL_ALIGNED_WIDTH_PER_COLOR \
CEIL_MUL(ISP2400_SH_CSS_MAX_SCTBL_WIDTH_PER_COLOR, ISP_VEC_NELEMS)
/* TODO: I will move macros of "*_SCTBL_*" to SC kernel.
"+ 2" should be "+ SH_CSS_SCTBL_CENTERING_MARGIN + SH_CSS_SCTBL_LAST_GRID_COUNT". (michie, Sep/23/2014) */
#define SH_CSS_MAX_SCTBL_WIDTH_PER_COLOR (SH_CSS_MAX_BQ_GRID_WIDTH + 2)
#define SH_CSS_MAX_SCTBL_HEIGHT_PER_COLOR (SH_CSS_MAX_BQ_GRID_HEIGHT + 2)
#endif
#define SH_CSS_MAX_SCTBL_ALIGNED_WIDTH_PER_COLOR \
CEIL_MUL(SH_CSS_MAX_SCTBL_WIDTH_PER_COLOR, ISP_VEC_NELEMS)
#define ISP2401_SH_CSS_MAX_SCTBL_WIDTH_PER_COLOR (SH_CSS_MAX_BQ_GRID_WIDTH + 2)
#define ISP2401_SH_CSS_MAX_SCTBL_HEIGHT_PER_COLOR (SH_CSS_MAX_BQ_GRID_HEIGHT + 2)
#define ISP2401_SH_CSS_MAX_SCTBL_ALIGNED_WIDTH_PER_COLOR \
CEIL_MUL(ISP2400_SH_CSS_MAX_SCTBL_WIDTH_PER_COLOR, ISP_VEC_NELEMS)
/* Each line of this table is aligned to the maximum line width. */
#define SH_CSS_MAX_S3ATBL_WIDTH SH_CSS_MAX_BQ_GRID_WIDTH
#ifndef ISP2401
/* The video binary supports a delay of 1 or 2 */
#define MAX_DVS_FRAME_DELAY 2
/* We always need one additional frame because the video binary
* reads the previous and writes the current frame concurrently */
#define MAX_NUM_VIDEO_DELAY_FRAMES (MAX_DVS_FRAME_DELAY + 1)
#define NUM_VIDEO_TNR_FRAMES 2
#define NUM_TNR_FRAMES 2 /* FIXME */
#define MAX_NUM_DELAY_FRAMES MAX_NUM_VIDEO_DELAY_FRAMES
#else
/* Video mode specific DVS define */
/* The video binary supports a delay of 1 or 2 frames */
#define VIDEO_FRAME_DELAY 2
......@@ -237,15 +218,14 @@ RGB[0,8191],coef[-8192,8191] -> RGB[0,8191]
*/
#define NUM_VALID_TNR_REF_FRAMES (1) /* At least one valid TNR reference frame is required */
#define NUM_TNR_FRAMES_PER_REF_BUF_SET (2)
/* In luma-only mode alternate illuminated frames are supported, that requires two double buffers */
#define NUM_TNR_REF_BUF_SETS (1)
#define NUM_TNR_FRAMES (NUM_TNR_FRAMES_PER_REF_BUF_SET * NUM_TNR_REF_BUF_SETS)
#define MAX_NUM_DELAY_FRAMES MAX(MAX_NUM_VIDEO_DELAY_FRAMES, NUM_PREVIEW_DVS_FRAMES)
#define NUM_VIDEO_TNR_FRAMES 2
#endif
#define MAX_NUM_DELAY_FRAMES MAX(MAX_NUM_VIDEO_DELAY_FRAMES, NUM_PREVIEW_DVS_FRAMES)
/* Note that this is the define used to configure all data structures common for all modes */
/* It should be equal or bigger to the max number of DVS frames for all possible modes */
......@@ -272,7 +252,6 @@ RGB[0,8191],coef[-8192,8191] -> RGB[0,8191]
CEIL_MUL(_ISP_MORPH_TABLE_WIDTH(width), \
SH_CSS_MORPH_TABLE_ELEMS_PER_DDR_WORD)
#ifndef ISP2401
#define _ISP_SCTBL_WIDTH_PER_COLOR(input_width, deci_factor_log2) \
(ISP_BQ_GRID_WIDTH(input_width, deci_factor_log2) + 1)
#define _ISP_SCTBL_HEIGHT(input_height, deci_factor_log2) \
......@@ -281,7 +260,7 @@ RGB[0,8191],coef[-8192,8191] -> RGB[0,8191]
CEIL_MUL(_ISP_SCTBL_WIDTH_PER_COLOR(input_width, deci_factor_log2), \
ISP_VEC_NELEMS)
#endif
/* *****************************************************************
* Statistics for 3A (Auto Focus, Auto White Balance, Auto Exposure)
* *****************************************************************/
......
......@@ -285,11 +285,7 @@ struct sh_css_binary_args {
struct ia_css_frame *in_frame; /* input frame */
struct ia_css_frame
*delay_frames[MAX_NUM_VIDEO_DELAY_FRAMES]; /* reference input frame */
#ifndef ISP2401
struct ia_css_frame *tnr_frames[NUM_VIDEO_TNR_FRAMES]; /* tnr frames */
#else
struct ia_css_frame *tnr_frames[NUM_TNR_FRAMES]; /* tnr frames */
#endif
struct ia_css_frame
*out_frame[IA_CSS_BINARY_MAX_OUTPUT_PORTS]; /* output frame */
struct ia_css_frame *out_vf_frame; /* viewfinder output frame */
......
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