Commit 0ef7dc30 authored by Laurent Pinchart's avatar Laurent Pinchart Committed by Mauro Carvalho Chehab

media: rkisp1: Swap value and address arguments to rkisp1_write()

While writel() takes the value and address arguments in that order, most
write functions (including in the regmap API) use the opposite
convention. Having the value first is considered confusing, and often
leads to more difficult to read code compared to the opposite convention
where the write call and the register name often fit on a single line:

	rkisp1_write(rkisp1, RKISP1_CIF_THE_REG_NAME,
		     complicate_calculation + for / the_register
		     value + goes | here);

Swap the arguments of the rkisp1_write() function, and use the following
semantic patch to update the callers:

@@
expression rkisp1, value, address;
@@

- rkisp1_write(rkisp1, value, address)
+ rkisp1_write(rkisp1, address, value)

This commit also includes a few additional line break cleanups in the
rkisp1_write() calls, but no other manual change.
Signed-off-by: default avatarLaurent Pinchart <laurent.pinchart@ideasonboard.com>
Reviewed-by: default avatarDafna Hirschfeld <dafna@fastmail.com>
Reviewed-by: default avatarRicardo Ribalda <ribalda@chromium.org>
Signed-off-by: default avatarMauro Carvalho Chehab <mchehab@kernel.org>
parent 3b430c2c
......@@ -383,7 +383,7 @@ static void rkisp1_mi_config_ctrl(struct rkisp1_capture *cap)
mi_ctrl |= RKISP1_CIF_MI_CTRL_INIT_BASE_EN |
RKISP1_CIF_MI_CTRL_INIT_OFFSET_EN;
rkisp1_write(cap->rkisp1, mi_ctrl, RKISP1_CIF_MI_CTRL);
rkisp1_write(cap->rkisp1, RKISP1_CIF_MI_CTRL, mi_ctrl);
}
static u32 rkisp1_pixfmt_comp_size(const struct v4l2_pix_format_mplane *pixm,
......@@ -404,7 +404,7 @@ static void rkisp1_irq_frame_end_enable(struct rkisp1_capture *cap)
u32 mi_imsc = rkisp1_read(cap->rkisp1, RKISP1_CIF_MI_IMSC);
mi_imsc |= RKISP1_CIF_MI_FRAME(cap);
rkisp1_write(cap->rkisp1, mi_imsc, RKISP1_CIF_MI_IMSC);
rkisp1_write(cap->rkisp1, RKISP1_CIF_MI_IMSC, mi_imsc);
}
static void rkisp1_mp_config(struct rkisp1_capture *cap)
......@@ -413,12 +413,12 @@ static void rkisp1_mp_config(struct rkisp1_capture *cap)
struct rkisp1_device *rkisp1 = cap->rkisp1;
u32 reg;
rkisp1_write(rkisp1, rkisp1_pixfmt_comp_size(pixm, RKISP1_PLANE_Y),
cap->config->mi.y_size_init);
rkisp1_write(rkisp1, rkisp1_pixfmt_comp_size(pixm, RKISP1_PLANE_CB),
cap->config->mi.cb_size_init);
rkisp1_write(rkisp1, rkisp1_pixfmt_comp_size(pixm, RKISP1_PLANE_CR),
cap->config->mi.cr_size_init);
rkisp1_write(rkisp1, cap->config->mi.y_size_init,
rkisp1_pixfmt_comp_size(pixm, RKISP1_PLANE_Y));
rkisp1_write(rkisp1, cap->config->mi.cb_size_init,
rkisp1_pixfmt_comp_size(pixm, RKISP1_PLANE_CB));
rkisp1_write(rkisp1, cap->config->mi.cr_size_init,
rkisp1_pixfmt_comp_size(pixm, RKISP1_PLANE_CR));
rkisp1_irq_frame_end_enable(cap);
......@@ -429,7 +429,7 @@ static void rkisp1_mp_config(struct rkisp1_capture *cap)
reg |= RKISP1_CIF_MI_XTD_FMT_CTRL_MP_CB_CR_SWAP;
else
reg &= ~RKISP1_CIF_MI_XTD_FMT_CTRL_MP_CB_CR_SWAP;
rkisp1_write(rkisp1, reg, RKISP1_CIF_MI_XTD_FORMAT_CTRL);
rkisp1_write(rkisp1, RKISP1_CIF_MI_XTD_FORMAT_CTRL, reg);
}
rkisp1_mi_config_ctrl(cap);
......@@ -437,11 +437,11 @@ static void rkisp1_mp_config(struct rkisp1_capture *cap)
reg = rkisp1_read(rkisp1, RKISP1_CIF_MI_CTRL);
reg &= ~RKISP1_MI_CTRL_MP_FMT_MASK;
reg |= cap->pix.cfg->write_format;
rkisp1_write(rkisp1, reg, RKISP1_CIF_MI_CTRL);
rkisp1_write(rkisp1, RKISP1_CIF_MI_CTRL, reg);
reg = rkisp1_read(rkisp1, RKISP1_CIF_MI_CTRL);
reg |= RKISP1_CIF_MI_MP_AUTOUPDATE_ENABLE;
rkisp1_write(rkisp1, reg, RKISP1_CIF_MI_CTRL);
rkisp1_write(rkisp1, RKISP1_CIF_MI_CTRL, reg);
}
static void rkisp1_sp_config(struct rkisp1_capture *cap)
......@@ -450,16 +450,16 @@ static void rkisp1_sp_config(struct rkisp1_capture *cap)
struct rkisp1_device *rkisp1 = cap->rkisp1;
u32 mi_ctrl, reg;
rkisp1_write(rkisp1, rkisp1_pixfmt_comp_size(pixm, RKISP1_PLANE_Y),
cap->config->mi.y_size_init);
rkisp1_write(rkisp1, rkisp1_pixfmt_comp_size(pixm, RKISP1_PLANE_CB),
cap->config->mi.cb_size_init);
rkisp1_write(rkisp1, rkisp1_pixfmt_comp_size(pixm, RKISP1_PLANE_CR),
cap->config->mi.cr_size_init);
rkisp1_write(rkisp1, cap->config->mi.y_size_init,
rkisp1_pixfmt_comp_size(pixm, RKISP1_PLANE_Y));
rkisp1_write(rkisp1, cap->config->mi.cb_size_init,
rkisp1_pixfmt_comp_size(pixm, RKISP1_PLANE_CB));
rkisp1_write(rkisp1, cap->config->mi.cr_size_init,
rkisp1_pixfmt_comp_size(pixm, RKISP1_PLANE_CR));
rkisp1_write(rkisp1, pixm->width, RKISP1_CIF_MI_SP_Y_PIC_WIDTH);
rkisp1_write(rkisp1, pixm->height, RKISP1_CIF_MI_SP_Y_PIC_HEIGHT);
rkisp1_write(rkisp1, cap->sp_y_stride, RKISP1_CIF_MI_SP_Y_LLENGTH);
rkisp1_write(rkisp1, RKISP1_CIF_MI_SP_Y_PIC_WIDTH, pixm->width);
rkisp1_write(rkisp1, RKISP1_CIF_MI_SP_Y_PIC_HEIGHT, pixm->height);
rkisp1_write(rkisp1, RKISP1_CIF_MI_SP_Y_LLENGTH, cap->sp_y_stride);
rkisp1_irq_frame_end_enable(cap);
......@@ -470,7 +470,7 @@ static void rkisp1_sp_config(struct rkisp1_capture *cap)
reg |= RKISP1_CIF_MI_XTD_FMT_CTRL_SP_CB_CR_SWAP;
else
reg &= ~RKISP1_CIF_MI_XTD_FMT_CTRL_SP_CB_CR_SWAP;
rkisp1_write(rkisp1, reg, RKISP1_CIF_MI_XTD_FORMAT_CTRL);
rkisp1_write(rkisp1, RKISP1_CIF_MI_XTD_FORMAT_CTRL, reg);
}
rkisp1_mi_config_ctrl(cap);
......@@ -481,7 +481,7 @@ static void rkisp1_sp_config(struct rkisp1_capture *cap)
RKISP1_MI_CTRL_SP_INPUT_YUV422 |
cap->pix.cfg->output_format |
RKISP1_CIF_MI_SP_AUTOUPDATE_ENABLE;
rkisp1_write(rkisp1, mi_ctrl, RKISP1_CIF_MI_CTRL);
rkisp1_write(rkisp1, RKISP1_CIF_MI_CTRL, mi_ctrl);
}
static void rkisp1_mp_disable(struct rkisp1_capture *cap)
......@@ -490,7 +490,7 @@ static void rkisp1_mp_disable(struct rkisp1_capture *cap)
mi_ctrl &= ~(RKISP1_CIF_MI_CTRL_MP_ENABLE |
RKISP1_CIF_MI_CTRL_RAW_ENABLE);
rkisp1_write(cap->rkisp1, mi_ctrl, RKISP1_CIF_MI_CTRL);
rkisp1_write(cap->rkisp1, RKISP1_CIF_MI_CTRL, mi_ctrl);
}
static void rkisp1_sp_disable(struct rkisp1_capture *cap)
......@@ -498,7 +498,7 @@ static void rkisp1_sp_disable(struct rkisp1_capture *cap)
u32 mi_ctrl = rkisp1_read(cap->rkisp1, RKISP1_CIF_MI_CTRL);
mi_ctrl &= ~RKISP1_CIF_MI_CTRL_SP_ENABLE;
rkisp1_write(cap->rkisp1, mi_ctrl, RKISP1_CIF_MI_CTRL);
rkisp1_write(cap->rkisp1, RKISP1_CIF_MI_CTRL, mi_ctrl);
}
static void rkisp1_mp_enable(struct rkisp1_capture *cap)
......@@ -514,7 +514,7 @@ static void rkisp1_mp_enable(struct rkisp1_capture *cap)
else
mi_ctrl |= RKISP1_CIF_MI_CTRL_MP_ENABLE;
rkisp1_write(cap->rkisp1, mi_ctrl, RKISP1_CIF_MI_CTRL);
rkisp1_write(cap->rkisp1, RKISP1_CIF_MI_CTRL, mi_ctrl);
}
static void rkisp1_sp_enable(struct rkisp1_capture *cap)
......@@ -522,15 +522,14 @@ static void rkisp1_sp_enable(struct rkisp1_capture *cap)
u32 mi_ctrl = rkisp1_read(cap->rkisp1, RKISP1_CIF_MI_CTRL);
mi_ctrl |= RKISP1_CIF_MI_CTRL_SP_ENABLE;
rkisp1_write(cap->rkisp1, mi_ctrl, RKISP1_CIF_MI_CTRL);
rkisp1_write(cap->rkisp1, RKISP1_CIF_MI_CTRL, mi_ctrl);
}
static void rkisp1_mp_sp_stop(struct rkisp1_capture *cap)
{
if (!cap->is_streaming)
return;
rkisp1_write(cap->rkisp1,
RKISP1_CIF_MI_FRAME(cap), RKISP1_CIF_MI_ICR);
rkisp1_write(cap->rkisp1, RKISP1_CIF_MI_ICR, RKISP1_CIF_MI_FRAME(cap));
cap->ops->disable(cap);
}
......@@ -554,7 +553,7 @@ static void rkisp1_mp_set_data_path(struct rkisp1_capture *cap)
dpcl = dpcl | RKISP1_CIF_VI_DPCL_CHAN_MODE_MP |
RKISP1_CIF_VI_DPCL_MP_MUX_MRSZ_MI;
rkisp1_write(cap->rkisp1, dpcl, RKISP1_CIF_VI_DPCL);
rkisp1_write(cap->rkisp1, RKISP1_CIF_VI_DPCL, dpcl);
}
static void rkisp1_sp_set_data_path(struct rkisp1_capture *cap)
......@@ -562,7 +561,7 @@ static void rkisp1_sp_set_data_path(struct rkisp1_capture *cap)
u32 dpcl = rkisp1_read(cap->rkisp1, RKISP1_CIF_VI_DPCL);
dpcl |= RKISP1_CIF_VI_DPCL_CHAN_MODE_SP;
rkisp1_write(cap->rkisp1, dpcl, RKISP1_CIF_VI_DPCL);
rkisp1_write(cap->rkisp1, RKISP1_CIF_VI_DPCL, dpcl);
}
static const struct rkisp1_capture_ops rkisp1_capture_ops_mp = {
......@@ -628,9 +627,8 @@ static void rkisp1_set_next_buf(struct rkisp1_capture *cap)
buff_addr = cap->buf.next->buff_addr;
rkisp1_write(cap->rkisp1,
buff_addr[RKISP1_PLANE_Y],
cap->config->mi.y_base_ad_init);
rkisp1_write(cap->rkisp1, cap->config->mi.y_base_ad_init,
buff_addr[RKISP1_PLANE_Y]);
/*
* In order to support grey format we capture
* YUV422 planar format from the camera and
......@@ -638,39 +636,36 @@ static void rkisp1_set_next_buf(struct rkisp1_capture *cap)
*/
if (cap->pix.cfg->fourcc == V4L2_PIX_FMT_GREY) {
rkisp1_write(cap->rkisp1,
cap->buf.dummy.dma_addr,
cap->config->mi.cb_base_ad_init);
cap->config->mi.cb_base_ad_init,
cap->buf.dummy.dma_addr);
rkisp1_write(cap->rkisp1,
cap->buf.dummy.dma_addr,
cap->config->mi.cr_base_ad_init);
cap->config->mi.cr_base_ad_init,
cap->buf.dummy.dma_addr);
} else {
rkisp1_write(cap->rkisp1,
buff_addr[RKISP1_PLANE_CB],
cap->config->mi.cb_base_ad_init);
cap->config->mi.cb_base_ad_init,
buff_addr[RKISP1_PLANE_CB]);
rkisp1_write(cap->rkisp1,
buff_addr[RKISP1_PLANE_CR],
cap->config->mi.cr_base_ad_init);
cap->config->mi.cr_base_ad_init,
buff_addr[RKISP1_PLANE_CR]);
}
} else {
/*
* Use the dummy space allocated by dma_alloc_coherent to
* throw data if there is no available buffer.
*/
rkisp1_write(cap->rkisp1,
cap->buf.dummy.dma_addr,
cap->config->mi.y_base_ad_init);
rkisp1_write(cap->rkisp1,
cap->buf.dummy.dma_addr,
cap->config->mi.cb_base_ad_init);
rkisp1_write(cap->rkisp1,
cap->buf.dummy.dma_addr,
cap->config->mi.cr_base_ad_init);
rkisp1_write(cap->rkisp1, cap->config->mi.y_base_ad_init,
cap->buf.dummy.dma_addr);
rkisp1_write(cap->rkisp1, cap->config->mi.cb_base_ad_init,
cap->buf.dummy.dma_addr);
rkisp1_write(cap->rkisp1, cap->config->mi.cr_base_ad_init,
cap->buf.dummy.dma_addr);
}
/* Set plane offsets */
rkisp1_write(cap->rkisp1, 0, cap->config->mi.y_offs_cnt_init);
rkisp1_write(cap->rkisp1, 0, cap->config->mi.cb_offs_cnt_init);
rkisp1_write(cap->rkisp1, 0, cap->config->mi.cr_offs_cnt_init);
rkisp1_write(cap->rkisp1, cap->config->mi.y_offs_cnt_init, 0);
rkisp1_write(cap->rkisp1, cap->config->mi.cb_offs_cnt_init, 0);
rkisp1_write(cap->rkisp1, cap->config->mi.cr_offs_cnt_init, 0);
}
/*
......@@ -710,7 +705,7 @@ irqreturn_t rkisp1_capture_isr(int irq, void *ctx)
if (!status)
return IRQ_NONE;
rkisp1_write(rkisp1, status, RKISP1_CIF_MI_ICR);
rkisp1_write(rkisp1, RKISP1_CIF_MI_ICR, status);
for (i = 0; i < ARRAY_SIZE(rkisp1->capture_devs); ++i) {
struct rkisp1_capture *cap = &rkisp1->capture_devs[i];
......@@ -888,8 +883,8 @@ static void rkisp1_cap_stream_enable(struct rkisp1_capture *cap)
*/
if (!other->is_streaming) {
/* force cfg update */
rkisp1_write(rkisp1,
RKISP1_CIF_MI_INIT_SOFT_UPD, RKISP1_CIF_MI_INIT);
rkisp1_write(rkisp1, RKISP1_CIF_MI_INIT,
RKISP1_CIF_MI_INIT_SOFT_UPD);
rkisp1_set_next_buf(cap);
}
spin_unlock_irq(&cap->buf.lock);
......
......@@ -425,7 +425,7 @@ struct rkisp1_isp_mbus_info {
};
static inline void
rkisp1_write(struct rkisp1_device *rkisp1, u32 val, unsigned int addr)
rkisp1_write(struct rkisp1_device *rkisp1, unsigned int addr, u32 val)
{
writel(val, rkisp1->base_addr + addr);
}
......
......@@ -222,7 +222,7 @@ static void rkisp1_dcrop_disable(struct rkisp1_resizer *rsz,
dc_ctrl |= RKISP1_CIF_DUAL_CROP_GEN_CFG_UPD;
else
dc_ctrl |= RKISP1_CIF_DUAL_CROP_CFG_UPD;
rkisp1_write(rsz->rkisp1, dc_ctrl, rsz->config->dual_crop.ctrl);
rkisp1_write(rsz->rkisp1, rsz->config->dual_crop.ctrl, dc_ctrl);
}
/* configure dual-crop unit */
......@@ -247,13 +247,13 @@ static void rkisp1_dcrop_config(struct rkisp1_resizer *rsz)
}
dc_ctrl = rkisp1_read(rkisp1, rsz->config->dual_crop.ctrl);
rkisp1_write(rkisp1, sink_crop->left, rsz->config->dual_crop.h_offset);
rkisp1_write(rkisp1, sink_crop->top, rsz->config->dual_crop.v_offset);
rkisp1_write(rkisp1, sink_crop->width, rsz->config->dual_crop.h_size);
rkisp1_write(rkisp1, sink_crop->height, rsz->config->dual_crop.v_size);
rkisp1_write(rkisp1, rsz->config->dual_crop.h_offset, sink_crop->left);
rkisp1_write(rkisp1, rsz->config->dual_crop.v_offset, sink_crop->top);
rkisp1_write(rkisp1, rsz->config->dual_crop.h_size, sink_crop->width);
rkisp1_write(rkisp1, rsz->config->dual_crop.v_size, sink_crop->height);
dc_ctrl |= rsz->config->dual_crop.yuvmode_mask;
dc_ctrl |= RKISP1_CIF_DUAL_CROP_CFG_UPD;
rkisp1_write(rkisp1, dc_ctrl, rsz->config->dual_crop.ctrl);
rkisp1_write(rkisp1, rsz->config->dual_crop.ctrl, dc_ctrl);
dev_dbg(rkisp1->dev, "stream %d crop: %dx%d -> %dx%d\n", rsz->id,
sink_fmt->width, sink_fmt->height,
......@@ -309,7 +309,7 @@ static void rkisp1_rsz_update_shadow(struct rkisp1_resizer *rsz,
else
ctrl_cfg |= RKISP1_CIF_RSZ_CTRL_CFG_UPD;
rkisp1_write(rsz->rkisp1, ctrl_cfg, rsz->config->rsz.ctrl);
rkisp1_write(rsz->rkisp1, rsz->config->rsz.ctrl, ctrl_cfg);
}
static u32 rkisp1_rsz_calc_ratio(u32 len_sink, u32 len_src)
......@@ -325,7 +325,7 @@ static u32 rkisp1_rsz_calc_ratio(u32 len_sink, u32 len_src)
static void rkisp1_rsz_disable(struct rkisp1_resizer *rsz,
enum rkisp1_shadow_regs_when when)
{
rkisp1_write(rsz->rkisp1, 0, rsz->config->rsz.ctrl);
rkisp1_write(rsz->rkisp1, rsz->config->rsz.ctrl, 0);
if (when == RKISP1_SHADOW_REGS_SYNC)
rkisp1_rsz_update_shadow(rsz, when);
......@@ -343,15 +343,15 @@ static void rkisp1_rsz_config_regs(struct rkisp1_resizer *rsz,
unsigned int i;
/* No phase offset */
rkisp1_write(rkisp1, 0, rsz->config->rsz.phase_hy);
rkisp1_write(rkisp1, 0, rsz->config->rsz.phase_hc);
rkisp1_write(rkisp1, 0, rsz->config->rsz.phase_vy);
rkisp1_write(rkisp1, 0, rsz->config->rsz.phase_vc);
rkisp1_write(rkisp1, rsz->config->rsz.phase_hy, 0);
rkisp1_write(rkisp1, rsz->config->rsz.phase_hc, 0);
rkisp1_write(rkisp1, rsz->config->rsz.phase_vy, 0);
rkisp1_write(rkisp1, rsz->config->rsz.phase_vc, 0);
/* Linear interpolation */
for (i = 0; i < 64; i++) {
rkisp1_write(rkisp1, i, rsz->config->rsz.scale_lut_addr);
rkisp1_write(rkisp1, i, rsz->config->rsz.scale_lut);
rkisp1_write(rkisp1, rsz->config->rsz.scale_lut_addr, i);
rkisp1_write(rkisp1, rsz->config->rsz.scale_lut, i);
}
if (sink_y->width != src_y->width) {
......@@ -359,7 +359,7 @@ static void rkisp1_rsz_config_regs(struct rkisp1_resizer *rsz,
if (sink_y->width < src_y->width)
rsz_ctrl |= RKISP1_CIF_RSZ_CTRL_SCALE_HY_UP;
ratio = rkisp1_rsz_calc_ratio(sink_y->width, src_y->width);
rkisp1_write(rkisp1, ratio, rsz->config->rsz.scale_hy);
rkisp1_write(rkisp1, rsz->config->rsz.scale_hy, ratio);
}
if (sink_c->width != src_c->width) {
......@@ -367,8 +367,8 @@ static void rkisp1_rsz_config_regs(struct rkisp1_resizer *rsz,
if (sink_c->width < src_c->width)
rsz_ctrl |= RKISP1_CIF_RSZ_CTRL_SCALE_HC_UP;
ratio = rkisp1_rsz_calc_ratio(sink_c->width, src_c->width);
rkisp1_write(rkisp1, ratio, rsz->config->rsz.scale_hcb);
rkisp1_write(rkisp1, ratio, rsz->config->rsz.scale_hcr);
rkisp1_write(rkisp1, rsz->config->rsz.scale_hcb, ratio);
rkisp1_write(rkisp1, rsz->config->rsz.scale_hcr, ratio);
}
if (sink_y->height != src_y->height) {
......@@ -376,7 +376,7 @@ static void rkisp1_rsz_config_regs(struct rkisp1_resizer *rsz,
if (sink_y->height < src_y->height)
rsz_ctrl |= RKISP1_CIF_RSZ_CTRL_SCALE_VY_UP;
ratio = rkisp1_rsz_calc_ratio(sink_y->height, src_y->height);
rkisp1_write(rkisp1, ratio, rsz->config->rsz.scale_vy);
rkisp1_write(rkisp1, rsz->config->rsz.scale_vy, ratio);
}
if (sink_c->height != src_c->height) {
......@@ -384,10 +384,10 @@ static void rkisp1_rsz_config_regs(struct rkisp1_resizer *rsz,
if (sink_c->height < src_c->height)
rsz_ctrl |= RKISP1_CIF_RSZ_CTRL_SCALE_VC_UP;
ratio = rkisp1_rsz_calc_ratio(sink_c->height, src_c->height);
rkisp1_write(rkisp1, ratio, rsz->config->rsz.scale_vc);
rkisp1_write(rkisp1, rsz->config->rsz.scale_vc, ratio);
}
rkisp1_write(rkisp1, rsz_ctrl, rsz->config->rsz.ctrl);
rkisp1_write(rkisp1, rsz->config->rsz.ctrl, rsz_ctrl);
rkisp1_rsz_update_shadow(rsz, when);
}
......
......@@ -408,7 +408,7 @@ void rkisp1_stats_isr(struct rkisp1_stats *stats, u32 isp_ris)
spin_lock(&stats->lock);
rkisp1_write(rkisp1, RKISP1_STATS_MEAS_MASK, RKISP1_CIF_ISP_ICR);
rkisp1_write(rkisp1, RKISP1_CIF_ISP_ICR, RKISP1_STATS_MEAS_MASK);
isp_mis_tmp = rkisp1_read(rkisp1, RKISP1_CIF_ISP_MIS);
if (isp_mis_tmp & RKISP1_STATS_MEAS_MASK)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment