hc
2024-05-14 bedbef8ad3e75a304af6361af235302bcc61d06b
kernel/drivers/media/platform/rockchip/isp/isp_params_v32.c
....@@ -555,11 +555,11 @@
555555 bool is_check, u32 id)
556556 {
557557 struct rkisp_device *dev = params_vdev->dev;
558
- u32 sram_addr, data, table;
558
+ u32 data = isp3_param_read(params_vdev, ISP3X_LSC_CTRL, id);
559
+ u32 sram_addr, table;
559560 int i, j;
560561
561
- if (is_check &&
562
- !(isp3_param_read(params_vdev, ISP3X_LSC_CTRL, id) & ISP_LSC_EN))
562
+ if (is_check && (data & ISP3X_LSC_LUT_EN || !(data & ISP_LSC_EN)))
563563 return;
564564
565565 table = isp3_param_read_direct(params_vdev, ISP3X_LSC_STATUS);
....@@ -643,12 +643,13 @@
643643 * readback mode lsc lut AHB config to sram, once for single device,
644644 * need record to switch for multi-device.
645645 */
646
- if (!IS_HDR_RDBK(dev->rd_mode))
646
+ if (!IS_HDR_RDBK(dev->rd_mode)) {
647647 isp_lsc_matrix_cfg_ddr(params_vdev, arg);
648
- else if (dev->hw_dev->is_single)
649
- isp_lsc_matrix_cfg_sram(params_vdev, arg, false, id);
650
- else
648
+ } else {
649
+ if (dev->hw_dev->is_single)
650
+ isp_lsc_matrix_cfg_sram(params_vdev, arg, false, id);
651651 params_rec->others.lsc_cfg = *arg;
652
+ }
652653 } else {
653654 /* two lsc sram table */
654655 params_rec->others.lsc_cfg = *arg;
....@@ -1435,6 +1436,12 @@
14351436 value &= ISP3X_RAWAE_BIG_EN;
14361437
14371438 wnd_num_idx = arg->wnd_num;
1439
+ if (wnd_num_idx >= ARRAY_SIZE(ae_wnd_num)) {
1440
+ wnd_num_idx = ARRAY_SIZE(ae_wnd_num) - 1;
1441
+ dev_err(params_vdev->dev->dev,
1442
+ "%s invalid wnd_num:%d, set to %d\n",
1443
+ __func__, arg->wnd_num, wnd_num_idx);
1444
+ }
14381445 value |= ISP3X_RAWAE_BIG_WND0_NUM(wnd_num_idx);
14391446
14401447 if (arg->subwin_en[0])
....@@ -1576,20 +1583,19 @@
15761583 isp_rawawb_cfg_sram(struct rkisp_isp_params_vdev *params_vdev,
15771584 const struct isp32_rawawb_meas_cfg *arg, bool is_check, u32 id)
15781585 {
1579
- u32 i, val = ISP32_MODULE_EN;
1586
+ u32 i, val = isp3_param_read(params_vdev, ISP3X_RAWAWB_CTRL, id);
15801587
1581
- if (params_vdev->dev->isp_ver == ISP_V32 && is_check &&
1582
- !(isp3_param_read(params_vdev, ISP3X_RAWAWB_CTRL, id) & val))
1588
+ if (params_vdev->dev->isp_ver != ISP_V32 ||
1589
+ (is_check && !(val & ISP32_MODULE_EN)))
15831590 return;
15841591
15851592 for (i = 0; i < ISP32_RAWAWB_WEIGHT_NUM / 5; i++) {
1586
- isp3_param_write_direct(params_vdev,
1587
- (arg->wp_blk_wei_w[5 * i] & 0x3f) |
1588
- (arg->wp_blk_wei_w[5 * i + 1] & 0x3f) << 6 |
1589
- (arg->wp_blk_wei_w[5 * i + 2] & 0x3f) << 12 |
1590
- (arg->wp_blk_wei_w[5 * i + 3] & 0x3f) << 18 |
1591
- (arg->wp_blk_wei_w[5 * i + 4] & 0x3f) << 24,
1592
- ISP3X_RAWAWB_WRAM_DATA_BASE);
1593
+ val = (arg->wp_blk_wei_w[5 * i] & 0x3f) |
1594
+ (arg->wp_blk_wei_w[5 * i + 1] & 0x3f) << 6 |
1595
+ (arg->wp_blk_wei_w[5 * i + 2] & 0x3f) << 12 |
1596
+ (arg->wp_blk_wei_w[5 * i + 3] & 0x3f) << 18 |
1597
+ (arg->wp_blk_wei_w[5 * i + 4] & 0x3f) << 24;
1598
+ isp3_param_write_direct(params_vdev, val, ISP3X_RAWAWB_WRAM_DATA_BASE);
15931599 }
15941600 }
15951601
....@@ -2255,9 +2261,7 @@
22552261 if (params_vdev->dev->isp_ver == ISP_V32) {
22562262 if (params_vdev->dev->hw_dev->is_single)
22572263 isp_rawawb_cfg_sram(params_vdev, arg, false, id);
2258
- else
2259
- memcpy(arg_rec->wp_blk_wei_w, arg->wp_blk_wei_w,
2260
- ISP32_RAWAWB_WEIGHT_NUM);
2264
+ memcpy(arg_rec->wp_blk_wei_w, arg->wp_blk_wei_w, ISP32_RAWAWB_WEIGHT_NUM);
22612265 } else {
22622266 for (i = 0; i < ISP32L_RAWAWB_WEIGHT_NUM; i++)
22632267 isp3_param_write(params_vdev, arg->win_weight[i],
....@@ -2415,6 +2419,12 @@
24152419 return;
24162420
24172421 wnd_num_idx = arg->wnd_num;
2422
+ if (wnd_num_idx >= ARRAY_SIZE(hist_wnd_num)) {
2423
+ wnd_num_idx = ARRAY_SIZE(hist_wnd_num) - 1;
2424
+ dev_err(params_vdev->dev->dev,
2425
+ "%s invalid wnd_num:%d, set to %d\n",
2426
+ __func__, arg->wnd_num, wnd_num_idx);
2427
+ }
24182428 memset(weight15x15, 0, sizeof(weight15x15));
24192429 for (i = 0; i < hist_wnd_num[wnd_num_idx]; i++) {
24202430 for (j = 0; j < hist_wnd_num[wnd_num_idx]; j++) {
....@@ -2465,6 +2475,12 @@
24652475 }
24662476
24672477 wnd_num_idx = arg->wnd_num;
2478
+ if (wnd_num_idx >= ARRAY_SIZE(hist_wnd_num)) {
2479
+ wnd_num_idx = ARRAY_SIZE(hist_wnd_num) - 1;
2480
+ dev_err(params_vdev->dev->dev,
2481
+ "%s invalid wnd_num:%d, set to %d\n",
2482
+ __func__, arg->wnd_num, wnd_num_idx);
2483
+ }
24682484 /* avoid to override the old enable value */
24692485 hist_ctrl = isp3_param_read(params_vdev, addr + ISP3X_RAWHIST_BIG_CTRL, id);
24702486 hist_ctrl &= ISP3X_RAWHIST_EN;
....@@ -2503,8 +2519,7 @@
25032519
25042520 if (dev->hw_dev->is_single)
25052521 isp_rawhstbig_cfg_sram(params_vdev, arg, blk_no, false, id);
2506
- else
2507
- *arg_rec = *arg;
2522
+ *arg_rec = *arg;
25082523 }
25092524
25102525 static void
....@@ -4269,8 +4284,6 @@
42694284 {
42704285 struct rkisp_isp_params_ops_v32 *ops =
42714286 (struct rkisp_isp_params_ops_v32 *)params_vdev->priv_ops;
4272
- struct rkisp_isp_params_val_v32 *priv_val =
4273
- (struct rkisp_isp_params_val_v32 *)params_vdev->priv_val;
42744287 u64 module_cfg_update = new_params->module_cfg_update;
42754288
42764289 params_vdev->cur_frame_id = new_params->frame_id;
....@@ -4314,9 +4327,7 @@
43144327 if ((module_cfg_update & ISP32_MODULE_RAWHIST3))
43154328 ops->rawhst3_config(params_vdev, &new_params->meas.rawhist3, id);
43164329
4317
- if ((module_cfg_update & ISP32_MODULE_RAWAWB) ||
4318
- ((priv_val->buf_info_owner == RKISP_INFO2DRR_OWNER_AWB) &&
4319
- !(isp3_param_read(params_vdev, ISP3X_RAWAWB_CTRL, id) & ISP32_RAWAWB_2DDR_PATH_EN)))
4330
+ if ((module_cfg_update & ISP32_MODULE_RAWAWB))
43204331 ops->rawawb_config(params_vdev, &new_params->meas.rawawb, id);
43214332 }
43224333
....@@ -5399,18 +5410,18 @@
53995410 else if (new_params->module_en_update ||
54005411 (new_params->module_cfg_update & ISP32_MODULE_FORCE)) {
54015412 /* update en immediately */
5402
- __isp_isr_meas_config(params_vdev, new_params, type, 0);
5403
- __isp_isr_other_config(params_vdev, new_params, type, 0);
5404
- __isp_isr_other_en(params_vdev, new_params, type, 0);
5405
- __isp_isr_meas_en(params_vdev, new_params, type, 0);
5413
+ __isp_isr_meas_config(params_vdev, new_params, RKISP_PARAMS_ALL, 0);
5414
+ __isp_isr_other_config(params_vdev, new_params, RKISP_PARAMS_ALL, 0);
5415
+ __isp_isr_other_en(params_vdev, new_params, RKISP_PARAMS_ALL, 0);
5416
+ __isp_isr_meas_en(params_vdev, new_params, RKISP_PARAMS_ALL, 0);
54065417 new_params->module_cfg_update = 0;
54075418 if (hw->unite) {
54085419 struct isp32_isp_params_cfg *params = new_params + 1;
54095420
5410
- __isp_isr_meas_config(params_vdev, params, type, 1);
5411
- __isp_isr_other_config(params_vdev, params, type, 1);
5412
- __isp_isr_other_en(params_vdev, params, type, 1);
5413
- __isp_isr_meas_en(params_vdev, params, type, 1);
5421
+ __isp_isr_meas_config(params_vdev, params, RKISP_PARAMS_ALL, 1);
5422
+ __isp_isr_other_config(params_vdev, params, RKISP_PARAMS_ALL, 1);
5423
+ __isp_isr_other_en(params_vdev, params, RKISP_PARAMS_ALL, 1);
5424
+ __isp_isr_meas_en(params_vdev, params, RKISP_PARAMS_ALL, 1);
54145425 params->module_cfg_update = 0;
54155426 }
54165427 }