| .. | .. |
|---|
| 460 | 460 | { |
|---|
| 461 | 461 | int i, j; |
|---|
| 462 | 462 | unsigned int sram_addr; |
|---|
| 463 | | - unsigned int data; |
|---|
| 463 | + unsigned int data = rkisp_ioread32(params_vdev, ISP_LSC_CTRL); |
|---|
| 464 | 464 | |
|---|
| 465 | | - if (is_check && |
|---|
| 466 | | - !(rkisp_ioread32(params_vdev, ISP_LSC_CTRL) & ISP_LSC_EN)) |
|---|
| 465 | + if (is_check && (data & ISP_LSC_LUT_EN || !(data & ISP_LSC_EN))) |
|---|
| 467 | 466 | return; |
|---|
| 468 | 467 | |
|---|
| 469 | 468 | /* CIF_ISP_LSC_TABLE_ADDRESS_153 = ( 17 * 18 ) >> 1 */ |
|---|
| .. | .. |
|---|
| 603 | 602 | * readback mode lsc lut AHB config to sram, once for single device, |
|---|
| 604 | 603 | * need record to switch for multi-device. |
|---|
| 605 | 604 | */ |
|---|
| 606 | | - if (!IS_HDR_RDBK(dev->rd_mode)) |
|---|
| 605 | + if (!IS_HDR_RDBK(dev->rd_mode)) { |
|---|
| 607 | 606 | isp_lsc_matrix_cfg_ddr(params_vdev, arg); |
|---|
| 608 | | - else if (dev->hw_dev->is_single) |
|---|
| 609 | | - isp_lsc_matrix_cfg_sram(params_vdev, arg, false); |
|---|
| 610 | | - else |
|---|
| 607 | + } else { |
|---|
| 608 | + if (dev->hw_dev->is_single) |
|---|
| 609 | + isp_lsc_matrix_cfg_sram(params_vdev, arg, false); |
|---|
| 611 | 610 | params_rec->others.lsc_cfg = *arg; |
|---|
| 611 | + } |
|---|
| 612 | 612 | |
|---|
| 613 | 613 | for (i = 0; i < 4; i++) { |
|---|
| 614 | 614 | /* program x size tables */ |
|---|
| .. | .. |
|---|
| 1178 | 1178 | ISP2X_REG_WR_MASK); |
|---|
| 1179 | 1179 | |
|---|
| 1180 | 1180 | wnd_num_idx = arg->wnd_num; |
|---|
| 1181 | + if (wnd_num_idx >= ARRAY_SIZE(ae_wnd_num)) { |
|---|
| 1182 | + wnd_num_idx = ARRAY_SIZE(ae_wnd_num) - 1; |
|---|
| 1183 | + dev_err(params_vdev->dev->dev, |
|---|
| 1184 | + "%s invalid wnd_num:%d, set to %d\n", |
|---|
| 1185 | + __func__, arg->wnd_num, wnd_num_idx); |
|---|
| 1186 | + } |
|---|
| 1181 | 1187 | value |= ISP2X_RAWAEBIG_WNDNUM_SET(wnd_num_idx); |
|---|
| 1182 | 1188 | |
|---|
| 1183 | 1189 | if (arg->subwin_en[0]) |
|---|
| .. | .. |
|---|
| 1327 | 1333 | (arg->sw_rawawb_wp_blk_wei_w[5 * i + 1] & 0x3f) << 6 | |
|---|
| 1328 | 1334 | (arg->sw_rawawb_wp_blk_wei_w[5 * i + 2] & 0x3f) << 12 | |
|---|
| 1329 | 1335 | (arg->sw_rawawb_wp_blk_wei_w[5 * i + 3] & 0x3f) << 18 | |
|---|
| 1330 | | - (arg->sw_rawawb_wp_blk_wei_w[5 * i + 4] & 0x3f) << 24, |
|---|
| 1331 | | - rkisp_iowrite32(params_vdev, val, ISP21_RAWAWB_WRAM_DATA_BASE); |
|---|
| 1336 | + (arg->sw_rawawb_wp_blk_wei_w[5 * i + 4] & 0x3f) << 24; |
|---|
| 1337 | + rkisp_write(params_vdev->dev, ISP21_RAWAWB_WRAM_DATA_BASE, val, true); |
|---|
| 1332 | 1338 | } |
|---|
| 1333 | 1339 | } |
|---|
| 1334 | 1340 | |
|---|
| .. | .. |
|---|
| 2143 | 2149 | |
|---|
| 2144 | 2150 | if (params_vdev->dev->hw_dev->is_single) |
|---|
| 2145 | 2151 | isp_rawawb_cfg_sram(params_vdev, arg, false); |
|---|
| 2146 | | - else |
|---|
| 2147 | | - memcpy(arg_rec->sw_rawawb_wp_blk_wei_w, |
|---|
| 2148 | | - arg->sw_rawawb_wp_blk_wei_w, |
|---|
| 2149 | | - ISP21_RAWAWB_WEIGHT_NUM); |
|---|
| 2152 | + memcpy(arg_rec->sw_rawawb_wp_blk_wei_w, |
|---|
| 2153 | + arg->sw_rawawb_wp_blk_wei_w, |
|---|
| 2154 | + ISP21_RAWAWB_WEIGHT_NUM); |
|---|
| 2150 | 2155 | |
|---|
| 2151 | 2156 | /* avoid to override the old enable value */ |
|---|
| 2152 | 2157 | value = rkisp_ioread32(params_vdev, ISP21_RAWAWB_CTRL); |
|---|
| .. | .. |
|---|
| 2292 | 2297 | return; |
|---|
| 2293 | 2298 | |
|---|
| 2294 | 2299 | wnd_num_idx = arg->wnd_num; |
|---|
| 2300 | + if (wnd_num_idx >= ARRAY_SIZE(hist_wnd_num)) { |
|---|
| 2301 | + wnd_num_idx = ARRAY_SIZE(hist_wnd_num) - 1; |
|---|
| 2302 | + dev_err(params_vdev->dev->dev, |
|---|
| 2303 | + "%s invalid wnd_num:%d, set to %d\n", |
|---|
| 2304 | + __func__, arg->wnd_num, wnd_num_idx); |
|---|
| 2305 | + } |
|---|
| 2295 | 2306 | memset(weight15x15, 0, sizeof(weight15x15)); |
|---|
| 2296 | 2307 | for (i = 0; i < hist_wnd_num[wnd_num_idx]; i++) { |
|---|
| 2297 | 2308 | for (j = 0; j < hist_wnd_num[wnd_num_idx]; j++) { |
|---|
| .. | .. |
|---|
| 2339 | 2350 | } |
|---|
| 2340 | 2351 | |
|---|
| 2341 | 2352 | wnd_num_idx = arg->wnd_num; |
|---|
| 2353 | + if (wnd_num_idx >= ARRAY_SIZE(hist_wnd_num)) { |
|---|
| 2354 | + wnd_num_idx = ARRAY_SIZE(hist_wnd_num) - 1; |
|---|
| 2355 | + dev_err(params_vdev->dev->dev, |
|---|
| 2356 | + "%s invalid wnd_num:%d, set to %d\n", |
|---|
| 2357 | + __func__, arg->wnd_num, wnd_num_idx); |
|---|
| 2358 | + } |
|---|
| 2342 | 2359 | /* avoid to override the old enable value */ |
|---|
| 2343 | 2360 | hist_ctrl = rkisp_ioread32(params_vdev, addr + ISP_RAWHIST_BIG_CTRL); |
|---|
| 2344 | 2361 | hist_ctrl &= ISP2X_RAWHSTBIG_CTRL_EN_MASK; |
|---|
| .. | .. |
|---|
| 2370 | 2387 | |
|---|
| 2371 | 2388 | if (dev->hw_dev->is_single) |
|---|
| 2372 | 2389 | isp_rawhstbig_cfg_sram(params_vdev, arg, blk_no, false); |
|---|
| 2373 | | - else |
|---|
| 2374 | | - *arg_rec = *arg; |
|---|
| 2390 | + *arg_rec = *arg; |
|---|
| 2375 | 2391 | } |
|---|
| 2376 | 2392 | |
|---|
| 2377 | 2393 | static void |
|---|
| .. | .. |
|---|
| 4339 | 4355 | ret = rkisp_alloc_buffer(params_vdev->dev, &priv_val->buf_3dlut[i]); |
|---|
| 4340 | 4356 | if (ret) { |
|---|
| 4341 | 4357 | dev_err(dev, "can not alloc buffer\n"); |
|---|
| 4342 | | - goto err; |
|---|
| 4358 | + goto err_3dlut; |
|---|
| 4343 | 4359 | } |
|---|
| 4344 | 4360 | } |
|---|
| 4345 | 4361 | |
|---|
| .. | .. |
|---|
| 4350 | 4366 | ret = rkisp_alloc_buffer(params_vdev->dev, &priv_val->buf_lsclut[i]); |
|---|
| 4351 | 4367 | if (ret) { |
|---|
| 4352 | 4368 | dev_err(dev, "can not alloc buffer\n"); |
|---|
| 4353 | | - goto err; |
|---|
| 4369 | + goto err_lsclut; |
|---|
| 4354 | 4370 | } |
|---|
| 4355 | 4371 | } |
|---|
| 4356 | 4372 | |
|---|
| .. | .. |
|---|
| 4359 | 4375 | params_vdev->priv_ops = &rkisp_v21_isp_params_ops; |
|---|
| 4360 | 4376 | rkisp_clear_first_param_v2x(params_vdev); |
|---|
| 4361 | 4377 | return 0; |
|---|
| 4362 | | - |
|---|
| 4363 | | -err: |
|---|
| 4364 | | - for (i = 0; i < RKISP_PARAM_3DLUT_BUF_NUM; i++) |
|---|
| 4378 | +err_lsclut: |
|---|
| 4379 | + for (i -= 1; i >= 0; i--) |
|---|
| 4380 | + rkisp_free_buffer(params_vdev->dev, &priv_val->buf_lsclut[i]); |
|---|
| 4381 | + i = RKISP_PARAM_3DLUT_BUF_NUM; |
|---|
| 4382 | +err_3dlut: |
|---|
| 4383 | + for (i -= 1; i >= 0; i--) |
|---|
| 4365 | 4384 | rkisp_free_buffer(params_vdev->dev, &priv_val->buf_3dlut[i]); |
|---|
| 4366 | 4385 | |
|---|
| 4367 | | - for (i = 0; i < RKISP_PARAM_LSC_LUT_BUF_NUM; i++) |
|---|
| 4368 | | - rkisp_free_buffer(params_vdev->dev, &priv_val->buf_lsclut[i]); |
|---|
| 4369 | 4386 | vfree(params_vdev->isp21_params); |
|---|
| 4370 | | - |
|---|
| 4387 | + kfree(priv_val); |
|---|
| 4371 | 4388 | return ret; |
|---|
| 4372 | 4389 | } |
|---|
| 4373 | 4390 | |
|---|