media: atomisp: convert default struct values to use compound-literals with designated initializers.
Subsystems (4)
PATCH 1/1 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.
--- .../hive_isp_css_common/input_formatter_global.h | 16 --- .../pci/atomisp2/css2400/ia_css_frame_public.h | 29 ++---- .../atomisp/pci/atomisp2/css2400/ia_css_pipe.h | 113 ++++++++------------- .../pci/atomisp2/css2400/ia_css_pipe_public.h | 108 +++----------------- .../atomisp/pci/atomisp2/css2400/ia_css_types.h | 64 +++--------- .../isp/kernels/s3a/s3a_1.0/ia_css_s3a_types.h | 50 +-------- .../kernels/sdis/common/ia_css_sdis_common_types.h | 31 ++---- .../isp/kernels/sdis/sdis_1.0/ia_css_sdis.host.c | 3 +- .../runtime/binary/interface/ia_css_binary.h | 88 ++-------------- .../atomisp2/css2400/runtime/binary/src/binary.c | 3 +- .../isp_param/interface/ia_css_isp_param_types.h | 10 -- .../runtime/pipeline/interface/ia_css_pipeline.h | 24 ++--- .../css2400/runtime/pipeline/src/pipeline.c | 7 +- .../media/atomisp/pci/atomisp2/css2400/sh_css.c | 31 ++---- .../atomisp/pci/atomisp2/css2400/sh_css_legacy.h | 11 -- .../atomisp/pci/atomisp2/css2400/sh_css_metrics.h | 21 ---- 16 files changed, 116 insertions(+), 493 deletions(-)
drivers/staging/media/atomisp/pci/atomisp2/css2400/hive_isp_css_common/input_formatter_global.h +0 -16
@@ -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 ];
drivers/staging/media/atomisp/pci/atomisp2/css2400/ia_css_frame_public.h +8 -21
@@ -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
drivers/staging/media/atomisp/pci/atomisp2/css2400/ia_css_pipe.h +40 -73
149 lines not on this page · raw message
drivers/staging/media/atomisp/pci/atomisp2/css2400/ia_css_pipe_public.h +14 -94
129 lines not on this page · raw message
drivers/staging/media/atomisp/pci/atomisp2/css2400/ia_css_types.h +13 -51
88 lines not on this page · raw message
drivers/staging/media/atomisp/pci/atomisp2/css2400/isp/kernels/s3a/s3a_1.0/ia_css_s3a_types.h +2 -48
68 lines not on this page · raw message
drivers/staging/media/atomisp/pci/atomisp2/css2400/isp/kernels/sdis/common/ia_css_sdis_common_types.h +9 -22
@@ -41,20 +41,6 @@ struct ia_css_sdis_info {uint32_t deci_factor_log2; }; -#define IA_CSS_DEFAULT_SDIS_INFO \ - { \ - { { 0, 0 },/* dim */ \ - { 0, 0 }, /* pad */ \ - }, /* grid */ \ - { { 0, 0 }, /* dim */ \ - { 0, 0 }, /* pad */ \ - }, /* coef */ \ - { { 0, 0 }, /* dim */ \ - { 0, 0 }, /* pad */ \ - }, /* proj */ \ - 0, /* dis_deci_factor_log2 */ \ - } -/* DVS statistics grid * * ISP block: SDVS1 (DIS/DVS Support for DIS/DVS ver.1 (2-axes))
@@ -209,16 +195,17 @@ struct ia_css_dvs_stat_grid_info {/* DVS statistics generated by accelerator default grid info */ -#define DEFAULT_DVS_GRID_INFO { \ -{ \ - { 0, 0, 0},/* GBL CFG reg: kappa, match_shifrt, binning mode*/ \ - {{{0, 0, 0, 0}, {0, 0, 0}, {0, 0} }, \ - {{0, 0, 0, 0}, {0, 0, 0}, {0, 0} }, \ - {{0, 0, 0, 0}, {0, 0, 0}, {0, 0} } }, \ - {{0, 0, 0, 0}, {4, 0, 0, 0}, {0, 0, 0, 0} } } \ +#define DEFAULT_DVS_GRID_INFO \ +(union ia_css_dvs_grid_u) { \ + .dvs_stat_grid_info = (struct ia_css_dvs_stat_grid_info) { \ + .fe_roi_cfg = { \ + [1] = (struct dvs_stat_public_dvs_level_fe_roi_cfg) { \ + .x_start = 4 \ + } \ + } \ + } \ } -/* Union that holds all types of DVS statistics grid info in * CSS format * */
drivers/staging/media/atomisp/pci/atomisp2/css2400/isp/kernels/sdis/sdis_1.0/ia_css_sdis.host.c +1 -2
@@ -169,8 +169,7 @@ ia_css_sdis_init_info( unsigned enabled) {if (!enabled) { -struct ia_css_sdis_info default_dis =IA_CSS_DEFAULT_SDIS_INFO ; - *dis = default_dis; + *dis = (struct ia_css_sdis_info ) { };return ; }
drivers/staging/media/atomisp/pci/atomisp2/css2400/runtime/binary/interface/ia_css_binary.h +6 -82
103 lines not on this page · raw message
drivers/staging/media/atomisp/pci/atomisp2/css2400/runtime/binary/src/binary.c +1 -2
@@ -490,7 +490,6 @@ ia_css_binary_get_shading_info_type_1(const struct ia_css_binary *binary, /* [instruct sh_css_shading_table_bayer_origin_compute_results res;#else struct sh_css_binary_sc_requirements scr; -struct ia_css_shading_info default_shading_info_type_1 =DEFAULT_SHADING_INFO_TYPE_1 ;#endif #ifndef ISP2401
@@ -542,7 +541,7 @@ ia_css_binary_get_shading_info_type_1(const struct ia_css_binary *binary, /* [in &res);if (err !=IA_CSS_SUCCESS ) #else - *shading_info = default_shading_info_type_1; + *shading_info =DEFAULT_SHADING_INFO_TYPE_1 ; err =sh_css_binary_get_sc_requirements (binary, required_bds_factor, stream_config, &scr);if (err !=IA_CSS_SUCCESS ) {
drivers/staging/media/atomisp/pci/atomisp2/css2400/runtime/isp_param/interface/ia_css_isp_param_types.h +0 -10
@@ -94,14 +94,4 @@ union ia_css_all_memory_offsets { } array[IA_CSS_NUM_PARAM_CLASSES]; }; -#define IA_CSS_DEFAULT_ISP_MEM_PARAMS \ - { { { { 0, 0 } } } } - -#define IA_CSS_DEFAULT_ISP_CSS_PARAMS \ - { { { { 0, 0 } } } } - -#define IA_CSS_DEFAULT_ISP_ISP_PARAMS \ - { { { { 0, 0 } } } } -#endif /* _IA_CSS_ISP_PARAM_TYPES_H_ */ -
drivers/staging/media/atomisp/pci/atomisp2/css2400/runtime/pipeline/interface/ia_css_pipeline.h +9 -15
@@ -74,21 +74,15 @@ struct ia_css_pipeline { };#define DEFAULT_PIPELINE \ -{ \ - IA_CSS_PIPE_ID_PREVIEW,/* pipe_id */ \ -0 ,/* pipe_num */ \ - false,/* stop_requested */ \ -NULL ,/* stages */ \ -NULL ,/* current_stage */ \ -0 ,/* num_stages */ \ -DEFAULT_FRAME ,/* in_frame */ \ - {DEFAULT_FRAME}, /* out_frame */ \ - {DEFAULT_FRAME}, /* vf_frame */ \ -IA_CSS_FRAME_DELAY_1 ,/* frame_delay */ \ -0 ,/* inout_port_config */ \ --1 ,/* num_execs */ \ - true,/* acquire_isp_each_stage */ \ -QOS_INVALID /* pipe_qos_config */ \ +(struct ia_css_pipeline) { \ + .pipe_id = IA_CSS_PIPE_ID_PREVIEW, \ + .in_frame = DEFAULT_FRAME, \ + .out_frame = {DEFAULT_FRAME}, \ + .vf_frame = {DEFAULT_FRAME}, \ + .dvs_frame_delay = IA_CSS_FRAME_DELAY_1, \ + .num_execs = -1, \ + .acquire_isp_each_stage = true, \ + .pipe_qos_config = QOS_INVALID \ }/* Stage descriptor used to create a new stage in the pipeline */
drivers/staging/media/atomisp/pci/atomisp2/css2400/runtime/pipeline/src/pipeline.c +3 -4
@@ -692,17 +692,16 @@ static void pipeline_init_defaults(unsigned int pipe_num, unsigned int dvs_frame_delay) { - struct ia_css_frame init_frame = DEFAULT_FRAME; unsigned int i; pipeline->pipe_id = pipe_id; pipeline->stages =NULL ; pipeline->stop_requested = false; pipeline->current_stage =NULL ; - pipeline->in_frame = init_frame; + pipeline->in_frame =DEFAULT_FRAME ;for (i =0 ; i <IA_CSS_PIPE_MAX_OUTPUT_STAGE ; i++) { - pipeline->out_frame[i] = init_frame; - pipeline->vf_frame[i] = init_frame; + pipeline->out_frame[i] =DEFAULT_FRAME ; + pipeline->vf_frame[i] =DEFAULT_FRAME ; } pipeline->num_execs =-1 ; pipeline->acquire_isp_each_stage = true;
drivers/staging/media/atomisp/pci/atomisp2/css2400/sh_css.c +10 -21
@@ -112,8 +112,6 @@ static int thread_alive;#define STATS_ENABLED (stage) (stage && stage->binary && stage->binary->info && \ (stage->binary->info->sp.enable.s3a || stage->binary->info->sp.enable.dis)) -#define DEFAULT_PLANES { {0, 0, 0, 0} } -struct sh_css my_css;int (*sh_css_printf) (const char *fmt,va_list args) =NULL ;
@@ -2291,25 +2289,19 @@ init_pipe_defaults(enum ia_css_pipe_mode mode, struct ia_css_pipe *pipe, bool copy_pipe) { -static struct ia_css_pipe default_pipe =IA_CSS_DEFAULT_PIPE ; -static struct ia_css_preview_settings prev =IA_CSS_DEFAULT_PREVIEW_SETTINGS ; -static struct ia_css_capture_settings capt =IA_CSS_DEFAULT_CAPTURE_SETTINGS ; -static struct ia_css_video_settings video =IA_CSS_DEFAULT_VIDEO_SETTINGS ; -static struct ia_css_yuvpp_settings yuvpp =IA_CSS_DEFAULT_YUVPP_SETTINGS ; -if (pipe ==NULL ) {IA_CSS_ERROR ("NULL pipe parameter" );return IA_CSS_ERR_INVALID_ARGUMENTS ; }/* Initialize pipe to pre-defined defaults */ - *pipe = default_pipe; + *pipe =IA_CSS_DEFAULT_PIPE ;/* TODO: JB should not be needed, but temporary backward reference */ switch (mode) {case IA_CSS_PIPE_MODE_PREVIEW : pipe->mode =IA_CSS_PIPE_ID_PREVIEW ; - pipe->pipe_settings.preview = prev; + pipe->pipe_settings.preview =IA_CSS_DEFAULT_PREVIEW_SETTINGS ;break ;case IA_CSS_PIPE_MODE_CAPTURE :if (copy_pipe) {
@@ -2317,11 +2309,11 @@ init_pipe_defaults(enum ia_css_pipe_mode mode, }else { pipe->mode =IA_CSS_PIPE_ID_CAPTURE ; } - pipe->pipe_settings.capture = capt; + pipe->pipe_settings.capture =IA_CSS_DEFAULT_CAPTURE_SETTINGS ;break ;case IA_CSS_PIPE_MODE_VIDEO : pipe->mode =IA_CSS_PIPE_ID_VIDEO ; - pipe->pipe_settings.video = video; + pipe->pipe_settings.video =IA_CSS_DEFAULT_VIDEO_SETTINGS ;break ;case IA_CSS_PIPE_MODE_ACC : pipe->mode =IA_CSS_PIPE_ID_ACC ;
@@ -2331,7 +2323,7 @@ init_pipe_defaults(enum ia_css_pipe_mode mode,break ;case IA_CSS_PIPE_MODE_YUVPP : pipe->mode =IA_CSS_PIPE_ID_YUVPP ; - pipe->pipe_settings.yuvpp = yuvpp; + pipe->pipe_settings.yuvpp =IA_CSS_DEFAULT_YUVPP_SETTINGS ;break ;default :return IA_CSS_ERR_INVALID_ARGUMENTS ;
@@ -5588,8 +5580,7 @@ static enum ia_css_err load_video_binaries(struct ia_css_pipe *pipe)/* we build up the pipeline starting at the end */ /* YUV post-processing if needed */ if (need_scaler) { -struct ia_css_cas_binary_descr cas_scaler_descr - =IA_CSS_DEFAULT_CAS_BINARY_DESCR ; +struct ia_css_cas_binary_descr cas_scaler_descr = { };/* NV12 is the common format that is supported by both */ /* yuv_scaler and the video_xx_isp2_min binaries. */
@@ -6244,8 +6235,8 @@ static enum ia_css_err load_primary_binaries( pipe_out_info->res);if (need_extra_yuv_scaler) { -struct ia_css_cas_binary_descr cas_scaler_descr - =IA_CSS_DEFAULT_CAS_BINARY_DESCR ; +struct ia_css_cas_binary_descr cas_scaler_descr = { }; + err = ia_css_pipe_create_cas_scaler_desc_single_output( &capt_pp_out_info, pipe_out_info,
@@ -7232,7 +7223,7 @@ load_yuvpp_binaries(struct ia_css_pipe *pipe)struct ia_css_frame_info *vf_pp_in_info[IA_CSS_PIPE_MAX_OUTPUT_STAGE ];struct ia_css_yuvpp_settings *mycs;struct ia_css_binary *next_binary; -struct ia_css_cas_binary_descr cas_scaler_descr =IA_CSS_DEFAULT_CAS_BINARY_DESCR ; +struct ia_css_cas_binary_descr cas_scaler_descr = { };unsigned int i, j;bool need_isp_copy_binary = false;
@@ -8827,10 +8818,8 @@ sh_css_init_host_sp_control_vars(void)*/ void ia_css_pipe_config_defaults (struct ia_css_pipe_config *pipe_config) { -struct ia_css_pipe_config def_config =DEFAULT_PIPE_CONFIG ; -ia_css_debug_dtrace (IA_CSS_DEBUG_TRACE ,"ia_css_pipe_config_defaults()\n" ); - *pipe_config = def_config; + *pipe_config =DEFAULT_PIPE_CONFIG ; }void
drivers/staging/media/atomisp/pci/atomisp2/css2400/sh_css_legacy.h +0 -11
@@ -52,17 +52,6 @@ struct ia_css_pipe_extra_config {bool disable_vf_pp; }; -#define DEFAULT_PIPE_EXTRA_CONFIG \ -{ \ - false,/* enable_raw_binning */ \ - false,/* enable_yuv_ds */ \ - false,/* enable_high_speed */ \ - false,/* enable_dvs_6axis */ \ - false,/* enable_reduced_pipe */ \ - false,/* enable_fractional_ds */ \ - false,/* disable_vf_pp */ \ -} - enum ia_css_err ia_css_pipe_create_extra(const struct ia_css_pipe_config *config, const struct ia_css_pipe_extra_config *extra_config,
drivers/staging/media/atomisp/pci/atomisp2/css2400/sh_css_metrics.h +0 -21
@@ -24,16 +24,6 @@ struct sh_css_pc_histogram {unsigned *msink; }; -#if !defined(__USE_DESIGNATED_INITIALISERS__) -#define DEFAULT_PC_HISTOGRAM \ -{ \ - 0, \ - NULL, \ - NULL, \ - NULL \ -} -#endif -struct sh_css_binary_metrics {unsigned mode;unsigned id;
@@ -42,17 +32,6 @@ struct sh_css_binary_metrics {struct sh_css_binary_metrics *next; }; -#if !defined(__USE_DESIGNATED_INITIALISERS__) -#define DEFAULT_BINARY_METRICS \ -{ \ - 0, \ - 0, \ - DEFAULT_PC_HISTOGRAM, \ - DEFAULT_PC_HISTOGRAM, \ - NULL \ -} -#endif -struct ia_css_frame_metrics {unsigned num_frames; };
base-commit: ae49432810c5cca2143afc1445edad6582c9f270
Signature · 1 line
2.15.1
Hi Jeremy,
drivers/staging/media/atomisp/pci/atomisp2/css2400/runtime/isp_param/interface/ia_css_isp_param_types.h union ia_css_all_memory_offsets { · line 98
Quoted 10 lines · Jeremy Sowden
drivers/staging/media/atomisp/pci/atomisp2/css2400/runtime/isp_param/interface/ia_css_isp_param_types.h +0
-2@@ -94,14 +94,4 @@ union ia_css_all_memory_offsets { } array[IA_CSS_NUM_PARAM_CLASSES ]; }; -#define IA_CSS_DEFAULT_ISP_MEM_PARAMS \ - { { { { 0, 0 } } } }
There was a minor conflict here, another patch had changed the first 0 to NULL. The lines were removed so that was trivial to resolve. The patch is now applied in my atomisp branch.
Signature · 2 lines
Sakari Ailus e-mail: [email protected]