mirror of
https://github.com/hardkernel/linux.git
synced 2026-06-08 03:40:35 +09:00
media: rockchip: isp: add isp32 for rv1106
Change-Id: I3f02927df17cb04868d868f8c3a72079a99fea77 Signed-off-by: Cai YiWei <cyw@rock-chips.com>
This commit is contained in:
@@ -30,6 +30,10 @@ config VIDEO_ROCKCHIP_ISP_VERSION_V30
|
||||
bool "isp30 for rk3588"
|
||||
default y if CPU_RK3588
|
||||
|
||||
config VIDEO_ROCKCHIP_ISP_VERSION_V32
|
||||
bool "isp32 for rv1106"
|
||||
default y if CPU_RV1106
|
||||
|
||||
config VIDEO_ROCKCHIP_THUNDER_BOOT_ISP
|
||||
bool "Rockchip Image Signal Processing Thunderboot helper"
|
||||
depends on ROCKCHIP_THUNDER_BOOT
|
||||
|
||||
@@ -39,4 +39,9 @@ video_rkisp-$(CONFIG_VIDEO_ROCKCHIP_ISP_VERSION_V30) += \
|
||||
bridge.o \
|
||||
bridge_v30.o
|
||||
|
||||
video_rkisp-$(CONFIG_VIDEO_ROCKCHIP_ISP_VERSION_V32) += \
|
||||
capture_v32.o \
|
||||
isp_params_v32.o \
|
||||
isp_stats_v32.o
|
||||
|
||||
video_rkisp-$(CONFIG_VIDEO_ROCKCHIP_THUNDER_BOOT_ISP) += rkisp_tb_helper.o
|
||||
|
||||
@@ -900,6 +900,7 @@ static int rkisp_set_fmt(struct rkisp_stream *stream,
|
||||
bool try)
|
||||
{
|
||||
const struct capture_fmt *fmt;
|
||||
struct rkisp_vdev_node *node = &stream->vnode;
|
||||
const struct stream_config *config = stream->config;
|
||||
struct rkisp_device *dev = stream->ispdev;
|
||||
u32 planes, imagsize = 0;
|
||||
@@ -927,7 +928,8 @@ static int rkisp_set_fmt(struct rkisp_stream *stream,
|
||||
fmt = find_fmt(stream, pixm->pixelformat);
|
||||
if (!fmt) {
|
||||
v4l2_err(&dev->v4l2_dev,
|
||||
"nonsupport pixelformat:%c%c%c%c\n",
|
||||
"%s nonsupport pixelformat:%c%c%c%c\n",
|
||||
node->vdev.name,
|
||||
pixm->pixelformat,
|
||||
pixm->pixelformat >> 8,
|
||||
pixm->pixelformat >> 16,
|
||||
@@ -949,7 +951,8 @@ static int rkisp_set_fmt(struct rkisp_stream *stream,
|
||||
pixm->width != dev->isp_sdev.out_crop.width &&
|
||||
pixm->height != dev->isp_sdev.out_crop.height) {
|
||||
v4l2_warn(&dev->v4l2_dev,
|
||||
"fullpath %dx%d no equal to isp output %dx%d\n",
|
||||
"%s %dx%d no equal to isp output %dx%d\n",
|
||||
node->vdev.name,
|
||||
pixm->width, pixm->height,
|
||||
dev->isp_sdev.out_crop.width,
|
||||
dev->isp_sdev.out_crop.height);
|
||||
@@ -959,12 +962,31 @@ static int rkisp_set_fmt(struct rkisp_stream *stream,
|
||||
pixm->width != stream->dcrop.width &&
|
||||
pixm->height != stream->dcrop.height) {
|
||||
v4l2_warn(&dev->v4l2_dev,
|
||||
"fbcpatch no scale %dx%d should equal to crop %dx%d\n",
|
||||
"%s no scale %dx%d should equal to crop %dx%d\n",
|
||||
node->vdev.name,
|
||||
pixm->width, pixm->height,
|
||||
stream->dcrop.width, stream->dcrop.height);
|
||||
pixm->width = stream->dcrop.width;
|
||||
pixm->height = stream->dcrop.height;
|
||||
}
|
||||
} else if (stream->id == RKISP_STREAM_MPDS || stream->id == RKISP_STREAM_BPDS) {
|
||||
struct rkisp_stream *t = &dev->cap_dev.stream[stream->conn_id];
|
||||
|
||||
if (pixm->pixelformat != t->out_fmt.pixelformat ||
|
||||
pixm->width != t->out_fmt.width / 4 ||
|
||||
pixm->height != t->out_fmt.height / 4) {
|
||||
v4l2_warn(&dev->v4l2_dev,
|
||||
"%s from %s, force to %dx%d %c%c%c%c\n",
|
||||
node->vdev.name, t->vnode.vdev.name,
|
||||
t->out_fmt.width / 4, t->out_fmt.height / 4,
|
||||
t->out_fmt.pixelformat,
|
||||
t->out_fmt.pixelformat >> 8,
|
||||
t->out_fmt.pixelformat >> 16,
|
||||
t->out_fmt.pixelformat >> 24);
|
||||
pixm->pixelformat = t->out_fmt.pixelformat;
|
||||
pixm->width = t->out_fmt.width / 4;
|
||||
pixm->height = t->out_fmt.height / 4;
|
||||
}
|
||||
}
|
||||
|
||||
pixm->num_planes = fmt->mplanes;
|
||||
@@ -985,6 +1007,9 @@ static int rkisp_set_fmt(struct rkisp_stream *stream,
|
||||
ALIGN(pixm->width, 16) : pixm->width;
|
||||
h = (fmt->fmt_type == FMT_FBC) ?
|
||||
ALIGN(pixm->height, 16) : pixm->height;
|
||||
/* mainpath for warp default */
|
||||
if (dev->cap_dev.wrap_line && stream->id == RKISP_STREAM_MP)
|
||||
h = dev->cap_dev.wrap_line;
|
||||
width = i ? w / xsubs : w;
|
||||
height = i ? h / ysubs : h;
|
||||
|
||||
@@ -1009,7 +1034,7 @@ static int rkisp_set_fmt(struct rkisp_stream *stream,
|
||||
|
||||
/* 128bit AXI, 16byte align for bytesperline */
|
||||
if ((dev->isp_ver == ISP_V20 && stream->id == RKISP_STREAM_SP) ||
|
||||
dev->isp_ver == ISP_V30)
|
||||
dev->isp_ver == ISP_V30 || dev->isp_ver == ISP_V32)
|
||||
plane_fmt->bytesperline = ALIGN(plane_fmt->bytesperline, 16);
|
||||
|
||||
plane_fmt->sizeimage = plane_fmt->bytesperline * height;
|
||||
@@ -1048,8 +1073,8 @@ static int rkisp_set_fmt(struct rkisp_stream *stream,
|
||||
}
|
||||
|
||||
v4l2_dbg(1, rkisp_debug, &stream->ispdev->v4l2_dev,
|
||||
"%s: stream: %d req(%d, %d) out(%d, %d)\n", __func__,
|
||||
stream->id, pixm->width, pixm->height,
|
||||
"%s: %s req(%d, %d) out(%d, %d)\n", __func__,
|
||||
node->vdev.name, pixm->width, pixm->height,
|
||||
stream->out_fmt.width, stream->out_fmt.height);
|
||||
}
|
||||
|
||||
@@ -1181,7 +1206,10 @@ static int rkisp_get_cmsk(struct rkisp_stream *stream, struct rkisp_cmsk_cfg *cf
|
||||
unsigned long lock_flags = 0;
|
||||
u32 i, win_en, mode;
|
||||
|
||||
if (dev->isp_ver != ISP_V30 || stream->id == RKISP_STREAM_FBC) {
|
||||
if ((dev->isp_ver != ISP_V30 && dev->isp_ver != ISP_V32) ||
|
||||
stream->id == RKISP_STREAM_FBC ||
|
||||
stream->id == RKISP_STREAM_MPDS ||
|
||||
stream->id == RKISP_STREAM_BPDS) {
|
||||
v4l2_err(&dev->v4l2_dev, "%s not support\n", __func__);
|
||||
return -EINVAL;
|
||||
}
|
||||
@@ -1226,7 +1254,10 @@ static int rkisp_set_cmsk(struct rkisp_stream *stream, struct rkisp_cmsk_cfg *cf
|
||||
u32 height = dev->isp_sdev.out_crop.height;
|
||||
bool warn = false;
|
||||
|
||||
if (dev->isp_ver != ISP_V30 || stream->id == RKISP_STREAM_FBC) {
|
||||
if ((dev->isp_ver != ISP_V30 && dev->isp_ver != ISP_V32) ||
|
||||
stream->id == RKISP_STREAM_FBC ||
|
||||
stream->id == RKISP_STREAM_MPDS ||
|
||||
stream->id == RKISP_STREAM_BPDS) {
|
||||
v4l2_err(&dev->v4l2_dev, "%s not support\n", __func__);
|
||||
return -EINVAL;
|
||||
}
|
||||
@@ -1510,7 +1541,9 @@ static struct v4l2_rect *rkisp_update_crop(struct rkisp_stream *stream,
|
||||
stream->id == RKISP_STREAM_DMATX0 ||
|
||||
stream->id == RKISP_STREAM_DMATX1 ||
|
||||
stream->id == RKISP_STREAM_DMATX2 ||
|
||||
stream->id == RKISP_STREAM_DMATX3) {
|
||||
stream->id == RKISP_STREAM_DMATX3 ||
|
||||
stream->id == RKISP_STREAM_MPDS ||
|
||||
stream->id == RKISP_STREAM_BPDS) {
|
||||
sel->left = 0;
|
||||
sel->top = 0;
|
||||
sel->width = in->width;
|
||||
@@ -1678,7 +1711,7 @@ unreg:
|
||||
int rkisp_register_stream_vdevs(struct rkisp_device *dev)
|
||||
{
|
||||
struct rkisp_capture_device *cap_dev = &dev->cap_dev;
|
||||
struct stream_config *mp_cfg = &rkisp_mp_stream_config;
|
||||
struct stream_config *st_cfg = &rkisp_mp_stream_config;
|
||||
int ret = 0;
|
||||
|
||||
memset(cap_dev, 0, sizeof(*cap_dev));
|
||||
@@ -1687,25 +1720,32 @@ int rkisp_register_stream_vdevs(struct rkisp_device *dev)
|
||||
|
||||
if (dev->isp_ver <= ISP_V13) {
|
||||
if (dev->isp_ver == ISP_V12) {
|
||||
mp_cfg->max_rsz_width = CIF_ISP_INPUT_W_MAX_V12;
|
||||
mp_cfg->max_rsz_height = CIF_ISP_INPUT_H_MAX_V12;
|
||||
st_cfg->max_rsz_width = CIF_ISP_INPUT_W_MAX_V12;
|
||||
st_cfg->max_rsz_height = CIF_ISP_INPUT_H_MAX_V12;
|
||||
} else if (dev->isp_ver == ISP_V13) {
|
||||
mp_cfg->max_rsz_width = CIF_ISP_INPUT_W_MAX_V13;
|
||||
mp_cfg->max_rsz_height = CIF_ISP_INPUT_H_MAX_V13;
|
||||
st_cfg->max_rsz_width = CIF_ISP_INPUT_W_MAX_V13;
|
||||
st_cfg->max_rsz_height = CIF_ISP_INPUT_H_MAX_V13;
|
||||
}
|
||||
ret = rkisp_register_stream_v1x(dev);
|
||||
} else if (dev->isp_ver == ISP_V20) {
|
||||
ret = rkisp_register_stream_v20(dev);
|
||||
} else if (dev->isp_ver == ISP_V21) {
|
||||
mp_cfg->max_rsz_width = CIF_ISP_INPUT_W_MAX_V21;
|
||||
mp_cfg->max_rsz_height = CIF_ISP_INPUT_H_MAX_V21;
|
||||
st_cfg->max_rsz_width = CIF_ISP_INPUT_W_MAX_V21;
|
||||
st_cfg->max_rsz_height = CIF_ISP_INPUT_H_MAX_V21;
|
||||
ret = rkisp_register_stream_v21(dev);
|
||||
} else if (dev->isp_ver == ISP_V30) {
|
||||
mp_cfg->max_rsz_width = dev->hw_dev->is_unite ?
|
||||
st_cfg->max_rsz_width = dev->hw_dev->is_unite ?
|
||||
CIF_ISP_INPUT_W_MAX_V30_UNITE : CIF_ISP_INPUT_W_MAX_V30;
|
||||
mp_cfg->max_rsz_height = dev->hw_dev->is_unite ?
|
||||
st_cfg->max_rsz_height = dev->hw_dev->is_unite ?
|
||||
CIF_ISP_INPUT_H_MAX_V30_UNITE : CIF_ISP_INPUT_H_MAX_V30;
|
||||
ret = rkisp_register_stream_v30(dev);
|
||||
} else if (dev->isp_ver == ISP_V32) {
|
||||
st_cfg->max_rsz_width = CIF_ISP_INPUT_W_MAX_V32;
|
||||
st_cfg->max_rsz_height = CIF_ISP_INPUT_H_MAX_V32;
|
||||
st_cfg = &rkisp_sp_stream_config;
|
||||
st_cfg->max_rsz_width = CIF_ISP_INPUT_W_MAX_V32;
|
||||
st_cfg->max_rsz_height = CIF_ISP_INPUT_H_MAX_V32;
|
||||
ret = rkisp_register_stream_v32(dev);
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
@@ -1720,6 +1760,8 @@ void rkisp_unregister_stream_vdevs(struct rkisp_device *dev)
|
||||
rkisp_unregister_stream_v21(dev);
|
||||
else if (dev->isp_ver == ISP_V30)
|
||||
rkisp_unregister_stream_v30(dev);
|
||||
else if (dev->isp_ver == ISP_V32)
|
||||
rkisp_unregister_stream_v32(dev);
|
||||
}
|
||||
|
||||
void rkisp_mi_isr(u32 mis_val, struct rkisp_device *dev)
|
||||
@@ -1732,4 +1774,6 @@ void rkisp_mi_isr(u32 mis_val, struct rkisp_device *dev)
|
||||
rkisp_mi_v21_isr(mis_val, dev);
|
||||
else if (dev->isp_ver == ISP_V30)
|
||||
rkisp_mi_v30_isr(mis_val, dev);
|
||||
else if (dev->isp_ver == ISP_V32)
|
||||
rkisp_mi_v32_isr(mis_val, dev);
|
||||
}
|
||||
|
||||
@@ -44,7 +44,9 @@
|
||||
#define SP_VDEV_NAME DRIVER_NAME "_selfpath"
|
||||
#define MP_VDEV_NAME DRIVER_NAME "_mainpath"
|
||||
#define FBC_VDEV_NAME DRIVER_NAME "_fbcpath"
|
||||
#define BP_VDEV_NAME DRIVER_NAME "_fullpath"
|
||||
#define BP_VDEV_NAME DRIVER_NAME "_bypasspath"
|
||||
#define MPDS_VDEV_NAME DRIVER_NAME "_mainpath_4x4sampling"
|
||||
#define BPDS_VDEV_NAME DRIVER_NAME "_bypasspath_4x4sampling"
|
||||
#define VIR_VDEV_NAME DRIVER_NAME "_iqtool"
|
||||
|
||||
#define DMATX0_VDEV_NAME DRIVER_NAME "_rawwr0"
|
||||
@@ -70,6 +72,8 @@ enum {
|
||||
RKISP_STREAM_DMATX3,
|
||||
RKISP_STREAM_FBC,
|
||||
RKISP_STREAM_BP,
|
||||
RKISP_STREAM_MPDS,
|
||||
RKISP_STREAM_BPDS,
|
||||
RKISP_STREAM_VIR,
|
||||
RKISP_MAX_STREAM,
|
||||
};
|
||||
@@ -187,6 +191,7 @@ struct stream_config {
|
||||
u32 cr_offs_cnt_init;
|
||||
u32 y_base_ad_shd;
|
||||
u32 length;
|
||||
u32 ctrl;
|
||||
} mi;
|
||||
struct {
|
||||
u32 ctrl;
|
||||
@@ -241,6 +246,7 @@ struct rkisp_stream {
|
||||
struct list_head buf_queue;
|
||||
struct rkisp_buffer *curr_buf;
|
||||
struct rkisp_buffer *next_buf;
|
||||
struct rkisp_dummy_buffer dummy_buf;
|
||||
struct mutex apilock;
|
||||
bool streaming;
|
||||
bool stopping;
|
||||
@@ -275,6 +281,7 @@ struct rkisp_capture_device {
|
||||
struct rkisp_vir_cpy vir_cpy;
|
||||
atomic_t refcnt;
|
||||
u32 wait_line;
|
||||
u32 wrap_line;
|
||||
bool is_done_early;
|
||||
};
|
||||
|
||||
|
||||
@@ -67,7 +67,7 @@ static const struct capture_fmt bp_fmts[] = {
|
||||
}
|
||||
};
|
||||
|
||||
struct stream_config rkisp_fbc_stream_config = {
|
||||
static struct stream_config rkisp_fbc_stream_config = {
|
||||
.fmts = fbc_fmts,
|
||||
.fmt_size = ARRAY_SIZE(fbc_fmts),
|
||||
.frame_end_id = ISP3X_MI_MPFBC_FRAME,
|
||||
@@ -86,7 +86,7 @@ struct stream_config rkisp_fbc_stream_config = {
|
||||
},
|
||||
};
|
||||
|
||||
struct stream_config rkisp_bp_stream_config = {
|
||||
static struct stream_config rkisp_bp_stream_config = {
|
||||
.fmts = bp_fmts,
|
||||
.fmt_size = ARRAY_SIZE(bp_fmts),
|
||||
.frame_end_id = ISP3X_MI_BP_FRAME,
|
||||
@@ -109,6 +109,13 @@ struct stream_config rkisp_bp_stream_config = {
|
||||
},
|
||||
};
|
||||
|
||||
static inline bool is_bp_stream_stopped(void __iomem *base)
|
||||
{
|
||||
u32 ret = readl(base + ISP3X_MI_BP_WR_CTRL);
|
||||
|
||||
return !(ret & ISP3X_BP_ENABLE);
|
||||
}
|
||||
|
||||
static bool is_fbc_stream_stopped(void __iomem *base)
|
||||
{
|
||||
u32 ret = readl(base + ISP3X_MPFBC_CTRL);
|
||||
|
||||
1414
drivers/media/platform/rockchip/isp/capture_v32.c
Normal file
1414
drivers/media/platform/rockchip/isp/capture_v32.c
Normal file
File diff suppressed because it is too large
Load Diff
@@ -20,4 +20,16 @@ static inline void rkisp_mi_v30_isr(u32 mis_val, struct rkisp_device *dev) {}
|
||||
static inline void rkisp_mipi_v30_isr(u32 phy, u32 packet, u32 overflow, u32 state, struct rkisp_device *dev) {}
|
||||
#endif
|
||||
|
||||
#if IS_ENABLED(CONFIG_VIDEO_ROCKCHIP_ISP_VERSION_V32)
|
||||
int rkisp_register_stream_v32(struct rkisp_device *dev);
|
||||
void rkisp_unregister_stream_v32(struct rkisp_device *dev);
|
||||
void rkisp_mi_v32_isr(u32 mis_val, struct rkisp_device *dev);
|
||||
void rkisp_mipi_v32_isr(u32 phy, u32 packet, u32 overflow, u32 state, struct rkisp_device *dev);
|
||||
#else
|
||||
static inline int rkisp_register_stream_v32(struct rkisp_device *dev) { return -EINVAL; }
|
||||
static inline void rkisp_unregister_stream_v32(struct rkisp_device *dev) {}
|
||||
static inline void rkisp_mi_v32_isr(u32 mis_val, struct rkisp_device *dev) {}
|
||||
static inline void rkisp_mipi_v32_isr(u32 phy, u32 packet, u32 overflow, u32 state, struct rkisp_device *dev) {}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
@@ -71,6 +71,7 @@ enum rkisp_isp_ver {
|
||||
ISP_V20 = 0x40,
|
||||
ISP_V21 = 0x50,
|
||||
ISP_V30 = 0x60,
|
||||
ISP_V32 = 0x70,
|
||||
};
|
||||
|
||||
enum rkisp_sd_type {
|
||||
@@ -110,11 +111,9 @@ enum rkisp_fmt_raw_pat_type {
|
||||
struct rkisp_buffer {
|
||||
struct vb2_v4l2_buffer vb;
|
||||
struct list_head queue;
|
||||
void *vaddr[VIDEO_MAX_PLANES];
|
||||
u32 buff_addr[VIDEO_MAX_PLANES];
|
||||
int dev_id;
|
||||
union {
|
||||
u32 buff_addr[VIDEO_MAX_PLANES];
|
||||
void *vaddr[VIDEO_MAX_PLANES];
|
||||
};
|
||||
};
|
||||
|
||||
struct rkisp_dummy_buffer {
|
||||
|
||||
@@ -470,7 +470,8 @@ int rkisp_csi_config_patch(struct rkisp_device *dev)
|
||||
v4l2_subdev_call(mipi_sensor, core, ioctl,
|
||||
RKISP_VICAP_CMD_MODE, &mode);
|
||||
/* vicap direct to isp */
|
||||
if (dev->isp_ver == ISP_V30 && !mode.is_rdbk) {
|
||||
if ((dev->isp_ver == ISP_V30 || dev->isp_ver == ISP_V32) &&
|
||||
!mode.is_rdbk) {
|
||||
switch (dev->hdr.op_mode) {
|
||||
case HDR_RDBK_FRAME3:
|
||||
dev->hdr.op_mode = HDR_LINEX3_DDR;
|
||||
@@ -538,7 +539,7 @@ int rkisp_csi_config_patch(struct rkisp_device *dev)
|
||||
rkisp_unite_set_bits(dev, CTRL_SWS_CFG, 0, SW_MPIP_DROP_FRM_DIS,
|
||||
true, dev->hw_dev->is_unite);
|
||||
|
||||
if (dev->isp_ver == ISP_V30)
|
||||
if (dev->isp_ver == ISP_V30 || dev->isp_ver == ISP_V32)
|
||||
rkisp_unite_set_bits(dev, CTRL_SWS_CFG, 0, ISP3X_SW_ACK_FRM_PRO_DIS,
|
||||
true, dev->hw_dev->is_unite);
|
||||
|
||||
@@ -608,7 +609,7 @@ int rkisp_register_csi_subdev(struct rkisp_device *dev,
|
||||
csi_dev->pads[CSI_SRC_CH2].flags = MEDIA_PAD_FL_SOURCE;
|
||||
csi_dev->pads[CSI_SRC_CH3].flags = MEDIA_PAD_FL_SOURCE;
|
||||
csi_dev->pads[CSI_SRC_CH4].flags = MEDIA_PAD_FL_SOURCE;
|
||||
} else if (dev->isp_ver == ISP_V30) {
|
||||
} else if (dev->isp_ver == ISP_V30 || dev->isp_ver == ISP_V32) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
@@ -265,7 +265,8 @@ static int rkisp_pipeline_close(struct rkisp_pipeline *p)
|
||||
|
||||
atomic_dec(&p->power_cnt);
|
||||
|
||||
if (dev->isp_ver == ISP_V30 && !atomic_read(&p->power_cnt))
|
||||
if (!atomic_read(&p->power_cnt) &&
|
||||
(dev->isp_ver == ISP_V30 || dev->isp_ver == ISP_V32))
|
||||
rkisp_rx_buf_pool_free(dev);
|
||||
|
||||
return 0;
|
||||
@@ -470,6 +471,23 @@ static int _set_pipeline_default_fmt(struct rkisp_device *dev)
|
||||
width, height, V4L2_PIX_FMT_NV12);
|
||||
#endif
|
||||
}
|
||||
|
||||
if (dev->isp_ver == ISP_V32) {
|
||||
struct v4l2_pix_format_mplane pixm = {
|
||||
.width = width,
|
||||
.height = height,
|
||||
.pixelformat = rkisp_mbus_pixelcode_to_v4l2(code),
|
||||
};
|
||||
|
||||
rkisp_dmarx_set_fmt(&dev->dmarx_dev.stream[RKISP_STREAM_RAWRD0], pixm);
|
||||
rkisp_dmarx_set_fmt(&dev->dmarx_dev.stream[RKISP_STREAM_RAWRD2], pixm);
|
||||
rkisp_set_stream_def_fmt(dev, RKISP_STREAM_BP,
|
||||
width, height, V4L2_PIX_FMT_NV12);
|
||||
rkisp_set_stream_def_fmt(dev, RKISP_STREAM_MPDS,
|
||||
width / 4, height / 4, V4L2_PIX_FMT_NV12);
|
||||
rkisp_set_stream_def_fmt(dev, RKISP_STREAM_BPDS,
|
||||
width / 4, height / 4, V4L2_PIX_FMT_NV12);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
@@ -60,8 +60,8 @@
|
||||
#define GRP_ID_ISP_BRIDGE BIT(6)
|
||||
#define GRP_ID_CSI BIT(7)
|
||||
|
||||
#define RKISP_MAX_SENSOR 2
|
||||
#define RKISP_MAX_PIPELINE 4
|
||||
#define RKISP_MAX_SENSOR 4
|
||||
#define RKISP_MAX_PIPELINE 8
|
||||
|
||||
#define RKISP_MEDIA_BUS_FMT_MASK 0xF000
|
||||
#define RKISP_MEDIA_BUS_FMT_BAYER 0x3000
|
||||
@@ -181,7 +181,6 @@ struct rkisp_device {
|
||||
struct v4l2_ctrl_handler ctrl_handler;
|
||||
struct media_device media_dev;
|
||||
struct v4l2_async_notifier notifier;
|
||||
struct v4l2_subdev *subdevs[RKISP_SD_MAX];
|
||||
struct rkisp_sensor_info *active_sensor;
|
||||
struct rkisp_sensor_info sensors[RKISP_MAX_SENSOR];
|
||||
int num_sensors;
|
||||
|
||||
@@ -619,7 +619,8 @@ static void dmarx_stop_streaming(struct vb2_queue *queue)
|
||||
if (stream->id == RKISP_STREAM_RAWRD2 &&
|
||||
(stream->ispdev->isp_ver == ISP_V20 ||
|
||||
stream->ispdev->isp_ver == ISP_V21 ||
|
||||
stream->ispdev->isp_ver == ISP_V30))
|
||||
stream->ispdev->isp_ver == ISP_V30 ||
|
||||
stream->ispdev->isp_ver == ISP_V32))
|
||||
kfifo_reset(&stream->ispdev->rdbk_kfifo);
|
||||
}
|
||||
|
||||
@@ -732,7 +733,8 @@ static int rkisp_set_fmt(struct rkisp_stream *stream,
|
||||
|
||||
if ((stream->ispdev->isp_ver == ISP_V20 ||
|
||||
stream->ispdev->isp_ver == ISP_V21 ||
|
||||
stream->ispdev->isp_ver == ISP_V30) &&
|
||||
stream->ispdev->isp_ver == ISP_V30 ||
|
||||
stream->ispdev->isp_ver == ISP_V32) &&
|
||||
fmt->fmt_type == FMT_BAYER &&
|
||||
!stream->memory &&
|
||||
stream->id != RKISP_STREAM_DMARX)
|
||||
@@ -1132,7 +1134,8 @@ int rkisp_register_dmarx_vdev(struct rkisp_device *dev)
|
||||
#endif
|
||||
if (dev->isp_ver == ISP_V20 ||
|
||||
dev->isp_ver == ISP_V21 ||
|
||||
dev->isp_ver == ISP_V30) {
|
||||
dev->isp_ver == ISP_V30 ||
|
||||
dev->isp_ver == ISP_V32) {
|
||||
ret = dmarx_init(dev, RKISP_STREAM_RAWRD0);
|
||||
if (ret < 0)
|
||||
goto err_free_dmarx;
|
||||
@@ -1171,7 +1174,8 @@ void rkisp_unregister_dmarx_vdev(struct rkisp_device *dev)
|
||||
|
||||
if (dev->isp_ver == ISP_V20 ||
|
||||
dev->isp_ver == ISP_V21 ||
|
||||
dev->isp_ver == ISP_V30) {
|
||||
dev->isp_ver == ISP_V30 ||
|
||||
dev->isp_ver == ISP_V32) {
|
||||
stream = &dmarx_dev->stream[RKISP_STREAM_RAWRD0];
|
||||
rkisp_unregister_dmarx_video(stream);
|
||||
|
||||
|
||||
@@ -87,6 +87,23 @@ static void default_sw_reg_flag(struct rkisp_device *dev)
|
||||
ISP3X_RAWHIST_BIG1_BASE, ISP3X_RAWHIST_BIG2_BASE, ISP3X_RAWHIST_BIG3_BASE,
|
||||
ISP3X_RAWAF_CTRL, ISP3X_RAWAWB_CTRL,
|
||||
};
|
||||
u32 v32_reg[] = {
|
||||
ISP3X_VI_ISP_PATH, ISP3X_IMG_EFF_CTRL, ISP3X_CMSK_CTRL0,
|
||||
ISP3X_CCM_CTRL, ISP3X_CPROC_CTRL, ISP3X_DUAL_CROP_CTRL,
|
||||
ISP3X_GAMMA_OUT_CTRL, ISP3X_SELF_RESIZE_CTRL, ISP3X_MAIN_RESIZE_CTRL,
|
||||
ISP32_BP_RESIZE_BASE, ISP3X_MI_BP_WR_CTRL, ISP32_MI_MPDS_WR_CTRL,
|
||||
ISP32_MI_BPDS_WR_CTRL, ISP32_MI_WR_WRAP_CTRL,
|
||||
ISP3X_LSC_CTRL, ISP3X_DEBAYER_CONTROL, ISP3X_CAC_CTRL,
|
||||
ISP3X_YNR_GLOBAL_CTRL, ISP3X_CNR_CTRL, ISP3X_SHARP_EN,
|
||||
ISP3X_BAY3D_CTRL, ISP3X_GIC_CONTROL, ISP3X_BLS_CTRL,
|
||||
ISP3X_DPCC0_MODE, ISP3X_DPCC1_MODE, ISP3X_DPCC2_MODE,
|
||||
ISP3X_HDRMGE_CTRL, ISP3X_DRC_CTRL0, ISP3X_BAYNR_CTRL,
|
||||
ISP3X_LDCH_STS, ISP3X_DHAZ_CTRL, ISP3X_3DLUT_CTRL,
|
||||
ISP3X_GAIN_CTRL, ISP3X_RAWAE_LITE_CTRL, ISP3X_RAWAE_BIG1_BASE,
|
||||
ISP3X_RAWAE_BIG2_BASE, ISP3X_RAWAE_BIG3_BASE, ISP3X_RAWHIST_LITE_CTRL,
|
||||
ISP3X_RAWHIST_BIG1_BASE, ISP3X_RAWHIST_BIG2_BASE, ISP3X_RAWHIST_BIG3_BASE,
|
||||
ISP3X_RAWAF_CTRL, ISP3X_RAWAWB_CTRL,
|
||||
};
|
||||
u32 i, *flag, *reg, size;
|
||||
|
||||
switch (dev->isp_ver) {
|
||||
@@ -102,6 +119,10 @@ static void default_sw_reg_flag(struct rkisp_device *dev)
|
||||
reg = v30_reg;
|
||||
size = ARRAY_SIZE(v30_reg);
|
||||
break;
|
||||
case ISP_V32:
|
||||
reg = v32_reg;
|
||||
size = ARRAY_SIZE(v32_reg);
|
||||
break;
|
||||
default:
|
||||
return;
|
||||
}
|
||||
@@ -138,7 +159,8 @@ static irqreturn_t mipi_irq_hdl(int irq, void *ctx)
|
||||
rkisp_mipi_v13_isr(err1, err2, err3, isp);
|
||||
} else if (hw_dev->isp_ver == ISP_V20 ||
|
||||
hw_dev->isp_ver == ISP_V21 ||
|
||||
hw_dev->isp_ver == ISP_V30) {
|
||||
hw_dev->isp_ver == ISP_V30 ||
|
||||
hw_dev->isp_ver == ISP_V32) {
|
||||
u32 phy, packet, overflow, state;
|
||||
|
||||
state = readl(base + CSI2RX_ERR_STAT);
|
||||
@@ -150,8 +172,10 @@ static irqreturn_t mipi_irq_hdl(int irq, void *ctx)
|
||||
rkisp_mipi_v20_isr(phy, packet, overflow, state, isp);
|
||||
else if (hw_dev->isp_ver == ISP_V21)
|
||||
rkisp_mipi_v21_isr(phy, packet, overflow, state, isp);
|
||||
else
|
||||
else if (hw_dev->isp_ver == ISP_V30)
|
||||
rkisp_mipi_v30_isr(phy, packet, overflow, state, isp);
|
||||
else
|
||||
rkisp_mipi_v32_isr(phy, packet, overflow, state, isp);
|
||||
}
|
||||
} else {
|
||||
u32 mis_val = readl(base + CIF_MIPI_MIS);
|
||||
@@ -203,7 +227,8 @@ static irqreturn_t isp_irq_hdl(int irq, void *ctx)
|
||||
mis_val = readl(base + CIF_ISP_MIS);
|
||||
if (hw_dev->isp_ver == ISP_V20 ||
|
||||
hw_dev->isp_ver == ISP_V21 ||
|
||||
hw_dev->isp_ver == ISP_V30)
|
||||
hw_dev->isp_ver == ISP_V30 ||
|
||||
hw_dev->isp_ver == ISP_V32)
|
||||
mis_3a = readl(base + ISP_ISP3A_MIS);
|
||||
if (mis_val || mis_3a)
|
||||
rkisp_isp_isr(mis_val, mis_3a, isp);
|
||||
@@ -221,7 +246,8 @@ static irqreturn_t irq_handler(int irq, void *ctx)
|
||||
mis_val = readl(hw_dev->base_addr + CIF_ISP_MIS);
|
||||
if (hw_dev->isp_ver == ISP_V20 ||
|
||||
hw_dev->isp_ver == ISP_V21 ||
|
||||
hw_dev->isp_ver == ISP_V30)
|
||||
hw_dev->isp_ver == ISP_V30 ||
|
||||
hw_dev->isp_ver == ISP_V32)
|
||||
mis_3a = readl(hw_dev->base_addr + ISP_ISP3A_MIS);
|
||||
if (mis_val || mis_3a)
|
||||
rkisp_isp_isr(mis_val, mis_3a, isp);
|
||||
@@ -363,6 +389,13 @@ static const char * const rk3588_isp_unite_clks[] = {
|
||||
"clk_isp_core_vicap1",
|
||||
};
|
||||
|
||||
static const char * const rv1106_isp_clks[] = {
|
||||
"clk_isp_core",
|
||||
"aclk_isp",
|
||||
"hclk_isp",
|
||||
"clk_isp_core_vicap",
|
||||
};
|
||||
|
||||
static const char * const rv1126_isp_clks[] = {
|
||||
"clk_isp",
|
||||
"aclk_isp",
|
||||
@@ -429,6 +462,19 @@ static const struct isp_clk_info rk3588_isp_clk_rate[] = {
|
||||
}
|
||||
};
|
||||
|
||||
static const struct isp_clk_info rv1106_isp_clk_rate[] = {
|
||||
{
|
||||
.clk_rate = 200,
|
||||
.refer_data = 1920, //width
|
||||
}, {
|
||||
.clk_rate = 300,
|
||||
.refer_data = 2688,
|
||||
}, {
|
||||
.clk_rate = 400,
|
||||
.refer_data = 3072,
|
||||
}
|
||||
};
|
||||
|
||||
static const struct isp_clk_info rv1126_isp_clk_rate[] = {
|
||||
{
|
||||
.clk_rate = 20,
|
||||
@@ -484,12 +530,29 @@ static struct isp_irqs_data rk3588_isp_irqs[] = {
|
||||
{"mipi_irq", mipi_irq_hdl}
|
||||
};
|
||||
|
||||
static struct isp_irqs_data rv1106_isp_irqs[] = {
|
||||
{"isp_irq", isp_irq_hdl},
|
||||
{"mi_irq", mi_irq_hdl},
|
||||
{"mipi_irq", mipi_irq_hdl}
|
||||
};
|
||||
|
||||
static struct isp_irqs_data rv1126_isp_irqs[] = {
|
||||
{"isp_irq", isp_irq_hdl},
|
||||
{"mi_irq", mi_irq_hdl},
|
||||
{"mipi_irq", mipi_irq_hdl}
|
||||
};
|
||||
|
||||
static const struct isp_match_data rv1106_isp_match_data = {
|
||||
.clks = rv1106_isp_clks,
|
||||
.num_clks = ARRAY_SIZE(rv1106_isp_clks),
|
||||
.isp_ver = ISP_V32,
|
||||
.clk_rate_tbl = rv1106_isp_clk_rate,
|
||||
.num_clk_rate_tbl = ARRAY_SIZE(rv1106_isp_clk_rate),
|
||||
.irqs = rv1106_isp_irqs,
|
||||
.num_irqs = ARRAY_SIZE(rv1106_isp_irqs),
|
||||
.unite = false,
|
||||
};
|
||||
|
||||
static const struct isp_match_data rv1126_isp_match_data = {
|
||||
.clks = rv1126_isp_clks,
|
||||
.num_clks = ARRAY_SIZE(rv1126_isp_clks),
|
||||
@@ -614,6 +677,9 @@ static const struct of_device_id rkisp_hw_of_match[] = {
|
||||
}, {
|
||||
.compatible = "rockchip,rk3588-rkisp-unite",
|
||||
.data = &rk3588_isp_unite_match_data,
|
||||
}, {
|
||||
.compatible = "rockchip,rv1106-rkisp",
|
||||
.data = &rv1106_isp_match_data,
|
||||
}, {
|
||||
.compatible = "rockchip,rv1126-rkisp",
|
||||
.data = &rv1126_isp_match_data,
|
||||
@@ -684,6 +750,8 @@ static void isp_config_clk(struct rkisp_hw_dev *dev, int on)
|
||||
|
||||
if ((dev->isp_ver == ISP_V20 || dev->isp_ver == ISP_V30) && on)
|
||||
val |= ICCL_MPFBC_CLK;
|
||||
if (dev->isp_ver == ISP_V32 && on)
|
||||
val |= ISP32_BRSZ_CLK_ENABLE;
|
||||
|
||||
writel(val, dev->base_addr + CIF_ICCL);
|
||||
if (dev->is_unite)
|
||||
@@ -697,9 +765,8 @@ static void isp_config_clk(struct rkisp_hw_dev *dev, int on)
|
||||
CIF_CLK_CTRL_CP | CIF_CLK_CTRL_IE;
|
||||
|
||||
writel(val, dev->base_addr + CIF_VI_ISP_CLK_CTRL_V12);
|
||||
} else if (dev->isp_ver == ISP_V20 ||
|
||||
dev->isp_ver == ISP_V21 ||
|
||||
dev->isp_ver == ISP_V30) {
|
||||
} else if (dev->isp_ver == ISP_V20 || dev->isp_ver == ISP_V21 ||
|
||||
dev->isp_ver == ISP_V30 || dev->isp_ver == ISP_V32) {
|
||||
val = !on ? 0 :
|
||||
CLK_CTRL_MI_LDC | CLK_CTRL_MI_MP |
|
||||
CLK_CTRL_MI_JPEG | CLK_CTRL_MI_DP |
|
||||
@@ -708,7 +775,8 @@ static void isp_config_clk(struct rkisp_hw_dev *dev, int on)
|
||||
CLK_CTRL_MI_READ | CLK_CTRL_MI_RAWRD |
|
||||
CLK_CTRL_ISP_RAW;
|
||||
|
||||
if ((dev->isp_ver == ISP_V20 || dev->isp_ver == ISP_V30) && on)
|
||||
if ((dev->isp_ver == ISP_V20 ||
|
||||
dev->isp_ver == ISP_V30 || dev->isp_ver == ISP_V32) && on)
|
||||
val |= CLK_CTRL_ISP_3A;
|
||||
writel(val, dev->base_addr + CTRL_VI_ISP_CLK_CTRL);
|
||||
if (dev->is_unite)
|
||||
@@ -758,6 +826,12 @@ static int enable_sys_clk(struct rkisp_hw_dev *dev)
|
||||
writel(0, dev->base_addr + CIF_ISP_CSI0_MASK1);
|
||||
writel(0, dev->base_addr + CIF_ISP_CSI0_MASK2);
|
||||
writel(0, dev->base_addr + CIF_ISP_CSI0_MASK3);
|
||||
} else if (dev->isp_ver == ISP_V32) {
|
||||
/* disable down samplling default */
|
||||
writel(ISP32_DS_DS_DIS, dev->base_addr + ISP32_MI_MPDS_WR_CTRL);
|
||||
writel(ISP32_DS_DS_DIS, dev->base_addr + ISP32_MI_BPDS_WR_CTRL);
|
||||
|
||||
writel(0, dev->base_addr + ISP32_BLS_ISP_OB_PREDGAIN);
|
||||
}
|
||||
|
||||
return 0;
|
||||
|
||||
@@ -13,6 +13,7 @@
|
||||
#include "isp_params_v2x.h"
|
||||
#include "isp_params_v21.h"
|
||||
#include "isp_params_v3x.h"
|
||||
#include "isp_params_v32.h"
|
||||
|
||||
#define PARAMS_NAME DRIVER_NAME "-input-params"
|
||||
#define RKISP_ISP_PARAMS_REQ_BUFS_MIN 2
|
||||
@@ -297,8 +298,10 @@ static int rkisp_init_params_vdev(struct rkisp_isp_params_vdev *params_vdev)
|
||||
ret = rkisp_init_params_vdev_v21(params_vdev);
|
||||
else if (params_vdev->dev->isp_ver == ISP_V20)
|
||||
ret = rkisp_init_params_vdev_v2x(params_vdev);
|
||||
else
|
||||
else if (params_vdev->dev->isp_ver == ISP_V30)
|
||||
ret = rkisp_init_params_vdev_v3x(params_vdev);
|
||||
else
|
||||
ret = rkisp_init_params_vdev_v32(params_vdev);
|
||||
|
||||
params_vdev->vdev_fmt.fmt.meta.dataformat =
|
||||
V4L2_META_FMT_RK_ISP1_PARAMS;
|
||||
@@ -316,8 +319,10 @@ static void rkisp_uninit_params_vdev(struct rkisp_isp_params_vdev *params_vdev)
|
||||
rkisp_uninit_params_vdev_v21(params_vdev);
|
||||
else if (params_vdev->dev->isp_ver == ISP_V20)
|
||||
rkisp_uninit_params_vdev_v2x(params_vdev);
|
||||
else
|
||||
else if (params_vdev->dev->isp_ver == ISP_V30)
|
||||
rkisp_uninit_params_vdev_v3x(params_vdev);
|
||||
else
|
||||
rkisp_uninit_params_vdev_v32(params_vdev);
|
||||
}
|
||||
|
||||
void rkisp_params_cfg(struct rkisp_isp_params_vdev *params_vdev, u32 frame_id)
|
||||
|
||||
@@ -7,6 +7,7 @@
|
||||
#include <linux/rkisp1-config.h>
|
||||
#include <linux/rkisp2-config.h>
|
||||
#include <linux/rkisp3-config.h>
|
||||
#include <linux/rkisp32-config.h>
|
||||
#include <linux/rk-preisp.h>
|
||||
#include "common.h"
|
||||
|
||||
@@ -59,6 +60,7 @@ struct rkisp_isp_params_vdev {
|
||||
struct isp2x_isp_params_cfg *isp2x_params;
|
||||
struct isp21_isp_params_cfg *isp21_params;
|
||||
struct isp3x_isp_params_cfg *isp3x_params;
|
||||
struct isp32_isp_params_cfg *isp32_params;
|
||||
};
|
||||
struct v4l2_format vdev_fmt;
|
||||
bool streamon;
|
||||
|
||||
4466
drivers/media/platform/rockchip/isp/isp_params_v32.c
Normal file
4466
drivers/media/platform/rockchip/isp/isp_params_v32.c
Normal file
File diff suppressed because it is too large
Load Diff
204
drivers/media/platform/rockchip/isp/isp_params_v32.h
Normal file
204
drivers/media/platform/rockchip/isp/isp_params_v32.h
Normal file
@@ -0,0 +1,204 @@
|
||||
/* SPDX-License-Identifier: GPL-2.0 */
|
||||
/* Copyright (c) 2022 Rockchip Electronics Co., Ltd. */
|
||||
|
||||
#ifndef _RKISP_ISP_PARAM_V32_H
|
||||
#define _RKISP_ISP_PARAM_V32_H
|
||||
|
||||
#include <linux/rkisp1-config.h>
|
||||
#include <linux/rk-preisp.h>
|
||||
#include "common.h"
|
||||
#include "isp_params.h"
|
||||
|
||||
#define ISP32_3DLUT_BUF_NUM 2
|
||||
#define ISP32_3DLUT_BUF_SIZE (9 * 9 * 9 * 4)
|
||||
|
||||
#define ISP32_RAWHISTBIG_ROW_NUM 15
|
||||
#define ISP32_RAWHISTBIG_COLUMN_NUM 15
|
||||
#define ISP32_RAWHISTBIG_WEIGHT_REG_SIZE \
|
||||
(ISP32_RAWHISTBIG_ROW_NUM * ISP32_RAWHISTBIG_COLUMN_NUM)
|
||||
|
||||
#define ISP32_RAWHISTLITE_ROW_NUM 5
|
||||
#define ISP32_RAWHISTLITE_COLUMN_NUM 5
|
||||
#define ISP32_RAWHISTLITE_WEIGHT_REG_SIZE \
|
||||
(ISP32_RAWHISTLITE_ROW_NUM * ISP32_RAWHISTLITE_COLUMN_NUM)
|
||||
|
||||
struct rkisp_isp_params_vdev;
|
||||
struct rkisp_isp_params_ops_v32 {
|
||||
void (*dpcc_config)(struct rkisp_isp_params_vdev *params_vdev,
|
||||
const struct isp2x_dpcc_cfg *arg);
|
||||
void (*dpcc_enable)(struct rkisp_isp_params_vdev *params_vdev,
|
||||
bool en);
|
||||
void (*bls_config)(struct rkisp_isp_params_vdev *params_vdev,
|
||||
const struct isp32_bls_cfg *arg);
|
||||
void (*bls_enable)(struct rkisp_isp_params_vdev *params_vdev,
|
||||
bool en);
|
||||
void (*sdg_config)(struct rkisp_isp_params_vdev *params_vdev,
|
||||
const struct isp2x_sdg_cfg *arg);
|
||||
void (*sdg_enable)(struct rkisp_isp_params_vdev *params_vdev,
|
||||
bool en);
|
||||
void (*lsc_config)(struct rkisp_isp_params_vdev *params_vdev,
|
||||
const struct isp3x_lsc_cfg *arg);
|
||||
void (*lsc_enable)(struct rkisp_isp_params_vdev *params_vdev,
|
||||
bool en);
|
||||
void (*awbgain_config)(struct rkisp_isp_params_vdev *params_vdev,
|
||||
const struct isp32_awb_gain_cfg *arg);
|
||||
void (*awbgain_enable)(struct rkisp_isp_params_vdev *params_vdev,
|
||||
bool en);
|
||||
void (*debayer_config)(struct rkisp_isp_params_vdev *params_vdev,
|
||||
const struct isp32_debayer_cfg *arg);
|
||||
void (*debayer_enable)(struct rkisp_isp_params_vdev *params_vdev,
|
||||
bool en);
|
||||
void (*ccm_config)(struct rkisp_isp_params_vdev *params_vdev,
|
||||
const struct isp32_ccm_cfg *arg);
|
||||
void (*ccm_enable)(struct rkisp_isp_params_vdev *params_vdev,
|
||||
bool en);
|
||||
void (*goc_config)(struct rkisp_isp_params_vdev *params_vdev,
|
||||
const struct isp3x_gammaout_cfg *arg);
|
||||
void (*goc_enable)(struct rkisp_isp_params_vdev *params_vdev,
|
||||
bool en);
|
||||
void (*cproc_config)(struct rkisp_isp_params_vdev *params_vdev,
|
||||
const struct isp2x_cproc_cfg *arg);
|
||||
void (*cproc_enable)(struct rkisp_isp_params_vdev *params_vdev,
|
||||
bool en);
|
||||
void (*ie_config)(struct rkisp_isp_params_vdev *params_vdev,
|
||||
const struct isp2x_ie_cfg *arg);
|
||||
void (*ie_enable)(struct rkisp_isp_params_vdev *params_vdev,
|
||||
bool en);
|
||||
void (*rawaf_config)(struct rkisp_isp_params_vdev *params_vdev,
|
||||
const struct isp32_rawaf_meas_cfg *arg);
|
||||
void (*rawaf_enable)(struct rkisp_isp_params_vdev *params_vdev,
|
||||
bool en);
|
||||
void (*rawae0_config)(struct rkisp_isp_params_vdev *params_vdev,
|
||||
const struct isp2x_rawaelite_meas_cfg *arg);
|
||||
void (*rawae0_enable)(struct rkisp_isp_params_vdev *params_vdev,
|
||||
bool en);
|
||||
void (*rawae1_config)(struct rkisp_isp_params_vdev *params_vdev,
|
||||
const struct isp2x_rawaebig_meas_cfg *arg);
|
||||
void (*rawae1_enable)(struct rkisp_isp_params_vdev *params_vdev,
|
||||
bool en);
|
||||
void (*rawae2_config)(struct rkisp_isp_params_vdev *params_vdev,
|
||||
const struct isp2x_rawaebig_meas_cfg *arg);
|
||||
void (*rawae2_enable)(struct rkisp_isp_params_vdev *params_vdev,
|
||||
bool en);
|
||||
void (*rawae3_config)(struct rkisp_isp_params_vdev *params_vdev,
|
||||
const struct isp2x_rawaebig_meas_cfg *arg);
|
||||
void (*rawae3_enable)(struct rkisp_isp_params_vdev *params_vdev,
|
||||
bool en);
|
||||
void (*rawawb_config)(struct rkisp_isp_params_vdev *params_vdev,
|
||||
const struct isp32_rawawb_meas_cfg *arg);
|
||||
void (*rawawb_enable)(struct rkisp_isp_params_vdev *params_vdev,
|
||||
bool en);
|
||||
void (*rawhst0_config)(struct rkisp_isp_params_vdev *params_vdev,
|
||||
const struct isp2x_rawhistlite_cfg *arg);
|
||||
void (*rawhst0_enable)(struct rkisp_isp_params_vdev *params_vdev,
|
||||
bool en);
|
||||
void (*rawhst1_config)(struct rkisp_isp_params_vdev *params_vdev,
|
||||
const struct isp2x_rawhistbig_cfg *arg);
|
||||
void (*rawhst1_enable)(struct rkisp_isp_params_vdev *params_vdev,
|
||||
bool en);
|
||||
void (*rawhst2_config)(struct rkisp_isp_params_vdev *params_vdev,
|
||||
const struct isp2x_rawhistbig_cfg *arg);
|
||||
void (*rawhst2_enable)(struct rkisp_isp_params_vdev *params_vdev,
|
||||
bool en);
|
||||
void (*rawhst3_config)(struct rkisp_isp_params_vdev *params_vdev,
|
||||
const struct isp2x_rawhistbig_cfg *arg);
|
||||
void (*rawhst3_enable)(struct rkisp_isp_params_vdev *params_vdev,
|
||||
bool en);
|
||||
void (*hdrdrc_config)(struct rkisp_isp_params_vdev *params_vdev,
|
||||
const struct isp32_drc_cfg *arg,
|
||||
enum rkisp_params_type type);
|
||||
void (*hdrdrc_enable)(struct rkisp_isp_params_vdev *params_vdev,
|
||||
bool en);
|
||||
void (*hdrmge_config)(struct rkisp_isp_params_vdev *params_vdev,
|
||||
const struct isp32_hdrmge_cfg *arg,
|
||||
enum rkisp_params_type type);
|
||||
void (*hdrmge_enable)(struct rkisp_isp_params_vdev *params_vdev,
|
||||
bool en);
|
||||
void (*gic_config)(struct rkisp_isp_params_vdev *params_vdev,
|
||||
const struct isp21_gic_cfg *arg);
|
||||
void (*gic_enable)(struct rkisp_isp_params_vdev *params_vdev,
|
||||
bool en);
|
||||
void (*dhaz_config)(struct rkisp_isp_params_vdev *params_vdev,
|
||||
const struct isp32_dhaz_cfg *arg);
|
||||
void (*dhaz_enable)(struct rkisp_isp_params_vdev *params_vdev,
|
||||
bool en);
|
||||
void (*isp3dlut_config)(struct rkisp_isp_params_vdev *params_vdev,
|
||||
const struct isp2x_3dlut_cfg *arg);
|
||||
void (*isp3dlut_enable)(struct rkisp_isp_params_vdev *params_vdev,
|
||||
bool en);
|
||||
void (*ldch_config)(struct rkisp_isp_params_vdev *params_vdev,
|
||||
const struct isp32_ldch_cfg *arg);
|
||||
void (*ldch_enable)(struct rkisp_isp_params_vdev *params_vdev,
|
||||
bool en);
|
||||
void (*ynr_config)(struct rkisp_isp_params_vdev *params_vdev,
|
||||
const struct isp32_ynr_cfg *arg);
|
||||
void (*ynr_enable)(struct rkisp_isp_params_vdev *params_vdev,
|
||||
bool en);
|
||||
void (*cnr_config)(struct rkisp_isp_params_vdev *params_vdev,
|
||||
const struct isp32_cnr_cfg *arg);
|
||||
void (*cnr_enable)(struct rkisp_isp_params_vdev *params_vdev,
|
||||
bool en);
|
||||
void (*sharp_config)(struct rkisp_isp_params_vdev *params_vdev,
|
||||
const struct isp32_sharp_cfg *arg);
|
||||
void (*sharp_enable)(struct rkisp_isp_params_vdev *params_vdev,
|
||||
bool en);
|
||||
void (*baynr_config)(struct rkisp_isp_params_vdev *params_vdev,
|
||||
const struct isp32_baynr_cfg *arg);
|
||||
void (*baynr_enable)(struct rkisp_isp_params_vdev *params_vdev,
|
||||
bool en);
|
||||
void (*bay3d_config)(struct rkisp_isp_params_vdev *params_vdev,
|
||||
const struct isp32_bay3d_cfg *arg);
|
||||
void (*bay3d_enable)(struct rkisp_isp_params_vdev *params_vdev,
|
||||
bool en);
|
||||
void (*gain_config)(struct rkisp_isp_params_vdev *params_vdev,
|
||||
const struct isp3x_gain_cfg *arg);
|
||||
void (*gain_enable)(struct rkisp_isp_params_vdev *params_vdev,
|
||||
bool en);
|
||||
void (*cac_config)(struct rkisp_isp_params_vdev *params_vdev,
|
||||
const struct isp32_cac_cfg *arg);
|
||||
void (*cac_enable)(struct rkisp_isp_params_vdev *params_vdev,
|
||||
bool en);
|
||||
void (*csm_config)(struct rkisp_isp_params_vdev *params_vdev,
|
||||
const struct isp21_csm_cfg *arg);
|
||||
};
|
||||
|
||||
struct rkisp_isp_params_val_v32 {
|
||||
struct tasklet_struct lsc_tasklet;
|
||||
|
||||
struct rkisp_dummy_buffer buf_3dlut[ISP32_3DLUT_BUF_NUM];
|
||||
u32 buf_3dlut_idx;
|
||||
|
||||
struct rkisp_dummy_buffer buf_ldch[ISP3X_MESH_BUF_NUM];
|
||||
u32 buf_ldch_idx;
|
||||
|
||||
struct rkisp_dummy_buffer buf_cac[ISP3X_MESH_BUF_NUM];
|
||||
u32 buf_cac_idx;
|
||||
|
||||
struct rkisp_dummy_buffer buf_3dnr_iir;
|
||||
struct rkisp_dummy_buffer buf_3dnr_cur;
|
||||
struct rkisp_dummy_buffer buf_3dnr_ds;
|
||||
|
||||
struct isp32_hdrmge_cfg last_hdrmge;
|
||||
struct isp32_drc_cfg last_hdrdrc;
|
||||
struct isp32_hdrmge_cfg cur_hdrmge;
|
||||
struct isp32_drc_cfg cur_hdrdrc;
|
||||
|
||||
bool dhaz_en;
|
||||
bool drc_en;
|
||||
bool lsc_en;
|
||||
bool mge_en;
|
||||
bool lut3d_en;
|
||||
bool bay3d_en;
|
||||
bool is_bigmode;
|
||||
bool is_lo8x8;
|
||||
};
|
||||
|
||||
#if IS_ENABLED(CONFIG_VIDEO_ROCKCHIP_ISP_VERSION_V32)
|
||||
int rkisp_init_params_vdev_v32(struct rkisp_isp_params_vdev *params_vdev);
|
||||
void rkisp_uninit_params_vdev_v32(struct rkisp_isp_params_vdev *params_vdev);
|
||||
#else
|
||||
static inline int rkisp_init_params_vdev_v32(struct rkisp_isp_params_vdev *params_vdev) { return -EINVAL; }
|
||||
static inline void rkisp_uninit_params_vdev_v32(struct rkisp_isp_params_vdev *params_vdev) {}
|
||||
#endif
|
||||
|
||||
#endif /* _RKISP_ISP_PARAM_V32_H */
|
||||
@@ -12,6 +12,7 @@
|
||||
#include "isp_stats_v2x.h"
|
||||
#include "isp_stats_v21.h"
|
||||
#include "isp_stats_v3x.h"
|
||||
#include "isp_stats_v32.h"
|
||||
|
||||
#define STATS_NAME DRIVER_NAME "-statistics"
|
||||
#define RKISP_ISP_STATS_REQ_BUFS_MIN 2
|
||||
@@ -140,10 +141,14 @@ static void rkisp_stats_vb2_buf_queue(struct vb2_buffer *vb)
|
||||
struct rkisp_buffer *stats_buf = to_rkisp_buffer(vbuf);
|
||||
struct vb2_queue *vq = vb->vb2_queue;
|
||||
struct rkisp_isp_stats_vdev *stats_dev = vq->drv_priv;
|
||||
u32 size = stats_dev->vdev_fmt.fmt.meta.buffersize;
|
||||
unsigned long flags;
|
||||
|
||||
stats_buf->vaddr[0] = vb2_plane_vaddr(vb, 0);
|
||||
|
||||
if (stats_dev->dev->isp_ver == ISP_V32)
|
||||
stats_buf->buff_addr[0] = vb2_dma_contig_plane_dma_addr(vb, 0);
|
||||
if (stats_buf->vaddr[0])
|
||||
memset(stats_buf->vaddr[0], 0, size);
|
||||
spin_lock_irqsave(&stats_dev->rd_lock, flags);
|
||||
list_add_tail(&stats_buf->queue, &stats_dev->stat);
|
||||
spin_unlock_irqrestore(&stats_dev->rd_lock, flags);
|
||||
@@ -172,8 +177,16 @@ static void rkisp_stats_vb2_stop_streaming(struct vb2_queue *vq)
|
||||
list_del(&buf->queue);
|
||||
vb2_buffer_done(&buf->vb.vb2_buf, VB2_BUF_STATE_ERROR);
|
||||
}
|
||||
if (stats_vdev->cur_buf)
|
||||
if (stats_vdev->cur_buf) {
|
||||
vb2_buffer_done(&stats_vdev->cur_buf->vb.vb2_buf, VB2_BUF_STATE_ERROR);
|
||||
if (stats_vdev->cur_buf == stats_vdev->nxt_buf)
|
||||
stats_vdev->nxt_buf = NULL;
|
||||
stats_vdev->cur_buf = NULL;
|
||||
}
|
||||
if (stats_vdev->nxt_buf) {
|
||||
vb2_buffer_done(&stats_vdev->nxt_buf->vb.vb2_buf, VB2_BUF_STATE_ERROR);
|
||||
stats_vdev->nxt_buf = NULL;
|
||||
}
|
||||
spin_unlock_irqrestore(&stats_vdev->rd_lock, flags);
|
||||
}
|
||||
|
||||
@@ -208,7 +221,10 @@ static int rkisp_stats_init_vb2_queue(struct vb2_queue *q,
|
||||
q->io_modes = VB2_MMAP | VB2_USERPTR;
|
||||
q->drv_priv = stats_vdev;
|
||||
q->ops = &rkisp_stats_vb2_ops;
|
||||
q->mem_ops = &vb2_vmalloc_memops;
|
||||
if (stats_vdev->dev->isp_ver == ISP_V32)
|
||||
q->mem_ops = &vb2_dma_contig_memops;
|
||||
else
|
||||
q->mem_ops = &vb2_vmalloc_memops;
|
||||
q->buf_struct_size = sizeof(struct rkisp_buffer);
|
||||
q->timestamp_flags = V4L2_BUF_FLAG_TIMESTAMP_MONOTONIC;
|
||||
q->lock = &stats_vdev->dev->iqlock;
|
||||
@@ -247,8 +263,10 @@ static void rkisp_init_stats_vdev(struct rkisp_isp_stats_vdev *stats_vdev)
|
||||
rkisp_init_stats_vdev_v21(stats_vdev);
|
||||
else if (stats_vdev->dev->isp_ver == ISP_V20)
|
||||
rkisp_init_stats_vdev_v2x(stats_vdev);
|
||||
else
|
||||
else if (stats_vdev->dev->isp_ver == ISP_V30)
|
||||
rkisp_init_stats_vdev_v3x(stats_vdev);
|
||||
else
|
||||
rkisp_init_stats_vdev_v32(stats_vdev);
|
||||
}
|
||||
|
||||
static void rkisp_uninit_stats_vdev(struct rkisp_isp_stats_vdev *stats_vdev)
|
||||
@@ -259,8 +277,10 @@ static void rkisp_uninit_stats_vdev(struct rkisp_isp_stats_vdev *stats_vdev)
|
||||
rkisp_uninit_stats_vdev_v21(stats_vdev);
|
||||
else if (stats_vdev->dev->isp_ver == ISP_V20)
|
||||
rkisp_uninit_stats_vdev_v2x(stats_vdev);
|
||||
else
|
||||
else if (stats_vdev->dev->isp_ver == ISP_V30)
|
||||
rkisp_uninit_stats_vdev_v3x(stats_vdev);
|
||||
else
|
||||
rkisp_uninit_stats_vdev_v32(stats_vdev);
|
||||
}
|
||||
|
||||
void rkisp_stats_rdbk_enable(struct rkisp_isp_stats_vdev *stats_vdev, bool en)
|
||||
@@ -276,6 +296,14 @@ void rkisp_stats_first_ddr_config(struct rkisp_isp_stats_vdev *stats_vdev)
|
||||
rkisp_stats_first_ddr_config_v21(stats_vdev);
|
||||
else if (stats_vdev->dev->isp_ver == ISP_V30)
|
||||
rkisp_stats_first_ddr_config_v3x(stats_vdev);
|
||||
else if (stats_vdev->dev->isp_ver == ISP_V32)
|
||||
rkisp_stats_first_ddr_config_v32(stats_vdev);
|
||||
}
|
||||
|
||||
void rkisp_stats_next_ddr_config(struct rkisp_isp_stats_vdev *stats_vdev)
|
||||
{
|
||||
if (stats_vdev->dev->isp_ver == ISP_V32)
|
||||
rkisp_stats_next_ddr_config_v32(stats_vdev);
|
||||
}
|
||||
|
||||
void rkisp_stats_isr(struct rkisp_isp_stats_vdev *stats_vdev,
|
||||
|
||||
@@ -71,11 +71,13 @@ struct rkisp_isp_stats_vdev {
|
||||
|
||||
struct rkisp_dummy_buffer tmp_statsbuf;
|
||||
struct rkisp_buffer *cur_buf;
|
||||
struct rkisp_buffer *nxt_buf;
|
||||
};
|
||||
|
||||
void rkisp_stats_rdbk_enable(struct rkisp_isp_stats_vdev *stats_vdev, bool en);
|
||||
|
||||
void rkisp_stats_first_ddr_config(struct rkisp_isp_stats_vdev *stats_vdev);
|
||||
void rkisp_stats_next_ddr_config(struct rkisp_isp_stats_vdev *stats_vdev);
|
||||
|
||||
void rkisp_stats_isr(struct rkisp_isp_stats_vdev *stats_vdev,
|
||||
u32 isp_ris, u32 isp3a_ris);
|
||||
|
||||
656
drivers/media/platform/rockchip/isp/isp_stats_v32.c
Normal file
656
drivers/media/platform/rockchip/isp/isp_stats_v32.c
Normal file
@@ -0,0 +1,656 @@
|
||||
// SPDX-License-Identifier: GPL-2.0
|
||||
/* Copyright (c) 2022 Rockchip Electronics Co., Ltd. */
|
||||
|
||||
#include <linux/kfifo.h>
|
||||
#include <linux/rkisp32-config.h>
|
||||
#include <media/v4l2-common.h>
|
||||
#include <media/v4l2-ioctl.h>
|
||||
#include <media/videobuf2-core.h>
|
||||
#include <media/videobuf2-vmalloc.h> /* for ISP statistics */
|
||||
#include "dev.h"
|
||||
#include "regs.h"
|
||||
#include "common.h"
|
||||
#include "isp_stats.h"
|
||||
#include "isp_stats_v32.h"
|
||||
|
||||
#define ISP32_3A_MEAS_DONE BIT(31)
|
||||
|
||||
static void isp3_module_done(struct rkisp_isp_stats_vdev *stats_vdev,
|
||||
u32 reg, u32 value)
|
||||
{
|
||||
void __iomem *base = stats_vdev->dev->hw_dev->base_addr;
|
||||
|
||||
writel(value, base + reg);
|
||||
}
|
||||
|
||||
static u32 isp3_stats_read(struct rkisp_isp_stats_vdev *stats_vdev, u32 addr)
|
||||
{
|
||||
return rkisp_read(stats_vdev->dev, addr, true);
|
||||
}
|
||||
|
||||
static void isp3_stats_write(struct rkisp_isp_stats_vdev *stats_vdev,
|
||||
u32 addr, u32 value)
|
||||
{
|
||||
rkisp_write(stats_vdev->dev, addr, value, true);
|
||||
}
|
||||
|
||||
static int
|
||||
rkisp_stats_get_bls_stats(struct rkisp_isp_stats_vdev *stats_vdev,
|
||||
struct rkisp32_isp_stat_buffer *pbuf)
|
||||
{
|
||||
struct ispsd_in_fmt in_fmt = stats_vdev->dev->isp_sdev.in_fmt;
|
||||
enum rkisp_fmt_raw_pat_type raw_type = in_fmt.bayer_pat;
|
||||
struct isp2x_bls_stat *bls;
|
||||
u32 value;
|
||||
|
||||
if (!pbuf)
|
||||
return 0;
|
||||
|
||||
bls = &pbuf->params.bls;
|
||||
value = isp3_stats_read(stats_vdev, ISP3X_BLS_CTRL);
|
||||
if (value & (ISP_BLS_ENA | ISP_BLS_MODE_MEASURED)) {
|
||||
pbuf->meas_type |= ISP32_STAT_BLS;
|
||||
|
||||
switch (raw_type) {
|
||||
case RAW_BGGR:
|
||||
bls->meas_r = isp3_stats_read(stats_vdev, ISP3X_BLS_D_MEASURED);
|
||||
bls->meas_gr = isp3_stats_read(stats_vdev, ISP3X_BLS_C_MEASURED);
|
||||
bls->meas_gb = isp3_stats_read(stats_vdev, ISP3X_BLS_B_MEASURED);
|
||||
bls->meas_b = isp3_stats_read(stats_vdev, ISP3X_BLS_A_MEASURED);
|
||||
break;
|
||||
case RAW_GBRG:
|
||||
bls->meas_r = isp3_stats_read(stats_vdev, ISP3X_BLS_C_MEASURED);
|
||||
bls->meas_gr = isp3_stats_read(stats_vdev, ISP3X_BLS_D_MEASURED);
|
||||
bls->meas_gb = isp3_stats_read(stats_vdev, ISP3X_BLS_A_MEASURED);
|
||||
bls->meas_b = isp3_stats_read(stats_vdev, ISP3X_BLS_B_MEASURED);
|
||||
break;
|
||||
case RAW_GRBG:
|
||||
bls->meas_r = isp3_stats_read(stats_vdev, ISP3X_BLS_B_MEASURED);
|
||||
bls->meas_gr = isp3_stats_read(stats_vdev, ISP3X_BLS_A_MEASURED);
|
||||
bls->meas_gb = isp3_stats_read(stats_vdev, ISP3X_BLS_D_MEASURED);
|
||||
bls->meas_b = isp3_stats_read(stats_vdev, ISP3X_BLS_C_MEASURED);
|
||||
break;
|
||||
case RAW_RGGB:
|
||||
bls->meas_r = isp3_stats_read(stats_vdev, ISP3X_BLS_A_MEASURED);
|
||||
bls->meas_gr = isp3_stats_read(stats_vdev, ISP3X_BLS_B_MEASURED);
|
||||
bls->meas_gb = isp3_stats_read(stats_vdev, ISP3X_BLS_C_MEASURED);
|
||||
bls->meas_b = isp3_stats_read(stats_vdev, ISP3X_BLS_D_MEASURED);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int
|
||||
rkisp_stats_get_dhaz_stats(struct rkisp_isp_stats_vdev *stats_vdev,
|
||||
struct rkisp32_isp_stat_buffer *pbuf)
|
||||
{
|
||||
struct isp3x_dhaz_stat *dhaz;
|
||||
u32 value, i;
|
||||
|
||||
if (!pbuf)
|
||||
return 0;
|
||||
|
||||
dhaz = &pbuf->params.dhaz;
|
||||
value = isp3_stats_read(stats_vdev, ISP3X_DHAZ_CTRL);
|
||||
if (value & ISP_DHAZ_ENMUX) {
|
||||
pbuf->meas_type |= ISP32_STAT_DHAZ;
|
||||
|
||||
value = isp3_stats_read(stats_vdev, ISP3X_DHAZ_SUMH_RD);
|
||||
dhaz->dhaz_pic_sumh = value;
|
||||
|
||||
value = isp3_stats_read(stats_vdev, ISP3X_DHAZ_ADP_RD0);
|
||||
dhaz->dhaz_adp_air_base = value >> 16;
|
||||
dhaz->dhaz_adp_wt = value & 0xFFFF;
|
||||
|
||||
value = isp3_stats_read(stats_vdev, ISP3X_DHAZ_ADP_RD1);
|
||||
dhaz->dhaz_adp_gratio = value >> 16;
|
||||
dhaz->dhaz_adp_tmax = value & 0xFFFF;
|
||||
|
||||
for (i = 0; i < ISP3X_DHAZ_HIST_IIR_NUM / 2; i++) {
|
||||
value = isp3_stats_read(stats_vdev, ISP3X_DHAZ_HIST_REG0 + 4 * i);
|
||||
dhaz->h_rgb_iir[2 * i] = value & 0xFFFF;
|
||||
dhaz->h_rgb_iir[2 * i + 1] = value >> 16;
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int
|
||||
rkisp_stats_get_rawawb_meas_ddr(struct rkisp_isp_stats_vdev *stats_vdev,
|
||||
struct rkisp32_isp_stat_buffer *pbuf)
|
||||
{
|
||||
u32 ctrl = isp3_stats_read(stats_vdev, ISP3X_RAWAWB_CTRL);
|
||||
|
||||
if (!(ctrl & ISP32_3A_MEAS_DONE)) {
|
||||
v4l2_dbg(1, rkisp_debug, &stats_vdev->dev->v4l2_dev,
|
||||
"%s fail, ctrl:0x%x\n", __func__, ctrl);
|
||||
return -ENODATA;
|
||||
}
|
||||
|
||||
if (!pbuf)
|
||||
goto out;
|
||||
|
||||
pbuf->meas_type |= ISP32_STAT_RAWAWB;
|
||||
out:
|
||||
isp3_module_done(stats_vdev, ISP3X_RAWAWB_CTRL, ctrl);
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int
|
||||
rkisp_stats_get_rawaf_meas_ddr(struct rkisp_isp_stats_vdev *stats_vdev,
|
||||
struct rkisp32_isp_stat_buffer *pbuf)
|
||||
{
|
||||
struct isp32_rawaf_stat *af;
|
||||
u32 ctrl;
|
||||
|
||||
ctrl = isp3_stats_read(stats_vdev, ISP3X_RAWAF_CTRL);
|
||||
if (!(ctrl & ISP32_3A_MEAS_DONE)) {
|
||||
v4l2_dbg(1, rkisp_debug, &stats_vdev->dev->v4l2_dev,
|
||||
"%s fail, ctrl:0x%x\n", __func__, ctrl);
|
||||
return -ENODATA;
|
||||
}
|
||||
|
||||
if (!pbuf)
|
||||
goto out;
|
||||
|
||||
af = &pbuf->params.rawaf;
|
||||
pbuf->meas_type |= ISP32_STAT_RAWAF;
|
||||
|
||||
af->afm_sum_b = isp3_stats_read(stats_vdev, ISP3X_RAWAF_SUM_B);
|
||||
af->afm_lum_b = isp3_stats_read(stats_vdev, ISP3X_RAWAF_LUM_B);
|
||||
af->int_state = isp3_stats_read(stats_vdev, ISP3X_RAWAF_INT_STATE);
|
||||
af->highlit_cnt_winb = isp3_stats_read(stats_vdev, ISP3X_RAWAF_HIGHLIT_CNT_WINB);
|
||||
|
||||
out:
|
||||
isp3_module_done(stats_vdev, ISP3X_RAWAF_CTRL, ctrl);
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int
|
||||
rkisp_stats_get_rawaebig_meas_ddr(struct rkisp_isp_stats_vdev *stats_vdev,
|
||||
struct isp32_rawaebig_stat1 *ae, u32 blk_no)
|
||||
{
|
||||
u32 i, base, addr, ctrl;
|
||||
|
||||
switch (blk_no) {
|
||||
case 1:
|
||||
base = RAWAE_BIG2_BASE;
|
||||
break;
|
||||
case 2:
|
||||
base = RAWAE_BIG3_BASE;
|
||||
break;
|
||||
default:
|
||||
base = RAWAE_BIG1_BASE;
|
||||
break;
|
||||
}
|
||||
|
||||
ctrl = isp3_stats_read(stats_vdev, base + ISP3X_RAWAE_BIG_CTRL);
|
||||
if (!(ctrl & ISP32_3A_MEAS_DONE)) {
|
||||
v4l2_dbg(1, rkisp_debug, &stats_vdev->dev->v4l2_dev,
|
||||
"%s fail, addr:0x%x ctrl:0x%x\n",
|
||||
__func__, base, ctrl);
|
||||
return -ENODATA;
|
||||
}
|
||||
|
||||
if (!ae)
|
||||
goto out;
|
||||
|
||||
for (i = 0; i < ISP32_RAWAEBIG_SUBWIN_NUM; i++) {
|
||||
addr = base + ISP3X_RAWAE_BIG_WND1_SUMR + i * 4;
|
||||
ae->sumr[i] = isp3_stats_read(stats_vdev, addr);
|
||||
addr = base + ISP3X_RAWAE_BIG_WND1_SUMG + i * 4;
|
||||
ae->sumg[i] = isp3_stats_read(stats_vdev, addr);
|
||||
addr = base + ISP3X_RAWAE_BIG_WND1_SUMB + i * 4;
|
||||
ae->sumb[i] = isp3_stats_read(stats_vdev, addr);
|
||||
}
|
||||
|
||||
out:
|
||||
isp3_module_done(stats_vdev, base + ISP3X_RAWAE_BIG_CTRL, ctrl);
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int
|
||||
rkisp_stats_get_rawhstbig_meas_ddr(struct rkisp_isp_stats_vdev *stats_vdev,
|
||||
struct isp2x_rawhistbig_stat *hst, u32 blk_no)
|
||||
{
|
||||
u32 addr, ctrl;
|
||||
|
||||
switch (blk_no) {
|
||||
case 1:
|
||||
addr = ISP3X_RAWHIST_BIG2_BASE;
|
||||
break;
|
||||
case 2:
|
||||
addr = ISP3X_RAWHIST_BIG3_BASE;
|
||||
break;
|
||||
case 0:
|
||||
default:
|
||||
addr = ISP3X_RAWHIST_BIG1_BASE;
|
||||
break;
|
||||
}
|
||||
|
||||
ctrl = isp3_stats_read(stats_vdev, addr + ISP3X_RAWHIST_BIG_CTRL);
|
||||
if (!(ctrl & ISP32_3A_MEAS_DONE)) {
|
||||
v4l2_dbg(1, rkisp_debug, &stats_vdev->dev->v4l2_dev,
|
||||
"%s fail, addr:0x%x ctrl:0x%x\n",
|
||||
__func__, addr, ctrl);
|
||||
return -ENODATA;
|
||||
}
|
||||
|
||||
if (!hst)
|
||||
goto out;
|
||||
|
||||
out:
|
||||
isp3_module_done(stats_vdev, addr + ISP3X_RAWHIST_BIG_CTRL, ctrl);
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int
|
||||
rkisp_stats_get_rawae1_meas_ddr(struct rkisp_isp_stats_vdev *stats_vdev,
|
||||
struct rkisp32_isp_stat_buffer *pbuf)
|
||||
{
|
||||
int ret = 0;
|
||||
|
||||
if (!pbuf) {
|
||||
rkisp_stats_get_rawaebig_meas_ddr(stats_vdev, NULL, 1);
|
||||
} else {
|
||||
ret = rkisp_stats_get_rawaebig_meas_ddr(stats_vdev,
|
||||
&pbuf->params.rawae1_1, 1);
|
||||
if (!ret)
|
||||
pbuf->meas_type |= ISP32_STAT_RAWAE1;
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
static int
|
||||
rkisp_stats_get_rawhst1_meas_ddr(struct rkisp_isp_stats_vdev *stats_vdev,
|
||||
struct rkisp32_isp_stat_buffer *pbuf)
|
||||
{
|
||||
int ret = 0;
|
||||
|
||||
if (!pbuf) {
|
||||
rkisp_stats_get_rawhstbig_meas_ddr(stats_vdev, NULL, 1);
|
||||
} else {
|
||||
ret = rkisp_stats_get_rawhstbig_meas_ddr(stats_vdev,
|
||||
&pbuf->params.rawhist1, 1);
|
||||
if (!ret)
|
||||
pbuf->meas_type |= ISP32_STAT_RAWHST1;
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
static int
|
||||
rkisp_stats_get_rawae2_meas_ddr(struct rkisp_isp_stats_vdev *stats_vdev,
|
||||
struct rkisp32_isp_stat_buffer *pbuf)
|
||||
{
|
||||
int ret = 0;
|
||||
|
||||
if (!pbuf) {
|
||||
rkisp_stats_get_rawaebig_meas_ddr(stats_vdev, NULL, 2);
|
||||
} else {
|
||||
ret = rkisp_stats_get_rawaebig_meas_ddr(stats_vdev,
|
||||
&pbuf->params.rawae2_1, 2);
|
||||
if (!ret)
|
||||
pbuf->meas_type |= ISP32_STAT_RAWAE2;
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
static int
|
||||
rkisp_stats_get_rawhst2_meas_ddr(struct rkisp_isp_stats_vdev *stats_vdev,
|
||||
struct rkisp32_isp_stat_buffer *pbuf)
|
||||
{
|
||||
int ret = 0;
|
||||
|
||||
if (!pbuf) {
|
||||
rkisp_stats_get_rawhstbig_meas_ddr(stats_vdev, NULL, 2);
|
||||
} else {
|
||||
ret = rkisp_stats_get_rawhstbig_meas_ddr(stats_vdev,
|
||||
&pbuf->params.rawhist2, 2);
|
||||
if (!ret)
|
||||
pbuf->meas_type |= ISP32_STAT_RAWHST2;
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
static int
|
||||
rkisp_stats_get_rawae3_meas_ddr(struct rkisp_isp_stats_vdev *stats_vdev,
|
||||
struct rkisp32_isp_stat_buffer *pbuf)
|
||||
{
|
||||
int ret = 0;
|
||||
|
||||
if (!pbuf) {
|
||||
rkisp_stats_get_rawaebig_meas_ddr(stats_vdev, NULL, 0);
|
||||
} else {
|
||||
ret = rkisp_stats_get_rawaebig_meas_ddr(stats_vdev,
|
||||
&pbuf->params.rawae3_1, 0);
|
||||
if (!ret)
|
||||
pbuf->meas_type |= ISP32_STAT_RAWAE3;
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
static int
|
||||
rkisp_stats_get_rawhst3_meas_ddr(struct rkisp_isp_stats_vdev *stats_vdev,
|
||||
struct rkisp32_isp_stat_buffer *pbuf)
|
||||
{
|
||||
int ret = 0;
|
||||
|
||||
if (!pbuf) {
|
||||
rkisp_stats_get_rawhstbig_meas_ddr(stats_vdev, NULL, 0);
|
||||
} else {
|
||||
ret = rkisp_stats_get_rawhstbig_meas_ddr(stats_vdev,
|
||||
&pbuf->params.rawhist3, 0);
|
||||
if (!ret)
|
||||
pbuf->meas_type |= ISP32_STAT_RAWHST3;
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
static int
|
||||
rkisp_stats_get_rawaelite_meas_ddr(struct rkisp_isp_stats_vdev *stats_vdev,
|
||||
struct rkisp32_isp_stat_buffer *pbuf)
|
||||
{
|
||||
u32 ctrl;
|
||||
|
||||
ctrl = isp3_stats_read(stats_vdev, ISP3X_RAWAE_LITE_CTRL);
|
||||
if ((ctrl & ISP32_3A_MEAS_DONE) == 0) {
|
||||
v4l2_dbg(1, rkisp_debug, &stats_vdev->dev->v4l2_dev,
|
||||
"%s fail, ctrl:0x%x\n", __func__, ctrl);
|
||||
return -ENODATA;
|
||||
}
|
||||
|
||||
if (!pbuf)
|
||||
goto out;
|
||||
|
||||
pbuf->meas_type |= ISP32_STAT_RAWAE0;
|
||||
|
||||
out:
|
||||
isp3_module_done(stats_vdev, ISP3X_RAWAE_LITE_CTRL, ctrl);
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int
|
||||
rkisp_stats_get_rawhstlite_meas_ddr(struct rkisp_isp_stats_vdev *stats_vdev,
|
||||
struct rkisp32_isp_stat_buffer *pbuf)
|
||||
{
|
||||
u32 ctrl;
|
||||
|
||||
ctrl = isp3_stats_read(stats_vdev, ISP3X_RAWHIST_LITE_CTRL);
|
||||
if ((ctrl & ISP32_3A_MEAS_DONE) == 0) {
|
||||
v4l2_dbg(1, rkisp_debug, &stats_vdev->dev->v4l2_dev,
|
||||
"%s fail, ctrl:0x%x\n", __func__, ctrl);
|
||||
return -ENODATA;
|
||||
}
|
||||
|
||||
if (!pbuf)
|
||||
goto out;
|
||||
|
||||
pbuf->meas_type |= ISP32_STAT_RAWHST0;
|
||||
|
||||
out:
|
||||
isp3_module_done(stats_vdev, ISP3X_RAWHIST_LITE_CTRL, ctrl);
|
||||
return 0;
|
||||
}
|
||||
|
||||
static struct rkisp_stats_ops_v32 __maybe_unused stats_ddr_ops_v32 = {
|
||||
.get_rawawb_meas = rkisp_stats_get_rawawb_meas_ddr,
|
||||
.get_rawaf_meas = rkisp_stats_get_rawaf_meas_ddr,
|
||||
.get_rawae0_meas = rkisp_stats_get_rawaelite_meas_ddr,
|
||||
.get_rawhst0_meas = rkisp_stats_get_rawhstlite_meas_ddr,
|
||||
.get_rawae1_meas = rkisp_stats_get_rawae1_meas_ddr,
|
||||
.get_rawhst1_meas = rkisp_stats_get_rawhst1_meas_ddr,
|
||||
.get_rawae2_meas = rkisp_stats_get_rawae2_meas_ddr,
|
||||
.get_rawhst2_meas = rkisp_stats_get_rawhst2_meas_ddr,
|
||||
.get_rawae3_meas = rkisp_stats_get_rawae3_meas_ddr,
|
||||
.get_rawhst3_meas = rkisp_stats_get_rawhst3_meas_ddr,
|
||||
.get_bls_stats = rkisp_stats_get_bls_stats,
|
||||
.get_dhaz_stats = rkisp_stats_get_dhaz_stats,
|
||||
};
|
||||
|
||||
static void
|
||||
rkisp_stats_update_buf(struct rkisp_isp_stats_vdev *stats_vdev)
|
||||
{
|
||||
struct rkisp_device *dev = stats_vdev->dev;
|
||||
struct rkisp_buffer *buf;
|
||||
unsigned long flags;
|
||||
|
||||
spin_lock_irqsave(&stats_vdev->rd_lock, flags);
|
||||
if (!stats_vdev->nxt_buf && !list_empty(&stats_vdev->stat)) {
|
||||
buf = list_first_entry(&stats_vdev->stat,
|
||||
struct rkisp_buffer, queue);
|
||||
list_del(&buf->queue);
|
||||
stats_vdev->nxt_buf = buf;
|
||||
}
|
||||
spin_unlock_irqrestore(&stats_vdev->rd_lock, flags);
|
||||
|
||||
if (stats_vdev->nxt_buf) {
|
||||
rkisp_set_bits(dev, ISP3X_SWS_CFG, 0, ISP3X_3A_DDR_WRITE_EN, false);
|
||||
rkisp_write(dev, ISP3X_MI_3A_WR_BASE, stats_vdev->nxt_buf->buff_addr[0], false);
|
||||
v4l2_dbg(2, rkisp_debug, &dev->v4l2_dev,
|
||||
"%s BASE:0x%x SHD:0x%x\n",
|
||||
__func__, stats_vdev->nxt_buf->buff_addr[0],
|
||||
isp3_stats_read(stats_vdev, ISP3X_MI_3A_WR_BASE));
|
||||
if (!dev->hw_dev->is_single) {
|
||||
stats_vdev->cur_buf = stats_vdev->nxt_buf;
|
||||
stats_vdev->nxt_buf = NULL;
|
||||
}
|
||||
} else {
|
||||
rkisp_clear_bits(dev, ISP3X_SWS_CFG, ISP3X_3A_DDR_WRITE_EN, false);
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
rkisp_stats_send_meas_v32(struct rkisp_isp_stats_vdev *stats_vdev,
|
||||
struct rkisp_isp_readout_work *meas_work)
|
||||
{
|
||||
unsigned int cur_frame_id = -1;
|
||||
struct rkisp_buffer *cur_buf = stats_vdev->cur_buf;
|
||||
struct rkisp32_isp_stat_buffer *cur_stat_buf = NULL;
|
||||
struct rkisp_stats_ops_v32 *ops =
|
||||
(struct rkisp_stats_ops_v32 *)stats_vdev->priv_ops;
|
||||
u32 size = sizeof(struct rkisp32_isp_stat_buffer);
|
||||
int ret = 0;
|
||||
|
||||
/* config buf for next frame */
|
||||
stats_vdev->cur_buf = NULL;
|
||||
if (stats_vdev->nxt_buf) {
|
||||
stats_vdev->cur_buf = stats_vdev->nxt_buf;
|
||||
stats_vdev->nxt_buf = NULL;
|
||||
}
|
||||
rkisp_stats_update_buf(stats_vdev);
|
||||
|
||||
cur_frame_id = meas_work->frame_id;
|
||||
|
||||
if (cur_buf) {
|
||||
cur_stat_buf =
|
||||
(struct rkisp32_isp_stat_buffer *)(cur_buf->vaddr[0]);
|
||||
cur_stat_buf->frame_id = cur_frame_id;
|
||||
}
|
||||
|
||||
if (meas_work->isp_ris & ISP3X_AFM_SUM_OF)
|
||||
v4l2_warn(stats_vdev->vnode.vdev.v4l2_dev,
|
||||
"ISP3X_AFM_SUM_OF\n");
|
||||
|
||||
if (meas_work->isp_ris & ISP3X_AFM_LUM_OF)
|
||||
v4l2_warn(stats_vdev->vnode.vdev.v4l2_dev,
|
||||
"ISP3X_AFM_LUM_OF\n");
|
||||
|
||||
if (meas_work->isp3a_ris & ISP3X_3A_RAWAF_SUM)
|
||||
v4l2_warn(stats_vdev->vnode.vdev.v4l2_dev,
|
||||
"ISP3X_3A_RAWAF_SUM\n");
|
||||
|
||||
if (meas_work->isp3a_ris & ISP3X_3A_RAWAWB)
|
||||
ret |= ops->get_rawawb_meas(stats_vdev, cur_stat_buf);
|
||||
|
||||
if (meas_work->isp3a_ris & ISP3X_3A_RAWAF)
|
||||
ret |= ops->get_rawaf_meas(stats_vdev, cur_stat_buf);
|
||||
|
||||
if (meas_work->isp3a_ris & ISP3X_3A_RAWAE_BIG)
|
||||
ret |= ops->get_rawae3_meas(stats_vdev, cur_stat_buf);
|
||||
|
||||
if (meas_work->isp3a_ris & ISP3X_3A_RAWHIST_BIG)
|
||||
ret |= ops->get_rawhst3_meas(stats_vdev, cur_stat_buf);
|
||||
|
||||
if (meas_work->isp3a_ris & ISP3X_3A_RAWAE_CH0)
|
||||
ret |= ops->get_rawae0_meas(stats_vdev, cur_stat_buf);
|
||||
|
||||
if (meas_work->isp3a_ris & ISP3X_3A_RAWAE_CH1)
|
||||
ret |= ops->get_rawae1_meas(stats_vdev, cur_stat_buf);
|
||||
|
||||
if (meas_work->isp3a_ris & ISP3X_3A_RAWAE_CH2)
|
||||
ret |= ops->get_rawae2_meas(stats_vdev, cur_stat_buf);
|
||||
|
||||
if (meas_work->isp3a_ris & ISP3X_3A_RAWHIST_CH0)
|
||||
ret |= ops->get_rawhst0_meas(stats_vdev, cur_stat_buf);
|
||||
|
||||
if (meas_work->isp3a_ris & ISP3X_3A_RAWHIST_CH1)
|
||||
ret |= ops->get_rawhst1_meas(stats_vdev, cur_stat_buf);
|
||||
|
||||
if (meas_work->isp3a_ris & ISP3X_3A_RAWHIST_CH2)
|
||||
ret |= ops->get_rawhst2_meas(stats_vdev, cur_stat_buf);
|
||||
|
||||
if (meas_work->isp_ris & ISP3X_FRAME) {
|
||||
ret |= ops->get_bls_stats(stats_vdev, cur_stat_buf);
|
||||
ret |= ops->get_dhaz_stats(stats_vdev, cur_stat_buf);
|
||||
}
|
||||
|
||||
if (cur_buf) {
|
||||
if (ret || !cur_stat_buf->meas_type) {
|
||||
unsigned long flags;
|
||||
|
||||
spin_lock_irqsave(&stats_vdev->rd_lock, flags);
|
||||
list_add_tail(&cur_buf->queue, &stats_vdev->stat);
|
||||
spin_unlock_irqrestore(&stats_vdev->rd_lock, flags);
|
||||
} else {
|
||||
vb2_set_plane_payload(&cur_buf->vb.vb2_buf, 0, size);
|
||||
cur_buf->vb.sequence = cur_frame_id;
|
||||
cur_buf->vb.vb2_buf.timestamp = meas_work->timestamp;
|
||||
vb2_buffer_done(&cur_buf->vb.vb2_buf, VB2_BUF_STATE_DONE);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
rkisp_stats_isr_v32(struct rkisp_isp_stats_vdev *stats_vdev,
|
||||
u32 isp_ris, u32 isp3a_ris)
|
||||
{
|
||||
struct rkisp_isp_readout_work work;
|
||||
u32 iq_isr_mask = ISP3X_SIAWB_DONE | ISP3X_SIAF_FIN |
|
||||
ISP3X_EXP_END | ISP3X_SIHST_RDY | ISP3X_AFM_SUM_OF | ISP3X_AFM_LUM_OF;
|
||||
u32 cur_frame_id, isp_mis_tmp = 0;
|
||||
u32 temp_isp_ris, temp_isp3a_ris;
|
||||
|
||||
rkisp_dmarx_get_frame(stats_vdev->dev, &cur_frame_id, NULL, NULL, true);
|
||||
|
||||
spin_lock(&stats_vdev->irq_lock);
|
||||
|
||||
temp_isp_ris = isp3_stats_read(stats_vdev, ISP3X_ISP_RIS);
|
||||
temp_isp3a_ris = isp3_stats_read(stats_vdev, ISP3X_ISP_3A_RIS);
|
||||
|
||||
isp_mis_tmp = isp_ris & iq_isr_mask;
|
||||
if (isp_mis_tmp) {
|
||||
isp3_stats_write(stats_vdev, ISP3X_ISP_ICR, isp_mis_tmp);
|
||||
|
||||
isp_mis_tmp &= isp3_stats_read(stats_vdev, ISP3X_ISP_MIS);
|
||||
if (isp_mis_tmp)
|
||||
v4l2_err(stats_vdev->vnode.vdev.v4l2_dev,
|
||||
"isp icr 3A info err: 0x%x 0x%x\n",
|
||||
isp_mis_tmp, isp_ris);
|
||||
}
|
||||
|
||||
isp_mis_tmp = temp_isp3a_ris;
|
||||
if (isp_mis_tmp) {
|
||||
isp3_stats_write(stats_vdev, ISP3X_ISP_3A_ICR, isp_mis_tmp);
|
||||
|
||||
isp_mis_tmp &= isp3_stats_read(stats_vdev, ISP3X_ISP_3A_MIS);
|
||||
if (isp_mis_tmp)
|
||||
v4l2_err(stats_vdev->vnode.vdev.v4l2_dev,
|
||||
"isp3A icr 3A info err: 0x%x 0x%x\n",
|
||||
isp_mis_tmp, isp3a_ris);
|
||||
}
|
||||
|
||||
if (!stats_vdev->streamon)
|
||||
goto unlock;
|
||||
|
||||
if (isp_ris & ISP3X_FRAME) {
|
||||
work.readout = RKISP_ISP_READOUT_MEAS;
|
||||
work.frame_id = cur_frame_id;
|
||||
work.isp_ris = temp_isp_ris | isp_ris;
|
||||
work.isp3a_ris = temp_isp3a_ris;
|
||||
work.timestamp = ktime_get_ns();
|
||||
rkisp_stats_send_meas_v32(stats_vdev, &work);
|
||||
}
|
||||
|
||||
unlock:
|
||||
spin_unlock(&stats_vdev->irq_lock);
|
||||
}
|
||||
|
||||
static void
|
||||
rkisp_stats_rdbk_enable_v32(struct rkisp_isp_stats_vdev *stats_vdev, bool en)
|
||||
{
|
||||
if (!en) {
|
||||
stats_vdev->isp_rdbk = 0;
|
||||
stats_vdev->isp3a_rdbk = 0;
|
||||
}
|
||||
|
||||
stats_vdev->rdbk_mode = en;
|
||||
}
|
||||
|
||||
static struct rkisp_isp_stats_ops rkisp_isp_stats_ops_tbl = {
|
||||
.isr_hdl = rkisp_stats_isr_v32,
|
||||
.send_meas = rkisp_stats_send_meas_v32,
|
||||
.rdbk_enable = rkisp_stats_rdbk_enable_v32,
|
||||
};
|
||||
|
||||
void rkisp_stats_first_ddr_config_v32(struct rkisp_isp_stats_vdev *stats_vdev)
|
||||
{
|
||||
struct rkisp_device *dev = stats_vdev->dev;
|
||||
u32 size = stats_vdev->vdev_fmt.fmt.meta.buffersize;
|
||||
|
||||
if (!stats_vdev->streamon)
|
||||
return;
|
||||
|
||||
rkisp_stats_update_buf(stats_vdev);
|
||||
rkisp_write(dev, ISP3X_MI_DBR_WR_SIZE, size, false);
|
||||
if (stats_vdev->nxt_buf) {
|
||||
stats_vdev->cur_buf = stats_vdev->nxt_buf;
|
||||
stats_vdev->nxt_buf = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
void rkisp_stats_next_ddr_config_v32(struct rkisp_isp_stats_vdev *stats_vdev)
|
||||
{
|
||||
struct rkisp_hw_dev *hw = stats_vdev->dev->hw_dev;
|
||||
|
||||
if (!stats_vdev->streamon)
|
||||
return;
|
||||
/* pingpong buf */
|
||||
if (hw->is_single)
|
||||
rkisp_stats_update_buf(stats_vdev);
|
||||
}
|
||||
|
||||
void rkisp_init_stats_vdev_v32(struct rkisp_isp_stats_vdev *stats_vdev)
|
||||
{
|
||||
stats_vdev->vdev_fmt.fmt.meta.dataformat =
|
||||
V4L2_META_FMT_RK_ISP1_STAT_3A;
|
||||
stats_vdev->vdev_fmt.fmt.meta.buffersize =
|
||||
sizeof(struct rkisp32_isp_stat_buffer);
|
||||
|
||||
stats_vdev->ops = &rkisp_isp_stats_ops_tbl;
|
||||
stats_vdev->priv_ops = &stats_ddr_ops_v32;
|
||||
stats_vdev->rd_stats_from_ddr = true;
|
||||
}
|
||||
|
||||
void rkisp_uninit_stats_vdev_v32(struct rkisp_isp_stats_vdev *stats_vdev)
|
||||
{
|
||||
|
||||
}
|
||||
54
drivers/media/platform/rockchip/isp/isp_stats_v32.h
Normal file
54
drivers/media/platform/rockchip/isp/isp_stats_v32.h
Normal file
@@ -0,0 +1,54 @@
|
||||
/* SPDX-License-Identifier: GPL-2.0 */
|
||||
/* Copyright (c) 2022 Rockchip Electronics Co., Ltd. */
|
||||
|
||||
#ifndef _RKISP_ISP_STATS_V32_H
|
||||
#define _RKISP_ISP_STATS_V32_H
|
||||
|
||||
#include <linux/rkisp1-config.h>
|
||||
#include <linux/interrupt.h>
|
||||
#include <linux/kfifo.h>
|
||||
#include "common.h"
|
||||
|
||||
#define ISP32_RD_STATS_BUF_SIZE 0x10000
|
||||
|
||||
struct rkisp_isp_stats_vdev;
|
||||
struct rkisp_stats_ops_v32 {
|
||||
int (*get_rawawb_meas)(struct rkisp_isp_stats_vdev *stats_vdev,
|
||||
struct rkisp32_isp_stat_buffer *pbuf);
|
||||
int (*get_rawaf_meas)(struct rkisp_isp_stats_vdev *stats_vdev,
|
||||
struct rkisp32_isp_stat_buffer *pbuf);
|
||||
int (*get_rawae0_meas)(struct rkisp_isp_stats_vdev *stats_vdev,
|
||||
struct rkisp32_isp_stat_buffer *pbuf);
|
||||
int (*get_rawhst0_meas)(struct rkisp_isp_stats_vdev *stats_vdev,
|
||||
struct rkisp32_isp_stat_buffer *pbuf);
|
||||
int (*get_rawae1_meas)(struct rkisp_isp_stats_vdev *stats_vdev,
|
||||
struct rkisp32_isp_stat_buffer *pbuf);
|
||||
int (*get_rawhst1_meas)(struct rkisp_isp_stats_vdev *stats_vdev,
|
||||
struct rkisp32_isp_stat_buffer *pbuf);
|
||||
int (*get_rawae2_meas)(struct rkisp_isp_stats_vdev *stats_vdev,
|
||||
struct rkisp32_isp_stat_buffer *pbuf);
|
||||
int (*get_rawhst2_meas)(struct rkisp_isp_stats_vdev *stats_vdev,
|
||||
struct rkisp32_isp_stat_buffer *pbuf);
|
||||
int (*get_rawae3_meas)(struct rkisp_isp_stats_vdev *stats_vdev,
|
||||
struct rkisp32_isp_stat_buffer *pbuf);
|
||||
int (*get_rawhst3_meas)(struct rkisp_isp_stats_vdev *stats_vdev,
|
||||
struct rkisp32_isp_stat_buffer *pbuf);
|
||||
int (*get_bls_stats)(struct rkisp_isp_stats_vdev *stats_vdev,
|
||||
struct rkisp32_isp_stat_buffer *pbuf);
|
||||
int (*get_dhaz_stats)(struct rkisp_isp_stats_vdev *stats_vdev,
|
||||
struct rkisp32_isp_stat_buffer *pbuf);
|
||||
};
|
||||
|
||||
#if IS_ENABLED(CONFIG_VIDEO_ROCKCHIP_ISP_VERSION_V32)
|
||||
void rkisp_stats_first_ddr_config_v32(struct rkisp_isp_stats_vdev *stats_vdev);
|
||||
void rkisp_stats_next_ddr_config_v32(struct rkisp_isp_stats_vdev *stats_vdev);
|
||||
void rkisp_init_stats_vdev_v32(struct rkisp_isp_stats_vdev *stats_vdev);
|
||||
void rkisp_uninit_stats_vdev_v32(struct rkisp_isp_stats_vdev *stats_vdev);
|
||||
#else
|
||||
static inline void rkisp_stats_first_ddr_config_v32(struct rkisp_isp_stats_vdev *stats_vdev) {}
|
||||
static inline void rkisp_stats_next_ddr_config_v32(struct rkisp_isp_stats_vdev *stats_vdev) {}
|
||||
static inline void rkisp_init_stats_vdev_v32(struct rkisp_isp_stats_vdev *stats_vdev) {}
|
||||
static inline void rkisp_uninit_stats_vdev_v32(struct rkisp_isp_stats_vdev *stats_vdev) {}
|
||||
#endif
|
||||
|
||||
#endif /* _RKISP_ISP_STATS_V32_H */
|
||||
@@ -762,6 +762,9 @@ static int isp_show(struct seq_file *p, void *v)
|
||||
else
|
||||
isp30_show(dev, p);
|
||||
break;
|
||||
case ISP_V32:
|
||||
isp30_show(dev, p);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -231,6 +231,14 @@ int rkisp_align_sensor_resolution(struct rkisp_device *dev,
|
||||
CIF_ISP_INPUT_H_MAX_V30_UNITE : CIF_ISP_INPUT_H_MAX_V30;
|
||||
h = clamp_t(u32, src_h, CIF_ISP_INPUT_H_MIN, h);
|
||||
break;
|
||||
case ISP_V32:
|
||||
w = clamp_t(u32, src_w,
|
||||
CIF_ISP_INPUT_W_MIN,
|
||||
CIF_ISP_INPUT_W_MAX_V32);
|
||||
h = clamp_t(u32, src_h,
|
||||
CIF_ISP_INPUT_H_MIN,
|
||||
CIF_ISP_INPUT_H_MAX_V32);
|
||||
break;
|
||||
default:
|
||||
w = clamp_t(u32, src_w,
|
||||
CIF_ISP_INPUT_W_MIN,
|
||||
@@ -591,9 +599,12 @@ void rkisp_trigger_read_back(struct rkisp_device *dev, u8 dma2frm, u32 mode, boo
|
||||
val = rkisp_read(dev, ISP3X_MPFBC_CTRL, false);
|
||||
val |= ISP3X_MPFBC_FORCE_UPD;
|
||||
writel(val, hw->base_addr + ISP3X_MPFBC_CTRL);
|
||||
} else if (dev->isp_ver == ISP_V32) {
|
||||
writel(CIF_MI_INIT_SOFT_UPD, hw->base_addr + ISP3X_MI_WR_INIT);
|
||||
}
|
||||
/* sensor mode & index */
|
||||
if (dev->isp_ver == ISP_V21 || dev->isp_ver == ISP_V30) {
|
||||
if (dev->isp_ver == ISP_V21 || dev->isp_ver == ISP_V30 ||
|
||||
dev->isp_ver == ISP_V32) {
|
||||
u32 mode = hw->dev_link_num >= 3 ? 2 : hw->dev_link_num - 1;
|
||||
u32 index = dev->dev_id;
|
||||
|
||||
@@ -621,7 +632,9 @@ void rkisp_trigger_read_back(struct rkisp_device *dev, u8 dma2frm, u32 mode, boo
|
||||
is_upd = true;
|
||||
}
|
||||
|
||||
if (dev->isp_ver == ISP_V21 || dev->isp_ver == ISP_V30)
|
||||
if (dev->isp_ver == ISP_V21 ||
|
||||
dev->isp_ver == ISP_V30 ||
|
||||
dev->isp_ver == ISP_V32)
|
||||
dma2frm = 0;
|
||||
if (dma2frm > 2)
|
||||
dma2frm = 2;
|
||||
@@ -845,7 +858,7 @@ static void rkisp_config_ism(struct rkisp_device *dev)
|
||||
rkisp_unite_write(dev, CIF_ISP_IS_V_SIZE, out_crop->height / mult,
|
||||
false, is_unite);
|
||||
|
||||
if (dev->isp_ver == ISP_V30)
|
||||
if (dev->isp_ver == ISP_V30 || dev->isp_ver == ISP_V32)
|
||||
return;
|
||||
|
||||
/* IS(Image Stabilization) is always on, working as output crop */
|
||||
@@ -1006,7 +1019,7 @@ static void rkisp_restart_monitor(struct work_struct *work)
|
||||
!(monitor->state & ISP_MIPI_ERROR))) {
|
||||
for (i = 0; i < hw->dev_num; i++) {
|
||||
isp = hw->isp[i];
|
||||
if (isp && !(isp->isp_inp & INP_CSI))
|
||||
if (!isp || (isp && !(isp->isp_inp & INP_CSI)))
|
||||
continue;
|
||||
if (!(isp->isp_state & ISP_START))
|
||||
break;
|
||||
@@ -1326,7 +1339,7 @@ static void rkisp_config_cmsk(struct rkisp_device *dev)
|
||||
unsigned long lock_flags = 0;
|
||||
struct rkisp_cmsk_cfg cfg;
|
||||
|
||||
if (dev->isp_ver != ISP_V30)
|
||||
if (dev->isp_ver != ISP_V30 && dev->isp_ver != ISP_V32)
|
||||
return;
|
||||
|
||||
spin_lock_irqsave(&dev->cmsk_lock, lock_flags);
|
||||
@@ -1382,9 +1395,8 @@ static int rkisp_config_isp(struct rkisp_device *dev)
|
||||
if (in_fmt->mbus_code == MEDIA_BUS_FMT_Y8_1X8 ||
|
||||
in_fmt->mbus_code == MEDIA_BUS_FMT_Y10_1X10 ||
|
||||
in_fmt->mbus_code == MEDIA_BUS_FMT_Y12_1X12) {
|
||||
if (dev->isp_ver == ISP_V20 ||
|
||||
dev->isp_ver == ISP_V21 ||
|
||||
dev->isp_ver == ISP_V30)
|
||||
if (dev->isp_ver == ISP_V20 || dev->isp_ver == ISP_V21 ||
|
||||
dev->isp_ver == ISP_V30 || dev->isp_ver == ISP_V32)
|
||||
rkisp_unite_write(dev, ISP_DEBAYER_CONTROL,
|
||||
0, false, is_unite);
|
||||
else
|
||||
@@ -1392,9 +1404,8 @@ static int rkisp_config_isp(struct rkisp_device *dev)
|
||||
CIF_ISP_DEMOSAIC_BYPASS |
|
||||
CIF_ISP_DEMOSAIC_TH(0xc), false);
|
||||
} else {
|
||||
if (dev->isp_ver == ISP_V20 ||
|
||||
dev->isp_ver == ISP_V21 ||
|
||||
dev->isp_ver == ISP_V30)
|
||||
if (dev->isp_ver == ISP_V20 || dev->isp_ver == ISP_V21 ||
|
||||
dev->isp_ver == ISP_V30 || dev->isp_ver == ISP_V32)
|
||||
rkisp_unite_write(dev, ISP_DEBAYER_CONTROL,
|
||||
SW_DEBAYER_EN |
|
||||
SW_DEBAYER_FILTER_G_EN |
|
||||
@@ -1489,9 +1500,8 @@ static int rkisp_config_isp(struct rkisp_device *dev)
|
||||
/* interrupt mask */
|
||||
irq_mask |= CIF_ISP_FRAME | CIF_ISP_V_START | CIF_ISP_PIC_SIZE_ERROR |
|
||||
CIF_ISP_FRAME_IN;
|
||||
if (dev->isp_ver == ISP_V20 ||
|
||||
dev->isp_ver == ISP_V21 ||
|
||||
dev->isp_ver == ISP_V30)
|
||||
if (dev->isp_ver == ISP_V20 || dev->isp_ver == ISP_V21 ||
|
||||
dev->isp_ver == ISP_V30 || dev->isp_ver == ISP_V32)
|
||||
irq_mask |= ISP2X_LSC_LUT_ERR;
|
||||
if (is_unite)
|
||||
rkisp_next_write(dev, CIF_ISP_IMSC, irq_mask, true);
|
||||
@@ -1769,9 +1779,8 @@ static int rkisp_isp_stop(struct rkisp_device *dev)
|
||||
readl(base + CIF_ISP_CSI0_ERR1);
|
||||
readl(base + CIF_ISP_CSI0_ERR2);
|
||||
readl(base + CIF_ISP_CSI0_ERR3);
|
||||
} else if (dev->isp_ver == ISP_V20 ||
|
||||
dev->isp_ver == ISP_V21 ||
|
||||
dev->isp_ver == ISP_V30) {
|
||||
} else if (dev->isp_ver == ISP_V20 || dev->isp_ver == ISP_V21 ||
|
||||
dev->isp_ver == ISP_V30 || dev->isp_ver == ISP_V32) {
|
||||
writel(0, base + CSI2RX_MASK_PHY);
|
||||
writel(0, base + CSI2RX_MASK_PACKET);
|
||||
writel(0, base + CSI2RX_MASK_OVERFLOW);
|
||||
@@ -1788,9 +1797,8 @@ static int rkisp_isp_stop(struct rkisp_device *dev)
|
||||
writel(0, base + CIF_ISP_IMSC);
|
||||
writel(~0, base + CIF_ISP_ICR);
|
||||
|
||||
if (dev->isp_ver == ISP_V20 ||
|
||||
dev->isp_ver == ISP_V21 ||
|
||||
dev->isp_ver == ISP_V30) {
|
||||
if (dev->isp_ver == ISP_V20 || dev->isp_ver == ISP_V21 ||
|
||||
dev->isp_ver == ISP_V30 || dev->isp_ver == ISP_V32) {
|
||||
writel(0, base + ISP_ISP3A_IMSC);
|
||||
writel(~0, base + ISP_ISP3A_ICR);
|
||||
}
|
||||
@@ -1806,9 +1814,8 @@ static int rkisp_isp_stop(struct rkisp_device *dev)
|
||||
udelay(20);
|
||||
}
|
||||
/* stop lsc to avoid lsclut error */
|
||||
if (dev->isp_ver == ISP_V20 ||
|
||||
dev->isp_ver == ISP_V21 ||
|
||||
dev->isp_ver == ISP_V30)
|
||||
if (dev->isp_ver == ISP_V20 || dev->isp_ver == ISP_V21 ||
|
||||
dev->isp_ver == ISP_V30 || dev->isp_ver == ISP_V32)
|
||||
writel(0, base + ISP_LSC_CTRL);
|
||||
/* stop ISP */
|
||||
val = readl(base + CIF_ISP_CTRL);
|
||||
@@ -1849,9 +1856,8 @@ static int rkisp_isp_stop(struct rkisp_device *dev)
|
||||
writel(0, base + CIF_ISP_CSI0_MASK1);
|
||||
writel(0, base + CIF_ISP_CSI0_MASK2);
|
||||
writel(0, base + CIF_ISP_CSI0_MASK3);
|
||||
} else if (dev->isp_ver == ISP_V20 ||
|
||||
dev->isp_ver == ISP_V21 ||
|
||||
dev->isp_ver == ISP_V30) {
|
||||
} else if (dev->isp_ver == ISP_V20 || dev->isp_ver == ISP_V21 ||
|
||||
dev->isp_ver == ISP_V30 || dev->isp_ver == ISP_V32) {
|
||||
writel(0, base + CSI2RX_CSI2_RESETN);
|
||||
if (hw->is_unite)
|
||||
rkisp_next_write(dev, CSI2RX_CSI2_RESETN, 0, true);
|
||||
@@ -1864,11 +1870,10 @@ end:
|
||||
dev->hdr.op_mode = 0;
|
||||
rkisp_set_state(&dev->isp_state, ISP_STOP);
|
||||
|
||||
if (dev->isp_ver == ISP_V20 ||
|
||||
dev->isp_ver == ISP_V21 ||
|
||||
dev->isp_ver == ISP_V30)
|
||||
if (dev->isp_ver == ISP_V20 || dev->isp_ver == ISP_V21 ||
|
||||
dev->isp_ver == ISP_V30 || dev->isp_ver == ISP_V32)
|
||||
kfifo_reset(&dev->rdbk_kfifo);
|
||||
if (dev->isp_ver == ISP_V30)
|
||||
if (dev->isp_ver == ISP_V30 || dev->isp_ver == ISP_V32)
|
||||
memset(&dev->cmsk_cfg, 0, sizeof(dev->cmsk_cfg));
|
||||
if (dev->emd_vc <= CIF_ISP_ADD_DATA_VC_MAX) {
|
||||
for (i = 0; i < RKISP_EMDDATA_FIFO_MAX; i++)
|
||||
@@ -2403,6 +2408,10 @@ static int rkisp_isp_sd_get_selection(struct v4l2_subdev *sd,
|
||||
max_h = dev->hw_dev->is_unite ?
|
||||
CIF_ISP_INPUT_H_MAX_V30_UNITE : CIF_ISP_INPUT_H_MAX_V30;
|
||||
break;
|
||||
case ISP_V32:
|
||||
max_w = CIF_ISP_INPUT_W_MAX_V32;
|
||||
max_h = CIF_ISP_INPUT_H_MAX_V32;
|
||||
break;
|
||||
default:
|
||||
max_w = CIF_ISP_INPUT_W_MAX;
|
||||
max_h = CIF_ISP_INPUT_H_MAX;
|
||||
@@ -2455,19 +2464,17 @@ static int rkisp_isp_sd_set_selection(struct v4l2_subdev *sd,
|
||||
|
||||
if (sel->pad == RKISP_ISP_PAD_SINK) {
|
||||
isp_sd->in_crop = *crop;
|
||||
/* ISP20 don't have out crop */
|
||||
if (dev->isp_ver == ISP_V20 ||
|
||||
dev->isp_ver == ISP_V21 ||
|
||||
dev->isp_ver == ISP_V30) {
|
||||
/* don't have out crop */
|
||||
if (dev->isp_ver == ISP_V20 || dev->isp_ver == ISP_V21 ||
|
||||
dev->isp_ver == ISP_V30 || dev->isp_ver == ISP_V32) {
|
||||
isp_sd->out_crop = *crop;
|
||||
isp_sd->out_crop.left = 0;
|
||||
isp_sd->out_crop.top = 0;
|
||||
dev->br_dev.crop = isp_sd->out_crop;
|
||||
}
|
||||
} else {
|
||||
if (dev->isp_ver == ISP_V20 ||
|
||||
dev->isp_ver == ISP_V21 ||
|
||||
dev->isp_ver == ISP_V30)
|
||||
if (dev->isp_ver == ISP_V20 || dev->isp_ver == ISP_V21 ||
|
||||
dev->isp_ver == ISP_V30 || dev->isp_ver == ISP_V32)
|
||||
*crop = isp_sd->out_crop;
|
||||
isp_sd->out_crop = *crop;
|
||||
}
|
||||
@@ -2546,6 +2553,7 @@ static void rkisp_global_update_mi(struct rkisp_device *dev)
|
||||
stream->ops->frame_end(stream);
|
||||
}
|
||||
}
|
||||
rkisp_stats_next_ddr_config(&dev->stats_vdev);
|
||||
}
|
||||
|
||||
static int rkisp_isp_sd_s_stream(struct v4l2_subdev *sd, int on)
|
||||
@@ -2574,9 +2582,9 @@ static int rkisp_isp_sd_s_stream(struct v4l2_subdev *sd, int on)
|
||||
}
|
||||
|
||||
atomic_set(&isp_dev->isp_sdev.frm_sync_seq, 0);
|
||||
rkisp_global_update_mi(isp_dev);
|
||||
rkisp_config_cif(isp_dev);
|
||||
rkisp_isp_start(isp_dev);
|
||||
rkisp_global_update_mi(isp_dev);
|
||||
rkisp_rdbk_trigger_event(isp_dev, T_CMD_QUEUE, NULL);
|
||||
return 0;
|
||||
}
|
||||
@@ -2698,9 +2706,8 @@ static int rkisp_isp_sd_s_power(struct v4l2_subdev *sd, int on)
|
||||
"%s on:%d\n", __func__, on);
|
||||
|
||||
if (on) {
|
||||
if (isp_dev->isp_ver == ISP_V20 ||
|
||||
isp_dev->isp_ver == ISP_V21 ||
|
||||
isp_dev->isp_ver == ISP_V30)
|
||||
if (isp_dev->isp_ver == ISP_V20 || isp_dev->isp_ver == ISP_V21 ||
|
||||
isp_dev->isp_ver == ISP_V30 || isp_dev->isp_ver == ISP_V32)
|
||||
kfifo_reset(&isp_dev->rdbk_kfifo);
|
||||
ret = pm_runtime_get_sync(isp_dev->dev);
|
||||
} else {
|
||||
|
||||
@@ -55,6 +55,8 @@
|
||||
#define CIF_ISP_INPUT_H_MAX_V30 3504
|
||||
#define CIF_ISP_INPUT_W_MAX_V30_UNITE 8192
|
||||
#define CIF_ISP_INPUT_H_MAX_V30_UNITE 6144
|
||||
#define CIF_ISP_INPUT_W_MAX_V32 3072
|
||||
#define CIF_ISP_INPUT_H_MAX_V32 1728
|
||||
#define CIF_ISP_INPUT_W_MIN 208
|
||||
#define CIF_ISP_INPUT_H_MIN 128
|
||||
#define CIF_ISP_OUTPUT_W_MAX CIF_ISP_INPUT_W_MAX
|
||||
|
||||
1371
include/uapi/linux/rkisp32-config.h
Normal file
1371
include/uapi/linux/rkisp32-config.h
Normal file
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user