* [PATCH 0/7] smiapp, omap3isp: Cleanups and fixes @ 2020-02-13 9:49 Sakari Ailus 2020-02-13 9:49 ` [PATCH 1/7] omap3isp: Prevent enabling CCDC when stopping streaming Sakari Ailus ` (6 more replies) 0 siblings, 7 replies; 8+ messages in thread From: Sakari Ailus @ 2020-02-13 9:49 UTC (permalink / raw) To: linux-media Hi all, This set contains a small fix for the omap3isp crashing the system, as well as cleanups for the smiapp driver. Sakari Ailus (7): omap3isp: Prevent enabling CCDC when stopping streaming smiapp: Simplify condition for choosing 8-bit access smiapp: Use unaligned get and put functions smiapp: Turn limit lookup into a function smiapp: Move SMIA limit reading up smiapp: Refactor reading SMIA limits smiapp: Move definitions under driver directory drivers/media/i2c/smiapp/smiapp-core.c | 259 +++++++++++----------- drivers/media/i2c/smiapp/smiapp-reg.h | 4 + drivers/media/i2c/smiapp/smiapp-regs.c | 71 ++---- drivers/media/i2c/smiapp/smiapp.h | 44 +++- drivers/media/platform/omap3isp/ispccdc.c | 4 + include/media/i2c/smiapp.h | 63 ------ 6 files changed, 200 insertions(+), 245 deletions(-) delete mode 100644 include/media/i2c/smiapp.h -- 2.20.1 ^ permalink raw reply [flat|nested] 8+ messages in thread
* [PATCH 1/7] omap3isp: Prevent enabling CCDC when stopping streaming 2020-02-13 9:49 [PATCH 0/7] smiapp, omap3isp: Cleanups and fixes Sakari Ailus @ 2020-02-13 9:49 ` Sakari Ailus 2020-02-13 9:49 ` [PATCH 2/7] smiapp: Simplify condition for choosing 8-bit access Sakari Ailus ` (5 subsequent siblings) 6 siblings, 0 replies; 8+ messages in thread From: Sakari Ailus @ 2020-02-13 9:49 UTC (permalink / raw) To: linux-media Commit ... prevented restarting CCDC through its interrupt handler when it's about to be disabled. It missed to address the case when CCDC might be enabled due to queueing a buffer. Do that now. Fixes: dd12ed17ce9e ("omap3isp: Don't restart CCDC if we're about to stop") Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com> --- drivers/media/platform/omap3isp/ispccdc.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/drivers/media/platform/omap3isp/ispccdc.c b/drivers/media/platform/omap3isp/ispccdc.c index 471ae7cdb813..0fbb2aa6dd2c 100644 --- a/drivers/media/platform/omap3isp/ispccdc.c +++ b/drivers/media/platform/omap3isp/ispccdc.c @@ -1312,6 +1312,10 @@ static void __ccdc_enable(struct isp_ccdc_device *ccdc, int enable) { struct isp_device *isp = to_isp_device(ccdc); + /* Avoid restarting the CCDC when streaming is stopping. */ + if (enable && ccdc->stopping & CCDC_STOP_REQUEST) + return; + isp_reg_clr_set(isp, OMAP3_ISP_IOMEM_CCDC, ISPCCDC_PCR, ISPCCDC_PCR_EN, enable ? ISPCCDC_PCR_EN : 0); -- 2.20.1 ^ permalink raw reply related [flat|nested] 8+ messages in thread
* [PATCH 2/7] smiapp: Simplify condition for choosing 8-bit access 2020-02-13 9:49 [PATCH 0/7] smiapp, omap3isp: Cleanups and fixes Sakari Ailus 2020-02-13 9:49 ` [PATCH 1/7] omap3isp: Prevent enabling CCDC when stopping streaming Sakari Ailus @ 2020-02-13 9:49 ` Sakari Ailus 2020-02-13 9:49 ` [PATCH 3/7] smiapp: Use unaligned get and put functions Sakari Ailus ` (4 subsequent siblings) 6 siblings, 0 replies; 8+ messages in thread From: Sakari Ailus @ 2020-02-13 9:49 UTC (permalink / raw) To: linux-media Use the only8 boolean to determine whether 8-bit access is required for reading. Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com> --- drivers/media/i2c/smiapp/smiapp-regs.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/media/i2c/smiapp/smiapp-regs.c b/drivers/media/i2c/smiapp/smiapp-regs.c index ce8c1d47fbf0..cc93a7dbf8a6 100644 --- a/drivers/media/i2c/smiapp/smiapp-regs.c +++ b/drivers/media/i2c/smiapp/smiapp-regs.c @@ -158,7 +158,7 @@ static int __smiapp_read(struct smiapp_sensor *sensor, u32 reg, u32 *val, && len != SMIAPP_REG_32BIT) return -EINVAL; - if (len == SMIAPP_REG_8BIT || !only8) + if (!only8) rval = ____smiapp_read(sensor, SMIAPP_REG_ADDR(reg), len, val); else rval = ____smiapp_read_8only(sensor, SMIAPP_REG_ADDR(reg), len, -- 2.20.1 ^ permalink raw reply related [flat|nested] 8+ messages in thread
* [PATCH 3/7] smiapp: Use unaligned get and put functions 2020-02-13 9:49 [PATCH 0/7] smiapp, omap3isp: Cleanups and fixes Sakari Ailus 2020-02-13 9:49 ` [PATCH 1/7] omap3isp: Prevent enabling CCDC when stopping streaming Sakari Ailus 2020-02-13 9:49 ` [PATCH 2/7] smiapp: Simplify condition for choosing 8-bit access Sakari Ailus @ 2020-02-13 9:49 ` Sakari Ailus 2020-02-13 9:49 ` [PATCH 4/7] smiapp: Turn limit lookup into a function Sakari Ailus ` (3 subsequent siblings) 6 siblings, 0 replies; 8+ messages in thread From: Sakari Ailus @ 2020-02-13 9:49 UTC (permalink / raw) To: linux-media Use get_unaligned_be* and put_unaligned_be* functions to convert register values to CPU endianness. Consequently, two instances of BUG() are removed. Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com> --- drivers/media/i2c/smiapp/smiapp-regs.c | 69 +++++++------------------- 1 file changed, 19 insertions(+), 50 deletions(-) diff --git a/drivers/media/i2c/smiapp/smiapp-regs.c b/drivers/media/i2c/smiapp/smiapp-regs.c index cc93a7dbf8a6..1b58b7c6c839 100644 --- a/drivers/media/i2c/smiapp/smiapp-regs.c +++ b/drivers/media/i2c/smiapp/smiapp-regs.c @@ -8,6 +8,8 @@ * Contact: Sakari Ailus <sakari.ailus@iki.fi> */ +#include <asm/unaligned.h> + #include <linux/delay.h> #include <linux/i2c.h> @@ -69,18 +71,19 @@ static int ____smiapp_read(struct smiapp_sensor *sensor, u16 reg, { struct i2c_client *client = v4l2_get_subdevdata(&sensor->src->sd); struct i2c_msg msg; - unsigned char data[4]; - u16 offset = reg; + unsigned char data_buf[sizeof(u32)] = { 0 }; + unsigned char offset_buf[sizeof(u16)]; int r; + if (len > sizeof(data_buf)) + return -EINVAL; + msg.addr = client->addr; msg.flags = 0; - msg.len = 2; - msg.buf = data; + msg.len = sizeof(offset_buf); + msg.buf = offset_buf; + put_unaligned_be16(reg, offset_buf); - /* high byte goes out first */ - data[0] = (u8) (offset >> 8); - data[1] = (u8) offset; r = i2c_transfer(client->adapter, &msg, 1); if (r != 1) { if (r >= 0) @@ -90,6 +93,8 @@ static int ____smiapp_read(struct smiapp_sensor *sensor, u16 reg, msg.len = len; msg.flags = I2C_M_RD; + msg.buf = &data_buf[sizeof(data_buf) - len]; + r = i2c_transfer(client->adapter, &msg, 1); if (r != 1) { if (r >= 0) @@ -97,27 +102,12 @@ static int ____smiapp_read(struct smiapp_sensor *sensor, u16 reg, goto err; } - *val = 0; - /* high byte comes first */ - switch (len) { - case SMIAPP_REG_32BIT: - *val = (data[0] << 24) + (data[1] << 16) + (data[2] << 8) + - data[3]; - break; - case SMIAPP_REG_16BIT: - *val = (data[0] << 8) + data[1]; - break; - case SMIAPP_REG_8BIT: - *val = data[0]; - break; - default: - BUG(); - } + *val = get_unaligned_be32(data_buf); return 0; err: - dev_err(&client->dev, "read from offset 0x%x error %d\n", offset, r); + dev_err(&client->dev, "read from offset 0x%x error %d\n", reg, r); return r; } @@ -214,13 +204,10 @@ int smiapp_write_no_quirk(struct smiapp_sensor *sensor, u32 reg, u32 val) struct i2c_msg msg; unsigned char data[6]; unsigned int retries; - u8 flags = SMIAPP_REG_FLAGS(reg); u8 len = SMIAPP_REG_WIDTH(reg); - u16 offset = SMIAPP_REG_ADDR(reg); int r; - if ((len != SMIAPP_REG_8BIT && len != SMIAPP_REG_16BIT && - len != SMIAPP_REG_32BIT) || flags) + if (len > sizeof(data) - 2) return -EINVAL; msg.addr = client->addr; @@ -228,27 +215,8 @@ int smiapp_write_no_quirk(struct smiapp_sensor *sensor, u32 reg, u32 val) msg.len = 2 + len; msg.buf = data; - /* high byte goes out first */ - data[0] = (u8) (reg >> 8); - data[1] = (u8) (reg & 0xff); - - switch (len) { - case SMIAPP_REG_8BIT: - data[2] = val; - break; - case SMIAPP_REG_16BIT: - data[2] = val >> 8; - data[3] = val; - break; - case SMIAPP_REG_32BIT: - data[2] = val >> 24; - data[3] = val >> 16; - data[4] = val >> 8; - data[5] = val; - break; - default: - BUG(); - } + put_unaligned_be16(SMIAPP_REG_ADDR(reg), data); + put_unaligned_be32(val << (8 * (sizeof(val) - len)), data + 2); for (retries = 0; retries < 5; retries++) { /* @@ -269,7 +237,8 @@ int smiapp_write_no_quirk(struct smiapp_sensor *sensor, u32 reg, u32 val) } dev_err(&client->dev, - "wrote 0x%x to offset 0x%x error %d\n", val, offset, r); + "wrote 0x%x to offset 0x%x error %d\n", val, + SMIAPP_REG_ADDR(reg), r); return r; } -- 2.20.1 ^ permalink raw reply related [flat|nested] 8+ messages in thread
* [PATCH 4/7] smiapp: Turn limit lookup into a function 2020-02-13 9:49 [PATCH 0/7] smiapp, omap3isp: Cleanups and fixes Sakari Ailus ` (2 preceding siblings ...) 2020-02-13 9:49 ` [PATCH 3/7] smiapp: Use unaligned get and put functions Sakari Ailus @ 2020-02-13 9:49 ` Sakari Ailus 2020-02-13 9:49 ` [PATCH 5/7] smiapp: Move SMIA limit reading up Sakari Ailus ` (2 subsequent siblings) 6 siblings, 0 replies; 8+ messages in thread From: Sakari Ailus @ 2020-02-13 9:49 UTC (permalink / raw) To: linux-media Instead of direct array access, turn accessing limit information into a function. Going forward, more laborate CCS limits will replace most SMIA limits, and conversion will be less complicated this way. Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com> --- drivers/media/i2c/smiapp/smiapp-core.c | 193 +++++++++++++------------ 1 file changed, 102 insertions(+), 91 deletions(-) diff --git a/drivers/media/i2c/smiapp/smiapp-core.c b/drivers/media/i2c/smiapp/smiapp-core.c index a80d7701b519..26422fb571ec 100644 --- a/drivers/media/i2c/smiapp/smiapp-core.c +++ b/drivers/media/i2c/smiapp/smiapp-core.c @@ -57,6 +57,18 @@ static const struct smiapp_module_ident smiapp_module_idents[] = { * */ +static u32 smiapp_get_limit(struct smiapp_sensor *sensor, + unsigned int limit) +{ + if (WARN_ON(limit >= SMIAPP_LIMIT_LAST)) + return 1; + + return sensor->limits[limit]; +} + +#define SMIA_LIM(sensor, limit) \ + smiapp_get_limit(sensor, SMIAPP_LIMIT_##limit) + static int smiapp_read_frame_fmt(struct smiapp_sensor *sensor) { struct i2c_client *client = v4l2_get_subdevdata(&sensor->src->sd); @@ -240,35 +252,35 @@ static int smiapp_pll_try(struct smiapp_sensor *sensor, { struct i2c_client *client = v4l2_get_subdevdata(&sensor->src->sd); struct smiapp_pll_limits lim = { - .min_pre_pll_clk_div = sensor->limits[SMIAPP_LIMIT_MIN_PRE_PLL_CLK_DIV], - .max_pre_pll_clk_div = sensor->limits[SMIAPP_LIMIT_MAX_PRE_PLL_CLK_DIV], - .min_pll_ip_freq_hz = sensor->limits[SMIAPP_LIMIT_MIN_PLL_IP_FREQ_HZ], - .max_pll_ip_freq_hz = sensor->limits[SMIAPP_LIMIT_MAX_PLL_IP_FREQ_HZ], - .min_pll_multiplier = sensor->limits[SMIAPP_LIMIT_MIN_PLL_MULTIPLIER], - .max_pll_multiplier = sensor->limits[SMIAPP_LIMIT_MAX_PLL_MULTIPLIER], - .min_pll_op_freq_hz = sensor->limits[SMIAPP_LIMIT_MIN_PLL_OP_FREQ_HZ], - .max_pll_op_freq_hz = sensor->limits[SMIAPP_LIMIT_MAX_PLL_OP_FREQ_HZ], - - .op.min_sys_clk_div = sensor->limits[SMIAPP_LIMIT_MIN_OP_SYS_CLK_DIV], - .op.max_sys_clk_div = sensor->limits[SMIAPP_LIMIT_MAX_OP_SYS_CLK_DIV], - .op.min_pix_clk_div = sensor->limits[SMIAPP_LIMIT_MIN_OP_PIX_CLK_DIV], - .op.max_pix_clk_div = sensor->limits[SMIAPP_LIMIT_MAX_OP_PIX_CLK_DIV], - .op.min_sys_clk_freq_hz = sensor->limits[SMIAPP_LIMIT_MIN_OP_SYS_CLK_FREQ_HZ], - .op.max_sys_clk_freq_hz = sensor->limits[SMIAPP_LIMIT_MAX_OP_SYS_CLK_FREQ_HZ], - .op.min_pix_clk_freq_hz = sensor->limits[SMIAPP_LIMIT_MIN_OP_PIX_CLK_FREQ_HZ], - .op.max_pix_clk_freq_hz = sensor->limits[SMIAPP_LIMIT_MAX_OP_PIX_CLK_FREQ_HZ], - - .vt.min_sys_clk_div = sensor->limits[SMIAPP_LIMIT_MIN_VT_SYS_CLK_DIV], - .vt.max_sys_clk_div = sensor->limits[SMIAPP_LIMIT_MAX_VT_SYS_CLK_DIV], - .vt.min_pix_clk_div = sensor->limits[SMIAPP_LIMIT_MIN_VT_PIX_CLK_DIV], - .vt.max_pix_clk_div = sensor->limits[SMIAPP_LIMIT_MAX_VT_PIX_CLK_DIV], - .vt.min_sys_clk_freq_hz = sensor->limits[SMIAPP_LIMIT_MIN_VT_SYS_CLK_FREQ_HZ], - .vt.max_sys_clk_freq_hz = sensor->limits[SMIAPP_LIMIT_MAX_VT_SYS_CLK_FREQ_HZ], - .vt.min_pix_clk_freq_hz = sensor->limits[SMIAPP_LIMIT_MIN_VT_PIX_CLK_FREQ_HZ], - .vt.max_pix_clk_freq_hz = sensor->limits[SMIAPP_LIMIT_MAX_VT_PIX_CLK_FREQ_HZ], - - .min_line_length_pck_bin = sensor->limits[SMIAPP_LIMIT_MIN_LINE_LENGTH_PCK_BIN], - .min_line_length_pck = sensor->limits[SMIAPP_LIMIT_MIN_LINE_LENGTH_PCK], + .min_pre_pll_clk_div = SMIA_LIM(sensor, MIN_PRE_PLL_CLK_DIV), + .max_pre_pll_clk_div = SMIA_LIM(sensor, MAX_PRE_PLL_CLK_DIV), + .min_pll_ip_freq_hz = SMIA_LIM(sensor, MIN_PLL_IP_FREQ_HZ), + .max_pll_ip_freq_hz = SMIA_LIM(sensor, MAX_PLL_IP_FREQ_HZ), + .min_pll_multiplier = SMIA_LIM(sensor, MIN_PLL_MULTIPLIER), + .max_pll_multiplier = SMIA_LIM(sensor, MAX_PLL_MULTIPLIER), + .min_pll_op_freq_hz = SMIA_LIM(sensor, MIN_PLL_OP_FREQ_HZ), + .max_pll_op_freq_hz = SMIA_LIM(sensor, MAX_PLL_OP_FREQ_HZ), + + .op.min_sys_clk_div = SMIA_LIM(sensor, MIN_OP_SYS_CLK_DIV), + .op.max_sys_clk_div = SMIA_LIM(sensor, MAX_OP_SYS_CLK_DIV), + .op.min_pix_clk_div = SMIA_LIM(sensor, MIN_OP_PIX_CLK_DIV), + .op.max_pix_clk_div = SMIA_LIM(sensor, MAX_OP_PIX_CLK_DIV), + .op.min_sys_clk_freq_hz = SMIA_LIM(sensor, MIN_OP_SYS_CLK_FREQ_HZ), + .op.max_sys_clk_freq_hz = SMIA_LIM(sensor, MAX_OP_SYS_CLK_FREQ_HZ), + .op.min_pix_clk_freq_hz = SMIA_LIM(sensor, MIN_OP_PIX_CLK_FREQ_HZ), + .op.max_pix_clk_freq_hz = SMIA_LIM(sensor, MAX_OP_PIX_CLK_FREQ_HZ), + + .vt.min_sys_clk_div = SMIA_LIM(sensor, MIN_VT_SYS_CLK_DIV), + .vt.max_sys_clk_div = SMIA_LIM(sensor, MAX_VT_SYS_CLK_DIV), + .vt.min_pix_clk_div = SMIA_LIM(sensor, MIN_VT_PIX_CLK_DIV), + .vt.max_pix_clk_div = SMIA_LIM(sensor, MAX_VT_PIX_CLK_DIV), + .vt.min_sys_clk_freq_hz = SMIA_LIM(sensor, MIN_VT_SYS_CLK_FREQ_HZ), + .vt.max_sys_clk_freq_hz = SMIA_LIM(sensor, MAX_VT_SYS_CLK_FREQ_HZ), + .vt.min_pix_clk_freq_hz = SMIA_LIM(sensor, MIN_VT_PIX_CLK_FREQ_HZ), + .vt.max_pix_clk_freq_hz = SMIA_LIM(sensor, MAX_VT_PIX_CLK_FREQ_HZ), + + .min_line_length_pck_bin = SMIA_LIM(sensor, MIN_LINE_LENGTH_PCK_BIN), + .min_line_length_pck = SMIA_LIM(sensor, MIN_LINE_LENGTH_PCK), }; return smiapp_pll_calculate(&client->dev, &lim, pll); @@ -311,7 +323,7 @@ static void __smiapp_update_exposure_limits(struct smiapp_sensor *sensor) max = sensor->pixel_array->crop[SMIAPP_PA_PAD_SRC].height + sensor->vblank->val - - sensor->limits[SMIAPP_LIMIT_COARSE_INTEGRATION_TIME_MAX_MARGIN]; + - SMIA_LIM(sensor, COARSE_INTEGRATION_TIME_MAX_MARGIN); __v4l2_ctrl_modify_range(ctrl, ctrl->minimum, max, ctrl->step, max); } @@ -568,10 +580,10 @@ static int smiapp_init_controls(struct smiapp_sensor *sensor) sensor->analog_gain = v4l2_ctrl_new_std( &sensor->pixel_array->ctrl_handler, &smiapp_ctrl_ops, V4L2_CID_ANALOGUE_GAIN, - sensor->limits[SMIAPP_LIMIT_ANALOGUE_GAIN_CODE_MIN], - sensor->limits[SMIAPP_LIMIT_ANALOGUE_GAIN_CODE_MAX], - max(sensor->limits[SMIAPP_LIMIT_ANALOGUE_GAIN_CODE_STEP], 1U), - sensor->limits[SMIAPP_LIMIT_ANALOGUE_GAIN_CODE_MIN]); + SMIA_LIM(sensor, ANALOGUE_GAIN_CODE_MIN), + SMIA_LIM(sensor, ANALOGUE_GAIN_CODE_MAX), + max(SMIA_LIM(sensor, ANALOGUE_GAIN_CODE_STEP), 1U), + SMIA_LIM(sensor, ANALOGUE_GAIN_CODE_MIN)); /* Exposure limits will be updated soon, use just something here. */ sensor->exposure = v4l2_ctrl_new_std( @@ -710,7 +722,7 @@ static int smiapp_get_all_limits(struct smiapp_sensor *sensor) return rval; } - if (sensor->limits[SMIAPP_LIMIT_SCALER_N_MIN] == 0) + if (SMIA_LIM(sensor, SCALER_N_MIN) == 0) smiapp_replace_limit(sensor, SMIAPP_LIMIT_SCALER_N_MIN, 16); return 0; @@ -869,21 +881,21 @@ static void smiapp_update_blanking(struct smiapp_sensor *sensor) int min, max; if (sensor->binning_vertical > 1 || sensor->binning_horizontal > 1) { - min_fll = sensor->limits[SMIAPP_LIMIT_MIN_FRAME_LENGTH_LINES_BIN]; - max_fll = sensor->limits[SMIAPP_LIMIT_MAX_FRAME_LENGTH_LINES_BIN]; - min_llp = sensor->limits[SMIAPP_LIMIT_MIN_LINE_LENGTH_PCK_BIN]; - max_llp = sensor->limits[SMIAPP_LIMIT_MAX_LINE_LENGTH_PCK_BIN]; - min_lbp = sensor->limits[SMIAPP_LIMIT_MIN_LINE_BLANKING_PCK_BIN]; + min_fll = SMIA_LIM(sensor, MIN_FRAME_LENGTH_LINES_BIN); + max_fll = SMIA_LIM(sensor, MAX_FRAME_LENGTH_LINES_BIN); + min_llp = SMIA_LIM(sensor, MIN_LINE_LENGTH_PCK_BIN); + max_llp = SMIA_LIM(sensor, MAX_LINE_LENGTH_PCK_BIN); + min_lbp = SMIA_LIM(sensor, MIN_LINE_BLANKING_PCK_BIN); } else { - min_fll = sensor->limits[SMIAPP_LIMIT_MIN_FRAME_LENGTH_LINES]; - max_fll = sensor->limits[SMIAPP_LIMIT_MAX_FRAME_LENGTH_LINES]; - min_llp = sensor->limits[SMIAPP_LIMIT_MIN_LINE_LENGTH_PCK]; - max_llp = sensor->limits[SMIAPP_LIMIT_MAX_LINE_LENGTH_PCK]; - min_lbp = sensor->limits[SMIAPP_LIMIT_MIN_LINE_BLANKING_PCK]; + min_fll = SMIA_LIM(sensor, MIN_FRAME_LENGTH_LINES); + max_fll = SMIA_LIM(sensor, MAX_FRAME_LENGTH_LINES); + min_llp = SMIA_LIM(sensor, MIN_LINE_LENGTH_PCK); + max_llp = SMIA_LIM(sensor, MAX_LINE_LENGTH_PCK); + min_lbp = SMIA_LIM(sensor, MIN_LINE_BLANKING_PCK); } min = max_t(int, - sensor->limits[SMIAPP_LIMIT_MIN_FRAME_BLANKING_LINES], + SMIA_LIM(sensor, MIN_FRAME_BLANKING_LINES), min_fll - sensor->pixel_array->crop[SMIAPP_PA_PAD_SRC].height); max = max_fll - sensor->pixel_array->crop[SMIAPP_PA_PAD_SRC].height; @@ -961,7 +973,7 @@ static int smiapp_read_nvm_page(struct smiapp_sensor *sensor, u32 p, u8 *nvm, return -ENODATA; } - if (sensor->limits[SMIAPP_LIMIT_DATA_TRANSFER_IF_CAPABILITY] & + if (SMIA_LIM(sensor, DATA_TRANSFER_IF_CAPABILITY) & SMIAPP_DATA_TRANSFER_IF_CAPABILITY_POLL) { for (i = 1000; i > 0; i--) { if (s & SMIAPP_DATA_TRANSFER_IF_1_STATUS_RD_READY) @@ -1416,7 +1428,7 @@ static int smiapp_start_streaming(struct smiapp_sensor *sensor) */ /* Digital crop */ - if (sensor->limits[SMIAPP_LIMIT_DIGITAL_CROP_CAPABILITY] + if (SMIA_LIM(sensor, DIGITAL_CROP_CAPABILITY) == SMIAPP_DIGITAL_CROP_CAPABILITY_INPUT_CROP) { rval = smiapp_write( sensor, SMIAPP_REG_U16_DIGITAL_CROP_X_OFFSET, @@ -1444,7 +1456,7 @@ static int smiapp_start_streaming(struct smiapp_sensor *sensor) } /* Scaling */ - if (sensor->limits[SMIAPP_LIMIT_SCALING_CAPABILITY] + if (SMIA_LIM(sensor, SCALING_CAPABILITY) != SMIAPP_SCALING_CAPABILITY_NONE) { rval = smiapp_write(sensor, SMIAPP_REG_U16_SCALING_MODE, sensor->scaling_mode); @@ -1467,7 +1479,7 @@ static int smiapp_start_streaming(struct smiapp_sensor *sensor) if (rval < 0) goto out; - if ((sensor->limits[SMIAPP_LIMIT_FLASH_MODE_CAPABILITY] & + if ((SMIA_LIM(sensor, FLASH_MODE_CAPABILITY) & (SMIAPP_FLASH_MODE_CAPABILITY_SINGLE_STROBE | SMIAPP_FLASH_MODE_CAPABILITY_MULTIPLE_STROBE)) && sensor->hwcfg->strobe_setup != NULL && @@ -1715,8 +1727,7 @@ static void smiapp_propagate(struct v4l2_subdev *subdev, if (which == V4L2_SUBDEV_FORMAT_ACTIVE) { if (ssd == sensor->scaler) { sensor->scale_m = - sensor->limits[ - SMIAPP_LIMIT_SCALER_N_MIN]; + SMIA_LIM(sensor, SCALER_N_MIN); sensor->scaling_mode = SMIAPP_SCALING_MODE_NONE; } else if (ssd == sensor->binner) { @@ -1828,12 +1839,12 @@ static int smiapp_set_format(struct v4l2_subdev *subdev, fmt->format.width = clamp(fmt->format.width, - sensor->limits[SMIAPP_LIMIT_MIN_X_OUTPUT_SIZE], - sensor->limits[SMIAPP_LIMIT_MAX_X_OUTPUT_SIZE]); + SMIA_LIM(sensor, MIN_X_OUTPUT_SIZE), + SMIA_LIM(sensor, MAX_X_OUTPUT_SIZE)); fmt->format.height = clamp(fmt->format.height, - sensor->limits[SMIAPP_LIMIT_MIN_Y_OUTPUT_SIZE], - sensor->limits[SMIAPP_LIMIT_MAX_Y_OUTPUT_SIZE]); + SMIA_LIM(sensor, MIN_Y_OUTPUT_SIZE), + SMIA_LIM(sensor, MAX_Y_OUTPUT_SIZE)); smiapp_get_crop_compose(subdev, cfg, crops, NULL, fmt->which); @@ -1886,7 +1897,7 @@ static int scaling_goodness(struct v4l2_subdev *subdev, int w, int ask_w, val -= abs(w - ask_w); val -= abs(h - ask_h); - if (w < sensor->limits[SMIAPP_LIMIT_MIN_X_OUTPUT_SIZE]) + if (w < SMIA_LIM(sensor, MIN_X_OUTPUT_SIZE)) val -= SCALING_GOODNESS_EXTREME; dev_dbg(&client->dev, "w %d ask_w %d h %d ask_h %d goodness %d\n", @@ -1952,7 +1963,7 @@ static void smiapp_set_compose_scaler(struct v4l2_subdev *subdev, struct i2c_client *client = v4l2_get_subdevdata(subdev); struct smiapp_sensor *sensor = to_smiapp_sensor(subdev); u32 min, max, a, b, max_m; - u32 scale_m = sensor->limits[SMIAPP_LIMIT_SCALER_N_MIN]; + u32 scale_m = SMIA_LIM(sensor, SCALER_N_MIN); int mode = SMIAPP_SCALING_MODE_HORIZONTAL; u32 try[4]; u32 ntry = 0; @@ -1965,19 +1976,19 @@ static void smiapp_set_compose_scaler(struct v4l2_subdev *subdev, crops[SMIAPP_PAD_SINK]->height); a = crops[SMIAPP_PAD_SINK]->width - * sensor->limits[SMIAPP_LIMIT_SCALER_N_MIN] / sel->r.width; + * SMIA_LIM(sensor, SCALER_N_MIN) / sel->r.width; b = crops[SMIAPP_PAD_SINK]->height - * sensor->limits[SMIAPP_LIMIT_SCALER_N_MIN] / sel->r.height; + * SMIA_LIM(sensor, SCALER_N_MIN) / sel->r.height; max_m = crops[SMIAPP_PAD_SINK]->width - * sensor->limits[SMIAPP_LIMIT_SCALER_N_MIN] - / sensor->limits[SMIAPP_LIMIT_MIN_X_OUTPUT_SIZE]; + * SMIA_LIM(sensor, SCALER_N_MIN) + / SMIA_LIM(sensor, MIN_X_OUTPUT_SIZE); - a = clamp(a, sensor->limits[SMIAPP_LIMIT_SCALER_M_MIN], - sensor->limits[SMIAPP_LIMIT_SCALER_M_MAX]); - b = clamp(b, sensor->limits[SMIAPP_LIMIT_SCALER_M_MIN], - sensor->limits[SMIAPP_LIMIT_SCALER_M_MAX]); - max_m = clamp(max_m, sensor->limits[SMIAPP_LIMIT_SCALER_M_MIN], - sensor->limits[SMIAPP_LIMIT_SCALER_M_MAX]); + a = clamp(a, SMIA_LIM(sensor, SCALER_M_MIN), + SMIA_LIM(sensor, SCALER_M_MAX)); + b = clamp(b, SMIA_LIM(sensor, SCALER_M_MIN), + SMIA_LIM(sensor, SCALER_M_MAX)); + max_m = clamp(max_m, SMIA_LIM(sensor, SCALER_M_MIN), + SMIA_LIM(sensor, SCALER_M_MAX)); dev_dbg(&client->dev, "scaling: a %d b %d max_m %d\n", a, b, max_m); @@ -2004,7 +2015,7 @@ static void smiapp_set_compose_scaler(struct v4l2_subdev *subdev, subdev, crops[SMIAPP_PAD_SINK]->width / try[i] - * sensor->limits[SMIAPP_LIMIT_SCALER_N_MIN], + * SMIA_LIM(sensor, SCALER_N_MIN), sel->r.width, crops[SMIAPP_PAD_SINK]->height, sel->r.height, @@ -2018,18 +2029,18 @@ static void smiapp_set_compose_scaler(struct v4l2_subdev *subdev, best = this; } - if (sensor->limits[SMIAPP_LIMIT_SCALING_CAPABILITY] + if (SMIA_LIM(sensor, SCALING_CAPABILITY) == SMIAPP_SCALING_CAPABILITY_HORIZONTAL) continue; this = scaling_goodness( subdev, crops[SMIAPP_PAD_SINK]->width / try[i] - * sensor->limits[SMIAPP_LIMIT_SCALER_N_MIN], + * SMIA_LIM(sensor, SCALER_N_MIN), sel->r.width, crops[SMIAPP_PAD_SINK]->height / try[i] - * sensor->limits[SMIAPP_LIMIT_SCALER_N_MIN], + * SMIA_LIM(sensor, SCALER_N_MIN), sel->r.height, sel->flags); @@ -2043,12 +2054,12 @@ static void smiapp_set_compose_scaler(struct v4l2_subdev *subdev, sel->r.width = (crops[SMIAPP_PAD_SINK]->width / scale_m - * sensor->limits[SMIAPP_LIMIT_SCALER_N_MIN]) & ~1; + * SMIA_LIM(sensor, SCALER_N_MIN)) & ~1; if (mode == SMIAPP_SCALING_MODE_BOTH) sel->r.height = (crops[SMIAPP_PAD_SINK]->height / scale_m - * sensor->limits[SMIAPP_LIMIT_SCALER_N_MIN]) + * SMIA_LIM(sensor, SCALER_N_MIN)) & ~1; else sel->r.height = crops[SMIAPP_PAD_SINK]->height; @@ -2104,7 +2115,7 @@ static int __smiapp_sel_supported(struct v4l2_subdev *subdev, return 0; if (ssd == sensor->scaler && sel->pad == SMIAPP_PAD_SINK - && sensor->limits[SMIAPP_LIMIT_DIGITAL_CROP_CAPABILITY] + && SMIA_LIM(sensor, DIGITAL_CROP_CAPABILITY) == SMIAPP_DIGITAL_CROP_CAPABILITY_INPUT_CROP) return 0; return -EINVAL; @@ -2120,7 +2131,7 @@ static int __smiapp_sel_supported(struct v4l2_subdev *subdev, if (ssd == sensor->binner) return 0; if (ssd == sensor->scaler - && sensor->limits[SMIAPP_LIMIT_SCALING_CAPABILITY] + && SMIA_LIM(sensor, SCALING_CAPABILITY) != SMIAPP_SCALING_CAPABILITY_NONE) return 0; /* Fall through */ @@ -2185,8 +2196,8 @@ static void smiapp_get_native_size(struct smiapp_subdev *ssd, { r->top = 0; r->left = 0; - r->width = ssd->sensor->limits[SMIAPP_LIMIT_X_ADDR_MAX] + 1; - r->height = ssd->sensor->limits[SMIAPP_LIMIT_Y_ADDR_MAX] + 1; + r->width = SMIA_LIM(ssd->sensor, X_ADDR_MAX) + 1; + r->height = SMIA_LIM(ssd->sensor, Y_ADDR_MAX) + 1; } static int __smiapp_get_selection(struct v4l2_subdev *subdev, @@ -2271,10 +2282,10 @@ static int smiapp_set_selection(struct v4l2_subdev *subdev, sel->r.height = SMIAPP_ALIGN_DIM(sel->r.height, sel->flags); sel->r.width = max_t(unsigned int, - sensor->limits[SMIAPP_LIMIT_MIN_X_OUTPUT_SIZE], + SMIA_LIM(sensor, MIN_X_OUTPUT_SIZE), sel->r.width); sel->r.height = max_t(unsigned int, - sensor->limits[SMIAPP_LIMIT_MIN_Y_OUTPUT_SIZE], + SMIA_LIM(sensor, MIN_Y_OUTPUT_SIZE), sel->r.height); switch (sel->target) { @@ -2963,7 +2974,7 @@ static int smiapp_probe(struct i2c_client *client) goto out_power_off; } - if (sensor->limits[SMIAPP_LIMIT_BINNING_CAPABILITY]) { + if (SMIA_LIM(sensor, BINNING_CAPABILITY)) { u32 val; rval = smiapp_read(sensor, @@ -3000,7 +3011,7 @@ static int smiapp_probe(struct i2c_client *client) } if (sensor->minfo.smiapp_version && - sensor->limits[SMIAPP_LIMIT_DATA_TRANSFER_IF_CAPABILITY] & + SMIA_LIM(sensor, DATA_TRANSFER_IF_CAPABILITY) & SMIAPP_DATA_TRANSFER_IF_CAPABILITY_SUPPORTED) { if (device_create_file(&client->dev, &dev_attr_nvm) != 0) { dev_err(&client->dev, "sysfs nvm entry failed\n"); @@ -3010,21 +3021,21 @@ static int smiapp_probe(struct i2c_client *client) } /* We consider this as profile 0 sensor if any of these are zero. */ - if (!sensor->limits[SMIAPP_LIMIT_MIN_OP_SYS_CLK_DIV] || - !sensor->limits[SMIAPP_LIMIT_MAX_OP_SYS_CLK_DIV] || - !sensor->limits[SMIAPP_LIMIT_MIN_OP_PIX_CLK_DIV] || - !sensor->limits[SMIAPP_LIMIT_MAX_OP_PIX_CLK_DIV]) { + if (!SMIA_LIM(sensor, MIN_OP_SYS_CLK_DIV) || + !SMIA_LIM(sensor, MAX_OP_SYS_CLK_DIV) || + !SMIA_LIM(sensor, MIN_OP_PIX_CLK_DIV) || + !SMIA_LIM(sensor, MAX_OP_PIX_CLK_DIV)) { sensor->minfo.smiapp_profile = SMIAPP_PROFILE_0; - } else if (sensor->limits[SMIAPP_LIMIT_SCALING_CAPABILITY] + } else if (SMIA_LIM(sensor, SCALING_CAPABILITY) != SMIAPP_SCALING_CAPABILITY_NONE) { - if (sensor->limits[SMIAPP_LIMIT_SCALING_CAPABILITY] + if (SMIA_LIM(sensor, SCALING_CAPABILITY) == SMIAPP_SCALING_CAPABILITY_HORIZONTAL) sensor->minfo.smiapp_profile = SMIAPP_PROFILE_1; else sensor->minfo.smiapp_profile = SMIAPP_PROFILE_2; sensor->scaler = &sensor->ssds[sensor->ssds_used]; sensor->ssds_used++; - } else if (sensor->limits[SMIAPP_LIMIT_DIGITAL_CROP_CAPABILITY] + } else if (SMIA_LIM(sensor, DIGITAL_CROP_CAPABILITY) == SMIAPP_DIGITAL_CROP_CAPABILITY_INPUT_CROP) { sensor->scaler = &sensor->ssds[sensor->ssds_used]; sensor->ssds_used++; @@ -3034,13 +3045,13 @@ static int smiapp_probe(struct i2c_client *client) sensor->pixel_array = &sensor->ssds[sensor->ssds_used]; sensor->ssds_used++; - sensor->scale_m = sensor->limits[SMIAPP_LIMIT_SCALER_N_MIN]; + sensor->scale_m = SMIA_LIM(sensor, SCALER_N_MIN); /* prepare PLL configuration input values */ sensor->pll.bus_type = SMIAPP_PLL_BUS_TYPE_CSI2; sensor->pll.csi2.lanes = sensor->hwcfg->lanes; sensor->pll.ext_clk_freq_hz = sensor->hwcfg->ext_clk; - sensor->pll.scale_n = sensor->limits[SMIAPP_LIMIT_SCALER_N_MIN]; + sensor->pll.scale_n = SMIA_LIM(sensor, SCALER_N_MIN); /* Profile 0 sensors have no separate OP clock branch. */ if (sensor->minfo.smiapp_profile == SMIAPP_PROFILE_0) sensor->pll.flags |= SMIAPP_PLL_FLAG_NO_OP_CLOCKS; -- 2.20.1 ^ permalink raw reply related [flat|nested] 8+ messages in thread
* [PATCH 5/7] smiapp: Move SMIA limit reading up 2020-02-13 9:49 [PATCH 0/7] smiapp, omap3isp: Cleanups and fixes Sakari Ailus ` (3 preceding siblings ...) 2020-02-13 9:49 ` [PATCH 4/7] smiapp: Turn limit lookup into a function Sakari Ailus @ 2020-02-13 9:49 ` Sakari Ailus 2020-02-13 9:49 ` [PATCH 6/7] smiapp: Refactor reading SMIA limits Sakari Ailus 2020-02-13 9:49 ` [PATCH 7/7] smiapp: Move definitions under driver directory Sakari Ailus 6 siblings, 0 replies; 8+ messages in thread From: Sakari Ailus @ 2020-02-13 9:49 UTC (permalink / raw) To: linux-media Move SMIA limit reading up, where other limit and capability handling takes place. Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com> --- drivers/media/i2c/smiapp/smiapp-core.c | 78 +++++++++++++------------- 1 file changed, 39 insertions(+), 39 deletions(-) diff --git a/drivers/media/i2c/smiapp/smiapp-core.c b/drivers/media/i2c/smiapp/smiapp-core.c index 26422fb571ec..a6800e5c495d 100644 --- a/drivers/media/i2c/smiapp/smiapp-core.c +++ b/drivers/media/i2c/smiapp/smiapp-core.c @@ -69,6 +69,45 @@ static u32 smiapp_get_limit(struct smiapp_sensor *sensor, #define SMIA_LIM(sensor, limit) \ smiapp_get_limit(sensor, SMIAPP_LIMIT_##limit) +static int smiapp_get_limits(struct smiapp_sensor *sensor, int const *limit, + unsigned int n) +{ + struct i2c_client *client = v4l2_get_subdevdata(&sensor->src->sd); + unsigned int i; + u32 val; + int rval; + + for (i = 0; i < n; i++) { + rval = smiapp_read( + sensor, smiapp_reg_limits[limit[i]].addr, &val); + if (rval) + return rval; + sensor->limits[limit[i]] = val; + dev_dbg(&client->dev, "0x%8.8x \"%s\" = %u, 0x%x\n", + smiapp_reg_limits[limit[i]].addr, + smiapp_reg_limits[limit[i]].what, val, val); + } + + return 0; +} + +static int smiapp_get_all_limits(struct smiapp_sensor *sensor) +{ + unsigned int i; + int rval; + + for (i = 0; i < SMIAPP_LIMIT_LAST; i++) { + rval = smiapp_get_limits(sensor, &i, 1); + if (rval < 0) + return rval; + } + + if (SMIA_LIM(sensor, SCALER_N_MIN) == 0) + smiapp_replace_limit(sensor, SMIAPP_LIMIT_SCALER_N_MIN, 16); + + return 0; +} + static int smiapp_read_frame_fmt(struct smiapp_sensor *sensor) { struct i2c_client *client = v4l2_get_subdevdata(&sensor->src->sd); @@ -689,45 +728,6 @@ static void smiapp_free_controls(struct smiapp_sensor *sensor) v4l2_ctrl_handler_free(&sensor->ssds[i].ctrl_handler); } -static int smiapp_get_limits(struct smiapp_sensor *sensor, int const *limit, - unsigned int n) -{ - struct i2c_client *client = v4l2_get_subdevdata(&sensor->src->sd); - unsigned int i; - u32 val; - int rval; - - for (i = 0; i < n; i++) { - rval = smiapp_read( - sensor, smiapp_reg_limits[limit[i]].addr, &val); - if (rval) - return rval; - sensor->limits[limit[i]] = val; - dev_dbg(&client->dev, "0x%8.8x \"%s\" = %u, 0x%x\n", - smiapp_reg_limits[limit[i]].addr, - smiapp_reg_limits[limit[i]].what, val, val); - } - - return 0; -} - -static int smiapp_get_all_limits(struct smiapp_sensor *sensor) -{ - unsigned int i; - int rval; - - for (i = 0; i < SMIAPP_LIMIT_LAST; i++) { - rval = smiapp_get_limits(sensor, &i, 1); - if (rval < 0) - return rval; - } - - if (SMIA_LIM(sensor, SCALER_N_MIN) == 0) - smiapp_replace_limit(sensor, SMIAPP_LIMIT_SCALER_N_MIN, 16); - - return 0; -} - static int smiapp_get_mbus_formats(struct smiapp_sensor *sensor) { struct i2c_client *client = v4l2_get_subdevdata(&sensor->src->sd); -- 2.20.1 ^ permalink raw reply related [flat|nested] 8+ messages in thread
* [PATCH 6/7] smiapp: Refactor reading SMIA limits 2020-02-13 9:49 [PATCH 0/7] smiapp, omap3isp: Cleanups and fixes Sakari Ailus ` (4 preceding siblings ...) 2020-02-13 9:49 ` [PATCH 5/7] smiapp: Move SMIA limit reading up Sakari Ailus @ 2020-02-13 9:49 ` Sakari Ailus 2020-02-13 9:49 ` [PATCH 7/7] smiapp: Move definitions under driver directory Sakari Ailus 6 siblings, 0 replies; 8+ messages in thread From: Sakari Ailus @ 2020-02-13 9:49 UTC (permalink / raw) To: linux-media Combine the two trivial functions reading limits into one. Also rename smiapp_get_all_limits() as smiapp_read_all_smia_limits(). Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com> --- drivers/media/i2c/smiapp/smiapp-core.c | 32 ++++++++------------------ 1 file changed, 10 insertions(+), 22 deletions(-) diff --git a/drivers/media/i2c/smiapp/smiapp-core.c b/drivers/media/i2c/smiapp/smiapp-core.c index a6800e5c495d..5e4f6a2ef78e 100644 --- a/drivers/media/i2c/smiapp/smiapp-core.c +++ b/drivers/media/i2c/smiapp/smiapp-core.c @@ -69,37 +69,25 @@ static u32 smiapp_get_limit(struct smiapp_sensor *sensor, #define SMIA_LIM(sensor, limit) \ smiapp_get_limit(sensor, SMIAPP_LIMIT_##limit) -static int smiapp_get_limits(struct smiapp_sensor *sensor, int const *limit, - unsigned int n) +static int smiapp_read_all_smia_limits(struct smiapp_sensor *sensor) { struct i2c_client *client = v4l2_get_subdevdata(&sensor->src->sd); unsigned int i; - u32 val; int rval; - for (i = 0; i < n; i++) { + for (i = 0; i < SMIAPP_LIMIT_LAST; i++) { + u32 val; + rval = smiapp_read( - sensor, smiapp_reg_limits[limit[i]].addr, &val); + sensor, smiapp_reg_limits[i].addr, &val); if (rval) return rval; - sensor->limits[limit[i]] = val; - dev_dbg(&client->dev, "0x%8.8x \"%s\" = %u, 0x%x\n", - smiapp_reg_limits[limit[i]].addr, - smiapp_reg_limits[limit[i]].what, val, val); - } - return 0; -} + sensor->limits[i] = val; -static int smiapp_get_all_limits(struct smiapp_sensor *sensor) -{ - unsigned int i; - int rval; - - for (i = 0; i < SMIAPP_LIMIT_LAST; i++) { - rval = smiapp_get_limits(sensor, &i, 1); - if (rval < 0) - return rval; + dev_dbg(&client->dev, "0x%8.8x \"%s\" = %u, 0x%x\n", + smiapp_reg_limits[i].addr, + smiapp_reg_limits[i].what, val, val); } if (SMIA_LIM(sensor, SCALER_N_MIN) == 0) @@ -2938,7 +2926,7 @@ static int smiapp_probe(struct i2c_client *client) goto out_power_off; } - rval = smiapp_get_all_limits(sensor); + rval = smiapp_read_all_smia_limits(sensor); if (rval) { rval = -ENODEV; goto out_power_off; -- 2.20.1 ^ permalink raw reply related [flat|nested] 8+ messages in thread
* [PATCH 7/7] smiapp: Move definitions under driver directory 2020-02-13 9:49 [PATCH 0/7] smiapp, omap3isp: Cleanups and fixes Sakari Ailus ` (5 preceding siblings ...) 2020-02-13 9:49 ` [PATCH 6/7] smiapp: Refactor reading SMIA limits Sakari Ailus @ 2020-02-13 9:49 ` Sakari Ailus 6 siblings, 0 replies; 8+ messages in thread From: Sakari Ailus @ 2020-02-13 9:49 UTC (permalink / raw) To: linux-media include/media/i2c/smiapp.h was meant to serve systems where the sensor is enumerated through platform data. That's no longer necessary, hopefully not even in out-of-tree use cases. Move the definitions to the appropriate headers. Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com> --- drivers/media/i2c/smiapp/smiapp-reg.h | 4 ++ drivers/media/i2c/smiapp/smiapp.h | 44 ++++++++++++++++++- include/media/i2c/smiapp.h | 63 --------------------------- 3 files changed, 47 insertions(+), 64 deletions(-) delete mode 100644 include/media/i2c/smiapp.h diff --git a/drivers/media/i2c/smiapp/smiapp-reg.h b/drivers/media/i2c/smiapp/smiapp-reg.h index 43505cd0616e..e6f96309786f 100644 --- a/drivers/media/i2c/smiapp/smiapp-reg.h +++ b/drivers/media/i2c/smiapp/smiapp-reg.h @@ -35,6 +35,10 @@ #define SMIAPP_FLASH_MODE_CAPABILITY_SINGLE_STROBE BIT(0) #define SMIAPP_FLASH_MODE_CAPABILITY_MULTIPLE_STROBE BIT(1) +#define SMIAPP_CSI_SIGNALLING_MODE_CCP2_DATA_CLOCK 0 +#define SMIAPP_CSI_SIGNALLING_MODE_CCP2_DATA_STROBE 1 +#define SMIAPP_CSI_SIGNALLING_MODE_CSI2 2 + #define SMIAPP_DPHY_CTRL_AUTOMATIC 0 /* DPHY control based on REQUESTED_LINK_BIT_RATE_MBPS */ #define SMIAPP_DPHY_CTRL_UI 1 diff --git a/drivers/media/i2c/smiapp/smiapp.h b/drivers/media/i2c/smiapp/smiapp.h index 4837d80dc453..6f469934f9e3 100644 --- a/drivers/media/i2c/smiapp/smiapp.h +++ b/drivers/media/i2c/smiapp/smiapp.h @@ -14,7 +14,6 @@ #include <linux/mutex.h> #include <media/v4l2-ctrls.h> #include <media/v4l2-subdev.h> -#include <media/i2c/smiapp.h> #include "smiapp-pll.h" #include "smiapp-reg.h" @@ -42,6 +41,49 @@ #define SMIAPP_COLOUR_COMPONENTS 4 +#define SMIAPP_NAME "smiapp" + +#define SMIAPP_DFL_I2C_ADDR (0x20 >> 1) /* Default I2C Address */ +#define SMIAPP_ALT_I2C_ADDR (0x6e >> 1) /* Alternate I2C Address */ + +/* + * Sometimes due to board layout considerations the camera module can be + * mounted rotated. The typical rotation used is 180 degrees which can be + * corrected by giving a default H-FLIP and V-FLIP in the sensor readout. + * FIXME: rotation also changes the bayer pattern. + */ +enum smiapp_module_board_orient { + SMIAPP_MODULE_BOARD_ORIENT_0 = 0, + SMIAPP_MODULE_BOARD_ORIENT_180, +}; + +struct smiapp_flash_strobe_parms { + u8 mode; + u32 strobe_width_high_us; + u16 strobe_delay; + u16 stobe_start_point; + u8 trigger; +}; + +struct smiapp_hwconfig { + /* + * Change the cci address if i2c_addr_alt is set. + * Both default and alternate cci addr need to be present + */ + unsigned short i2c_addr_dfl; /* Default i2c addr */ + unsigned short i2c_addr_alt; /* Alternate i2c addr */ + + uint32_t ext_clk; /* sensor external clk */ + + unsigned int lanes; /* Number of CSI-2 lanes */ + uint32_t csi_signalling_mode; /* SMIAPP_CSI_SIGNALLING_MODE_* */ + uint64_t *op_sys_clock; + + enum smiapp_module_board_orient module_board_orient; + + struct smiapp_flash_strobe_parms *strobe_setup; +}; + #include "smiapp-limits.h" struct smiapp_quirk; diff --git a/include/media/i2c/smiapp.h b/include/media/i2c/smiapp.h deleted file mode 100644 index 80f8251d87a3..000000000000 --- a/include/media/i2c/smiapp.h +++ /dev/null @@ -1,63 +0,0 @@ -/* SPDX-License-Identifier: GPL-2.0-only */ -/* - * include/media/i2c/smiapp.h - * - * Generic driver for SMIA/SMIA++ compliant camera modules - * - * Copyright (C) 2011--2012 Nokia Corporation - * Contact: Sakari Ailus <sakari.ailus@iki.fi> - */ - -#ifndef __SMIAPP_H_ -#define __SMIAPP_H_ - -#include <media/v4l2-subdev.h> - -#define SMIAPP_NAME "smiapp" - -#define SMIAPP_DFL_I2C_ADDR (0x20 >> 1) /* Default I2C Address */ -#define SMIAPP_ALT_I2C_ADDR (0x6e >> 1) /* Alternate I2C Address */ - -#define SMIAPP_CSI_SIGNALLING_MODE_CCP2_DATA_CLOCK 0 -#define SMIAPP_CSI_SIGNALLING_MODE_CCP2_DATA_STROBE 1 -#define SMIAPP_CSI_SIGNALLING_MODE_CSI2 2 - -/* - * Sometimes due to board layout considerations the camera module can be - * mounted rotated. The typical rotation used is 180 degrees which can be - * corrected by giving a default H-FLIP and V-FLIP in the sensor readout. - * FIXME: rotation also changes the bayer pattern. - */ -enum smiapp_module_board_orient { - SMIAPP_MODULE_BOARD_ORIENT_0 = 0, - SMIAPP_MODULE_BOARD_ORIENT_180, -}; - -struct smiapp_flash_strobe_parms { - u8 mode; - u32 strobe_width_high_us; - u16 strobe_delay; - u16 stobe_start_point; - u8 trigger; -}; - -struct smiapp_hwconfig { - /* - * Change the cci address if i2c_addr_alt is set. - * Both default and alternate cci addr need to be present - */ - unsigned short i2c_addr_dfl; /* Default i2c addr */ - unsigned short i2c_addr_alt; /* Alternate i2c addr */ - - uint32_t ext_clk; /* sensor external clk */ - - unsigned int lanes; /* Number of CSI-2 lanes */ - uint32_t csi_signalling_mode; /* SMIAPP_CSI_SIGNALLING_MODE_* */ - uint64_t *op_sys_clock; - - enum smiapp_module_board_orient module_board_orient; - - struct smiapp_flash_strobe_parms *strobe_setup; -}; - -#endif /* __SMIAPP_H_ */ -- 2.20.1 ^ permalink raw reply related [flat|nested] 8+ messages in thread
end of thread, other threads:[~2020-02-13 9:49 UTC | newest] Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed) -- links below jump to the message on this page -- 2020-02-13 9:49 [PATCH 0/7] smiapp, omap3isp: Cleanups and fixes Sakari Ailus 2020-02-13 9:49 ` [PATCH 1/7] omap3isp: Prevent enabling CCDC when stopping streaming Sakari Ailus 2020-02-13 9:49 ` [PATCH 2/7] smiapp: Simplify condition for choosing 8-bit access Sakari Ailus 2020-02-13 9:49 ` [PATCH 3/7] smiapp: Use unaligned get and put functions Sakari Ailus 2020-02-13 9:49 ` [PATCH 4/7] smiapp: Turn limit lookup into a function Sakari Ailus 2020-02-13 9:49 ` [PATCH 5/7] smiapp: Move SMIA limit reading up Sakari Ailus 2020-02-13 9:49 ` [PATCH 6/7] smiapp: Refactor reading SMIA limits Sakari Ailus 2020-02-13 9:49 ` [PATCH 7/7] smiapp: Move definitions under driver directory Sakari Ailus
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox; as well as URLs for NNTP newsgroup(s).