media: atomisp: Replace macros from math_support.h
Subsystems (4)
PATCH 1/1 media: atomisp: Replace macros from math_support.h
Replace rarely used macros by generic ones from Linux kernel headers.
Signed-off-by Andy Shevchenko <[email protected]>
---
Please, apply only after tests that confirm everything is working as expected.
.../media/atomisp/pci/atomisp_compat_css20.c | 15 ++++---- .../kernels/anr/anr_1.0/ia_css_anr_types.h | 4 ++- .../pci/isp/kernels/dpc2/ia_css_dpc2_param.h | 6 ++-- .../isp/kernels/dvs/dvs_1.0/ia_css_dvs.host.c | 4 +-- .../isp/kernels/eed1_8/ia_css_eed1_8_param.h | 22 ++++++------ .../isp/kernels/fpn/fpn_1.0/ia_css_fpn.host.c | 6 ++-- .../isp/kernels/sc/sc_1.0/ia_css_sc_param.h | 2 +- .../pci/isp/modes/interface/input_buf.isp.h | 5 ++- .../pci/isp/modes/interface/isp_const.h | 32 +++++++++-------- .../pci/runtime/debug/src/ia_css_debug.c | 1 - .../atomisp/pci/runtime/frame/src/frame.c | 34 +++++++++---------- .../atomisp/pci/runtime/ifmtr/src/ifmtr.c | 11 +++--- .../pci/runtime/isys/src/virtual_isys.c | 2 +- drivers/staging/media/atomisp/pci/sh_css.c | 10 +++--- .../staging/media/atomisp/pci/sh_css_defs.h | 12 +++---- .../media/atomisp/pci/sh_css_internal.h | 8 ++--- .../media/atomisp/pci/sh_css_param_dvs.h | 19 ++++++----- .../media/atomisp/pci/sh_css_param_shading.c | 4 +-- .../staging/media/atomisp/pci/sh_css_params.c | 12 +++---- 19 files changed, 110 insertions(+), 99 deletions(-)
drivers/staging/media/atomisp/pci/atomisp_compat_css20.c +6 -9
@@ -12,10 +12,12 @@* but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. -* -* */ +#include <linux/io.h> +#include <linux/math.h> +#include <linux/pm_runtime.h> +#include <media/v4l2-dev.h> #include <media/v4l2-event.h>
@@ -36,9 +38,6 @@#include "sh_css_hrt.h" #include "ia_css_isys.h" -#include <linux/io.h> -#include <linux/pm_runtime.h> -/* Assume max number of ACC stages */ #define MAX_ACC_STAGES 20
@@ -1939,10 +1938,8 @@ static void __configure_capture_pp_input(struct atomisp_sub_device *asd, height * 9 / 10 < pipe_configs->output_info[0].res.height)return ;/* here just copy the calculation in css */ - hor_ds_factor =CEIL_DIV (width >>1 , - pipe_configs->output_info[0 ].res.width); - ver_ds_factor =CEIL_DIV (height >>1 , - pipe_configs->output_info[0 ].res.height); + hor_ds_factor =DIV_ROUND_UP (width >>1 , pipe_configs->output_info[0 ].res.width); + ver_ds_factor =DIV_ROUND_UP (height >>1 , pipe_configs->output_info[0 ].res.height); if ((asd->isp->media_dev.hw_revision < (ATOMISP_HW_REVISION_ISP2401 << ATOMISP_HW_REVISION_SHIFT) ||
drivers/staging/media/atomisp/pci/isp/kernels/anr/anr_1.0/ia_css_anr_types.h +3 -1
@@ -20,9 +20,11 @@* CSS-API header file for Advanced Noise Reduction kernel v1 */ +#include <linux/math.h> +/* Application specific DMA settings */ #define ANR_BPP 10 -#define ANR_ELEMENT_BITS ((CEIL_DIV(ANR_BPP, 8)) * 8) +#define ANR_ELEMENT_BITS round_up(ANR_BPP, 8)/* Advanced Noise Reduction configuration. * This is also known as Low-Light.
drivers/staging/media/atomisp/pci/isp/kernels/dpc2/ia_css_dpc2_param.h +4 -2
@@ -16,6 +16,8 @@#ifndef __IA_CSS_DPC2_PARAM_H#define __IA_CSS_DPC2_PARAM_H +#include <linux/math.h> +#include "type_support.h" #include "vmem.h" /* for VMEM_ARRAY*/
@@ -28,12 +30,12 @@/* 3 lines state per color plane input_line_state */ #define DPC2_STATE_INPUT_BUFFER_HEIGHT (3 * NUM_PLANES)/* Each plane has width equal to half frame line */ -#define DPC2_STATE_INPUT_BUFFER_WIDTH CEIL_DIV(MAX_FRAME_SIMDWIDTH, 2) +#define DPC2_STATE_INPUT_BUFFER_WIDTH DIV_ROUND_UP(MAX_FRAME_SIMDWIDTH, 2)/* 1 line state per color plane for local deviation state*/ #define DPC2_STATE_LOCAL_DEVIATION_BUFFER_HEIGHT (1 * NUM_PLANES)/* Each plane has width equal to half frame line */ -#define DPC2_STATE_LOCAL_DEVIATION_BUFFER_WIDTH CEIL_DIV(MAX_FRAME_SIMDWIDTH, 2) +#define DPC2_STATE_LOCAL_DEVIATION_BUFFER_WIDTH DIV_ROUND_UP(MAX_FRAME_SIMDWIDTH, 2)/* MINMAX state buffer stores 1 full input line (GR-R color line) */ #define DPC2_STATE_SECOND_MINMAX_BUFFER_HEIGHT 1
drivers/staging/media/atomisp/pci/isp/kernels/dvs/dvs_1.0/ia_css_dvs.host.c +2 -2
@@ -150,10 +150,10 @@ convert_coords_to_ispparams(/* similar to topleft_y calculation, but round up if ymax * has any fraction bits */ - bottom_y =CEIL_DIV (ymax,1 <<DVS_COORD_FRAC_BITS ); + bottom_y =DIV_ROUND_UP (ymax,BIT (DVS_COORD_FRAC_BITS )); s.in_block_height = bottom_y - topleft_y + dvs_interp_envelope; - bottom_x =CEIL_DIV (xmax,1 <<DVS_COORD_FRAC_BITS ); + bottom_x =DIV_ROUND_UP (xmax,BIT (DVS_COORD_FRAC_BITS )); s.in_block_width = bottom_x - topleft_x + dvs_interp_envelope; topleft_x_frac = topleft_x << (DVS_COORD_FRAC_BITS );
drivers/staging/media/atomisp/pci/isp/kernels/eed1_8/ia_css_eed1_8_param.h +12 -10
@@ -16,6 +16,8 @@#ifndef __IA_CSS_EED1_8_PARAM_H#define __IA_CSS_EED1_8_PARAM_H +#include <linux/math.h> +#include "type_support.h" #include "vmem.h" /* needed for VMEM_ARRAY */
@@ -44,35 +46,35 @@#define EED1_8_STATE_INPUT_BUFFER_HEIGHT (5 * NUM_PLANES)/* Each plane has width equal to half frame line */ -#define EED1_8_STATE_INPUT_BUFFER_WIDTH CEIL_DIV(MAX_FRAME_SIMDWIDTH, 2) +#define EED1_8_STATE_INPUT_BUFFER_WIDTH DIV_ROUND_UP(MAX_FRAME_SIMDWIDTH, 2)/* 1 line state per color plane LD_H state */ #define EED1_8_STATE_LD_H_HEIGHT (1 * NUM_PLANES) -#define EED1_8_STATE_LD_H_WIDTH CEIL_DIV(MAX_FRAME_SIMDWIDTH, 2) +#define EED1_8_STATE_LD_H_WIDTH DIV_ROUND_UP(MAX_FRAME_SIMDWIDTH, 2)/* 1 line state per color plane LD_V state */ #define EED1_8_STATE_LD_V_HEIGHT (1 * NUM_PLANES) -#define EED1_8_STATE_LD_V_WIDTH CEIL_DIV(MAX_FRAME_SIMDWIDTH, 2) +#define EED1_8_STATE_LD_V_WIDTH DIV_ROUND_UP(MAX_FRAME_SIMDWIDTH, 2)/* 1 line (single plane) state for D_Hr state */ #define EED1_8_STATE_D_HR_HEIGHT 1 -#define EED1_8_STATE_D_HR_WIDTH CEIL_DIV(MAX_FRAME_SIMDWIDTH, 2) +#define EED1_8_STATE_D_HR_WIDTH DIV_ROUND_UP(MAX_FRAME_SIMDWIDTH, 2)/* 1 line (single plane) state for D_Hb state */ #define EED1_8_STATE_D_HB_HEIGHT 1 -#define EED1_8_STATE_D_HB_WIDTH CEIL_DIV(MAX_FRAME_SIMDWIDTH, 2) +#define EED1_8_STATE_D_HB_WIDTH DIV_ROUND_UP(MAX_FRAME_SIMDWIDTH, 2)/* 2 lines (single plane) state for D_Vr state */ #define EED1_8_STATE_D_VR_HEIGHT 2 -#define EED1_8_STATE_D_VR_WIDTH CEIL_DIV(MAX_FRAME_SIMDWIDTH, 2) +#define EED1_8_STATE_D_VR_WIDTH DIV_ROUND_UP(MAX_FRAME_SIMDWIDTH, 2)/* 2 line (single plane) state for D_Vb state */ #define EED1_8_STATE_D_VB_HEIGHT 2 -#define EED1_8_STATE_D_VB_WIDTH CEIL_DIV(MAX_FRAME_SIMDWIDTH, 2) +#define EED1_8_STATE_D_VB_WIDTH DIV_ROUND_UP(MAX_FRAME_SIMDWIDTH, 2)/* 2 lines state for R and B (= 2 planes) rb_zipped_state */ #define EED1_8_STATE_RB_ZIPPED_HEIGHT (2 * 2) -#define EED1_8_STATE_RB_ZIPPED_WIDTH CEIL_DIV(MAX_FRAME_SIMDWIDTH, 2) +#define EED1_8_STATE_RB_ZIPPED_WIDTH DIV_ROUND_UP(MAX_FRAME_SIMDWIDTH, 2)#if EED1_8_FC_ENABLE_MEDIAN /* 1 full input line (GR-R color line) for Yc state */
@@ -81,11 +83,11 @@/* 1 line state per color plane Cg_state */ #define EED1_8_STATE_CG_HEIGHT (1 * NUM_PLANES) -#define EED1_8_STATE_CG_WIDTH CEIL_DIV(MAX_FRAME_SIMDWIDTH, 2) +#define EED1_8_STATE_CG_WIDTH DIV_ROUND_UP(MAX_FRAME_SIMDWIDTH, 2)/* 1 line state per color plane Co_state */ #define EED1_8_STATE_CO_HEIGHT (1 * NUM_PLANES) -#define EED1_8_STATE_CO_WIDTH CEIL_DIV(MAX_FRAME_SIMDWIDTH, 2) +#define EED1_8_STATE_CO_WIDTH DIV_ROUND_UP(MAX_FRAME_SIMDWIDTH, 2)/* 1 full input line (GR-R color line) for AbsK state */ #define EED1_8_STATE_ABSK_HEIGHT 1
drivers/staging/media/atomisp/pci/isp/kernels/fpn/fpn_1.0/ia_css_fpn.host.c +4 -2
@@ -13,6 +13,8 @@* more details. */ +#include <linux/math.h> +#include <assert_support.h> #include <ia_css_frame_public.h> #include <ia_css_frame.h>
@@ -80,9 +82,9 @@ int ia_css_fpn_configure(const struct ia_css_binary *binary, &my_info }; - my_info.res.width =CEIL_DIV (info->res.width,2 );/* Packed by 2x */ + my_info.res.width =DIV_ROUND_UP (info->res.width,2 );/* Packed by 2x */ my_info.res.height = info->res.height; - my_info.padded_width =CEIL_DIV (info->padded_width,2 );/* Packed by 2x */ + my_info.padded_width =DIV_ROUND_UP (info->padded_width,2 );/* Packed by 2x */ my_info.format = info->format; my_info.raw_bit_depth =FPN_BITS_PER_PIXEL ; my_info.raw_bayer_order = info->raw_bayer_order;
drivers/staging/media/atomisp/pci/isp/kernels/sc/sc_1.0/ia_css_sc_param.h +1 -1
@@ -31,7 +31,7 @@ struct sh_css_isp_sc_params {* vec_slice is used for 2 adjacent vectors of shading gains. * The number of shift times by vec_slice is 8. * Max grid cell bqs to support the shading table centerting: N = 32 -* CEIL_DIV(N-1, ISP_SLICE_NELEMS) = CEIL_DIV(31, 4) = 8 +* DIV_ROUND_UP(N-1, ISP_SLICE_NELEMS) = DIV_ROUND_UP(31, 4) = 8 */ #define SH_CSS_SC_INTERPED_GAIN_HOR_SLICE_TIMES 8
drivers/staging/media/atomisp/pci/isp/modes/interface/input_buf.isp.h +4 -1
@@ -16,6 +16,8 @@ more details.#ifndef _INPUT_BUF_ISP_H_#define _INPUT_BUF_ISP_H_ +#include <linux/math.h> +/* Temporary include, since IA_CSS_BINARY_MODE_COPY is still needed */ #include "sh_css_defs.h" #include "isp_const.h" /* MAX_VECTORS_PER_INPUT_LINE */
@@ -30,7 +32,8 @@ more details./* In continuous mode, the input buffer must be a fixed size for all binaries * and at a fixed address since it will be used by the SP. */ #define EXTRA_INPUT_VECTORS 2/* For left padding */ -#define MAX_VECTORS_PER_INPUT_LINE_CONT (CEIL_DIV(SH_CSS_MAX_SENSOR_WIDTH, ISP_NWAY) + EXTRA_INPUT_VECTORS) +#define MAX_VECTORS_PER_INPUT_LINE_CONT \ + (DIV_ROUND_UP(SH_CSS_MAX_SENSOR_WIDTH, ISP_NWAY) + EXTRA_INPUT_VECTORS)/* The input buffer should be on a fixed address in vmem, for continuous capture */ #define INPUT_BUF_ADDR 0x0
drivers/staging/media/atomisp/pci/isp/modes/interface/isp_const.h +17 -15
@@ -16,6 +16,8 @@ more details.#ifndef _COMMON_ISP_CONST_H_#define _COMMON_ISP_CONST_H_ +#include <linux/math.h> +/*#include "isp.h"*/ /* ISP_VEC_NELEMS */ /* Binary independent constants */
@@ -33,8 +35,8 @@ more details.#define XMEM_INTS_PER_WORD (HIVE_ISP_DDR_WORD_BITS / 32)#define XMEM_POW2_BYTES_PER_WORD HIVE_ISP_DDR_WORD_BYTES -#define BITS8_ELEMENTS_PER_XMEM_ADDR CEIL_DIV(XMEM_WIDTH_BITS, 8) -#define BITS16_ELEMENTS_PER_XMEM_ADDR CEIL_DIV(XMEM_WIDTH_BITS, 16) +#define BITS8_ELEMENTS_PER_XMEM_ADDR DIV_ROUND_UP(XMEM_WIDTH_BITS, 8) +#define BITS16_ELEMENTS_PER_XMEM_ADDR DIV_ROUND_UP(XMEM_WIDTH_BITS, 16)#define ISP_NWAY_LOG2 6
@@ -67,17 +69,17 @@ more details.#define UDS_MAX_CHUNKS 16#define ISP_LEFT_PADDING _ISP_LEFT_CROP_EXTRA(ISP_LEFT_CROPPING) -#define ISP_LEFT_PADDING_VECS CEIL_DIV(ISP_LEFT_PADDING, ISP_VEC_NELEMS) +#define ISP_LEFT_PADDING_VECS DIV_ROUND_UP(ISP_LEFT_PADDING, ISP_VEC_NELEMS)/* in case of continuous the croppong of the current binary doesn't matter for the buffer calculation, but the cropping of the sp copy should be used */ #define ISP_LEFT_PADDING_CONT _ISP_LEFT_CROP_EXTRA(SH_CSS_MAX_LEFT_CROPPING) -#define ISP_LEFT_PADDING_VECS_CONT CEIL_DIV(ISP_LEFT_PADDING_CONT, ISP_VEC_NELEMS) +#define ISP_LEFT_PADDING_VECS_CONT DIV_ROUND_UP(ISP_LEFT_PADDING_CONT, ISP_VEC_NELEMS)#define CEIL_ROUND_DIV_STRIPE (width, stripe, padding) \ - CEIL_MUL(padding + CEIL_DIV(width - padding, stripe), ((ENABLE_RAW_BINNING || ENABLE_FIXED_BAYER_DS) ? 4 : 2)) + round_up(padding + DIV_ROUND_UP(width - padding, stripe), (ENABLE_RAW_BINNING || ENABLE_FIXED_BAYER_DS) ? 4 : 2)/* output (Y,U,V) image, 4:2:0 */ #define MAX_VECTORS_PER_LINE \ - CEIL_ROUND_DIV_STRIPE(CEIL_DIV(ISP_MAX_INTERNAL_WIDTH, ISP_VEC_NELEMS), \ + CEIL_ROUND_DIV_STRIPE(DIV_ROUND_UP(ISP_MAX_INTERNAL_WIDTH, ISP_VEC_NELEMS), \ ISP_NUM_STRIPES, \ ISP_LEFT_PADDING_VECS)
@@ -89,16 +91,16 @@ more details.* ((width[vectors]/num_of_stripes) + 2[vectors]) */ #define MAX_VECTORS_PER_OUTPUT_LINE \ - CEIL_DIV(CEIL_DIV(ISP_MAX_OUTPUT_WIDTH, ISP_NUM_STRIPES) + ISP_LEFT_PADDING, ISP_VEC_NELEMS) + DIV_ROUND_UP(DIV_ROUND_UP(ISP_MAX_OUTPUT_WIDTH, ISP_NUM_STRIPES) + ISP_LEFT_PADDING, ISP_VEC_NELEMS)/* Must be even due to interlaced bayer input */ -#define MAX_VECTORS_PER_INPUT_LINE CEIL_MUL((CEIL_DIV(ISP_MAX_INPUT_WIDTH, ISP_VEC_NELEMS) + ISP_LEFT_PADDING_VECS), 2) +#define MAX_VECTORS_PER_INPUT_LINE round_up(DIV_ROUND_UP(ISP_MAX_INPUT_WIDTH, ISP_VEC_NELEMS) + ISP_LEFT_PADDING_VECS, 2)#define MAX_VECTORS_PER_INPUT_STRIPE CEIL_ROUND_DIV_STRIPE(MAX_VECTORS_PER_INPUT_LINE, \ ISP_NUM_STRIPES, \ ISP_LEFT_PADDING_VECS)/* Add 2 for left croppping */ -#define MAX_SP_RAW_COPY_VECTORS_PER_INPUT_LINE (CEIL_DIV(ISP_MAX_INPUT_WIDTH, ISP_VEC_NELEMS) + 2) +#define MAX_SP_RAW_COPY_VECTORS_PER_INPUT_LINE (DIV_ROUND_UP(ISP_MAX_INPUT_WIDTH, ISP_VEC_NELEMS) + 2)#define MAX_VECTORS_PER_BUF_LINE \ (MAX_VECTORS_PER_LINE + DUMMY_BUF_VECTORS)
@@ -111,14 +113,14 @@ more details.#define MAX_OUTPUT_C_FRAME_WIDTH \ (MAX_OUTPUT_Y_FRAME_WIDTH / 2)#define MAX_OUTPUT_C_FRAME_SIMDWIDTH \ - CEIL_DIV(MAX_OUTPUT_C_FRAME_WIDTH, ISP_VEC_NELEMS) + DIV_ROUND_UP(MAX_OUTPUT_C_FRAME_WIDTH, ISP_VEC_NELEMS)/* should be even */ #define NO_CHUNKING (OUTPUT_NUM_CHUNKS == 1)#define MAX_VECTORS_PER_CHUNK \ (NO_CHUNKING ? MAX_VECTORS_PER_LINE \ - : 2 * CEIL_DIV(MAX_VECTORS_PER_LINE, \ + : 2 * DIV_ROUND_UP(MAX_VECTORS_PER_LINE, \ 2 * OUTPUT_NUM_CHUNKS))#define MAX_C_VECTORS_PER_CHUNK \
@@ -127,7 +129,7 @@ more details./* should be even */ #define MAX_VECTORS_PER_OUTPUT_CHUNK \ (NO_CHUNKING ? MAX_VECTORS_PER_OUTPUT_LINE \ - : 2 * CEIL_DIV(MAX_VECTORS_PER_OUTPUT_LINE, \ + : 2 * DIV_ROUND_UP(MAX_VECTORS_PER_OUTPUT_LINE, \ 2 * OUTPUT_NUM_CHUNKS))#define MAX_C_VECTORS_PER_OUTPUT_CHUNK \
@@ -136,7 +138,7 @@ more details./* should be even */ #define MAX_VECTORS_PER_INPUT_CHUNK \ (INPUT_NUM_CHUNKS == 1 ? MAX_VECTORS_PER_INPUT_STRIPE \ - : 2 * CEIL_DIV(MAX_VECTORS_PER_INPUT_STRIPE, \ + : 2 * DIV_ROUND_UP(MAX_VECTORS_PER_INPUT_STRIPE, \ 2 * OUTPUT_NUM_CHUNKS))#define DEFAULT_C_SUBSAMPLING 2
@@ -148,9 +150,9 @@ more details./* [isp vmem] table size[vectors] per line per color (GR,R,B,GB), multiples of NWAY */ #define ISP2400_SCTBL_VECTORS_PER_LINE_PER_COLOR \ - CEIL_DIV(SH_CSS_MAX_SCTBL_WIDTH_PER_COLOR, ISP_VEC_NELEMS) + DIV_ROUND_UP(SH_CSS_MAX_SCTBL_WIDTH_PER_COLOR, ISP_VEC_NELEMS)#define ISP2401_SCTBL_VECTORS_PER_LINE_PER_COLOR \ - CEIL_DIV(SH_CSS_MAX_SCTBL_WIDTH_PER_COLOR, ISP_VEC_NELEMS) + DIV_ROUND_UP(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 \
drivers/staging/media/atomisp/pci/runtime/debug/src/ia_css_debug.c +0 -1
@@ -60,7 +60,6 @@#include "sp.h" #include "isp.h" #include "type_support.h" -#include "math_support.h" /* CEIL_DIV */ #include "input_system.h" /* input_formatter_reg_load */ #include "ia_css_tagger_common.h"
drivers/staging/media/atomisp/pci/runtime/frame/src/frame.c +17 -17
@@ -13,15 +13,16 @@* more details. */ -#include "hmm.h" +#include <linux/bitops.h> +#include <linux/math.h> -#include "ia_css_frame.h" -#include <math_support.h> #include "assert_support.h" +#include "atomisp_internal.h" +#include "hmm.h" #include "ia_css_debug.h" +#include "ia_css_frame.h" #include "isp.h" #include "sh_css_internal.h" -#include "atomisp_internal.h" #define NV12_TILEY_TILE_WIDTH 128#define NV12_TILEY_TILE_HEIGHT 32
@@ -427,7 +428,7 @@ int ia_css_dma_configure_from_info(struct dma_port_config *config,unsigned int bits_per_pixel = is_raw_packed ? info->raw_bit_depth :ia_css_elems_bytes_from_info (info) *8 ;unsigned int pix_per_ddrword =HIVE_ISP_DDR_WORD_BITS / bits_per_pixel; -unsigned int words_per_line =CEIL_DIV (info->padded_width, pix_per_ddrword); +unsigned int words_per_line =DIV_ROUND_UP (info->padded_width, pix_per_ddrword);unsigned int elems_b = pix_per_ddrword; config->stride =HIVE_ISP_DDR_WORD_BYTES * words_per_line;
@@ -468,15 +469,16 @@ static void frame_init_single_plane(struct ia_css_frame *frame,unsigned int stride; stride = subpixels_per_line * bytes_per_pixel; -/* Frame height needs to be even number - needed by hw ISYS2401 -In case of odd number, round up to even. -Images won't be impacted by this round up, -only needed by jpeg/embedded data. -As long as buffer allocation and release are using data_bytes, -there won't be memory leak. */ - frame->data_bytes = stride *CEIL_MUL2 (height,2 ); +/* +* Frame height needs to be even number - needed by hw ISYS2401. +* In case of odd number, round up to even. +* Images won't be impacted by this round up, +* only needed by jpeg/embedded data. +* As long as buffer allocation and release are using data_bytes, +* there won't be memory leak. +*/ + frame->data_bytes = stride *round_up (height,2 );frame_init_plane (plane, subpixels_per_line, stride, height,0 ); -return ; } static void frame_init_raw_single_plane(
@@ -491,11 +493,9 @@ static void frame_init_raw_single_plane(assert (frame); stride =HIVE_ISP_DDR_WORD_BYTES * -CEIL_DIV (subpixels_per_line, -HIVE_ISP_DDR_WORD_BITS / bits_per_pixel); +DIV_ROUND_UP (subpixels_per_line,HIVE_ISP_DDR_WORD_BITS / bits_per_pixel); frame->data_bytes = stride * height;frame_init_plane (plane, subpixels_per_line, stride, height,0 ); -return ; } static void frame_init_nv_planes(struct ia_css_frame *frame,
@@ -699,7 +699,7 @@ ia_css_elems_bytes_from_info(const struct ia_css_frame_info *info)if (info->format ==IA_CSS_FRAME_FORMAT_RAW || (info->format ==IA_CSS_FRAME_FORMAT_RAW_PACKED )) {if (info->raw_bit_depth) -return CEIL_DIV (info->raw_bit_depth,8 ); +return BITS_TO_BYTES (info->raw_bit_depth);else return 2 ;/* bytes per pixel */ }
drivers/staging/media/atomisp/pci/runtime/ifmtr/src/ifmtr.c +5 -6
@@ -13,9 +13,9 @@* more details. */ -#include "system_global.h" -#include <linux/kernel.h> +#include <linux/math.h> +#include "system_global.h" #include "ia_css_ifmtr.h" #include <math_support.h>
@@ -158,10 +158,9 @@ int ia_css_ifmtr_configure(struct ia_css_stream_config *config, left_padding =2 *ISP_VEC_NELEMS - config->left_padding;if (left_padding) { - num_vectors =CEIL_DIV (cropped_width + left_padding, -ISP_VEC_NELEMS ); + num_vectors =DIV_ROUND_UP (cropped_width + left_padding,ISP_VEC_NELEMS ); }else { - num_vectors =CEIL_DIV (cropped_width,ISP_VEC_NELEMS ); + num_vectors =DIV_ROUND_UP (cropped_width,ISP_VEC_NELEMS ); num_vectors *= buffer_height;/* todo: in case of left padding, num_vectors is vectors per line,
@@ -314,7 +313,7 @@ int ia_css_ifmtr_configure(struct ia_css_stream_config *config,if ((!binary) || config->continuous)/* !binary -> sp raw copy pipe */ buffer_height *=2 ; - vectors_per_line =CEIL_DIV (cropped_width,ISP_VEC_NELEMS ); + vectors_per_line =DIV_ROUND_UP (cropped_width,ISP_VEC_NELEMS ); vectors_per_line =CEIL_MUL (vectors_per_line, deinterleaving);break ;case ATOMISP_INPUT_FORMAT_RAW_14 :
drivers/staging/media/atomisp/pci/runtime/isys/src/virtual_isys.c +1 -1
@@ -817,7 +817,7 @@ static bool calculate_isys2401_dma_port_cfg( cfg->elements =HIVE_ISP_DDR_WORD_BITS / bits_per_pixel; cfg->cropping =0 ; - cfg->width =CEIL_DIV (cfg->stride,HIVE_ISP_DDR_WORD_BYTES ); + cfg->width =DIV_ROUND_UP (cfg->stride,HIVE_ISP_DDR_WORD_BYTES );return true; }
drivers/staging/media/atomisp/pci/sh_css.c +6 -4
@@ -5846,8 +5846,8 @@ static int ia_css_pipe_create_cas_scaler_desc_single_output(/* We assume that this function is used only for single output port case. */ descr->num_output_stage =1 ; - hor_ds_factor =CEIL_DIV (in_info->res.width, out_info->res.width); - ver_ds_factor =CEIL_DIV (in_info->res.height, out_info->res.height); + hor_ds_factor =DIV_ROUND_UP (in_info->res.width, out_info->res.width); + ver_ds_factor =DIV_ROUND_UP (in_info->res.height, out_info->res.height);/* use the same horizontal and vertical downscaling factor for simplicity */ assert (hor_ds_factor == ver_ds_factor);
@@ -5987,8 +5987,10 @@ ia_css_pipe_create_cas_scaler_desc(struct ia_css_pipe *pipe, }if (out_info[i]) { - hor_scale_factor[i] =CEIL_DIV (in_info.res.width, out_info[i]->res.width); - ver_scale_factor[i] =CEIL_DIV (in_info.res.height, out_info[i]->res.height); + hor_scale_factor[i] = +DIV_ROUND_UP (in_info.res.width, out_info[i]->res.width); + ver_scale_factor[i] = +DIV_ROUND_UP (in_info.res.height, out_info[i]->res.height);/* use the same horizontal and vertical scaling factor for simplicity */ assert (hor_scale_factor[i] == ver_scale_factor[i]); scale_factor =1 ;
drivers/staging/media/atomisp/pci/sh_css_defs.h +6 -6
@@ -16,12 +16,12 @@#ifndef _SH_CSS_DEFS_H_#define _SH_CSS_DEFS_H_ +#include <linux/math.h> +#include "isp.h" /*#include "vamem.h"*/ /* Cannot include for VAMEM properties this file is visible on ISP -> pipeline generator */ -#include "math_support.h" /* max(), min, etc etc */ -/* ID's for refcount */ #define IA_CSS_REFCOUNT_PARAM_SET_POOL 0xCAFE0001#define IA_CSS_REFCOUNT_PARAM_BUFFER 0xCAFE0002
@@ -191,7 +191,7 @@ RGB[0,8191],coef[-8192,8191] -> RGB[0,8191]The ISP firmware needs these rules to be applied at pre-processor time, that's why these are macros, not functions. */ #define _ISP_BQS (num) ((num) / 2) -#define _ISP_VECS (width) CEIL_DIV(width, ISP_VEC_NELEMS) +#define _ISP_VECS (width) DIV_ROUND_UP(width, ISP_VEC_NELEMS)#define ISP_BQ_GRID_WIDTH (elements_per_line, deci_factor_log2) \ CEIL_SHIFT(elements_per_line / 2, deci_factor_log2)
@@ -203,9 +203,9 @@ RGB[0,8191],coef[-8192,8191] -> RGB[0,8191]/* The morphing table is similar to the shading table in the sense that we have 1 more value than we have cells in the grid. */ #define _ISP_MORPH_TABLE_WIDTH (int_width) \ - (CEIL_DIV(int_width, SH_CSS_MORPH_TABLE_GRID) + 1) + (DIV_ROUND_UP(int_width, SH_CSS_MORPH_TABLE_GRID) + 1)#define _ISP_MORPH_TABLE_HEIGHT (int_height) \ - (CEIL_DIV(int_height, SH_CSS_MORPH_TABLE_GRID) + 1) + (DIV_ROUND_UP(int_height, SH_CSS_MORPH_TABLE_GRID) + 1)#define _ISP_MORPH_TABLE_ALIGNED_WIDTH (width) \ CEIL_MUL(_ISP_MORPH_TABLE_WIDTH(width), \ SH_CSS_MORPH_TABLE_ELEMS_PER_DDR_WORD)
@@ -307,7 +307,7 @@ RGB[0,8191],coef[-8192,8191] -> RGB[0,8191] c_subsampling, \ num_chunks, \ pipelining) \ - CEIL_MUL2(CEIL_MUL2(MAX(__ISP_PADDED_OUTPUT_WIDTH(out_width, \ + round_up(round_up(MAX(__ISP_PADDED_OUTPUT_WIDTH(out_width, \ dvs_env_width, \ left_crop), \ __ISP_MIN_INTERNAL_WIDTH(num_chunks, \
drivers/staging/media/atomisp/pci/sh_css_internal.h +3 -5
@@ -17,6 +17,7 @@#define _SH_CSS_INTERNAL_H_#include <linux/build_bug.h> +#include <linux/math.h> #include <linux/stdarg.h> #include <system_global.h>
@@ -104,7 +105,6 @@* the SIZE_OF_XXX macro of the corresponding struct. If they are not * equal, functionality will break. */ -#define CALC_ALIGNMENT_MEMBER (x, y) (CEIL_MUL(x, y) - x)#define SIZE_OF_HRT_VADDRESS sizeof(hive_uint32)/* Number of SP's */
@@ -713,13 +713,11 @@ struct sh_css_hmm_buffer {/* Do not use sizeof(uint64_t) since that does not exist of SP */ #define SIZE_OF_SH_CSS_HMM_BUFFER_STRUCT \ - (SIZE_OF_PAYLOAD_UNION + \ - CALC_ALIGNMENT_MEMBER(SIZE_OF_PAYLOAD_UNION, 8) + \ + (round_up(SIZE_OF_PAYLOAD_UNION, 8) + \ 8 + \ 8 + \ SIZE_OF_IA_CSS_TIME_MEAS_STRUCT + \ - SIZE_OF_IA_CSS_CLOCK_TICK_STRUCT + \ - CALC_ALIGNMENT_MEMBER(SIZE_OF_IA_CSS_CLOCK_TICK_STRUCT, 8)) + round_up(SIZE_OF_IA_CSS_CLOCK_TICK_STRUCT, 8))static_assert (sizeof (struct sh_css_hmm_buffer ) ==SIZE_OF_SH_CSS_HMM_BUFFER_STRUCT );
drivers/staging/media/atomisp/pci/sh_css_param_dvs.h +11 -8
@@ -16,6 +16,8 @@#ifndef _SH_CSS_PARAMS_DVS_H_#define _SH_CSS_PARAMS_DVS_H_ +#include <linux/math.h> +#include <math_support.h> #include <ia_css_types.h> #include "gdc_global.h" /* gdc_warp_param_mem_t */
@@ -29,16 +31,17 @@/* ISP2400 */ /* horizontal 64x64 blocks round up to DVS_BLOCKDIM_X, make even */ -#define DVS_NUM_BLOCKS_X (X ) (CEIL_MUL(CEIL_DIV((X), DVS_BLOCKDIM_X), 2)) +#define DVS_NUM_BLOCKS_X (X ) round_up(DIV_ROUND_UP((X), DVS_BLOCKDIM_X), 2) +#define DVS_NUM_BLOCKS_X_CHROMA (X ) DIV_ROUND_UP((X), DVS_BLOCKDIM_X)/* ISP2400 */ /* vertical 64x64 blocks round up to DVS_BLOCKDIM_Y */ -#define DVS_NUM_BLOCKS_Y (X ) (CEIL_DIV((X), DVS_BLOCKDIM_Y_LUMA)) -#define DVS_NUM_BLOCKS_X_CHROMA (X ) (CEIL_DIV((X), DVS_BLOCKDIM_X)) -#define DVS_NUM_BLOCKS_Y_CHROMA (X ) (CEIL_DIV((X), DVS_BLOCKDIM_Y_CHROMA)) +#define DVS_NUM_BLOCKS_Y (X ) DIV_ROUND_UP((X), DVS_BLOCKDIM_Y_LUMA) +#define DVS_NUM_BLOCKS_Y_CHROMA (X ) DIV_ROUND_UP((X), DVS_BLOCKDIM_Y_CHROMA) -#define DVS_TABLE_IN_BLOCKDIM_X_LUMA (X ) (DVS_NUM_BLOCKS_X(X) + 1)/* N blocks have N + 1 set of coords */ -#define DVS_TABLE_IN_BLOCKDIM_X_CHROMA (X ) (DVS_NUM_BLOCKS_X_CHROMA(X) + 1) +/* N blocks have N + 1 set of coords */ +#define DVS_TABLE_IN_BLOCKDIM_X_LUMA (X ) (DVS_NUM_BLOCKS_X(X) + 1) +#define DVS_TABLE_IN_BLOCKDIM_X_CHROMA (X ) (DVS_NUM_BLOCKS_X_CHROMA(X) + 1)#define DVS_TABLE_IN_BLOCKDIM_Y_LUMA (X ) (DVS_NUM_BLOCKS_Y(X) + 1)#define DVS_TABLE_IN_BLOCKDIM_Y_CHROMA (X ) (DVS_NUM_BLOCKS_Y_CHROMA(X) + 1)
@@ -52,8 +55,8 @@#define XMEM_ALIGN_LOG2 (5) -#define DVS_6AXIS_COORDS_ELEMS CEIL_MUL(sizeof(gdc_warp_param_mem_t) \ - , HIVE_ISP_DDR_WORD_BYTES) +#define DVS_6AXIS_COORDS_ELEMS \ + round_up(sizeof(gdc_warp_param_mem_t), HIVE_ISP_DDR_WORD_BYTES)/* currently we only support two output with the same resolution, output 0 is th default one. */ #define DVS_6AXIS_BYTES (binary) \
drivers/staging/media/atomisp/pci/sh_css_param_shading.c +2 -2
@@ -107,8 +107,8 @@ crop_and_interpolate(unsigned int cropped_width, out_ptr = out_table->data[color]; padded_width = cropped_width + left_padding + right_padding; - out_cell_size =CEIL_DIV (padded_width, out_table->width -1 ); - in_cell_size =CEIL_DIV (sensor_width, table_width -1 ); + out_cell_size =DIV_ROUND_UP (padded_width, out_table->width -1 ); + in_cell_size =DIV_ROUND_UP (sensor_width, table_width -1 ); out_start_col = ((int )sensor_width - (int )cropped_width) /2 - left_padding; out_start_row = ((int )sensor_height - (int )cropped_height) /2 - top_padding;
drivers/staging/media/atomisp/pci/sh_css_params.c +6 -6
@@ -13,6 +13,8 @@* more details. */ +#include <linux/math.h> +#include "gdc_device.h" /* gdc_lut_store(), ... */ #include "isp.h" /* ISP_VEC_ELEMBITS */ #include "vamem.h"
@@ -30,8 +32,6 @@#include "platform_support.h" #include "assert_support.h" -#include "misc_support.h" /* NOT_USED */ -#include "math_support.h" /* max(), min() EVEN_FLOOR()*/ #include "ia_css_stream.h" #include "sh_css_params_internal.h"
@@ -4051,10 +4051,10 @@ sh_css_update_uds_and_crop_info( }/* Must enforce that the crop position is even */ - crop_x =EVEN_FLOOR (crop_x); - crop_y =EVEN_FLOOR (crop_y); - uds_xc =EVEN_FLOOR (uds_xc); - uds_yc =EVEN_FLOOR (uds_yc); + crop_x =round_down (crop_x,2 ); + crop_y =round_down (crop_y,2 ); + uds_xc =round_down (uds_xc,2 ); + uds_yc =round_down (uds_yc,2 ); uds->xc = (uint16_t )uds_xc; uds->yc = (uint16_t )uds_yc;
Signature · 1 line
2.43.0.rc1.1336.g36b5255a03ac
Hi,
Quoted 7 lines · Andy Shevchenko
Replace rarely used macros by generic ones from Linux kernel headers.
Signed-off-by Andy Shevchenko <[email protected]>---
Please, apply only after tests that confirm everything is working as expected.
I gave this a try today and I'm afraid that it causes problems.
The original CEIL_DIV helper had a check to avoid divide by 0 and it looks like that check is necessary in at least some cases (I did not investigate this further):
[ 494.054038] Oops: divide error: 0000 [#1] PREEMPT SMP PTI [ 494.054083] CPU: 0 UID: 1000 PID: 2622 Comm: qcam Tainted: G C E 6.12.0-rc3+ #175 [ 494.054112] Tainted: [C]=CRAP, [E]=UNSIGNED_MODULE [ 494.054124] Hardware name: Acer Iconia W4-820/Cheetah3, BIOS V1.16 03/13/2014 [ 494.054138] RIP: 0010:atomisp_css2_hw_store_32+0x503/0x5b0 [atomisp] [ 494.054296] Code: 48 c1 e8 23 39 f0 72 7b 4c 8b af 68 0f 00 00 41 81 bd 58 01 00 00 ff 1f 00 00 0f 87 9b 00 00 00 89 e8 31 d2 d1 e8 8d 44 01 ff <f7> f1 31 d2 89 c1 44 89 e0 d1 e8 8d 44 06 ff f7 f6 39 c1 0f 85 37 [ 494.054316] RSP: 0018:ffff9e3d458379c0 EFLAGS: 00010206 [ 494.054339] RAX: 00000000000003bf RBX: ffff909c42f584a0 RCX: 0000000000000000 [ 494.054354] RDX: 0000000000000000 RSI: 0000000000000000 RDI: ffff909c42f584a0 [ 494.054369] RBP: 0000000000000780 R08: 00000000000005a0 R09: 0000000000000780 [ 494.054383] R10: ffffffffc0f448e0 R11: 0000000000000000 R12: 00000000000005a0 [ 494.054397] R13: ffff909c42f58028 R14: ffffffffc0f44e20 R15: ffffffffc0f44d90 [ 494.054413] FS: 00007f2c5f4006c0(0000) GS:ffff909cb4800000(0000) knlGS:0000000000000000 [ 494.054431] CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033 [ 494.054446] CR2: 00007f2c8247ea19 CR3: 00000000327b6000 CR4: 00000000001026f0 [ 494.054463] Call Trace: [ 494.054478] <TASK> [ 494.054494] ? __die_body.cold+0x19/0x27 [ 494.054523] ? die+0x2a/0x50 [ 494.054551] ? do_trap+0xc6/0x110 [ 494.054577] ? atomisp_css2_hw_store_32+0x503/0x5b0 [atomisp] [ 494.054717] ? do_error_trap+0x81/0x110 [ 494.054737] ? atomisp_css2_hw_store_32+0x503/0x5b0 [atomisp] [ 494.054890] ? exc_divide_error+0x34/0x50 [ 494.054916] ? atomisp_css2_hw_store_32+0x503/0x5b0 [atomisp] [ 494.055117] ? asm_exc_divide_error+0x16/0x20 [ 494.055147] ? __pfx_atomisp_css_preview_get_output_frame_info+0x10/0x10 [atomisp] [ 494.055357] ? __pfx_atomisp_css_preview_configure_pp_input+0x10/0x10 [atomisp] [ 494.055545] ? __pfx_atomisp_css_preview_configure_output+0x10/0x10 [atomisp] [ 494.055721] ? atomisp_css2_hw_store_32+0x503/0x5b0 [atomisp] [ 494.055933] atomisp_css_preview_configure_pp_input+0xe0/0x1e0 [atomisp] [ 494.056151] ? __pfx_atomisp_css_preview_configure_pp_input+0x10/0x10 [atomisp] [ 494.056367] atomisp_set_fmt+0x774/0xb80 [atomisp] [ 494.056580] v4l_s_fmt+0x1c7/0x5a0 [videodev] [ 494.056761] __video_do_ioctl+0x456/0x480 [videodev] [ 494.056936] video_usercopy+0x381/0x830 [videodev] [ 494.057052] ? __pfx___video_do_ioctl+0x10/0x10 [videodev] [ 494.057167] ? ioctl_has_perm.constprop.0.isra.0+0xa8/0xe0 [ 494.057204] ? __pfx_inode_insert5+0x5/0x10 [ 494.057235] ? __fget_files+0x9b/0x190 [ 494.057258] ? lock_release+0x175/0x2a0 [ 494.057299] v4l2_ioctl+0x49/0x50 [videodev] [ 494.057455] __x64_sys_ioctl+0x90/0xd0 [ 494.057485] do_syscall_64+0x93/0x180 [ 494.057511] ? lock_release+0x175/0x2a0 [ 494.057532] ? _raw_spin_unlock_irqrestore+0x35/0x60 [ 494.057563] ? ldsem_up_read+0x17/0x40 [ 494.057587] ? file_tty_write.isra.0+0x224/0x2d0 [ 494.057622] ? vfs_write+0x259/0x510 [ 494.057654] ? syscall_exit_to_user_mode+0x11/0x280 [ 494.057681] ? do_syscall_64+0x9f/0x180 [ 494.057708] ? lockdep_hardirqs_on+0x78/0x100 [ 494.057738] ? do_syscall_64+0x9f/0x180 [ 494.057765] ? __rseq_handle_notify_resume+0x316/0x580 [ 494.057804] ? do_syscall_64+0x9f/0x180 [ 494.057830] ? lockdep_hardirqs_on+0x78/0x100 [ 494.057859] ? do_syscall_64+0x9f/0x180 [ 494.057891] entry_SYSCALL_64_after_hwframe+0x76/0x7e [ 494.057920] RIP: 0033:0x7f2c818fe0ad [ 494.057950] Code: 04 25 28 00 00 00 48 89 45 c8 31 c0 48 8d 45 10 c7 45 b0 10 00 00 00 48 89 45 b8 48 8d 45 d0 48 89 45 c0 b8 10 00 00 00 0f 05 <89> c2 3d 00 f0 ff ff 77 1a 48 8b 45 c8 64 48 2b 04 25 28 00 00 00 [ 494.057977] RSP: 002b:00007f2c5f3fe2f0 EFLAGS: 00000246 ORIG_RAX: 0000000000000010 [ 494.058004] RAX: ffffffffffffffda RBX: 00007f2c5f3fe750 RCX: 00007f2c818fe0ad [ 494.058021] RDX: 00007f2c5f3fe390 RSI: 00000000c0d05605 RDI: 0000000000000025 [ 494.058036] RBP: 00007f2c5f3fe340 R08: 00007f2c300178d0 R09: 000000000000000d [ 494.058052] R10: 00007f2c3000b320 R11: 0000000000000246 R12: 00000000ffffffea [ 494.058067] R13: 0000000000000001 R14: 00007f2c5f3fe740 R15: 00007f2c5f3fe750 [ 494.058110] </TASK>
Regards,
Hans