From 6ffc8e398a114bc1280ead6b55d15ee837cd059b Mon Sep 17 00:00:00 2001 From: Hu Kejun Date: Tue, 5 Jun 2018 10:00:29 +0800 Subject: [PATCH] media: rk-isp10: update to v0.1.f fix MI_CTRL and MI_XTD_FORMAT_CTRL register is not correct merge isp11: rockchip: v0.2.4 and isp11: rockchip: v0.2.5 merge isp11: Support Y8 for AEC merge isp11: rockchip: v0.2.7 merge isp11: rockchip: v0.2.9 & v0.2.8 merge isp11: print version merge isp11: rockchip: v0.2.b merge isp11: rockchip: v0.2.c merge isp11: rockchip: v0.3.2 merge isp11: rockchip: v0.3.4 merge isp11: rockchip: modify for debugfs merge isp11: rockchip: v0.1.7 merge isp11: rockchip: v0.1.8 merge isp11: rockchip: v0.1.9 merge isp11: rockchip: v0.1.d merge isp11: send afm meas data alone Change-Id: I00c9181849addf5dd44c0deea2bb39ac02ff999d Signed-off-by: Hu Kejun --- drivers/media/platform/rk-isp10/cif_isp10.c | 492 +- drivers/media/platform/rk-isp10/cif_isp10.h | 21 +- .../platform/rk-isp10/cif_isp10_img_src.c | 32 + .../platform/rk-isp10/cif_isp10_img_src.h | 12 + .../platform/rk-isp10/cif_isp10_img_src_ops.h | 12 +- .../rk-isp10/cif_isp10_img_src_v4l2-subdev.c | 56 + .../rk-isp10/cif_isp10_img_src_v4l2-subdev.h | 8 + .../media/platform/rk-isp10/cif_isp10_isp.c | 3988 +++++++++-------- .../media/platform/rk-isp10/cif_isp10_isp.h | 42 +- .../platform/rk-isp10/cif_isp10_pltfrm.c | 385 +- .../media/platform/rk-isp10/cif_isp10_v4l2.c | 172 +- .../platform/rk-isp10/cif_isp10_version.h | 5 +- include/media/rk-isp10-config.h | 59 +- include/media/rk-isp10-ioctl.h | 39 +- include/media/v4l2-config_rockchip.h | 29 + include/media/v4l2-controls_rockchip.h | 4 + 16 files changed, 2844 insertions(+), 2512 deletions(-) diff --git a/drivers/media/platform/rk-isp10/cif_isp10.c b/drivers/media/platform/rk-isp10/cif_isp10.c index 4723a106f720..2adfce69eb8f 100644 --- a/drivers/media/platform/rk-isp10/cif_isp10.c +++ b/drivers/media/platform/rk-isp10/cif_isp10.c @@ -685,6 +685,8 @@ static const char *cif_isp10_pix_fmt_string(int pixfmt) return "DATA"; case CIF_JPEG: return "JPEG"; + case CIF_Y10: + return "Y10"; default: return "unknown/unsupported"; } @@ -1550,14 +1552,21 @@ static int cif_isp10_config_img_src( ret = (int)cif_isp10_img_src_ioctl(dev->img_src, RK_VIDIOC_SENSOR_MODE_DATA, &sensor_mode); if (IS_ERR_VALUE(ret)) { - dev->img_src_exps.exp_valid_frms = 2; + dev->img_src_exps.exp_valid_frms[VALID_FR_EXP_T_INDEX] = 4; + dev->img_src_exps.exp_valid_frms[VALID_FR_EXP_G_INDEX] = 4; } else { - if ((sensor_mode.exposure_valid_frame[0] < 2) || - (sensor_mode.exposure_valid_frame[0] > 6)) - dev->img_src_exps.exp_valid_frms = 2; + if ((sensor_mode.exposure_valid_frame[VALID_FR_EXP_T_INDEX] < 2) || + (sensor_mode.exposure_valid_frame[VALID_FR_EXP_T_INDEX] > 6)) + dev->img_src_exps.exp_valid_frms[VALID_FR_EXP_T_INDEX] = 4; else - dev->img_src_exps.exp_valid_frms = - sensor_mode.exposure_valid_frame[0]; + dev->img_src_exps.exp_valid_frms[VALID_FR_EXP_T_INDEX] = + sensor_mode.exposure_valid_frame[VALID_FR_EXP_T_INDEX]; + if ((sensor_mode.exposure_valid_frame[VALID_FR_EXP_G_INDEX] < 2) || + (sensor_mode.exposure_valid_frame[VALID_FR_EXP_G_INDEX] > 6)) + dev->img_src_exps.exp_valid_frms[VALID_FR_EXP_G_INDEX] = 2; + else + dev->img_src_exps.exp_valid_frms[VALID_FR_EXP_G_INDEX] = + sensor_mode.exposure_valid_frame[VALID_FR_EXP_G_INDEX]; } cif_isp10_pltfrm_pr_dbg(dev->dev, "cam_itf: (type: 0x%x, dphy: %d, vc: %d, nb_lanes: %d, bitrate: %d)", @@ -1610,7 +1619,8 @@ static int cif_isp10_config_isp( output = &dev->config.isp_config.output; cam_itf = &dev->config.cam_itf; - if (CIF_ISP10_PIX_FMT_IS_RAW_BAYER(in_pix_fmt)) { + if (CIF_ISP10_PIX_FMT_IS_RAW_BAYER(in_pix_fmt) || + (in_pix_fmt == CIF_Y10)) { if (!dev->config.mi_config.raw_enable) { output->pix_fmt = CIF_YUV422I; @@ -1635,15 +1645,23 @@ static int cif_isp10_config_isp( if (dev->sp_stream.state == CIF_ISP10_STATE_READY) { output->quantization = dev->config.mi_config.sp.output.quantization; + + if (in_pix_fmt == CIF_Y10) + output->pix_fmt = CIF_YUV400; } if (dev->mp_stream.state == CIF_ISP10_STATE_READY) { output->quantization = - dev->config.mi_config.sp.output.quantization; + dev->config.mi_config.mp.output.quantization; } - cif_iowrite32(0xc, - dev->config.base_addr + CIF_ISP_DEMOSAIC); + if (in_pix_fmt == CIF_Y10) { + cif_iowrite32(0x40c, + dev->config.base_addr + CIF_ISP_DEMOSAIC); + } else { + cif_iowrite32(0xc, + dev->config.base_addr + CIF_ISP_DEMOSAIC); + } if (PLTFRM_CAM_ITF_IS_BT656(dev->config.cam_itf.type)) { cif_iowrite32( @@ -1882,7 +1900,11 @@ static int cif_isp10_config_isp( CIF_ISP_FRAME | CIF_ISP_PIC_SIZE_ERROR | CIF_ISP_FRAME_IN | - CIF_ISP_V_START; + CIF_ISP_V_START | + CIF_ISP_AWB_DONE | + CIF_ISP_AFM_FIN | + CIF_ISP_EXP_END | + CIF_ISP_HIST_MEASURE_RDY; cif_iowrite32(irq_mask, dev->config.base_addr + CIF_ISP_IMSC); @@ -1998,6 +2020,8 @@ static int cif_isp10_config_mipi( (CIF_ISP10_PIX_FMT_YUV_GET_Y_SUBS(in_pix_fmt) == 4) && (CIF_ISP10_PIX_FMT_GET_BPP(in_pix_fmt) == 20)) data_type = CSI2_DT_YUV422_10b; + else if (in_pix_fmt == CIF_Y10) + data_type = CSI2_DT_RAW10; else { cif_isp10_pltfrm_pr_err(dev->dev, "unsupported format %s\n", @@ -2178,7 +2202,10 @@ static int cif_isp10_config_mi_mp( CIF_MI_IMSC, ~0); if (swap_cb_cr) { - cif_iowrite32OR(swap_cb_cr, + cif_iowrite32OR(CIF_MI_XTD_FMT_CTRL_MP_CB_CR_SWAP, + dev->config.base_addr + CIF_MI_XTD_FORMAT_CTRL); + } else { + cif_iowrite32AND(~CIF_MI_XTD_FMT_CTRL_MP_CB_CR_SWAP, dev->config.base_addr + CIF_MI_XTD_FORMAT_CTRL); } @@ -2199,7 +2226,8 @@ static int cif_isp10_config_mi_mp( " MI_STATUS 0x%08x\n" " MI_MP_Y_SIZE %d\n" " MI_MP_CB_SIZE %d\n" - " MI_MP_CR_SIZE %d\n", + " MI_MP_CR_SIZE %d\n" + " MI_XTD_FORMAT_CTRL %d\n", cif_ioread32(dev->config.base_addr + CIF_MI_CTRL), cif_ioread32(dev->config.base_addr + @@ -2209,7 +2237,9 @@ static int cif_isp10_config_mi_mp( cif_ioread32(dev->config.base_addr + CIF_MI_MP_CB_SIZE_INIT), cif_ioread32(dev->config.base_addr + - CIF_MI_MP_CR_SIZE_INIT)); + CIF_MI_MP_CR_SIZE_INIT), + cif_ioread32(dev->config.base_addr + + CIF_MI_XTD_FORMAT_CTRL)); return 0; } @@ -2287,6 +2317,8 @@ static int cif_isp10_config_mi_sp( CIF_ISP10_PIX_FMT_YUV_GET_NUM_CPLANES(out_pix_fmt); if (num_cplanes == 0) { writeformat = CIF_ISP10_BUFF_FMT_INTERLEAVED; + if (out_pix_fmt == CIF_YUV400) + writeformat = CIF_ISP10_BUFF_FMT_PLANAR; } else { dev->config.mi_config.sp.y_size = (dev->config.mi_config.sp.y_size * 4) / @@ -2420,19 +2452,26 @@ static int cif_isp10_config_mi_sp( CIF_MI_IMSC, ~0); if (swap_cb_cr) { - cif_iowrite32OR(swap_cb_cr, + cif_iowrite32OR(CIF_MI_XTD_FMT_CTRL_SP_CB_CR_SWAP, + dev->config.base_addr + CIF_MI_XTD_FORMAT_CTRL); + } else { + cif_iowrite32AND(~CIF_MI_XTD_FMT_CTRL_SP_CB_CR_SWAP, dev->config.base_addr + CIF_MI_XTD_FORMAT_CTRL); } mi_ctrl = cif_ioread32(dev->config.base_addr + CIF_MI_CTRL); - mi_ctrl &= ~(CIF_MI_CTRL_SP_WRITE_FMT(3)); - mi_ctrl |= CIF_MI_CTRL_SP_WRITE_FMT(writeformat) | - input_format | - output_format | - burst_len | - CIF_MI_CTRL_INIT_BASE_EN | - CIF_MI_CTRL_INIT_OFFSET_EN | - CIF_MI_SP_AUTOUPDATE_ENABLE; + mi_ctrl &= ~(CIF_MI_CTRL_SP_WRITE_FMT(3) |/* SP_WRITE_FMT */ + (0x7 << 28) | /* SP_OUTPUT_FMT */ + (0x3 << 26) | /* SP_INPUT_FMT */ + (0xF << 16)); /* burst_len_chrom & burst_len_lum */ + mi_ctrl = mi_ctrl | + CIF_MI_CTRL_SP_WRITE_FMT(writeformat) | + input_format | + output_format | + burst_len | + CIF_MI_CTRL_INIT_BASE_EN | + CIF_MI_CTRL_INIT_OFFSET_EN | + CIF_MI_SP_AUTOUPDATE_ENABLE; cif_iowrite32_verify(mi_ctrl, dev->config.base_addr + CIF_MI_CTRL, ~0); @@ -2445,7 +2484,8 @@ static int cif_isp10_config_mi_sp( " MI_SP_PIC_WIDTH %d\n" " MI_SP_PIC_HEIGHT %d\n" " MI_SP_PIC_LLENGTH %d\n" - " MI_SP_PIC_SIZE %d\n", + " MI_SP_PIC_SIZE %d\n" + " MI_XTD_FORMAT_CTRL %d\n", cif_ioread32(dev->config.base_addr + CIF_MI_CTRL), cif_ioread32(dev->config.base_addr + CIF_MI_STATUS), cif_ioread32(dev->config.base_addr + CIF_MI_SP_Y_SIZE_INIT), @@ -2454,7 +2494,8 @@ static int cif_isp10_config_mi_sp( cif_ioread32(dev->config.base_addr + CIF_MI_SP_Y_PIC_WIDTH), cif_ioread32(dev->config.base_addr + CIF_MI_SP_Y_PIC_HEIGHT), cif_ioread32(dev->config.base_addr + CIF_MI_SP_Y_LLENGTH), - cif_ioread32(dev->config.base_addr + CIF_MI_SP_Y_PIC_SIZE)); + cif_ioread32(dev->config.base_addr + CIF_MI_SP_Y_PIC_SIZE), + cif_ioread32(dev->config.base_addr + CIF_MI_XTD_FORMAT_CTRL)); return 0; err: @@ -3349,6 +3390,9 @@ static int cif_isp10_config_cif( cif_isp10_config_clk(dev); + cifisp_frame_id_reset(&dev->isp_dev); + dev->isp_dev.frame_id_setexp = 0; + /* Decide when to switch to asynchronous mode */ /* * TODO: remove dev->isp_dev.ycflt_en check for @@ -3551,6 +3595,7 @@ static void cif_isp10_init_stream( stream->curr_buf = NULL; stream->stop = false; stream->stall = false; + spin_lock_init(&stream->metadata.spinlock); cif_isp10_pltfrm_event_clear(dev->dev, &stream->done); @@ -3940,6 +3985,18 @@ static int cif_isp10_s_fmt_mp( strm_fmt->frm_fmt.quantization); /* TBD: check whether format is a valid format for MP */ + if (strm_fmt->frm_fmt.pix_fmt == CIF_YUV400) { + cif_isp10_pltfrm_pr_err(dev->dev, + "format %s %dx%d@%d/%dfps, stride = %d not supported on MP\n", + cif_isp10_pix_fmt_string(strm_fmt->frm_fmt.pix_fmt), + strm_fmt->frm_fmt.width, + strm_fmt->frm_fmt.height, + strm_fmt->frm_intrvl.numerator, + strm_fmt->frm_intrvl.denominator, + stride); + ret = -EINVAL; + goto err; + } if (PLTFRM_CAM_ITF_INTERLACE(dev->config.cam_itf.type)) { ret = -EINVAL; @@ -4301,16 +4358,25 @@ static int cif_isp10_mi_frame_end( vb2_buffer_done(vb2_buf, VB2_BUF_STATE_DONE); wake_now = false; + spin_lock(&stream->metadata.spinlock); if (stream->metadata.d && dev->isp_dev.streamon) { struct v4l2_buffer_metadata_s *metadata; + unsigned int meta_read_id; metadata = (struct v4l2_buffer_metadata_s *) (stream->metadata.d + stream->curr_buf->vb.vb2_buf.index * CAMERA_METADATA_LEN); - metadata->frame_id = dev->isp_dev.frame_id; - metadata->frame_t.vs_t = dev->isp_dev.vs_t; - metadata->frame_t.fi_t = dev->isp_dev.fi_t; + meta_read_id = dev->isp_dev.meta_info.read_id; + metadata->frame_id = dev->isp_dev.meta_info.frame_id[meta_read_id]; + metadata->frame_t.vs_t = dev->isp_dev.meta_info.vs_t[meta_read_id]; + metadata->frame_t.fi_t = dev->isp_dev.meta_info.fi_t[meta_read_id]; + dev->isp_dev.meta_info.read_cnt++; + if (dev->isp_dev.meta_info.read_cnt >= dev->isp_dev.meta_info.read_max) { + dev->isp_dev.meta_info.read_cnt = 0; + dev->isp_dev.meta_info.read_id = (meta_read_id + 1) % CIF_ISP10_META_INFO_NUM; + } + spin_unlock(&stream->metadata.spinlock); work = (struct cif_isp10_isp_readout_work *) kmalloc( @@ -4325,10 +4391,12 @@ static int cif_isp10_mi_frame_end( work->isp_dev = &dev->isp_dev; work->frame_id = - dev->isp_dev.frame_id; + metadata->frame_id; work->vb = &stream->curr_buf->vb.vb2_buf; work->stream_id = stream->id; + work->isp_metadata = + (struct cifisp_isp_metadata *)metadata->isp; if (!queue_work(dev->isp_dev.readout_wq, (struct work_struct *)work)) { cif_isp10_pltfrm_pr_err( @@ -4343,6 +4411,7 @@ static int cif_isp10_mi_frame_end( wake_now = true; } } else { + spin_unlock(&stream->metadata.spinlock); wake_now = true; } @@ -4452,14 +4521,78 @@ static int cif_isp10_mi_frame_end( return 0; } +static int cif_isp10_update_mi_immediate( + struct cif_isp10_device *dev, + enum cif_isp10_stream_id stream_id) +{ + struct cif_isp10_stream *stream; + u32 *next_buff_addr; + CIF_ISP10_PLTFRM_MEM_IO_ADDR y_base_addr; +#ifdef CIF_ISP10_MODE_DMA_SG + struct sg_table *sgt = NULL; +#endif + int (*update_mi)( + struct cif_isp10_device *dev); + + if (stream_id == CIF_ISP10_STREAM_MP) { + stream = &dev->mp_stream; + y_base_addr = + dev->config.base_addr + CIF_MI_MP_Y_BASE_AD_SHD; + next_buff_addr = &dev->config.mi_config.mp.next_buff_addr; + update_mi = cif_isp10_update_mi_mp; + } else if (stream_id == CIF_ISP10_STREAM_SP) { + stream = &dev->sp_stream; + y_base_addr = + dev->config.base_addr + CIF_MI_SP_Y_BASE_AD_SHD; + next_buff_addr = &dev->config.mi_config.sp.next_buff_addr; + update_mi = cif_isp10_update_mi_sp; + } else { + BUG(); + } + + if (stream->state != CIF_ISP10_STATE_STREAMING) + return 0; + + if (stream->next_buf) + return 0; + + if (!list_empty(&stream->buf_queue)) { + stream->next_buf = + list_first_entry(&stream->buf_queue, + struct cif_isp10_buffer, queue); + list_del(&stream->next_buf->queue); +#ifdef CIF_ISP10_MODE_DMA_CONTIG + *next_buff_addr = vb2_dma_contig_plane_dma_addr( + &stream->next_buf->vb.vb2_buf, 0); +#endif +#ifdef CIF_ISP10_MODE_DMA_SG + sgt = vb2_dma_sg_plane_desc( + &stream->next_buf->vb.vb2_buf, 0); + *next_buff_addr = sg_dma_address(sgt->sgl); +#endif + } + + update_mi(dev); + + cif_isp10_pltfrm_pr_dbg(dev->dev, + "%s curr_buff: %d, next_buf: %d, 0x%x\n", + cif_isp10_stream_id_string(stream_id), + (stream->curr_buf) ? stream->curr_buf->vb.vb2_buf.index : -1, + (stream->next_buf) ? stream->next_buf->vb.vb2_buf.index : -1, + *next_buff_addr); + return 0; +} + static void cif_isp10_stream_metadata_reset( struct cif_isp10_stream *stream_dev ) { unsigned int i; + unsigned long flags = 0; struct v4l2_buffer_metadata_s *metadata; struct cifisp_isp_metadata *isp_metadata; + spin_lock_irqsave(&stream_dev->metadata.spinlock, flags); if (stream_dev->metadata.d) { for (i = 0; i < stream_dev->metadata.cnt; i++) { metadata = (struct v4l2_buffer_metadata_s *) @@ -4471,6 +4604,7 @@ static void cif_isp10_stream_metadata_reset( isp_metadata->meas_cfg.s_frame_id = 0xffffffff; } } + spin_unlock_irqrestore(&stream_dev->metadata.spinlock, flags); } static void cif_isp10_start_mi( @@ -4765,6 +4899,8 @@ static int cif_isp10_stop( spin_unlock_irqrestore(&dev->isp_state_lock, flags); } + cifisp_clr_readout_wq(&dev->isp_dev); + if (!CIF_ISP10_INP_IS_DMA(dev->config.input_sel)) { if (IS_ERR_VALUE(cif_isp10_img_src_set_state(dev, CIF_ISP10_IMG_SRC_STATE_SW_STNDBY))) @@ -4900,7 +5036,7 @@ static int cif_isp10_start( */ mdelay(1); /* start sensor output! */ - dev->isp_dev.frame_id = 0; + cifisp_frame_id_reset(&dev->isp_dev); dev->isp_dev.frame_id_setexp = 0; list_for_each_entry_safe( @@ -4950,6 +5086,13 @@ static int cif_isp10_start( cif_isp10_dma_next_buff(dev); } + dev->isp_dev.meta_info.read_cnt = 0; + dev->isp_dev.meta_info.read_max = 0; + if (dev->sp_stream.state == CIF_ISP10_STATE_STREAMING) + dev->isp_dev.meta_info.read_max++; + if (dev->mp_stream.state == CIF_ISP10_STATE_STREAMING) + dev->isp_dev.meta_info.read_max++; + cif_isp10_pltfrm_pr_dbg(dev->dev, "SP state = %s, MP state = %s, DMA state = %s, img_src state = %s\n" " MI_CTRL 0x%08x\n" @@ -5243,12 +5386,13 @@ static void cif_isp10_vs_work(struct work_struct *work) struct cif_isp10_isp_vs_work *vs_wk = container_of(work, struct cif_isp10_isp_vs_work, work); struct cif_isp10_device *dev = vs_wk->dev; + unsigned int v_frame_id; switch (vs_wk->cmd) { case CIF_ISP10_VS_EXP: { struct cif_isp10_img_src_exp *exp = (struct cif_isp10_img_src_exp *)vs_wk->param; - struct cif_isp10_img_src_ext_ctrl *exp_ctrl = exp->exp; + struct cif_isp10_img_src_ext_ctrl *exp_ctrl = &exp->exp; struct cif_isp10_img_src_data *new_data; if (dev->img_src) @@ -5264,8 +5408,19 @@ static void cif_isp10_vs_work(struct work_struct *work) new_data = &dev->img_src_exps.data[1]; mutex_lock(&dev->img_src_exps.mutex); - new_data->v_frame_id = dev->isp_dev.frame_id + - dev->img_src_exps.exp_valid_frms; + if (exp_ctrl->ctrls->id == V4L2_CID_EXPOSURE) + v_frame_id = dev->isp_dev.frame_id + + dev->img_src_exps.exp_valid_frms[VALID_FR_EXP_T_INDEX]; + else + v_frame_id = dev->isp_dev.frame_id + + dev->img_src_exps.exp_valid_frms[VALID_FR_EXP_G_INDEX]; + + if (v_frame_id == dev->img_src_exps.data[0].v_frame_id) + new_data = &dev->img_src_exps.data[0]; + if (v_frame_id == dev->img_src_exps.data[1].v_frame_id) + new_data = &dev->img_src_exps.data[1]; + new_data->v_frame_id = v_frame_id; + cif_isp10_img_src_ioctl(dev->img_src, RK_VIDIOC_SENSOR_MODE_DATA, &new_data->data); @@ -5293,10 +5448,8 @@ static void cif_isp10_vs_work(struct work_struct *work) * new_data->v_frame_id); */ - kfree(exp->exp->ctrls); - exp->exp->ctrls = NULL; - kfree(exp->exp); - exp->exp = NULL; + kfree(exp->exp.ctrls); + exp->exp.ctrls = NULL; kfree(exp); exp = NULL; break; @@ -5309,6 +5462,38 @@ static void cif_isp10_vs_work(struct work_struct *work) vs_wk = NULL; } +static int cif_isp10_vs_work_cmd( + struct cif_isp10_device *dev, + enum cif_isp10_isp_vs_cmd cmd, + void *para) +{ + struct cif_isp10_isp_vs_work *vs_wk; + + if (cmd == CIF_ISP10_VS_EXP) + vs_wk = kmalloc(sizeof(struct cif_isp10_isp_vs_work), + GFP_ATOMIC); + else + vs_wk = kmalloc(sizeof(struct cif_isp10_isp_vs_work), + GFP_KERNEL); + + if (vs_wk) { + vs_wk->cmd = cmd; + vs_wk->dev = dev; + vs_wk->param = (void *)para; + INIT_WORK((struct work_struct *)&vs_wk->work, + cif_isp10_vs_work); + if (!queue_work(dev->vs_wq, + (struct work_struct *)&vs_wk->work)) { + cif_isp10_pltfrm_pr_err(dev->dev, + "%s: queue work failed\n", __func__); + kfree(vs_wk); + } + return 0; + } else { + return -ENOMEM; + } +} + /* Public Functions */ void cif_isp10_sensor_mode_data_sync( struct cif_isp10_device *dev, @@ -5452,6 +5637,7 @@ int cif_isp10_streamoff( bool streamoff_mp = stream_ids & CIF_ISP10_STREAM_MP; bool streamoff_dma = stream_ids & CIF_ISP10_STREAM_DMA; unsigned int streamoff_all = 0; + unsigned long lock_flags; cif_isp10_pltfrm_pr_dbg(dev->dev, "SP state = %s, MP state = %s, DMA state = %s, streamoff SP = %d, streamoff MP = %d, streamoff DMA = %d\n", @@ -5484,8 +5670,20 @@ int cif_isp10_streamoff( } else { streamoff_all |= CIF_ISP10_STREAM_MP; } - if (streamoff_all == (CIF_ISP10_STREAM_MP | CIF_ISP10_STREAM_SP)) + if (streamoff_all == (CIF_ISP10_STREAM_MP | CIF_ISP10_STREAM_SP)) { + struct cif_isp10_img_src_exp *exp; + spin_lock_irqsave(&dev->img_src_exps.lock, lock_flags); + if (!list_empty(&dev->img_src_exps.list)) { + exp = list_first_entry(&dev->img_src_exps.list, + struct cif_isp10_img_src_exp, + list); + list_del(&exp->list); + kfree(exp->exp.ctrls); + kfree(exp); + } + spin_unlock_irqrestore(&dev->img_src_exps.lock, lock_flags); drain_workqueue(dev->vs_wq); + } ret = cif_isp10_stop(dev, streamoff_sp, streamoff_mp); if (IS_ERR_VALUE(ret)) @@ -5685,6 +5883,8 @@ int cif_isp10_release( int stream_ids) { int ret; + unsigned char *meta_addr = NULL; + unsigned long flags = 0; struct cif_isp10_stream *strm_dev; cif_isp10_pltfrm_pr_dbg(NULL, "0x%08x\n", stream_ids); @@ -5710,11 +5910,15 @@ int cif_isp10_release( strm_dev = NULL; if (strm_dev) { + spin_lock_irqsave(&strm_dev->metadata.spinlock, flags); if (strm_dev->metadata.d) { - vfree(strm_dev->metadata.d); + meta_addr = strm_dev->metadata.d; strm_dev->metadata.d = NULL; strm_dev->metadata.cnt = 0; } + spin_unlock_irqrestore(&strm_dev->metadata.spinlock, flags); + if (meta_addr) + vfree(meta_addr); } if (stream_ids & CIF_ISP10_STREAM_SP) { @@ -5819,7 +6023,8 @@ struct cif_isp10_device *cif_isp10_create( cif_isp10_pltfrm_event_init(dev->dev, &dev->sp_stream.done); cif_isp10_pltfrm_event_init(dev->dev, &dev->mp_stream.done); - dev->img_src_exps.exp_valid_frms = 2; + dev->img_src_exps.exp_valid_frms[VALID_FR_EXP_T_INDEX] = 4; + dev->img_src_exps.exp_valid_frms[VALID_FR_EXP_G_INDEX] = 4; mutex_init(&dev->img_src_exps.mutex); memset(&dev->img_src_exps.data, 0x00, sizeof(dev->img_src_exps.data)); spin_lock_init(&dev->img_src_exps.lock); @@ -5944,9 +6149,11 @@ int cif_isp10_qbuf( switch (stream) { case CIF_ISP10_STREAM_SP: list_add_tail(&buf->queue, &dev->sp_stream.buf_queue); + cif_isp10_update_mi_immediate(dev, CIF_ISP10_STREAM_SP); break; case CIF_ISP10_STREAM_MP: list_add_tail(&buf->queue, &dev->mp_stream.buf_queue); + cif_isp10_update_mi_immediate(dev, CIF_ISP10_STREAM_MP); break; case CIF_ISP10_STREAM_DMA: list_add_tail(&buf->queue, &dev->dma_stream.buf_queue); @@ -5976,6 +6183,7 @@ int cif_isp10_reqbufs( enum cif_isp10_stream_id strm, struct v4l2_requestbuffers *req) { + unsigned long flags = 0; struct cif_isp10_stream *strm_dev = NULL; switch (strm) { @@ -5991,7 +6199,9 @@ int cif_isp10_reqbufs( break; } + spin_lock_irqsave(&strm_dev->metadata.spinlock, flags); strm_dev->metadata.cnt = req->count; + spin_unlock_irqrestore(&strm_dev->metadata.spinlock, flags); return 0; } @@ -6000,28 +6210,112 @@ int cif_isp10_s_exp( struct cif_isp10_device *dev, struct cif_isp10_img_src_ext_ctrl *exp_ctrl) { - struct cif_isp10_img_src_exp *exp = NULL; + struct cif_isp10_img_src_ctrl *ctrl_exp_t = NULL, *ctrl_exp_g = NULL; + struct cif_isp10_img_src_exp *exp = NULL, *exp_t = NULL, *exp_g = NULL; unsigned long lock_flags; - int retval; + int retval, i, exp_cnt; if (!dev->vs_wq) return -ENODEV; - exp = kmalloc(sizeof(*exp), GFP_KERNEL); - if (!exp) { - retval = -ENOMEM; - goto failed; + if (dev->img_src_exps.exp_valid_frms[VALID_FR_EXP_T_INDEX] == + dev->img_src_exps.exp_valid_frms[VALID_FR_EXP_G_INDEX]) { + exp = kmalloc(sizeof(struct cif_isp10_img_src_exp), GFP_KERNEL); + if (!exp) { + retval = -ENOMEM; + goto failed; + } + exp->exp = *exp_ctrl; + + spin_lock_irqsave(&dev->img_src_exps.lock, lock_flags); + list_add_tail(&exp->list, &dev->img_src_exps.list); + spin_unlock_irqrestore(&dev->img_src_exps.lock, lock_flags); + } else { + exp_t = kmalloc(sizeof(struct cif_isp10_img_src_exp), GFP_KERNEL); + if (!exp_t) { + retval = -ENOMEM; + goto failed; + } + ctrl_exp_t = kmalloc(sizeof(struct cif_isp10_img_src_ctrl) * 2, GFP_KERNEL); + if (!ctrl_exp_t) { + retval = -ENOMEM; + goto failed; + } + + exp_g = kmalloc(sizeof(struct cif_isp10_img_src_exp), GFP_KERNEL); + if (!exp_g) { + retval = -ENOMEM; + goto failed; + } + ctrl_exp_g = kmalloc(sizeof(struct cif_isp10_img_src_ctrl)*2, GFP_KERNEL); + if (!ctrl_exp_g) { + retval = -ENOMEM; + goto failed; + } + + exp_cnt = 0; + for (i = 0; i < exp_ctrl->cnt; i++) { + if (exp_ctrl->ctrls[i].id == V4L2_CID_EXPOSURE) { + *ctrl_exp_t = exp_ctrl->ctrls[i]; + exp_cnt++; + } + if (exp_ctrl->ctrls[i].id == RK_V4L2_CID_VTS) { + *(ctrl_exp_t + 1) = exp_ctrl->ctrls[i]; + exp_cnt++; + } + if (exp_ctrl->ctrls[i].id == V4L2_CID_GAIN) { + *ctrl_exp_g = exp_ctrl->ctrls[i]; + } + if (exp_ctrl->ctrls[i].id == RK_V4L2_CID_GAIN_PERCENT) { + *(ctrl_exp_g+1) = exp_ctrl->ctrls[i]; + } + } + kfree(exp_ctrl->ctrls); + exp_ctrl->ctrls = NULL; + + exp_t->exp.cnt = exp_cnt; + exp_t->exp.class = exp_ctrl->class; + exp_t->exp.ctrls = ctrl_exp_t; + exp_g->exp.cnt = 2; + exp_g->exp.class = exp_ctrl->class; + exp_g->exp.ctrls = ctrl_exp_g; + + if (dev->img_src_exps.exp_valid_frms[VALID_FR_EXP_T_INDEX] < + dev->img_src_exps.exp_valid_frms[VALID_FR_EXP_G_INDEX]) { + spin_lock_irqsave(&dev->img_src_exps.lock, lock_flags); + list_add_tail(&exp_g->list, &dev->img_src_exps.list); + list_add_tail(&exp_t->list, &dev->img_src_exps.list); + spin_unlock_irqrestore(&dev->img_src_exps.lock, lock_flags); + } else { + spin_lock_irqsave(&dev->img_src_exps.lock, lock_flags); + list_add_tail(&exp_t->list, &dev->img_src_exps.list); + list_add_tail(&exp_g->list, &dev->img_src_exps.list); + spin_unlock_irqrestore(&dev->img_src_exps.lock, lock_flags); + } } - - exp->exp = exp_ctrl; - - spin_lock_irqsave(&dev->img_src_exps.lock, lock_flags); - list_add_tail(&exp->list, &dev->img_src_exps.list); - spin_unlock_irqrestore(&dev->img_src_exps.lock, lock_flags); - return 0; failed: + if (exp) { + kfree(exp); + exp = NULL; + } + if (exp_t) { + kfree(exp_t); + exp_t = NULL; + } + if (exp_g) { + kfree(exp_g); + exp_g = NULL; + } + if (ctrl_exp_t) { + kfree(ctrl_exp_t); + ctrl_exp_t = NULL; + } + if (ctrl_exp_g) { + kfree(ctrl_exp_g); + ctrl_exp_g = NULL; + } return retval; } @@ -6036,20 +6330,18 @@ int cif_isp10_s_vcm( return 0; } -int cif_isp10_s_isp_metadata( +int cif_isp10_s_vb_metadata( struct cif_isp10_device *dev, - struct cif_isp10_isp_readout_work *readout_work, - struct cifisp_isp_other_cfg *new_other, - struct cifisp_isp_meas_cfg *new_meas, - struct cifisp_stat_buffer *new_stats) + struct cif_isp10_isp_readout_work *readout_work) { + unsigned long flags = 0; unsigned int stream_id = readout_work->stream_id; struct vb2_buffer *vb = readout_work->vb; struct cif_isp10_stream *strm_dev = NULL; struct v4l2_buffer_metadata_s *metadata; - struct cifisp_isp_metadata *isp_last; + struct isp_supplemental_sensor_mode_data sensor_mode; switch (stream_id) { case CIF_ISP10_STREAM_MP: @@ -6061,50 +6353,39 @@ int cif_isp10_s_isp_metadata( default: cif_isp10_pltfrm_pr_err(dev->dev, "unknown stream id%d\n", stream_id); - break; + return -1; } + if (strm_dev->state != CIF_ISP10_STATE_STREAMING) { + cif_isp10_pltfrm_pr_err(dev->dev, + "stream id%d is not streaming\n", stream_id); + return -1; + } + + cif_isp10_sensor_mode_data_sync(dev, + readout_work->frame_id, + &sensor_mode); + + spin_lock_irqsave(&strm_dev->metadata.spinlock, flags); if (vb && strm_dev->metadata.d) { + if (vb->index >= strm_dev->metadata.cnt) { + cif_isp10_pltfrm_pr_err(dev->dev, + "vb->index %d is bigger than metadata.cnt %d\n", + vb->index, strm_dev->metadata.cnt); + spin_unlock_irqrestore(&strm_dev->metadata.spinlock, flags); + return -1; + } metadata = (struct v4l2_buffer_metadata_s *) (strm_dev->metadata.d + vb->index * CAMERA_METADATA_LEN); metadata->frame_id = readout_work->frame_id; - isp_last = - (struct cifisp_isp_metadata *)metadata->isp; - - if (new_meas) { - if ((isp_last->meas_cfg.s_frame_id == 0xffffffff) || - (isp_last->meas_cfg.s_frame_id < - new_meas->s_frame_id)) { - memcpy(&isp_last->meas_cfg, - new_meas, - sizeof(struct cifisp_isp_meas_cfg)); - } - } - - if (new_other) { - if ((isp_last->other_cfg.s_frame_id == 0xffffffff) || - (isp_last->other_cfg.s_frame_id < - new_other->s_frame_id)) { - memcpy(&isp_last->other_cfg, - new_other, - sizeof(struct cifisp_isp_other_cfg)); - } - } - - if (new_stats) { - memcpy(&isp_last->meas_stat, - new_stats, - sizeof(struct cifisp_stat_buffer)); - metadata->sensor.exp_time = - new_stats->sensor_mode.exp_time; - metadata->sensor.gain = - new_stats->sensor_mode.gain; - } else { - isp_last->meas_stat.meas_type = 0x00; - } + metadata->sensor.exp_time = + sensor_mode.exp_time; + metadata->sensor.gain = + sensor_mode.gain; } + spin_unlock_irqrestore(&strm_dev->metadata.spinlock, flags); if (vb) { cif_isp10_pltfrm_pr_dbg(NULL, @@ -6124,6 +6405,7 @@ int cif_isp10_mmap( void *mem_vaddr; int retval = 0, pages; unsigned long mem_size; + unsigned long flags = 0; switch (stream_id) { case CIF_ISP10_STREAM_MP: @@ -6169,7 +6451,9 @@ int cif_isp10_mmap( goto done; } + spin_lock_irqsave(&strm_dev->metadata.spinlock, flags); strm_dev->metadata.d = (unsigned char *)mem_vaddr; + spin_unlock_irqrestore(&strm_dev->metadata.spinlock, flags); vma->vm_private_data = (void *)&strm_dev->metadata; @@ -6578,7 +6862,6 @@ int cif_isp10_isp_isr(unsigned int isp_mis, void *cntxt) } if (isp_mis & CIF_ISP_V_START) { - struct cif_isp10_isp_vs_work *vs_wk; struct cif_isp10_img_src_exp *exp; do_gettimeofday(&tv); @@ -6620,23 +6903,8 @@ int cif_isp10_isp_isr(unsigned int isp_mis, void *cntxt) } spin_unlock(&dev->img_src_exps.lock); - if (exp) { - vs_wk = kmalloc(sizeof(*vs_wk), - GFP_KERNEL); - if (vs_wk) { - vs_wk->cmd = CIF_ISP10_VS_EXP; - vs_wk->dev = dev; - vs_wk->param = (void *)exp; - INIT_WORK((struct work_struct *)&vs_wk->work, - cif_isp10_vs_work); - if (!queue_work(dev->vs_wq, - (struct work_struct *)&vs_wk->work)) { - cif_isp10_pltfrm_pr_err(dev->dev, - "%s: queue work failed\n", __func__); - kfree(vs_wk); - } - } - } + if (exp) + cif_isp10_vs_work_cmd(dev, CIF_ISP10_VS_EXP, (void *)exp); } if (isp_mis & CIF_ISP_FRAME_IN) { diff --git a/drivers/media/platform/rk-isp10/cif_isp10.h b/drivers/media/platform/rk-isp10/cif_isp10.h index b97e2f41087f..e34d1df007b1 100644 --- a/drivers/media/platform/rk-isp10/cif_isp10.h +++ b/drivers/media/platform/rk-isp10/cif_isp10.h @@ -246,6 +246,7 @@ enum cif_isp10_pix_fmt { /* YUV */ CIF_YUV400 = 0x10008000, CIF_YVU400 = 0x10008004, + CIF_Y10 = 0x1000a000, CIF_YUV420I = 0x1000c220, CIF_YUV420SP = 0x1000c221, /* NV12 */ @@ -469,6 +470,7 @@ struct cif_isp10_buffer { struct cif_isp10_metadata_s { unsigned int cnt; unsigned int vmas; + spinlock_t spinlock; unsigned char *d; }; @@ -552,7 +554,7 @@ struct cif_isp10_mi_state { struct cif_isp10_img_src_exp { struct list_head list; - struct cif_isp10_img_src_ext_ctrl *exp; + struct cif_isp10_img_src_ext_ctrl exp; }; struct cif_isp10_img_src_data { @@ -566,11 +568,12 @@ struct cif_isp10_img_src_exps { struct mutex mutex; /* protect frm_exp */ struct cif_isp10_img_src_data data[2]; - unsigned char exp_valid_frms; + unsigned char exp_valid_frms[2]; }; enum cif_isp10_isp_vs_cmd { - CIF_ISP10_VS_EXP = 0, + CIF_ISP10_VS_EXIT = 0, + CIF_ISP10_VS_EXP = 1 }; struct cif_isp10_isp_vs_work { @@ -778,17 +781,9 @@ int cif_isp10_s_ctrl( const enum cif_isp10_cid id, int val); -void cif_isp10_dbgfs_fill_sensor_aec_para( - struct cif_isp10_device *cif_isp10_dev, - s32 exp_time, - u16 gain); - -int cif_isp10_s_isp_metadata( +int cif_isp10_s_vb_metadata( struct cif_isp10_device *dev, - struct cif_isp10_isp_readout_work *readout_work, - struct cifisp_isp_other_cfg *new_other, - struct cifisp_isp_meas_cfg *new_meas, - struct cifisp_stat_buffer *new_stats); + struct cif_isp10_isp_readout_work *readout_work); int cif_isp10_s_exp( struct cif_isp10_device *dev, diff --git a/drivers/media/platform/rk-isp10/cif_isp10_img_src.c b/drivers/media/platform/rk-isp10/cif_isp10_img_src.c index 7d8a18c30578..d9edf2bf4389 100644 --- a/drivers/media/platform/rk-isp10/cif_isp10_img_src.c +++ b/drivers/media/platform/rk-isp10/cif_isp10_img_src.c @@ -173,3 +173,35 @@ const char *cif_isp10_img_src_g_name( return img_src->ops->g_name(img_src->img_src); } +void *cif_isp10_img_src_g_img_src( + struct cif_isp10_img_src *img_src) +{ + if (img_src) { + return img_src->img_src; + } + + return NULL; +} + +int cif_isp10_img_src_s_frame_interval( + struct cif_isp10_img_src *img_src, + struct cif_isp10_frm_intrvl *frm_intrvl) +{ + if (img_src) + return img_src->ops->s_frame_interval( + img_src->img_src, + frm_intrvl); + return -EINVAL; +} + +int cif_isp10_img_src_g_frame_interval( + struct cif_isp10_img_src *img_src, + struct cif_isp10_frm_intrvl *frm_intrvl) +{ + if (img_src) + return img_src->ops->g_frame_interval( + img_src->img_src, + frm_intrvl); + return -EINVAL; +} + diff --git a/drivers/media/platform/rk-isp10/cif_isp10_img_src.h b/drivers/media/platform/rk-isp10/cif_isp10_img_src.h index 0ef90b036954..48bb4c7405aa 100644 --- a/drivers/media/platform/rk-isp10/cif_isp10_img_src.h +++ b/drivers/media/platform/rk-isp10/cif_isp10_img_src.h @@ -23,6 +23,7 @@ struct cif_isp10_strm_fmt; struct cif_isp10_csi_config; enum cif_isp10_pix_fmt; +struct cif_isp10_frm_intrvl; struct cif_isp10_img_src; struct pltfrm_soc_cfg; @@ -80,4 +81,15 @@ long cif_isp10_img_src_ioctl( unsigned int cmd, void *arg); +void *cif_isp10_img_src_g_img_src( + struct cif_isp10_img_src *img_src); + +int cif_isp10_img_src_s_frame_interval( + struct cif_isp10_img_src *img_src, + struct cif_isp10_frm_intrvl *frm_intrvl); + +int cif_isp10_img_src_g_frame_interval( + struct cif_isp10_img_src *img_src, + struct cif_isp10_frm_intrvl *frm_intrvl); + #endif diff --git a/drivers/media/platform/rk-isp10/cif_isp10_img_src_ops.h b/drivers/media/platform/rk-isp10/cif_isp10_img_src_ops.h index 130af3b6eb1c..a82d18ccbdae 100644 --- a/drivers/media/platform/rk-isp10/cif_isp10_img_src_ops.h +++ b/drivers/media/platform/rk-isp10/cif_isp10_img_src_ops.h @@ -53,6 +53,12 @@ struct cif_isp10_img_src_ops { void *img_src, unsigned int cmd, void *arg); + int (*s_frame_interval)( + void *img_src, + struct cif_isp10_frm_intrvl *frm_intrvl); + int (*g_frame_interval)( + void *img_src, + struct cif_isp10_frm_intrvl *frm_intrvl); }; const struct { @@ -81,7 +87,11 @@ const struct { .s_ext_ctrls = cif_isp10_img_src_v4l2_subdev_s_ext_ctrls, .ioctl = - cif_isp10_img_src_v4l2_subdev_ioctl + cif_isp10_img_src_v4l2_subdev_ioctl, + .s_frame_interval = + cif_isp10_img_src_v4l2_subdev_s_frame_interval, + .g_frame_interval = + cif_isp10_img_src_v4l2_subdev_g_frame_interval, } }, }; diff --git a/drivers/media/platform/rk-isp10/cif_isp10_img_src_v4l2-subdev.c b/drivers/media/platform/rk-isp10/cif_isp10_img_src_v4l2-subdev.c index 92ac9d5e7adf..da677e2f89ce 100644 --- a/drivers/media/platform/rk-isp10/cif_isp10_img_src_v4l2-subdev.c +++ b/drivers/media/platform/rk-isp10/cif_isp10_img_src_v4l2-subdev.c @@ -64,6 +64,10 @@ static enum cif_isp10_pix_fmt img_src_v4l2_subdev_pix_fmt2cif_isp10_pix_fmt( int img_src_pix_fmt) { switch (img_src_pix_fmt) { + case MEDIA_BUS_FMT_Y8_1X8: + return CIF_YUV400; + case MEDIA_BUS_FMT_Y10_1X10: + return CIF_Y10; case MEDIA_BUS_FMT_YUYV8_1_5X8: case MEDIA_BUS_FMT_YUYV8_2X8: case MEDIA_BUS_FMT_YUYV10_2X10: @@ -136,6 +140,10 @@ static int cif_isp10_pix_fmt2img_src_v4l2_subdev_pix_fmt( enum cif_isp10_pix_fmt cif_isp10_pix_fmt) { switch (cif_isp10_pix_fmt) { + case CIF_Y10: + return MEDIA_BUS_FMT_Y10_1X10; + case CIF_YUV400: + return MEDIA_BUS_FMT_Y8_1X8; case CIF_YUV422I: return MEDIA_BUS_FMT_YUYV8_2X8; case CIF_YVU422I: @@ -460,6 +468,8 @@ long cif_isp10_img_src_v4l2_subdev_ioctl( switch (cmd) { case RK_VIDIOC_SENSOR_MODE_DATA: case RK_VIDIOC_CAMERA_MODULEINFO: + case RK_VIDIOC_SENSOR_CONFIGINFO: + case RK_VIDIOC_SENSOR_REG_ACCESS: case PLTFRM_CIFCAM_G_ITF_CFG: case PLTFRM_CIFCAM_G_DEFRECT: @@ -484,3 +494,49 @@ long cif_isp10_img_src_v4l2_subdev_ioctl( return ret; } + +int cif_isp10_img_src_v4l2_subdev_s_frame_interval( + void *img_src, + struct cif_isp10_frm_intrvl *frm_intrvl) +{ + int ret = 0; + struct v4l2_subdev *subdev = img_src; + struct v4l2_subdev_frame_interval interval; + + interval.interval.numerator = frm_intrvl->numerator; + interval.interval.denominator = frm_intrvl->denominator; + + ret = v4l2_subdev_call(subdev, video, s_frame_interval, &interval); + if (IS_ERR_VALUE(ret)) + goto err; + + return 0; +err: + pr_err("img_src.%s ERR: failed with error %d\n", __func__, ret); + return ret; +} + +int cif_isp10_img_src_v4l2_subdev_g_frame_interval( + void *img_src, + struct cif_isp10_frm_intrvl *frm_intrvl) +{ + int ret = 0; + struct v4l2_subdev *subdev = img_src; + struct v4l2_subdev_frame_interval interval; + + interval.interval.numerator = 0; + interval.interval.denominator = 0; + + ret = v4l2_subdev_call(subdev, video, g_frame_interval, &interval); + if (IS_ERR_VALUE(ret)) + goto err; + + frm_intrvl->denominator = interval.interval.denominator; + frm_intrvl->numerator = interval.interval.numerator; + + return 0; +err: + pr_err("img_src.%s ERR: failed with error %d\n", __func__, ret); + return ret; +} + diff --git a/drivers/media/platform/rk-isp10/cif_isp10_img_src_v4l2-subdev.h b/drivers/media/platform/rk-isp10/cif_isp10_img_src_v4l2-subdev.h index a5ba17e4b7c8..c2697e4ac81f 100644 --- a/drivers/media/platform/rk-isp10/cif_isp10_img_src_v4l2-subdev.h +++ b/drivers/media/platform/rk-isp10/cif_isp10_img_src_v4l2-subdev.h @@ -62,4 +62,12 @@ long cif_isp10_img_src_v4l2_subdev_ioctl( unsigned int cmd, void *arg); +int cif_isp10_img_src_v4l2_subdev_s_frame_interval( + void *img_src, + struct cif_isp10_frm_intrvl *frm_intrvl); + +int cif_isp10_img_src_v4l2_subdev_g_frame_interval( + void *img_src, + struct cif_isp10_frm_intrvl *frm_intrvl); + #endif diff --git a/drivers/media/platform/rk-isp10/cif_isp10_isp.c b/drivers/media/platform/rk-isp10/cif_isp10_isp.c index e6c645a88fe2..3bf900622b73 100644 --- a/drivers/media/platform/rk-isp10/cif_isp10_isp.c +++ b/drivers/media/platform/rk-isp10/cif_isp10_isp.c @@ -31,6 +31,8 @@ #include "cif_isp10_pltfrm.h" #include "cif_isp10.h" +#define CIFISP_MEAS_SEND_ALONE (CIF_ISP_AFM_FIN) + #define _GET_ 0 #define _SET_ 1 #define CIFISP_MODULE_EN(v, m) ((v) |= (m)) @@ -40,6 +42,10 @@ #define CIFISP_MODULE_CLR_UPDATE(v, m) ((v) &= ~(m)) #define CIFISP_MODULE_IS_UPDATE(v, m) (((v) & (m)) == (m)) +#define CIFISP_MODULE_UNACTIVE(v, m) ((v) |= (m)) +#define CIFISP_MODULE_ACTIVE(v, m) ((v) &= ~(m)) +#define CIFISP_MODULE_IS_UNACTIVE(v, m) (((v) & (m)) == (m)) + /* Demosaic */ #define CIFISP_BDM_BYPASS_EN(val) ((val) << 10) /* HIST */ @@ -314,44 +320,63 @@ static void cifisp_reg_dump(const struct cif_isp10_isp_dev *isp_dev, static void cifisp_reg_dump_capture(const struct cif_isp10_isp_dev *isp_dev); #endif +static bool cifisp_isp_isr_other_config( + struct cif_isp10_isp_dev *isp_dev, + unsigned int *time_left); + +static bool cifisp_isp_isr_meas_config( + struct cif_isp10_isp_dev *isp_dev, + unsigned int *time_left); + static struct cif_isp10_buffer *to_cif_isp10_vb(struct vb2_v4l2_buffer *vb) { return container_of(vb, struct cif_isp10_buffer, vb); } static int cifisp_module_enable(struct cif_isp10_isp_dev *isp_dev, - bool flag, __s32 *value, unsigned int module) + bool flag, __s32 *value, unsigned int module) { - unsigned int *curr_ens, *updates, *new_ens; + unsigned int curr_id, new_id; + unsigned int *updates, *curr_ens, *new_ens, *actives; unsigned long lock_flags = 0; + if (module >= CIFISP_MODULE_MAX) + return -EINVAL; + spin_lock_irqsave(&isp_dev->config_lock, lock_flags); - if (module & (CIFISP_MODULE_AWB | - CIFISP_MODULE_AEC | - CIFISP_MODULE_AFC | - CIFISP_MODULE_HST)) { - curr_ens = &isp_dev->meas_cfgs.curr->module_ens; - new_ens = &isp_dev->meas_cfgs.last_or_new->module_ens; + if (module >= CIFISP_MEAS_ID) { + curr_id = isp_dev->meas_cfgs.log[module].curr_id; + new_id = isp_dev->meas_cfgs.log[module].new_id; updates = &isp_dev->meas_cfgs.module_updates; + actives = &isp_dev->meas_cfgs.module_actives; + curr_ens = &isp_dev->meas_cfgs.cfgs[curr_id].module_ens; + new_ens = &isp_dev->meas_cfgs.cfgs[new_id].module_ens; } else { - curr_ens = &isp_dev->other_cfgs.curr->module_ens; - new_ens = &isp_dev->other_cfgs.last_or_new->module_ens; + curr_id = isp_dev->other_cfgs.log[module].curr_id; + new_id = isp_dev->other_cfgs.log[module].new_id; updates = &isp_dev->other_cfgs.module_updates; + actives = &isp_dev->other_cfgs.module_actives; + curr_ens = &isp_dev->other_cfgs.cfgs[curr_id].module_ens; + new_ens = &isp_dev->other_cfgs.cfgs[new_id].module_ens; } if (flag == _GET_) { - *value = CIFISP_MODULE_IS_EN(*curr_ens, module); + *value = CIFISP_MODULE_IS_EN( + *curr_ens, (1 << module)); goto end; } - if (CIFISP_MODULE_IS_EN(*curr_ens, module) != *value) { - if (*value) - CIFISP_MODULE_EN(*new_ens, module); - else - CIFISP_MODULE_DIS(*new_ens, module); + if (CIFISP_MODULE_IS_UNACTIVE(*actives, (1 << module)) && *value) + goto end; - CIFISP_MODULE_UPDATE(*updates, module); + if ((CIFISP_MODULE_IS_EN(*curr_ens, (1 << module)) != *value) || + (CIFISP_MODULE_IS_UPDATE(*updates, (1 << module)))) { + if (*value) + CIFISP_MODULE_EN(*new_ens, (1 << module)); + else + CIFISP_MODULE_DIS(*new_ens, (1 << module)); + CIFISP_MODULE_UPDATE(*updates, (1 << module)); } end: @@ -362,11 +387,13 @@ static int cifisp_module_enable(struct cif_isp10_isp_dev *isp_dev, /* ISP BP interface function */ static int cifisp_dpcc_param(struct cif_isp10_isp_dev *isp_dev, - bool flag, struct cifisp_dpcc_config *arg) + bool flag, struct cifisp_dpcc_config *arg) { unsigned long lock_flags = 0; unsigned int i; struct cifisp_dpcc_methods_config *method; + struct cif_isp10_isp_cfgs_log *cfg_log; + struct cifisp_dpcc_config *curr_cfg, *new_cfg; int retval = 0; if (!arg) { @@ -378,18 +405,28 @@ static int cifisp_dpcc_param(struct cif_isp10_isp_dev *isp_dev, spin_lock_irqsave(&isp_dev->config_lock, lock_flags); + cfg_log = &isp_dev->other_cfgs.log[CIFISP_DPCC_ID]; + curr_cfg = &isp_dev->other_cfgs.cfgs[cfg_log->curr_id].dpcc_config; + new_cfg = &isp_dev->other_cfgs.cfgs[cfg_log->new_id].dpcc_config; + if (flag == _GET_) { - memcpy(arg, - &isp_dev->other_cfgs.curr->dpcc_config, - sizeof(*arg)); + memcpy(arg, curr_cfg, sizeof(*arg)); + goto end; + } + + if (CIFISP_MODULE_IS_UNACTIVE(isp_dev->other_cfgs.module_actives, + CIFISP_MODULE_DPCC)) { + CIFISP_DPRINT(CIFISP_ERROR, + "module is unactive in function: %s\n", __func__); goto end; } cifisp_param_dump(arg, CIFISP_MODULE_DPCC); - if (memcmp(arg, - &isp_dev->other_cfgs.curr->dpcc_config, - sizeof(*arg)) == 0) { + if (CIFISP_MODULE_IS_EN( + isp_dev->other_cfgs.cfgs[cfg_log->curr_id].module_ens, + CIFISP_MODULE_DPCC) && + memcmp(arg, curr_cfg, sizeof(*arg)) == 0) { CIFISP_DPRINT(CIFISP_DEBUG, "same param in function: %s\n", __func__); goto end; @@ -409,16 +446,16 @@ static int cifisp_dpcc_param(struct cif_isp10_isp_dev *isp_dev, method = &arg->methods[i]; for (i = 0; i < CIFISP_DPCC_METHODS_MAX; i++) { if ((method->method & - CIFISP_DPCC_METHODS_SET_RESERVED) || - (method->line_thresh & - CIFISP_DPCC_LINE_THRESH_RESERVED) || - (method->line_mad_fac & - CIFISP_DPCC_LINE_MAD_FAC_RESERVED) || - (method->pg_fac & - CIFISP_DPCC_PG_FAC_RESERVED) || - (method->rnd_thresh & - CIFISP_DPCC_RND_THRESH_RESERVED) || - (method->rg_fac & CIFISP_DPCC_RG_FAC_RESERVED)) { + CIFISP_DPCC_METHODS_SET_RESERVED) || + (method->line_thresh & + CIFISP_DPCC_LINE_THRESH_RESERVED) || + (method->line_mad_fac & + CIFISP_DPCC_LINE_MAD_FAC_RESERVED) || + (method->pg_fac & + CIFISP_DPCC_PG_FAC_RESERVED) || + (method->rnd_thresh & + CIFISP_DPCC_RND_THRESH_RESERVED) || + (method->rg_fac & CIFISP_DPCC_RG_FAC_RESERVED)) { CIFISP_DPRINT(CIFISP_ERROR, "incompatible param in function: %s\n", __func__); retval = -EINVAL; @@ -427,9 +464,7 @@ static int cifisp_dpcc_param(struct cif_isp10_isp_dev *isp_dev, method++; } - memcpy(&isp_dev->other_cfgs.last_or_new->dpcc_config, - arg, - sizeof(struct cifisp_dpcc_config)); + memcpy(new_cfg, arg, sizeof(struct cifisp_dpcc_config)); CIFISP_MODULE_UPDATE( isp_dev->other_cfgs.module_updates, CIFISP_MODULE_DPCC); @@ -444,6 +479,8 @@ static int cifisp_bls_param(struct cif_isp10_isp_dev *isp_dev, bool flag, struct cifisp_bls_config *arg) { unsigned long lock_flags = 0; + struct cif_isp10_isp_cfgs_log *cfg_log; + struct cifisp_bls_config *curr_cfg, *new_cfg; int retval = 0; if (!arg) @@ -451,18 +488,28 @@ static int cifisp_bls_param(struct cif_isp10_isp_dev *isp_dev, spin_lock_irqsave(&isp_dev->config_lock, lock_flags); + cfg_log = &isp_dev->other_cfgs.log[CIFISP_BLS_ID]; + curr_cfg = &isp_dev->other_cfgs.cfgs[cfg_log->curr_id].bls_config; + new_cfg = &isp_dev->other_cfgs.cfgs[cfg_log->new_id].bls_config; + if (flag == _GET_) { - memcpy(arg, - &isp_dev->other_cfgs.curr->bls_config, - sizeof(*arg)); + memcpy(arg, curr_cfg, sizeof(*arg)); + goto end; + } + + if (CIFISP_MODULE_IS_UNACTIVE(isp_dev->other_cfgs.module_actives, + CIFISP_MODULE_BLS)) { + CIFISP_DPRINT(CIFISP_ERROR, + "module is unactive in function: %s\n", __func__); goto end; } cifisp_param_dump(arg, CIFISP_MODULE_BLS); - if (memcmp(arg, - &isp_dev->other_cfgs.curr->bls_config, - sizeof(*arg)) == 0) { + if (CIFISP_MODULE_IS_EN( + isp_dev->other_cfgs.cfgs[cfg_log->curr_id].module_ens, + CIFISP_MODULE_BLS) && + memcmp(arg, curr_cfg, sizeof(*arg)) == 0) { CIFISP_DPRINT(CIFISP_DEBUG, "same param in function: %s\n", __func__); goto end; @@ -491,9 +538,9 @@ static int cifisp_bls_param(struct cif_isp10_isp_dev *isp_dev, goto end; } - memcpy(&isp_dev->other_cfgs.last_or_new->bls_config, - arg, - sizeof(struct cifisp_bls_config)); + memcpy(new_cfg, + arg, + sizeof(struct cifisp_bls_config)); CIFISP_MODULE_UPDATE( isp_dev->other_cfgs.module_updates, CIFISP_MODULE_BLS); @@ -509,6 +556,8 @@ static int cifisp_lsc_param(struct cif_isp10_isp_dev *isp_dev, { int i; unsigned long lock_flags = 0; + struct cif_isp10_isp_cfgs_log *cfg_log; + struct cifisp_lsc_config *curr_cfg, *new_cfg; int retval = 0; if (!arg) @@ -516,18 +565,28 @@ static int cifisp_lsc_param(struct cif_isp10_isp_dev *isp_dev, spin_lock_irqsave(&isp_dev->config_lock, lock_flags); + cfg_log = &isp_dev->other_cfgs.log[CIFISP_LSC_ID]; + curr_cfg = &isp_dev->other_cfgs.cfgs[cfg_log->curr_id].lsc_config; + new_cfg = &isp_dev->other_cfgs.cfgs[cfg_log->new_id].lsc_config; + if (flag == _GET_) { - memcpy(arg, - &isp_dev->other_cfgs.curr->lsc_config, - sizeof(*arg)); + memcpy(arg, curr_cfg, sizeof(*arg)); + goto end; + } + + if (CIFISP_MODULE_IS_UNACTIVE(isp_dev->other_cfgs.module_actives, + CIFISP_MODULE_LSC)) { + CIFISP_DPRINT(CIFISP_ERROR, + "module is unactive in function: %s\n", __func__); goto end; } cifisp_param_dump(arg, CIFISP_MODULE_LSC); - if (memcmp(arg, - &isp_dev->other_cfgs.curr->lsc_config, - sizeof(*arg)) == 0) { + if (CIFISP_MODULE_IS_EN( + isp_dev->other_cfgs.cfgs[cfg_log->curr_id].module_ens, + CIFISP_MODULE_LSC) && + memcmp(arg, curr_cfg, sizeof(*arg)) == 0) { CIFISP_DPRINT(CIFISP_DEBUG, "same param in function: %s\n", __func__); goto end; @@ -567,19 +626,19 @@ static int cifisp_lsc_param(struct cif_isp10_isp_dev *isp_dev, (*(arg->b_data_tbl + i) & CIFISP_LSC_SAMPLE_RESERVED)) { CIFISP_DPRINT(CIFISP_ERROR, - "incompatible sample r 0x%x gr 0x%x gb 0x%x b 0x%x in function: %s\n", - *(arg->r_data_tbl + i), - *(arg->gr_data_tbl + i), - *(arg->gb_data_tbl + i), - *(arg->b_data_tbl + i), __func__); + "incompatible sample r 0x%x gr 0x%x gb 0x%x b 0x%x in function: %s\n", + *(arg->r_data_tbl + i), + *(arg->gr_data_tbl + i), + *(arg->gb_data_tbl + i), + *(arg->b_data_tbl + i), __func__); retval = -EINVAL; goto end; } } - memcpy(&isp_dev->other_cfgs.last_or_new->lsc_config, - arg, - sizeof(struct cifisp_lsc_config)); + memcpy(new_cfg, + arg, + sizeof(struct cifisp_lsc_config)); CIFISP_MODULE_UPDATE( isp_dev->other_cfgs.module_updates, CIFISP_MODULE_LSC); @@ -594,6 +653,8 @@ static int cifisp_flt_param(struct cif_isp10_isp_dev *isp_dev, bool flag, struct cifisp_flt_config *arg) { unsigned long lock_flags = 0; + struct cif_isp10_isp_cfgs_log *cfg_log; + struct cifisp_flt_config *curr_cfg, *new_cfg; int retval = 0; if (!arg) @@ -601,18 +662,28 @@ static int cifisp_flt_param(struct cif_isp10_isp_dev *isp_dev, spin_lock_irqsave(&isp_dev->config_lock, lock_flags); + cfg_log = &isp_dev->other_cfgs.log[CIFISP_FLT_ID]; + curr_cfg = &isp_dev->other_cfgs.cfgs[cfg_log->curr_id].flt_config; + new_cfg = &isp_dev->other_cfgs.cfgs[cfg_log->new_id].flt_config; + if (flag == _GET_) { - memcpy(arg, - &isp_dev->other_cfgs.curr->flt_config, - sizeof(*arg)); + memcpy(arg, curr_cfg, sizeof(*arg)); + goto end; + } + + if (CIFISP_MODULE_IS_UNACTIVE(isp_dev->other_cfgs.module_actives, + CIFISP_MODULE_FLT)) { + CIFISP_DPRINT(CIFISP_ERROR, + "module is unactive in function: %s\n", __func__); goto end; } cifisp_param_dump(arg, CIFISP_MODULE_FLT); - if (memcmp(arg, - &isp_dev->other_cfgs.curr->flt_config, - sizeof(*arg)) == 0) { + if (CIFISP_MODULE_IS_EN( + isp_dev->other_cfgs.cfgs[cfg_log->curr_id].module_ens, + CIFISP_MODULE_FLT) && + memcmp(arg, curr_cfg, sizeof(*arg)) == 0) { CIFISP_DPRINT(CIFISP_DEBUG, "same param in function: %s\n", __func__); goto end; @@ -620,28 +691,28 @@ static int cifisp_flt_param(struct cif_isp10_isp_dev *isp_dev, /* Parameter check */ if (arg->mode > CIFISP_FLT_MODE_MAX || - arg->grn_stage1 > CIFISP_FLT_GREEN_STAGE1_MAX || - arg->chr_v_mode > CIFISP_FLT_CHROMA_MODE_MAX || - arg->chr_h_mode > CIFISP_FLT_CHROMA_MODE_MAX || - arg->thresh_sh0 & CIFISP_FLT_THREAD_RESERVED || - arg->thresh_sh1 & CIFISP_FLT_THREAD_RESERVED || - arg->thresh_bl0 & CIFISP_FLT_THREAD_RESERVED || - arg->thresh_bl1 & CIFISP_FLT_THREAD_RESERVED || - arg->fac_bl0 & CIFISP_FLT_FAC_RESERVED || - arg->fac_bl1 & CIFISP_FLT_FAC_RESERVED || - arg->fac_sh0 & CIFISP_FLT_FAC_RESERVED || - arg->fac_sh1 & CIFISP_FLT_FAC_RESERVED || - arg->fac_mid & CIFISP_FLT_FAC_RESERVED || - arg->lum_weight & CIFISP_FLT_LUM_WEIGHT_RESERVED) { + arg->grn_stage1 > CIFISP_FLT_GREEN_STAGE1_MAX || + arg->chr_v_mode > CIFISP_FLT_CHROMA_MODE_MAX || + arg->chr_h_mode > CIFISP_FLT_CHROMA_MODE_MAX || + arg->thresh_sh0 & CIFISP_FLT_THREAD_RESERVED || + arg->thresh_sh1 & CIFISP_FLT_THREAD_RESERVED || + arg->thresh_bl0 & CIFISP_FLT_THREAD_RESERVED || + arg->thresh_bl1 & CIFISP_FLT_THREAD_RESERVED || + arg->fac_bl0 & CIFISP_FLT_FAC_RESERVED || + arg->fac_bl1 & CIFISP_FLT_FAC_RESERVED || + arg->fac_sh0 & CIFISP_FLT_FAC_RESERVED || + arg->fac_sh1 & CIFISP_FLT_FAC_RESERVED || + arg->fac_mid & CIFISP_FLT_FAC_RESERVED || + arg->lum_weight & CIFISP_FLT_LUM_WEIGHT_RESERVED) { CIFISP_DPRINT(CIFISP_ERROR, "incompatible param in function: %s\n", __func__); retval = -EINVAL; goto end; } - memcpy(&isp_dev->other_cfgs.last_or_new->flt_config, - arg, - sizeof(struct cifisp_flt_config)); + memcpy(new_cfg, + arg, + sizeof(struct cifisp_flt_config)); CIFISP_MODULE_UPDATE( isp_dev->other_cfgs.module_updates, CIFISP_MODULE_FLT); @@ -656,6 +727,8 @@ static int cifisp_bdm_param(struct cif_isp10_isp_dev *isp_dev, bool flag, struct cifisp_bdm_config *arg) { unsigned long lock_flags = 0; + struct cif_isp10_isp_cfgs_log *cfg_log; + struct cifisp_bdm_config *curr_cfg, *new_cfg; int retval = 0; if (!arg) @@ -663,26 +736,36 @@ static int cifisp_bdm_param(struct cif_isp10_isp_dev *isp_dev, spin_lock_irqsave(&isp_dev->config_lock, lock_flags); + cfg_log = &isp_dev->other_cfgs.log[CIFISP_BDM_ID]; + curr_cfg = &isp_dev->other_cfgs.cfgs[cfg_log->curr_id].bdm_config; + new_cfg = &isp_dev->other_cfgs.cfgs[cfg_log->new_id].bdm_config; + if (flag == _GET_) { - memcpy(arg, - &isp_dev->other_cfgs.curr->bdm_config, - sizeof(*arg)); + memcpy(arg, curr_cfg, sizeof(*arg)); + goto end; + } + + if (CIFISP_MODULE_IS_UNACTIVE(isp_dev->other_cfgs.module_actives, + CIFISP_MODULE_BDM)) { + CIFISP_DPRINT(CIFISP_ERROR, + "module is unactive in function: %s\n", __func__); goto end; } cifisp_param_dump(arg, CIFISP_MODULE_BDM); - if (memcmp(arg, - &isp_dev->other_cfgs.curr->bdm_config, - sizeof(*arg)) == 0) { + if (CIFISP_MODULE_IS_EN( + isp_dev->other_cfgs.cfgs[cfg_log->curr_id].module_ens, + CIFISP_MODULE_BDM) && + memcmp(arg, curr_cfg, sizeof(*arg)) == 0) { CIFISP_DPRINT(CIFISP_DEBUG, "same param in function: %s\n", __func__); goto end; } - memcpy(&isp_dev->other_cfgs.last_or_new->bdm_config, - arg, - sizeof(struct cifisp_bdm_config)); + memcpy(new_cfg, + arg, + sizeof(struct cifisp_bdm_config)); CIFISP_MODULE_UPDATE( isp_dev->other_cfgs.module_updates, CIFISP_MODULE_BDM); @@ -698,6 +781,8 @@ static int cifisp_sdg_param(struct cif_isp10_isp_dev *isp_dev, { unsigned long lock_flags = 0; unsigned int i; + struct cif_isp10_isp_cfgs_log *cfg_log; + struct cifisp_sdg_config *curr_cfg, *new_cfg; int retval = 0; if (!arg) @@ -705,18 +790,28 @@ static int cifisp_sdg_param(struct cif_isp10_isp_dev *isp_dev, spin_lock_irqsave(&isp_dev->config_lock, lock_flags); + cfg_log = &isp_dev->other_cfgs.log[CIFISP_SDG_ID]; + curr_cfg = &isp_dev->other_cfgs.cfgs[cfg_log->curr_id].sdg_config; + new_cfg = &isp_dev->other_cfgs.cfgs[cfg_log->new_id].sdg_config; + if (flag == _GET_) { - memcpy(arg, - &isp_dev->other_cfgs.curr->sdg_config, - sizeof(*arg)); + memcpy(arg, curr_cfg, sizeof(*arg)); + goto end; + } + + if (CIFISP_MODULE_IS_UNACTIVE(isp_dev->other_cfgs.module_actives, + CIFISP_MODULE_SDG)) { + CIFISP_DPRINT(CIFISP_ERROR, + "module is unactive in function: %s\n", __func__); goto end; } cifisp_param_dump(arg, CIFISP_MODULE_SDG); - if (memcmp(arg, - &isp_dev->other_cfgs.curr->sdg_config, - sizeof(*arg)) == 0) { + if (CIFISP_MODULE_IS_EN( + isp_dev->other_cfgs.cfgs[cfg_log->curr_id].module_ens, + CIFISP_MODULE_SDG) && + memcmp(arg, curr_cfg, sizeof(*arg)) == 0) { CIFISP_DPRINT(CIFISP_DEBUG, "same param in function: %s\n", __func__); goto end; @@ -732,8 +827,8 @@ static int cifisp_sdg_param(struct cif_isp10_isp_dev *isp_dev, for (i = 0; i < CIFISP_DEGAMMA_CURVE_SIZE; i++) { if ((arg->curve_b.gamma_y[i] & CIFISP_DEGAMMA_Y_RESERVED) || - (arg->curve_r.gamma_y[i] & CIFISP_DEGAMMA_Y_RESERVED) || - (arg->curve_g.gamma_y[i] & CIFISP_DEGAMMA_Y_RESERVED)) { + (arg->curve_r.gamma_y[i] & CIFISP_DEGAMMA_Y_RESERVED) || + (arg->curve_g.gamma_y[i] & CIFISP_DEGAMMA_Y_RESERVED)) { CIFISP_DPRINT(CIFISP_ERROR, "incompatible param in function: %s\n", __func__); retval = -EINVAL; @@ -741,9 +836,9 @@ static int cifisp_sdg_param(struct cif_isp10_isp_dev *isp_dev, } } - memcpy(&isp_dev->other_cfgs.last_or_new->sdg_config, - arg, - sizeof(struct cifisp_sdg_config)); + memcpy(new_cfg, + arg, + sizeof(struct cifisp_sdg_config)); CIFISP_MODULE_UPDATE( isp_dev->other_cfgs.module_updates, CIFISP_MODULE_SDG); @@ -758,6 +853,8 @@ static int cifisp_goc_param(struct cif_isp10_isp_dev *isp_dev, bool flag, struct cifisp_goc_config *arg) { unsigned long lock_flags = 0; + struct cif_isp10_isp_cfgs_log *cfg_log; + struct cifisp_goc_config *curr_cfg, *new_cfg; int retval = 0; if (!arg) @@ -765,18 +862,28 @@ static int cifisp_goc_param(struct cif_isp10_isp_dev *isp_dev, spin_lock_irqsave(&isp_dev->config_lock, lock_flags); + cfg_log = &isp_dev->other_cfgs.log[CIFISP_GOC_ID]; + curr_cfg = &isp_dev->other_cfgs.cfgs[cfg_log->curr_id].goc_config; + new_cfg = &isp_dev->other_cfgs.cfgs[cfg_log->new_id].goc_config; + if (flag == _GET_) { - memcpy(arg, - &isp_dev->other_cfgs.curr->goc_config, - sizeof(*arg)); + memcpy(arg, curr_cfg, sizeof(*arg)); + goto end; + } + + if (CIFISP_MODULE_IS_UNACTIVE(isp_dev->other_cfgs.module_actives, + CIFISP_MODULE_GOC)) { + CIFISP_DPRINT(CIFISP_ERROR, + "module is unactive in function: %s\n", __func__); goto end; } cifisp_param_dump(arg, CIFISP_MODULE_GOC); - if (memcmp(arg, - &isp_dev->other_cfgs.curr->goc_config, - sizeof(*arg)) == 0) { + if (CIFISP_MODULE_IS_EN( + isp_dev->other_cfgs.cfgs[cfg_log->curr_id].module_ens, + CIFISP_MODULE_GOC) && + memcmp(arg, curr_cfg, sizeof(*arg)) == 0) { CIFISP_DPRINT(CIFISP_DEBUG, "same param in function: %s\n", __func__); goto end; @@ -784,15 +891,15 @@ static int cifisp_goc_param(struct cif_isp10_isp_dev *isp_dev, if (arg->mode > CIFISP_GOC_MODE_MAX) { CIFISP_DPRINT(CIFISP_ERROR, - "incompatible param 0x%x in function: %s\n", - arg->mode, __func__); + "incompatible param 0x%x in function: %s\n", + arg->mode, __func__); retval = -EINVAL; goto end; } - memcpy(&isp_dev->other_cfgs.last_or_new->goc_config, - arg, - sizeof(struct cifisp_goc_config)); + memcpy(new_cfg, + arg, + sizeof(struct cifisp_goc_config)); CIFISP_MODULE_UPDATE( isp_dev->other_cfgs.module_updates, CIFISP_MODULE_GOC); @@ -807,6 +914,8 @@ static int cifisp_ctk_param(struct cif_isp10_isp_dev *isp_dev, bool flag, struct cifisp_ctk_config *arg) { unsigned long lock_flags = 0; + struct cif_isp10_isp_cfgs_log *cfg_log; + struct cifisp_ctk_config *curr_cfg, *new_cfg; int retval = 0; if (!arg) @@ -814,18 +923,28 @@ static int cifisp_ctk_param(struct cif_isp10_isp_dev *isp_dev, spin_lock_irqsave(&isp_dev->config_lock, lock_flags); + cfg_log = &isp_dev->other_cfgs.log[CIFISP_CTK_ID]; + curr_cfg = &isp_dev->other_cfgs.cfgs[cfg_log->curr_id].ctk_config; + new_cfg = &isp_dev->other_cfgs.cfgs[cfg_log->new_id].ctk_config; + if (flag == _GET_) { - memcpy(arg, - &isp_dev->other_cfgs.curr->ctk_config, - sizeof(*arg)); + memcpy(arg, curr_cfg, sizeof(*arg)); + goto end; + } + + if (CIFISP_MODULE_IS_UNACTIVE(isp_dev->other_cfgs.module_actives, + CIFISP_MODULE_CTK)) { + CIFISP_DPRINT(CIFISP_ERROR, + "module is unactive in function: %s\n", __func__); goto end; } cifisp_param_dump(arg, CIFISP_MODULE_CTK); - if (memcmp(arg, - &isp_dev->other_cfgs.curr->ctk_config, - sizeof(*arg)) == 0) { + if (CIFISP_MODULE_IS_EN( + isp_dev->other_cfgs.cfgs[cfg_log->curr_id].module_ens, + CIFISP_MODULE_CTK) && + memcmp(arg, curr_cfg, sizeof(*arg)) == 0) { CIFISP_DPRINT(CIFISP_DEBUG, "same param in function: %s\n", __func__); goto end; @@ -850,9 +969,9 @@ static int cifisp_ctk_param(struct cif_isp10_isp_dev *isp_dev, goto end; } - memcpy(&isp_dev->other_cfgs.last_or_new->ctk_config, - arg, - sizeof(struct cifisp_ctk_config)); + memcpy(new_cfg, + arg, + sizeof(struct cifisp_ctk_config)); CIFISP_MODULE_UPDATE( isp_dev->other_cfgs.module_updates, CIFISP_MODULE_CTK); @@ -867,6 +986,8 @@ static int cifisp_awb_meas_param(struct cif_isp10_isp_dev *isp_dev, bool flag, struct cifisp_awb_meas_config *arg) { unsigned long lock_flags = 0; + struct cif_isp10_isp_cfgs_log *cfg_log; + struct cifisp_awb_meas_config *curr_cfg, *new_cfg; int retval = 0; if (!arg) @@ -874,18 +995,28 @@ static int cifisp_awb_meas_param(struct cif_isp10_isp_dev *isp_dev, spin_lock_irqsave(&isp_dev->config_lock, lock_flags); + cfg_log = &isp_dev->meas_cfgs.log[CIFISP_AWB_ID]; + curr_cfg = &isp_dev->meas_cfgs.cfgs[cfg_log->curr_id].awb_meas_config; + new_cfg = &isp_dev->meas_cfgs.cfgs[cfg_log->new_id].awb_meas_config; + if (flag == _GET_) { - memcpy(arg, - &isp_dev->meas_cfgs.curr->awb_meas_config, - sizeof(*arg)); + memcpy(arg, curr_cfg, sizeof(*arg)); + goto end; + } + + if (CIFISP_MODULE_IS_UNACTIVE(isp_dev->meas_cfgs.module_actives, + CIFISP_MODULE_AWB)) { + CIFISP_DPRINT(CIFISP_ERROR, + "module is unactive in function: %s\n", __func__); goto end; } cifisp_param_dump(arg, CIFISP_MODULE_AWB); - if (memcmp(arg, - &isp_dev->meas_cfgs.curr->awb_meas_config, - sizeof(*arg)) == 0) { + if (CIFISP_MODULE_IS_EN( + isp_dev->meas_cfgs.cfgs[cfg_log->curr_id].module_ens, + CIFISP_MODULE_AWB) && + memcmp(arg, curr_cfg, sizeof(*arg)) == 0) { CIFISP_DPRINT(CIFISP_DEBUG, "same param in function: %s\n", __func__); goto end; @@ -903,9 +1034,9 @@ static int cifisp_awb_meas_param(struct cif_isp10_isp_dev *isp_dev, goto end; } - memcpy(&isp_dev->meas_cfgs.last_or_new->awb_meas_config, - arg, - sizeof(struct cifisp_awb_meas_config)); + memcpy(new_cfg, + arg, + sizeof(struct cifisp_awb_meas_config)); CIFISP_MODULE_UPDATE( isp_dev->meas_cfgs.module_updates, CIFISP_MODULE_AWB); @@ -919,6 +1050,8 @@ static int cifisp_awb_gain_param(struct cif_isp10_isp_dev *isp_dev, bool flag, struct cifisp_awb_gain_config *arg) { unsigned long lock_flags = 0; + struct cif_isp10_isp_cfgs_log *cfg_log; + struct cifisp_awb_gain_config *curr_cfg, *new_cfg; int retval = 0; if (!arg) @@ -926,18 +1059,28 @@ static int cifisp_awb_gain_param(struct cif_isp10_isp_dev *isp_dev, spin_lock_irqsave(&isp_dev->config_lock, lock_flags); + cfg_log = &isp_dev->other_cfgs.log[CIFISP_AWB_GAIN_ID]; + curr_cfg = &isp_dev->other_cfgs.cfgs[cfg_log->curr_id].awb_gain_config; + new_cfg = &isp_dev->other_cfgs.cfgs[cfg_log->new_id].awb_gain_config; + if (flag == _GET_) { - memcpy(arg, - &isp_dev->other_cfgs.curr->awb_gain_config, - sizeof(*arg)); + memcpy(arg, curr_cfg, sizeof(*arg)); + goto end; + } + + if (CIFISP_MODULE_IS_UNACTIVE(isp_dev->other_cfgs.module_actives, + CIFISP_MODULE_AWB_GAIN)) { + CIFISP_DPRINT(CIFISP_ERROR, + "module is unactive in function: %s\n", __func__); goto end; } cifisp_param_dump(arg, CIFISP_MODULE_AWB_GAIN); - if (memcmp(arg, - &isp_dev->other_cfgs.curr->awb_gain_config, - sizeof(*arg)) == 0) { + if (CIFISP_MODULE_IS_EN( + isp_dev->other_cfgs.cfgs[cfg_log->curr_id].module_ens, + CIFISP_MODULE_AWB_GAIN) && + memcmp(arg, curr_cfg, sizeof(*arg)) == 0) { CIFISP_DPRINT(CIFISP_DEBUG, "same param in function: %s\n", __func__); goto end; @@ -953,9 +1096,9 @@ static int cifisp_awb_gain_param(struct cif_isp10_isp_dev *isp_dev, goto end; } - memcpy(&isp_dev->other_cfgs.last_or_new->awb_gain_config, - arg, - sizeof(struct cifisp_awb_gain_config)); + memcpy(new_cfg, + arg, + sizeof(struct cifisp_awb_gain_config)); CIFISP_MODULE_UPDATE( isp_dev->other_cfgs.module_updates, CIFISP_MODULE_AWB_GAIN); @@ -969,6 +1112,8 @@ static int cifisp_aec_param(struct cif_isp10_isp_dev *isp_dev, bool flag, struct cifisp_aec_config *arg) { unsigned long lock_flags = 0; + struct cif_isp10_isp_cfgs_log *cfg_log; + struct cifisp_aec_config *curr_cfg, *new_cfg; int retval = 0; if (!arg) @@ -976,39 +1121,36 @@ static int cifisp_aec_param(struct cif_isp10_isp_dev *isp_dev, spin_lock_irqsave(&isp_dev->config_lock, lock_flags); + cfg_log = &isp_dev->meas_cfgs.log[CIFISP_AEC_ID]; + curr_cfg = &isp_dev->meas_cfgs.cfgs[cfg_log->curr_id].aec_config; + new_cfg = &isp_dev->meas_cfgs.cfgs[cfg_log->new_id].aec_config; + if (flag == _GET_) { - memcpy(arg, - &isp_dev->meas_cfgs.curr->aec_config, - sizeof(*arg)); + memcpy(arg, curr_cfg, sizeof(*arg)); + goto end; + } + + if (CIFISP_MODULE_IS_UNACTIVE(isp_dev->meas_cfgs.module_actives, + CIFISP_MODULE_AEC)) { + CIFISP_DPRINT(CIFISP_ERROR, + "module is unactive in function: %s\n", __func__); goto end; } cifisp_param_dump(arg, CIFISP_MODULE_AEC); - if (memcmp(arg, - &isp_dev->meas_cfgs.curr->aec_config, - sizeof(*arg)) == 0) { + if (CIFISP_MODULE_IS_EN( + isp_dev->meas_cfgs.cfgs[cfg_log->curr_id].module_ens, + CIFISP_MODULE_AEC) && + memcmp(arg, curr_cfg, sizeof(*arg)) == 0) { CIFISP_DPRINT(CIFISP_DEBUG, "same param in function: %s\n", __func__); goto end; } - if (arg->meas_window.h_offs > CIFISP_EXP_MAX_HOFFS || - arg->meas_window.h_size > CIFISP_EXP_MAX_HSIZE || - arg->meas_window.h_size < CIFISP_EXP_MIN_HSIZE || - arg->meas_window.v_offs > CIFISP_EXP_MAX_VOFFS || - arg->meas_window.v_size > CIFISP_EXP_MAX_VSIZE || - arg->meas_window.v_size < CIFISP_EXP_MIN_VSIZE || - arg->mode > CIFISP_EXP_MEASURING_MODE_1) { - CIFISP_DPRINT(CIFISP_ERROR, - "incompatible param in function: %s\n", __func__); - retval = -EINVAL; - goto end; - } - - memcpy(&isp_dev->meas_cfgs.last_or_new->aec_config, - arg, - sizeof(struct cifisp_aec_config)); + memcpy(new_cfg, + arg, + sizeof(struct cifisp_aec_config)); CIFISP_MODULE_UPDATE( isp_dev->meas_cfgs.module_updates, CIFISP_MODULE_AEC); @@ -1022,6 +1164,8 @@ static int cifisp_cproc_param(struct cif_isp10_isp_dev *isp_dev, bool flag, struct cifisp_cproc_config *arg) { unsigned long lock_flags = 0; + struct cif_isp10_isp_cfgs_log *cfg_log; + struct cifisp_cproc_config *curr_cfg, *new_cfg; int retval = 0; if (!arg) @@ -1029,18 +1173,28 @@ static int cifisp_cproc_param(struct cif_isp10_isp_dev *isp_dev, spin_lock_irqsave(&isp_dev->config_lock, lock_flags); + cfg_log = &isp_dev->other_cfgs.log[CIFISP_CPROC_ID]; + curr_cfg = &isp_dev->other_cfgs.cfgs[cfg_log->curr_id].cproc_config; + new_cfg = &isp_dev->other_cfgs.cfgs[cfg_log->new_id].cproc_config; + if (flag == _GET_) { - memcpy(arg, - &isp_dev->other_cfgs.curr->cproc_config, - sizeof(*arg)); + memcpy(arg, curr_cfg, sizeof(*arg)); + goto end; + } + + if (CIFISP_MODULE_IS_UNACTIVE(isp_dev->other_cfgs.module_actives, + CIFISP_MODULE_CPROC)) { + CIFISP_DPRINT(CIFISP_ERROR, + "module is unactive in function: %s\n", __func__); goto end; } cifisp_param_dump(arg, CIFISP_MODULE_CPROC); - if (memcmp(arg, - &isp_dev->other_cfgs.curr->cproc_config, - sizeof(*arg)) == 0) { + if (CIFISP_MODULE_IS_EN( + isp_dev->other_cfgs.cfgs[cfg_log->curr_id].module_ens, + CIFISP_MODULE_CPROC) && + memcmp(arg, curr_cfg, sizeof(*arg)) == 0) { CIFISP_DPRINT(CIFISP_DEBUG, "same param in function: %s\n", __func__); goto end; @@ -1059,9 +1213,9 @@ static int cifisp_cproc_param(struct cif_isp10_isp_dev *isp_dev, goto end; } - memcpy(&isp_dev->other_cfgs.last_or_new->cproc_config, - arg, - sizeof(struct cifisp_cproc_config)); + memcpy(new_cfg, + arg, + sizeof(struct cifisp_cproc_config)); CIFISP_MODULE_UPDATE( isp_dev->other_cfgs.module_updates, CIFISP_MODULE_CPROC); @@ -1076,6 +1230,8 @@ static int cifisp_hst_param(struct cif_isp10_isp_dev *isp_dev, { unsigned long lock_flags = 0; unsigned int i; + struct cif_isp10_isp_cfgs_log *cfg_log; + struct cifisp_hst_config *curr_cfg, *new_cfg; int retval = 0; if (!arg) @@ -1083,32 +1239,42 @@ static int cifisp_hst_param(struct cif_isp10_isp_dev *isp_dev, spin_lock_irqsave(&isp_dev->config_lock, lock_flags); + cfg_log = &isp_dev->meas_cfgs.log[CIFISP_HST_ID]; + curr_cfg = &isp_dev->meas_cfgs.cfgs[cfg_log->curr_id].hst_config; + new_cfg = &isp_dev->meas_cfgs.cfgs[cfg_log->new_id].hst_config; + if (flag == _GET_) { - memcpy(arg, - &isp_dev->meas_cfgs.curr->hst_config, - sizeof(*arg)); + memcpy(arg, curr_cfg, sizeof(*arg)); goto end; } - if (memcmp(arg, - &isp_dev->meas_cfgs.curr->hst_config, - sizeof(*arg)) == 0) { + if (CIFISP_MODULE_IS_UNACTIVE(isp_dev->meas_cfgs.module_actives, + CIFISP_MODULE_HST)) { + CIFISP_DPRINT(CIFISP_ERROR, + "module is unactive in function: %s\n", __func__); + goto end; + } + + if (CIFISP_MODULE_IS_EN( + isp_dev->meas_cfgs.cfgs[cfg_log->curr_id].module_ens, + CIFISP_MODULE_HST) && + memcmp(arg, curr_cfg, sizeof(*arg)) == 0) { CIFISP_DPRINT(CIFISP_DEBUG, "same param in function: %s\n", __func__); goto end; } if (arg->mode > CIFISP_HISTOGRAM_MODE_Y_HISTOGRAM || - arg->histogram_predivider > CIFISP_MAX_HIST_PREDIVIDER || - arg->meas_window.v_offs & CIFISP_HIST_WINDOW_OFFSET_RESERVED || - arg->meas_window.h_offs & CIFISP_HIST_WINDOW_OFFSET_RESERVED || - (arg->meas_window.v_size / (CIFISP_HIST_ROW_NUM - 1)) & - CIFISP_HIST_WINDOW_SIZE_RESERVED || - (arg->meas_window.h_size / (CIFISP_HIST_COLUMN_NUM - 1)) & - CIFISP_HIST_WINDOW_SIZE_RESERVED) { + arg->histogram_predivider > CIFISP_MAX_HIST_PREDIVIDER || + arg->meas_window.v_offs & CIFISP_HIST_WINDOW_OFFSET_RESERVED || + arg->meas_window.h_offs & CIFISP_HIST_WINDOW_OFFSET_RESERVED || + (arg->meas_window.v_size / (CIFISP_HIST_ROW_NUM - 1)) & + CIFISP_HIST_WINDOW_SIZE_RESERVED || + (arg->meas_window.h_size / (CIFISP_HIST_COLUMN_NUM - 1)) & + CIFISP_HIST_WINDOW_SIZE_RESERVED) { CIFISP_DPRINT(CIFISP_ERROR, - "incompatible param in function: %s line: %d\n", - __func__, __LINE__); + "incompatible param in function: %s line: %d\n", + __func__, __LINE__); retval = -EINVAL; goto end; } @@ -1116,16 +1282,16 @@ static int cifisp_hst_param(struct cif_isp10_isp_dev *isp_dev, for (i = 0; i < CIFISP_HISTOGRAM_WEIGHT_GRIDS_SIZE; i++) { if (arg->hist_weight[i] & CIFISP_HIST_WEIGHT_RESERVED) { CIFISP_DPRINT(CIFISP_ERROR, - "incompatible param in function: %s line: %d\n", - __func__, __LINE__); + "incompatible param in function: %s line: %d\n", + __func__, __LINE__); retval = -EINVAL; goto end; } } - memcpy(&isp_dev->meas_cfgs.last_or_new->hst_config, - arg, - sizeof(struct cifisp_hst_config)); + memcpy(new_cfg, + arg, + sizeof(struct cifisp_hst_config)); CIFISP_MODULE_UPDATE( isp_dev->meas_cfgs.module_updates, CIFISP_MODULE_HST); @@ -1140,6 +1306,8 @@ static int cifisp_afc_param(struct cif_isp10_isp_dev *isp_dev, { unsigned long lock_flags = 0; int i; + struct cif_isp10_isp_cfgs_log *cfg_log; + struct cifisp_afc_config *curr_cfg, *new_cfg; int retval = 0; if (!arg) @@ -1147,18 +1315,28 @@ static int cifisp_afc_param(struct cif_isp10_isp_dev *isp_dev, spin_lock_irqsave(&isp_dev->config_lock, lock_flags); + cfg_log = &isp_dev->meas_cfgs.log[CIFISP_AFC_ID]; + curr_cfg = &isp_dev->meas_cfgs.cfgs[cfg_log->curr_id].afc_config; + new_cfg = &isp_dev->meas_cfgs.cfgs[cfg_log->new_id].afc_config; + if (flag == _GET_) { - memcpy(arg, - &isp_dev->meas_cfgs.curr->afc_config, - sizeof(*arg)); + memcpy(arg, curr_cfg, sizeof(*arg)); + goto end; + } + + if (CIFISP_MODULE_IS_UNACTIVE(isp_dev->meas_cfgs.module_actives, + CIFISP_MODULE_AFC)) { + CIFISP_DPRINT(CIFISP_ERROR, + "module is unactive in function: %s\n", __func__); goto end; } cifisp_param_dump(arg, CIFISP_MODULE_AFC); - if (memcmp(arg, - &isp_dev->meas_cfgs.curr->afc_config, - sizeof(*arg)) == 0) { + if (CIFISP_MODULE_IS_EN( + isp_dev->meas_cfgs.cfgs[cfg_log->curr_id].module_ens, + CIFISP_MODULE_AFC) && + memcmp(arg, curr_cfg, sizeof(*arg)) == 0) { CIFISP_DPRINT(CIFISP_DEBUG, "same param in function: %s\n", __func__); goto end; @@ -1188,9 +1366,9 @@ static int cifisp_afc_param(struct cif_isp10_isp_dev *isp_dev, } } - memcpy(&isp_dev->meas_cfgs.last_or_new->afc_config, - arg, - sizeof(struct cifisp_afc_config)); + memcpy(new_cfg, + arg, + sizeof(struct cifisp_afc_config)); CIFISP_MODULE_UPDATE( isp_dev->meas_cfgs.module_updates, CIFISP_MODULE_AFC); @@ -1201,9 +1379,11 @@ static int cifisp_afc_param(struct cif_isp10_isp_dev *isp_dev, } static int cifisp_ie_param(struct cif_isp10_isp_dev *isp_dev, - bool flag, struct cifisp_ie_config *arg) + bool flag, struct cifisp_ie_config *arg) { unsigned long lock_flags = 0; + struct cif_isp10_isp_cfgs_log *cfg_log; + struct cifisp_ie_config *curr_cfg, *new_cfg; int retval = 0; if (!arg) @@ -1211,40 +1391,50 @@ static int cifisp_ie_param(struct cif_isp10_isp_dev *isp_dev, spin_lock_irqsave(&isp_dev->config_lock, lock_flags); + cfg_log = &isp_dev->other_cfgs.log[CIFISP_IE_ID]; + curr_cfg = &isp_dev->other_cfgs.cfgs[cfg_log->curr_id].ie_config; + new_cfg = &isp_dev->other_cfgs.cfgs[cfg_log->new_id].ie_config; + if (flag == _GET_) { - memcpy(arg, - &isp_dev->other_cfgs.curr->ie_config, - sizeof(*arg)); + memcpy(arg, curr_cfg, sizeof(*arg)); + goto end; + } + + if (CIFISP_MODULE_IS_UNACTIVE(isp_dev->other_cfgs.module_actives, + CIFISP_MODULE_IE)) { + CIFISP_DPRINT(CIFISP_ERROR, + "module is unactive in function: %s\n", __func__); goto end; } cifisp_param_dump(arg, CIFISP_MODULE_IE); - if (memcmp(arg, - &isp_dev->other_cfgs.curr->ie_config, - sizeof(*arg)) == 0) { + if (CIFISP_MODULE_IS_EN( + isp_dev->other_cfgs.cfgs[cfg_log->curr_id].module_ens, + CIFISP_MODULE_IE) && + memcmp(arg, curr_cfg, sizeof(*arg)) == 0) { CIFISP_DPRINT(CIFISP_DEBUG, "same param in function: %s\n", __func__); goto end; } if (arg->effect != V4L2_COLORFX_NONE && - arg->effect != V4L2_COLORFX_BW && - arg->effect != V4L2_COLORFX_SEPIA && - arg->effect != V4L2_COLORFX_NEGATIVE && - arg->effect != V4L2_COLORFX_EMBOSS && - arg->effect != V4L2_COLORFX_SKETCH && - arg->effect != V4L2_COLORFX_AQUA && - arg->effect != V4L2_COLORFX_SET_CBCR) { + arg->effect != V4L2_COLORFX_BW && + arg->effect != V4L2_COLORFX_SEPIA && + arg->effect != V4L2_COLORFX_NEGATIVE && + arg->effect != V4L2_COLORFX_EMBOSS && + arg->effect != V4L2_COLORFX_SKETCH && + arg->effect != V4L2_COLORFX_AQUA && + arg->effect != V4L2_COLORFX_SET_CBCR) { CIFISP_DPRINT(CIFISP_ERROR, "incompatible param in function: %s\n", __func__); retval = -EINVAL; goto end; } - memcpy(&isp_dev->other_cfgs.last_or_new->ie_config, - arg, - sizeof(struct cifisp_ie_config)); + memcpy(new_cfg, + arg, + sizeof(struct cifisp_ie_config)); CIFISP_MODULE_UPDATE( isp_dev->other_cfgs.module_updates, CIFISP_MODULE_IE); @@ -1260,6 +1450,8 @@ static int cifisp_dpf_param(struct cif_isp10_isp_dev *isp_dev, { unsigned long lock_flags = 0; unsigned int i; + struct cif_isp10_isp_cfgs_log *cfg_log; + struct cifisp_dpf_config *curr_cfg, *new_cfg; int retval = 0; if (!arg) @@ -1267,18 +1459,28 @@ static int cifisp_dpf_param(struct cif_isp10_isp_dev *isp_dev, spin_lock_irqsave(&isp_dev->config_lock, lock_flags); + cfg_log = &isp_dev->other_cfgs.log[CIFISP_DPF_ID]; + curr_cfg = &isp_dev->other_cfgs.cfgs[cfg_log->curr_id].dpf_config; + new_cfg = &isp_dev->other_cfgs.cfgs[cfg_log->new_id].dpf_config; + if (flag == _GET_) { - memcpy(arg, - &isp_dev->other_cfgs.curr->dpf_config, - sizeof(*arg)); + memcpy(arg, curr_cfg, sizeof(*arg)); + goto end; + } + + if (CIFISP_MODULE_IS_UNACTIVE(isp_dev->other_cfgs.module_actives, + CIFISP_MODULE_DPF)) { + CIFISP_DPRINT(CIFISP_ERROR, + "module is unactive in function: %s\n", __func__); goto end; } cifisp_param_dump(arg, CIFISP_MODULE_DPF); - if (memcmp(arg, - &isp_dev->other_cfgs.curr->dpf_config, - sizeof(*arg)) == 0) { + if (CIFISP_MODULE_IS_EN( + isp_dev->other_cfgs.cfgs[cfg_log->curr_id].module_ens, + CIFISP_MODULE_DPF) && + memcmp(arg, curr_cfg, sizeof(*arg)) == 0) { CIFISP_DPRINT(CIFISP_DEBUG, "same param in function: %s\n", __func__); goto end; @@ -1286,24 +1488,24 @@ static int cifisp_dpf_param(struct cif_isp10_isp_dev *isp_dev, /* Parameter check */ if ((arg->gain.mode >= CIFISP_DPF_GAIN_USAGE_MAX) || - (arg->gain.mode < CIFISP_DPF_GAIN_USAGE_DISABLED) || - (arg->gain.nf_b_gain & CIFISP_DPF_NF_GAIN_RESERVED) || - (arg->gain.nf_r_gain & CIFISP_DPF_NF_GAIN_RESERVED) || - (arg->gain.nf_gr_gain & CIFISP_DPF_NF_GAIN_RESERVED) || - (arg->gain.nf_gb_gain & CIFISP_DPF_NF_GAIN_RESERVED)) { + (arg->gain.mode < CIFISP_DPF_GAIN_USAGE_DISABLED) || + (arg->gain.nf_b_gain & CIFISP_DPF_NF_GAIN_RESERVED) || + (arg->gain.nf_r_gain & CIFISP_DPF_NF_GAIN_RESERVED) || + (arg->gain.nf_gr_gain & CIFISP_DPF_NF_GAIN_RESERVED) || + (arg->gain.nf_gb_gain & CIFISP_DPF_NF_GAIN_RESERVED)) { CIFISP_DPRINT(CIFISP_ERROR, - "incompatible DPF GAIN param in function: %s\n", - __func__); + "incompatible DPF GAIN param in function: %s\n", + __func__); retval = -EINVAL; goto end; } for (i = 0; i < CIFISP_DPF_MAX_SPATIAL_COEFFS; i++) { if ((arg->g_flt.spatial_coeff[i] > - CIFISP_DPF_SPATIAL_COEFF_MAX)) { + CIFISP_DPF_SPATIAL_COEFF_MAX)) { CIFISP_DPRINT(CIFISP_ERROR, - "incompatible DPF G Spatial param in function: %s\n", - __func__); + "incompatible DPF G Spatial param in function: %s\n", + __func__); retval = -EINVAL; goto end; } @@ -1311,15 +1513,15 @@ static int cifisp_dpf_param(struct cif_isp10_isp_dev *isp_dev, if (arg->rb_flt.spatial_coeff[i] > CIFISP_DPF_SPATIAL_COEFF_MAX) { CIFISP_DPRINT(CIFISP_ERROR, - "incompatible DPF RB Spatial param in function: %s\n", - __func__); + "incompatible DPF RB Spatial param in function: %s\n", + __func__); retval = -EINVAL; goto end; } } if ((arg->rb_flt.fltsize != CIFISP_DPF_RB_FILTERSIZE_9x9) && - (arg->rb_flt.fltsize != CIFISP_DPF_RB_FILTERSIZE_13x9)) { + (arg->rb_flt.fltsize != CIFISP_DPF_RB_FILTERSIZE_13x9)) { CIFISP_DPRINT(CIFISP_ERROR, "incompatible DPF RB filter size param in function: %s\n", __func__); @@ -1338,7 +1540,7 @@ static int cifisp_dpf_param(struct cif_isp10_isp_dev *isp_dev, } if ((arg->nll.scale_mode != CIFISP_NLL_SCALE_LINEAR) && - (arg->nll.scale_mode != CIFISP_NLL_SCALE_LOGARITHMIC)) { + (arg->nll.scale_mode != CIFISP_NLL_SCALE_LOGARITHMIC)) { CIFISP_DPRINT(CIFISP_ERROR, "incompatible DPF NLL scale mode param in function: %s\n", __func__); @@ -1346,9 +1548,9 @@ static int cifisp_dpf_param(struct cif_isp10_isp_dev *isp_dev, goto end; } - memcpy(&isp_dev->other_cfgs.last_or_new->dpf_config, - arg, - sizeof(struct cifisp_dpf_config)); + memcpy(new_cfg, + arg, + sizeof(struct cifisp_dpf_config)); CIFISP_MODULE_UPDATE( isp_dev->other_cfgs.module_updates, CIFISP_MODULE_DPF); @@ -1359,9 +1561,11 @@ static int cifisp_dpf_param(struct cif_isp10_isp_dev *isp_dev, } static int cifisp_dpf_strength_param(struct cif_isp10_isp_dev *isp_dev, - bool flag, struct cifisp_dpf_strength_config *arg) + bool flag, struct cifisp_dpf_strength_config *arg) { unsigned long lock_flags = 0; + struct cif_isp10_isp_cfgs_log *cfg_log; + struct cifisp_dpf_strength_config *curr_cfg, *new_cfg; int retval = 0; if (!arg) @@ -1369,26 +1573,36 @@ static int cifisp_dpf_strength_param(struct cif_isp10_isp_dev *isp_dev, spin_lock_irqsave(&isp_dev->config_lock, lock_flags); + cfg_log = &isp_dev->other_cfgs.log[CIFISP_DPF_STRENGTH_ID]; + curr_cfg = &isp_dev->other_cfgs.cfgs[cfg_log->curr_id].dpf_strength_config; + new_cfg = &isp_dev->other_cfgs.cfgs[cfg_log->new_id].dpf_strength_config; + if (flag == _GET_) { - memcpy(arg, - &isp_dev->other_cfgs.curr->dpf_strength_config, - sizeof(*arg)); + memcpy(arg, curr_cfg, sizeof(*arg)); + goto end; + } + + if (CIFISP_MODULE_IS_UNACTIVE(isp_dev->other_cfgs.module_actives, + CIFISP_MODULE_DPF_STRENGTH)) { + CIFISP_DPRINT(CIFISP_ERROR, + "module is unactive in function: %s\n", __func__); goto end; } cifisp_param_dump(arg, CIFISP_MODULE_DPF_STRENGTH); - if (memcmp(arg, - &isp_dev->other_cfgs.curr->dpf_strength_config, - sizeof(*arg)) == 0) { + if (CIFISP_MODULE_IS_EN( + isp_dev->other_cfgs.cfgs[cfg_log->curr_id].module_ens, + CIFISP_MODULE_DPF_STRENGTH) && + memcmp(arg, curr_cfg, sizeof(*arg)) == 0) { CIFISP_DPRINT(CIFISP_DEBUG, "same param in function: %s\n", __func__); goto end; } - memcpy(&isp_dev->other_cfgs.last_or_new->dpf_strength_config, - arg, - sizeof(struct cifisp_dpf_strength_config)); + memcpy(new_cfg, + arg, + sizeof(struct cifisp_dpf_strength_config)); CIFISP_MODULE_UPDATE( isp_dev->other_cfgs.module_updates, CIFISP_MODULE_DPF_STRENGTH); @@ -1415,31 +1629,33 @@ static int cifisp_last_capture_config(struct cifisp_last_capture_config *arg) /* DPCC */ static void cifisp_dpcc_config(const struct cif_isp10_isp_dev *isp_dev) { - const struct cifisp_dpcc_config *pconfig = - &isp_dev->other_cfgs.last_or_new->dpcc_config; unsigned int i; + unsigned int new_id = + isp_dev->other_cfgs.log[CIFISP_DPCC_ID].new_id; + const struct cifisp_dpcc_config *pconfig = + &isp_dev->other_cfgs.cfgs[new_id].dpcc_config; cifisp_iowrite32(pconfig->mode, CIF_ISP_DPCC_MODE); cifisp_iowrite32(pconfig->output_mode, CIF_ISP_DPCC_OUTPUT_MODE); cifisp_iowrite32(pconfig->set_use, CIF_ISP_DPCC_SET_USE); cifisp_iowrite32(pconfig->methods[0].method, - CIF_ISP_DPCC_METHODS_SET_1); + CIF_ISP_DPCC_METHODS_SET_1); cifisp_iowrite32(pconfig->methods[1].method, - CIF_ISP_DPCC_METHODS_SET_2); + CIF_ISP_DPCC_METHODS_SET_2); cifisp_iowrite32(pconfig->methods[2].method, - CIF_ISP_DPCC_METHODS_SET_3); + CIF_ISP_DPCC_METHODS_SET_3); for (i = 0; i < CIFISP_DPCC_METHODS_MAX; i++) { cifisp_iowrite32(pconfig->methods[i].line_thresh, - CIF_ISP_DPCC_LINE_THRESH_1 + 0x14 * i); + CIF_ISP_DPCC_LINE_THRESH_1 + 0x14 * i); cifisp_iowrite32(pconfig->methods[i].line_mad_fac, - CIF_ISP_DPCC_LINE_MAD_FAC_1 + 0x14 * i); + CIF_ISP_DPCC_LINE_MAD_FAC_1 + 0x14 * i); cifisp_iowrite32(pconfig->methods[i].pg_fac, - CIF_ISP_DPCC_PG_FAC_1 + 0x14 * i); + CIF_ISP_DPCC_PG_FAC_1 + 0x14 * i); cifisp_iowrite32(pconfig->methods[i].rnd_thresh, - CIF_ISP_DPCC_RND_THRESH_1 + 0x14 * i); + CIF_ISP_DPCC_RND_THRESH_1 + 0x14 * i); cifisp_iowrite32(pconfig->methods[i].rg_fac, - CIF_ISP_DPCC_RG_FAC_1 + 0x14 * i); + CIF_ISP_DPCC_RG_FAC_1 + 0x14 * i); } cifisp_iowrite32(pconfig->rnd_offs, CIF_ISP_DPCC_RND_OFFS); @@ -1469,8 +1685,10 @@ static bool cifisp_lsc_correct_matrix_config(struct cif_isp10_isp_dev *isp_dev) int i, n; unsigned int isp_lsc_status, sram_addr, isp_lsc_table_sel; unsigned int data; - struct cifisp_lsc_config *pconfig = - &isp_dev->other_cfgs.last_or_new->lsc_config; + unsigned int new_id = + isp_dev->other_cfgs.log[CIFISP_LSC_ID].new_id; + const struct cifisp_lsc_config *pconfig = + &isp_dev->other_cfgs.cfgs[new_id].lsc_config; isp_lsc_status = cifisp_ioread32(CIF_ISP_LSC_STATUS); sram_addr = (isp_lsc_status & 0x2U) ? 0U : 153U; /* ( 17 * 18 ) >> 1 */ @@ -1489,7 +1707,8 @@ static bool cifisp_lsc_correct_matrix_config(struct cif_isp10_isp_dev *isp_dev) * DWORDs (8 steps + 1 outside loop) */ for (i = 0; i < (CIFISP_LSC_SECTORS_MAX); i += 2) { - data = CIFISP_LSC_TABLE_DATA(pconfig->r_data_tbl[n + i], + data = CIFISP_LSC_TABLE_DATA( + pconfig->r_data_tbl[n + i], pconfig->r_data_tbl[n + i + 1]); cifisp_iowrite32(data, CIF_ISP_LSC_R_TABLE_DATA); @@ -1503,7 +1722,8 @@ static bool cifisp_lsc_correct_matrix_config(struct cif_isp10_isp_dev *isp_dev) pconfig->gb_data_tbl[n + i + 1]); cifisp_iowrite32(data, CIF_ISP_LSC_GB_TABLE_DATA); - data = CIFISP_LSC_TABLE_DATA(pconfig->b_data_tbl[n + i], + data = CIFISP_LSC_TABLE_DATA( + pconfig->b_data_tbl[n + i], pconfig->b_data_tbl[n + i + 1]); cifisp_iowrite32(data, CIF_ISP_LSC_B_TABLE_DATA); } @@ -1539,11 +1759,13 @@ static bool cifisp_lsc_config(struct cif_isp10_isp_dev *isp_dev) { int i; unsigned int data; - struct cifisp_lsc_config *pconfig = - &isp_dev->other_cfgs.last_or_new->lsc_config; + unsigned int new_id = + isp_dev->other_cfgs.log[CIFISP_LSC_ID].new_id; + const struct cifisp_lsc_config *pconfig = + &isp_dev->other_cfgs.cfgs[new_id].lsc_config; if (pconfig->config_width != isp_dev->input_width || - pconfig->config_height != isp_dev->input_height) { + pconfig->config_height != isp_dev->input_height) { CIFISP_DPRINT(CIFISP_DEBUG, "LSC config: lsc_w %d lsc_h %d act_w %d act_h %d\n", pconfig->config_width, @@ -1554,49 +1776,44 @@ static bool cifisp_lsc_config(struct cif_isp10_isp_dev *isp_dev) } CIFISP_DPRINT(CIFISP_DEBUG, - "LSC config: lsc_w %d lsc_h %d\n", - pconfig->config_width, - pconfig->config_height); + "LSC config: lsc_w %d lsc_h %d\n", + pconfig->config_width, + pconfig->config_height); /* To config must be off */ cifisp_iowrite32(0, CIF_ISP_LSC_CTRL); cifisp_lsc_correct_matrix_config(isp_dev); - if (isp_dev->active_lsc_width != - pconfig->config_width || - isp_dev->active_lsc_height != - pconfig->config_height) { - for (i = 0; i < 4; i++) { - /* program x size tables */ - data = CIFISP_LSC_SECT_SIZE( - pconfig->x_size_tbl[i * 2], - pconfig->x_size_tbl[i * 2 + 1]); - cifisp_iowrite32(data, CIF_ISP_LSC_XSIZE_01 + i * 4); + for (i = 0; i < 4; i++) { + /* program x size tables */ + data = CIFISP_LSC_SECT_SIZE( + pconfig->x_size_tbl[i*2], + pconfig->x_size_tbl[i*2 + 1]); + cifisp_iowrite32(data, CIF_ISP_LSC_XSIZE_01 + i * 4); - /* program x grad tables */ - data = CIFISP_LSC_SECT_SIZE( - pconfig->x_grad_tbl[i * 2], - pconfig->x_grad_tbl[i * 2 + 1]); - cifisp_iowrite32(data, CIF_ISP_LSC_XGRAD_01 + i * 4); + /* program x grad tables */ + data = CIFISP_LSC_SECT_SIZE( + pconfig->x_grad_tbl[i*2], + pconfig->x_grad_tbl[i*2 + 1]); + cifisp_iowrite32(data, CIF_ISP_LSC_XGRAD_01 + i * 4); - /* program y size tables */ - data = CIFISP_LSC_SECT_SIZE( - pconfig->y_size_tbl[i * 2], - pconfig->y_size_tbl[i * 2 + 1]); - cifisp_iowrite32(data, CIF_ISP_LSC_YSIZE_01 + i * 4); + /* program y size tables */ + data = CIFISP_LSC_SECT_SIZE( + pconfig->y_size_tbl[i*2], + pconfig->y_size_tbl[i*2 + 1]); + cifisp_iowrite32(data, CIF_ISP_LSC_YSIZE_01 + i * 4); - /* program y grad tables */ - data = CIFISP_LSC_SECT_SIZE( - pconfig->y_grad_tbl[i * 2], - pconfig->y_grad_tbl[i * 2 + 1]); - cifisp_iowrite32(data, CIF_ISP_LSC_YGRAD_01 + i * 4); - } - - isp_dev->active_lsc_width = pconfig->config_width; - isp_dev->active_lsc_height = pconfig->config_height; + /* program y grad tables */ + data = CIFISP_LSC_SECT_SIZE( + pconfig->y_grad_tbl[i*2], + pconfig->y_grad_tbl[i*2 + 1]); + cifisp_iowrite32(data, CIF_ISP_LSC_YGRAD_01 + i * 4); } + isp_dev->active_lsc_width = pconfig->config_width; + isp_dev->active_lsc_height = pconfig->config_height; + cifisp_iowrite32(1, CIF_ISP_LSC_CTRL); return true; @@ -1612,7 +1829,7 @@ static void cifisp_lsc_config_read(const struct cif_isp10_isp_dev *isp_dev, /*****************************************************************************/ static void cifisp_bls_get_meas(const struct cif_isp10_isp_dev *isp_dev, - struct cifisp_stat_buffer *pbuf) + struct cifisp_stat_buffer *pbuf) { const struct cif_isp10_device *cif_dev = container_of(isp_dev, struct cif_isp10_device, isp_dev); @@ -1661,8 +1878,10 @@ static void cifisp_bls_get_meas(const struct cif_isp10_isp_dev *isp_dev, /*****************************************************************************/ static void cifisp_bls_config(const struct cif_isp10_isp_dev *isp_dev) { + unsigned int new_id = + isp_dev->other_cfgs.log[CIFISP_BLS_ID].new_id; const struct cifisp_bls_config *pconfig = - &isp_dev->other_cfgs.last_or_new->bls_config; + &isp_dev->other_cfgs.cfgs[new_id].bls_config; u32 new_control = 0; const struct cif_isp10_device *cif_dev = container_of(isp_dev, struct cif_isp10_device, isp_dev); @@ -1673,7 +1892,7 @@ static void cifisp_bls_config(const struct cif_isp10_isp_dev *isp_dev) /* fixed subtraction values */ if (!pconfig->enable_auto) { const struct cifisp_bls_fixed_val *pval = - &isp_dev->other_cfgs.last_or_new->bls_config.fixed_val; + &pconfig->fixed_val; if (CIF_ISP10_PIX_FMT_BAYER_PAT_IS_BGGR(in_pix_fmt)) { cifisp_iowrite32(pval->r, CIF_ISP_BLS_D_FIXED); @@ -1702,25 +1921,25 @@ static void cifisp_bls_config(const struct cif_isp10_isp_dev *isp_dev) } else { if (pconfig->en_windows & 2) { cifisp_iowrite32(pconfig->bls_window2.h_offs, - CIF_ISP_BLS_H2_START); + CIF_ISP_BLS_H2_START); cifisp_iowrite32(pconfig->bls_window2.h_size, - CIF_ISP_BLS_H2_STOP); + CIF_ISP_BLS_H2_STOP); cifisp_iowrite32(pconfig->bls_window2.v_offs, - CIF_ISP_BLS_V2_START); + CIF_ISP_BLS_V2_START); cifisp_iowrite32(pconfig->bls_window2.v_size, - CIF_ISP_BLS_V2_STOP); + CIF_ISP_BLS_V2_STOP); new_control |= CIFISP_BLS_WINDOW_2; } if (pconfig->en_windows & 1) { cifisp_iowrite32(pconfig->bls_window1.h_offs, - CIF_ISP_BLS_H1_START); + CIF_ISP_BLS_H1_START); cifisp_iowrite32(pconfig->bls_window1.h_size, - CIF_ISP_BLS_H1_STOP); + CIF_ISP_BLS_H1_STOP); cifisp_iowrite32(pconfig->bls_window1.v_offs, - CIF_ISP_BLS_V1_START); + CIF_ISP_BLS_V1_START); cifisp_iowrite32(pconfig->bls_window1.v_size, - CIF_ISP_BLS_V1_STOP); + CIF_ISP_BLS_V1_STOP); new_control |= CIFISP_BLS_WINDOW_1; } @@ -1748,8 +1967,10 @@ static void cifisp_bls_end(const struct cif_isp10_isp_dev *isp_dev) /*****************************************************************************/ static void cifisp_sdg_config(const struct cif_isp10_isp_dev *isp_dev) { + unsigned int new_id = + isp_dev->other_cfgs.log[CIFISP_SDG_ID].new_id; const struct cifisp_sdg_config *pconfig = - &isp_dev->other_cfgs.last_or_new->sdg_config; + &isp_dev->other_cfgs.cfgs[new_id].sdg_config; unsigned int i; cifisp_iowrite32(pconfig->xa_pnts.gamma_dx0, CIF_ISP_GAMMA_DX_LO); @@ -1757,11 +1978,11 @@ static void cifisp_sdg_config(const struct cif_isp10_isp_dev *isp_dev) for (i = 0; i < CIFISP_DEGAMMA_CURVE_SIZE; i++) { cifisp_iowrite32(pconfig->curve_r.gamma_y[i], - CIF_ISP_GAMMA_R_Y0 + i * 4); + CIF_ISP_GAMMA_R_Y0 + i * 4); cifisp_iowrite32(pconfig->curve_g.gamma_y[i], - CIF_ISP_GAMMA_G_Y0 + i * 4); + CIF_ISP_GAMMA_G_Y0 + i * 4); cifisp_iowrite32(pconfig->curve_b.gamma_y[i], - CIF_ISP_GAMMA_B_Y0 + i * 4); + CIF_ISP_GAMMA_B_Y0 + i * 4); } } @@ -1788,15 +2009,17 @@ static void cifisp_sdg_end(const struct cif_isp10_isp_dev *isp_dev) static void cifisp_goc_config(const struct cif_isp10_isp_dev *isp_dev) { int i; + unsigned int new_id = + isp_dev->other_cfgs.log[CIFISP_GOC_ID].new_id; const struct cifisp_goc_config *pconfig = - &isp_dev->other_cfgs.last_or_new->goc_config; + &isp_dev->other_cfgs.cfgs[new_id].goc_config; cifisp_iowrite32AND(~CIF_ISP_CTRL_ISP_GAMMA_OUT_ENA, CIF_ISP_CTRL); cifisp_iowrite32(pconfig->mode, CIF_ISP_GAMMA_OUT_MODE); for (i = 0; i < CIFISP_GAMMA_OUT_MAX_SAMPLES; i++) cifisp_iowrite32(pconfig->gamma_y[i], - CIF_ISP_GAMMA_OUT_Y_0 + i * 4); + CIF_ISP_GAMMA_OUT_Y_0 + i * 4); } #ifdef LOG_CAPTURE_PARAMS @@ -1821,8 +2044,10 @@ static void cifisp_goc_end(const struct cif_isp10_isp_dev *isp_dev) /*****************************************************************************/ static void cifisp_bdm_config(const struct cif_isp10_isp_dev *isp_dev) { + unsigned int new_id = + isp_dev->other_cfgs.log[CIFISP_BDM_ID].new_id; const struct cifisp_bdm_config *pconfig = - &isp_dev->other_cfgs.last_or_new->bdm_config; + &isp_dev->other_cfgs.cfgs[new_id].bdm_config; /*set demosaic threshold */ cifisp_iowrite32(pconfig->demosaic_th, CIF_ISP_DEMOSAIC); @@ -1843,29 +2068,31 @@ static void cifisp_bdm_end(const struct cif_isp10_isp_dev *isp_dev) /*****************************************************************************/ static void cifisp_flt_config(const struct cif_isp10_isp_dev *isp_dev) { + unsigned int new_id = + isp_dev->other_cfgs.log[CIFISP_FLT_ID].new_id; const struct cifisp_flt_config *pconfig = - &isp_dev->other_cfgs.last_or_new->flt_config; + &isp_dev->other_cfgs.cfgs[new_id].flt_config; cifisp_iowrite32(pconfig->thresh_bl0, - CIF_ISP_FILT_THRESH_BL0); + CIF_ISP_FILT_THRESH_BL0); cifisp_iowrite32(pconfig->thresh_bl1, - CIF_ISP_FILT_THRESH_BL1); + CIF_ISP_FILT_THRESH_BL1); cifisp_iowrite32(pconfig->thresh_sh0, - CIF_ISP_FILT_THRESH_SH0); + CIF_ISP_FILT_THRESH_SH0); cifisp_iowrite32(pconfig->thresh_sh1, - CIF_ISP_FILT_THRESH_SH1); + CIF_ISP_FILT_THRESH_SH1); cifisp_iowrite32(pconfig->fac_bl0, - CIF_ISP_FILT_FAC_BL0); + CIF_ISP_FILT_FAC_BL0); cifisp_iowrite32(pconfig->fac_bl1, - CIF_ISP_FILT_FAC_BL1); + CIF_ISP_FILT_FAC_BL1); cifisp_iowrite32(pconfig->fac_mid, - CIF_ISP_FILT_FAC_MID); + CIF_ISP_FILT_FAC_MID); cifisp_iowrite32(pconfig->fac_sh0, - CIF_ISP_FILT_FAC_SH0); + CIF_ISP_FILT_FAC_SH0); cifisp_iowrite32(pconfig->fac_sh1, - CIF_ISP_FILT_FAC_SH1); + CIF_ISP_FILT_FAC_SH1); cifisp_iowrite32(pconfig->lum_weight, - CIF_ISP_FILT_LUM_WEIGHT); + CIF_ISP_FILT_LUM_WEIGHT); cifisp_iowrite32(CIFISP_FLT_MODE(pconfig->mode) | CIFISP_FLT_CHROMA_V_MODE(pconfig->chr_v_mode) | @@ -1897,14 +2124,22 @@ static void cifisp_flt_end(const struct cif_isp10_isp_dev *isp_dev) /*****************************************************************************/ static void cifisp_awb_gain_config(const struct cif_isp10_isp_dev *isp_dev) { + unsigned int new_id = + isp_dev->other_cfgs.log[CIFISP_AWB_GAIN_ID].new_id; + unsigned int new_ens = + isp_dev->other_cfgs.cfgs[new_id].module_ens; const struct cifisp_awb_gain_config *pconfig = - &isp_dev->other_cfgs.last_or_new->awb_gain_config; + &isp_dev->other_cfgs.cfgs[new_id].awb_gain_config; - cifisp_iowrite32(CIFISP_AWB_GAIN_R_SET(pconfig->gain_green_r) | - pconfig->gain_green_b, CIF_ISP_AWB_GAIN_G); - - cifisp_iowrite32(CIFISP_AWB_GAIN_R_SET(pconfig->gain_red) | - pconfig->gain_blue, CIF_ISP_AWB_GAIN_RB); + if (CIFISP_MODULE_IS_EN(new_ens, CIFISP_MODULE_AWB_GAIN)) { + cifisp_iowrite32(CIFISP_AWB_GAIN_R_SET(pconfig->gain_green_r) | + pconfig->gain_green_b, CIF_ISP_AWB_GAIN_G); + cifisp_iowrite32(CIFISP_AWB_GAIN_R_SET(pconfig->gain_red) | + pconfig->gain_blue, CIF_ISP_AWB_GAIN_RB); + } else { + cifisp_iowrite32(0x01000100, CIF_ISP_AWB_GAIN_G); + cifisp_iowrite32(0x01000100, CIF_ISP_AWB_GAIN_RB); + } } #ifdef LOG_CAPTURE_PARAMS @@ -1924,8 +2159,10 @@ static void cifisp_awb_gain_config_read(const struct cif_isp10_isp_dev *isp_dev, /*****************************************************************************/ static void cifisp_awb_meas_config(const struct cif_isp10_isp_dev *isp_dev) { + unsigned int new_id = + isp_dev->meas_cfgs.log[CIFISP_AWB_ID].new_id; const struct cifisp_awb_meas_config *pconfig = - &isp_dev->meas_cfgs.last_or_new->awb_meas_config; + &isp_dev->meas_cfgs.cfgs[new_id].awb_meas_config; unsigned int awb_prob = 0; /* based on the mode,configure the awb module */ @@ -1949,9 +2186,9 @@ static void cifisp_awb_meas_config(const struct cif_isp10_isp_dev *isp_dev) cifisp_iowrite32(awb_prob, CIF_ISP_AWB_PROP); /* window offset */ cifisp_iowrite32(pconfig->awb_wnd.v_offs, - CIF_ISP_AWB_WND_V_OFFS); + CIF_ISP_AWB_WND_V_OFFS); cifisp_iowrite32(pconfig->awb_wnd.h_offs, - CIF_ISP_AWB_WND_H_OFFS); + CIF_ISP_AWB_WND_H_OFFS); /* AWB window size */ cifisp_iowrite32(pconfig->awb_wnd.v_size, CIF_ISP_AWB_WND_V_SIZE); cifisp_iowrite32(pconfig->awb_wnd.h_size, CIF_ISP_AWB_WND_H_SIZE); @@ -1969,8 +2206,10 @@ static void cifisp_awb_meas_config_read(const struct cif_isp10_isp_dev *isp_dev, /*****************************************************************************/ static void cifisp_awb_meas_en(struct cif_isp10_isp_dev *isp_dev) { + unsigned int new_id = + isp_dev->meas_cfgs.log[CIFISP_AWB_ID].new_id; const struct cifisp_awb_meas_config *pconfig = - &isp_dev->meas_cfgs.last_or_new->awb_meas_config; + &isp_dev->meas_cfgs.cfgs[new_id].awb_meas_config; u32 reg_val = cifisp_ioread32(CIF_ISP_AWB_PROP); /* switch off */ @@ -2001,37 +2240,20 @@ static void cifisp_awb_meas_end(struct cif_isp10_isp_dev *isp_dev) isp_dev->active_meas &= ~CIF_ISP_AWB_DONE; - if (!CIFISP_MODULE_IS_EN( - isp_dev->meas_cfgs.last_or_new->module_ens, - CIFISP_MODULE_AWB)) - cifisp_iowrite32AND(~CIF_ISP_CTRL_ISP_AWB_ENA, - CIF_ISP_CTRL); -} - -/*****************************************************************************/ -static void cifisp_awb_gain_en(const struct cif_isp10_isp_dev *isp_dev) -{ - cifisp_iowrite32OR(CIF_ISP_CTRL_ISP_AWB_ENA, CIF_ISP_CTRL); -} - -/*****************************************************************************/ -static void cifisp_awb_gain_end(const struct cif_isp10_isp_dev *isp_dev) -{ - if (!CIFISP_MODULE_IS_EN( - isp_dev->meas_cfgs.last_or_new->module_ens, - CIFISP_MODULE_AWB)) - cifisp_iowrite32AND(~CIF_ISP_CTRL_ISP_AWB_ENA, - CIF_ISP_CTRL); + cifisp_iowrite32AND(~CIF_ISP_CTRL_ISP_AWB_ENA, + CIF_ISP_CTRL); } /*****************************************************************************/ static void cifisp_get_awb_meas(struct cif_isp10_isp_dev *isp_dev, - struct cifisp_stat_buffer *pbuf) + struct cifisp_stat_buffer *pbuf) { /* Protect against concurrent access from ISR? */ u32 reg_val; + unsigned int curr_id = + isp_dev->meas_cfgs.log[CIFISP_AWB_ID].curr_id; const struct cifisp_awb_meas_config *pconfig = - &isp_dev->meas_cfgs.curr->awb_meas_config; + &isp_dev->meas_cfgs.cfgs[curr_id].awb_meas_config; pbuf->meas_type |= CIFISP_STAT_AWB; reg_val = cifisp_ioread32(CIF_ISP_AWB_WHITE_CNT); @@ -2060,8 +2282,10 @@ static void cifisp_get_awb_meas(struct cif_isp10_isp_dev *isp_dev, /*****************************************************************************/ static void cifisp_aec_config(const struct cif_isp10_isp_dev *isp_dev) { + unsigned int new_id = + isp_dev->meas_cfgs.log[CIFISP_AEC_ID].new_id; const struct cifisp_aec_config *pconfig = - &isp_dev->meas_cfgs.last_or_new->aec_config; + &isp_dev->meas_cfgs.cfgs[new_id].aec_config; unsigned int block_hsize, block_vsize; cifisp_iowrite32(CIFISP_EXP_CTRL_AUTOSTOP(pconfig->autostop) | @@ -2138,8 +2362,10 @@ static void cifisp_ctk_config_read(const struct cif_isp10_isp_dev *isp_dev, /*****************************************************************************/ static void cifisp_ctk_en(const struct cif_isp10_isp_dev *isp_dev) { + unsigned int new_id = + isp_dev->other_cfgs.log[CIFISP_CTK_ID].new_id; const struct cifisp_ctk_config *pconfig = - &isp_dev->other_cfgs.last_or_new->ctk_config; + &isp_dev->other_cfgs.cfgs[new_id].ctk_config; cifisp_iowrite32(pconfig->coeff0, CIF_ISP_CT_COEFF_0); cifisp_iowrite32(pconfig->coeff1, CIF_ISP_CT_COEFF_1); @@ -2179,10 +2405,14 @@ static void cifisp_ctk_end(const struct cif_isp10_isp_dev *isp_dev) static void cifisp_cproc_config(const struct cif_isp10_isp_dev *isp_dev, enum cif_isp10_pix_fmt_quantization quantization) { + unsigned int new_id_cproc = + isp_dev->other_cfgs.log[CIFISP_CPROC_ID].new_id; const struct cifisp_cproc_config *pconfig = - &isp_dev->other_cfgs.last_or_new->cproc_config; + &isp_dev->other_cfgs.cfgs[new_id_cproc].cproc_config; + unsigned int curr_id = + isp_dev->other_cfgs.log[CIFISP_IE_ID].curr_id; const struct cifisp_ie_config *ie_pconfig = - &isp_dev->other_cfgs.last_or_new->ie_config; + &isp_dev->other_cfgs.cfgs[curr_id].ie_config; cifisp_iowrite32(pconfig->contrast, CIF_C_PROC_CONTRAST); cifisp_iowrite32(pconfig->hue, CIF_C_PROC_HUE); @@ -2190,7 +2420,7 @@ static void cifisp_cproc_config(const struct cif_isp10_isp_dev *isp_dev, cifisp_iowrite32(pconfig->brightness, CIF_C_PROC_BRIGHTNESS); if ((quantization != CIF_ISP10_QUANTIZATION_FULL_RANGE) || - (ie_pconfig->effect != V4L2_COLORFX_NONE)) { + (ie_pconfig->effect != V4L2_COLORFX_NONE)) { cifisp_iowrite32( ~(CIF_C_PROC_YOUT_FULL | CIF_C_PROC_YIN_FULL | @@ -2236,8 +2466,10 @@ static void cifisp_cproc_end(const struct cif_isp10_isp_dev *isp_dev) static void cifisp_afc_config(const struct cif_isp10_isp_dev *isp_dev) { + unsigned int new_id = + isp_dev->meas_cfgs.log[CIFISP_AFC_ID].new_id; const struct cifisp_afc_config *pconfig = - &isp_dev->meas_cfgs.last_or_new->afc_config; + &isp_dev->meas_cfgs.cfgs[new_id].afc_config; int num_of_win = pconfig->num_afm_win, i; /* Switch off to configure. Enabled during normal flow in frame isr. */ @@ -2299,12 +2531,14 @@ static void cifisp_get_afc_meas(struct cif_isp10_isp_dev *isp_dev, /*****************************************************************************/ static void cifisp_hst_config(const struct cif_isp10_isp_dev *isp_dev) { + unsigned int new_id = + isp_dev->meas_cfgs.log[CIFISP_HST_ID].new_id; const struct cifisp_hst_config *pconfig = - &isp_dev->meas_cfgs.last_or_new->hst_config; + &isp_dev->meas_cfgs.cfgs[new_id].hst_config; unsigned int block_hsize, block_vsize; cifisp_iowrite32(CIFISP_HIST_PREDIV_SET(pconfig->histogram_predivider), - CIF_ISP_HIST_PROP); + CIF_ISP_HIST_PROP); cifisp_iowrite32(pconfig->meas_window.h_offs, CIF_ISP_HIST_H_OFFS); cifisp_iowrite32(pconfig->meas_window.v_offs, CIF_ISP_HIST_V_OFFS); @@ -2317,36 +2551,38 @@ static void cifisp_hst_config(const struct cif_isp10_isp_dev *isp_dev) cifisp_iowrite32(block_vsize, CIF_ISP_HIST_V_SIZE); cifisp_iowrite32(CIFISP_HIST_WEIGHT_SET(pconfig->hist_weight[0], - pconfig->hist_weight[1], pconfig->hist_weight[2], - pconfig->hist_weight[3]), CIF_ISP_HIST_WEIGHT_00TO30); + pconfig->hist_weight[1], pconfig->hist_weight[2], + pconfig->hist_weight[3]), CIF_ISP_HIST_WEIGHT_00TO30); cifisp_iowrite32(CIFISP_HIST_WEIGHT_SET(pconfig->hist_weight[4], - pconfig->hist_weight[5], pconfig->hist_weight[6], - pconfig->hist_weight[7]), CIF_ISP_HIST_WEIGHT_40TO21); + pconfig->hist_weight[5], pconfig->hist_weight[6], + pconfig->hist_weight[7]), CIF_ISP_HIST_WEIGHT_40TO21); cifisp_iowrite32(CIFISP_HIST_WEIGHT_SET(pconfig->hist_weight[8], - pconfig->hist_weight[9], pconfig->hist_weight[10], - pconfig->hist_weight[11]), CIF_ISP_HIST_WEIGHT_31TO12); + pconfig->hist_weight[9], pconfig->hist_weight[10], + pconfig->hist_weight[11]), CIF_ISP_HIST_WEIGHT_31TO12); cifisp_iowrite32(CIFISP_HIST_WEIGHT_SET(pconfig->hist_weight[12], - pconfig->hist_weight[13], pconfig->hist_weight[14], - pconfig->hist_weight[15]), CIF_ISP_HIST_WEIGHT_22TO03); + pconfig->hist_weight[13], pconfig->hist_weight[14], + pconfig->hist_weight[15]), CIF_ISP_HIST_WEIGHT_22TO03); cifisp_iowrite32(CIFISP_HIST_WEIGHT_SET(pconfig->hist_weight[16], - pconfig->hist_weight[17], pconfig->hist_weight[18], - pconfig->hist_weight[19]), CIF_ISP_HIST_WEIGHT_13TO43); + pconfig->hist_weight[17], pconfig->hist_weight[18], + pconfig->hist_weight[19]), CIF_ISP_HIST_WEIGHT_13TO43); cifisp_iowrite32(CIFISP_HIST_WEIGHT_SET(pconfig->hist_weight[20], - pconfig->hist_weight[21], pconfig->hist_weight[22], - pconfig->hist_weight[23]), CIF_ISP_HIST_WEIGHT_04TO34); + pconfig->hist_weight[21], pconfig->hist_weight[22], + pconfig->hist_weight[23]), CIF_ISP_HIST_WEIGHT_04TO34); cifisp_iowrite32(CIFISP_HIST_WEIGHT_SET(pconfig->hist_weight[24], - 0, 0, 0), CIF_ISP_HIST_WEIGHT_44); + 0, 0, 0), CIF_ISP_HIST_WEIGHT_44); } static void cifisp_hst_en(struct cif_isp10_isp_dev *isp_dev) { + unsigned int new_id = + isp_dev->meas_cfgs.log[CIFISP_HST_ID].new_id; const struct cifisp_hst_config *pconfig = - &isp_dev->meas_cfgs.last_or_new->hst_config; + &isp_dev->meas_cfgs.cfgs[new_id].hst_config; isp_dev->active_meas |= CIF_ISP_HIST_MEASURE_RDY; cifisp_iowrite32OR(pconfig->mode, - CIF_ISP_HIST_PROP); + CIF_ISP_HIST_PROP); } /*****************************************************************************/ @@ -2354,7 +2590,7 @@ static void cifisp_hst_end(struct cif_isp10_isp_dev *isp_dev) { /* Disable measurement */ cifisp_iowrite32(CIFISP_HISTOGRAM_MODE_DISABLE, - CIF_ISP_HIST_PROP); + CIF_ISP_HIST_PROP); isp_dev->active_meas &= ~CIF_ISP_HIST_MEASURE_RDY; } @@ -2376,8 +2612,10 @@ static void cifisp_get_hst_meas(const struct cif_isp10_isp_dev *isp_dev, /*****************************************************************************/ static void cifisp_ie_config(const struct cif_isp10_isp_dev *isp_dev) { + unsigned int new_id = + isp_dev->other_cfgs.log[CIFISP_IE_ID].new_id; const struct cifisp_ie_config *pconfig = - &isp_dev->other_cfgs.last_or_new->ie_config; + &isp_dev->other_cfgs.cfgs[new_id].ie_config; switch (pconfig->effect) { case V4L2_COLORFX_SET_CBCR: @@ -2407,8 +2645,10 @@ static void cifisp_ie_config(const struct cif_isp10_isp_dev *isp_dev) static void cifisp_ie_en(const struct cif_isp10_isp_dev *isp_dev) { + unsigned int new_id = + isp_dev->other_cfgs.log[CIFISP_IE_ID].new_id; const struct cifisp_ie_config *pconfig = - &isp_dev->other_cfgs.last_or_new->ie_config; + &isp_dev->other_cfgs.cfgs[new_id].ie_config; enum cif_isp10_image_effect effect; switch (pconfig->effect) { @@ -2456,15 +2696,21 @@ static void cifisp_ie_end(const struct cif_isp10_isp_dev *isp_dev) } static void cifisp_csm_config(const struct cif_isp10_isp_dev *isp_dev, - enum cif_isp10_pix_fmt_quantization quantization) + enum cif_isp10_pix_fmt_quantization quantization) { - const struct cifisp_ie_config *pconfig = - &isp_dev->other_cfgs.last_or_new->ie_config; + unsigned int curr_id_ie = + isp_dev->other_cfgs.log[CIFISP_IE_ID].curr_id; + const struct cifisp_ie_config *ie_pconfig = + &isp_dev->other_cfgs.cfgs[curr_id_ie].ie_config; + unsigned int curr_id_cproc = + isp_dev->other_cfgs.log[CIFISP_CPROC_ID].curr_id; + unsigned int curr_cproc_en = + isp_dev->other_cfgs.cfgs[curr_id_cproc].module_ens; if ((quantization != CIF_ISP10_QUANTIZATION_FULL_RANGE) || - ((pconfig->effect != V4L2_COLORFX_NONE) && + ((ie_pconfig->effect != V4L2_COLORFX_NONE) && CIFISP_MODULE_IS_EN( - isp_dev->other_cfgs.last_or_new->module_ens, + curr_cproc_en, CIFISP_MODULE_CPROC))) { /* Limit range conversion */ cifisp_iowrite32(0x21, CIF_ISP_CC_COEFF_0); @@ -2477,9 +2723,9 @@ static void cifisp_csm_config(const struct cif_isp10_isp_dev *isp_dev, cifisp_iowrite32(0x1d1, CIF_ISP_CC_COEFF_7); cifisp_iowrite32(0x1f7, CIF_ISP_CC_COEFF_8); cifisp_iowrite32AND(~CIF_ISP_CTRL_ISP_CSM_Y_FULL_ENA, - CIF_ISP_CTRL); + CIF_ISP_CTRL); cifisp_iowrite32AND(~CIF_ISP_CTRL_ISP_CSM_C_FULL_ENA, - CIF_ISP_CTRL); + CIF_ISP_CTRL); } else { cifisp_iowrite32(0x26, CIF_ISP_CC_COEFF_0); cifisp_iowrite32(0x4b, CIF_ISP_CC_COEFF_1); @@ -2491,9 +2737,9 @@ static void cifisp_csm_config(const struct cif_isp10_isp_dev *isp_dev, cifisp_iowrite32(0x1ca, CIF_ISP_CC_COEFF_7); cifisp_iowrite32(0x1f6, CIF_ISP_CC_COEFF_8); cifisp_iowrite32OR(CIF_ISP_CTRL_ISP_CSM_Y_FULL_ENA, - CIF_ISP_CTRL); + CIF_ISP_CTRL); cifisp_iowrite32OR(CIF_ISP_CTRL_ISP_CSM_C_FULL_ENA, - CIF_ISP_CTRL); + CIF_ISP_CTRL); } } @@ -2501,13 +2747,16 @@ static void cifisp_csm_config(const struct cif_isp10_isp_dev *isp_dev, /*****************************************************************************/ static void cifisp_dpf_config(const struct cif_isp10_isp_dev *isp_dev) { + unsigned int new_id = + isp_dev->other_cfgs.log[CIFISP_DPF_ID].new_id; const struct cifisp_dpf_config *pconfig = - &isp_dev->other_cfgs.last_or_new->dpf_config; + &isp_dev->other_cfgs.cfgs[new_id].dpf_config; unsigned int isp_dpf_mode; unsigned int i; unsigned int spatial_coeff; - isp_dpf_mode = 0x00; + isp_dpf_mode = + cifisp_ioread32(CIF_ISP_DPF_MODE) & CIFISP_DPF_MODE_EN; switch (pconfig->gain.mode) { case CIFISP_DPF_GAIN_USAGE_DISABLED: @@ -2557,7 +2806,7 @@ static void cifisp_dpf_config(const struct cif_isp10_isp_dev *isp_dev) for (i = 0; i < CIFISP_DPF_MAX_NLF_COEFFS; i++) { cifisp_iowrite32(pconfig->nll.coeff[i], - CIF_ISP_DPF_NULL_COEFF_0 + i * 4); + CIF_ISP_DPF_NULL_COEFF_0 + i * 4); } spatial_coeff = pconfig->g_flt.spatial_coeff[0] | @@ -2580,8 +2829,10 @@ static void cifisp_dpf_config(const struct cif_isp10_isp_dev *isp_dev) static void cifisp_dpf_strength_config(const struct cif_isp10_isp_dev *isp_dev) { + unsigned int new_id = + isp_dev->other_cfgs.log[CIFISP_DPF_STRENGTH_ID].new_id; const struct cifisp_dpf_strength_config *pconfig = - &isp_dev->other_cfgs.last_or_new->dpf_strength_config; + &isp_dev->other_cfgs.cfgs[new_id].dpf_strength_config; cifisp_iowrite32(pconfig->b, CIF_ISP_DPF_STRENGTH_B); cifisp_iowrite32(pconfig->g, CIF_ISP_DPF_STRENGTH_G); @@ -2591,13 +2842,13 @@ static void cifisp_dpf_strength_config(const struct cif_isp10_isp_dev *isp_dev) static void cifisp_dpf_en(struct cif_isp10_isp_dev *isp_dev) { cifisp_iowrite32OR(CIFISP_DPF_MODE_EN, - CIF_ISP_DPF_MODE); + CIF_ISP_DPF_MODE); } static void cifisp_dpf_end(struct cif_isp10_isp_dev *isp_dev) { cifisp_iowrite32AND(~CIFISP_DPF_MODE_EN, - CIF_ISP_DPF_MODE); + CIF_ISP_DPF_MODE); } /* ================== IOCTL implementation ========================= */ @@ -2605,8 +2856,8 @@ static int cifisp_reqbufs(struct file *file, void *priv, struct v4l2_requestbuffers *p) { CIFISP_DPRINT(CIFISP_DEBUG, - " %s: %s: p->type %d p->count %d\n", - ISP_VDEV_NAME, __func__, p->type, p->count); + " %s: %s: p->type %d p->count %d\n", + ISP_VDEV_NAME, __func__, p->type, p->count); return vb2_ioctl_reqbufs(file, priv, p); } @@ -2659,14 +2910,12 @@ static int cifisp_streamoff(struct file *file, void *priv, enum v4l2_buf_type i) struct cif_isp10_isp_dev *isp_dev = video_get_drvdata(video_devdata(file)); - drain_workqueue(isp_dev->readout_wq); ret = vb2_ioctl_streamoff(file, priv, i); - if (ret == 0) isp_dev->streamon = false; CIFISP_DPRINT(CIFISP_DEBUG, - " %s: %s: ret %d\n", ISP_VDEV_NAME, __func__, ret); + " %s: %s: ret %d\n", ISP_VDEV_NAME, __func__, ret); return ret; } @@ -2684,112 +2933,112 @@ static int cifisp_g_ctrl(struct file *file, void *priv, struct v4l2_control *vc) isp_dev, _GET_, &vc->value, - CIFISP_MODULE_DPCC); + CIFISP_DPCC_ID); break; case V4L2_CID_CIFISP_BLS: ret = cifisp_module_enable( isp_dev, _GET_, &vc->value, - CIFISP_MODULE_BLS); + CIFISP_BLS_ID); break; case V4L2_CID_CIFISP_SDG: ret = cifisp_module_enable( isp_dev, _GET_, &vc->value, - CIFISP_MODULE_SDG); + CIFISP_SDG_ID); break; case V4L2_CID_CIFISP_LSC: ret = cifisp_module_enable( isp_dev, _GET_, &vc->value, - CIFISP_MODULE_LSC); + CIFISP_LSC_ID); break; case V4L2_CID_CIFISP_AWB_MEAS: ret = cifisp_module_enable( isp_dev, _GET_, &vc->value, - CIFISP_MODULE_AWB); + CIFISP_AWB_ID); break; case V4L2_CID_CIFISP_AWB_GAIN: ret = cifisp_module_enable( isp_dev, _GET_, &vc->value, - CIFISP_MODULE_AWB_GAIN); + CIFISP_AWB_GAIN_ID); break; case V4L2_CID_CIFISP_FLT: ret = cifisp_module_enable( isp_dev, _GET_, &vc->value, - CIFISP_MODULE_FLT); + CIFISP_FLT_ID); break; case V4L2_CID_CIFISP_BDM: ret = cifisp_module_enable( isp_dev, _GET_, &vc->value, - CIFISP_MODULE_BDM); + CIFISP_BDM_ID); break; case V4L2_CID_CIFISP_CTK: ret = cifisp_module_enable( isp_dev, _GET_, &vc->value, - CIFISP_MODULE_CTK); + CIFISP_CTK_ID); break; case V4L2_CID_CIFISP_GOC: ret = cifisp_module_enable( isp_dev, _GET_, &vc->value, - CIFISP_MODULE_GOC); + CIFISP_GOC_ID); break; case V4L2_CID_CIFISP_HST: ret = cifisp_module_enable( isp_dev, _GET_, &vc->value, - CIFISP_MODULE_HST); + CIFISP_HST_ID); break; case V4L2_CID_CIFISP_AEC: ret = cifisp_module_enable( isp_dev, _GET_, &vc->value, - CIFISP_MODULE_AEC); + CIFISP_AEC_ID); break; case V4L2_CID_CIFISP_CPROC: ret = cifisp_module_enable( isp_dev, _GET_, &vc->value, - CIFISP_MODULE_CPROC); + CIFISP_CPROC_ID); break; case V4L2_CID_CIFISP_AFC: ret = cifisp_module_enable( isp_dev, _GET_, &vc->value, - CIFISP_MODULE_AFC); + CIFISP_AFC_ID); break; case V4L2_CID_CIFISP_IE: ret = cifisp_module_enable( isp_dev, _GET_, &vc->value, - CIFISP_MODULE_IE); + CIFISP_IE_ID); break; case V4L2_CID_CIFISP_DPF: ret = cifisp_module_enable( isp_dev, _GET_, &vc->value, - CIFISP_MODULE_DPF); + CIFISP_DPF_ID); break; default: ret = -EINVAL; @@ -2802,130 +3051,16 @@ static int cifisp_s_ctrl(struct file *file, void *priv, struct v4l2_control *vc) { struct cif_isp10_isp_dev *isp_dev = video_get_drvdata(video_devdata(file)); - int ret; - switch (vc->id) { - case V4L2_CID_CIFISP_DPCC: - ret = cifisp_module_enable( - isp_dev, - _SET_, - &vc->value, - CIFISP_MODULE_DPCC); - break; - case V4L2_CID_CIFISP_BLS: - ret = cifisp_module_enable( - isp_dev, - _SET_, - &vc->value, - CIFISP_MODULE_BLS); - break; - case V4L2_CID_CIFISP_SDG: - ret = cifisp_module_enable( - isp_dev, - _SET_, - &vc->value, - CIFISP_MODULE_SDG); - break; - case V4L2_CID_CIFISP_LSC: - ret = cifisp_module_enable( - isp_dev, - _SET_, - &vc->value, - CIFISP_MODULE_LSC); - break; - case V4L2_CID_CIFISP_AWB_MEAS: - ret = cifisp_module_enable( - isp_dev, - _SET_, - &vc->value, - CIFISP_MODULE_AWB); - break; - case V4L2_CID_CIFISP_AWB_GAIN: - ret = cifisp_module_enable( - isp_dev, - _SET_, - &vc->value, - CIFISP_MODULE_AWB_GAIN); - break; - case V4L2_CID_CIFISP_FLT: - ret = cifisp_module_enable( - isp_dev, - _SET_, - &vc->value, - CIFISP_MODULE_FLT); - break; - case V4L2_CID_CIFISP_BDM: - ret = cifisp_module_enable( - isp_dev, - _SET_, - &vc->value, - CIFISP_MODULE_BDM); - break; - case V4L2_CID_CIFISP_CTK: - ret = cifisp_module_enable( - isp_dev, - _SET_, - &vc->value, - CIFISP_MODULE_CTK); - break; - case V4L2_CID_CIFISP_GOC: - ret = cifisp_module_enable( - isp_dev, - _SET_, - &vc->value, - CIFISP_MODULE_GOC); - break; - case V4L2_CID_CIFISP_HST: - ret = cifisp_module_enable( - isp_dev, - _SET_, - &vc->value, - CIFISP_MODULE_HST); - break; - case V4L2_CID_CIFISP_AEC: - ret = cifisp_module_enable( - isp_dev, - _SET_, - &vc->value, - CIFISP_MODULE_AEC); - break; - case V4L2_CID_CIFISP_CPROC: - ret = cifisp_module_enable( - isp_dev, - _SET_, - &vc->value, - CIFISP_MODULE_CPROC); - break; - case V4L2_CID_CIFISP_AFC: - ret = cifisp_module_enable( - isp_dev, - _SET_, - &vc->value, - CIFISP_MODULE_AFC); - break; - case V4L2_CID_CIFISP_IE: - ret = cifisp_module_enable( - isp_dev, - _SET_, - &vc->value, - CIFISP_MODULE_IE); - break; - case V4L2_CID_CIFISP_DPF: - ret = cifisp_module_enable( - isp_dev, - _SET_, - &vc->value, - CIFISP_MODULE_DPF); - break; - default: - ret = -EINVAL; - break; - } - return ret; + return cifisp_module_enable( + isp_dev, + _SET_, + &vc->value, + vc->id - V4L2_CID_PRIVATE_BASE); } -static long cifisp_ioctl_default(struct file *file, - void *fh, bool valid_prio, unsigned int cmd, void *arg) +static long cifisp_ioctl_default(struct file *file, void *fh, + bool valid_prio, unsigned int cmd, void *arg) { struct cif_isp10_isp_dev *isp = video_get_drvdata(video_devdata(file)); long ret; @@ -3053,8 +3188,8 @@ static int cifisp_g_fmt_vid_cap(struct file *file, void *fh, return 0; } -static int cifisp_querycap(struct file *file, - void *priv, struct v4l2_capability *cap) +static int cifisp_querycap(struct file *file, void *priv, + struct v4l2_capability *cap) { struct video_device *vdev = video_devdata(file); struct cif_isp10_isp_dev *isp_dev = video_get_drvdata(vdev); @@ -3062,8 +3197,8 @@ static int cifisp_querycap(struct file *file, strcpy(cap->driver, DRIVER_NAME); strlcpy(cap->card, vdev->name, sizeof(cap->card)); snprintf(cap->bus_info, sizeof(cap->bus_info), - "platform:" DRIVER_NAME "-%03i", - *isp_dev->dev_id); + "platform:" DRIVER_NAME "-%03i", + *isp_dev->dev_id); cap->capabilities = V4L2_CAP_VIDEO_CAPTURE | V4L2_CAP_DEVICE_CAPS; cap->device_caps = V4L2_CAP_VIDEO_CAPTURE | V4L2_CAP_DEVICE_CAPS; @@ -3112,15 +3247,10 @@ static int cifisp_reset(struct file *file) struct cif_isp10_isp_dev *isp_dev = video_get_drvdata(video_devdata(file)); - memset(isp_dev->other_cfgs.cfgs, 0, sizeof(isp_dev->other_cfgs.cfgs)); - memset(isp_dev->meas_cfgs.cfgs, 0, sizeof(isp_dev->meas_cfgs.cfgs)); - - isp_dev->other_cfgs.last_or_new = &isp_dev->other_cfgs.cfgs[0]; - isp_dev->other_cfgs.curr = &isp_dev->other_cfgs.cfgs[1]; + memset(&isp_dev->other_cfgs, 0, sizeof(struct cifisp_isp_other_cfg)); + memset(&isp_dev->meas_cfgs, 0, sizeof(struct cifisp_isp_meas_cfg)); isp_dev->other_cfgs.module_updates = 0; - isp_dev->meas_cfgs.last_or_new = &isp_dev->meas_cfgs.cfgs[0]; - isp_dev->meas_cfgs.curr = &isp_dev->meas_cfgs.cfgs[1]; isp_dev->meas_cfgs.module_updates = 0; isp_dev->active_lsc_width = 0; isp_dev->active_lsc_height = 0; @@ -3129,6 +3259,15 @@ static int cifisp_reset(struct file *file) isp_dev->active_meas = 0; isp_dev->frame_id = 0; isp_dev->cif_ism_cropping = false; + + isp_dev->meas_send_alone = CIFISP_MEAS_SEND_ALONE; + isp_dev->awb_meas_ready = false; + isp_dev->afm_meas_ready = false; + isp_dev->aec_meas_ready = false; + isp_dev->hst_meas_ready = false; + + isp_dev->meta_info.write_id = 0; + isp_dev->meta_info.read_id = 0; return 0; } @@ -3151,6 +3290,50 @@ static int cifisp_close(struct file *file) return 0; } +static int cifisp_meas_queue_work(struct cif_isp10_isp_dev *isp_dev, unsigned int send_meas) +{ + unsigned int module_updates = 0; + struct cif_isp10_isp_readout_work *work; + + if (send_meas & CIF_ISP_AWB_DONE) + module_updates |= CIFISP_MODULE_AWB; + if (send_meas & CIF_ISP_AFM_FIN) + module_updates |= CIFISP_MODULE_AFC; + if (send_meas & CIF_ISP_EXP_END) + module_updates |= CIFISP_MODULE_AEC; + if (send_meas & CIF_ISP_HIST_MEASURE_RDY) + module_updates |= CIFISP_MODULE_HST; + + if ((isp_dev->meas_cfgs.module_updates & module_updates) == 0 && + (isp_dev->active_meas & send_meas)) { + work = kmalloc(sizeof(*work), GFP_ATOMIC); + if (work) { + INIT_WORK((struct work_struct *)work, + cifisp_isp_readout_work); + work->readout = CIF_ISP10_ISP_READOUT_MEAS; + work->isp_dev = isp_dev; + work->frame_id = isp_dev->frame_id; + work->active_meas = send_meas; + work->vs_t = isp_dev->vs_t; + work->fi_t = isp_dev->fi_t; + + if (!queue_work(isp_dev->readout_wq, + (struct work_struct *)work)) { + CIFISP_DPRINT(CIFISP_ERROR, + "Could not schedule work\n"); + kfree((void *)work); + } + + CIFISP_DPRINT(CIFISP_DEBUG, + "Send 0x%x Packet\n", send_meas); + } else { + CIFISP_DPRINT(CIFISP_ERROR, + "Could not allocate work\n"); + } + } + return 0; +} + struct v4l2_file_operations cifisp_fops = { .mmap = cifisp_mmap, .unlocked_ioctl = video_ioctl2, @@ -3173,9 +3356,11 @@ static void cifisp_release(struct video_device *vdev) /************************************************************/ static int cif_isp10_vb2_queue_setup(struct vb2_queue *vq, - const void *parg, - unsigned int *count, unsigned int *num_planes, - unsigned int sizes[], void *alloc_ctxs[]) + const void *parg, + unsigned int *count, + unsigned int *num_planes, + unsigned int sizes[], + void *alloc_ctxs[]) { sizes[0] = sizeof(struct cifisp_stat_buffer); *num_planes = 1; @@ -3240,9 +3425,9 @@ static int cif_isp10_init_vb2_queue(struct vb2_queue *q, /************************************************************/ int register_cifisp_device(struct cif_isp10_isp_dev *isp_dev, - struct video_device *vdev_cifisp, - struct v4l2_device *v4l2_dev, - void __iomem *cif_reg_baseaddress) + struct video_device *vdev_cifisp, + struct v4l2_device *v4l2_dev, + void __iomem *cif_reg_baseaddress) { isp_dev->base_addr = cif_reg_baseaddress; WARN_ON(!(isp_dev->base_addr)); @@ -3273,24 +3458,23 @@ int register_cifisp_device(struct cif_isp10_isp_dev *isp_dev, vdev_cifisp->queue = &isp_dev->vb2_vidq; - if (video_register_device(vdev_cifisp, VFL_TYPE_GRABBER, -1) < 0) { dev_err(&vdev_cifisp->dev, "could not register Video for Linux device\n"); return -ENODEV; } else { dev_info(&vdev_cifisp->dev, - "successfully registered video device for cifisp(video%d)\n", - vdev_cifisp->minor); + "successfully registered video device for cifisp(video%d)\n", + vdev_cifisp->minor); } CIFISP_DPRINT(CIFISP_DEBUG, - "%s: CIFISP vdev minor = %d\n", - __func__, vdev_cifisp->minor); + "%s: CIFISP vdev minor = %d\n", + __func__, vdev_cifisp->minor); isp_dev->readout_wq = alloc_workqueue("measurement_queue", - WQ_UNBOUND | WQ_MEM_RECLAIM, 1); + WQ_UNBOUND | WQ_MEM_RECLAIM, 1); if (!isp_dev->readout_wq) return -ENOMEM; @@ -3350,28 +3534,44 @@ static void cifisp_dump_reg(struct cif_isp10_isp_dev *isp_dev, int level) #endif } -static inline void cifisp_meas_config_swap( - struct cif_isp10_isp_dev *isp_dev) +static void cifisp_set_isp_modules_actives(struct cif_isp10_isp_dev *isp_dev, + enum cif_isp10_pix_fmt in_pix_fmt) { - struct cifisp_isp_meas_cfg *new_cfg; + isp_dev->other_cfgs.module_actives = 0; + isp_dev->meas_cfgs.module_actives = 0; + if (CIF_ISP10_PIX_FMT_IS_RAW_BAYER(in_pix_fmt)) { + /* unlimited */ + } else if (in_pix_fmt == CIF_Y10) { + CIFISP_MODULE_UNACTIVE( + isp_dev->other_cfgs.module_actives, + CIFISP_MODULE_LSC | + CIFISP_MODULE_AWB_GAIN | + CIFISP_MODULE_BDM | + CIFISP_MODULE_CTK); - new_cfg = isp_dev->meas_cfgs.last_or_new; - new_cfg->s_frame_id = isp_dev->frame_id; - isp_dev->meas_cfgs.last_or_new = - isp_dev->meas_cfgs.curr; - isp_dev->meas_cfgs.curr = new_cfg; -} + CIFISP_MODULE_UNACTIVE( + isp_dev->meas_cfgs.module_actives, + CIFISP_MODULE_AWB); + } else { + CIFISP_MODULE_UNACTIVE( + isp_dev->other_cfgs.module_actives, + CIFISP_MODULE_DPCC | + CIFISP_MODULE_BLS | + CIFISP_MODULE_SDG | + CIFISP_MODULE_LSC | + CIFISP_MODULE_FLT | + CIFISP_MODULE_BDM | + CIFISP_MODULE_CTK | + CIFISP_MODULE_GOC | + CIFISP_MODULE_DPF); -static inline void cifisp_other_config_swap( - struct cif_isp10_isp_dev *isp_dev) -{ - struct cifisp_isp_other_cfg *new_cfg; - - new_cfg = isp_dev->other_cfgs.last_or_new; - new_cfg->s_frame_id = isp_dev->frame_id; - isp_dev->other_cfgs.last_or_new = - isp_dev->other_cfgs.curr; - isp_dev->other_cfgs.curr = new_cfg; + CIFISP_MODULE_UNACTIVE( + isp_dev->meas_cfgs.module_actives, + CIFISP_MODULE_HST | + CIFISP_MODULE_AFC | + CIFISP_MODULE_AWB | + CIFISP_MODULE_AEC); + } } /* Not called when the camera active, thus not isr protection. */ @@ -3380,221 +3580,74 @@ void cifisp_configure_isp( enum cif_isp10_pix_fmt in_pix_fmt, enum cif_isp10_pix_fmt_quantization quantization) { - unsigned int *other_ens, *other_updates; - unsigned int *meas_ens, *meas_updates; + unsigned int time_left = 3000; + unsigned int i, curr_id; CIFISP_DPRINT(CIFISP_DEBUG, "%s\n", __func__); mutex_lock(&isp_dev->mutex); spin_lock(&isp_dev->config_lock); - other_ens = &isp_dev->other_cfgs.last_or_new->module_ens; - other_updates = &isp_dev->other_cfgs.module_updates; - meas_ens = &isp_dev->meas_cfgs.last_or_new->module_ens; - meas_updates = &isp_dev->meas_cfgs.module_updates; isp_dev->quantization = quantization; - if (CIF_ISP10_PIX_FMT_IS_RAW_BAYER(in_pix_fmt)) { - if (CIFISP_MODULE_IS_EN(*other_ens, CIFISP_MODULE_DPCC)) { - cifisp_dpcc_config(isp_dev); - cifisp_dpcc_en(isp_dev); - CIFISP_MODULE_CLR_UPDATE(*other_updates, - CIFISP_MODULE_DPCC); - } + cifisp_set_isp_modules_actives(isp_dev, in_pix_fmt); + /* + * Must config isp, Hardware may has been reset. + */ + for (i = 0; i < CIFISP_MEAS_ID; i++) { + if (CIFISP_MODULE_IS_UNACTIVE( + isp_dev->other_cfgs.module_actives, + (1 << i))) + continue; - if (CIFISP_MODULE_IS_EN(*other_ens, CIFISP_MODULE_LSC)) { - if (cifisp_lsc_config(isp_dev)) - CIFISP_MODULE_CLR_UPDATE(*other_updates, - CIFISP_MODULE_LSC); - } + if (CIFISP_MODULE_IS_UPDATE( + isp_dev->other_cfgs.module_updates, + (1 << i))) + continue; - if (CIFISP_MODULE_IS_EN(*other_ens, CIFISP_MODULE_BLS)) { - cifisp_bls_config(isp_dev); - cifisp_bls_en(isp_dev); - CIFISP_MODULE_CLR_UPDATE(*other_updates, - CIFISP_MODULE_BLS); - } + curr_id = isp_dev->other_cfgs.log[i].curr_id; + if (CIFISP_MODULE_IS_EN( + isp_dev->other_cfgs.cfgs[curr_id].module_ens, + (1 << i))) { + isp_dev->other_cfgs.log[i].new_id = curr_id; + CIFISP_MODULE_UPDATE( + isp_dev->other_cfgs.module_updates, + (1 << i)); - if (CIFISP_MODULE_IS_EN(*other_ens, CIFISP_MODULE_SDG)) { - cifisp_sdg_config(isp_dev); - cifisp_sdg_en(isp_dev); - CIFISP_MODULE_CLR_UPDATE(*other_updates, - CIFISP_MODULE_SDG); - } - - if (CIFISP_MODULE_IS_EN(*other_ens, CIFISP_MODULE_GOC)) { - cifisp_goc_config(isp_dev); - cifisp_goc_en(isp_dev); - CIFISP_MODULE_CLR_UPDATE(*other_updates, - CIFISP_MODULE_GOC); - } - - if (CIFISP_MODULE_IS_EN(*other_ens, CIFISP_MODULE_BDM)) { - cifisp_bdm_config(isp_dev); - cifisp_bdm_en(isp_dev); - CIFISP_MODULE_CLR_UPDATE(*other_updates, - CIFISP_MODULE_BDM); - } - - if (CIFISP_MODULE_IS_EN(*other_ens, CIFISP_MODULE_FLT)) { - cifisp_flt_config(isp_dev); - cifisp_flt_en(isp_dev); - CIFISP_MODULE_CLR_UPDATE(*other_updates, - CIFISP_MODULE_FLT); - } - - if (CIFISP_MODULE_IS_EN(*other_ens, CIFISP_MODULE_AWB_GAIN)) { - cifisp_awb_gain_config(isp_dev); - cifisp_awb_gain_en(isp_dev); - CIFISP_MODULE_CLR_UPDATE(*other_updates, - CIFISP_MODULE_AWB_GAIN); - } - - if (CIFISP_MODULE_IS_EN(*other_ens, CIFISP_MODULE_CTK)) { - cifisp_ctk_config(isp_dev); - cifisp_ctk_en(isp_dev); - CIFISP_MODULE_CLR_UPDATE(*other_updates, - CIFISP_MODULE_CTK); - } - - if (CIFISP_MODULE_IS_EN(*other_ens, CIFISP_MODULE_CPROC)) { - cifisp_cproc_config(isp_dev, quantization); - cifisp_cproc_en(isp_dev); - CIFISP_MODULE_CLR_UPDATE(*other_updates, - CIFISP_MODULE_CPROC); - } - - if (CIFISP_MODULE_IS_EN(*other_ens, CIFISP_MODULE_IE)) { - cifisp_ie_config(isp_dev); - cifisp_ie_en(isp_dev); - CIFISP_MODULE_CLR_UPDATE(*other_updates, - CIFISP_MODULE_IE); - } - - cifisp_csm_config(isp_dev, quantization); - - if (CIFISP_MODULE_IS_EN(*other_ens, CIFISP_MODULE_DPF)) { - cifisp_dpf_config(isp_dev); - cifisp_dpf_strength_config(isp_dev); - cifisp_dpf_en(isp_dev); - CIFISP_MODULE_CLR_UPDATE(*other_updates, - CIFISP_MODULE_DPF | CIFISP_MODULE_DPF_STRENGTH); - } - - if (CIFISP_MODULE_IS_EN(*meas_ens, CIFISP_MODULE_AFC)) { - cifisp_afc_config(isp_dev); - cifisp_afc_en(isp_dev); - CIFISP_MODULE_CLR_UPDATE(*meas_updates, - CIFISP_MODULE_AFC); - } - - if (CIFISP_MODULE_IS_EN(*meas_ens, CIFISP_MODULE_AWB)) { - cifisp_awb_meas_config(isp_dev); - cifisp_awb_meas_en(isp_dev); - CIFISP_MODULE_CLR_UPDATE(*meas_updates, - CIFISP_MODULE_AWB); - } - - if (CIFISP_MODULE_IS_EN(*meas_ens, CIFISP_MODULE_AEC)) { - cifisp_aec_config(isp_dev); - cifisp_aec_en(isp_dev); - CIFISP_MODULE_CLR_UPDATE(*meas_updates, - CIFISP_MODULE_AEC); - } - - if (CIFISP_MODULE_IS_EN(*meas_ens, CIFISP_MODULE_HST)) { - cifisp_hst_config(isp_dev); - cifisp_hst_en(isp_dev); - CIFISP_MODULE_CLR_UPDATE(*meas_updates, - CIFISP_MODULE_HST); - } - } else { - /* Disable modules for yuv */ - cifisp_dpcc_end(isp_dev); - CIFISP_MODULE_CLR_UPDATE(*other_updates, - CIFISP_MODULE_DPCC); - - cifisp_lsc_end(isp_dev); - CIFISP_MODULE_CLR_UPDATE(*other_updates, - CIFISP_MODULE_LSC); - - cifisp_bls_end(isp_dev); - CIFISP_MODULE_CLR_UPDATE(*other_updates, - CIFISP_MODULE_BLS); - - cifisp_sdg_end(isp_dev); - CIFISP_MODULE_CLR_UPDATE(*other_updates, - CIFISP_MODULE_SDG); - - cifisp_goc_end(isp_dev); - CIFISP_MODULE_CLR_UPDATE(*other_updates, - CIFISP_MODULE_GOC); - - cifisp_bdm_end(isp_dev); - CIFISP_MODULE_CLR_UPDATE(*other_updates, - CIFISP_MODULE_BDM); - - cifisp_flt_end(isp_dev); - CIFISP_MODULE_CLR_UPDATE(*other_updates, - CIFISP_MODULE_FLT); - - cifisp_awb_meas_end(isp_dev); - CIFISP_MODULE_CLR_UPDATE(*meas_updates, - CIFISP_MODULE_AWB); - - cifisp_awb_gain_end(isp_dev); - CIFISP_MODULE_CLR_UPDATE(*other_updates, - CIFISP_MODULE_AWB_GAIN); - - cifisp_aec_end(isp_dev); - CIFISP_MODULE_CLR_UPDATE(*meas_updates, - CIFISP_MODULE_AEC); - - cifisp_ctk_end(isp_dev); - CIFISP_MODULE_CLR_UPDATE(*other_updates, - CIFISP_MODULE_CTK); - - cifisp_dpf_end(isp_dev); - CIFISP_MODULE_CLR_UPDATE(*other_updates, - CIFISP_MODULE_DPF); - - /* cproc can be used for yuv in reduced range */ - if (CIFISP_MODULE_IS_EN(*other_ens, CIFISP_MODULE_CPROC)) { - cifisp_cproc_config(isp_dev, false); - cifisp_cproc_en(isp_dev); - CIFISP_MODULE_CLR_UPDATE(*other_updates, - CIFISP_MODULE_CPROC); - } - - cifisp_hst_end(isp_dev); - CIFISP_MODULE_CLR_UPDATE(*meas_updates, - CIFISP_MODULE_HST); - - cifisp_afc_end(isp_dev); - CIFISP_MODULE_CLR_UPDATE(*meas_updates, - CIFISP_MODULE_AFC); - /* ie can be used for yuv */ - if (CIFISP_MODULE_IS_EN(*other_ens, CIFISP_MODULE_IE)) { - cifisp_ie_config(isp_dev); - cifisp_ie_en(isp_dev); - CIFISP_MODULE_CLR_UPDATE(*other_updates, - CIFISP_MODULE_IE); - } else { - cifisp_ie_end(isp_dev); + if (i == CIFISP_DPF_ID) { + isp_dev->other_cfgs.log[CIFISP_DPF_STRENGTH_ID].new_id = curr_id; + CIFISP_MODULE_UPDATE( + isp_dev->other_cfgs.module_updates, + (1 << CIFISP_DPF_STRENGTH_ID)); + } } } + for (i = CIFISP_MEAS_ID; i < CIFISP_MODULE_MAX; i++) { + if (CIFISP_MODULE_IS_UNACTIVE( + isp_dev->meas_cfgs.module_actives, + (1 << i))) + continue; + + if (CIFISP_MODULE_IS_UPDATE( + isp_dev->meas_cfgs.module_updates, + (1 << i))) + continue; + + curr_id = isp_dev->meas_cfgs.log[i].curr_id; + if (CIFISP_MODULE_IS_EN( + isp_dev->meas_cfgs.cfgs[curr_id].module_ens, + (1 << i))) { + isp_dev->meas_cfgs.log[i].new_id = curr_id; + CIFISP_MODULE_UPDATE( + isp_dev->meas_cfgs.module_updates, + (1 << i)); + } + } + cifisp_isp_isr_other_config(isp_dev, &time_left); + cifisp_csm_config(isp_dev, quantization); + cifisp_isp_isr_meas_config(isp_dev, &time_left); cifisp_dump_reg(isp_dev, CIFISP_DEBUG); - cifisp_meas_config_swap(isp_dev); - cifisp_other_config_swap(isp_dev); - - memcpy(isp_dev->other_cfgs.last_or_new, - isp_dev->other_cfgs.curr, - sizeof(struct cifisp_isp_other_cfg)); - memcpy(isp_dev->meas_cfgs.last_or_new, - isp_dev->meas_cfgs.curr, - sizeof(struct cifisp_isp_meas_cfg)); - spin_unlock(&isp_dev->config_lock); mutex_unlock(&isp_dev->mutex); } @@ -3603,17 +3656,48 @@ void cifisp_frame_in( struct cif_isp10_isp_dev *isp_dev, const struct timeval *fi_t) { + unsigned int write_id; /* Called in an interrupt context. */ isp_dev->fi_t = *fi_t; + + write_id = isp_dev->meta_info.write_id; + isp_dev->meta_info.fi_t[write_id] = *fi_t; + isp_dev->meta_info.write_id = (write_id + 1) % CIF_ISP10_META_INFO_NUM; } void cifisp_v_start( struct cif_isp10_isp_dev *isp_dev, const struct timeval *vs_t) { + unsigned int write_id; /* Called in an interrupt context. */ isp_dev->frame_id += 2; isp_dev->vs_t = *vs_t; + + write_id = isp_dev->meta_info.write_id; + isp_dev->meta_info.frame_id[write_id] = isp_dev->frame_id; + isp_dev->meta_info.vs_t[write_id] = *vs_t; +} + +void cifisp_frame_id_reset( + struct cif_isp10_isp_dev *isp_dev) +{ + unsigned int i; + + isp_dev->frame_id = 0; + for (i = 0; i < CIFISP_MEAS_ID; i++) { + memset(isp_dev->other_cfgs.log[i].s_frame_id, + 0x00, + sizeof(isp_dev->other_cfgs.log[i].s_frame_id)); + } + for (i = CIFISP_MEAS_ID; i < CIFISP_MODULE_MAX; i++) { + memset(isp_dev->meas_cfgs.log[i].s_frame_id, + 0x00, + sizeof(isp_dev->meas_cfgs.log[i].s_frame_id)); + } + + isp_dev->meta_info.read_id = 0; + isp_dev->meta_info.write_id = 0; } /* Not called when the camera active, thus not isr protection. */ @@ -3631,7 +3715,6 @@ void cifisp_disable_isp(struct cif_isp10_isp_dev *isp_dev) cifisp_bdm_end(isp_dev); cifisp_flt_end(isp_dev); cifisp_awb_meas_end(isp_dev); - cifisp_awb_gain_end(isp_dev); cifisp_aec_end(isp_dev); cifisp_ctk_end(isp_dev); cifisp_cproc_end(isp_dev); @@ -3645,25 +3728,11 @@ void cifisp_disable_isp(struct cif_isp10_isp_dev *isp_dev) */ spin_lock(&isp_dev->config_lock); - isp_dev->other_cfgs.last_or_new->module_ens = 0; - isp_dev->meas_cfgs.last_or_new->module_ens = 0; - - /* - * 1. Swap last_or_new and curr pointer; - * 2. Sync last_or_new and curr configuration; - */ - cifisp_meas_config_swap(isp_dev); - cifisp_other_config_swap(isp_dev); - - memcpy(isp_dev->other_cfgs.last_or_new, - isp_dev->other_cfgs.curr, - sizeof(struct cifisp_isp_other_cfg)); - memcpy(isp_dev->meas_cfgs.last_or_new, - isp_dev->meas_cfgs.curr, - sizeof(struct cifisp_isp_meas_cfg)); - + memset(&isp_dev->other_cfgs, 0, sizeof(struct cifisp_isp_other_cfg)); + memset(&isp_dev->meas_cfgs, 0, sizeof(struct cifisp_isp_meas_cfg)); + isp_dev->other_cfgs.module_updates = 0; + isp_dev->meas_cfgs.module_updates = 0; spin_unlock(&isp_dev->config_lock); - mutex_unlock(&isp_dev->mutex); } @@ -3675,24 +3744,23 @@ static void cifisp_send_measurement( struct cif_isp10_buffer *buf = NULL; struct vb2_buffer *vb = NULL; void *mem_addr; - struct pltfrm_cam_vcm_tim vcm_tim; - long ret; - - unsigned int active_meas = isp_dev->active_meas; + unsigned int active_meas = meas_work->active_meas; struct cifisp_stat_buffer *stat_buf; struct cif_isp10_device *cif_dev = container_of(isp_dev, struct cif_isp10_device, isp_dev); + struct pltfrm_cam_vcm_tim vcm_tim; + long ret; spin_lock_irqsave(&isp_dev->irq_lock, lock_flags); if (!list_empty(&isp_dev->stat)) { buf = list_first_entry(&isp_dev->stat, - struct cif_isp10_buffer, queue); + struct cif_isp10_buffer, queue); vb = &buf->vb.vb2_buf; } else { spin_unlock_irqrestore(&isp_dev->irq_lock, lock_flags); CIFISP_DPRINT(CIFISP_DEBUG, - "Not enought measurement bufs\n"); + "Not enought measurement bufs\n"); goto end; } spin_unlock_irqrestore(&isp_dev->irq_lock, lock_flags); @@ -3703,61 +3771,44 @@ static void cifisp_send_measurement( stat_buf = (struct cifisp_stat_buffer *)mem_addr; memset(stat_buf, 0x00, sizeof(struct cifisp_stat_buffer)); - if (active_meas & CIF_ISP_AWB_DONE) - cifisp_get_awb_meas(isp_dev, stat_buf); - - if (active_meas & CIF_ISP_AFM_FIN) - cifisp_get_afc_meas(isp_dev, stat_buf); - - if (active_meas & CIF_ISP_EXP_END) { - cifisp_get_aec_meas(isp_dev, stat_buf); - cifisp_bls_get_meas(isp_dev, stat_buf); - } - - if (active_meas & CIF_ISP_HIST_MEASURE_RDY) - cifisp_get_hst_meas(isp_dev, stat_buf); - spin_lock_irqsave(&isp_dev->irq_lock, lock_flags); list_del(&buf->queue); spin_unlock_irqrestore(&isp_dev->irq_lock, lock_flags); - isp_dev->meas_stats.stat.meas_type = 0; + stat_buf->meas_type = 0; if (active_meas & CIF_ISP_AWB_DONE) { - memcpy(&isp_dev->meas_stats.stat.params.awb, - &stat_buf->params.awb, - sizeof(struct cifisp_awb_stat)); - isp_dev->meas_stats.stat.meas_type |= CIFISP_STAT_AWB; + memcpy(&stat_buf->params.awb, + &isp_dev->meas_stats.stat.params.awb, + sizeof(struct cifisp_awb_stat)); + stat_buf->meas_type |= CIFISP_STAT_AWB; } if (active_meas & CIF_ISP_AFM_FIN) { - memcpy(&isp_dev->meas_stats.stat.params.af, - &stat_buf->params.af, - sizeof(struct cifisp_af_stat)); - isp_dev->meas_stats.stat.meas_type |= CIFISP_STAT_AFM_FIN; + memcpy(&stat_buf->params.af, + &isp_dev->meas_stats.stat.params.af, + sizeof(struct cifisp_af_stat)); + stat_buf->meas_type |= CIFISP_STAT_AFM_FIN; } if (active_meas & CIF_ISP_EXP_END) { + memcpy(&stat_buf->params.ae, + &isp_dev->meas_stats.stat.params.ae, + sizeof(struct cifisp_ae_stat)); + cif_isp10_sensor_mode_data_sync(cif_dev, meas_work->frame_id, &stat_buf->sensor_mode); - memcpy(&isp_dev->meas_stats.stat.params.ae, - &stat_buf->params.ae, - sizeof(struct cifisp_ae_stat)); - memcpy(&isp_dev->meas_stats.stat.sensor_mode, - &stat_buf->sensor_mode, - sizeof(struct isp_supplemental_sensor_mode_data)); - isp_dev->meas_stats.stat.meas_type |= CIFISP_STAT_AUTOEXP; + stat_buf->meas_type |= CIFISP_STAT_AUTOEXP; } if (active_meas & CIF_ISP_HIST_MEASURE_RDY) { - memcpy(&isp_dev->meas_stats.stat.params.hist, - &stat_buf->params.hist, - sizeof(struct cifisp_hist_stat)); - isp_dev->meas_stats.stat.meas_type |= CIFISP_STAT_HIST; + memcpy(&stat_buf->params.hist, + &isp_dev->meas_stats.stat.params.hist, + sizeof(struct cifisp_hist_stat)); + stat_buf->meas_type |= CIFISP_STAT_HIST; } - isp_dev->meas_stats.g_frame_id = meas_work->frame_id; ret = cif_isp10_img_src_ioctl(cif_dev->img_src, - PLTFRM_CIFCAM_GET_VCM_MOVE_RES, - &vcm_tim); + PLTFRM_CIFCAM_GET_VCM_MOVE_RES, + &vcm_tim); if (ret == 0) { stat_buf->subdev_stat.vcm.vcm_start_t = vcm_tim.vcm_start_t; stat_buf->subdev_stat.vcm.vcm_end_t = vcm_tim.vcm_end_t; @@ -3770,7 +3821,7 @@ static void cifisp_send_measurement( wake_up(&vb->vb2_queue->done_wq); CIFISP_DPRINT(CIFISP_DEBUG, - "Measurement done\n"); + "Measurement done\n"); vb = NULL; end: @@ -3778,15 +3829,228 @@ static void cifisp_send_measurement( vb->state = VB2_BUF_STATE_QUEUED; } +static int cifisp_s_vb_metadata( + struct cif_isp10_isp_dev *isp_dev, + struct cif_isp10_isp_readout_work *readout_work) +{ + struct cif_isp10_device *cif_dev = + container_of(isp_dev, struct cif_isp10_device, isp_dev); + struct cifisp_isp_metadata *isp_metadata = + readout_work->isp_metadata; + struct cifisp_isp_other_cfg *other_cfg = + &isp_metadata->other_cfg; + struct cifisp_isp_meas_cfg *meas_cfg = + &isp_metadata->meas_cfg; + struct cifisp_stat_buffer *stat_new = + &isp_metadata->meas_stat; + unsigned int i, j, match_id; + unsigned long int lock_flags; + + cif_isp10_sensor_mode_data_sync(cif_dev, + readout_work->frame_id, + &isp_dev->meas_stats.stat.sensor_mode); + + spin_lock_irqsave(&isp_dev->config_lock, lock_flags); + other_cfg->module_ens = 0; + for (i = 0; i < CIFISP_MEAS_ID; i++) { + match_id = 0xff; + for (j = 0; j < 3; j++) { + if (readout_work->frame_id >= + isp_dev->other_cfgs.log[i].s_frame_id[j]) { + if (match_id == 0xff) + match_id = j; + else if (isp_dev->other_cfgs.log[i].s_frame_id[match_id] < + isp_dev->other_cfgs.log[i].s_frame_id[j]) + match_id = j; + } + } + + if (match_id == 0xff) { + CIFISP_DPRINT(CIFISP_ERROR, + "%s: FrameID:%d isp other config haven't found! s_frame_id:%d, %d,%d\n", + __func__, + readout_work->frame_id, + isp_dev->other_cfgs.log[i].s_frame_id[0], + isp_dev->other_cfgs.log[i].s_frame_id[1], + isp_dev->other_cfgs.log[i].s_frame_id[2]); + match_id = isp_dev->other_cfgs.log[i].curr_id; + } + + other_cfg->module_ens |= + (isp_dev->other_cfgs.cfgs[match_id].module_ens & + (1 << i)); + + switch (i) { + case CIFISP_DPCC_ID: + memcpy(&other_cfg->dpcc_config, + &isp_dev->other_cfgs.cfgs[match_id].dpcc_config, + sizeof(other_cfg->dpcc_config)); + break; + case CIFISP_BLS_ID: + memcpy(&other_cfg->bls_config, + &isp_dev->other_cfgs.cfgs[match_id].bls_config, + sizeof(other_cfg->bls_config)); + break; + case CIFISP_SDG_ID: + memcpy(&other_cfg->sdg_config, + &isp_dev->other_cfgs.cfgs[match_id].sdg_config, + sizeof(other_cfg->sdg_config)); + break; + case CIFISP_LSC_ID: + memcpy(&other_cfg->lsc_config, + &isp_dev->other_cfgs.cfgs[match_id].lsc_config, + sizeof(other_cfg->lsc_config)); + break; + case CIFISP_AWB_GAIN_ID: + if (CIFISP_MODULE_IS_EN(other_cfg->module_ens, + CIFISP_MODULE_AWB_GAIN)) { + memcpy(&other_cfg->awb_gain_config, + &isp_dev->other_cfgs.cfgs[match_id].awb_gain_config, + sizeof(other_cfg->awb_gain_config)); + } else { + unsigned int reg = cifisp_ioread32(CIF_ISP_AWB_GAIN_RB); + + other_cfg->awb_gain_config.gain_red = + (unsigned short)CIFISP_AWB_GAIN_R_READ(reg); + other_cfg->awb_gain_config.gain_blue = + (unsigned short)CIFISP_AWB_GAIN_B_READ(reg); + reg = cifisp_ioread32(CIF_ISP_AWB_GAIN_RB); + other_cfg->awb_gain_config.gain_green_r = + (unsigned short)CIFISP_AWB_GAIN_R_READ(reg); + other_cfg->awb_gain_config.gain_green_b = + (unsigned short)CIFISP_AWB_GAIN_B_READ(reg); + } + break; + case CIFISP_FLT_ID: + memcpy(&other_cfg->flt_config, + &isp_dev->other_cfgs.cfgs[match_id].flt_config, + sizeof(other_cfg->flt_config)); + break; + case CIFISP_BDM_ID: + memcpy(&other_cfg->bdm_config, + &isp_dev->other_cfgs.cfgs[match_id].bdm_config, + sizeof(other_cfg->bdm_config)); + break; + case CIFISP_CTK_ID: + if (CIFISP_MODULE_IS_EN(other_cfg->module_ens, + CIFISP_MODULE_CTK)) { + memcpy(&other_cfg->ctk_config, + &isp_dev->other_cfgs.cfgs[match_id].ctk_config, + sizeof(other_cfg->ctk_config)); + } else { + other_cfg->ctk_config.coeff0 = cifisp_ioread32(CIF_ISP_CT_COEFF_0); + other_cfg->ctk_config.coeff1 = cifisp_ioread32(CIF_ISP_CT_COEFF_1); + other_cfg->ctk_config.coeff2 = cifisp_ioread32(CIF_ISP_CT_COEFF_2); + other_cfg->ctk_config.coeff3 = cifisp_ioread32(CIF_ISP_CT_COEFF_3); + other_cfg->ctk_config.coeff4 = cifisp_ioread32(CIF_ISP_CT_COEFF_4); + other_cfg->ctk_config.coeff5 = cifisp_ioread32(CIF_ISP_CT_COEFF_5); + other_cfg->ctk_config.coeff6 = cifisp_ioread32(CIF_ISP_CT_COEFF_6); + other_cfg->ctk_config.coeff7 = cifisp_ioread32(CIF_ISP_CT_COEFF_7); + other_cfg->ctk_config.coeff8 = cifisp_ioread32(CIF_ISP_CT_COEFF_8); + } + break; + case CIFISP_GOC_ID: + memcpy(&other_cfg->goc_config, + &isp_dev->other_cfgs.cfgs[match_id].goc_config, + sizeof(other_cfg->goc_config)); + break; + case CIFISP_CPROC_ID: + memcpy(&other_cfg->cproc_config, + &isp_dev->other_cfgs.cfgs[match_id].cproc_config, + sizeof(other_cfg->cproc_config)); + break; + case CIFISP_IE_ID: + memcpy(&other_cfg->ie_config, + &isp_dev->other_cfgs.cfgs[match_id].ie_config, + sizeof(other_cfg->ie_config)); + break; + case CIFISP_DPF_ID: + memcpy(&other_cfg->dpf_config, + &isp_dev->other_cfgs.cfgs[match_id].dpf_config, + sizeof(other_cfg->dpf_config)); + break; + case CIFISP_DPF_STRENGTH_ID: + memcpy(&other_cfg->dpf_strength_config, + &isp_dev->other_cfgs.cfgs[match_id].dpf_strength_config, + sizeof(other_cfg->dpf_strength_config)); + break; + default: + break; + } + } + + meas_cfg->module_ens = 0; + for (i = CIFISP_MEAS_ID; i < CIFISP_MODULE_MAX; i++) { + match_id = 0xff; + for (j = 0; j < 3; j++) { + if (readout_work->frame_id >= + isp_dev->meas_cfgs.log[i].s_frame_id[j]) { + if (match_id == 0xff) + match_id = j; + else if (isp_dev->meas_cfgs.log[i].s_frame_id[match_id] < + isp_dev->meas_cfgs.log[i].s_frame_id[j]) + match_id = j; + } + } + + if (match_id == 0xff) { + CIFISP_DPRINT(CIFISP_ERROR, + "%s: FrameID:%d isp meas config haven't found! s_frame_id:%d, %d,%d\n", + __func__, + readout_work->frame_id, + isp_dev->meas_cfgs.log[i].s_frame_id[0], + isp_dev->meas_cfgs.log[i].s_frame_id[1], + isp_dev->meas_cfgs.log[i].s_frame_id[2]); + match_id = isp_dev->meas_cfgs.log[i].curr_id; + } + switch (i) { + case CIFISP_AFC_ID: + memcpy(&meas_cfg->afc_config, + &isp_dev->meas_cfgs.cfgs[match_id].afc_config, + sizeof(meas_cfg->afc_config)); + break; + case CIFISP_AEC_ID: + memcpy(&meas_cfg->aec_config, + &isp_dev->meas_cfgs.cfgs[match_id].aec_config, + sizeof(meas_cfg->aec_config)); + break; + case CIFISP_AWB_ID: + memcpy(&meas_cfg->awb_meas_config, + &isp_dev->meas_cfgs.cfgs[match_id].awb_meas_config, + sizeof(meas_cfg->awb_meas_config)); + break; + case CIFISP_HST_ID: + memcpy(&meas_cfg->hst_config, + &isp_dev->meas_cfgs.cfgs[match_id].hst_config, + sizeof(meas_cfg->hst_config)); + break; + default: + break; + } + + meas_cfg->module_ens |= + (isp_dev->meas_cfgs.cfgs[match_id].module_ens & + (1 << i)); + } + + if (isp_dev->meas_stats.g_frame_id >= + readout_work->frame_id) { + memcpy(stat_new, + &isp_dev->meas_stats.stat, + sizeof(*stat_new)); + } + spin_unlock_irqrestore(&isp_dev->config_lock, lock_flags); + + cif_isp10_s_vb_metadata(cif_dev, readout_work); + return 0; +} + void cifisp_isp_readout_work(struct work_struct *work) { struct cif_isp10_isp_readout_work *readout_work = (struct cif_isp10_isp_readout_work *)work; struct cif_isp10_isp_dev *isp_dev = readout_work->isp_dev; - struct cif_isp10_device *cif_dev = - container_of(isp_dev, struct cif_isp10_device, isp_dev); - unsigned long int lock_flags; if (!isp_dev->streamon) return; @@ -3797,51 +4061,10 @@ void cifisp_isp_readout_work(struct work_struct *work) break; case CIF_ISP10_ISP_READOUT_META: { - struct cifisp_isp_other_cfg *other_new = NULL; - struct cifisp_isp_meas_cfg *meas_new = NULL; - struct cifisp_stat_buffer *stat_new = NULL; - - spin_lock_irqsave(&isp_dev->config_lock, lock_flags); - - if (isp_dev->other_cfgs.module_updates == 0) { - if (readout_work->frame_id == - isp_dev->other_cfgs.curr->s_frame_id) - other_new = isp_dev->other_cfgs.last_or_new; - else if (readout_work->frame_id > - isp_dev->other_cfgs.curr->s_frame_id) - other_new = isp_dev->other_cfgs.curr; - else - other_new = NULL; - } - - if (isp_dev->meas_cfgs.module_updates == 0) { - if (readout_work->frame_id == - isp_dev->meas_cfgs.curr->s_frame_id) - meas_new = isp_dev->meas_cfgs.last_or_new; - else if (readout_work->frame_id > - isp_dev->meas_cfgs.curr->s_frame_id) - meas_new = isp_dev->meas_cfgs.curr; - else - meas_new = NULL; - } - - if ((isp_dev->meas_stats.g_frame_id == - readout_work->frame_id) && - isp_dev->meas_stats.stat.meas_type) - stat_new = &isp_dev->meas_stats.stat; - else - stat_new = NULL; - - cif_isp10_s_isp_metadata( - cif_dev, - readout_work, - other_new, - meas_new, - stat_new); - spin_unlock_irqrestore(&isp_dev->config_lock, lock_flags); - + cifisp_s_vb_metadata(isp_dev, readout_work); break; } + default: break; } @@ -3849,398 +4072,250 @@ void cifisp_isp_readout_work(struct work_struct *work) kfree((void *)work); } -static inline bool cifisp_isp_isr_other_config( +static bool cifisp_isp_isr_other_config( struct cif_isp10_isp_dev *isp_dev, unsigned int *time_left) { unsigned int time_in = *time_left; bool config_chk; + unsigned int new_id; + unsigned int i, j; unsigned int *ens; + unsigned int *actives = &isp_dev->other_cfgs.module_actives; - ens = &isp_dev->other_cfgs.last_or_new->module_ens; + for (i = 0; i < CIFISP_MEAS_ID; i++) { + if (CIFISP_MODULE_IS_UNACTIVE(*actives, (1 << i))) + continue; - if (CIFISP_MODULE_IS_UPDATE( - isp_dev->other_cfgs.module_updates, - CIFISP_MODULE_DPCC)) { - /*update dpc config */ - cifisp_dpcc_config(isp_dev); - - if (CIFISP_MODULE_IS_EN(*ens, CIFISP_MODULE_DPCC)) - cifisp_dpcc_en(isp_dev); - else - cifisp_dpcc_end(isp_dev); - - CIFISP_MODULE_CLR_UPDATE( + if (CIFISP_MODULE_IS_UPDATE( isp_dev->other_cfgs.module_updates, - CIFISP_MODULE_DPCC); + (1 << i))) { + new_id = isp_dev->other_cfgs.log[i].new_id; + ens = &isp_dev->other_cfgs.cfgs[new_id].module_ens; - *time_left -= CIFISP_MODULE_DPCC_PROC_TIME; + switch (i) { + case CIFISP_DPCC_ID: + /*update dpc config */ + cifisp_dpcc_config(isp_dev); + if (CIFISP_MODULE_IS_EN(*ens, (1 << i))) + cifisp_dpcc_en(isp_dev); + else + cifisp_dpcc_end(isp_dev); + *time_left -= CIFISP_MODULE_DPCC_PROC_TIME; + break; + case CIFISP_BLS_ID: + /*update bls config */ + cifisp_bls_config(isp_dev); + if (CIFISP_MODULE_IS_EN(*ens, (1 << i))) + cifisp_bls_en(isp_dev); + else + cifisp_bls_end(isp_dev); + *time_left -= CIFISP_MODULE_BLS_PROC_TIME; + break; + case CIFISP_SDG_ID: + /*update sdg config */ + cifisp_sdg_config(isp_dev); + if (CIFISP_MODULE_IS_EN(*ens, (1 << i))) + cifisp_sdg_en(isp_dev); + else + cifisp_sdg_end(isp_dev); + *time_left -= CIFISP_MODULE_SDG_PROC_TIME; + break; + case CIFISP_LSC_ID: { + bool res = true; - CIFISP_DPRINT(CIFISP_DEBUG, - "dpcc time-left :%d\n", - *time_left); - } + if (CIFISP_MODULE_IS_EN(*ens, (1 << i))) { + if (!cifisp_lsc_config(isp_dev)) + res = false; + } else { + cifisp_lsc_end(isp_dev); + } + *time_left -= CIFISP_MODULE_LSC_PROC_TIME; + break; + } + case CIFISP_AWB_GAIN_ID: + /*update awb gains */ + cifisp_awb_gain_config(isp_dev); + *time_left -= CIFISP_MODULE_AWB_GAIN_PROC_TIME; + break; + case CIFISP_BDM_ID: + /*update bdm config */ + cifisp_bdm_config(isp_dev); + if (CIFISP_MODULE_IS_EN(*ens, (1 << i))) + cifisp_bdm_en(isp_dev); + else + cifisp_bdm_end(isp_dev); + *time_left -= CIFISP_MODULE_BDM_PROC_TIME; + break; + case CIFISP_FLT_ID: + /*update filter config */ + cifisp_flt_config(isp_dev); + if (CIFISP_MODULE_IS_EN(*ens, (1 << i))) + cifisp_flt_en(isp_dev); + else + cifisp_flt_end(isp_dev); + *time_left -= CIFISP_MODULE_FLT_PROC_TIME; + break; + case CIFISP_CTK_ID: + /*update ctk config */ + cifisp_ctk_config(isp_dev); + if (CIFISP_MODULE_IS_EN(*ens, (1 << i))) + cifisp_ctk_en(isp_dev); + else + cifisp_ctk_end(isp_dev); + *time_left -= CIFISP_MODULE_CTK_PROC_TIME; + break; + case CIFISP_GOC_ID: + /*update goc config */ + cifisp_goc_config(isp_dev); + if (CIFISP_MODULE_IS_EN(*ens, (1 << i))) + cifisp_goc_en(isp_dev); + else + cifisp_goc_end(isp_dev); + *time_left -= CIFISP_MODULE_GOC_PROC_TIME; + break; + case CIFISP_CPROC_ID: + /*update cprc config */ + cifisp_cproc_config( + isp_dev, + isp_dev->quantization); + cifisp_csm_config( + isp_dev, + isp_dev->quantization); + if (CIFISP_MODULE_IS_EN(*ens, (1 << i))) + cifisp_cproc_en(isp_dev); + else + cifisp_cproc_end(isp_dev); - if (CIFISP_MODULE_IS_UPDATE( - isp_dev->other_cfgs.module_updates, - CIFISP_MODULE_BLS) && - *time_left >= CIFISP_MODULE_BLS_PROC_TIME) { - /* update bls config */ - cifisp_bls_config(isp_dev); + *time_left -= CIFISP_MODULE_CPROC_PROC_TIME; + break; + case CIFISP_IE_ID: + /*update ie config */ + cifisp_ie_config(isp_dev); + if (CIFISP_MODULE_IS_EN(*ens, (1 << i))) + cifisp_ie_en(isp_dev); + else + cifisp_ie_end(isp_dev); + *time_left -= CIFISP_MODULE_IE_PROC_TIME; + break; + case CIFISP_DPF_ID: + /*update dpf config */ + cifisp_dpf_config(isp_dev); + if (CIFISP_MODULE_IS_EN(*ens, (1 << i))) + cifisp_dpf_en(isp_dev); + else + cifisp_dpf_end(isp_dev); + *time_left -= CIFISP_MODULE_DPF_TIME; + break; + case CIFISP_DPF_STRENGTH_ID: + /*update dpf strength config */ + cifisp_dpf_strength_config(isp_dev); + *time_left -= CIFISP_MODULE_DPF_STRENGTH_TIME; + break; + default: + break; + } - if (CIFISP_MODULE_IS_EN(*ens, CIFISP_MODULE_BLS)) - cifisp_bls_en(isp_dev); - else - cifisp_bls_end(isp_dev); - - CIFISP_MODULE_CLR_UPDATE( - isp_dev->other_cfgs.module_updates, - CIFISP_MODULE_BLS); - - *time_left -= CIFISP_MODULE_BLS_PROC_TIME; - CIFISP_DPRINT(CIFISP_DEBUG, - "bls time-left :%d\n", - *time_left); - } - - if (CIFISP_MODULE_IS_UPDATE( - isp_dev->other_cfgs.module_updates, - CIFISP_MODULE_SDG) && - *time_left >= CIFISP_MODULE_SDG_PROC_TIME) { - /* update sdg config */ - cifisp_sdg_config(isp_dev); - - if (CIFISP_MODULE_IS_EN(*ens, CIFISP_MODULE_SDG)) - cifisp_sdg_en(isp_dev); - else - cifisp_sdg_end(isp_dev); - - CIFISP_MODULE_CLR_UPDATE( - isp_dev->other_cfgs.module_updates, - CIFISP_MODULE_SDG); - - *time_left -= CIFISP_MODULE_SDG_PROC_TIME; - CIFISP_DPRINT(CIFISP_DEBUG, - "sdg time-left :%d\n", - *time_left); - } - - if (CIFISP_MODULE_IS_UPDATE( - isp_dev->other_cfgs.module_updates, - CIFISP_MODULE_LSC) && - *time_left >= CIFISP_MODULE_LSC_PROC_TIME) { - /* update lsc config */ - bool res = true; - - if (CIFISP_MODULE_IS_EN(*ens, CIFISP_MODULE_LSC)) { - if (!cifisp_lsc_config(isp_dev)) - res = false; - } else { - cifisp_lsc_end(isp_dev); - } - - if (res) + isp_dev->other_cfgs.log[i].s_frame_id[new_id] = + isp_dev->frame_id; + isp_dev->other_cfgs.log[i].curr_id = new_id; + new_id = 0; + for (j = 0; j < 3; j++) { + if (isp_dev->other_cfgs.log[i].s_frame_id[new_id] > + isp_dev->other_cfgs.log[i].s_frame_id[j]) + new_id = j; + } + isp_dev->other_cfgs.log[i].new_id = new_id; CIFISP_MODULE_CLR_UPDATE( isp_dev->other_cfgs.module_updates, - CIFISP_MODULE_LSC); - - *time_left -= CIFISP_MODULE_LSC_PROC_TIME; - CIFISP_DPRINT(CIFISP_DEBUG, - "lsc time-left :%d\n", - *time_left); - } - - if (CIFISP_MODULE_IS_UPDATE( - isp_dev->other_cfgs.module_updates, - CIFISP_MODULE_AWB_GAIN) && - *time_left >= CIFISP_MODULE_AWB_GAIN_PROC_TIME) { - /* update awb gains */ - cifisp_awb_gain_config(isp_dev); - - if (CIFISP_MODULE_IS_EN(*ens, CIFISP_MODULE_AWB_GAIN)) - cifisp_awb_gain_en(isp_dev); - else - cifisp_awb_gain_end(isp_dev); - - CIFISP_MODULE_CLR_UPDATE( - isp_dev->other_cfgs.module_updates, - CIFISP_MODULE_AWB_GAIN); - - *time_left -= CIFISP_MODULE_AWB_GAIN_PROC_TIME; - CIFISP_DPRINT(CIFISP_DEBUG, - "awb-g time-left :%d\n", - *time_left); - } - - if (CIFISP_MODULE_IS_UPDATE( - isp_dev->other_cfgs.module_updates, - CIFISP_MODULE_BDM) && - *time_left >= CIFISP_MODULE_BDM_PROC_TIME) { - /* update bdm config */ - cifisp_bdm_config(isp_dev); - - if (CIFISP_MODULE_IS_EN(*ens, CIFISP_MODULE_BDM)) - cifisp_bdm_en(isp_dev); - else - cifisp_bdm_end(isp_dev); - - CIFISP_MODULE_CLR_UPDATE( - isp_dev->other_cfgs.module_updates, - CIFISP_MODULE_BDM); - - *time_left -= CIFISP_MODULE_BDM_PROC_TIME; - CIFISP_DPRINT(CIFISP_DEBUG, - "bdm time-left :%d\n", - *time_left); - } - - if (CIFISP_MODULE_IS_UPDATE( - isp_dev->other_cfgs.module_updates, - CIFISP_MODULE_FLT) && - *time_left >= CIFISP_MODULE_FLT_PROC_TIME) { - /* update filter config */ - cifisp_flt_config(isp_dev); - - if (CIFISP_MODULE_IS_EN(*ens, CIFISP_MODULE_FLT)) - cifisp_flt_en(isp_dev); - else - cifisp_flt_end(isp_dev); - - CIFISP_MODULE_CLR_UPDATE( - isp_dev->other_cfgs.module_updates, - CIFISP_MODULE_FLT); - - *time_left -= CIFISP_MODULE_FLT_PROC_TIME; - CIFISP_DPRINT(CIFISP_DEBUG, - "flt time-left :%d\n", - *time_left); - } - - if (CIFISP_MODULE_IS_UPDATE( - isp_dev->other_cfgs.module_updates, - CIFISP_MODULE_CTK) && - *time_left >= CIFISP_MODULE_CTK_PROC_TIME) { - /* update ctk config */ - cifisp_ctk_config(isp_dev); - - if (CIFISP_MODULE_IS_EN(*ens, CIFISP_MODULE_CTK)) - cifisp_ctk_en(isp_dev); - else - cifisp_ctk_end(isp_dev); - - CIFISP_MODULE_CLR_UPDATE( - isp_dev->other_cfgs.module_updates, - CIFISP_MODULE_CTK); - - *time_left -= CIFISP_MODULE_CTK_PROC_TIME; - CIFISP_DPRINT(CIFISP_DEBUG, - "ctk time-left :%d\n", - *time_left); - } - - if (CIFISP_MODULE_IS_UPDATE( - isp_dev->other_cfgs.module_updates, - CIFISP_MODULE_GOC) && - *time_left >= CIFISP_MODULE_GOC_PROC_TIME) { - /* update goc config */ - cifisp_goc_config(isp_dev); - - if (CIFISP_MODULE_IS_EN(*ens, CIFISP_MODULE_GOC)) - cifisp_goc_en(isp_dev); - else - cifisp_goc_end(isp_dev); - - CIFISP_MODULE_CLR_UPDATE( - isp_dev->other_cfgs.module_updates, - CIFISP_MODULE_IE); - - *time_left -= CIFISP_MODULE_GOC_PROC_TIME; - CIFISP_DPRINT(CIFISP_DEBUG, - "goc time-left :%d\n", - *time_left); - } - - if (CIFISP_MODULE_IS_UPDATE( - isp_dev->other_cfgs.module_updates, - CIFISP_MODULE_CPROC) && - *time_left >= CIFISP_MODULE_CPROC_PROC_TIME) { - /* update cprc config */ - cifisp_cproc_config( - isp_dev, - isp_dev->quantization); - - cifisp_csm_config(isp_dev, - isp_dev->quantization); - - if (CIFISP_MODULE_IS_EN(*ens, CIFISP_MODULE_CPROC)) - cifisp_cproc_en(isp_dev); - else - cifisp_cproc_end(isp_dev); - - CIFISP_MODULE_CLR_UPDATE( - isp_dev->other_cfgs.module_updates, - CIFISP_MODULE_CPROC); - - *time_left -= CIFISP_MODULE_CPROC_PROC_TIME; - CIFISP_DPRINT(CIFISP_DEBUG, - "cproc time-left :%d\n", - *time_left); - } - - if (CIFISP_MODULE_IS_UPDATE( - isp_dev->other_cfgs.module_updates, - CIFISP_MODULE_IE) && - *time_left >= CIFISP_MODULE_IE_PROC_TIME) { - /* update ie config */ - cifisp_ie_config(isp_dev); - - if (CIFISP_MODULE_IS_EN(*ens, CIFISP_MODULE_IE)) - cifisp_ie_en(isp_dev); - else - cifisp_ie_end(isp_dev); - - CIFISP_MODULE_CLR_UPDATE( - isp_dev->other_cfgs.module_updates, - CIFISP_MODULE_IE); - - *time_left -= CIFISP_MODULE_IE_PROC_TIME; - CIFISP_DPRINT(CIFISP_DEBUG, - "ie time-left :%d\n", - *time_left); - } - - if (CIFISP_MODULE_IS_UPDATE( - isp_dev->other_cfgs.module_updates, - CIFISP_MODULE_DPF) && - *time_left >= CIFISP_MODULE_DPF_TIME) { - /* update dpf config */ - cifisp_dpf_config(isp_dev); - - if (CIFISP_MODULE_IS_EN(*ens, CIFISP_MODULE_DPF)) - cifisp_dpf_en(isp_dev); - else - cifisp_dpf_end(isp_dev); - - CIFISP_MODULE_CLR_UPDATE( - isp_dev->other_cfgs.module_updates, - CIFISP_MODULE_DPF); - - *time_left -= CIFISP_MODULE_DPF_TIME; - CIFISP_DPRINT(CIFISP_DEBUG, - "dpf time-left :%d\n", - *time_left); - } - - if (CIFISP_MODULE_IS_UPDATE( - isp_dev->other_cfgs.module_updates, - CIFISP_MODULE_DPF_STRENGTH) && - *time_left >= CIFISP_MODULE_DPF_STRENGTH_TIME) { - if (CIFISP_MODULE_IS_EN(*ens, CIFISP_MODULE_DPF)) { - /* update dpf strength config */ - cifisp_dpf_strength_config(isp_dev); - cifisp_dpf_en(isp_dev); - } else { - cifisp_dpf_end(isp_dev); + (1 << i)); } - - CIFISP_MODULE_CLR_UPDATE( - isp_dev->other_cfgs.module_updates, - CIFISP_MODULE_DPF_STRENGTH); - - *time_left -= CIFISP_MODULE_DPF_STRENGTH_TIME; - CIFISP_DPRINT(CIFISP_DEBUG, - "dpf strength time-left :%d\n", - *time_left); } config_chk = time_in > *time_left; - if (config_chk) - cifisp_other_config_swap(isp_dev); return config_chk; } -static inline bool cifisp_isp_isr_meas_config( +static bool cifisp_isp_isr_meas_config( struct cif_isp10_isp_dev *isp_dev, unsigned int *time_left) { unsigned int time_in = *time_left; bool config_chk; + unsigned int new_id; + unsigned int i, j; unsigned int *ens; + unsigned int *actives = &isp_dev->meas_cfgs.module_actives; - ens = &isp_dev->meas_cfgs.last_or_new->module_ens; + for (i = CIFISP_MEAS_ID; i < CIFISP_MODULE_MAX; i++) { + if (CIFISP_MODULE_IS_UNACTIVE(*actives, (1 << i))) + continue; - if (CIFISP_MODULE_IS_UPDATE( - isp_dev->meas_cfgs.module_updates, - CIFISP_MODULE_AWB)) { - /* update awb config */ - cifisp_awb_meas_config(isp_dev); - - if (CIFISP_MODULE_IS_EN(*ens, CIFISP_MODULE_AWB)) - cifisp_awb_meas_en(isp_dev); - else - cifisp_awb_meas_end(isp_dev); - - CIFISP_MODULE_CLR_UPDATE( + if (CIFISP_MODULE_IS_UPDATE( isp_dev->meas_cfgs.module_updates, - CIFISP_MODULE_AWB); - *time_left -= CIFISP_MODULE_AWB_PROC_TIME; - } + (1 << i))) { + new_id = isp_dev->meas_cfgs.log[i].new_id; + ens = &isp_dev->meas_cfgs.cfgs[new_id].module_ens; - if (CIFISP_MODULE_IS_UPDATE( - isp_dev->meas_cfgs.module_updates, - CIFISP_MODULE_AFC)) { - /* update afc config */ - cifisp_afc_config(isp_dev); + switch (i) { + case CIFISP_AWB_ID: + /*update dpc config */ + cifisp_awb_meas_config(isp_dev); + if (CIFISP_MODULE_IS_EN(*ens, (1 << i))) + cifisp_awb_meas_en(isp_dev); + else + cifisp_awb_meas_end(isp_dev); + *time_left -= CIFISP_MODULE_AWB_PROC_TIME; + break; + case CIFISP_AEC_ID: + /*update aec config */ + cifisp_aec_config(isp_dev); + if (CIFISP_MODULE_IS_EN(*ens, (1 << i))) + cifisp_aec_en(isp_dev); + else + cifisp_aec_end(isp_dev); + *time_left -= CIFISP_MODULE_AEC_PROC_TIME; + break; + case CIFISP_AFC_ID: + /*update afc config */ + cifisp_afc_config(isp_dev); + if (CIFISP_MODULE_IS_EN(*ens, (1 << i))) + cifisp_afc_en(isp_dev); + else + cifisp_afc_end(isp_dev); + *time_left -= CIFISP_MODULE_AFC_PROC_TIME; + break; + case CIFISP_HST_ID: + /*update hst config */ + cifisp_hst_config(isp_dev); + if (CIFISP_MODULE_IS_EN(*ens, (1 << i))) + cifisp_hst_en(isp_dev); + else + cifisp_hst_end(isp_dev); + *time_left -= CIFISP_MODULE_HST_PROC_TIME; + break; + default: + break; + } - if (CIFISP_MODULE_IS_EN(*ens, CIFISP_MODULE_AFC)) - cifisp_afc_en(isp_dev); - else - cifisp_afc_end(isp_dev); - - CIFISP_MODULE_CLR_UPDATE( - isp_dev->meas_cfgs.module_updates, - CIFISP_MODULE_AFC); - *time_left -= CIFISP_MODULE_AFC_PROC_TIME; - } - - if (CIFISP_MODULE_IS_UPDATE( - isp_dev->meas_cfgs.module_updates, - CIFISP_MODULE_HST)) { - /* update hst config */ - cifisp_hst_config(isp_dev); - - if (CIFISP_MODULE_IS_EN(*ens, CIFISP_MODULE_HST)) - cifisp_hst_en(isp_dev); - else - cifisp_hst_end(isp_dev); - - CIFISP_MODULE_CLR_UPDATE( - isp_dev->meas_cfgs.module_updates, - CIFISP_MODULE_HST); - *time_left -= CIFISP_MODULE_HST_PROC_TIME; - } - - if (CIFISP_MODULE_IS_UPDATE( - isp_dev->meas_cfgs.module_updates, - CIFISP_MODULE_AEC)) { - /* update aec config */ - cifisp_aec_config(isp_dev); - - if (CIFISP_MODULE_IS_EN(*ens, CIFISP_MODULE_AEC)) - cifisp_aec_en(isp_dev); - else - cifisp_aec_end(isp_dev); - - CIFISP_MODULE_CLR_UPDATE( - isp_dev->meas_cfgs.module_updates, - CIFISP_MODULE_AEC); - *time_left -= CIFISP_MODULE_AEC_PROC_TIME; + isp_dev->meas_cfgs.log[i].s_frame_id[new_id] = + isp_dev->frame_id; + isp_dev->meas_cfgs.log[i].curr_id = new_id; + new_id = 0; + for (j = 0; j < 3; j++) { + if (isp_dev->meas_cfgs.log[i].s_frame_id[new_id] > + isp_dev->meas_cfgs.log[i].s_frame_id[j]) + new_id = j; + } + isp_dev->meas_cfgs.log[i].new_id = new_id; + CIFISP_MODULE_CLR_UPDATE( + isp_dev->meas_cfgs.module_updates, + (1 << i)); + } } config_chk = time_in > *time_left; - if (config_chk) - cifisp_meas_config_swap(isp_dev); return config_chk; } @@ -4248,59 +4323,76 @@ static inline bool cifisp_isp_isr_meas_config( int cifisp_isp_isr(struct cif_isp10_isp_dev *isp_dev, u32 isp_mis) { unsigned int isp_mis_tmp = 0; - struct cif_isp10_isp_readout_work *work; unsigned int time_left = isp_dev->v_blanking_us; + unsigned int active_meas = 0; + #ifdef LOG_ISR_EXE_TIME ktime_t in_t = ktime_get(); #endif if (isp_mis & (CIF_ISP_DATA_LOSS | CIF_ISP_PIC_SIZE_ERROR)) return 0; + cifisp_iowrite32( + (isp_mis & (CIF_ISP_AWB_DONE | CIF_ISP_AFM_FIN | + CIF_ISP_EXP_END | CIF_ISP_HIST_MEASURE_RDY)), + CIF_ISP_ICR); + isp_mis_tmp = cifisp_ioread32(CIF_ISP_MIS); + if (isp_mis_tmp & + (isp_mis & (CIF_ISP_AWB_DONE | CIF_ISP_AFM_FIN | + CIF_ISP_EXP_END | CIF_ISP_HIST_MEASURE_RDY))) + CIFISP_DPRINT(CIFISP_ERROR, + "isp icr 3A info err: 0x%x\n", + isp_mis_tmp); + + if (isp_mis & CIF_ISP_AWB_DONE) { + isp_dev->awb_meas_ready = true; + cifisp_get_awb_meas(isp_dev, &isp_dev->meas_stats.stat); + } + if (isp_mis & CIF_ISP_AFM_FIN) { + isp_dev->afm_meas_ready = true; + cifisp_get_afc_meas(isp_dev, &isp_dev->meas_stats.stat); + } + if (isp_mis & CIF_ISP_EXP_END) { + isp_dev->aec_meas_ready = true; + cifisp_get_aec_meas(isp_dev, &isp_dev->meas_stats.stat); + cifisp_bls_get_meas(isp_dev, &isp_dev->meas_stats.stat); + isp_dev->meas_stats.g_frame_id = isp_dev->frame_id; + } + + if (isp_mis & CIF_ISP_HIST_MEASURE_RDY) { + isp_dev->hst_meas_ready = true; + cifisp_get_hst_meas(isp_dev, &isp_dev->meas_stats.stat); + } + + if ((isp_dev->meas_send_alone & CIF_ISP_AWB_DONE) && isp_dev->awb_meas_ready) { + isp_dev->awb_meas_ready = false; + cifisp_meas_queue_work(isp_dev, CIF_ISP_AWB_DONE); + } + if ((isp_dev->meas_send_alone & CIF_ISP_AFM_FIN) && isp_dev->afm_meas_ready) { + isp_dev->afm_meas_ready = false; + cifisp_meas_queue_work(isp_dev, CIF_ISP_AFM_FIN); + } + if ((isp_dev->meas_send_alone & (CIF_ISP_EXP_END | CIF_ISP_HIST_MEASURE_RDY)) && + isp_dev->aec_meas_ready && isp_dev->hst_meas_ready) { + isp_dev->aec_meas_ready = false; + isp_dev->hst_meas_ready = false; + cifisp_meas_queue_work(isp_dev, CIF_ISP_EXP_END | CIF_ISP_HIST_MEASURE_RDY); + } + if (isp_mis & CIF_ISP_FRAME) { - u32 isp_ris = cifisp_ioread32(CIF_ISP_RIS); + active_meas = isp_dev->active_meas; + active_meas &= ~isp_dev->meas_send_alone; - cifisp_iowrite32( - (CIF_ISP_AWB_DONE | CIF_ISP_AFM_FIN | - CIF_ISP_EXP_END | CIF_ISP_HIST_MEASURE_RDY), - CIF_ISP_ICR); - isp_mis_tmp = cifisp_ioread32(CIF_ISP_MIS); - if (isp_mis_tmp & - (CIF_ISP_AWB_DONE | CIF_ISP_AFM_FIN | - CIF_ISP_EXP_END | CIF_ISP_HIST_MEASURE_RDY)) - CIFISP_DPRINT(CIFISP_ERROR, - "isp icr 3A info err: 0x%x\n", - isp_mis_tmp); + if (!(isp_dev->meas_send_alone & CIF_ISP_AWB_DONE)) + isp_dev->awb_meas_ready = false; + if (!(isp_dev->meas_send_alone & CIF_ISP_AFM_FIN)) + isp_dev->afm_meas_ready = false; + if (!(isp_dev->meas_send_alone & CIF_ISP_EXP_END)) + isp_dev->aec_meas_ready = false; + if (!(isp_dev->meas_send_alone & CIF_ISP_HIST_MEASURE_RDY)) + isp_dev->hst_meas_ready = false; - CIFISP_DPRINT(CIFISP_DEBUG, "isp_ris 0x%x\n", isp_ris); - - if (((isp_dev->meas_cfgs.module_updates & - (CIFISP_MODULE_AWB | - CIFISP_MODULE_AEC | - CIFISP_MODULE_AFC)) == 0) && - isp_dev->active_meas && - ((isp_dev->active_meas & isp_ris) == - isp_dev->active_meas)) { - work = (struct cif_isp10_isp_readout_work *) - kmalloc(sizeof( - struct cif_isp10_isp_readout_work), - GFP_ATOMIC); - if (work) { - INIT_WORK((struct work_struct *)work, - cifisp_isp_readout_work); - work->readout = CIF_ISP10_ISP_READOUT_MEAS; - work->isp_dev = isp_dev; - work->frame_id = isp_dev->frame_id; - if (!queue_work(isp_dev->readout_wq, - (struct work_struct *)work)) { - CIFISP_DPRINT(CIFISP_ERROR, - "Could not schedule work\n"); - kfree((void *)work); - } - } else { - CIFISP_DPRINT(CIFISP_ERROR, - "Could not allocate work\n"); - } - } + cifisp_meas_queue_work(isp_dev, active_meas); /* * Then update changed configs. Some of them involve @@ -4330,27 +4422,32 @@ int cifisp_isp_isr(struct cif_isp10_isp_dev *isp_dev, u32 isp_mis) return 0; } +void cifisp_clr_readout_wq(struct cif_isp10_isp_dev *isp_dev) +{ + drain_workqueue(isp_dev->readout_wq); +} + static void cifisp_param_dump(const void *config, unsigned int module) { #ifdef CIFISP_DEBUG_PARAM switch (module) { case CIFISP_MODULE_AWB_GAIN:{ - struct cifisp_awb_gain_config *pconfig = - (struct cifisp_awb_gain_config *)config; - CIFISP_DPRINT(CIFISP_DEBUG, - "#### %s: AWB Gain Parameters - BEGIN ####\n", - ISP_VDEV_NAME); - CIFISP_DPRINT(CIFISP_DEBUG, "g_g: %d\n", - pconfig->gain_green_r); - CIFISP_DPRINT(CIFISP_DEBUG, "g_b: %d\n", - pconfig->gain_green_b); - CIFISP_DPRINT(CIFISP_DEBUG, "r: %d\n", - pconfig->gain_red); - CIFISP_DPRINT(CIFISP_DEBUG, "b: %d\n", - pconfig->gain_blue); - CIFISP_DPRINT(CIFISP_DEBUG, - "#### %s: AWB Gain Parameters - END ####\n", - ISP_VDEV_NAME); + struct cifisp_awb_gain_config *pconfig = + (struct cifisp_awb_gain_config *)config; + CIFISP_DPRINT(CIFISP_DEBUG, + "#### %s: AWB Gain Parameters - BEGIN ####\n", + ISP_VDEV_NAME); + CIFISP_DPRINT(CIFISP_DEBUG, "g_g: %d\n", + pconfig->gain_green_r); + CIFISP_DPRINT(CIFISP_DEBUG, "g_b: %d\n", + pconfig->gain_green_b); + CIFISP_DPRINT(CIFISP_DEBUG, "r: %d\n", + pconfig->gain_red); + CIFISP_DPRINT(CIFISP_DEBUG, "b: %d\n", + pconfig->gain_blue); + CIFISP_DPRINT(CIFISP_DEBUG, + "#### %s: AWB Gain Parameters - END ####\n", + ISP_VDEV_NAME); } break; case CIFISP_MODULE_DPCC:{ @@ -4358,414 +4455,413 @@ static void cifisp_param_dump(const void *config, unsigned int module) break; case CIFISP_MODULE_BLS:{ - struct cifisp_bls_config *pconfig = - (struct cifisp_bls_config *)config; - struct cifisp_bls_fixed_val *pval = &pconfig->fixed_val; + struct cifisp_bls_config *pconfig = + (struct cifisp_bls_config *)config; + struct cifisp_bls_fixed_val *pval = &pconfig->fixed_val; - CIFISP_DPRINT(CIFISP_DEBUG, - "#### %s: BLS Parameters - BEGIN ####\n", - ISP_VDEV_NAME); - CIFISP_DPRINT(CIFISP_DEBUG, " enable_auto: %d\n", - pconfig->enable_auto); - CIFISP_DPRINT(CIFISP_DEBUG, " en_windows: %d\n", - pconfig->en_windows); - CIFISP_DPRINT(CIFISP_DEBUG, - " bls_window1.h_offs: %d\n", - pconfig->bls_window1.h_offs); - CIFISP_DPRINT(CIFISP_DEBUG, - " bls_window1.v_offs: %d\n", - pconfig->bls_window1.v_offs); - CIFISP_DPRINT(CIFISP_DEBUG, - " bls_window1.h_size: %d\n", - pconfig->bls_window1.h_size); - CIFISP_DPRINT(CIFISP_DEBUG, - " bls_window1.v_size: %d\n", - pconfig->bls_window1.v_size); - CIFISP_DPRINT(CIFISP_DEBUG, - " bls_window2.h_offs: %d\n", - pconfig->bls_window2.h_offs); - CIFISP_DPRINT(CIFISP_DEBUG, - " bls_window2.v_offs: %d\n", - pconfig->bls_window2.v_offs); - CIFISP_DPRINT(CIFISP_DEBUG, - " bls_window2.h_size: %d\n", - pconfig->bls_window2.h_size); - CIFISP_DPRINT(CIFISP_DEBUG, - " bls_window2.v_size: %d\n", - pconfig->bls_window2.v_size); - CIFISP_DPRINT(CIFISP_DEBUG, " bls_samples: %d\n", - pconfig->bls_samples); - CIFISP_DPRINT(CIFISP_DEBUG, " fixed_A: %d\n", - pval->fixed_a); - CIFISP_DPRINT(CIFISP_DEBUG, " fixed_B: %d\n", - pval->fixed_b); - CIFISP_DPRINT(CIFISP_DEBUG, " fixed_C: %d\n", - pval->fixed_c); - CIFISP_DPRINT(CIFISP_DEBUG, " fixed_D: %d\n", - pval->fixed_d); - CIFISP_DPRINT(CIFISP_DEBUG, - "#### %s: BLS Parameters - END ####\n", - ISP_VDEV_NAME); + CIFISP_DPRINT(CIFISP_DEBUG, + "#### %s: BLS Parameters - BEGIN ####\n", + ISP_VDEV_NAME); + CIFISP_DPRINT(CIFISP_DEBUG, " enable_auto: %d\n", + pconfig->enable_auto); + CIFISP_DPRINT(CIFISP_DEBUG, " en_windows: %d\n", + pconfig->en_windows); + CIFISP_DPRINT(CIFISP_DEBUG, + " bls_window1.h_offs: %d\n", + pconfig->bls_window1.h_offs); + CIFISP_DPRINT(CIFISP_DEBUG, + " bls_window1.v_offs: %d\n", + pconfig->bls_window1.v_offs); + CIFISP_DPRINT(CIFISP_DEBUG, + " bls_window1.h_size: %d\n", + pconfig->bls_window1.h_size); + CIFISP_DPRINT(CIFISP_DEBUG, + " bls_window1.v_size: %d\n", + pconfig->bls_window1.v_size); + CIFISP_DPRINT(CIFISP_DEBUG, + " bls_window2.h_offs: %d\n", + pconfig->bls_window2.h_offs); + CIFISP_DPRINT(CIFISP_DEBUG, + " bls_window2.v_offs: %d\n", + pconfig->bls_window2.v_offs); + CIFISP_DPRINT(CIFISP_DEBUG, + " bls_window2.h_size: %d\n", + pconfig->bls_window2.h_size); + CIFISP_DPRINT(CIFISP_DEBUG, + " bls_window2.v_size: %d\n", + pconfig->bls_window2.v_size); + CIFISP_DPRINT(CIFISP_DEBUG, " bls_samples: %d\n", + pconfig->bls_samples); + CIFISP_DPRINT(CIFISP_DEBUG, " fixed_A: %d\n", + pval->fixed_a); + CIFISP_DPRINT(CIFISP_DEBUG, " fixed_B: %d\n", + pval->fixed_b); + CIFISP_DPRINT(CIFISP_DEBUG, " fixed_C: %d\n", + pval->fixed_c); + CIFISP_DPRINT(CIFISP_DEBUG, " fixed_D: %d\n", + pval->fixed_d); + CIFISP_DPRINT(CIFISP_DEBUG, + "#### %s: BLS Parameters - END ####\n", + ISP_VDEV_NAME); } break; case CIFISP_MODULE_LSC:{ - CIFISP_DPRINT(CIFISP_DEBUG, - "#### LSC Parameters - BEGIN ####\n"); - CIFISP_DPRINT(CIFISP_DEBUG, - "#### LSC Parameters - END ####\n"); + CIFISP_DPRINT(CIFISP_DEBUG, + "#### LSC Parameters - BEGIN ####\n"); + CIFISP_DPRINT(CIFISP_DEBUG, + "#### LSC Parameters - END ####\n"); } break; case CIFISP_MODULE_FLT:{ - struct cifisp_flt_config *pconfig = - (struct cifisp_flt_config *)config; - CIFISP_DPRINT(CIFISP_DEBUG, - "#### %s: FLT Parameters - BEGIN ####\n", - ISP_VDEV_NAME); - CIFISP_DPRINT(CIFISP_DEBUG, - " flt_mask_sharp0: %d\n", - pconfig->flt_mask_sharp0); - CIFISP_DPRINT(CIFISP_DEBUG, - " flt_mask_sharp1: %d\n", - pconfig->flt_mask_sharp1); - CIFISP_DPRINT(CIFISP_DEBUG, " flt_mask_diag: %d\n", - pconfig->flt_mask_diag); - CIFISP_DPRINT(CIFISP_DEBUG, - " flt_mask_blur_max: %d\n", - pconfig->flt_mask_blur_max); - CIFISP_DPRINT(CIFISP_DEBUG, " flt_mask_blur: %d\n", - pconfig->flt_mask_blur); - CIFISP_DPRINT(CIFISP_DEBUG, " flt_mask_lin: %d\n", - pconfig->flt_mask_lin); - CIFISP_DPRINT(CIFISP_DEBUG, " flt_mask_orth: %d\n", - pconfig->flt_mask_orth); - CIFISP_DPRINT(CIFISP_DEBUG, - " flt_mask_v_diag: %d\n", - pconfig->flt_mask_v_diag); - CIFISP_DPRINT(CIFISP_DEBUG, - " flt_mask_h_diag: %d\n", - pconfig->flt_mask_h_diag); - CIFISP_DPRINT(CIFISP_DEBUG, - " flt_lum_weight: %d\n", - pconfig->flt_lum_weight); - CIFISP_DPRINT(CIFISP_DEBUG, " flt_blur_th0: %d\n", - pconfig->flt_blur_th0); - CIFISP_DPRINT(CIFISP_DEBUG, " flt_blur_th1: %d\n", - pconfig->flt_blur_th1); - CIFISP_DPRINT(CIFISP_DEBUG, " flt_sharp0_th: %d\n", - pconfig->flt_sharp0_th); - CIFISP_DPRINT(CIFISP_DEBUG, " flt_sharp1_th: %d\n", - pconfig->flt_sharp1_th); - CIFISP_DPRINT(CIFISP_DEBUG, - " flt_chrom_h_mode: %d\n", - pconfig->flt_chrom_h_mode); - CIFISP_DPRINT(CIFISP_DEBUG, - " flt_chrom_v_mode: %d\n", - pconfig->flt_chrom_v_mode); - CIFISP_DPRINT(CIFISP_DEBUG, - " flt_diag_sharp_mode: %d\n", - pconfig->flt_diag_sharp_mode); - CIFISP_DPRINT(CIFISP_DEBUG, " flt_mode: %d\n", - pconfig->flt_mode); - CIFISP_DPRINT(CIFISP_DEBUG, - "#### %s: FLT Parameters - END ####\n", - ISP_VDEV_NAME); + struct cifisp_flt_config *pconfig = + (struct cifisp_flt_config *)config; + CIFISP_DPRINT(CIFISP_DEBUG, + "#### %s: FLT Parameters - BEGIN ####\n", + ISP_VDEV_NAME); + CIFISP_DPRINT(CIFISP_DEBUG, + " flt_mask_sharp0: %d\n", + pconfig->flt_mask_sharp0); + CIFISP_DPRINT(CIFISP_DEBUG, + " flt_mask_sharp1: %d\n", + pconfig->flt_mask_sharp1); + CIFISP_DPRINT(CIFISP_DEBUG, " flt_mask_diag: %d\n", + pconfig->flt_mask_diag); + CIFISP_DPRINT(CIFISP_DEBUG, + " flt_mask_blur_max: %d\n", + pconfig->flt_mask_blur_max); + CIFISP_DPRINT(CIFISP_DEBUG, " flt_mask_blur: %d\n", + pconfig->flt_mask_blur); + CIFISP_DPRINT(CIFISP_DEBUG, " flt_mask_lin: %d\n", + pconfig->flt_mask_lin); + CIFISP_DPRINT(CIFISP_DEBUG, " flt_mask_orth: %d\n", + pconfig->flt_mask_orth); + CIFISP_DPRINT(CIFISP_DEBUG, + " flt_mask_v_diag: %d\n", + pconfig->flt_mask_v_diag); + CIFISP_DPRINT(CIFISP_DEBUG, + " flt_mask_h_diag: %d\n", + pconfig->flt_mask_h_diag); + CIFISP_DPRINT(CIFISP_DEBUG, + " flt_lum_weight: %d\n", + pconfig->flt_lum_weight); + CIFISP_DPRINT(CIFISP_DEBUG, " flt_blur_th0: %d\n", + pconfig->flt_blur_th0); + CIFISP_DPRINT(CIFISP_DEBUG, " flt_blur_th1: %d\n", + pconfig->flt_blur_th1); + CIFISP_DPRINT(CIFISP_DEBUG, " flt_sharp0_th: %d\n", + pconfig->flt_sharp0_th); + CIFISP_DPRINT(CIFISP_DEBUG, " flt_sharp1_th: %d\n", + pconfig->flt_sharp1_th); + CIFISP_DPRINT(CIFISP_DEBUG, + " flt_chrom_h_mode: %d\n", + pconfig->flt_chrom_h_mode); + CIFISP_DPRINT(CIFISP_DEBUG, + " flt_chrom_v_mode: %d\n", + pconfig->flt_chrom_v_mode); + CIFISP_DPRINT(CIFISP_DEBUG, + " flt_diag_sharp_mode: %d\n", + pconfig->flt_diag_sharp_mode); + CIFISP_DPRINT(CIFISP_DEBUG, " flt_mode: %d\n", + pconfig->flt_mode); + CIFISP_DPRINT(CIFISP_DEBUG, + "#### %s: FLT Parameters - END ####\n", + ISP_VDEV_NAME); } break; case CIFISP_MODULE_BDM:{ - struct cifisp_bdm_config *pconfig = - (struct cifisp_bdm_config *)config; - CIFISP_DPRINT(CIFISP_DEBUG, - "#### %s: BDM Parameters - BEGIN ####\n", - ISP_VDEV_NAME); - CIFISP_DPRINT(CIFISP_DEBUG, " demosaic_th: %d\n", - pconfig->demosaic_th); - CIFISP_DPRINT(CIFISP_DEBUG, - "#### %s: BDM Parameters - END ####\n", - ISP_VDEV_NAME); + struct cifisp_bdm_config *pconfig = + (struct cifisp_bdm_config *)config; + CIFISP_DPRINT(CIFISP_DEBUG, + "#### %s: BDM Parameters - BEGIN ####\n", + ISP_VDEV_NAME); + CIFISP_DPRINT(CIFISP_DEBUG, " demosaic_th: %d\n", + pconfig->demosaic_th); + CIFISP_DPRINT(CIFISP_DEBUG, + "#### %s: BDM Parameters - END ####\n", + ISP_VDEV_NAME); } break; case CIFISP_MODULE_SDG:{ - struct cifisp_sdg_config *pconfig = - (struct cifisp_sdg_config *)config; - unsigned int i; + struct cifisp_sdg_config *pconfig = + (struct cifisp_sdg_config *)config; + unsigned int i; + CIFISP_DPRINT(CIFISP_DEBUG, + "#### %s: SDG Parameters - BEGIN ####\n", + ISP_VDEV_NAME); + CIFISP_DPRINT(CIFISP_DEBUG, + " RED -Curve parameters\n"); + for (i = 0; i < CIFISP_DEGAMMA_CURVE_SIZE; i++) { CIFISP_DPRINT(CIFISP_DEBUG, - "#### %s: SDG Parameters - BEGIN ####\n", - ISP_VDEV_NAME); + " gamma_y[%d]: %d\n", + pconfig->curve_r.gamma_y[i]); + } + CIFISP_DPRINT(CIFISP_DEBUG, + " GREEN -Curve parameters\n"); + for (i = 0; i < CIFISP_DEGAMMA_CURVE_SIZE; i++) { CIFISP_DPRINT(CIFISP_DEBUG, - " RED -Curve parameters\n"); - for (i = 0; i < CIFISP_DEGAMMA_CURVE_SIZE; i++) { - CIFISP_DPRINT(CIFISP_DEBUG, - " gamma_y[%d]: %d\n", - pconfig->curve_r.gamma_y[i]); - } + " gamma_y[%d]: %d\n", + p config->curve_g.gamma_y[i]); + } + CIFISP_DPRINT(CIFISP_DEBUG, + " BLUE -Curve parameters\n"); + for (i = 0; i < CIFISP_DEGAMMA_CURVE_SIZE; i++) { CIFISP_DPRINT(CIFISP_DEBUG, - " GREEN -Curve parameters\n"); - for (i = 0; i < CIFISP_DEGAMMA_CURVE_SIZE; i++) { - CIFISP_DPRINT(CIFISP_DEBUG, - " gamma_y[%d]: %d\n", - pconfig->curve_g.gamma_y[i]); - } - CIFISP_DPRINT(CIFISP_DEBUG, - " BLUE -Curve parameters\n"); - for (i = 0; i < CIFISP_DEGAMMA_CURVE_SIZE; i++) { - CIFISP_DPRINT(CIFISP_DEBUG, - " gamma_y[%d]: %d\n", - pconfig->curve_b.gamma_y[i]); - } - CIFISP_DPRINT(CIFISP_DEBUG, - "#### %s: SDG Parameters - END ####\n", - ISP_VDEV_NAME); + " gamma_y[%d]: %d\n", + pconfig->curve_b.gamma_y[i]); + } + CIFISP_DPRINT(CIFISP_DEBUG, + "#### %s: SDG Parameters - END ####\n", + ISP_VDEV_NAME); } break; case CIFISP_MODULE_GOC:{ - CIFISP_DPRINT(CIFISP_DEBUG, - "#### %s: GOC Parameters - BEGIN ####\n", - ISP_VDEV_NAME); - CIFISP_DPRINT(CIFISP_DEBUG, - "#### %s: GOC Parameters - END ####\n", - ISP_VDEV_NAME); + CIFISP_DPRINT(CIFISP_DEBUG, + "#### %s: GOC Parameters - BEGIN ####\n", + ISP_VDEV_NAME); + CIFISP_DPRINT(CIFISP_DEBUG, + "#### %s: GOC Parameters - END ####\n", + ISP_VDEV_NAME); } break; case CIFISP_MODULE_CTK:{ - struct cifisp_ctk_config *pconfig = - (struct cifisp_ctk_config *)config; - CIFISP_DPRINT(CIFISP_DEBUG, - "#### %s: CTK Parameters - BEGIN ####\n", - ISP_VDEV_NAME); - CIFISP_DPRINT(CIFISP_DEBUG, " coeff0: %d\n", - pconfig->coeff0); - CIFISP_DPRINT(CIFISP_DEBUG, " coeff1: %d\n", - pconfig->coeff1); - CIFISP_DPRINT(CIFISP_DEBUG, " coeff2: %d\n", - pconfig->coeff2); - CIFISP_DPRINT(CIFISP_DEBUG, " coeff3: %d\n", - pconfig->coeff3); - CIFISP_DPRINT(CIFISP_DEBUG, " coeff4: %d\n", - pconfig->coeff4); - CIFISP_DPRINT(CIFISP_DEBUG, " coeff5: %d\n", - pconfig->coeff5); - CIFISP_DPRINT(CIFISP_DEBUG, " coeff6: %d\n", - pconfig->coeff6); - CIFISP_DPRINT(CIFISP_DEBUG, " coeff7: %d\n", - pconfig->coeff7); - CIFISP_DPRINT(CIFISP_DEBUG, " coeff8: %d\n", - pconfig->coeff8); - CIFISP_DPRINT(CIFISP_DEBUG, " ct_offset_r: %d\n", - pconfig->ct_offset_r); - CIFISP_DPRINT(CIFISP_DEBUG, " ct_offset_g: %d\n", - pconfig->ct_offset_g); - CIFISP_DPRINT(CIFISP_DEBUG, " ct_offset_b: %d\n", - pconfig->ct_offset_b); - CIFISP_DPRINT(CIFISP_DEBUG, - "#### %s: CTK Parameters - END ####\n", - ISP_VDEV_NAME); + struct cifisp_ctk_config *pconfig = + (struct cifisp_ctk_config *)config; + CIFISP_DPRINT(CIFISP_DEBUG, + "#### %s: CTK Parameters - BEGIN ####\n", + ISP_VDEV_NAME); + CIFISP_DPRINT(CIFISP_DEBUG, " coeff0: %d\n", + pconfig->coeff0); + CIFISP_DPRINT(CIFISP_DEBUG, " coeff1: %d\n", + pconfig->coeff1); + CIFISP_DPRINT(CIFISP_DEBUG, " coeff2: %d\n", + pconfig->coeff2); + CIFISP_DPRINT(CIFISP_DEBUG, " coeff3: %d\n", + pconfig->coeff3); + CIFISP_DPRINT(CIFISP_DEBUG, " coeff4: %d\n", + pconfig->coeff4); + CIFISP_DPRINT(CIFISP_DEBUG, " coeff5: %d\n", + pconfig->coeff5); + CIFISP_DPRINT(CIFISP_DEBUG, " coeff6: %d\n", + pconfig->coeff6); + CIFISP_DPRINT(CIFISP_DEBUG, " coeff7: %d\n", + pconfig->coeff7); + CIFISP_DPRINT(CIFISP_DEBUG, " coeff8: %d\n", + pconfig->coeff8); + CIFISP_DPRINT(CIFISP_DEBUG, " ct_offset_r: %d\n", + pconfig->ct_offset_r); + CIFISP_DPRINT(CIFISP_DEBUG, " ct_offset_g: %d\n", + pconfig->ct_offset_g); + CIFISP_DPRINT(CIFISP_DEBUG, " ct_offset_b: %d\n", + pconfig->ct_offset_b); + CIFISP_DPRINT(CIFISP_DEBUG, + "#### %s: CTK Parameters - END ####\n", + ISP_VDEV_NAME); } break; case CIFISP_MODULE_AWB:{ - struct cifisp_awb_meas_config *pconfig = - (struct cifisp_awb_meas_config *)config; - CIFISP_DPRINT(CIFISP_DEBUG, - "#### %s: AWB Parameters - BEGIN ####\n", - ISP_VDEV_NAME); - CIFISP_DPRINT(CIFISP_DEBUG, " awb_mode: %d\n", - pconfig->awb_mode); - CIFISP_DPRINT(CIFISP_DEBUG, " max_y: %d\n", - pconfig->max_y); - CIFISP_DPRINT(CIFISP_DEBUG, " min_y: %d\n", - pconfig->min_y); - CIFISP_DPRINT(CIFISP_DEBUG, " max_csum: %d\n", - pconfig->max_csum); - CIFISP_DPRINT(CIFISP_DEBUG, " min_c: %d\n", - pconfig->min_c); - CIFISP_DPRINT(CIFISP_DEBUG, " frames: %d\n", - pconfig->frames); - CIFISP_DPRINT(CIFISP_DEBUG, " awb_ref_cr: %d\n", - pconfig->awb_ref_cr); - CIFISP_DPRINT(CIFISP_DEBUG, " awb_ref_cb: %d\n", - pconfig->awb_ref_cb); - CIFISP_DPRINT(CIFISP_DEBUG, " gb_sat: %d\n", - pconfig->gb_sat); - CIFISP_DPRINT(CIFISP_DEBUG, " gr_sat: %d\n", - pconfig->gr_sat); - CIFISP_DPRINT(CIFISP_DEBUG, " r_sat: %d\n", - pconfig->b_sat); - CIFISP_DPRINT(CIFISP_DEBUG, " grid_h_dim: %d\n", - pconfig->grid_h_dim); - CIFISP_DPRINT(CIFISP_DEBUG, " grid_v_dim: %d\n", - pconfig->grid_v_dim); - CIFISP_DPRINT(CIFISP_DEBUG, " grid_h_dist: %d\n", - pconfig->grid_h_dist); - CIFISP_DPRINT(CIFISP_DEBUG, " grid_v_dist: %d\n", - pconfig->grid_v_dist); - CIFISP_DPRINT(CIFISP_DEBUG, - " enable_ymax_cmp: %d\n", - pconfig->enable_ymax_cmp); - CIFISP_DPRINT(CIFISP_DEBUG, " rgb_meas_pnt: %d\n", - pconfig->rgb_meas_pnt); - CIFISP_DPRINT(CIFISP_DEBUG, " AWB Window size\n"); - CIFISP_DPRINT(CIFISP_DEBUG, " h_offs: %d\n", - pconfig->awb_wnd.h_offs); - CIFISP_DPRINT(CIFISP_DEBUG, " v_offs: %d\n", - pconfig->awb_wnd.v_offs); - CIFISP_DPRINT(CIFISP_DEBUG, " h_size: %d\n", - pconfig->awb_wnd.h_size); - CIFISP_DPRINT(CIFISP_DEBUG, " v_size: %d\n", - pconfig->awb_wnd.v_size); - CIFISP_DPRINT(CIFISP_DEBUG, - "#### %s: AWB Parameters - END ####\n", - ISP_VDEV_NAME); + struct cifisp_awb_meas_config *pconfig = + (struct cifisp_awb_meas_config *)config; + CIFISP_DPRINT(CIFISP_DEBUG, + "#### %s: AWB Parameters - BEGIN ####\n", + ISP_VDEV_NAME); + CIFISP_DPRINT(CIFISP_DEBUG, " awb_mode: %d\n", + pconfig->awb_mode); + CIFISP_DPRINT(CIFISP_DEBUG, " max_y: %d\n", + pconfig->max_y); + CIFISP_DPRINT(CIFISP_DEBUG, " min_y: %d\n", + pconfig->min_y); + CIFISP_DPRINT(CIFISP_DEBUG, " max_csum: %d\n", + pconfig->max_csum); + CIFISP_DPRINT(CIFISP_DEBUG, " min_c: %d\n", + pconfig->min_c); + CIFISP_DPRINT(CIFISP_DEBUG, " frames: %d\n", + pconfig->frames); + CIFISP_DPRINT(CIFISP_DEBUG, " awb_ref_cr: %d\n", + pconfig->awb_ref_cr); + CIFISP_DPRINT(CIFISP_DEBUG, " awb_ref_cb: %d\n", + pconfig->awb_ref_cb); + CIFISP_DPRINT(CIFISP_DEBUG, " gb_sat: %d\n", + pconfig->gb_sat); + CIFISP_DPRINT(CIFISP_DEBUG, " gr_sat: %d\n", + pconfig->gr_sat); + CIFISP_DPRINT(CIFISP_DEBUG, " r_sat: %d\n", + pconfig->b_sat); + CIFISP_DPRINT(CIFISP_DEBUG, " grid_h_dim: %d\n", + pconfig->grid_h_dim); + CIFISP_DPRINT(CIFISP_DEBUG, " grid_v_dim: %d\n", + pconfig->grid_v_dim); + CIFISP_DPRINT(CIFISP_DEBUG, " grid_h_dist: %d\n", + pconfig->grid_h_dist); + CIFISP_DPRINT(CIFISP_DEBUG, " grid_v_dist: %d\n", + pconfig->grid_v_dist); + CIFISP_DPRINT(CIFISP_DEBUG, + " enable_ymax_cmp: %d\n", + pconfig->enable_ymax_cmp); + CIFISP_DPRINT(CIFISP_DEBUG, " rgb_meas_pnt: %d\n", + pconfig->rgb_meas_pnt); + CIFISP_DPRINT(CIFISP_DEBUG, " AWB Window size\n"); + CIFISP_DPRINT(CIFISP_DEBUG, " h_offs: %d\n", + pconfig->awb_wnd.h_offs); + CIFISP_DPRINT(CIFISP_DEBUG, " v_offs: %d\n", + pconfig->awb_wnd.v_offs); + CIFISP_DPRINT(CIFISP_DEBUG, " h_size: %d\n", + pconfig->awb_wnd.h_size); + CIFISP_DPRINT(CIFISP_DEBUG, " v_size: %d\n", + pconfig->awb_wnd.v_size); + CIFISP_DPRINT(CIFISP_DEBUG, + "#### %s: AWB Parameters - END ####\n", + ISP_VDEV_NAME); } break; case CIFISP_MODULE_HST:{ - struct cifisp_hst_config *pconfig = - (struct cifisp_hst_config *)config; - CIFISP_DPRINT(CIFISP_DEBUG, - "#### %s: HST Parameters - BEGIN ####\n", - ISP_VDEV_NAME); - CIFISP_DPRINT(CIFISP_DEBUG, " mode: %d\n", - pconfig->mode); - CIFISP_DPRINT(CIFISP_DEBUG, - " histogram_predivider: %d\n", - pconfig->histogram_predivider); - CIFISP_DPRINT(CIFISP_DEBUG, " HST Window size\n"); - CIFISP_DPRINT(CIFISP_DEBUG, " h_offs: %d\n", - pconfig->meas_window.h_offs); - CIFISP_DPRINT(CIFISP_DEBUG, " v_offs: %d\n", - pconfig->meas_window.v_offs); - CIFISP_DPRINT(CIFISP_DEBUG, " h_size: %d\n", - pconfig->meas_window.h_size); - CIFISP_DPRINT(CIFISP_DEBUG, " v_size: %d\n", - pconfig->meas_window.v_size); - CIFISP_DPRINT(CIFISP_DEBUG, - "#### %s: HST Parameters - END ####\n", - ISP_VDEV_NAME); + struct cifisp_hst_config *pconfig = + (struct cifisp_hst_config *)config; + CIFISP_DPRINT(CIFISP_DEBUG, + "#### %s: HST Parameters - BEGIN ####\n", + ISP_VDEV_NAME); + CIFISP_DPRINT(CIFISP_DEBUG, " mode: %d\n", + pconfig->mode); + CIFISP_DPRINT(CIFISP_DEBUG, + " histogram_predivider: %d\n", + pconfig->histogram_predivider); + CIFISP_DPRINT(CIFISP_DEBUG, " HST Window size\n"); + CIFISP_DPRINT(CIFISP_DEBUG, " h_offs: %d\n", + pconfig->meas_window.h_offs); + CIFISP_DPRINT(CIFISP_DEBUG, " v_offs: %d\n", + pconfig->meas_window.v_offs); + CIFISP_DPRINT(CIFISP_DEBUG, " h_size: %d\n", + pconfig->meas_window.h_size); + CIFISP_DPRINT(CIFISP_DEBUG, " v_size: %d\n", + pconfig->meas_window.v_size); + CIFISP_DPRINT(CIFISP_DEBUG, + "#### %s: HST Parameters - END ####\n", + ISP_VDEV_NAME); } break; case CIFISP_MODULE_AEC:{ - struct cifisp_aec_config *pconfig = - (struct cifisp_aec_config *)config; - CIFISP_DPRINT(CIFISP_DEBUG, - "#### %s: AEC Parameters - BEGIN ####\n", - ISP_VDEV_NAME); - CIFISP_DPRINT(CIFISP_DEBUG, " autostop: %d\n", - pconfig->autostop); - CIFISP_DPRINT(CIFISP_DEBUG, " AEC Window size\n"); - CIFISP_DPRINT(CIFISP_DEBUG, " h_offs: %d\n", - pconfig->meas_window.h_offs); - CIFISP_DPRINT(CIFISP_DEBUG, " v_offs: %d\n", - pconfig->meas_window.v_offs); - CIFISP_DPRINT(CIFISP_DEBUG, " h_size: %d\n", - pconfig->meas_window.h_size); - CIFISP_DPRINT(CIFISP_DEBUG, " v_size: %d\n", - pconfig->meas_window.v_size); - CIFISP_DPRINT(CIFISP_DEBUG, - "#### %s: AEC Parameters - END ####\n", - ISP_VDEV_NAME); + struct cifisp_aec_config *pconfig = + (struct cifisp_aec_config *)config; + CIFISP_DPRINT(CIFISP_DEBUG, + "#### %s: AEC Parameters - BEGIN ####\n", + ISP_VDEV_NAME); + CIFISP_DPRINT(CIFISP_DEBUG, " autostop: %d\n", + pconfig->autostop); + CIFISP_DPRINT(CIFISP_DEBUG, " AEC Window size\n"); + CIFISP_DPRINT(CIFISP_DEBUG, " h_offs: %d\n", + pconfig->meas_window.h_offs); + CIFISP_DPRINT(CIFISP_DEBUG, " v_offs: %d\n", + pconfig->meas_window.v_offs); + CIFISP_DPRINT(CIFISP_DEBUG, " h_size: %d\n", + pconfig->meas_window.h_size); + CIFISP_DPRINT(CIFISP_DEBUG, " v_size: %d\n", + pconfig->meas_window.v_size); + CIFISP_DPRINT(CIFISP_DEBUG, + "#### %s: AEC Parameters - END ####\n", + ISP_VDEV_NAME); } break; case CIFISP_MODULE_CPROC:{ - struct cifisp_cproc_config *pconfig = - (struct cifisp_cproc_config *)config; - CIFISP_DPRINT(CIFISP_DEBUG, - "#### %s: CPROC Parameters - BEGIN ####\n", - ISP_VDEV_NAME); - CIFISP_DPRINT(CIFISP_DEBUG, " contrast: %d\n", - pconfig->contrast); - CIFISP_DPRINT(CIFISP_DEBUG, " hue: %d\n", - pconfig->hue); - CIFISP_DPRINT(CIFISP_DEBUG, " sat: %d\n", - pconfig->sat); - CIFISP_DPRINT(CIFISP_DEBUG, " brightness: %d\n", - pconfig->brightness); - CIFISP_DPRINT(CIFISP_DEBUG, - "#### %s: CPROC Parameters - END ####\n", - ISP_VDEV_NAME); + struct cifisp_cproc_config *pconfig = + (struct cifisp_cproc_config *)config; + CIFISP_DPRINT(CIFISP_DEBUG, + "#### %s: CPROC Parameters - BEGIN ####\n", + ISP_VDEV_NAME); + CIFISP_DPRINT(CIFISP_DEBUG, " contrast: %d\n", + pconfig->contrast); + CIFISP_DPRINT(CIFISP_DEBUG, " hue: %d\n", + pconfig->hue); + CIFISP_DPRINT(CIFISP_DEBUG, " sat: %d\n", + pconfig->sat); + CIFISP_DPRINT(CIFISP_DEBUG, " brightness: %d\n", + pconfig->brightness); + CIFISP_DPRINT(CIFISP_DEBUG, + "#### %s: CPROC Parameters - END ####\n", + ISP_VDEV_NAME); } break; case CIFISP_MODULE_YCFLT:{ - struct cifisp_ycflt_config *pconfig = - (struct cifisp_ycflt_config *)config; - CIFISP_DPRINT(CIFISP_DEBUG, - "#### %s: YCFLT Parameters - BEGIN ####\n", - ISP_VDEV_NAME); - CIFISP_DPRINT(CIFISP_DEBUG, " chr_ss_ctrl: %d\n", - CIFISP_DPRINT(CIFISP_DEBUG, " ctrl: %d\n", - pconfig->ctrl); - CIFISP_DPRINT(CIFISP_DEBUG, " chr_ss_ctrl: %d\n", - pconfig->chr_ss_ctrl); - CIFISP_DPRINT(CIFISP_DEBUG, " chr_ss_fac: %d\n", - pconfig->chr_ss_fac); - CIFISP_DPRINT(CIFISP_DEBUG, " chr_ss_offs: %d\n", - pconfig->chr_ss_offs); - CIFISP_DPRINT(CIFISP_DEBUG, " chr_nr_ctrl: %d\n", - pconfig->chr_nr_ctrl); - CIFISP_DPRINT(CIFISP_DEBUG, - " lum_eenr_edge_gain: %d\n", - pconfig->lum_eenr_edge_gain); - CIFISP_DPRINT(CIFISP_DEBUG, - " lum_eenr_corner_gain: %d\n", - pconfig->lum_eenr_corner_gain); - CIFISP_DPRINT(CIFISP_DEBUG, - " lum_eenr_fc_crop_neg: %d\n", - pconfig->lum_eenr_fc_crop_neg); - CIFISP_DPRINT(CIFISP_DEBUG, - " lum_eenr_fc_crop_pos: %d\n", - pconfig->lum_eenr_fc_crop_pos); - CIFISP_DPRINT(CIFISP_DEBUG, - " lum_eenr_fc_gain_neg: %d\n", - pconfig->lum_eenr_fc_gain_neg); - CIFISP_DPRINT(CIFISP_DEBUG, - " lum_eenr_fc_gain_pos: %d\n", - pconfig->lum_eenr_fc_gain_pos); - CIFISP_DPRINT(CIFISP_DEBUG, - "#### %s: YCFLT Parameters - END ####\n", - ISP_VDEV_NAME); - break; + struct cifisp_ycflt_config *pconfig = + (struct cifisp_ycflt_config *)config; + CIFISP_DPRINT(CIFISP_DEBUG, + "#### %s: YCFLT Parameters - BEGIN ####\n", + ISP_VDEV_NAME); + CIFISP_DPRINT(CIFISP_DEBUG, " ctrl: %d\n", + pconfig->ctrl); + CIFISP_DPRINT(CIFISP_DEBUG, " chr_ss_ctrl: %d\n", + pconfig->chr_ss_ctrl); + CIFISP_DPRINT(CIFISP_DEBUG, " chr_ss_fac: %d\n", + pconfig->chr_ss_fac); + CIFISP_DPRINT(CIFISP_DEBUG, " chr_ss_offs: %d\n", + pconfig->chr_ss_offs); + CIFISP_DPRINT(CIFISP_DEBUG, " chr_nr_ctrl: %d\n", + pconfig->chr_nr_ctrl); + CIFISP_DPRINT(CIFISP_DEBUG, + " lum_eenr_edge_gain: %d\n", + pconfig->lum_eenr_edge_gain); + CIFISP_DPRINT(CIFISP_DEBUG, + " lum_eenr_corner_gain: %d\n", + pconfig->lum_eenr_corner_gain); + CIFISP_DPRINT(CIFISP_DEBUG, + " lum_eenr_fc_crop_neg: %d\n", + pconfig->lum_eenr_fc_crop_neg); + CIFISP_DPRINT(CIFISP_DEBUG, + " lum_eenr_fc_crop_pos: %d\n", + pconfig->lum_eenr_fc_crop_pos); + CIFISP_DPRINT(CIFISP_DEBUG, + " lum_eenr_fc_gain_neg: %d\n", + pconfig->lum_eenr_fc_gain_neg); + CIFISP_DPRINT(CIFISP_DEBUG, + " lum_eenr_fc_gain_pos: %d\n", + pconfig->lum_eenr_fc_gain_pos); + CIFISP_DPRINT(CIFISP_DEBUG, + "#### %s: YCFLT Parameters - END ####\n", + ISP_VDEV_NAME); + break; } case CIFISP_MODULE_AFC:{ - struct cifisp_afc_config *pconfig = - (struct cifisp_afc_config *)config; - CIFISP_DPRINT(CIFISP_DEBUG, - "#### %s: AFC Parameters - BEGIN ####\n", - ISP_VDEV_NAME); - CIFISP_DPRINT(CIFISP_DEBUG, - " window A %d %d %d %d\n", - pconfig->afm_win[0].h_offs, - pconfig->afm_win[0].v_offs, - pconfig->afm_win[0].h_size, - pconfig->afm_win[0].v_size); - CIFISP_DPRINT(CIFISP_DEBUG, - " window B %d %d %d %d\n", - pconfig->afm_win[1].h_offs, - pconfig->afm_win[1].v_offs, - pconfig->afm_win[1].h_size, - pconfig->afm_win[1].v_size); - CIFISP_DPRINT(CIFISP_DEBUG, - " window C %d %d %d %d\n", - pconfig->afm_win[2].h_offs, - pconfig->afm_win[2].v_offs, - pconfig->afm_win[2].h_size, - pconfig->afm_win[2].v_size); - CIFISP_DPRINT(CIFISP_DEBUG, " thres: %d\n", - pconfig->thres); - CIFISP_DPRINT(CIFISP_DEBUG, " var_shift: %d\n", - pconfig->var_shift); - break; + struct cifisp_afc_config *pconfig = + (struct cifisp_afc_config *)config; + CIFISP_DPRINT(CIFISP_DEBUG, + "#### %s: AFC Parameters - BEGIN ####\n", + ISP_VDEV_NAME); + CIFISP_DPRINT(CIFISP_DEBUG, + " window A %d %d %d %d\n", + pconfig->afm_win[0].h_offs, + pconfig->afm_win[0].v_offs, + pconfig->afm_win[0].h_size, + pconfig->afm_win[0].v_size); + CIFISP_DPRINT(CIFISP_DEBUG, + " window B %d %d %d %d\n", + pconfig->afm_win[1].h_offs, + pconfig->afm_win[1].v_offs, + pconfig->afm_win[1].h_size, + pconfig->afm_win[1].v_size); + CIFISP_DPRINT(CIFISP_DEBUG, + " window C %d %d %d %d\n", + pconfig->afm_win[2].h_offs, + pconfig->afm_win[2].v_offs, + pconfig->afm_win[2].h_size, + pconfig->afm_win[2].v_size); + CIFISP_DPRINT(CIFISP_DEBUG, " thres: %d\n", + pconfig->thres); + CIFISP_DPRINT(CIFISP_DEBUG, " var_shift: %d\n", + pconfig->var_shift); + break; } case CIFISP_MODULE_IE: { - struct cifisp_ie_config *pconfig = - (struct cifisp_ie_config *)config; - CIFISP_DPRINT(CIFISP_DEBUG, - "effect %d, %x, %x, %x, %x, %x, %x %d\n", - pconfig->effect, pconfig->color_sel, - pconfig->eff_mat_1, pconfig->eff_mat_2, - pconfig->eff_mat_3, pconfig->eff_mat_4, - pconfig->eff_mat_5, pconfig->eff_tint); - break; + struct cifisp_ie_config *pconfig = + (struct cifisp_ie_config *)config; + CIFISP_DPRINT(CIFISP_DEBUG, + "effect %d, %x, %x, %x, %x, %x, %x %d\n", + pconfig->effect, pconfig->color_sel, + pconfig->eff_mat_1, pconfig->eff_mat_2, + pconfig->eff_mat_3, pconfig->eff_mat_4, + pconfig->eff_mat_5, pconfig->eff_tint); + break; } default: CIFISP_DPRINT(CIFISP_DEBUG, - "####%s: Invalid Module ID ####\n", ISP_VDEV_NAME); + "####%s: Invalid Module ID ####\n", ISP_VDEV_NAME); break; } #endif @@ -4858,304 +4954,294 @@ static void cifisp_reg_dump(const struct cif_isp10_isp_dev *isp_dev, CIFISP_DPRINT(level, "#### LSC Registers - BEGIN ####\n"); CIFISP_DPRINT(level, "#### LSC Registers - END ####\n"); break; - case CIFISP_MODULE_FLT:{ - CIFISP_DPRINT(level, - "#### %s: FLT Registers - BEGIN ####\n", - ISP_VDEV_NAME); - CIFISP_DPRINT(level, - " CIF_ISP_FILT_MODE: %d\n", - cifisp_ioread32(CIF_ISP_FILT_MODE)); - CIFISP_DPRINT(level, - " CIF_ISP_FILT_LUM_WEIGHT: %d\n", - cifisp_ioread32(CIF_ISP_FILT_LUM_WEIGHT)); - CIFISP_DPRINT(level, - "#### %s: FLT Registers - END ####\n", - ISP_VDEV_NAME); - } + case CIFISP_MODULE_FLT: + CIFISP_DPRINT(level, + "#### %s: FLT Registers - BEGIN ####\n", + ISP_VDEV_NAME); + CIFISP_DPRINT(level, + " CIF_ISP_FILT_MODE: %d\n", + cifisp_ioread32(CIF_ISP_FILT_MODE)); + CIFISP_DPRINT(level, + " CIF_ISP_FILT_LUM_WEIGHT: %d\n", + cifisp_ioread32(CIF_ISP_FILT_LUM_WEIGHT)); + CIFISP_DPRINT(level, + "#### %s: FLT Registers - END ####\n", + ISP_VDEV_NAME); break; - case CIFISP_MODULE_BDM:{ - CIFISP_DPRINT(level, - "#### %s: BDM Registers - BEGIN ####\n", - ISP_VDEV_NAME); - CIFISP_DPRINT(level, " CIF_ISP_DEMOSAIC: %d\n", - cifisp_ioread32(CIF_ISP_DEMOSAIC)); - CIFISP_DPRINT(level, - "#### %s: BDM Registers - END ####\n", - ISP_VDEV_NAME); - } + case CIFISP_MODULE_BDM: + CIFISP_DPRINT(level, + "#### %s: BDM Registers - BEGIN ####\n", + ISP_VDEV_NAME); + CIFISP_DPRINT(level, " CIF_ISP_DEMOSAIC: %d\n", + cifisp_ioread32(CIF_ISP_DEMOSAIC)); + CIFISP_DPRINT(level, + "#### %s: BDM Registers - END ####\n", + ISP_VDEV_NAME); break; - case CIFISP_MODULE_SDG:{ - CIFISP_DPRINT(level, - "#### %s: SDG Registers - BEGIN ####\n", - ISP_VDEV_NAME); - CIFISP_DPRINT(level, " CIF_ISP_GAMMA_DX_LO: %d\n", - cifisp_ioread32(CIF_ISP_GAMMA_DX_LO)); - CIFISP_DPRINT(level, " CIF_ISP_GAMMA_DX_HI: %d\n", - cifisp_ioread32(CIF_ISP_GAMMA_DX_HI)); + case CIFISP_MODULE_SDG: + CIFISP_DPRINT(level, + "#### %s: SDG Registers - BEGIN ####\n", + ISP_VDEV_NAME); + CIFISP_DPRINT(level, " CIF_ISP_GAMMA_DX_LO: %d\n", + cifisp_ioread32(CIF_ISP_GAMMA_DX_LO)); + CIFISP_DPRINT(level, " CIF_ISP_GAMMA_DX_HI: %d\n", + cifisp_ioread32(CIF_ISP_GAMMA_DX_HI)); - CIFISP_DPRINT(level, " CIF_ISP_GAMMA_R_Y0: %d\n", - cifisp_ioread32(CIF_ISP_GAMMA_R_Y0)); - CIFISP_DPRINT(level, " CIF_ISP_GAMMA_R_Y1: %d\n", - cifisp_ioread32(CIF_ISP_GAMMA_R_Y1)); - CIFISP_DPRINT(level, " CIF_ISP_GAMMA_R_Y2: %d\n", - cifisp_ioread32(CIF_ISP_GAMMA_R_Y2)); - CIFISP_DPRINT(level, " CIF_ISP_GAMMA_R_Y3: %d\n", - cifisp_ioread32(CIF_ISP_GAMMA_R_Y3)); - CIFISP_DPRINT(level, " CIF_ISP_GAMMA_R_Y4: %d\n", - cifisp_ioread32(CIF_ISP_GAMMA_R_Y4)); - CIFISP_DPRINT(level, " CIF_ISP_GAMMA_R_Y5: %d\n", - cifisp_ioread32(CIF_ISP_GAMMA_R_Y5)); - CIFISP_DPRINT(level, " CIF_ISP_GAMMA_R_Y6: %d\n", - cifisp_ioread32(CIF_ISP_GAMMA_R_Y6)); - CIFISP_DPRINT(level, " CIF_ISP_GAMMA_R_Y7: %d\n", - cifisp_ioread32(CIF_ISP_GAMMA_R_Y7)); - CIFISP_DPRINT(level, " CIF_ISP_GAMMA_R_Y8: %d\n", - cifisp_ioread32(CIF_ISP_GAMMA_R_Y8)); - CIFISP_DPRINT(level, " CIF_ISP_GAMMA_R_Y9: %d\n", - cifisp_ioread32(CIF_ISP_GAMMA_R_Y9)); - CIFISP_DPRINT(level, " CIF_ISP_GAMMA_R_Y10: %d\n", - cifisp_ioread32(CIF_ISP_GAMMA_R_Y10)); - CIFISP_DPRINT(level, " CIF_ISP_GAMMA_R_Y11: %d\n", - cifisp_ioread32(CIF_ISP_GAMMA_R_Y11)); - CIFISP_DPRINT(level, " CIF_ISP_GAMMA_R_Y12: %d\n", - cifisp_ioread32(CIF_ISP_GAMMA_R_Y12)); - CIFISP_DPRINT(level, " CIF_ISP_GAMMA_R_Y13: %d\n", - cifisp_ioread32(CIF_ISP_GAMMA_R_Y13)); - CIFISP_DPRINT(level, " CIF_ISP_GAMMA_R_Y14: %d\n", - cifisp_ioread32(CIF_ISP_GAMMA_R_Y14)); - CIFISP_DPRINT(level, " CIF_ISP_GAMMA_R_Y15: %d\n", - cifisp_ioread32(CIF_ISP_GAMMA_R_Y15)); - CIFISP_DPRINT(level, " CIF_ISP_GAMMA_R_Y16: %d\n", - cifisp_ioread32(CIF_ISP_GAMMA_R_Y16)); + CIFISP_DPRINT(level, " CIF_ISP_GAMMA_R_Y0: %d\n", + cifisp_ioread32(CIF_ISP_GAMMA_R_Y0)); + CIFISP_DPRINT(level, " CIF_ISP_GAMMA_R_Y1: %d\n", + cifisp_ioread32(CIF_ISP_GAMMA_R_Y1)); + CIFISP_DPRINT(level, " CIF_ISP_GAMMA_R_Y2: %d\n", + cifisp_ioread32(CIF_ISP_GAMMA_R_Y2)); + CIFISP_DPRINT(level, " CIF_ISP_GAMMA_R_Y3: %d\n", + cifisp_ioread32(CIF_ISP_GAMMA_R_Y3)); + CIFISP_DPRINT(level, " CIF_ISP_GAMMA_R_Y4: %d\n", + cifisp_ioread32(CIF_ISP_GAMMA_R_Y4)); + CIFISP_DPRINT(level, " CIF_ISP_GAMMA_R_Y5: %d\n", + cifisp_ioread32(CIF_ISP_GAMMA_R_Y5)); + CIFISP_DPRINT(level, " CIF_ISP_GAMMA_R_Y6: %d\n", + cifisp_ioread32(CIF_ISP_GAMMA_R_Y6)); + CIFISP_DPRINT(level, " CIF_ISP_GAMMA_R_Y7: %d\n", + cifisp_ioread32(CIF_ISP_GAMMA_R_Y7)); + CIFISP_DPRINT(level, " CIF_ISP_GAMMA_R_Y8: %d\n", + cifisp_ioread32(CIF_ISP_GAMMA_R_Y8)); + CIFISP_DPRINT(level, " CIF_ISP_GAMMA_R_Y9: %d\n", + cifisp_ioread32(CIF_ISP_GAMMA_R_Y9)); + CIFISP_DPRINT(level, " CIF_ISP_GAMMA_R_Y10: %d\n", + cifisp_ioread32(CIF_ISP_GAMMA_R_Y10)); + CIFISP_DPRINT(level, " CIF_ISP_GAMMA_R_Y11: %d\n", + cifisp_ioread32(CIF_ISP_GAMMA_R_Y11)); + CIFISP_DPRINT(level, " CIF_ISP_GAMMA_R_Y12: %d\n", + cifisp_ioread32(CIF_ISP_GAMMA_R_Y12)); + CIFISP_DPRINT(level, " CIF_ISP_GAMMA_R_Y13: %d\n", + cifisp_ioread32(CIF_ISP_GAMMA_R_Y13)); + CIFISP_DPRINT(level, " CIF_ISP_GAMMA_R_Y14: %d\n", + cifisp_ioread32(CIF_ISP_GAMMA_R_Y14)); + CIFISP_DPRINT(level, " CIF_ISP_GAMMA_R_Y15: %d\n", + cifisp_ioread32(CIF_ISP_GAMMA_R_Y15)); + CIFISP_DPRINT(level, " CIF_ISP_GAMMA_R_Y16: %d\n", + cifisp_ioread32(CIF_ISP_GAMMA_R_Y16)); - CIFISP_DPRINT(level, " CIF_ISP_GAMMA_G_Y0: %d\n", - cifisp_ioread32(CIF_ISP_GAMMA_G_Y0)); - CIFISP_DPRINT(level, " CIF_ISP_GAMMA_G_Y1: %d\n", - cifisp_ioread32(CIF_ISP_GAMMA_G_Y1)); - CIFISP_DPRINT(level, " CIF_ISP_GAMMA_G_Y2: %d\n", - cifisp_ioread32(CIF_ISP_GAMMA_G_Y2)); - CIFISP_DPRINT(level, " CIF_ISP_GAMMA_G_Y3: %d\n", - cifisp_ioread32(CIF_ISP_GAMMA_G_Y3)); - CIFISP_DPRINT(level, " CIF_ISP_GAMMA_G_Y4: %d\n", - cifisp_ioread32(CIF_ISP_GAMMA_G_Y4)); - CIFISP_DPRINT(level, " CIF_ISP_GAMMA_G_Y5: %d\n", - cifisp_ioread32(CIF_ISP_GAMMA_G_Y5)); - CIFISP_DPRINT(level, " CIF_ISP_GAMMA_G_Y6: %d\n", - cifisp_ioread32(CIF_ISP_GAMMA_G_Y6)); - CIFISP_DPRINT(level, " CIF_ISP_GAMMA_G_Y7: %d\n", - cifisp_ioread32(CIF_ISP_GAMMA_G_Y7)); - CIFISP_DPRINT(level, " CIF_ISP_GAMMA_G_Y8: %d\n", - cifisp_ioread32(CIF_ISP_GAMMA_G_Y8)); - CIFISP_DPRINT(level, " CIF_ISP_GAMMA_G_Y9: %d\n", - cifisp_ioread32(CIF_ISP_GAMMA_G_Y9)); - CIFISP_DPRINT(level, " CIF_ISP_GAMMA_G_Y10: %d\n", - cifisp_ioread32(CIF_ISP_GAMMA_G_Y10)); - CIFISP_DPRINT(level, " CIF_ISP_GAMMA_G_Y11: %d\n", - cifisp_ioread32(CIF_ISP_GAMMA_G_Y11)); - CIFISP_DPRINT(level, " CIF_ISP_GAMMA_G_Y12: %d\n", - cifisp_ioread32(CIF_ISP_GAMMA_G_Y12)); - CIFISP_DPRINT(level, " CIF_ISP_GAMMA_G_Y13: %d\n", - cifisp_ioread32(CIF_ISP_GAMMA_G_Y13)); - CIFISP_DPRINT(level, " CIF_ISP_GAMMA_G_Y14: %d\n", - cifisp_ioread32(CIF_ISP_GAMMA_G_Y14)); - CIFISP_DPRINT(level, " CIF_ISP_GAMMA_G_Y15: %d\n", - cifisp_ioread32(CIF_ISP_GAMMA_G_Y15)); - CIFISP_DPRINT(level, " CIF_ISP_GAMMA_G_Y16: %d\n", - cifisp_ioread32(CIF_ISP_GAMMA_G_Y16)); + CIFISP_DPRINT(level, " CIF_ISP_GAMMA_G_Y0: %d\n", + cifisp_ioread32(CIF_ISP_GAMMA_G_Y0)); + CIFISP_DPRINT(level, " CIF_ISP_GAMMA_G_Y1: %d\n", + cifisp_ioread32(CIF_ISP_GAMMA_G_Y1)); + CIFISP_DPRINT(level, " CIF_ISP_GAMMA_G_Y2: %d\n", + cifisp_ioread32(CIF_ISP_GAMMA_G_Y2)); + CIFISP_DPRINT(level, " CIF_ISP_GAMMA_G_Y3: %d\n", + cifisp_ioread32(CIF_ISP_GAMMA_G_Y3)); + CIFISP_DPRINT(level, " CIF_ISP_GAMMA_G_Y4: %d\n", + cifisp_ioread32(CIF_ISP_GAMMA_G_Y4)); + CIFISP_DPRINT(level, " CIF_ISP_GAMMA_G_Y5: %d\n", + cifisp_ioread32(CIF_ISP_GAMMA_G_Y5)); + CIFISP_DPRINT(level, " CIF_ISP_GAMMA_G_Y6: %d\n", + cifisp_ioread32(CIF_ISP_GAMMA_G_Y6)); + CIFISP_DPRINT(level, " CIF_ISP_GAMMA_G_Y7: %d\n", + cifisp_ioread32(CIF_ISP_GAMMA_G_Y7)); + CIFISP_DPRINT(level, " CIF_ISP_GAMMA_G_Y8: %d\n", + cifisp_ioread32(CIF_ISP_GAMMA_G_Y8)); + CIFISP_DPRINT(level, " CIF_ISP_GAMMA_G_Y9: %d\n", + cifisp_ioread32(CIF_ISP_GAMMA_G_Y9)); + CIFISP_DPRINT(level, " CIF_ISP_GAMMA_G_Y10: %d\n", + cifisp_ioread32(CIF_ISP_GAMMA_G_Y10)); + CIFISP_DPRINT(level, " CIF_ISP_GAMMA_G_Y11: %d\n", + cifisp_ioread32(CIF_ISP_GAMMA_G_Y11)); + CIFISP_DPRINT(level, " CIF_ISP_GAMMA_G_Y12: %d\n", + cifisp_ioread32(CIF_ISP_GAMMA_G_Y12)); + CIFISP_DPRINT(level, " CIF_ISP_GAMMA_G_Y13: %d\n", + cifisp_ioread32(CIF_ISP_GAMMA_G_Y13)); + CIFISP_DPRINT(level, " CIF_ISP_GAMMA_G_Y14: %d\n", + cifisp_ioread32(CIF_ISP_GAMMA_G_Y14)); + CIFISP_DPRINT(level, " CIF_ISP_GAMMA_G_Y15: %d\n", + cifisp_ioread32(CIF_ISP_GAMMA_G_Y15)); + CIFISP_DPRINT(level, " CIF_ISP_GAMMA_G_Y16: %d\n", + cifisp_ioread32(CIF_ISP_GAMMA_G_Y16)); - CIFISP_DPRINT(level, " CIF_ISP_GAMMA_B_Y0: %d\n", - cifisp_ioread32(CIF_ISP_GAMMA_B_Y0)); - CIFISP_DPRINT(level, " CIF_ISP_GAMMA_B_Y1: %d\n", - cifisp_ioread32(CIF_ISP_GAMMA_B_Y1)); - CIFISP_DPRINT(level, " CIF_ISP_GAMMA_B_Y2: %d\n", - cifisp_ioread32(CIF_ISP_GAMMA_B_Y2)); - CIFISP_DPRINT(level, " CIF_ISP_GAMMA_B_Y3: %d\n", - cifisp_ioread32(CIF_ISP_GAMMA_B_Y3)); - CIFISP_DPRINT(level, " CIF_ISP_GAMMA_B_Y4: %d\n", - cifisp_ioread32(CIF_ISP_GAMMA_B_Y4)); - CIFISP_DPRINT(level, " CIF_ISP_GAMMA_B_Y5: %d\n", - cifisp_ioread32(CIF_ISP_GAMMA_B_Y5)); - CIFISP_DPRINT(level, " CIF_ISP_GAMMA_B_Y6: %d\n", - cifisp_ioread32(CIF_ISP_GAMMA_B_Y6)); - CIFISP_DPRINT(level, " CIF_ISP_GAMMA_B_Y7: %d\n", - cifisp_ioread32(CIF_ISP_GAMMA_B_Y7)); - CIFISP_DPRINT(level, " CIF_ISP_GAMMA_B_Y8: %d\n", - cifisp_ioread32(CIF_ISP_GAMMA_B_Y8)); - CIFISP_DPRINT(level, " CIF_ISP_GAMMA_B_Y9: %d\n", - cifisp_ioread32(CIF_ISP_GAMMA_B_Y9)); - CIFISP_DPRINT(level, " CIF_ISP_GAMMA_B_Y10: %d\n", - cifisp_ioread32(CIF_ISP_GAMMA_B_Y10)); - CIFISP_DPRINT(level, " CIF_ISP_GAMMA_B_Y11: %d\n", - cifisp_ioread32(CIF_ISP_GAMMA_B_Y11)); - CIFISP_DPRINT(level, " CIF_ISP_GAMMA_B_Y12: %d\n", - cifisp_ioread32(CIF_ISP_GAMMA_B_Y12)); - CIFISP_DPRINT(level, " CIF_ISP_GAMMA_B_Y13: %d\n", - cifisp_ioread32(CIF_ISP_GAMMA_B_Y13)); - CIFISP_DPRINT(level, " CIF_ISP_GAMMA_B_Y14: %d\n", - cifisp_ioread32(CIF_ISP_GAMMA_B_Y14)); - CIFISP_DPRINT(level, " CIF_ISP_GAMMA_B_Y15: %d\n", - cifisp_ioread32(CIF_ISP_GAMMA_B_Y15)); - CIFISP_DPRINT(level, " CIF_ISP_GAMMA_B_Y16: %d\n", - cifisp_ioread32(CIF_ISP_GAMMA_B_Y16)); - CIFISP_DPRINT(level, - "#### %s: SDG Registers - END ####\n", - ISP_VDEV_NAME); - } + CIFISP_DPRINT(level, " CIF_ISP_GAMMA_B_Y0: %d\n", + cifisp_ioread32(CIF_ISP_GAMMA_B_Y0)); + CIFISP_DPRINT(level, " CIF_ISP_GAMMA_B_Y1: %d\n", + cifisp_ioread32(CIF_ISP_GAMMA_B_Y1)); + CIFISP_DPRINT(level, " CIF_ISP_GAMMA_B_Y2: %d\n", + cifisp_ioread32(CIF_ISP_GAMMA_B_Y2)); + CIFISP_DPRINT(level, " CIF_ISP_GAMMA_B_Y3: %d\n", + cifisp_ioread32(CIF_ISP_GAMMA_B_Y3)); + CIFISP_DPRINT(level, " CIF_ISP_GAMMA_B_Y4: %d\n", + cifisp_ioread32(CIF_ISP_GAMMA_B_Y4)); + CIFISP_DPRINT(level, " CIF_ISP_GAMMA_B_Y5: %d\n", + cifisp_ioread32(CIF_ISP_GAMMA_B_Y5)); + CIFISP_DPRINT(level, " CIF_ISP_GAMMA_B_Y6: %d\n", + cifisp_ioread32(CIF_ISP_GAMMA_B_Y6)); + CIFISP_DPRINT(level, " CIF_ISP_GAMMA_B_Y7: %d\n", + cifisp_ioread32(CIF_ISP_GAMMA_B_Y7)); + CIFISP_DPRINT(level, " CIF_ISP_GAMMA_B_Y8: %d\n", + cifisp_ioread32(CIF_ISP_GAMMA_B_Y8)); + CIFISP_DPRINT(level, " CIF_ISP_GAMMA_B_Y9: %d\n", + cifisp_ioread32(CIF_ISP_GAMMA_B_Y9)); + CIFISP_DPRINT(level, " CIF_ISP_GAMMA_B_Y10: %d\n", + cifisp_ioread32(CIF_ISP_GAMMA_B_Y10)); + CIFISP_DPRINT(level, " CIF_ISP_GAMMA_B_Y11: %d\n", + cifisp_ioread32(CIF_ISP_GAMMA_B_Y11)); + CIFISP_DPRINT(level, " CIF_ISP_GAMMA_B_Y12: %d\n", + cifisp_ioread32(CIF_ISP_GAMMA_B_Y12)); + CIFISP_DPRINT(level, " CIF_ISP_GAMMA_B_Y13: %d\n", + cifisp_ioread32(CIF_ISP_GAMMA_B_Y13)); + CIFISP_DPRINT(level, " CIF_ISP_GAMMA_B_Y14: %d\n", + cifisp_ioread32(CIF_ISP_GAMMA_B_Y14)); + CIFISP_DPRINT(level, " CIF_ISP_GAMMA_B_Y15: %d\n", + cifisp_ioread32(CIF_ISP_GAMMA_B_Y15)); + CIFISP_DPRINT(level, " CIF_ISP_GAMMA_B_Y16: %d\n", + cifisp_ioread32(CIF_ISP_GAMMA_B_Y16)); + CIFISP_DPRINT(level, + "#### %s: SDG Registers - END ####\n", + ISP_VDEV_NAME); break; - case CIFISP_MODULE_GOC:{ - CIFISP_DPRINT(level, - "#### %s: GOC Registers - BEGIN ####\n", - ISP_VDEV_NAME); - CIFISP_DPRINT(level, - "#### %s: GOC registers - END ####\n", - ISP_VDEV_NAME); - } + case CIFISP_MODULE_GOC: + CIFISP_DPRINT(level, + "#### %s: GOC Registers - BEGIN ####\n", + ISP_VDEV_NAME); + CIFISP_DPRINT(level, + "#### %s: GOC registers - END ####\n", + ISP_VDEV_NAME); break; - case CIFISP_MODULE_CTK:{ - CIFISP_DPRINT(level, - "#### %s: CTK Registers - BEGIN ####\n", - ISP_VDEV_NAME); - CIFISP_DPRINT(level, " CIF_ISP_CT_COEFF_0: %d\n", - cifisp_ioread32(CIF_ISP_CT_COEFF_0)); - CIFISP_DPRINT(level, " CIF_ISP_CT_COEFF_1: %d\n", - cifisp_ioread32(CIF_ISP_CT_COEFF_1)); - CIFISP_DPRINT(level, " CIF_ISP_CT_COEFF_2: %d\n", - cifisp_ioread32(CIF_ISP_CT_COEFF_2)); - CIFISP_DPRINT(level, " CIF_ISP_CT_COEFF_3: %d\n", - cifisp_ioread32(CIF_ISP_CT_COEFF_3)); - CIFISP_DPRINT(level, " CIF_ISP_CT_COEFF_4: %d\n", - cifisp_ioread32(CIF_ISP_CT_COEFF_4)); - CIFISP_DPRINT(level, " CIF_ISP_CT_COEFF_5: %d\n", - cifisp_ioread32(CIF_ISP_CT_COEFF_5)); - CIFISP_DPRINT(level, " CIF_ISP_CT_COEFF_6: %d\n", - cifisp_ioread32(CIF_ISP_CT_COEFF_6)); - CIFISP_DPRINT(level, " CIF_ISP_CT_COEFF_7: %d\n", - cifisp_ioread32(CIF_ISP_CT_COEFF_7)); - CIFISP_DPRINT(level, " CIF_ISP_CT_COEFF_8: %d\n", - cifisp_ioread32(CIF_ISP_CT_COEFF_8)); - CIFISP_DPRINT(level, " CIF_ISP_CT_OFFSET_R: %d\n", - cifisp_ioread32(CIF_ISP_CT_OFFSET_R)); - CIFISP_DPRINT(level, " CIF_ISP_CT_OFFSET_G: %d\n", - cifisp_ioread32(CIF_ISP_CT_OFFSET_G)); - CIFISP_DPRINT(level, " CIF_ISP_CT_OFFSET_B: %d\n", - cifisp_ioread32(CIF_ISP_CT_OFFSET_B)); - CIFISP_DPRINT(level, - "#### %s: CTK Registers - END ####\n", - ISP_VDEV_NAME); - } + case CIFISP_MODULE_CTK: + CIFISP_DPRINT(level, + "#### %s: CTK Registers - BEGIN ####\n", + ISP_VDEV_NAME); + CIFISP_DPRINT(level, " CIF_ISP_CT_COEFF_0: %d\n", + cifisp_ioread32(CIF_ISP_CT_COEFF_0)); + CIFISP_DPRINT(level, " CIF_ISP_CT_COEFF_1: %d\n", + cifisp_ioread32(CIF_ISP_CT_COEFF_1)); + CIFISP_DPRINT(level, " CIF_ISP_CT_COEFF_2: %d\n", + cifisp_ioread32(CIF_ISP_CT_COEFF_2)); + CIFISP_DPRINT(level, " CIF_ISP_CT_COEFF_3: %d\n", + cifisp_ioread32(CIF_ISP_CT_COEFF_3)); + CIFISP_DPRINT(level, " CIF_ISP_CT_COEFF_4: %d\n", + cifisp_ioread32(CIF_ISP_CT_COEFF_4)); + CIFISP_DPRINT(level, " CIF_ISP_CT_COEFF_5: %d\n", + cifisp_ioread32(CIF_ISP_CT_COEFF_5)); + CIFISP_DPRINT(level, " CIF_ISP_CT_COEFF_6: %d\n", + cifisp_ioread32(CIF_ISP_CT_COEFF_6)); + CIFISP_DPRINT(level, " CIF_ISP_CT_COEFF_7: %d\n", + cifisp_ioread32(CIF_ISP_CT_COEFF_7)); + CIFISP_DPRINT(level, " CIF_ISP_CT_COEFF_8: %d\n", + cifisp_ioread32(CIF_ISP_CT_COEFF_8)); + CIFISP_DPRINT(level, " CIF_ISP_CT_OFFSET_R: %d\n", + cifisp_ioread32(CIF_ISP_CT_OFFSET_R)); + CIFISP_DPRINT(level, " CIF_ISP_CT_OFFSET_G: %d\n", + cifisp_ioread32(CIF_ISP_CT_OFFSET_G)); + CIFISP_DPRINT(level, " CIF_ISP_CT_OFFSET_B: %d\n", + cifisp_ioread32(CIF_ISP_CT_OFFSET_B)); + CIFISP_DPRINT(level, + "#### %s: CTK Registers - END ####\n", + ISP_VDEV_NAME); break; - case CIFISP_MODULE_AWB:{ - CIFISP_DPRINT(level, - "#### %s: AWB Registers - BEGIN ####\n", - ISP_VDEV_NAME); - CIFISP_DPRINT(level, " CIF_ISP_AWB_PROP: %x\n", - cifisp_ioread32(CIF_ISP_AWB_PROP)); - CIFISP_DPRINT(level, " CIF_ISP_AWB_GAIN_G: %x\n", - cifisp_ioread32(CIF_ISP_AWB_GAIN_G)); - CIFISP_DPRINT(level, " CIF_ISP_AWB_GAIN_RB: %x\n", - cifisp_ioread32(CIF_ISP_AWB_GAIN_RB)); - CIFISP_DPRINT(level, " CIF_ISP_AWB_REF: %x\n", - cifisp_ioread32(CIF_ISP_AWB_REF)); - CIFISP_DPRINT(level, " CIF_ISP_AWB_GAIN_RB: %x\n", - cifisp_ioread32(CIF_ISP_AWB_PROP)); - CIFISP_DPRINT(level, " CIF_ISP_AWB_FRAMES: %x\n", - cifisp_ioread32(CIF_ISP_AWB_FRAMES)); - CIFISP_DPRINT(level, - "#### %s: AWB Registers - END ####\n", - ISP_VDEV_NAME); - } + case CIFISP_MODULE_AWB: + CIFISP_DPRINT(level, + "#### %s: AWB Registers - BEGIN ####\n", + ISP_VDEV_NAME); + CIFISP_DPRINT(level, " CIF_ISP_AWB_PROP: %x\n", + cifisp_ioread32(CIF_ISP_AWB_PROP)); + CIFISP_DPRINT(level, " CIF_ISP_AWB_GAIN_G: %x\n", + cifisp_ioread32(CIF_ISP_AWB_GAIN_G)); + CIFISP_DPRINT(level, " CIF_ISP_AWB_GAIN_RB: %x\n", + cifisp_ioread32(CIF_ISP_AWB_GAIN_RB)); + CIFISP_DPRINT(level, " CIF_ISP_AWB_REF: %x\n", + cifisp_ioread32(CIF_ISP_AWB_REF)); + CIFISP_DPRINT(level, " CIF_ISP_AWB_GAIN_RB: %x\n", + cifisp_ioread32(CIF_ISP_AWB_PROP)); + CIFISP_DPRINT(level, " CIF_ISP_AWB_FRAMES: %x\n", + cifisp_ioread32(CIF_ISP_AWB_FRAMES)); + CIFISP_DPRINT(level, + "#### %s: AWB Registers - END ####\n", + ISP_VDEV_NAME); break; - case CIFISP_MODULE_HST:{ - CIFISP_DPRINT(level, - "#### %s: HST Registers - BEGIN ####\n", - ISP_VDEV_NAME); - CIFISP_DPRINT(level, " CIF_ISP_HIST_PROP: %d\n", - cifisp_ioread32(CIF_ISP_HIST_PROP)); - CIFISP_DPRINT(level, " CIF_ISP_HIST_H_OFFS: %d\n", - cifisp_ioread32(CIF_ISP_HIST_H_OFFS)); - CIFISP_DPRINT(level, " CIF_ISP_HIST_H_SIZE: %d\n", - cifisp_ioread32(CIF_ISP_HIST_H_SIZE)); - CIFISP_DPRINT(level, " CIF_ISP_HIST_V_OFFS: %d\n", - cifisp_ioread32(CIF_ISP_HIST_V_OFFS)); - CIFISP_DPRINT(level, " CIF_ISP_HIST_V_SIZE: %d\n", - cifisp_ioread32(CIF_ISP_HIST_V_SIZE)); - CIFISP_DPRINT(level, - "#### %s: HST Registers - END ####\n", - ISP_VDEV_NAME); - } + case CIFISP_MODULE_HST: + CIFISP_DPRINT(level, + "#### %s: HST Registers - BEGIN ####\n", + ISP_VDEV_NAME); + CIFISP_DPRINT(level, " CIF_ISP_HIST_PROP: %d\n", + cifisp_ioread32(CIF_ISP_HIST_PROP)); + CIFISP_DPRINT(level, " CIF_ISP_HIST_H_OFFS: %d\n", + cifisp_ioread32(CIF_ISP_HIST_H_OFFS)); + CIFISP_DPRINT(level, " CIF_ISP_HIST_H_SIZE: %d\n", + cifisp_ioread32(CIF_ISP_HIST_H_SIZE)); + CIFISP_DPRINT(level, " CIF_ISP_HIST_V_OFFS: %d\n", + cifisp_ioread32(CIF_ISP_HIST_V_OFFS)); + CIFISP_DPRINT(level, " CIF_ISP_HIST_V_SIZE: %d\n", + cifisp_ioread32(CIF_ISP_HIST_V_SIZE)); + CIFISP_DPRINT(level, + "#### %s: HST Registers - END ####\n", + ISP_VDEV_NAME); break; - case CIFISP_MODULE_AEC:{ - CIFISP_DPRINT(level, - "#### %s: AEC Registers - BEGIN ####\n", - ISP_VDEV_NAME); - CIFISP_DPRINT(level, " CIF_ISP_EXP_CTRL: %d\n", - cifisp_ioread32(CIF_ISP_EXP_CTRL)); - CIFISP_DPRINT(level, " CIF_ISP_EXP_H_OFFSET: %d\n", - cifisp_ioread32(CIF_ISP_EXP_H_OFFSET)); - CIFISP_DPRINT(level, " CIF_ISP_EXP_V_OFFSET: %d\n", - cifisp_ioread32(CIF_ISP_EXP_V_OFFSET)); - CIFISP_DPRINT(level, " CIF_ISP_EXP_H_SIZE: %d\n", - cifisp_ioread32(CIF_ISP_EXP_H_SIZE)); - CIFISP_DPRINT(level, " CIF_ISP_EXP_V_SIZE: %d\n", - cifisp_ioread32(CIF_ISP_EXP_V_SIZE)); - CIFISP_DPRINT(level, - "#### %s: AEC Registers - END ####\n", - ISP_VDEV_NAME); - } + case CIFISP_MODULE_AEC: + CIFISP_DPRINT(level, + "#### %s: AEC Registers - BEGIN ####\n", + ISP_VDEV_NAME); + CIFISP_DPRINT(level, " CIF_ISP_EXP_CTRL: %d\n", + cifisp_ioread32(CIF_ISP_EXP_CTRL)); + CIFISP_DPRINT(level, " CIF_ISP_EXP_H_OFFSET: %d\n", + cifisp_ioread32(CIF_ISP_EXP_H_OFFSET)); + CIFISP_DPRINT(level, " CIF_ISP_EXP_V_OFFSET: %d\n", + cifisp_ioread32(CIF_ISP_EXP_V_OFFSET)); + CIFISP_DPRINT(level, " CIF_ISP_EXP_H_SIZE: %d\n", + cifisp_ioread32(CIF_ISP_EXP_H_SIZE)); + CIFISP_DPRINT(level, " CIF_ISP_EXP_V_SIZE: %d\n", + cifisp_ioread32(CIF_ISP_EXP_V_SIZE)); + CIFISP_DPRINT(level, + "#### %s: AEC Registers - END ####\n", + ISP_VDEV_NAME); break; - case CIFISP_MODULE_CPROC:{ - CIFISP_DPRINT(level, - "#### %s: CPROC Registers - BEGIN ####\n", - ISP_VDEV_NAME); - CIFISP_DPRINT(level, " ctrl: %d\n", - cifisp_ioread32(CIF_C_PROC_CTRL)); - CIFISP_DPRINT(level, " contrast: %d\n", - cifisp_ioread32(CIF_C_PROC_CONTRAST)); - CIFISP_DPRINT(level, " hue: %d\n", - cifisp_ioread32(CIF_C_PROC_HUE)); - CIFISP_DPRINT(level, " sat: %d\n", - cifisp_ioread32(CIF_C_PROC_SATURATION)); - CIFISP_DPRINT(level, " brightness: %d\n", - cifisp_ioread32(CIF_C_PROC_BRIGHTNESS)); - CIFISP_DPRINT(level, - "#### %s: CPROC Registers - END ####\n", - ISP_VDEV_NAME); - } + case CIFISP_MODULE_CPROC: + CIFISP_DPRINT(level, + "#### %s: CPROC Registers - BEGIN ####\n", + ISP_VDEV_NAME); + CIFISP_DPRINT(level, " ctrl: %d\n", + cifisp_ioread32(CIF_C_PROC_CTRL)); + CIFISP_DPRINT(level, " contrast: %d\n", + cifisp_ioread32(CIF_C_PROC_CONTRAST)); + CIFISP_DPRINT(level, " hue: %d\n", + cifisp_ioread32(CIF_C_PROC_HUE)); + CIFISP_DPRINT(level, " sat: %d\n", + cifisp_ioread32(CIF_C_PROC_SATURATION)); + CIFISP_DPRINT(level, " brightness: %d\n", + cifisp_ioread32(CIF_C_PROC_BRIGHTNESS)); + CIFISP_DPRINT(level, + "#### %s: CPROC Registers - END ####\n", + ISP_VDEV_NAME); break; - case CIFISP_MODULE_AFC:{ - CIFISP_DPRINT(level, - "#### %s: AFC Registers - BEGIN ####\n", - ISP_VDEV_NAME); - CIFISP_DPRINT(level, " afm_ctr: %d\n", - cifisp_ioread32(CIF_ISP_AFM_CTRL)); - CIFISP_DPRINT(level, " afm_lt_a: %d\n", - cifisp_ioread32(CIF_ISP_AFM_LT_A)); - CIFISP_DPRINT(level, " afm_rb_a: %d\n", - cifisp_ioread32(CIF_ISP_AFM_RB_A)); - CIFISP_DPRINT(level, " afm_lt_b: %d\n", - cifisp_ioread32(CIF_ISP_AFM_LT_B)); - CIFISP_DPRINT(level, " afm_rb_b: %d\n", - cifisp_ioread32(CIF_ISP_AFM_RB_B)); - CIFISP_DPRINT(level, " afm_lt_c: %d\n", - cifisp_ioread32(CIF_ISP_AFM_LT_C)); - CIFISP_DPRINT(level, " afm_rb_c: %d\n", - cifisp_ioread32(CIF_ISP_AFM_RB_C)); - CIFISP_DPRINT(level, " afm_thres: %d\n", - cifisp_ioread32(CIF_ISP_AFM_THRES)); - CIFISP_DPRINT(level, " afm_var_shift: %d\n", - cifisp_ioread32(CIF_ISP_AFM_VAR_SHIFT)); - CIFISP_DPRINT(level, - "#### %s: YCFLT Registers - END ####\n", - ISP_VDEV_NAME); - } + case CIFISP_MODULE_AFC: + CIFISP_DPRINT(level, + "#### %s: AFC Registers - BEGIN ####\n", + ISP_VDEV_NAME); + CIFISP_DPRINT(level, " afm_ctr: %d\n", + cifisp_ioread32(CIF_ISP_AFM_CTRL)); + CIFISP_DPRINT(level, " afm_lt_a: %d\n", + cifisp_ioread32(CIF_ISP_AFM_LT_A)); + CIFISP_DPRINT(level, " afm_rb_a: %d\n", + cifisp_ioread32(CIF_ISP_AFM_RB_A)); + CIFISP_DPRINT(level, " afm_lt_b: %d\n", + cifisp_ioread32(CIF_ISP_AFM_LT_B)); + CIFISP_DPRINT(level, " afm_rb_b: %d\n", + cifisp_ioread32(CIF_ISP_AFM_RB_B)); + CIFISP_DPRINT(level, " afm_lt_c: %d\n", + cifisp_ioread32(CIF_ISP_AFM_LT_C)); + CIFISP_DPRINT(level, " afm_rb_c: %d\n", + cifisp_ioread32(CIF_ISP_AFM_RB_C)); + CIFISP_DPRINT(level, " afm_thres: %d\n", + cifisp_ioread32(CIF_ISP_AFM_THRES)); + CIFISP_DPRINT(level, " afm_var_shift: %d\n", + cifisp_ioread32(CIF_ISP_AFM_VAR_SHIFT)); + CIFISP_DPRINT(level, + "#### %s: YCFLT Registers - END ####\n", + ISP_VDEV_NAME); break; default: CIFISP_DPRINT(level, "####%s: Invalid Module ID ####\n", diff --git a/drivers/media/platform/rk-isp10/cif_isp10_isp.h b/drivers/media/platform/rk-isp10/cif_isp10_isp.h index 006c808ffca5..2b3867bb389f 100644 --- a/drivers/media/platform/rk-isp10/cif_isp10_isp.h +++ b/drivers/media/platform/rk-isp10/cif_isp10_isp.h @@ -25,6 +25,8 @@ /* * ISP device struct */ +#define CIF_ISP10_META_INFO_NUM 2 + enum cif_isp10_pix_fmt; enum cif_isp10_pix_fmt_quantization { @@ -33,18 +35,34 @@ enum cif_isp10_pix_fmt_quantization { CIF_ISP10_QUANTIZATION_LIM_RANGE = 2 }; +struct cif_isp10_isp_meta_info { + unsigned int write_id; + unsigned int read_id; + unsigned int read_cnt; + unsigned int read_max; + unsigned int frame_id[CIF_ISP10_META_INFO_NUM]; + struct timeval vs_t[CIF_ISP10_META_INFO_NUM]; + struct timeval fi_t[CIF_ISP10_META_INFO_NUM]; +}; + +struct cif_isp10_isp_cfgs_log { + unsigned int s_frame_id[3]; + unsigned int new_id; + unsigned int curr_id; +}; + struct cif_isp10_isp_other_cfgs { - struct cifisp_isp_other_cfg *last_or_new; - struct cifisp_isp_other_cfg *curr; - struct cifisp_isp_other_cfg cfgs[2]; + struct cif_isp10_isp_cfgs_log log[CIFISP_MODULE_MAX]; + struct cifisp_isp_other_cfg cfgs[3]; unsigned int module_updates; + unsigned int module_actives; }; struct cif_isp10_isp_meas_cfgs { - struct cifisp_isp_meas_cfg *last_or_new; - struct cifisp_isp_meas_cfg *curr; - struct cifisp_isp_meas_cfg cfgs[2]; + struct cif_isp10_isp_cfgs_log log[CIFISP_MODULE_MAX]; + struct cifisp_isp_meas_cfg cfgs[3]; unsigned int module_updates; + unsigned int module_actives; }; struct cif_isp10_isp_meas_stats { @@ -87,10 +105,17 @@ struct cif_isp10_isp_dev { unsigned int frame_id; unsigned int frame_id_setexp; unsigned int active_meas; + unsigned int meas_send_alone; + + bool awb_meas_ready; + bool afm_meas_ready; + bool aec_meas_ready; + bool hst_meas_ready; struct timeval vs_t; /* updated each frame */ struct timeval fi_t; /* updated each frame */ struct workqueue_struct *readout_wq; + struct cif_isp10_isp_meta_info meta_info; unsigned int *dev_id; @@ -107,11 +132,13 @@ struct cif_isp10_isp_readout_work { struct cif_isp10_isp_dev *isp_dev; unsigned int frame_id; + unsigned int active_meas; struct timeval vs_t; struct timeval fi_t; enum cif_isp10_isp_readout_cmd readout; struct vb2_buffer *vb; unsigned int stream_id; + struct cifisp_isp_metadata *isp_metadata; }; int register_cifisp_device( @@ -126,11 +153,14 @@ void cifisp_configure_isp( enum cif_isp10_pix_fmt_quantization quantization); void cifisp_disable_isp(struct cif_isp10_isp_dev *isp_dev); int cifisp_isp_isr(struct cif_isp10_isp_dev *isp_dev, u32 isp_mis); +void cifisp_clr_readout_wq(struct cif_isp10_isp_dev *isp_dev); void cifisp_v_start(struct cif_isp10_isp_dev *isp_dev, const struct timeval *timestamp); void cifisp_frame_in( struct cif_isp10_isp_dev *isp_dev, const struct timeval *fi_t); +void cifisp_frame_id_reset( + struct cif_isp10_isp_dev *isp_dev); void cifisp_isp_readout_work(struct work_struct *work); #endif diff --git a/drivers/media/platform/rk-isp10/cif_isp10_pltfrm.c b/drivers/media/platform/rk-isp10/cif_isp10_pltfrm.c index 66d694ef8140..98a865a97cd4 100644 --- a/drivers/media/platform/rk-isp10/cif_isp10_pltfrm.c +++ b/drivers/media/platform/rk-isp10/cif_isp10_pltfrm.c @@ -29,7 +29,7 @@ #include "cif_isp10.h" #include #include "cif_isp10_regs.h" -#ifndef CONFIG_DEBUG_FS +#ifdef CONFIG_DEBUG_FS #include #include #include @@ -67,12 +67,8 @@ struct cif_isp10_pltfrm_data { int mis; int (*isr)(unsigned int mis, void *cntxt); } irq_handlers[4]; - struct list_head csi0_configs; - struct list_head csi1_configs; - s32 exp_time; - u16 gain; -#ifndef CONFIG_DEBUG_FS +#ifdef CONFIG_DEBUG_FS struct { struct dentry *dir; struct dentry *cif_isp10_file; @@ -91,7 +87,7 @@ void cif_isp10_pltfrm_debug_register_print_cb( struct device *dev, void (*print)(void *cntxt, const char *block), void *cntxt) { -#ifndef CONFIG_DEBUG_FS +#ifdef CONFIG_DEBUG_FS struct cif_isp10_pltfrm_data *pdata = dev->platform_data; pdata->dbgfs.print_cntxt = cntxt; @@ -99,334 +95,9 @@ void cif_isp10_pltfrm_debug_register_print_cb( #endif } -#ifndef CONFIG_DEBUG_FS +#ifdef CONFIG_DEBUG_FS #define CIF_ISP10_DBGFS_BUF_SIZE 1024 static char cif_isp10_dbgfs_buf[CIF_ISP10_DBGFS_BUF_SIZE]; - -static int cif_isp10_dbgfs_fill_csi_config_from_string( - struct device *dev, - struct cif_isp10_csi_config *csi_config, - char *strp) -{ - char *token; - - token = strsep(&strp, " "); - if (IS_ERR_OR_NULL(token)) - goto missing_token; - if (IS_ERR_VALUE(kstrtou32(token, 10, - &csi_config->vc))) - goto wrong_token_format; - token = strsep(&strp, " "); - if (IS_ERR_OR_NULL(token)) - goto missing_token; - if (IS_ERR_VALUE(kstrtou32(token, 10, - &csi_config->nb_lanes))) - goto wrong_token_format; - token = strsep(&strp, " "); - if (IS_ERR_OR_NULL(token)) - goto missing_token; - if (IS_ERR_VALUE(kstrtou32(token, 16, - &csi_config->dphy1))) - goto wrong_token_format; - token = strsep(&strp, " "); - if (IS_ERR_OR_NULL(token)) - goto missing_token; - if (IS_ERR_VALUE(kstrtou32(token, 16, - &csi_config->dphy2))) - goto wrong_token_format; - token = strsep(&strp, " "); - if (!IS_ERR_OR_NULL(token)) { - if (IS_ERR_VALUE(kstrtou32(token, 10, - &csi_config->ana_bandgab_bias))) - goto wrong_token_format; - } else { - csi_config->ana_bandgab_bias = (u32)-1; - } - - return 0; -missing_token: - cif_isp10_pltfrm_pr_err(dev, - "missing token, command format is 'push <#lanes> '\n"); - return -EINVAL; -wrong_token_format: - cif_isp10_pltfrm_pr_err(dev, - "wrong token format, command format is 'push <#lanes> '\n"); - return -EINVAL; -} - -static int cif_isp10_dbgfs_csi_configs_init( - struct device *dev, - enum cif_isp10_inp inp, - struct list_head *csi_configs) -{ - int ret = 0; - struct device *img_src_dev = NULL; - struct device_node *parent_node = NULL; - struct device_node *child_node = NULL, *prev_node = NULL; - struct cif_isp10_pltfrm_csi_config *cfg = NULL; - u32 pps; - - img_src_dev = cif_isp10_pltfrm_get_img_src_device(dev, inp); - if (IS_ERR_OR_NULL(img_src_dev)) { - ret = -EFAULT; - goto err; - } - parent_node = of_node_get(img_src_dev->of_node); - put_device(img_src_dev); - img_src_dev = NULL; - - while (!IS_ERR_OR_NULL(child_node = - of_get_next_child(parent_node, prev_node))) { - if (!strncasecmp(child_node->name, - "intel,camera-module-csi-config", - strlen("intel,camera-module-csi-config"))) { - ret = of_property_read_u32(child_node, - "intel,csi-pixels-per-second", &pps); - if (IS_ERR_VALUE(ret)) { - cif_isp10_pltfrm_pr_err(dev, - "reading property 'intel,csi-pixels-per-second'\n"); - goto err; - } - cfg = kmalloc( - sizeof(struct cif_isp10_pltfrm_csi_config), - GFP_KERNEL); - if (!cfg) { - cif_isp10_pltfrm_pr_err(dev, - "memory allocation failed\n"); - ret = -ENOMEM; - goto err; - } - cfg->pps = pps; - ret = cif_isp10_pltfrm_fill_csi_config_from_node( - dev, &cfg->csi_config, child_node); - if (IS_ERR_VALUE(ret)) - goto err; - list_add_tail(&cfg->list, csi_configs); - cfg = NULL; - } - of_node_put(prev_node); - prev_node = child_node; - } - of_node_put(prev_node); - of_node_put(parent_node); - - return 0; -err: - of_node_put(prev_node); - of_node_put(child_node); - of_node_put(parent_node); - kfree(cfg); - if (!IS_ERR_OR_NULL(img_src_dev)) - put_device(img_src_dev); - return ret; -} - -static ssize_t cif_isp10_dbgfs_csi_read( - struct file *f, - char __user *out, - size_t count, - loff_t *pos) -{ - u32 out_size = 0; - u32 str_len; - struct cif_isp10_pltfrm_csi_config *cfg; - u32 index = 0; - struct list_head *list_pos; - struct device *dev = f->f_inode->i_private; - struct cif_isp10_pltfrm_data *pdata = dev->platform_data; - struct list_head *csi_configs; - enum cif_isp10_inp inp; - - if (f->f_inode == pdata->dbgfs.csi0_file->d_inode) { - csi_configs = &pdata->csi0_configs; - inp = CIF_ISP10_INP_CSI_0; - } else if (f->f_inode == pdata->dbgfs.csi1_file->d_inode) { - csi_configs = &pdata->csi1_configs; - inp = CIF_ISP10_INP_CSI_1; - } else { - cif_isp10_pltfrm_pr_err(dev, "wrong file handle\n"); - return -EINVAL; - } - - if (list_empty(csi_configs)) - if (IS_ERR_VALUE(cif_isp10_dbgfs_csi_configs_init( - dev, inp, csi_configs))) - return -EFAULT; - - if (*pos) - return 0; - - list_for_each(list_pos, csi_configs) { - cfg = list_entry(list_pos, - struct cif_isp10_pltfrm_csi_config, list); - sprintf(cif_isp10_dbgfs_buf, - "csi-config-%d:\n" - " pps = %d\n" - " vc = %d\n" - " nb_lanes = %d\n" - " dphy1 = 0x%08x\n" - " dphy2 = 0x%08x\n" - " ana_bandgap_bias = %d\n", - index, - cfg->pps, cfg->csi_config.vc, cfg->csi_config.nb_lanes, - cfg->csi_config.dphy1, cfg->csi_config.dphy2, - cfg->csi_config.ana_bandgab_bias); - index++; - str_len = strnlen(cif_isp10_dbgfs_buf, - CIF_ISP10_DBGFS_BUF_SIZE); - if (str_len > count) { - *pos += out_size; - return 0; - } - *pos = 0; - if (IS_ERR_VALUE(simple_read_from_buffer( - out + out_size, str_len, pos, - cif_isp10_dbgfs_buf, str_len))) - break; - out_size += strnlen(cif_isp10_dbgfs_buf, - CIF_ISP10_DBGFS_BUF_SIZE); - count -= str_len; - } - - *pos += out_size; - return out_size; -} - -static ssize_t cif_isp10_dbgfs_csi_write( - struct file *f, - const char __user *in, - size_t count, - loff_t *pos) -{ - ssize_t ret; - char *strp = cif_isp10_dbgfs_buf; - char *token; - struct device *dev = f->f_inode->i_private; - struct cif_isp10_pltfrm_data *pdata = dev->platform_data; - struct list_head *csi_configs; - enum cif_isp10_inp inp; - - if (count > CIF_ISP10_DBGFS_BUF_SIZE) { - cif_isp10_pltfrm_pr_err(dev, "command line too large\n"); - return -EINVAL; - } - - if (f->f_inode == pdata->dbgfs.csi0_file->d_inode) { - csi_configs = &pdata->csi0_configs; - inp = CIF_ISP10_INP_CSI_0; - } else if (f->f_inode == pdata->dbgfs.csi1_file->d_inode) { - csi_configs = &pdata->csi1_configs; - inp = CIF_ISP10_INP_CSI_1; - } else { - cif_isp10_pltfrm_pr_err(dev, "wrong file handle\n"); - return -EINVAL; - } - - if (list_empty(csi_configs)) - if (IS_ERR_VALUE(cif_isp10_dbgfs_csi_configs_init( - dev, inp, csi_configs))) - return -EFAULT; - - memset(cif_isp10_dbgfs_buf, 0, CIF_ISP10_DBGFS_BUF_SIZE); - ret = simple_write_to_buffer(strp, - CIF_ISP10_DBGFS_BUF_SIZE, pos, in, count); - if (IS_ERR_VALUE(ret)) - return ret; - - token = strsep(&strp, " "); - if (!strcmp(token, "push")) { - struct cif_isp10_pltfrm_csi_config cfg; - - token = strsep(&strp, " "); - if (IS_ERR_OR_NULL(token)) { - cif_isp10_pltfrm_pr_err(dev, - "missing token, command format is 'push <#lanes> '\n"); - return -EINVAL; - } - if (IS_ERR_VALUE(kstrtou32(token, 10, - &cfg.pps))) { - cif_isp10_pltfrm_pr_err(dev, - "missing token, command format is 'push <#lanes> '\n"); - return -EINVAL; - } - ret = cif_isp10_dbgfs_fill_csi_config_from_string( - dev, &cfg.csi_config, strp); - if (IS_ERR_VALUE(ret)) - return ret; - ret = cif_isp10_pltfrm_l_s_csi_config( - dev, inp, cfg.pps, &cfg.csi_config); - if (IS_ERR_VALUE(ret)) - return ret; - } else if (!strncmp(token, "reset", 5)) { - } else { - cif_isp10_pltfrm_pr_err(dev, "unknown command %s\n", token); - return -EINVAL; - } - - return count; -} - -void cif_isp10_dbgfs_fill_sensor_aec_para( - struct cif_isp10_device *cif_isp10_dev, - s32 exp_time, - u16 gain) -{ - struct cif_isp10_pltfrm_data *pdata; - - pdata = (struct cif_isp10_pltfrm_data *) - cif_isp10_dev->dev->platform_data; - pdata->exp_time = exp_time; - pdata->gain = gain; -} - -static ssize_t cif_isp10_dbgfs_sensor_read( - struct file *f, - char __user *out, - size_t count, - loff_t *pos) -{ - u32 out_size = 0; - u32 str_len; - struct device *dev = f->f_inode->i_private; - struct cif_isp10_pltfrm_data *pdata = dev->platform_data; - - if (*pos) - return 0; - - sprintf(cif_isp10_dbgfs_buf, - "sensor current exp_time: %d\n" - " gain = %d\n", - pdata->exp_time, - pdata->gain); - str_len = strnlen(cif_isp10_dbgfs_buf, - CIF_ISP10_DBGFS_BUF_SIZE); - if (str_len > count) { - *pos += out_size; - return 0; - } - *pos = 0; - if (IS_ERR_VALUE(simple_read_from_buffer( - out + out_size, str_len, pos, - cif_isp10_dbgfs_buf, str_len))) - goto ERR; - out_size += strnlen(cif_isp10_dbgfs_buf, - CIF_ISP10_DBGFS_BUF_SIZE); - count -= str_len; - - *pos += out_size; -ERR: - return out_size; -} - -static ssize_t cif_isp10_dbgfs_sensor_write( - struct file *f, - const char __user *in, - size_t count, - loff_t *pos) -{ - return 0; -} - static ssize_t cif_isp10_dbgfs_write( struct file *f, const char __user *in, @@ -497,7 +168,7 @@ static ssize_t cif_isp10_dbgfs_write( } if (!strncmp(token, "on", 2)) { if (IS_ERR_VALUE(cif_isp10_pltfrm_pm_set_state(dev, - CIF_ISP10_PM_STATE_SW_STNDBY, NULL))) + CIF_ISP10_PM_STATE_SW_STNDBY))) cif_isp10_pltfrm_pr_err(dev, "power on failed\n"); else @@ -505,7 +176,7 @@ static ssize_t cif_isp10_dbgfs_write( "switched on\n"); } else if (!strncmp(token, "off", 3)) { if (IS_ERR_VALUE(cif_isp10_pltfrm_pm_set_state(dev, - CIF_ISP10_PM_STATE_OFF, NULL))) + CIF_ISP10_PM_STATE_OFF))) cif_isp10_pltfrm_pr_err(dev, "power off failed\n"); else @@ -556,20 +227,10 @@ static ssize_t cif_isp10_dbgfs_write( return count; } -static const struct file_operations cif_isp10_dbgfs_csi_fops = { - .read = cif_isp10_dbgfs_csi_read, - .write = cif_isp10_dbgfs_csi_write -}; - static const struct file_operations cif_isp10_dbgfs_fops = { .write = cif_isp10_dbgfs_write }; -static const struct file_operations cif_isp10_dbgfs_sensor_fops = { - .read = cif_isp10_dbgfs_sensor_read, - .write = cif_isp10_dbgfs_sensor_write -}; - #ifdef CONFIG_CIF_ISP10_REG_TRACE static inline int cif_isp10_pltfrm_trace_printf( @@ -614,7 +275,7 @@ static inline int cif_isp10_pltfrm_trace_printf( return i; } -inline int cif_isp10_pltfrm_rtrace_printf( +int cif_isp10_pltfrm_rtrace_printf( struct device *dev, const char *fmt, ...) @@ -629,7 +290,7 @@ inline int cif_isp10_pltfrm_rtrace_printf( return i; } -inline int cif_isp10_pltfrm_ftrace_printf( +int cif_isp10_pltfrm_ftrace_printf( struct device *dev, const char *fmt, ...) @@ -1290,35 +951,15 @@ int cif_isp10_pltfrm_dev_init( dev->platform_data = pdata; - INIT_LIST_HEAD(&pdata->csi0_configs); - INIT_LIST_HEAD(&pdata->csi1_configs); - -#ifndef CONFIG_DEBUG_FS +#ifdef CONFIG_DEBUG_FS pdata->dbgfs.dir = debugfs_create_dir("cif_isp10", NULL); - pdata->dbgfs.csi0_file = debugfs_create_file( - "csi-0", - 0644, - pdata->dbgfs.dir, - dev, - &cif_isp10_dbgfs_csi_fops); - pdata->dbgfs.csi1_file = debugfs_create_file( - "csi-1", - 0644, - pdata->dbgfs.dir, - dev, - &cif_isp10_dbgfs_csi_fops); pdata->dbgfs.cif_isp10_file = debugfs_create_file( "cif_isp20", 0200, pdata->dbgfs.dir, dev, &cif_isp10_dbgfs_fops); - pdata->dbgfs.cif_isp10_file = debugfs_create_file( - "sensor", - 0644, - pdata->dbgfs.dir, - dev, - &cif_isp10_dbgfs_sensor_fops); + #ifdef CONFIG_CIF_ISP10_REG_TRACE pdata->dbgfs.reg_trace_file = debugfs_create_file( "reg_trace", @@ -1450,7 +1091,7 @@ int cif_isp10_pltfrm_g_interface_config( PLTFRM_CIFCAM_G_ITF_CFG, (void *)cam_itf); if (IS_ERR_VALUE(ret)) { cif_isp10_pltfrm_pr_err( - dev, + NULL, "cif_isp10_img_src_ioctl PLTFRM_CIFCAM_G_ITF_CFG failed!\n"); return ret; } @@ -1669,8 +1310,6 @@ int cif_isp10_pltfrm_get_img_src_device( array_len); break; } - } else { - continue; } } @@ -1691,7 +1330,7 @@ void cif_isp10_pltfrm_dev_release( cif_isp10_drm_iommu_cb(dev, cif_isp10_dev, false); #endif -#ifndef CONFIG_DEBUG_FS +#ifdef CONFIG_DEBUG_FS { struct cif_isp10_pltfrm_data *pdata = dev->platform_data; diff --git a/drivers/media/platform/rk-isp10/cif_isp10_v4l2.c b/drivers/media/platform/rk-isp10/cif_isp10_v4l2.c index ae04c07e10b5..e97fa4c20fda 100644 --- a/drivers/media/platform/rk-isp10/cif_isp10_v4l2.c +++ b/drivers/media/platform/rk-isp10/cif_isp10_v4l2.c @@ -30,10 +30,10 @@ #include #include -#define CIF_ISP10_V4L2_SP_DEV_MAJOR 0 -#define CIF_ISP10_V4L2_ISP_DEV_MAJOR 1 -#define CIF_ISP10_V4L2_MP_DEV_MAJOR 2 -#define CIF_ISP10_V4L2_DMA_DEV_MAJOR 3 +#define CIF_ISP10_V4L2_SP_DEV_MAJOR -1 +#define CIF_ISP10_V4L2_ISP_DEV_MAJOR -1 +#define CIF_ISP10_V4L2_MP_DEV_MAJOR -1 +#define CIF_ISP10_V4L2_DMA_DEV_MAJOR -1 #define SP_DEV 0 #define MP_DEV 1 @@ -330,6 +330,8 @@ static enum cif_isp10_pix_fmt cif_isp10_v4l2_pix_fmt2cif_isp10_pix_fmt( switch (v4l2_pix_fmt) { case V4L2_PIX_FMT_GREY: return CIF_YUV400; + case V4L2_PIX_FMT_Y10: + return CIF_Y10; case V4L2_PIX_FMT_YUV420: return CIF_YUV420P; case V4L2_PIX_FMT_YVU420: @@ -506,6 +508,31 @@ static int cif_isp10_v4l2_register_video_device( return ret; } +static int cif_isp10_v4l2_register_imgsrc_subdev( + struct cif_isp10_device *dev) +{ + unsigned int i; + struct v4l2_subdev *sd; + + for (i = 0; i < dev->img_src_cnt; i++) { + if (dev->img_src_array[i] != NULL) { + sd = (struct v4l2_subdev *) + cif_isp10_img_src_g_img_src( + dev->img_src_array[i]); + if (sd) { + if (v4l2_device_register_subdev( + &dev->v4l2_dev, + sd) < 0) + cif_isp10_pltfrm_pr_err(dev->dev, + "register subdev(%s) failed!", + cif_isp10_img_src_g_name(dev->img_src_array[i])); + } + } + } + + return v4l2_device_register_subdev_nodes(&dev->v4l2_dev); +} + static int cif_isp10_v4l2_streamon( struct file *file, void *priv, @@ -1133,18 +1160,24 @@ static unsigned int cif_isp10_v4l2_poll( */ static void cif_isp10_v4l2_vm_open(struct vm_area_struct *vma) { + unsigned long flags = 0; struct cif_isp10_metadata_s *metadata = (struct cif_isp10_metadata_s *)vma->vm_private_data; + spin_lock_irqsave(&metadata->spinlock, flags); metadata->vmas++; + spin_unlock_irqrestore(&metadata->spinlock, flags); } static void cif_isp10_v4l2_vm_close(struct vm_area_struct *vma) { + unsigned long flags = 0; struct cif_isp10_metadata_s *metadata = (struct cif_isp10_metadata_s *)vma->vm_private_data; + spin_lock_irqsave(&metadata->spinlock, flags); metadata->vmas--; + spin_unlock_irqrestore(&metadata->spinlock, flags); } static const struct vm_operations_struct cif_isp10_vm_ops = { @@ -1348,6 +1381,30 @@ static long v4l2_default_ioctl(struct file *file, void *fh, "failed to get camera module information\n"); return ret; } + } else if (cmd == RK_VIDIOC_SENSOR_CONFIGINFO) { + struct sensor_config_info_s *p_sensor_config = + (struct sensor_config_info_s *)arg; + + ret = (int)cif_isp10_img_src_ioctl(dev->img_src, + RK_VIDIOC_SENSOR_CONFIGINFO, p_sensor_config); + + if (ret < 0) { + cif_isp10_pltfrm_pr_err(dev->dev, + "failed to get camera module information\n"); + return ret; + } + } else if (cmd == RK_VIDIOC_SENSOR_REG_ACCESS) { + struct sensor_reg_rw_s *p_sensor_rw = + (struct sensor_reg_rw_s *)arg; + + ret = (int)cif_isp10_img_src_ioctl(dev->img_src, + RK_VIDIOC_SENSOR_REG_ACCESS, p_sensor_rw); + + if (ret < 0) { + cif_isp10_pltfrm_pr_err(dev->dev, + "failed to get camera module information\n"); + return ret; + } } return ret; @@ -1511,9 +1568,9 @@ static int v4l2_s_ext_ctrls(struct file *file, void *priv, struct v4l2_ext_controls *vc_ext) { struct cif_isp10_img_src_ctrl *ctrls; - struct cif_isp10_img_src_ext_ctrl *ctrl; struct vb2_queue *queue = to_vb2_queue(file); struct cif_isp10_device *dev = to_cif_isp10_device(queue); + struct cif_isp10_img_src_ext_ctrl ctrl; int ret = -EINVAL; unsigned int i; @@ -1526,30 +1583,24 @@ static int v4l2_s_ext_ctrls(struct file *file, void *priv, if (vc_ext->count == 0) return ret; - ctrl = kmalloc(sizeof(*ctrl), GFP_KERNEL); - if (!ctrl) - return -ENOMEM; - ctrls = kmalloc(vc_ext->count * sizeof(struct cif_isp10_img_src_ctrl), GFP_KERNEL); - if (!ctrls) { - kfree(ctrl); + if (!ctrls) return -ENOMEM; - } - ctrl->cnt = vc_ext->count; + ctrl.cnt = vc_ext->count; /*current kernel version don't define *this member for struct v4l2_ext_control. */ - /*ctrl->class = vc_ext->ctrl_class;*/ - ctrl->ctrls = ctrls; + /*ctrl.class = vc_ext->ctrl_class;*/ + ctrl.ctrls = ctrls; for (i = 0; i < vc_ext->count; i++) { ctrls[i].id = vc_ext->controls[i].id; ctrls[i].val = vc_ext->controls[i].value; } - ret = cif_isp10_s_exp(dev, ctrl); + ret = cif_isp10_s_exp(dev, &ctrl); return ret; } @@ -1768,7 +1819,8 @@ static const struct of_device_id cif_isp10_v4l2_of_match[] = { {}, }; -static unsigned int cif_isp10_v4l2_dev_cnt; +static unsigned int g_cif_isp10_v4l2_dev_cnt; +static struct cif_isp10_v4l2_device *g_cif_isp10_v4l2_dev[4]; static int cif_isp10_v4l2_drv_probe(struct platform_device *pdev) { const struct of_device_id *match; @@ -1777,7 +1829,10 @@ static int cif_isp10_v4l2_drv_probe(struct platform_device *pdev) struct cif_isp10_v4l2_device *cif_isp10_v4l2_dev; int ret; - cif_isp10_pltfrm_pr_info(NULL, "probing...\n"); + cif_isp10_pltfrm_pr_info(NULL, "CIF ISP10 driver version: v%x.%x.%x\n", + CONFIG_CIFISP10_DRIVER_VERSION >> 16, + (CONFIG_CIFISP10_DRIVER_VERSION & 0xff00) >> 8, + CONFIG_CIFISP10_DRIVER_VERSION & 0x00ff); cif_isp10_v4l2_dev = devm_kzalloc( &pdev->dev, @@ -1798,7 +1853,7 @@ static int cif_isp10_v4l2_drv_probe(struct platform_device *pdev) goto err; } - dev->dev_id = cif_isp10_v4l2_dev_cnt; + dev->dev_id = g_cif_isp10_v4l2_dev_cnt; dev->isp_dev.dev_id = &dev->dev_id; dev->nodes = (void *)cif_isp10_v4l2_dev; dev->isp_state = CIF_ISP10_STATE_IDLE; @@ -1855,9 +1910,14 @@ static int cif_isp10_v4l2_drv_probe(struct platform_device *pdev) if (ret) goto err; + cif_isp10_v4l2_register_imgsrc_subdev( + dev); + pm_runtime_enable(&pdev->dev); - cif_isp10_v4l2_dev_cnt++; + g_cif_isp10_v4l2_dev[g_cif_isp10_v4l2_dev_cnt] = + cif_isp10_v4l2_dev; + g_cif_isp10_v4l2_dev_cnt++; return 0; err: cif_isp10_destroy(dev); @@ -1886,7 +1946,8 @@ static int cif_isp10_v4l2_drv_remove(struct platform_device *pdev) cif_isp10_pltfrm_dev_release(&pdev->dev, cif_isp10_dev); cif_isp10_destroy(cif_isp10_dev); - cif_isp10_v4l2_dev_cnt--; + g_cif_isp10_v4l2_dev_cnt--; + g_cif_isp10_v4l2_dev[g_cif_isp10_v4l2_dev_cnt] = NULL; return 0; } @@ -1976,6 +2037,7 @@ static int cif_isp10_v4l2_init(void) { int ret; + g_cif_isp10_v4l2_dev_cnt = 0; ret = platform_driver_register(&cif_isp10_v4l2_plat_drv); if (ret) { cif_isp10_pltfrm_pr_err(NULL, @@ -1993,6 +2055,74 @@ static void __exit cif_isp10_v4l2_exit(void) platform_driver_unregister(&cif_isp10_v4l2_plat_drv); } +/* ======================================================================== */ +void cif_isp10_v4l2_s_frame_interval( + unsigned int numerator, + unsigned int denominator) +{ + struct cif_isp10_v4l2_device *cif_isp10_v4l2_dev; + struct cif_isp10_device *cif_isp10_dev; + struct vb2_queue *queue; + struct cif_isp10_frm_intrvl frm_intrvl; + unsigned int i; + + for (i = 0; i < g_cif_isp10_v4l2_dev_cnt; i++) { + if (g_cif_isp10_v4l2_dev[i] == NULL) + continue; + + cif_isp10_v4l2_dev = + g_cif_isp10_v4l2_dev[i]; + queue = (struct vb2_queue *) + &cif_isp10_v4l2_dev->node[SP_DEV].buf_queue; + cif_isp10_dev = to_cif_isp10_device(queue); + + if (cif_isp10_dev->img_src == NULL) + continue; + + frm_intrvl.numerator = numerator; + frm_intrvl.denominator = denominator; + cif_isp10_img_src_s_frame_interval( + cif_isp10_dev->img_src, + &frm_intrvl); + } +} + +int cif_isp10_v4l2_g_frame_interval( + unsigned int *numerator, + unsigned int *denominator) +{ + struct cif_isp10_v4l2_device *cif_isp10_v4l2_dev; + struct cif_isp10_device *cif_isp10_dev; + struct vb2_queue *queue; + struct cif_isp10_frm_intrvl frm_intrvl; + unsigned int i; + int ret = -EFAULT; + + for (i = 0; i < g_cif_isp10_v4l2_dev_cnt; i++) { + if (g_cif_isp10_v4l2_dev[i] == NULL) + continue; + + cif_isp10_v4l2_dev = + g_cif_isp10_v4l2_dev[i]; + queue = (struct vb2_queue *) + &cif_isp10_v4l2_dev->node[SP_DEV].buf_queue; + cif_isp10_dev = to_cif_isp10_device(queue); + + if (cif_isp10_dev->img_src == NULL) + continue; + + ret = cif_isp10_img_src_g_frame_interval( + cif_isp10_dev->img_src, + &frm_intrvl); + if (ret == 0) { + *numerator = frm_intrvl.numerator; + *denominator = frm_intrvl.denominator; + } + } + + return ret; +} + device_initcall_sync(cif_isp10_v4l2_init); module_exit(cif_isp10_v4l2_exit); diff --git a/drivers/media/platform/rk-isp10/cif_isp10_version.h b/drivers/media/platform/rk-isp10/cif_isp10_version.h index c13ba690285b..31c95cf82730 100644 --- a/drivers/media/platform/rk-isp10/cif_isp10_version.h +++ b/drivers/media/platform/rk-isp10/cif_isp10_version.h @@ -103,8 +103,11 @@ *5. modify for af function. *6. add module parameter for dumpsys. * + *v0.1.0xf + *1. merge modification from rv1108 project. + * */ -#define CONFIG_CIFISP10_DRIVER_VERSION KERNEL_VERSION(0, 1, 0xe) +#define CONFIG_CIFISP10_DRIVER_VERSION KERNEL_VERSION(0, 1, 0xf) #endif diff --git a/include/media/rk-isp10-config.h b/include/media/rk-isp10-config.h index f64af7f9f8f0..63e02e7e93f4 100644 --- a/include/media/rk-isp10-config.h +++ b/include/media/rk-isp10-config.h @@ -18,24 +18,47 @@ #include -#define CIFISP_MODULE_DPCC BIT(0) -#define CIFISP_MODULE_BLS BIT(1) -#define CIFISP_MODULE_SDG BIT(2) -#define CIFISP_MODULE_HST BIT(3) -#define CIFISP_MODULE_LSC BIT(4) -#define CIFISP_MODULE_AWB_GAIN BIT(5) -#define CIFISP_MODULE_FLT BIT(6) -#define CIFISP_MODULE_BDM BIT(7) -#define CIFISP_MODULE_CTK BIT(8) -#define CIFISP_MODULE_GOC BIT(9) -#define CIFISP_MODULE_CPROC BIT(10) -#define CIFISP_MODULE_AFC BIT(11) -#define CIFISP_MODULE_AWB BIT(12) -#define CIFISP_MODULE_IE BIT(13) -#define CIFISP_MODULE_AEC BIT(14) -#define CIFISP_MODULE_WDR BIT(15) -#define CIFISP_MODULE_DPF BIT(16) -#define CIFISP_MODULE_DPF_STRENGTH BIT(17) +#define CIFISP_MODULE_MAX 18 +/* ISP Other module ID */ +#define CIFISP_DPCC_ID 0 +#define CIFISP_BLS_ID 1 +#define CIFISP_SDG_ID 2 +#define CIFISP_LSC_ID 3 +#define CIFISP_AWB_GAIN_ID 4 +#define CIFISP_FLT_ID 5 +#define CIFISP_BDM_ID 6 +#define CIFISP_CTK_ID 7 +#define CIFISP_GOC_ID 8 +#define CIFISP_CPROC_ID 9 +#define CIFISP_IE_ID 10 +#define CIFISP_WDR_ID 11 +#define CIFISP_DPF_ID 12 +#define CIFISP_DPF_STRENGTH_ID 13 +/* ISP Meas module ID, It must be after other id */ +#define CIFISP_MEAS_ID 14 +#define CIFISP_AEC_ID (CIFISP_MEAS_ID + 0) +#define CIFISP_AFC_ID (CIFISP_MEAS_ID + 1) +#define CIFISP_AWB_ID (CIFISP_MEAS_ID + 2) +#define CIFISP_HST_ID (CIFISP_MEAS_ID + 3) + +#define CIFISP_MODULE_DPCC (1 << CIFISP_DPCC_ID) +#define CIFISP_MODULE_BLS (1 << CIFISP_BLS_ID) +#define CIFISP_MODULE_SDG (1 << CIFISP_SDG_ID) +#define CIFISP_MODULE_HST (1 << CIFISP_HST_ID) +#define CIFISP_MODULE_LSC (1 << CIFISP_LSC_ID) +#define CIFISP_MODULE_AWB_GAIN (1 << CIFISP_AWB_GAIN_ID) +#define CIFISP_MODULE_FLT (1 << CIFISP_FLT_ID) +#define CIFISP_MODULE_BDM (1 << CIFISP_BDM_ID) +#define CIFISP_MODULE_CTK (1 << CIFISP_CTK_ID) +#define CIFISP_MODULE_GOC (1 << CIFISP_GOC_ID) +#define CIFISP_MODULE_CPROC (1 << CIFISP_CPROC_ID) +#define CIFISP_MODULE_AFC (1 << CIFISP_AFC_ID) +#define CIFISP_MODULE_AWB (1 << CIFISP_AWB_ID) +#define CIFISP_MODULE_IE (1 << CIFISP_IE_ID) +#define CIFISP_MODULE_AEC (1 << CIFISP_AEC_ID) +#define CIFISP_MODULE_WDR (1 << CIFISP_WDR_ID) +#define CIFISP_MODULE_DPF (1 << CIFISP_DPF_ID) +#define CIFISP_MODULE_DPF_STRENGTH (1 << CIFISP_DPF_STRENGTH_ID) #define CIFISP_CTK_COEFF_MAX 0x100 #define CIFISP_CTK_OFFSET_MAX 0x800 diff --git a/include/media/rk-isp10-ioctl.h b/include/media/rk-isp10-ioctl.h index 22e2e6e8d8a5..367e28003d9e 100644 --- a/include/media/rk-isp10-ioctl.h +++ b/include/media/rk-isp10-ioctl.h @@ -106,22 +106,22 @@ _IOR('v', BASE_VIDIOC_PRIVATE + 35, struct cifisp_last_capture_config) /* CIF-ISP Private control IDs */ -#define V4L2_CID_CIFISP_DPCC (V4L2_CID_PRIVATE_BASE + 0) -#define V4L2_CID_CIFISP_BLS (V4L2_CID_PRIVATE_BASE + 1) -#define V4L2_CID_CIFISP_SDG (V4L2_CID_PRIVATE_BASE + 2) -#define V4L2_CID_CIFISP_LSC (V4L2_CID_PRIVATE_BASE + 3) -#define V4L2_CID_CIFISP_AWB_MEAS (V4L2_CID_PRIVATE_BASE + 4) -#define V4L2_CID_CIFISP_FLT (V4L2_CID_PRIVATE_BASE + 5) -#define V4L2_CID_CIFISP_BDM (V4L2_CID_PRIVATE_BASE + 6) -#define V4L2_CID_CIFISP_CTK (V4L2_CID_PRIVATE_BASE + 7) -#define V4L2_CID_CIFISP_GOC (V4L2_CID_PRIVATE_BASE + 8) -#define V4L2_CID_CIFISP_HST (V4L2_CID_PRIVATE_BASE + 9) -#define V4L2_CID_CIFISP_AEC (V4L2_CID_PRIVATE_BASE + 10) -#define V4L2_CID_CIFISP_AWB_GAIN (V4L2_CID_PRIVATE_BASE + 11) -#define V4L2_CID_CIFISP_CPROC (V4L2_CID_PRIVATE_BASE + 12) -#define V4L2_CID_CIFISP_AFC (V4L2_CID_PRIVATE_BASE + 13) -#define V4L2_CID_CIFISP_IE (V4L2_CID_PRIVATE_BASE + 14) -#define V4L2_CID_CIFISP_DPF (V4L2_CID_PRIVATE_BASE + 15) +#define V4L2_CID_CIFISP_DPCC (V4L2_CID_PRIVATE_BASE + CIFISP_DPCC_ID) +#define V4L2_CID_CIFISP_BLS (V4L2_CID_PRIVATE_BASE + CIFISP_BLS_ID) +#define V4L2_CID_CIFISP_SDG (V4L2_CID_PRIVATE_BASE + CIFISP_SDG_ID) +#define V4L2_CID_CIFISP_HST (V4L2_CID_PRIVATE_BASE + CIFISP_HST_ID) +#define V4L2_CID_CIFISP_LSC (V4L2_CID_PRIVATE_BASE + CIFISP_LSC_ID) +#define V4L2_CID_CIFISP_AWB_GAIN (V4L2_CID_PRIVATE_BASE + CIFISP_AWB_GAIN_ID) +#define V4L2_CID_CIFISP_FLT (V4L2_CID_PRIVATE_BASE + CIFISP_FLT_ID) +#define V4L2_CID_CIFISP_BDM (V4L2_CID_PRIVATE_BASE + CIFISP_BDM_ID) +#define V4L2_CID_CIFISP_CTK (V4L2_CID_PRIVATE_BASE + CIFISP_CTK_ID) +#define V4L2_CID_CIFISP_GOC (V4L2_CID_PRIVATE_BASE + CIFISP_GOC_ID) +#define V4L2_CID_CIFISP_CPROC (V4L2_CID_PRIVATE_BASE + CIFISP_CPROC_ID) +#define V4L2_CID_CIFISP_AFC (V4L2_CID_PRIVATE_BASE + CIFISP_AFC_ID) +#define V4L2_CID_CIFISP_AWB_MEAS (V4L2_CID_PRIVATE_BASE + CIFISP_AWB_ID) +#define V4L2_CID_CIFISP_IE (V4L2_CID_PRIVATE_BASE + CIFISP_IE_ID) +#define V4L2_CID_CIFISP_AEC (V4L2_CID_PRIVATE_BASE + CIFISP_AEC_ID) +#define V4L2_CID_CIFISP_DPF (V4L2_CID_PRIVATE_BASE + CIFISP_DPF_ID) /* Camera Sensors' running modes */ #define CI_MODE_PREVIEW 0x8000 @@ -130,4 +130,11 @@ #define CI_MODE_CONTINUOUS 0x1000 #define CI_MODE_NONE 0x0000 +/* Kernel API */ +void cif_isp11_v4l2_s_frame_interval( + unsigned int numerator, + unsigned int denominator); +int cif_isp11_v4l2_g_frame_interval( + unsigned int *numerator, + unsigned int *denominator); #endif diff --git a/include/media/v4l2-config_rockchip.h b/include/media/v4l2-config_rockchip.h index b7dd7a7a8d7c..0f2cfb6b3c5a 100644 --- a/include/media/v4l2-config_rockchip.h +++ b/include/media/v4l2-config_rockchip.h @@ -19,6 +19,11 @@ #define CAMERA_STRLEN 32 #define CAMERA_METADATA_LEN (2 * PAGE_SIZE) +#define VALID_FR_EXP_T_INDEX 0 +#define VALID_FR_EXP_G_INDEX 1 +#define SENSOR_CONFIG_NUM 4 +#define SENSOR_READ_MODE 0 +#define SENSOR_WRITE_MODE 1 /* Sensor resolution specific data for AE calculation.*/ struct isp_supplemental_sensor_mode_data { @@ -43,6 +48,11 @@ struct isp_supplemental_sensor_mode_data { unsigned int isp_output_height; unsigned char binning_factor_x; /* horizontal binning factor used */ unsigned char binning_factor_y; /* vertical binning factor used */ + /* + *0: Exposure time valid fileds; + *1: Exposure gain valid fileds; + *(2 fileds == 1 frames) + */ unsigned char exposure_valid_frame[2]; int exp_time; unsigned short gain; @@ -65,6 +75,25 @@ struct camera_module_info_s { int af_support; }; +struct sensor_resolution_s { + unsigned short width; + unsigned short height; +}; + +struct sensor_config_info_s { + unsigned char config_num; + unsigned char sensor_fmt[SENSOR_CONFIG_NUM]; + struct sensor_resolution_s reso[SENSOR_CONFIG_NUM]; +}; + +struct sensor_reg_rw_s { + unsigned char reg_access_mode; + unsigned char reg_addr_len; + unsigned char reg_data_len; + unsigned short addr; + unsigned short data; +}; + struct flash_timeinfo_s { struct timeval preflash_start_t; struct timeval preflash_end_t; diff --git a/include/media/v4l2-controls_rockchip.h b/include/media/v4l2-controls_rockchip.h index 010ddf4696b4..c185a58e33da 100644 --- a/include/media/v4l2-controls_rockchip.h +++ b/include/media/v4l2-controls_rockchip.h @@ -24,6 +24,10 @@ _IOWR('v', BASE_VIDIOC_PRIVATE + 10, struct camera_module_info_s) #define RK_VIDIOC_SENSOR_MODE_DATA \ _IOR('v', BASE_VIDIOC_PRIVATE, struct isp_supplemental_sensor_mode_data) +#define RK_VIDIOC_SENSOR_CONFIGINFO \ + _IOR('v', BASE_VIDIOC_PRIVATE + 1, struct sensor_config_info_s) +#define RK_VIDIOC_SENSOR_REG_ACCESS \ + _IOWR('v', BASE_VIDIOC_PRIVATE + 2, struct sensor_reg_rw_s) #define V4L2_CID_USER_RK_BASE (V4L2_CID_USER_BASE + 0x1080) #define RK_V4L2_CID_VBLANKING (V4L2_CID_USER_RK_BASE + 1)