diff options
author | changhuang.liang <changhuang.liang@starfivetech.com> | 2022-05-10 06:34:23 +0300 |
---|---|---|
committer | Jianlong Huang <jianlong.huang@starfivetech.com> | 2022-06-13 06:39:17 +0300 |
commit | 17e3cd22a930ddaa7357a71c26748492b7cb8836 (patch) | |
tree | dd71ff4c98134112dd78fa60dfb225a60eb837de | |
parent | 4bcc1c56cac24fefd2ba06670704553d5fd64ef5 (diff) | |
download | linux-17e3cd22a930ddaa7357a71c26748492b7cb8836.tar.xz |
V4L2: fix v4l2 coding style
Signed-off-by: changhuang.liang <changhuang.liang@starfivetech.com>
20 files changed, 154 insertions, 166 deletions
diff --git a/drivers/media/platform/starfive/imx219_mipi.c b/drivers/media/platform/starfive/imx219_mipi.c index 96307a5621ce..70f14c7af86a 100644 --- a/drivers/media/platform/starfive/imx219_mipi.c +++ b/drivers/media/platform/starfive/imx219_mipi.c @@ -681,7 +681,7 @@ static void imx219_set_default_format(struct imx219 *imx219) fmt->colorspace = V4L2_COLORSPACE_SRGB; fmt->ycbcr_enc = V4L2_MAP_YCBCR_ENC_DEFAULT(fmt->colorspace); fmt->quantization = V4L2_MAP_QUANTIZATION_DEFAULT(true, - fmt->colorspace,fmt->ycbcr_enc); + fmt->colorspace, fmt->ycbcr_enc); fmt->xfer_func = V4L2_MAP_XFER_FUNC_DEFAULT(fmt->colorspace); fmt->width = supported_modes[0].width; fmt->height = supported_modes[0].height; @@ -755,7 +755,7 @@ static int imx219_set_ctrl(struct v4l2_ctrl *ctrl) break; case V4L2_CID_TEST_PATTERN: ret = imx219_write_reg(imx219, IMX219_REG_TEST_PATTERN, - IMX219_REG_VALUE_16BIT,imx219_test_pattern_val[ctrl->val]); + IMX219_REG_VALUE_16BIT, imx219_test_pattern_val[ctrl->val]); break; case V4L2_CID_HFLIP: case V4L2_CID_VFLIP: @@ -854,9 +854,8 @@ static int imx219_enum_frame_interval(struct v4l2_subdev *sd, if (fie->code != code) return -EINVAL; - pr_debug("fie->width = %d, fie->height = %d \n", fie->width, fie->height); - for (i = 0; i < MODE_COUNT_MAX; i++) - { + pr_debug("fie->width = %d, fie->height = %d\n", fie->width, fie->height); + for (i = 0; i < MODE_COUNT_MAX; i++) { if (fie->width == supported_modes[i].width && fie->height == supported_modes[i].height) break; } @@ -903,7 +902,7 @@ static int __imx219_get_pad_format(struct imx219 *imx219, fmt->format = *try_fmt; } else { imx219_update_pad_format(imx219, imx219->mode, fmt); - fmt->format.code = imx219_get_format_code(imx219,imx219->fmt.code); + fmt->format.code = imx219_get_format_code(imx219, imx219->fmt.code); } return 0; @@ -958,7 +957,7 @@ static int imx219_set_pad_format(struct v4l2_subdev *sd, __v4l2_ctrl_modify_range(imx219->vblank, IMX219_VBLANK_MIN, IMX219_VTS_MAX - mode->height, 1, mode->vts_def - mode->height); - __v4l2_ctrl_s_ctrl(imx219->vblank,mode->vts_def - mode->height); + __v4l2_ctrl_s_ctrl(imx219->vblank, mode->vts_def - mode->height); /* Update max exposure while meeting expected vblanking */ exposure_max = mode->vts_def - 4; exposure_def = (exposure_max < IMX219_EXPOSURE_DEFAULT) ? @@ -1319,12 +1318,12 @@ static int imx219_init_controls(struct imx219 *imx219) /* Initial vblank/hblank/exposure parameters based on current mode */ imx219->vblank = v4l2_ctrl_new_std(ctrl_hdlr, &imx219_ctrl_ops, - V4L2_CID_VBLANK,IMX219_VBLANK_MIN, + V4L2_CID_VBLANK, IMX219_VBLANK_MIN, IMX219_VTS_MAX - height, 1, imx219->mode->vts_def - height); hblank = IMX219_PPL_DEFAULT - imx219->mode->width; imx219->hblank = v4l2_ctrl_new_std(ctrl_hdlr, &imx219_ctrl_ops, - V4L2_CID_HBLANK,hblank, hblank, 1, hblank); + V4L2_CID_HBLANK, hblank, hblank, 1, hblank); if (imx219->hblank) imx219->hblank->flags |= V4L2_CTRL_FLAG_READ_ONLY; exposure_max = imx219->mode->vts_def - 4; diff --git a/drivers/media/platform/starfive/ov4689_mipi.c b/drivers/media/platform/starfive/ov4689_mipi.c index 64d850dbd136..b15a7a9f3e9f 100644..100755 --- a/drivers/media/platform/starfive/ov4689_mipi.c +++ b/drivers/media/platform/starfive/ov4689_mipi.c @@ -622,7 +622,7 @@ static const struct reg_value ov4689_setting_720P_1280_720[] = { {0x3809, 0x00, 0, 0}, {0x380a, 0x02, 0, 0}, {0x380b, 0xD0, 0, 0}, -#if 1 +#ifndef UNUSED_CODE {0x380c, 0x04, 0, 0}, // 0a ; 03 {0x380d, 0x08, 0, 0}, // 1c ; 5C #else @@ -1347,7 +1347,7 @@ static int ov4689_read_reg(struct ov4689_dev *sensor, u16 reg, u8 *val) ret = i2c_transfer(client->adapter, msg, 2); if (ret < 0) { - dev_err(&client->dev, "%s: error: reg=%x\n",__func__, reg); + dev_err(&client->dev, "%s: error: reg=%x\n", __func__, reg); return ret; } @@ -1715,10 +1715,10 @@ static int ov4689_set_mipi_pclk(struct ov4689_dev *sensor, val16 = val << 8; ret = ov4689_read_reg(sensor, OV4689_TIMING_HTS + 1, &val); val16 |= val; - st_info(ST_SENSOR, "fps = %d, max_fps = %d, mode->htot = 0x%x, " - "htot = 0x%x, 0x%x = 0x%x\n", - fps, mode->max_fps, mode->htot, - htot, OV4689_TIMING_HTS, val16); + st_info(ST_SENSOR, "fps = %d, max_fps = %d, mode->htot = 0x%x," + fps, mode->max_fps, mode->htot); + st_info(ST_SENSOR, "htot = 0x%x, 0x%x = 0x%x\n", + htot, OV4689_TIMING_HTS, val16); return 0; } @@ -1943,6 +1943,7 @@ static int ov4689_try_frame_interval(struct ov4689_dev *sensor, best_fps = minfps; for (i = 0; i < ARRAY_SIZE(ov4689_framerates); i++) { int curr_fps = ov4689_framerates[i]; + if (abs(curr_fps - fps) < abs(best_fps - fps)) { best_fps = curr_fps; rate = i; diff --git a/drivers/media/platform/starfive/stf_common.h b/drivers/media/platform/starfive/stf_common.h index 23920a574349..2c064174517e 100644 --- a/drivers/media/platform/starfive/stf_common.h +++ b/drivers/media/platform/starfive/stf_common.h @@ -1,5 +1,5 @@ -// SPDX-License-Identifier: GPL-2.0 -/* +/* SPDX-License-Identifier: GPL-2.0 + * * Copyright (C) 2021 StarFive Technology Co., Ltd. */ #ifndef STF_COMMON_H @@ -21,7 +21,7 @@ enum { ST_VIN = 0x0010, ST_VIDEO = 0x0020, ST_CAMSS = 0x0040, - ST_SENSOR= 0x0080, + ST_SENSOR = 0x0080, }; enum { @@ -126,17 +126,17 @@ extern unsigned int stdbg_mask; #define set_bits(p, v, b, m) (((p) & ~(m)) | ((v) << (b))) -static inline u32 reg_read(void __iomem * base, u32 reg) +static inline u32 reg_read(void __iomem *base, u32 reg) { return ioread32(base + reg); } -static inline void reg_write(void __iomem * base, u32 reg, u32 val) +static inline void reg_write(void __iomem *base, u32 reg, u32 val) { iowrite32(val, base + reg); } -static inline void reg_set_bit(void __iomem * base, u32 reg, u32 mask, u32 val) +static inline void reg_set_bit(void __iomem *base, u32 reg, u32 mask, u32 val) { u32 value; @@ -146,17 +146,17 @@ static inline void reg_set_bit(void __iomem * base, u32 reg, u32 mask, u32 val) iowrite32(val, base + reg); } -static inline void reg_set(void __iomem * base, u32 reg, u32 mask) +static inline void reg_set(void __iomem *base, u32 reg, u32 mask) { iowrite32(ioread32(base + reg) | mask, base + reg); } -static inline void reg_clear(void __iomem * base, u32 reg, u32 mask) +static inline void reg_clear(void __iomem *base, u32 reg, u32 mask) { iowrite32(ioread32(base + reg) & ~mask, base + reg); } -static inline void reg_set_highest_bit(void __iomem * base, u32 reg) +static inline void reg_set_highest_bit(void __iomem *base, u32 reg) { u32 val; @@ -166,7 +166,7 @@ static inline void reg_set_highest_bit(void __iomem * base, u32 reg) iowrite32(val, base + reg); } -static inline void reg_clr_highest_bit(void __iomem * base, u32 reg) +static inline void reg_clr_highest_bit(void __iomem *base, u32 reg) { u32 val; @@ -176,7 +176,7 @@ static inline void reg_clr_highest_bit(void __iomem * base, u32 reg) iowrite32(val, base + reg); } -static inline void print_reg(unsigned int module, void __iomem * base, u32 reg) +static inline void print_reg(unsigned int module, void __iomem *base, u32 reg) { st_debug(module, "0x%08x = 0x%08x\n", reg, ioread32(base + reg)); } diff --git a/drivers/media/platform/starfive/stf_csi.h b/drivers/media/platform/starfive/stf_csi.h index 0fa786b67162..6e94664eb35e 100644 --- a/drivers/media/platform/starfive/stf_csi.h +++ b/drivers/media/platform/starfive/stf_csi.h @@ -1,5 +1,5 @@ -// SPDX-License-Identifier: GPL-2.0 -/* +/* SPDX-License-Identifier: GPL-2.0 + * * Copyright (C) 2021 StarFive Technology Co., Ltd. */ #ifndef STF_CSI_H diff --git a/drivers/media/platform/starfive/stf_csi_hw_ops.c b/drivers/media/platform/starfive/stf_csi_hw_ops.c index e727d07ef744..911870aa4587 100644 --- a/drivers/media/platform/starfive/stf_csi_hw_ops.c +++ b/drivers/media/platform/starfive/stf_csi_hw_ops.c @@ -184,14 +184,14 @@ static int stf_csi_config_set(struct stf_csi_dev *csi_dev) case SENSOR_ISP0: #ifdef USE_CLK_TREE clk_set_parent(csi_dev->stfcamss->sys_clk[STFCLK_ISP0_MIPI_CTRL].clk, - csi_dev->stfcamss->sys_clk[STFCLK_MIPIRX0_PIXEL + csi_dev->id].clk ); + csi_dev->stfcamss->sys_clk[STFCLK_MIPIRX0_PIXEL + csi_dev->id].clk); clk_set_parent(csi_dev->stfcamss->sys_clk[STFCLK_C_ISP0_CTRL].clk, csi_dev->stfcamss->sys_clk[STFCLK_MIPIRX0_PIXEL + csi_dev->id].clk); #else reg_set_bit(vin->clkgen_base, CLK_ISP0_MIPI_CTRL, BIT(24), csi_dev->id << 24); - reg_set_bit(vin->clkgen_base, CLK_C_ISP0_CTRL,BIT(25) | BIT(24), + reg_set_bit(vin->clkgen_base, CLK_C_ISP0_CTRL, BIT(25) | BIT(24), csi_dev->id << 24); #endif mipi_channel_sel = csi_dev->id * 4 + mipi_vc; @@ -201,7 +201,7 @@ static int stf_csi_config_set(struct stf_csi_dev *csi_dev) case SENSOR_ISP1: #ifdef USE_CLK_TREE clk_set_parent(csi_dev->stfcamss->sys_clk[STFCLK_ISP1_MIPI_CTRL].clk, - csi_dev->stfcamss->sys_clk[STFCLK_MIPIRX0_PIXEL + csi_dev->id].clk ); + csi_dev->stfcamss->sys_clk[STFCLK_MIPIRX0_PIXEL + csi_dev->id].clk); clk_set_parent(csi_dev->stfcamss->sys_clk[STFCLK_C_ISP1_CTRL].clk, csi_dev->stfcamss->sys_clk[STFCLK_MIPIRX0_PIXEL + csi_dev->id].clk); #else @@ -262,7 +262,7 @@ static void csi2rx_reset(void *reg_base) writel(0, reg_base + CSI2RX_SOFT_RESET_REG); } -#if 0 +#ifdef UNUSED_CODE static void csi2rx_debug_config(void *reg_base, u32 frame_lines) { // data_id, ecc, crc error to irq @@ -340,6 +340,7 @@ static int csi2rx_start(struct stf_csi_dev *csi_dev) */ for (i = csiphy->num_data_lanes; i < CSI2RX_LANES_MAX; i++) { unsigned int idx = find_first_zero_bit(&lanes_used, CSI2RX_LANES_MAX); + set_bit(idx, &lanes_used); reg |= CSI2RX_STATIC_CFG_DLANE_MAP(i, idx + 1); } diff --git a/drivers/media/platform/starfive/stf_csiphy.c b/drivers/media/platform/starfive/stf_csiphy.c index cd39cd0529ad..c69638b72e92 100644 --- a/drivers/media/platform/starfive/stf_csiphy.c +++ b/drivers/media/platform/starfive/stf_csiphy.c @@ -40,6 +40,7 @@ static int csiphy_set_power(struct v4l2_subdev *sd, int on) #ifdef CONFIG_VIDEO_CADENCE_CSI2RX struct stf_csiphy_dev *csiphy_dev = v4l2_get_subdevdata(sd); + if (on) csiphy_dev->hw_ops->cdns_csi_power(csiphy_dev, on); #endif @@ -84,7 +85,7 @@ __csiphy_get_format(struct stf_csiphy_dev *csiphy_dev, enum v4l2_subdev_format_whence which) { if (which == V4L2_SUBDEV_FORMAT_TRY) - return v4l2_subdev_get_try_format( &csiphy_dev->subdev, cfg, pad); + return v4l2_subdev_get_try_format(&csiphy_dev->subdev, cfg, pad); return &csiphy_dev->fmt[pad]; } diff --git a/drivers/media/platform/starfive/stf_csiphy.h b/drivers/media/platform/starfive/stf_csiphy.h index 23292e8f60a8..a308f8820db9 100644 --- a/drivers/media/platform/starfive/stf_csiphy.h +++ b/drivers/media/platform/starfive/stf_csiphy.h @@ -1,5 +1,5 @@ -// SPDX-License-Identifier: GPL-2.0 -/* +/* SPDX-License-Identifier: GPL-2.0 + * * Copyright (C) 2021 StarFive Technology Co., Ltd. */ #ifndef STF_CSIPHY_H diff --git a/drivers/media/platform/starfive/stf_csiphy_hw_ops.c b/drivers/media/platform/starfive/stf_csiphy_hw_ops.c index 6ecbca836fef..e824e43ed11a 100644 --- a/drivers/media/platform/starfive/stf_csiphy_hw_ops.c +++ b/drivers/media/platform/starfive/stf_csiphy_hw_ops.c @@ -69,6 +69,7 @@ static int stf_csiphy_clk_enable(struct stf_csiphy_dev *csiphy_dev) // enable clk struct stfcamss *stfcamss = csiphy_dev->stfcamss; int ret = 0; + clk_set_rate(stfcamss->sys_clk[STFCLK_CSIDPHY_CFGCLK].clk, 100000000); clk_set_rate(stfcamss->sys_clk[STFCLK_CSIDPHY_REFCLK].clk, 50000000); clk_set_rate(stfcamss->sys_clk[STFCLK_CSIDPHY_TXCLKESC].clk, 20000000); @@ -88,6 +89,7 @@ static int stf_csiphy_clk_disable(struct stf_csiphy_dev *csiphy_dev) { #ifdef USE_CLK_TREE struct stfcamss *stfcamss = csiphy_dev->stfcamss; + stfcamss_disable_clocks(3, &stfcamss->sys_clk[STFCLK_CSIDPHY_CFGCLK]); return 0; #else @@ -233,7 +235,7 @@ static int stf_csiphy_config_set(struct stf_csiphy_dev *csiphy_dev) { struct stf_vin_dev *vin = csiphy_dev->stfcamss->vin; - st_debug(ST_CSIPHY, "%s, csiphy id = %d\n",__func__, csiphy_dev->id); + st_debug(ST_CSIPHY, "%s, csiphy id = %d\n", __func__, csiphy_dev->id); csi2rx_dphy_config(vin, csiphy_dev); return 0; } @@ -251,14 +253,14 @@ static int stf_csi_clk_enable(struct stf_csiphy_dev *csiphy_dev) reg_set_highest_bit(vin->clkgen_base, CLK_CSI2RX0_APB_CTRL); if (csiphy_dev->id == 0) { - reg_set_bit(vin->clkgen_base,CLK_MIPI_RX0_PXL_CTRL,0x1F, 0x3); + reg_set_bit(vin->clkgen_base, CLK_MIPI_RX0_PXL_CTRL, 0x1F, 0x3); reg_set_highest_bit(vin->clkgen_base, CLK_MIPI_RX0_PXL_0_CTRL); reg_set_highest_bit(vin->clkgen_base, CLK_MIPI_RX0_PXL_1_CTRL); reg_set_highest_bit(vin->clkgen_base, CLK_MIPI_RX0_PXL_2_CTRL); reg_set_highest_bit(vin->clkgen_base, CLK_MIPI_RX0_PXL_3_CTRL); reg_set_highest_bit(vin->clkgen_base, CLK_MIPI_RX0_SYS0_CTRL); } else { - reg_set_bit(vin->clkgen_base,CLK_MIPI_RX1_PXL_CTRL,0x1F, 0x3); + reg_set_bit(vin->clkgen_base, CLK_MIPI_RX1_PXL_CTRL, 0x1F, 0x3); reg_set_highest_bit(vin->clkgen_base, CLK_MIPI_RX1_PXL_0_CTRL); reg_set_highest_bit(vin->clkgen_base, CLK_MIPI_RX1_PXL_1_CTRL); reg_set_highest_bit(vin->clkgen_base, CLK_MIPI_RX1_PXL_2_CTRL); diff --git a/drivers/media/platform/starfive/stf_dvp.c b/drivers/media/platform/starfive/stf_dvp.c index 010d01a2c600..bbc2224e24f9 100644 --- a/drivers/media/platform/starfive/stf_dvp.c +++ b/drivers/media/platform/starfive/stf_dvp.c @@ -151,6 +151,7 @@ static int dvp_enum_mbus_code(struct v4l2_subdev *sd, code->code = dvp_dev->formats[code->index].code; } else { struct v4l2_mbus_framefmt *sink_fmt; + sink_fmt = __dvp_get_format(dvp_dev, cfg, STF_DVP_PAD_SINK, code->which); code->code = sink_fmt->code; diff --git a/drivers/media/platform/starfive/stf_dvp.h b/drivers/media/platform/starfive/stf_dvp.h index d3130a417f5a..6401526a3a68 100644 --- a/drivers/media/platform/starfive/stf_dvp.h +++ b/drivers/media/platform/starfive/stf_dvp.h @@ -1,5 +1,5 @@ -// SPDX-License-Identifier: GPL-2.0 -/* +/* SPDX-License-Identifier: GPL-2.0 + * * Copyright (C) 2021 StarFive Technology Co., Ltd. */ #ifndef STF_DVP_H diff --git a/drivers/media/platform/starfive/stf_isp.c b/drivers/media/platform/starfive/stf_isp.c index c45c113e635a..d236978a7b4c 100644 --- a/drivers/media/platform/starfive/stf_isp.c +++ b/drivers/media/platform/starfive/stf_isp.c @@ -84,10 +84,11 @@ static int isp_set_ctrl_white_balance(struct stf_isp_dev *isp_dev, int awb) if (!awb && (ctrls->red_balance->is_new || ctrls->blue_balance->is_new)) { u16 red = (u16)ctrls->red_balance->val; u16 blue = (u16)ctrls->blue_balance->val; + st_debug(ST_ISP, "red = 0x%x, blue = 0x%x\n", red, blue); // isp_dev->hw_ops->isp_set_awb_r_gain(isp_dev, red); // if (ret) - // return ret; + // return ret; // isp_dev->hw_ops->isp_set_awb_b_gain(isp_dev, blue); } @@ -95,7 +96,7 @@ static int isp_set_ctrl_white_balance(struct stf_isp_dev *isp_dev, int awb) } static int isp_set_ctrl_exposure(struct stf_isp_dev *isp_dev, - enum v4l2_exposure_auto_type auto_exposure) + enum v4l2_exposure_auto_type auto_exposure) { int ret = 0; @@ -321,7 +322,7 @@ static int isp_set_power(struct v4l2_subdev *sd, int on) return 0; } -static struct v4l2_mbus_framefmt * __isp_get_format(struct stf_isp_dev *isp_dev, +static struct v4l2_mbus_framefmt *__isp_get_format(struct stf_isp_dev *isp_dev, struct v4l2_subdev_pad_config *cfg, unsigned int pad, enum v4l2_subdev_format_whence which) @@ -392,7 +393,7 @@ static void isp_try_format(struct stf_isp_dev *isp_dev, fmt->code = MEDIA_BUS_FMT_RGB565_2X8_LE; fmt->width = clamp_t(u32, fmt->width, 8, STFCAMSS_FRAME_MAX_WIDTH); - fmt->width &= ~0x7 ; + fmt->width &= ~0x7; fmt->height = clamp_t(u32, fmt->height, 1, STFCAMSS_FRAME_MAX_HEIGHT_PIX); @@ -422,6 +423,7 @@ static int isp_enum_mbus_code(struct v4l2_subdev *sd, code->code = isp_dev->formats[code->index].code; } else { struct v4l2_mbus_framefmt *sink_fmt; + sink_fmt = __isp_get_format(isp_dev, cfg, STF_ISP_PAD_SINK, code->which); @@ -522,7 +524,7 @@ static int isp_set_format(struct v4l2_subdev *sd, return 0; } -static struct v4l2_rect * __isp_get_compose(struct stf_isp_dev *isp_dev, +static struct v4l2_rect *__isp_get_compose(struct stf_isp_dev *isp_dev, struct v4l2_subdev_pad_config *cfg, enum v4l2_subdev_format_whence which) { @@ -781,7 +783,7 @@ static int stf_isp_load_setfile(struct stf_isp_dev *isp_dev, char *file_name) isp_dev->setfile.state = 1; regval_num = (int *)&buf[fw->size - sizeof(unsigned int)]; isp_dev->setfile.settings.regval_num = *regval_num; - isp_dev->setfile.settings.regval = (regval_t *)buf; + isp_dev->setfile.settings.regval = (struct regval_t *)buf; mutex_unlock(&isp_dev->setfile_lock); st_debug(ST_ISP, "stf_isp setfile loaded size: %zu B, reg_nul: %d\n", diff --git a/drivers/media/platform/starfive/stf_isp.h b/drivers/media/platform/starfive/stf_isp.h index 64ee98e63997..e4938f841a50 100644 --- a/drivers/media/platform/starfive/stf_isp.h +++ b/drivers/media/platform/starfive/stf_isp.h @@ -1,5 +1,5 @@ -// SPDX-License-Identifier: GPL-2.0 -/* +/* SPDX-License-Identifier: GPL-2.0 + * * Copyright (C) 2021 StarFive Technology Co., Ltd. */ #ifndef STF_ISP_H @@ -33,22 +33,22 @@ struct stfisp_fw_info { }; #define VIDIOC_STFISP_LOAD_FW \ - _IOW('V', BASE_VIDIOC_PRIVATE + 1, struct stfisp_fw_info) + _IOW('V', BASE_VIDIOC_PRIVATE + 1, struct stfisp_fw_info) struct isp_format { u32 code; u8 bpp; }; -typedef struct { +struct regval_t { u32 addr; u32 val; u32 mask; u32 delay_ms; -} regval_t; +}; struct reg_table { - const regval_t *regval; + const struct regval_t *regval; int regval_num; }; diff --git a/drivers/media/platform/starfive/stf_isp_hw_ops.c b/drivers/media/platform/starfive/stf_isp_hw_ops.c index 2a262e9856a0..87cc62418ae2 100644 --- a/drivers/media/platform/starfive/stf_isp_hw_ops.c +++ b/drivers/media/platform/starfive/stf_isp_hw_ops.c @@ -7,14 +7,14 @@ * PURPOSE: This files contains the driver of VPP. */ #include "stfcamss.h" -#include <asm/io.h> +#include <linux/io.h> #include <linux/fb.h> #include <linux/module.h> #include <video/stf-vin.h> #include <linux/delay.h> #include <linux/clk.h> -static const regval_t isp_sc2235_reg_config_list[] = { +static const struct regval_t isp_sc2235_reg_config_list[] = { {0x00000014, 0x00000008, 0, 0}, // {0x00000018, 0x000011BB, 0, 0}, {0x00000A1C, 0x00000030, 0, 0}, @@ -47,7 +47,7 @@ static const regval_t isp_sc2235_reg_config_list[] = { {0x00000000, 0x00000001, 0, 0}, }; -static const regval_t isp_1080p_reg_config_list[] = { +static const struct regval_t isp_1080p_reg_config_list[] = { {0x00000014, 0x0000000D, 0, 0}, // {0x00000018, 0x000011BB, 0, 0}, {0x00000A1C, 0x00000032, 0, 0}, @@ -128,7 +128,7 @@ const struct reg_table isp_sc2235_settings[] = { ARRAY_SIZE(isp_sc2235_reg_config_list)}, }; -static regval_t isp_format_reg_list[] = { +static struct regval_t isp_format_reg_list[] = { {0x0000001C, 0x00000000, 0, 0}, {0x00000020, 0x0437077F, 0, 0}, {0x00000A0C, 0x04380780, 0, 0}, diff --git a/drivers/media/platform/starfive/stf_video.c b/drivers/media/platform/starfive/stf_video.c index 77d0e108c042..0acd589e345e 100644..100755 --- a/drivers/media/platform/starfive/stf_video.c +++ b/drivers/media/platform/starfive/stf_video.c @@ -126,9 +126,9 @@ static int __video_try_fmt(struct stfcamss_video *video, pix_mp->colorspace, pix_mp->ycbcr_enc); pix_mp->xfer_func = V4L2_MAP_XFER_FUNC_DEFAULT(pix_mp->colorspace); - st_info(ST_VIDEO, "w, h = %d, %d, bpp = %d, " - "i = %d, p = %d, s = 0x%x\n", - pix_mp->width, pix_mp->height, fi->bpp[0], i, + st_info(ST_VIDEO, "w, h = %d, %d, bpp = %d,", + pix_mp->width, pix_mp->height, fi->bpp[0]); + st_info(ST_VIDEO, "i = %d, p = %d, s = 0x%x\n", i, pix_mp->num_planes, pix_mp->plane_fmt[0].sizeimage); } else { @@ -164,10 +164,9 @@ static int __video_try_fmt(struct stfcamss_video *video, pix->quantization = V4L2_MAP_QUANTIZATION_DEFAULT(true, pix->colorspace, pix->ycbcr_enc); pix->xfer_func = V4L2_MAP_XFER_FUNC_DEFAULT(pix->colorspace); - st_info(ST_VIDEO, "w, h = %d, %d, bpp = %d, " - "i = %d, s = 0x%x\n", - pix->width, pix->height, - fi->bpp[0], i, pix->sizeimage); + st_info(ST_VIDEO, "w, h = %d, %d, bpp = %d", + pix->width, pix->height); + st_info(ST_VIDEO, "i = %d, s = 0x%x\n", i, pix->sizeimage); } return 0; } @@ -707,11 +706,11 @@ static int video_enum_framesizes(struct file *file, void *fh, code.which = V4L2_SUBDEV_FORMAT_ACTIVE; ret = v4l2_subdev_call(subdev, pad, enum_mbus_code, NULL, &code); if (ret < 0) - return EINVAL; + return -EINVAL; fse.index = fsize->index; fse.code = code.code; fse.which = V4L2_SUBDEV_FORMAT_ACTIVE; - ret = v4l2_subdev_call(subdev, pad, enum_frame_size, NULL,&fse); + ret = v4l2_subdev_call(subdev, pad, enum_frame_size, NULL, &fse); if (ret < 0) return -EINVAL; fsize->type = V4L2_FRMSIZE_TYPE_DISCRETE; @@ -854,11 +853,11 @@ static int video_pipeline_s_fmt(struct stfcamss_video *video, break; if (mf->code != code || mf->width != width || mf->height != height) { - st_warn(ST_VIDEO, - "\"%s\":%d pad fmt has been" - " changed to 0x%x %ux%u\n", - subdev->name, fmt.pad, mf->code, - mf->width, mf->height); + // st_warn(ST_VIDEO, + // "\"%s\":%d pad fmt has been" + // " changed to 0x%x %ux%u\n", + // subdev->name, fmt.pad, mf->code, + // mf->width, mf->height); } } } @@ -867,12 +866,12 @@ static int video_pipeline_s_fmt(struct stfcamss_video *video, media_graph_walk_cleanup(&graph); if (ret < 0 && ret != -ENOIOCTLCMD) { - st_err(ST_VIDEO, - "%s: Failed to set fmt 0x%x %ux%u" - " on \"%s\":%d pad (%d)\n", - __func__, mf->code, - mf->width, mf->height, - subdev->name, fmt.pad, ret); + // st_err(ST_VIDEO, + // "%s: Failed to set fmt 0x%x %ux%u" + // " on \"%s\":%d pad (%d)\n", + // __func__, mf->code, + // mf->width, mf->height, + // subdev->name, fmt.pad, ret); return ret; } @@ -1164,7 +1163,7 @@ int video_g_ctrl(struct file *file, void *fh, int ret; subdev = get_senname(file, __func__); - if( subdev == NULL) + if (!subdev) return -EINVAL; ret = v4l2_g_ctrl(subdev->ctrl_handler, ctrls); @@ -1180,19 +1179,19 @@ static int video_s_ctrl(struct file *file, void *fh, int ret; subdev = get_senname(file, __func__); - if( subdev == NULL) + if (!subdev) return -EINVAL; - vfh = container_of(&subdev->ctrl_handler, struct v4l2_fh , ctrl_handler); + vfh = container_of(&subdev->ctrl_handler, struct v4l2_fh, ctrl_handler); if (!vfh->ctrl_handler) return -ENOTTY; - ret = v4l2_s_ctrl(vfh,subdev->ctrl_handler, ctrl); + ret = v4l2_s_ctrl(vfh, subdev->ctrl_handler, ctrl); return ret; } -#if 0 +#ifdef UNUSED_CODE static int video_query_ext_ctrl(struct file *file, void *fh, struct v4l2_query_ext_ctrl *qec) { @@ -1200,7 +1199,7 @@ static int video_query_ext_ctrl(struct file *file, void *fh, int ret; subdev = get_senname(file, __func__); - if( subdev == NULL) + if (!subdev) return -EINVAL; ret = v4l2_query_ext_ctrl(subdev->ctrl_handler, qec); @@ -1218,7 +1217,7 @@ static int video_g_ext_ctrls(struct file *file, void *fh, int ret; subdev = get_senname(file, __func__); - if( subdev == NULL) + if (!subdev) return -EINVAL; ret = v4l2_g_ext_ctrls(subdev->ctrl_handler, @@ -1230,7 +1229,6 @@ static int video_g_ext_ctrls(struct file *file, void *fh, static int video_queryctrl(struct file *file, void *fh, struct v4l2_queryctrl *qc) { -#if 1 struct stfcamss_video *video = video_drvdata(file); struct video_device *vdev = &video->vdev; struct media_entity *entity = &vdev->entity; @@ -1239,31 +1237,15 @@ static int video_queryctrl(struct file *file, void *fh, int ret = 0; sensor = stfcamss_find_sensor(entity); - if(sensor) { + if (sensor) { subdev = media_entity_to_v4l2_subdev(sensor); - ret= v4l2_queryctrl(subdev->ctrl_handler, qc); + ret = v4l2_queryctrl(subdev->ctrl_handler, qc); } else { // st_err(ST_VIDEO, "== [%s] Please configure pipeline first ==\n", __func__); return -EINVAL; } return ret; -#else - struct stfcamss_video *video = video_drvdata(file); - struct video_device *vdev = &video->vdev; - struct v4l2_subdev *subdev; - struct v4l2_fh *vfh; - int ret; - - subdev = get_senname(file, __func__); - if( subdev == NULL ) - return -EINVAL; - - vfh = container_of(&subdev->ctrl_handler, struct v4l2_fh , ctrl_handler); - ret= v4l2_queryctrl(subdev->ctrl_handler, qc); - - return ret; -#endif } static int video_s_ext_ctrls(struct file *file, void *fh, @@ -1276,10 +1258,10 @@ static int video_s_ext_ctrls(struct file *file, void *fh, int ret; subdev = get_senname(file, __func__); - if( subdev == NULL ) + if (!subdev) return -EINVAL; - vfh = container_of(&subdev->ctrl_handler, struct v4l2_fh , ctrl_handler); + vfh = container_of(&subdev->ctrl_handler, struct v4l2_fh, ctrl_handler); if (!vfh->ctrl_handler) return -ENOTTY; ret = v4l2_s_ext_ctrls(vfh, subdev->ctrl_handler, @@ -1298,10 +1280,10 @@ static int video_try_ext_ctrls(struct file *file, void *fh, int ret; subdev = get_senname(file, __func__); - if( subdev == NULL ) + if (!subdev) return -EINVAL; - vfh = container_of(&subdev->ctrl_handler, struct v4l2_fh , ctrl_handler); + vfh = container_of(&subdev->ctrl_handler, struct v4l2_fh, ctrl_handler); if (!vfh->ctrl_handler) return -ENOTTY; ret = v4l2_try_ext_ctrls(vfh->ctrl_handler, @@ -1317,7 +1299,7 @@ static int video_querymenu(struct file *file, void *fh, int ret; subdev = get_senname(file, __func__); - if( subdev == NULL ) + if (!subdev) return -EINVAL; ret = v4l2_querymenu(subdev->ctrl_handler, qm); @@ -1386,7 +1368,7 @@ static const struct v4l2_ioctl_ops stf_vid_ioctl_ops_mp = { .vidioc_g_selection = video_g_selection, .vidioc_g_ctrl = video_g_ctrl, .vidioc_s_ctrl = video_s_ctrl, - .vidioc_g_ext_ctrls = video_g_ext_ctrls, + .vidioc_g_ext_ctrls = video_g_ext_ctrls, .vidioc_queryctrl = video_queryctrl, .vidioc_s_ext_ctrls = video_s_ext_ctrls, .vidioc_try_ext_ctrls = video_try_ext_ctrls, diff --git a/drivers/media/platform/starfive/stf_video.h b/drivers/media/platform/starfive/stf_video.h index d17b3d1c6507..f8a21ba91564 100644 --- a/drivers/media/platform/starfive/stf_video.h +++ b/drivers/media/platform/starfive/stf_video.h @@ -1,5 +1,5 @@ -// SPDX-License-Identifier: GPL-2.0 -/* +/* SPDX-License-Identifier: GPL-2.0 + * * Copyright (C) 2021 StarFive Technology Co., Ltd. */ #ifndef STF_VIDEO_H diff --git a/drivers/media/platform/starfive/stf_vin.c b/drivers/media/platform/starfive/stf_vin.c index a26a488e1e11..47c489f0ed97 100644 --- a/drivers/media/platform/starfive/stf_vin.c +++ b/drivers/media/platform/starfive/stf_vin.c @@ -11,11 +11,11 @@ #define STF_VIN_NAME "stf_vin" -#define vin_line_array(ptr_line) \ - ((const struct vin_line (*)[]) &(ptr_line[-(ptr_line->id)])) +#define vin_line_array(ptr_line) \ + ((const struct vin_line (*)[]) &(ptr_line[-(ptr_line->id)])) -#define line_to_vin2_dev(ptr_line) \ - container_of(vin_line_array(ptr_line), struct stf_vin2_dev, line) +#define line_to_vin2_dev(ptr_line) \ + container_of(vin_line_array(ptr_line), struct stf_vin2_dev, line) #define VIN_FRAME_DROP_MAX_VAL 30 #define VIN_FRAME_DROP_MIN_VAL 4 @@ -347,6 +347,7 @@ static int vin_enum_mbus_code(struct v4l2_subdev *sd, code->code = line->formats[code->index].code; } else { struct v4l2_mbus_framefmt *sink_fmt; + sink_fmt = __vin_get_format(line, cfg, STF_VIN_PAD_SINK, code->which); code->code = sink_fmt->code; if (!code->code) @@ -522,7 +523,7 @@ static struct stfcamss_buffer *vin_buf_get_pending(struct vin_output *output) return buffer; } -#if 0 +#ifdef UNUSED_CODE static void vin_output_checkpending(struct vin_line *line) { struct vin_output *output = &line->output; @@ -610,6 +611,7 @@ static void vin_buf_update_on_new(struct vin_line *line, #ifdef VIN_TWO_BUFFER struct stf_vin2_dev *vin_dev = line_to_vin2_dev(line); int inactive_idx; + inactive_idx = !output->active_buf; if (!output->buf[inactive_idx] && line->id == VIN_LINE_WR) { @@ -919,7 +921,7 @@ int stf_vin_register(struct stf_vin2_dev *vin_dev, struct v4l2_device *v4l2_dev) goto err_vid_reg; } - ret = media_create_pad_link( &sd->entity, STF_VIN_PAD_SRC, + ret = media_create_pad_link(&sd->entity, STF_VIN_PAD_SRC, &video_out->vdev.entity, 0, MEDIA_LNK_FL_IMMUTABLE | MEDIA_LNK_FL_ENABLED); if (ret < 0) { diff --git a/drivers/media/platform/starfive/stf_vin.h b/drivers/media/platform/starfive/stf_vin.h index 1ef65de51028..f8fbe284f50a 100644 --- a/drivers/media/platform/starfive/stf_vin.h +++ b/drivers/media/platform/starfive/stf_vin.h @@ -1,5 +1,5 @@ -// SPDX-License-Identifier: GPL-2.0 -/* +/* SPDX-License-Identifier: GPL-2.0 + * * Copyright (C) 2021 StarFive Technology Co., Ltd. */ #ifndef STF_VIN_H diff --git a/drivers/media/platform/starfive/stf_vin_hw_ops.c b/drivers/media/platform/starfive/stf_vin_hw_ops.c index 4eca44438c25..9d8c75dd57d0 100644 --- a/drivers/media/platform/starfive/stf_vin_hw_ops.c +++ b/drivers/media/platform/starfive/stf_vin_hw_ops.c @@ -37,7 +37,7 @@ static int vin_rstgen_assert_reset(struct stf_vin_dev *vin) } #endif -static void vin_intr_clear(void __iomem * sysctrl_base) +static void vin_intr_clear(void __iomem *sysctrl_base) { reg_set_bit(sysctrl_base, SYSCTRL_VIN_INTP_CTRL, BIT(0), 0x1); reg_set_bit(sysctrl_base, SYSCTRL_VIN_INTP_CTRL, BIT(0), 0x0); @@ -105,23 +105,21 @@ static int stf_vin_clk_init(struct stf_vin2_dev *vin_dev) for (i = STFRST_VIN_SRC; i <= STFRST_ISP1NOC_AXI; i++) { ret = reset_control_reset(stfcamss->sys_rst[i].rst); - if(ret){ + if (ret) { st_err(ST_VIN, "%s reset rst %d failed\n", __func__, i); return ret; } } // hold vin resets for sub modules before csi2rx controller get configed - for(i = STFRST_SYS_CLK; i <= STFRST_C_ISP1; i++) { + for (i = STFRST_SYS_CLK; i <= STFRST_C_ISP1; i++) reset_control_assert(stfcamss->sys_rst[i].rst); - } // clear reset for all vin submodules // except dphy-rx (follow lunhai's advice) - for(i = STFRST_SYS_CLK; i <= STFRST_C_ISP1; i++) { - if(i != STFRST_DPHY_HW_RSTN) { + for (i = STFRST_SYS_CLK; i <= STFRST_C_ISP1; i++) { + if (i != STFRST_DPHY_HW_RSTN) reset_control_deassert(stfcamss->sys_rst[i].rst); - } } // disable clk @@ -195,14 +193,12 @@ static int stf_vin_clk_enable(struct stf_vin2_dev *vin_dev) } /* rst disable */ - for(i = STFRST_SYS_CLK; i <= STFRST_C_ISP1; i++) { + for (i = STFRST_SYS_CLK; i <= STFRST_C_ISP1; i++) reset_control_assert(stfcamss->sys_rst[i].rst); - } /* rst enable */ - for(i = STFRST_SYS_CLK; i <= STFRST_C_ISP1; i++) { + for (i = STFRST_SYS_CLK; i <= STFRST_C_ISP1; i++) reset_control_deassert(stfcamss->sys_rst[i].rst); - } return ret; #else diff --git a/drivers/media/platform/starfive/stfcamss.c b/drivers/media/platform/starfive/stfcamss.c index 248c93c0e508..c59a98393ebb 100644 --- a/drivers/media/platform/starfive/stfcamss.c +++ b/drivers/media/platform/starfive/stfcamss.c @@ -59,7 +59,7 @@ static const struct reg_name mem_reg_name[] = { #endif }; -char * clocks[] = { +char *clocks[] = { "vin_src", "isp0_axi", "isp0noc_axi", @@ -91,15 +91,15 @@ char * clocks[] = { "isp1_mipi", "dom4_apb", "csi2rx_apb", - "vin_axi_wr", - "vin_axi_rd", - "c_isp0", + "vin_axi_wr", + "vin_axi_rd", + "c_isp0", "c_isp1", NULL, }; -char * resets[]={ +char *resets[] = { "vin_src", "ispslv_axi", "vin_axi", @@ -108,28 +108,28 @@ char * resets[]={ "isp0noc_axi", "isp1_axi", "isp1noc_axi", - "sys_clk", - "pclk", - "sys_clk_1", - "pixel_clk_if0", - "pixel_clk_if1", - "pixel_clk_if2", - "pixel_clk_if3", - "pixel_clk_if10", - "pixel_clk_if11", - "pixel_clk_if12", - "pixel_clk_if13", - "isp_0", - "isp_1", - "p_axird", - "p_axiwr", - "p_isp0", - "p_isp1", - "dphy_hw_rstn", - "dphy_rst09_alwy_on", - "c_isp0", + "sys_clk", + "pclk", + "sys_clk_1", + "pixel_clk_if0", + "pixel_clk_if1", + "pixel_clk_if2", + "pixel_clk_if3", + "pixel_clk_if10", + "pixel_clk_if11", + "pixel_clk_if12", + "pixel_clk_if13", + "isp_0", + "isp_1", + "p_axird", + "p_axiwr", + "p_isp0", + "p_isp1", + "dphy_hw_rstn", + "dphy_rst09_alwy_on", + "c_isp0", "c_isp1", - + NULL, }; @@ -697,7 +697,7 @@ static int stfcamss_subdev_notifier_bound(struct v4l2_async_notifier *async, return 0; } -#if 0 +#ifdef UNUSED_CODE static int stfcamss_subdev_notifier_complete( struct v4l2_async_notifier *async) { @@ -1017,7 +1017,7 @@ static int stfcamss_probe(struct platform_device *pdev) struct device *dev = &pdev->dev; int ret = 0, i, num_subdevs; - st_info(ST_CAMSS, "stfcamss probe enter!\n"); + dev_info(dev, "stfcamss probe enter!\n"); stfcamss = devm_kzalloc(dev, sizeof(struct stfcamss), GFP_KERNEL); if (!stfcamss) @@ -1120,7 +1120,7 @@ static int stfcamss_probe(struct platform_device *pdev) st_err(ST_CAMSS, "get %s clocks name failed\n", clocks[i]); goto err_cam_clk; } - st_debug(ST_CAMSS, "get %s clocks name: \n", clocks[i]); + st_debug(ST_CAMSS, "get %s clocks name:\n", clocks[i]); clock->name = clocks[i]; } @@ -1140,13 +1140,14 @@ static int stfcamss_probe(struct platform_device *pdev) for (i = 0; i < stfcamss->nrsts; i++) { struct stfcamss_rst *reset = &stfcamss->sys_rst[i]; + reset->rst = devm_reset_control_get_exclusive(dev, resets[i]); if (IS_ERR(reset->rst)) { ret = -ENOMEM; st_err(ST_CAMSS, "get %s resets name failed\n", resets[i]); goto err_cam_rst; } - st_debug(ST_CAMSS, "get %s resets name: \n", resets[i]); + st_debug(ST_CAMSS, "get %s resets name:\n", resets[i]); reset->name = resets[i]; } @@ -1226,13 +1227,13 @@ static int stfcamss_probe(struct platform_device *pdev) #ifdef CONFIG_DEBUG_FS stfcamss->debugfs_entry = debugfs_create_dir("stfcamss", NULL); stfcamss->vin_debugfs = debugfs_create_file("stf_vin", - S_IRUGO | S_IWUSR, stfcamss->debugfs_entry, + 0644, stfcamss->debugfs_entry, (void *)dev, &vin_debug_fops); debugfs_create_u32("dbg_level", - S_IRUGO | S_IWUSR, stfcamss->debugfs_entry, + 0644, stfcamss->debugfs_entry, &stdbg_level); debugfs_create_u32("dbg_mask", - S_IRUGO | S_IWUSR, stfcamss->debugfs_entry, + 0644, stfcamss->debugfs_entry, &stdbg_mask); #endif @@ -1259,7 +1260,7 @@ err_cam_rst: reset_control_put(reset->rst); st_debug(ST_CAMSS, "put %s reset\n", reset->name); - } + } err_cam_clk: for (i = stfcamss->nclks; i > 0; i--) { struct stfcamss_clk *clock = &stfcamss->sys_clk[i]; @@ -1295,7 +1296,7 @@ static int stfcamss_remove(struct platform_device *pdev) } static const struct of_device_id stfcamss_of_match[] = { - {.compatible = "starfive,stf-vin"}, + { .compatible = "starfive,stf-vin" }, { /* end node */ }, }; diff --git a/drivers/media/platform/starfive/stfcamss.h b/drivers/media/platform/starfive/stfcamss.h index 37a48ac5a61e..e14ad62d2783 100644 --- a/drivers/media/platform/starfive/stfcamss.h +++ b/drivers/media/platform/starfive/stfcamss.h @@ -1,5 +1,5 @@ -// SPDX-License-Identifier: GPL-2.0 -/* +/* SPDX-License-Identifier: GPL-2.0 + * * Copyright (C) 2021 StarFive Technology Co., Ltd. */ #ifndef STFCAMSS_H |