Commit 6dc9a256 authored by Jeremy Sowden's avatar Jeremy Sowden Committed by Mauro Carvalho Chehab
Browse files

media: atomisp: convert default struct values to use compound-literals with designated initializers



The CSS API uses a lot of nested anonymous structs defined in object
macros to assign default values to its data-structures.  These have been
changed to use compound-literals and designated initializers to make
them more comprehensible and less fragile.

The compound-literals can also be used in assignment, which means we can
get rid of some temporary variables whose only purpose is to be
initialized by one of these anonymous structs and then serve as the
rvalue in an assignment expression.

A lot of the members of the default struct values used by the CSS API
were explicitly initialized to zero values.  Designated initializers
have allowed these members, and in some case whole default struct
values, to be removed.

Signed-off-by: default avatarJeremy Sowden <jeremy@azazel.net>
Signed-off-by: default avatarSakari Ailus <sakari.ailus@linux.intel.com>
Signed-off-by: default avatarMauro Carvalho Chehab <mchehab@s-opensource.com>
parent d82a4a14
Loading
Loading
Loading
Loading
+0 −16
Original line number Diff line number Diff line
@@ -107,22 +107,6 @@ struct input_formatter_cfg_s {
	uint32_t	block_no_reqs;
};

#define DEFAULT_IF_CONFIG \
{ \
	0,          /* start_line */\
	0,          /* start_column */\
	0,          /* left_padding */\
	0,          /* cropped_height */\
	0,          /* cropped_width */\
	0,          /* deinterleaving */\
	0,          /*.buf_vecs */\
	0,          /* buf_start_index */\
	0,          /* buf_increment */\
	0,          /* buf_eol_offset */\
	false,      /* is_yuv420_format */\
	false       /* block_no_reqs */\
}

extern const hrt_address HIVE_IF_SRST_ADDRESS[N_INPUT_FORMATTER_ID];
extern const hrt_data HIVE_IF_SRST_MASK[N_INPUT_FORMATTER_ID];
extern const uint8_t HIVE_IF_SWITCH_CODE[N_INPUT_FORMATTER_ID];
+8 −21
Original line number Diff line number Diff line
@@ -121,15 +121,9 @@ struct ia_css_frame_info {
};

#define IA_CSS_BINARY_DEFAULT_FRAME_INFO \
{ \
	{0,                      /* width */ \
	 0},                     /* height */ \
	0,                       /* padded_width */ \
	IA_CSS_FRAME_FORMAT_NUM, /* format */ \
	0,                       /* raw_bit_depth */ \
	IA_CSS_BAYER_ORDER_NUM,  /* raw_bayer_order */ \
	{0,                       /*start col */ \
	 0},                       /*start line */ \
(struct ia_css_frame_info) { \
	.format			= IA_CSS_FRAME_FORMAT_NUM,  \
	.raw_bayer_order	= IA_CSS_BAYER_ORDER_NUM, \
}

/**
@@ -190,18 +184,11 @@ struct ia_css_frame {
};

#define DEFAULT_FRAME \
{ \
	IA_CSS_BINARY_DEFAULT_FRAME_INFO,	/* info */ \
	0,					/* data */ \
	0,					/* data_bytes */ \
	SH_CSS_INVALID_QUEUE_ID,		/* dynamic_data_index */ \
	IA_CSS_BUFFER_TYPE_INVALID,			/* buf_type */ \
	IA_CSS_FRAME_FLASH_STATE_NONE,		/* flash_state */ \
	0,					/* exp_id */ \
	0,					/* isp_config_id */ \
	false,					/* valid */ \
	false,					/* contiguous  */ \
	{ 0 }					/* planes */ \
(struct ia_css_frame) { \
	.info			= IA_CSS_BINARY_DEFAULT_FRAME_INFO, \
	.dynamic_queue_id	= SH_CSS_INVALID_QUEUE_ID, \
	.buf_type		= IA_CSS_BUFFER_TYPE_INVALID, \
	.flash_state		= IA_CSS_FRAME_FLASH_STATE_NONE, \
}

/* @brief Fill a frame with zeros
+40 −73
Original line number Diff line number Diff line
@@ -40,15 +40,10 @@ struct ia_css_preview_settings {
};

#define IA_CSS_DEFAULT_PREVIEW_SETTINGS \
{ \
	IA_CSS_BINARY_DEFAULT_SETTINGS,	/* copy_binary */\
	IA_CSS_BINARY_DEFAULT_SETTINGS,	/* preview_binary */\
	IA_CSS_BINARY_DEFAULT_SETTINGS,	/* vf_pp_binary */\
	{ NULL },			/* dvs_frames */ \
	{ NULL },			/* tnr_frames */ \
	NULL,				/* copy_pipe */\
	NULL,				/* capture_pipe */\
	NULL,				/* acc_pipe */\
(struct ia_css_preview_settings) { \
	.copy_binary	= IA_CSS_BINARY_DEFAULT_SETTINGS, \
	.preview_binary	= IA_CSS_BINARY_DEFAULT_SETTINGS, \
	.vf_pp_binary	= IA_CSS_BINARY_DEFAULT_SETTINGS, \
}

struct ia_css_capture_settings {
@@ -70,20 +65,15 @@ struct ia_css_capture_settings {
};

#define IA_CSS_DEFAULT_CAPTURE_SETTINGS \
{ \
	IA_CSS_BINARY_DEFAULT_SETTINGS,	/* copy_binary */\
	{IA_CSS_BINARY_DEFAULT_SETTINGS},	/* primary_binary */\
	0,				/* num_primary_stage */\
	IA_CSS_BINARY_DEFAULT_SETTINGS,	/* pre_isp_binary */\
	IA_CSS_BINARY_DEFAULT_SETTINGS,	/* anr_gdc_binary */\
	IA_CSS_BINARY_DEFAULT_SETTINGS,	/* post_isp_binary */\
	IA_CSS_BINARY_DEFAULT_SETTINGS,	/* capture_pp_binary */\
	IA_CSS_BINARY_DEFAULT_SETTINGS,	/* vf_pp_binary */\
	IA_CSS_BINARY_DEFAULT_SETTINGS,	/* capture_ldc_binary */\
	NULL,				/* yuv_scaler_binary */ \
	{ NULL },			/* delay_frames[ref_frames] */ \
	NULL,				/* is_output_stage */ \
	0,				/* num_yuv_scaler */ \
(struct ia_css_capture_settings) { \
	.copy_binary		= IA_CSS_BINARY_DEFAULT_SETTINGS, \
	.primary_binary		= {IA_CSS_BINARY_DEFAULT_SETTINGS}, \
	.pre_isp_binary		= IA_CSS_BINARY_DEFAULT_SETTINGS, \
	.anr_gdc_binary		= IA_CSS_BINARY_DEFAULT_SETTINGS, \
	.post_isp_binary	= IA_CSS_BINARY_DEFAULT_SETTINGS, \
	.capture_pp_binary	= IA_CSS_BINARY_DEFAULT_SETTINGS, \
	.vf_pp_binary		= IA_CSS_BINARY_DEFAULT_SETTINGS, \
	.capture_ldc_binary	= IA_CSS_BINARY_DEFAULT_SETTINGS, \
}

struct ia_css_video_settings {
@@ -105,18 +95,10 @@ struct ia_css_video_settings {
};

#define IA_CSS_DEFAULT_VIDEO_SETTINGS \
{ \
	IA_CSS_BINARY_DEFAULT_SETTINGS,	/* copy_binary */ \
	IA_CSS_BINARY_DEFAULT_SETTINGS,	/* video_binary */ \
	IA_CSS_BINARY_DEFAULT_SETTINGS,	/* vf_pp_binary */ \
	NULL,				/* yuv_scaler_binary */ \
	{ NULL },			/* delay_frames */ \
	{ NULL },			/* tnr_frames */ \
	NULL,				/* vf_pp_in_frame */ \
	NULL,				/* copy_pipe */ \
	NULL,				/* capture_pipe */ \
	NULL,				/* is_output_stage */ \
	0,				/* num_yuv_scaler */ \
(struct ia_css_video_settings) { \
	.copy_binary	= IA_CSS_BINARY_DEFAULT_SETTINGS, \
	.video_binary	= IA_CSS_BINARY_DEFAULT_SETTINGS, \
	.vf_pp_binary	= IA_CSS_BINARY_DEFAULT_SETTINGS, \
}

struct ia_css_yuvpp_settings {
@@ -130,14 +112,8 @@ struct ia_css_yuvpp_settings {
};

#define IA_CSS_DEFAULT_YUVPP_SETTINGS \
{ \
	IA_CSS_BINARY_DEFAULT_SETTINGS,		/* copy_binary */ \
	NULL,					/* yuv_scaler_binary */ \
	NULL,					/* vf_pp_binary */ \
	NULL,					/* is_output_stage */ \
	0,					/* num_yuv_scaler */ \
	0,					/* num_vf_pp */ \
	0,					/* num_output */ \
(struct ia_css_yuvpp_settings) { \
	.copy_binary	= IA_CSS_BINARY_DEFAULT_SETTINGS, \
}

struct osys_object;
@@ -185,35 +161,26 @@ struct ia_css_pipe {
};

#define IA_CSS_DEFAULT_PIPE \
{ \
	false,					/* stop_requested */ \
	DEFAULT_PIPE_CONFIG,			/* config */ \
	DEFAULT_PIPE_EXTRA_CONFIG,		/* extra_config */ \
	DEFAULT_PIPE_INFO,			/* info */ \
	IA_CSS_PIPE_ID_ACC,			/* mode (pipe_id) */ \
	NULL,					/* shading_table */ \
	DEFAULT_PIPELINE,			/* pipeline */ \
	{IA_CSS_BINARY_DEFAULT_FRAME_INFO},	/* output_info */ \
	IA_CSS_BINARY_DEFAULT_FRAME_INFO,	/* bds_output_info */ \
	{IA_CSS_BINARY_DEFAULT_FRAME_INFO},	/* vf_output_info */ \
	IA_CSS_BINARY_DEFAULT_FRAME_INFO,	/* out_yuv_ds_input_info */ \
	IA_CSS_BINARY_DEFAULT_FRAME_INFO,	/* vf_yuv_ds_input_info */ \
	NULL,					/* output_stage */ \
	NULL,					/* vf_stage */ \
	SH_CSS_BDS_FACTOR_1_00,			/* required_bds_factor */ \
	1,					/* dvs_frame_delay */ \
	0,					/* num_invalid_frames */ \
	{true},					/* enable_viewfinder */ \
	NULL,					/* stream */ \
	DEFAULT_FRAME,				/* in_frame_struct */ \
	DEFAULT_FRAME,				/* out_frame_struct */ \
	DEFAULT_FRAME,				/* vf_frame_struct */ \
	{ NULL },				/* continuous_frames */ \
	{ NULL },				/* cont_md_buffers */ \
	{ IA_CSS_DEFAULT_PREVIEW_SETTINGS },	/* pipe_settings */ \
	0,					/* scaler_pp_lut */ \
	NULL,					/* osys object */ \
	PIPE_ENTRY_EMPTY_TOKEN,			/* pipe_num */\
(struct ia_css_pipe) { \
	.config			= DEFAULT_PIPE_CONFIG, \
	.info			= DEFAULT_PIPE_INFO, \
	.mode			= IA_CSS_PIPE_ID_ACC, /* (pipe_id) */ \
	.pipeline		= DEFAULT_PIPELINE, \
	.output_info		= {IA_CSS_BINARY_DEFAULT_FRAME_INFO}, \
	.bds_output_info	= IA_CSS_BINARY_DEFAULT_FRAME_INFO, \
	.vf_output_info		= {IA_CSS_BINARY_DEFAULT_FRAME_INFO}, \
	.out_yuv_ds_input_info	= IA_CSS_BINARY_DEFAULT_FRAME_INFO, \
	.vf_yuv_ds_input_info	= IA_CSS_BINARY_DEFAULT_FRAME_INFO, \
	.required_bds_factor	= SH_CSS_BDS_FACTOR_1_00, \
	.dvs_frame_delay	= 1, \
	.enable_viewfinder	= {true}, \
	.in_frame_struct	= DEFAULT_FRAME, \
	.out_frame_struct	= DEFAULT_FRAME, \
	.vf_frame_struct	= DEFAULT_FRAME, \
	.pipe_settings		= { \
		.preview = IA_CSS_DEFAULT_PREVIEW_SETTINGS \
	}, \
	.pipe_num		= PIPE_ENTRY_EMPTY_TOKEN, \
}

void ia_css_pipe_map_queue(struct ia_css_pipe *pipe, bool map);
+14 −94
Original line number Diff line number Diff line
@@ -152,82 +152,20 @@ struct ia_css_pipe_config {
};


#ifdef ISP2401
/**
 * Default origin of internal frame positioned on shading table.
 */
#define IA_CSS_PIPE_DEFAULT_INTERNAL_FRAME_ORIGIN_BQS_ON_SCTBL \
{ \
	0,					/* x [bqs] */ \
	0					/* y [bqs] */ \
}

/**
 * Default settings for newly created pipe configurations.
 */
#define DEFAULT_PIPE_CONFIG \
{ \
	IA_CSS_PIPE_MODE_PREVIEW,		/* mode */ \
	1,					/* isp_pipe_version */ \
	{ 0, 0 },				/* pipe_effective_input_res */ \
	{ 0, 0 },				/* bayer_ds_out_res */ \
	{ 0, 0 },				/* vf_pp_in_res */ \
	{ 0, 0 },				/* capt_pp_in_res */ \
	{ 0, 0 },				/* output_system_in_res */ \
	{ 0, 0 },				/* dvs_crop_out_res */ \
	{IA_CSS_BINARY_DEFAULT_FRAME_INFO},	/* output_info */ \
	{IA_CSS_BINARY_DEFAULT_FRAME_INFO},	/* vf_output_info */ \
	NULL,					/* acc_extension */ \
	NULL,					/* acc_stages */ \
	0,					/* num_acc_stages */ \
	DEFAULT_CAPTURE_CONFIG,			/* default_capture_config */ \
	{ 0, 0 },				/* dvs_envelope */ \
	IA_CSS_FRAME_DELAY_1,			/* dvs_frame_delay */ \
	-1,					/* acc_num_execs */ \
	false,					/* enable_dz */ \
	false,					/* enable_dpc */ \
	false,					/* enable_vfpp_bci */ \
	false,					/* enable_luma_only */ \
	false,					/* enable_tnr */ \
	NULL,					/* p_isp_config */\
	{ 0, 0 },				/* gdc_in_buffer_res */ \
	{ 0, 0 },				/* gdc_in_buffer_offset */ \
	IA_CSS_PIPE_DEFAULT_INTERNAL_FRAME_ORIGIN_BQS_ON_SCTBL	/* internal_frame_origin_bqs_on_sctbl */ \
}

#else

/**
 * Default settings for newly created pipe configurations.
 */
#define DEFAULT_PIPE_CONFIG \
{ \
	IA_CSS_PIPE_MODE_PREVIEW,		/* mode */ \
	1,					/* isp_pipe_version */ \
	{ 0, 0 },				/* pipe_effective_input_res */ \
	{ 0, 0 },				/* bayer_ds_out_res */ \
	{ 0, 0 },				/* vf_pp_in_res */ \
	{ 0, 0 },				/* capt_pp_in_res */ \
	{ 0, 0 },				/* dvs_crop_out_res */ \
	{IA_CSS_BINARY_DEFAULT_FRAME_INFO},	/* output_info */ \
	{IA_CSS_BINARY_DEFAULT_FRAME_INFO},	/* vf_output_info */ \
	NULL,					/* acc_extension */ \
	NULL,					/* acc_stages */ \
	0,					/* num_acc_stages */ \
	DEFAULT_CAPTURE_CONFIG,			/* default_capture_config */ \
	{ 0, 0 },				/* dvs_envelope */ \
	IA_CSS_FRAME_DELAY_1,			/* dvs_frame_delay */ \
	-1,					/* acc_num_execs */ \
	false,					/* enable_dz */ \
	false,					/* enable_dpc */ \
	false,					/* enable_vfpp_bci */ \
	NULL,					/* p_isp_config */\
	{ 0, 0 },				/* gdc_in_buffer_res */ \
	{ 0, 0 }				/* gdc_in_buffer_offset */ \
(struct ia_css_pipe_config) { \
	.mode			= IA_CSS_PIPE_MODE_PREVIEW, \
	.isp_pipe_version	= 1, \
	.output_info		= {IA_CSS_BINARY_DEFAULT_FRAME_INFO}, \
	.vf_output_info		= {IA_CSS_BINARY_DEFAULT_FRAME_INFO}, \
	.default_capture_config	= DEFAULT_CAPTURE_CONFIG, \
	.dvs_frame_delay	= IA_CSS_FRAME_DELAY_1, \
	.acc_num_execs		= -1, \
}

#endif

/* Pipe info, this struct describes properties of a pipe after it's stream has
 * been created.
 * ~~~** DO NOT ADD NEW FIELD **~~~ This structure will be deprecated.
@@ -272,33 +210,15 @@ struct ia_css_pipe_info {
/**
 * Defaults for ia_css_pipe_info structs.
 */
#ifdef ISP2401

#define DEFAULT_PIPE_INFO \
{ \
	{IA_CSS_BINARY_DEFAULT_FRAME_INFO},	/* output_info */ \
	{IA_CSS_BINARY_DEFAULT_FRAME_INFO},	/* vf_output_info */ \
	IA_CSS_BINARY_DEFAULT_FRAME_INFO,	/* raw_output_info */ \
	{ 0, 0},				/* output system in res */ \
	DEFAULT_SHADING_INFO,			/* shading_info */ \
	DEFAULT_GRID_INFO,			/* grid_info */ \
	0					/* num_invalid_frames */ \
}

#else

#define DEFAULT_PIPE_INFO \
{ \
	{IA_CSS_BINARY_DEFAULT_FRAME_INFO},	/* output_info */ \
	{IA_CSS_BINARY_DEFAULT_FRAME_INFO},	/* vf_output_info */ \
	IA_CSS_BINARY_DEFAULT_FRAME_INFO,	/* raw_output_info */ \
	DEFAULT_SHADING_INFO,			/* shading_info */ \
	DEFAULT_GRID_INFO,			/* grid_info */ \
	0					/* num_invalid_frames */ \
(struct ia_css_pipe_info) { \
	.output_info		= {IA_CSS_BINARY_DEFAULT_FRAME_INFO}, \
	.vf_output_info		= {IA_CSS_BINARY_DEFAULT_FRAME_INFO}, \
	.raw_output_info	= IA_CSS_BINARY_DEFAULT_FRAME_INFO, \
	.shading_info		= DEFAULT_SHADING_INFO, \
	.grid_info		= DEFAULT_GRID_INFO, \
}

#endif

/* @brief Load default pipe configuration
 * @param[out]	pipe_config The pipe configuration.
 * @return	None
+13 −51
Original line number Diff line number Diff line
@@ -370,52 +370,20 @@ struct ia_css_shading_info {
	} info;
};

#ifndef ISP2401

/* Default Shading Correction information of Shading Correction Type 1. */
#define DEFAULT_SHADING_INFO_TYPE_1 \
{ \
	IA_CSS_SHADING_CORRECTION_TYPE_1,	/* type */ \
	{					/* info */ \
		{ \
			0,	/* enable */ \
			0,	/* num_hor_grids */ \
			0,	/* num_ver_grids */ \
			0,	/* bqs_per_grid_cell */ \
			1,	/* bayer_scale_hor_ratio_in */ \
			1,	/* bayer_scale_hor_ratio_out */ \
			1,	/* bayer_scale_ver_ratio_in */ \
			1,	/* bayer_scale_ver_ratio_out */ \
			0,	/* sc_bayer_origin_x_bqs_on_shading_table */ \
			0	/* sc_bayer_origin_y_bqs_on_shading_table */ \
		} \
	} \
}

#else

/* Default Shading Correction information of Shading Correction Type 1. */
#define DEFAULT_SHADING_INFO_TYPE_1 \
{ \
	IA_CSS_SHADING_CORRECTION_TYPE_1,	/* type */ \
	{					/* info */ \
		{ \
			0,			/* num_hor_grids */ \
			0,			/* num_ver_grids */ \
			0,			/* bqs_per_grid_cell */ \
			1,			/* bayer_scale_hor_ratio_in */ \
			1,			/* bayer_scale_hor_ratio_out */ \
			1,			/* bayer_scale_ver_ratio_in */ \
			1,			/* bayer_scale_ver_ratio_out */ \
			{0, 0},			/* isp_input_sensor_data_res_bqs */ \
			{0, 0},			/* sensor_data_res_bqs */ \
			{0, 0}			/* sensor_data_origin_bqs_on_sctbl */ \
(struct ia_css_shading_info) { \
	.type = IA_CSS_SHADING_CORRECTION_TYPE_1, \
	.info = { \
		.type_1 = { \
			.bayer_scale_hor_ratio_in	= 1, \
			.bayer_scale_hor_ratio_out	= 1, \
			.bayer_scale_ver_ratio_in	= 1, \
			.bayer_scale_ver_ratio_out	= 1, \
		} \
	} \
}

#endif

/* Default Shading Correction information. */
#define DEFAULT_SHADING_INFO	DEFAULT_SHADING_INFO_TYPE_1

@@ -438,12 +406,9 @@ struct ia_css_grid_info {

/* defaults for ia_css_grid_info structs */
#define DEFAULT_GRID_INFO \
{ \
	0,				/* isp_in_width */ \
	0,				/* isp_in_height */ \
	DEFAULT_3A_GRID_INFO,		/* s3a_grid */ \
	DEFAULT_DVS_GRID_INFO,		/* dvs_grid */ \
	IA_CSS_VAMEM_TYPE_1		/* vamem_type */ \
(struct ia_css_grid_info) { \
	.dvs_grid	= DEFAULT_DVS_GRID_INFO, \
	.vamem_type	= IA_CSS_VAMEM_TYPE_1 \
}

/* Morphing table, used for geometric distortion and chromatic abberration
@@ -534,11 +499,8 @@ struct ia_css_capture_config {

/* default settings for ia_css_capture_config structs */
#define DEFAULT_CAPTURE_CONFIG \
{ \
	IA_CSS_CAPTURE_MODE_PRIMARY,	/* mode (capture) */ \
	false,				/* enable_xnr */ \
	false,				/* enable_raw_output */ \
	false				/* enable_capture_pp_bli */ \
(struct ia_css_capture_config) { \
	.mode	= IA_CSS_CAPTURE_MODE_PRIMARY, \
}


Loading