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

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
Loading
Loading
Loading
Loading
+21 −7
Original line number Diff line number Diff line
@@ -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);
+0 −4
Original line number Diff line number Diff line
@@ -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;
+2 −4
Original line number Diff line number Diff line
@@ -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 */
+1 −11
Original line number Diff line number Diff line
@@ -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;
+0 −8
Original line number Diff line number Diff line
@@ -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 */
Loading