| .. | .. |
|---|
| 45 | 45 | #include <linux/pm_runtime.h> |
|---|
| 46 | 46 | #include <linux/pinctrl/consumer.h> |
|---|
| 47 | 47 | #include <linux/regmap.h> |
|---|
| 48 | | -#include <dt-bindings/soc/rockchip-system-status.h> |
|---|
| 49 | 48 | #include <soc/rockchip/rockchip-system-status.h> |
|---|
| 50 | 49 | #include "common.h" |
|---|
| 51 | 50 | #include "isp_ispp.h" |
|---|
| 52 | 51 | #include "regs.h" |
|---|
| 53 | 52 | #include "rkisp.h" |
|---|
| 54 | 53 | #include "version.h" |
|---|
| 54 | +#include "csi.h" |
|---|
| 55 | 55 | |
|---|
| 56 | 56 | #define RKISP_VERNO_LEN 10 |
|---|
| 57 | 57 | |
|---|
| .. | .. |
|---|
| 62 | 62 | bool rkisp_monitor; |
|---|
| 63 | 63 | module_param_named(monitor, rkisp_monitor, bool, 0644); |
|---|
| 64 | 64 | MODULE_PARM_DESC(monitor, "rkisp abnormal restart monitor"); |
|---|
| 65 | + |
|---|
| 66 | +bool rkisp_irq_dbg; |
|---|
| 67 | +module_param_named(irq_dbg, rkisp_irq_dbg, bool, 0644); |
|---|
| 68 | +MODULE_PARM_DESC(irq_dbg, "rkisp interrupt runtime"); |
|---|
| 69 | + |
|---|
| 70 | +static bool rkisp_rdbk_auto; |
|---|
| 71 | +module_param_named(rdbk_auto, rkisp_rdbk_auto, bool, 0644); |
|---|
| 72 | +MODULE_PARM_DESC(irq_dbg, "rkisp and vicap auto readback mode"); |
|---|
| 65 | 73 | |
|---|
| 66 | 74 | static bool rkisp_clk_dbg; |
|---|
| 67 | 75 | module_param_named(clk_dbg, rkisp_clk_dbg, bool, 0644); |
|---|
| .. | .. |
|---|
| 78 | 86 | static unsigned int rkisp_wait_line; |
|---|
| 79 | 87 | module_param_named(wait_line, rkisp_wait_line, uint, 0644); |
|---|
| 80 | 88 | MODULE_PARM_DESC(wait_line, "rkisp wait line to buf done early"); |
|---|
| 89 | + |
|---|
| 90 | +static unsigned int rkisp_wrap_line; |
|---|
| 91 | +module_param_named(wrap_line, rkisp_wrap_line, uint, 0644); |
|---|
| 92 | +MODULE_PARM_DESC(wrap_line, "rkisp wrap line for mpp"); |
|---|
| 81 | 93 | |
|---|
| 82 | 94 | static DEFINE_MUTEX(rkisp_dev_mutex); |
|---|
| 83 | 95 | static LIST_HEAD(rkisp_device_list); |
|---|
| .. | .. |
|---|
| 126 | 138 | p->num_subdevs = 0; |
|---|
| 127 | 139 | memset(p->subdevs, 0, sizeof(p->subdevs)); |
|---|
| 128 | 140 | |
|---|
| 129 | | - if (!(dev->isp_inp & (INP_CSI | INP_DVP | INP_LVDS))) |
|---|
| 141 | + if (!(dev->isp_inp & (INP_CSI | INP_DVP | INP_LVDS | INP_CIF))) |
|---|
| 130 | 142 | return 0; |
|---|
| 131 | 143 | |
|---|
| 132 | 144 | while (1) { |
|---|
| .. | .. |
|---|
| 164 | 176 | { |
|---|
| 165 | 177 | struct rkisp_device *dev = container_of(p, struct rkisp_device, pipe); |
|---|
| 166 | 178 | struct rkisp_hw_dev *hw_dev = dev->hw_dev; |
|---|
| 167 | | - u32 w = hw_dev->max_in.w ? hw_dev->max_in.w : dev->isp_sdev.in_frm.width; |
|---|
| 168 | 179 | struct v4l2_subdev *sd; |
|---|
| 169 | 180 | struct v4l2_ctrl *ctrl; |
|---|
| 170 | | - u64 data_rate; |
|---|
| 171 | | - int i; |
|---|
| 181 | + u64 data_rate = 0; |
|---|
| 182 | + int i, fps; |
|---|
| 172 | 183 | |
|---|
| 173 | | - if (dev->isp_inp & (INP_RAWRD0 | INP_RAWRD1 | INP_RAWRD2 | INP_CIF)) { |
|---|
| 174 | | - for (i = 0; i < hw_dev->num_clk_rate_tbl; i++) { |
|---|
| 175 | | - if (w <= hw_dev->clk_rate_tbl[i].refer_data) |
|---|
| 176 | | - break; |
|---|
| 184 | + hw_dev->isp_size[dev->dev_id].is_on = true; |
|---|
| 185 | + if (hw_dev->is_runing) { |
|---|
| 186 | + if (dev->isp_ver >= ISP_V30 && !rkisp_clk_dbg) |
|---|
| 187 | + hw_dev->is_dvfs = true; |
|---|
| 188 | + return 0; |
|---|
| 189 | + } |
|---|
| 190 | + |
|---|
| 191 | + if (dev->isp_inp & (INP_RAWRD0 | INP_RAWRD1 | INP_RAWRD2) || |
|---|
| 192 | + (dev->is_pre_on && hw_dev->dev_num > 1)) { |
|---|
| 193 | + if (dev->isp_ver < ISP_V30 || dev->is_pre_on) { |
|---|
| 194 | + /* isp with mipi no support dvfs, calculate max data rate */ |
|---|
| 195 | + for (i = 0; i < hw_dev->dev_num; i++) { |
|---|
| 196 | + fps = hw_dev->isp_size[i].fps; |
|---|
| 197 | + if (!fps) |
|---|
| 198 | + fps = 30; |
|---|
| 199 | + data_rate += (fps * hw_dev->isp_size[i].size); |
|---|
| 200 | + } |
|---|
| 201 | + } else { |
|---|
| 202 | + i = dev->dev_id; |
|---|
| 203 | + fps = hw_dev->isp_size[i].fps; |
|---|
| 204 | + if (!fps) |
|---|
| 205 | + fps = 30; |
|---|
| 206 | + data_rate = fps * hw_dev->isp_size[i].size; |
|---|
| 177 | 207 | } |
|---|
| 178 | | - if (!hw_dev->is_single) |
|---|
| 179 | | - i++; |
|---|
| 180 | | - if (i > hw_dev->num_clk_rate_tbl - 1) |
|---|
| 181 | | - i = hw_dev->num_clk_rate_tbl - 1; |
|---|
| 182 | 208 | goto end; |
|---|
| 183 | 209 | } |
|---|
| 184 | 210 | |
|---|
| .. | .. |
|---|
| 187 | 213 | return 0; |
|---|
| 188 | 214 | } |
|---|
| 189 | 215 | |
|---|
| 190 | | - /* find the subdev of active sensor */ |
|---|
| 216 | + /* find the subdev of active sensor or vicap itf */ |
|---|
| 191 | 217 | sd = p->subdevs[0]; |
|---|
| 192 | 218 | for (i = 0; i < p->num_subdevs; i++) { |
|---|
| 193 | 219 | sd = p->subdevs[i]; |
|---|
| 194 | | - if (sd->entity.function == MEDIA_ENT_F_CAM_SENSOR) |
|---|
| 220 | + if (sd->entity.function == MEDIA_ENT_F_CAM_SENSOR || |
|---|
| 221 | + sd->entity.function == MEDIA_ENT_F_PROC_VIDEO_COMPOSER) |
|---|
| 195 | 222 | break; |
|---|
| 196 | 223 | } |
|---|
| 197 | 224 | |
|---|
| 198 | 225 | if (i == p->num_subdevs) { |
|---|
| 199 | 226 | v4l2_warn(&dev->v4l2_dev, "No active sensor\n"); |
|---|
| 227 | + hw_dev->isp_size[dev->dev_id].is_on = false; |
|---|
| 200 | 228 | return -EPIPE; |
|---|
| 201 | 229 | } |
|---|
| 202 | 230 | |
|---|
| 203 | 231 | ctrl = v4l2_ctrl_find(sd->ctrl_handler, V4L2_CID_PIXEL_RATE); |
|---|
| 204 | 232 | if (!ctrl) { |
|---|
| 205 | 233 | v4l2_warn(&dev->v4l2_dev, "No pixel rate control in subdev\n"); |
|---|
| 234 | + hw_dev->isp_size[dev->dev_id].is_on = false; |
|---|
| 206 | 235 | return -EPIPE; |
|---|
| 207 | 236 | } |
|---|
| 208 | 237 | |
|---|
| .. | .. |
|---|
| 210 | 239 | data_rate = v4l2_ctrl_g_ctrl_int64(ctrl) * |
|---|
| 211 | 240 | dev->isp_sdev.in_fmt.bus_width; |
|---|
| 212 | 241 | data_rate >>= 3; |
|---|
| 242 | +end: |
|---|
| 213 | 243 | do_div(data_rate, 1000 * 1000); |
|---|
| 244 | + if (hw_dev->unite == ISP_UNITE_ONE) |
|---|
| 245 | + data_rate *= 4; |
|---|
| 214 | 246 | |
|---|
| 215 | 247 | /* increase 25% margin */ |
|---|
| 216 | 248 | data_rate += data_rate >> 2; |
|---|
| .. | .. |
|---|
| 221 | 253 | break; |
|---|
| 222 | 254 | if (i == hw_dev->num_clk_rate_tbl) |
|---|
| 223 | 255 | i--; |
|---|
| 224 | | -end: |
|---|
| 256 | + |
|---|
| 225 | 257 | /* set isp clock rate */ |
|---|
| 226 | 258 | rkisp_set_clk_rate(hw_dev->clks[0], hw_dev->clk_rate_tbl[i].clk_rate * 1000000UL); |
|---|
| 227 | | - dev_dbg(hw_dev->dev, "set isp clk = %luHz\n", clk_get_rate(hw_dev->clks[0])); |
|---|
| 259 | + if (hw_dev->unite == ISP_UNITE_TWO) |
|---|
| 260 | + rkisp_set_clk_rate(hw_dev->clks[5], hw_dev->clk_rate_tbl[i].clk_rate * 1000000UL); |
|---|
| 261 | + /* aclk equal to core clk */ |
|---|
| 262 | + if (dev->isp_ver == ISP_V32) |
|---|
| 263 | + rkisp_set_clk_rate(hw_dev->clks[1], hw_dev->clk_rate_tbl[i].clk_rate * 1000000UL); |
|---|
| 264 | + dev_info(hw_dev->dev, "set isp clk = %luHz\n", clk_get_rate(hw_dev->clks[0])); |
|---|
| 228 | 265 | |
|---|
| 229 | 266 | return 0; |
|---|
| 230 | 267 | } |
|---|
| .. | .. |
|---|
| 245 | 282 | if (prepare) { |
|---|
| 246 | 283 | ret = __isp_pipeline_prepare(p, me); |
|---|
| 247 | 284 | if (ret < 0) |
|---|
| 248 | | - return ret; |
|---|
| 285 | + goto err; |
|---|
| 249 | 286 | } |
|---|
| 250 | 287 | |
|---|
| 251 | 288 | ret = __isp_pipeline_s_isp_clk(p); |
|---|
| 252 | 289 | if (ret < 0) |
|---|
| 253 | | - return ret; |
|---|
| 290 | + goto err; |
|---|
| 291 | + |
|---|
| 292 | + if (!dev->hw_dev->monitor.is_en) |
|---|
| 293 | + dev->hw_dev->monitor.is_en = rkisp_monitor; |
|---|
| 254 | 294 | |
|---|
| 255 | 295 | if (dev->isp_inp & (INP_CSI | INP_RAWRD0 | INP_RAWRD1 | INP_RAWRD2 | INP_CIF)) |
|---|
| 256 | 296 | rkisp_csi_config_patch(dev); |
|---|
| 257 | 297 | return 0; |
|---|
| 298 | +err: |
|---|
| 299 | + atomic_dec(&p->power_cnt); |
|---|
| 300 | + return ret; |
|---|
| 258 | 301 | } |
|---|
| 259 | 302 | |
|---|
| 260 | 303 | static int rkisp_pipeline_close(struct rkisp_pipeline *p) |
|---|
| 261 | 304 | { |
|---|
| 262 | | - atomic_dec(&p->power_cnt); |
|---|
| 305 | + struct rkisp_device *dev = container_of(p, struct rkisp_device, pipe); |
|---|
| 263 | 306 | |
|---|
| 307 | + if (atomic_dec_return(&p->power_cnt)) |
|---|
| 308 | + return 0; |
|---|
| 309 | + |
|---|
| 310 | + rkisp_rx_buf_pool_free(dev); |
|---|
| 311 | + dev->hw_dev->isp_size[dev->dev_id].is_on = false; |
|---|
| 312 | + if (dev->hw_dev->is_runing && (dev->isp_ver >= ISP_V30) && !rkisp_clk_dbg) |
|---|
| 313 | + dev->hw_dev->is_dvfs = true; |
|---|
| 264 | 314 | return 0; |
|---|
| 265 | 315 | } |
|---|
| 266 | 316 | |
|---|
| .. | .. |
|---|
| 271 | 321 | static int rkisp_pipeline_set_stream(struct rkisp_pipeline *p, bool on) |
|---|
| 272 | 322 | { |
|---|
| 273 | 323 | struct rkisp_device *dev = container_of(p, struct rkisp_device, pipe); |
|---|
| 274 | | - int i, ret; |
|---|
| 324 | + int i, ret, open_num = 0; |
|---|
| 275 | 325 | |
|---|
| 276 | 326 | if ((on && atomic_inc_return(&p->stream_cnt) > 1) || |
|---|
| 277 | 327 | (!on && atomic_dec_return(&p->stream_cnt) > 0)) |
|---|
| .. | .. |
|---|
| 281 | 331 | if (dev->vs_irq >= 0) |
|---|
| 282 | 332 | enable_irq(dev->vs_irq); |
|---|
| 283 | 333 | rockchip_set_system_status(SYS_STATUS_ISP); |
|---|
| 284 | | - v4l2_subdev_call(&dev->isp_sdev.sd, video, s_stream, true); |
|---|
| 334 | + ret = v4l2_subdev_call(&dev->isp_sdev.sd, video, s_stream, true); |
|---|
| 335 | + if (ret < 0) |
|---|
| 336 | + goto err; |
|---|
| 285 | 337 | /* phy -> sensor */ |
|---|
| 286 | 338 | for (i = 0; i < p->num_subdevs; ++i) { |
|---|
| 339 | + if ((dev->vicap_in.merge_num > 1) && |
|---|
| 340 | + (p->subdevs[i]->entity.function == MEDIA_ENT_F_CAM_SENSOR)) |
|---|
| 341 | + continue; |
|---|
| 287 | 342 | ret = v4l2_subdev_call(p->subdevs[i], video, s_stream, on); |
|---|
| 288 | 343 | if (on && ret < 0 && ret != -ENOIOCTLCMD && ret != -ENODEV) |
|---|
| 289 | 344 | goto err_stream_off; |
|---|
| 290 | 345 | } |
|---|
| 291 | 346 | } else { |
|---|
| 347 | + for (i = 0; i < dev->hw_dev->dev_num; i++) { |
|---|
| 348 | + if (dev->hw_dev->isp_size[i].is_on) |
|---|
| 349 | + open_num++; |
|---|
| 350 | + } |
|---|
| 351 | + if (dev->hw_dev->monitor.is_en && open_num == 1) { |
|---|
| 352 | + dev->hw_dev->monitor.is_en = 0; |
|---|
| 353 | + dev->hw_dev->monitor.state = ISP_STOP; |
|---|
| 354 | + if (!completion_done(&dev->hw_dev->monitor.cmpl)) |
|---|
| 355 | + complete(&dev->hw_dev->monitor.cmpl); |
|---|
| 356 | + } |
|---|
| 292 | 357 | /* sensor -> phy */ |
|---|
| 293 | | - for (i = p->num_subdevs - 1; i >= 0; --i) |
|---|
| 358 | + for (i = p->num_subdevs - 1; i >= 0; --i) { |
|---|
| 359 | + if ((dev->vicap_in.merge_num > 1) && |
|---|
| 360 | + (p->subdevs[i]->entity.function == MEDIA_ENT_F_CAM_SENSOR)) |
|---|
| 361 | + continue; |
|---|
| 294 | 362 | v4l2_subdev_call(p->subdevs[i], video, s_stream, on); |
|---|
| 363 | + } |
|---|
| 295 | 364 | if (dev->vs_irq >= 0) |
|---|
| 296 | 365 | disable_irq(dev->vs_irq); |
|---|
| 297 | 366 | v4l2_subdev_call(&dev->isp_sdev.sd, video, s_stream, false); |
|---|
| .. | .. |
|---|
| 304 | 373 | for (--i; i >= 0; --i) |
|---|
| 305 | 374 | v4l2_subdev_call(p->subdevs[i], video, s_stream, false); |
|---|
| 306 | 375 | v4l2_subdev_call(&dev->isp_sdev.sd, video, s_stream, false); |
|---|
| 376 | +err: |
|---|
| 307 | 377 | rockchip_clear_system_status(SYS_STATUS_ISP); |
|---|
| 378 | + atomic_dec_return(&p->stream_cnt); |
|---|
| 308 | 379 | return ret; |
|---|
| 309 | 380 | } |
|---|
| 310 | 381 | |
|---|
| .. | .. |
|---|
| 320 | 391 | for (s = 0; s < dev->num_sensors; ++s) { |
|---|
| 321 | 392 | struct rkisp_sensor_info *sensor = &dev->sensors[s]; |
|---|
| 322 | 393 | u32 type = sensor->sd->entity.function; |
|---|
| 323 | | - bool en = s ? 0 : MEDIA_LNK_FL_ENABLED; |
|---|
| 394 | + bool en = s ? 0 : true; |
|---|
| 324 | 395 | |
|---|
| 325 | 396 | for (pad = 0; pad < sensor->sd->entity.num_pads; pad++) |
|---|
| 326 | 397 | if (sensor->sd->entity.pads[pad].flags & MEDIA_PAD_FL_SOURCE) |
|---|
| .. | .. |
|---|
| 342 | 413 | ret = media_create_pad_link(&sensor->sd->entity, pad, |
|---|
| 343 | 414 | &dev->isp_sdev.sd.entity, RKISP_ISP_PAD_SINK, en); |
|---|
| 344 | 415 | } else { |
|---|
| 345 | | - v4l2_subdev_call(sensor->sd, video, |
|---|
| 346 | | - g_mbus_config, &sensor->mbus); |
|---|
| 416 | + v4l2_subdev_call(sensor->sd, pad, |
|---|
| 417 | + get_mbus_config, 0, &sensor->mbus); |
|---|
| 347 | 418 | if (sensor->mbus.type == V4L2_MBUS_CCP2) { |
|---|
| 348 | 419 | /* mipi-phy lvds link -> isp */ |
|---|
| 349 | 420 | dev->isp_inp = INP_LVDS; |
|---|
| .. | .. |
|---|
| 366 | 437 | return ret; |
|---|
| 367 | 438 | } |
|---|
| 368 | 439 | |
|---|
| 369 | | -static int _set_pipeline_default_fmt(struct rkisp_device *dev) |
|---|
| 440 | +static int _set_pipeline_default_fmt(struct rkisp_device *dev, bool is_init) |
|---|
| 370 | 441 | { |
|---|
| 371 | 442 | struct v4l2_subdev *isp; |
|---|
| 372 | 443 | struct v4l2_subdev_format fmt; |
|---|
| 373 | 444 | struct v4l2_subdev_selection sel; |
|---|
| 374 | | - u32 width, height, code; |
|---|
| 445 | + u32 i, width, height, code; |
|---|
| 375 | 446 | |
|---|
| 447 | + memset(&sel, 0, sizeof(sel)); |
|---|
| 448 | + memset(&fmt, 0, sizeof(fmt)); |
|---|
| 376 | 449 | isp = &dev->isp_sdev.sd; |
|---|
| 377 | 450 | |
|---|
| 378 | | - fmt = dev->active_sensor->fmt[0]; |
|---|
| 451 | + if (dev->active_sensor) { |
|---|
| 452 | + fmt = dev->active_sensor->fmt[0]; |
|---|
| 453 | + if (!is_init && |
|---|
| 454 | + fmt.format.code == dev->isp_sdev.in_frm.code && |
|---|
| 455 | + fmt.format.width == dev->isp_sdev.in_frm.width && |
|---|
| 456 | + fmt.format.height == dev->isp_sdev.in_frm.height) |
|---|
| 457 | + return 0; |
|---|
| 458 | + } else { |
|---|
| 459 | + fmt.format = dev->isp_sdev.in_frm; |
|---|
| 460 | + } |
|---|
| 379 | 461 | code = fmt.format.code; |
|---|
| 380 | 462 | fmt.which = V4L2_SUBDEV_FORMAT_ACTIVE; |
|---|
| 381 | 463 | fmt.pad = RKISP_ISP_PAD_SINK; |
|---|
| .. | .. |
|---|
| 411 | 493 | rkisp_set_stream_def_fmt(dev, RKISP_STREAM_SP, |
|---|
| 412 | 494 | width, height, V4L2_PIX_FMT_NV12); |
|---|
| 413 | 495 | if ((dev->isp_ver == ISP_V20 || dev->isp_ver == ISP_V21) && |
|---|
| 414 | | - dev->isp_inp == INP_CSI) { |
|---|
| 496 | + dev->isp_inp == INP_CSI && dev->active_sensor) { |
|---|
| 415 | 497 | width = dev->active_sensor->fmt[1].format.width; |
|---|
| 416 | 498 | height = dev->active_sensor->fmt[1].format.height; |
|---|
| 417 | 499 | code = dev->active_sensor->fmt[1].format.code; |
|---|
| .. | .. |
|---|
| 431 | 513 | width, height, rkisp_mbus_pixelcode_to_v4l2(code)); |
|---|
| 432 | 514 | } |
|---|
| 433 | 515 | |
|---|
| 434 | | - if (dev->isp_ver == ISP_V20 && dev->isp_inp == INP_CSI) { |
|---|
| 516 | + if (dev->isp_ver == ISP_V20 && |
|---|
| 517 | + dev->isp_inp == INP_CSI && dev->active_sensor) { |
|---|
| 435 | 518 | width = dev->active_sensor->fmt[2].format.width; |
|---|
| 436 | 519 | height = dev->active_sensor->fmt[2].format.height; |
|---|
| 437 | 520 | code = dev->active_sensor->fmt[2].format.code; |
|---|
| 438 | 521 | rkisp_set_stream_def_fmt(dev, RKISP_STREAM_DMATX1, |
|---|
| 439 | 522 | width, height, rkisp_mbus_pixelcode_to_v4l2(code)); |
|---|
| 523 | + } |
|---|
| 524 | + |
|---|
| 525 | + if (dev->isp_ver == ISP_V30) { |
|---|
| 526 | + struct v4l2_pix_format_mplane pixm = { |
|---|
| 527 | + .width = width, |
|---|
| 528 | + .height = height, |
|---|
| 529 | + .pixelformat = rkisp_mbus_pixelcode_to_v4l2(code), |
|---|
| 530 | + }; |
|---|
| 531 | + |
|---|
| 532 | + for (i = RKISP_STREAM_RAWRD0; i <= RKISP_STREAM_RAWRD2; i++) |
|---|
| 533 | + rkisp_dmarx_set_fmt(&dev->dmarx_dev.stream[i], pixm); |
|---|
| 534 | + rkisp_set_stream_def_fmt(dev, RKISP_STREAM_FBC, |
|---|
| 535 | + width, height, V4L2_PIX_FMT_FBC0); |
|---|
| 536 | +#ifdef RKISP_STREAM_BP_EN |
|---|
| 537 | + rkisp_set_stream_def_fmt(dev, RKISP_STREAM_BP, |
|---|
| 538 | + width, height, V4L2_PIX_FMT_NV12); |
|---|
| 539 | +#endif |
|---|
| 540 | + } |
|---|
| 541 | + |
|---|
| 542 | + if (dev->isp_ver == ISP_V32 || dev->isp_ver == ISP_V32_L) { |
|---|
| 543 | + struct v4l2_pix_format_mplane pixm = { |
|---|
| 544 | + .width = width, |
|---|
| 545 | + .height = height, |
|---|
| 546 | + .pixelformat = rkisp_mbus_pixelcode_to_v4l2(code), |
|---|
| 547 | + }; |
|---|
| 548 | + |
|---|
| 549 | + rkisp_dmarx_set_fmt(&dev->dmarx_dev.stream[RKISP_STREAM_RAWRD0], pixm); |
|---|
| 550 | + rkisp_dmarx_set_fmt(&dev->dmarx_dev.stream[RKISP_STREAM_RAWRD2], pixm); |
|---|
| 551 | + if (dev->isp_ver == ISP_V32) { |
|---|
| 552 | + rkisp_set_stream_def_fmt(dev, RKISP_STREAM_BP, |
|---|
| 553 | + width, height, V4L2_PIX_FMT_NV12); |
|---|
| 554 | + rkisp_set_stream_def_fmt(dev, RKISP_STREAM_MPDS, |
|---|
| 555 | + width / 4, height / 4, V4L2_PIX_FMT_NV12); |
|---|
| 556 | + rkisp_set_stream_def_fmt(dev, RKISP_STREAM_BPDS, |
|---|
| 557 | + width / 4, height / 4, V4L2_PIX_FMT_NV12); |
|---|
| 558 | + } |
|---|
| 440 | 559 | } |
|---|
| 441 | 560 | return 0; |
|---|
| 442 | 561 | } |
|---|
| .. | .. |
|---|
| 456 | 575 | if (ret < 0) |
|---|
| 457 | 576 | goto unlock; |
|---|
| 458 | 577 | |
|---|
| 459 | | - ret = rkisp_update_sensor_info(dev); |
|---|
| 460 | | - if (ret < 0) { |
|---|
| 461 | | - v4l2_err(&dev->v4l2_dev, "update sensor failed\n"); |
|---|
| 462 | | - goto unlock; |
|---|
| 578 | + if (dev->isp_inp) { |
|---|
| 579 | + ret = rkisp_update_sensor_info(dev); |
|---|
| 580 | + if (ret < 0) { |
|---|
| 581 | + v4l2_err(&dev->v4l2_dev, "update sensor failed\n"); |
|---|
| 582 | + goto unlock; |
|---|
| 583 | + } |
|---|
| 584 | + dev->is_hw_link = true; |
|---|
| 463 | 585 | } |
|---|
| 464 | 586 | |
|---|
| 465 | | - ret = _set_pipeline_default_fmt(dev); |
|---|
| 587 | + ret = _set_pipeline_default_fmt(dev, true); |
|---|
| 466 | 588 | if (ret < 0) |
|---|
| 467 | 589 | goto unlock; |
|---|
| 468 | 590 | |
|---|
| .. | .. |
|---|
| 470 | 592 | |
|---|
| 471 | 593 | unlock: |
|---|
| 472 | 594 | mutex_unlock(&dev->media_dev.graph_mutex); |
|---|
| 595 | + if (!ret && dev->is_thunderboot) |
|---|
| 596 | + schedule_work(&dev->cap_dev.fast_work); |
|---|
| 473 | 597 | return ret; |
|---|
| 474 | 598 | } |
|---|
| 475 | 599 | |
|---|
| .. | .. |
|---|
| 521 | 645 | return 0; |
|---|
| 522 | 646 | } |
|---|
| 523 | 647 | |
|---|
| 648 | +static void subdev_notifier_unbind(struct v4l2_async_notifier *notifier, |
|---|
| 649 | + struct v4l2_subdev *subdev, |
|---|
| 650 | + struct v4l2_async_subdev *asd) |
|---|
| 651 | +{ |
|---|
| 652 | + struct rkisp_device *isp_dev = container_of(notifier, struct rkisp_device, notifier); |
|---|
| 653 | + struct rkisp_isp_subdev *isp_sdev = &isp_dev->isp_sdev; |
|---|
| 654 | + struct v4l2_subdev *isp_sd = &isp_sdev->sd; |
|---|
| 655 | + int i; |
|---|
| 656 | + |
|---|
| 657 | + for (i = 0; i < isp_dev->num_sensors; i++) { |
|---|
| 658 | + if (isp_dev->sensors[i].sd == subdev) { |
|---|
| 659 | + media_entity_call(&isp_sd->entity, link_setup, |
|---|
| 660 | + isp_sd->entity.pads, subdev->entity.pads, 0); |
|---|
| 661 | + isp_dev->sensors[i].sd = NULL; |
|---|
| 662 | + } |
|---|
| 663 | + } |
|---|
| 664 | +} |
|---|
| 665 | + |
|---|
| 524 | 666 | static const struct v4l2_async_notifier_operations subdev_notifier_ops = { |
|---|
| 525 | 667 | .bound = subdev_notifier_bound, |
|---|
| 526 | 668 | .complete = subdev_notifier_complete, |
|---|
| 669 | + .unbind = subdev_notifier_unbind, |
|---|
| 527 | 670 | }; |
|---|
| 528 | 671 | |
|---|
| 529 | 672 | static int isp_subdev_notifier(struct rkisp_device *isp_dev) |
|---|
| .. | .. |
|---|
| 532 | 675 | struct device *dev = isp_dev->dev; |
|---|
| 533 | 676 | int ret; |
|---|
| 534 | 677 | |
|---|
| 678 | + v4l2_async_notifier_init(ntf); |
|---|
| 679 | + |
|---|
| 535 | 680 | ret = v4l2_async_notifier_parse_fwnode_endpoints( |
|---|
| 536 | 681 | dev, ntf, sizeof(struct rkisp_async_subdev), |
|---|
| 537 | 682 | rkisp_fwnode_parse); |
|---|
| 538 | 683 | if (ret < 0) |
|---|
| 539 | 684 | return ret; |
|---|
| 540 | | - |
|---|
| 541 | | - if (!ntf->num_subdevs) |
|---|
| 542 | | - return -ENODEV; /* no endpoint */ |
|---|
| 543 | 685 | |
|---|
| 544 | 686 | ntf->ops = &subdev_notifier_ops; |
|---|
| 545 | 687 | |
|---|
| .. | .. |
|---|
| 588 | 730 | if (ret < 0) { |
|---|
| 589 | 731 | v4l2_err(&dev->v4l2_dev, |
|---|
| 590 | 732 | "Failed to register subdev notifier(%d)\n", ret); |
|---|
| 591 | | - /* maybe use dmarx to input image */ |
|---|
| 592 | | - ret = v4l2_device_register_subdev_nodes(&dev->v4l2_dev); |
|---|
| 593 | | - if (ret == 0) |
|---|
| 594 | | - return 0; |
|---|
| 595 | 733 | goto err_unreg_luma_vdev; |
|---|
| 596 | 734 | } |
|---|
| 597 | 735 | |
|---|
| .. | .. |
|---|
| 688 | 826 | sizeof(struct rkisp_thunderboot_resmem_head), |
|---|
| 689 | 827 | DMA_BIDIRECTIONAL); |
|---|
| 690 | 828 | ret = dma_mapping_error(dev, isp_dev->resmem_addr); |
|---|
| 691 | | - |
|---|
| 692 | 829 | isp_dev->is_thunderboot = true; |
|---|
| 693 | | - atomic_inc(&isp_dev->hw_dev->tb_ref); |
|---|
| 694 | | - |
|---|
| 695 | | - dev_info(dev, "Allocated reserved memory, paddr: 0x%x\n", |
|---|
| 696 | | - (u32)isp_dev->resmem_pa); |
|---|
| 830 | + isp_dev->is_rtt_suspend = false; |
|---|
| 831 | + isp_dev->is_rtt_first = true; |
|---|
| 832 | + if (device_property_read_bool(dev, "rtt-suspend")) { |
|---|
| 833 | + isp_dev->is_rtt_suspend = true; |
|---|
| 834 | + if (!isp_dev->hw_dev->is_thunderboot) { |
|---|
| 835 | + isp_dev->is_thunderboot = false; |
|---|
| 836 | + isp_dev->is_rtt_first = false; |
|---|
| 837 | + } |
|---|
| 838 | + } |
|---|
| 839 | + dev_info(dev, "Allocated reserved memory, paddr: 0x%x\n", (u32)isp_dev->resmem_pa); |
|---|
| 697 | 840 | return ret; |
|---|
| 698 | 841 | } |
|---|
| 699 | 842 | |
|---|
| .. | .. |
|---|
| 702 | 845 | struct device *dev = &pdev->dev; |
|---|
| 703 | 846 | struct v4l2_device *v4l2_dev; |
|---|
| 704 | 847 | struct rkisp_device *isp_dev; |
|---|
| 705 | | - int i, ret; |
|---|
| 848 | + int i, ret, mult = 1; |
|---|
| 706 | 849 | |
|---|
| 707 | | - sprintf(rkisp_version, "v%02x.%02x.%02x", |
|---|
| 708 | | - RKISP_DRIVER_VERSION >> 16, |
|---|
| 709 | | - (RKISP_DRIVER_VERSION & 0xff00) >> 8, |
|---|
| 710 | | - RKISP_DRIVER_VERSION & 0x00ff); |
|---|
| 850 | + snprintf(rkisp_version, sizeof(rkisp_version), |
|---|
| 851 | + "v%02x.%02x.%02x", |
|---|
| 852 | + RKISP_DRIVER_VERSION >> 16, |
|---|
| 853 | + (RKISP_DRIVER_VERSION & 0xff00) >> 8, |
|---|
| 854 | + RKISP_DRIVER_VERSION & 0x00ff); |
|---|
| 711 | 855 | |
|---|
| 712 | 856 | dev_info(dev, "rkisp driver version: %s\n", rkisp_version); |
|---|
| 713 | 857 | |
|---|
| 714 | 858 | isp_dev = devm_kzalloc(dev, sizeof(*isp_dev), GFP_KERNEL); |
|---|
| 715 | 859 | if (!isp_dev) |
|---|
| 716 | 860 | return -ENOMEM; |
|---|
| 717 | | - isp_dev->sw_base_addr = devm_kzalloc(dev, RKISP_ISP_SW_MAX_SIZE, GFP_KERNEL); |
|---|
| 718 | | - if (!isp_dev->sw_base_addr) |
|---|
| 719 | | - return -ENOMEM; |
|---|
| 720 | 861 | |
|---|
| 721 | 862 | dev_set_drvdata(dev, isp_dev); |
|---|
| 722 | 863 | isp_dev->dev = dev; |
|---|
| 864 | + ret = rkisp_attach_hw(isp_dev); |
|---|
| 865 | + if (ret) |
|---|
| 866 | + return ret; |
|---|
| 867 | + |
|---|
| 868 | + if (isp_dev->hw_dev->unite) |
|---|
| 869 | + mult = 2; |
|---|
| 870 | + isp_dev->sw_base_addr = devm_kzalloc(dev, RKISP_ISP_SW_MAX_SIZE * mult, GFP_KERNEL); |
|---|
| 871 | + if (!isp_dev->sw_base_addr) |
|---|
| 872 | + return -ENOMEM; |
|---|
| 723 | 873 | |
|---|
| 724 | 874 | ret = rkisp_vs_irq_parse(dev); |
|---|
| 725 | 875 | if (ret) |
|---|
| 726 | 876 | return ret; |
|---|
| 727 | 877 | |
|---|
| 728 | | - ret = rkisp_attach_hw(isp_dev); |
|---|
| 878 | + snprintf(isp_dev->media_dev.model, sizeof(isp_dev->media_dev.model), |
|---|
| 879 | + "%s%d", DRIVER_NAME, isp_dev->dev_id); |
|---|
| 880 | + if (!isp_dev->hw_dev->unite) |
|---|
| 881 | + strscpy(isp_dev->name, dev_name(dev), sizeof(isp_dev->name)); |
|---|
| 882 | + else |
|---|
| 883 | + snprintf(isp_dev->name, sizeof(isp_dev->name), |
|---|
| 884 | + "%s%d", "rkisp-unite", isp_dev->dev_id); |
|---|
| 885 | + strscpy(isp_dev->media_dev.driver_name, isp_dev->name, |
|---|
| 886 | + sizeof(isp_dev->media_dev.driver_name)); |
|---|
| 887 | + |
|---|
| 888 | + ret = rkisp_get_reserved_mem(isp_dev); |
|---|
| 729 | 889 | if (ret) |
|---|
| 730 | 890 | return ret; |
|---|
| 731 | | - |
|---|
| 732 | | - sprintf(isp_dev->media_dev.model, "%s%d", |
|---|
| 733 | | - DRIVER_NAME, isp_dev->dev_id); |
|---|
| 734 | | - |
|---|
| 735 | | - if (isp_dev->hw_dev->is_thunderboot) { |
|---|
| 736 | | - ret = rkisp_get_reserved_mem(isp_dev); |
|---|
| 737 | | - if (ret) |
|---|
| 738 | | - return ret; |
|---|
| 739 | | - } |
|---|
| 740 | 891 | |
|---|
| 741 | 892 | mutex_init(&isp_dev->apilock); |
|---|
| 742 | 893 | mutex_init(&isp_dev->iqlock); |
|---|
| .. | .. |
|---|
| 755 | 906 | } |
|---|
| 756 | 907 | } |
|---|
| 757 | 908 | |
|---|
| 758 | | - strscpy(isp_dev->name, dev_name(dev), sizeof(isp_dev->name)); |
|---|
| 759 | | - strscpy(isp_dev->media_dev.driver_name, isp_dev->name, |
|---|
| 760 | | - sizeof(isp_dev->media_dev.driver_name)); |
|---|
| 761 | 909 | isp_dev->media_dev.dev = dev; |
|---|
| 762 | 910 | isp_dev->media_dev.ops = &rkisp_media_ops; |
|---|
| 763 | 911 | |
|---|
| .. | .. |
|---|
| 780 | 928 | goto err_unreg_v4l2_dev; |
|---|
| 781 | 929 | } |
|---|
| 782 | 930 | |
|---|
| 931 | + pm_runtime_enable(dev); |
|---|
| 783 | 932 | /* create & register platefom subdev (from of_node) */ |
|---|
| 784 | 933 | ret = rkisp_register_platform_subdevs(isp_dev); |
|---|
| 785 | | - if (ret < 0) |
|---|
| 934 | + if (ret < 0) { |
|---|
| 935 | + v4l2_err(v4l2_dev, "Failed to register platform subdevs:%d\n", ret); |
|---|
| 786 | 936 | goto err_unreg_media_dev; |
|---|
| 787 | | - |
|---|
| 937 | + } |
|---|
| 788 | 938 | rkisp_wait_line = 0; |
|---|
| 789 | 939 | of_property_read_u32(dev->of_node, "wait-line", &rkisp_wait_line); |
|---|
| 790 | 940 | |
|---|
| .. | .. |
|---|
| 793 | 943 | mutex_lock(&rkisp_dev_mutex); |
|---|
| 794 | 944 | list_add_tail(&isp_dev->list, &rkisp_device_list); |
|---|
| 795 | 945 | mutex_unlock(&rkisp_dev_mutex); |
|---|
| 796 | | - |
|---|
| 797 | | - pm_runtime_enable(dev); |
|---|
| 798 | | - if (isp_dev->hw_dev->is_thunderboot && isp_dev->is_thunderboot) |
|---|
| 799 | | - pm_runtime_get_noresume(isp_dev->hw_dev->dev); |
|---|
| 946 | + isp_dev->is_probe_end = true; |
|---|
| 800 | 947 | return 0; |
|---|
| 801 | 948 | |
|---|
| 802 | 949 | err_unreg_media_dev: |
|---|
| .. | .. |
|---|
| 810 | 957 | { |
|---|
| 811 | 958 | struct rkisp_device *isp_dev = platform_get_drvdata(pdev); |
|---|
| 812 | 959 | |
|---|
| 960 | + isp_dev->is_hw_link = false; |
|---|
| 961 | + isp_dev->hw_dev->isp[isp_dev->dev_id] = NULL; |
|---|
| 962 | + |
|---|
| 813 | 963 | pm_runtime_disable(&pdev->dev); |
|---|
| 814 | 964 | |
|---|
| 815 | 965 | rkisp_proc_cleanup(isp_dev); |
|---|
| 816 | 966 | media_device_unregister(&isp_dev->media_dev); |
|---|
| 967 | + v4l2_async_notifier_unregister(&isp_dev->notifier); |
|---|
| 968 | + v4l2_async_notifier_cleanup(&isp_dev->notifier); |
|---|
| 817 | 969 | v4l2_device_unregister(&isp_dev->v4l2_dev); |
|---|
| 970 | + v4l2_ctrl_handler_free(&isp_dev->ctrl_handler); |
|---|
| 818 | 971 | rkisp_unregister_luma_vdev(&isp_dev->luma_vdev); |
|---|
| 819 | 972 | rkisp_unregister_params_vdev(&isp_dev->params_vdev); |
|---|
| 820 | 973 | rkisp_unregister_stats_vdev(&isp_dev->stats_vdev); |
|---|
| .. | .. |
|---|
| 843 | 996 | struct rkisp_device *isp_dev = dev_get_drvdata(dev); |
|---|
| 844 | 997 | int ret; |
|---|
| 845 | 998 | |
|---|
| 999 | + /* power on to config default format from sensor */ |
|---|
| 1000 | + if (isp_dev->isp_inp & (INP_CSI | INP_DVP | INP_LVDS | INP_CIF) && |
|---|
| 1001 | + rkisp_update_sensor_info(isp_dev) >= 0) |
|---|
| 1002 | + _set_pipeline_default_fmt(isp_dev, false); |
|---|
| 1003 | + |
|---|
| 1004 | + if (isp_dev->hw_dev->is_assigned_clk) |
|---|
| 1005 | + rkisp_clk_dbg = true; |
|---|
| 1006 | + |
|---|
| 1007 | + if (isp_dev->hw_dev->unite == ISP_UNITE_ONE && |
|---|
| 1008 | + !(isp_dev->isp_inp & INP_RAWRD2)) |
|---|
| 1009 | + rkisp_rdbk_auto = true; |
|---|
| 1010 | + |
|---|
| 846 | 1011 | isp_dev->cap_dev.wait_line = rkisp_wait_line; |
|---|
| 1012 | + isp_dev->cap_dev.wrap_line = rkisp_wrap_line; |
|---|
| 1013 | + isp_dev->is_rdbk_auto = rkisp_rdbk_auto; |
|---|
| 847 | 1014 | mutex_lock(&isp_dev->hw_dev->dev_lock); |
|---|
| 848 | 1015 | ret = pm_runtime_get_sync(isp_dev->hw_dev->dev); |
|---|
| 849 | 1016 | mutex_unlock(&isp_dev->hw_dev->dev_lock); |
|---|
| .. | .. |
|---|
| 860 | 1027 | late_initcall_sync(rkisp_clr_unready_dev); |
|---|
| 861 | 1028 | #endif |
|---|
| 862 | 1029 | |
|---|
| 1030 | +static int rkisp_pm_prepare(struct device *dev) |
|---|
| 1031 | +{ |
|---|
| 1032 | + struct rkisp_device *isp_dev = dev_get_drvdata(dev); |
|---|
| 1033 | + struct rkisp_hw_dev *hw = isp_dev->hw_dev; |
|---|
| 1034 | + struct rkisp_pipeline *p = &isp_dev->pipe; |
|---|
| 1035 | + unsigned long lock_flags = 0; |
|---|
| 1036 | + int i, on = 0, time = 100; |
|---|
| 1037 | + |
|---|
| 1038 | + if (isp_dev->isp_state & ISP_STOP) { |
|---|
| 1039 | + if (pm_runtime_active(dev) && |
|---|
| 1040 | + rkisp_link_sensor(isp_dev->isp_inp)) { |
|---|
| 1041 | + struct v4l2_subdev *mipi_sensor = NULL; |
|---|
| 1042 | + |
|---|
| 1043 | + rkisp_get_remote_mipi_sensor(isp_dev, &mipi_sensor, MEDIA_ENT_F_CAM_SENSOR); |
|---|
| 1044 | + if (mipi_sensor) |
|---|
| 1045 | + v4l2_subdev_call(mipi_sensor, core, s_power, 0); |
|---|
| 1046 | + } |
|---|
| 1047 | + return 0; |
|---|
| 1048 | + } |
|---|
| 1049 | + |
|---|
| 1050 | + isp_dev->suspend_sync = false; |
|---|
| 1051 | + isp_dev->is_suspend = true; |
|---|
| 1052 | + if (rkisp_link_sensor(isp_dev->isp_inp)) { |
|---|
| 1053 | + for (i = p->num_subdevs - 1; i >= 0; i--) |
|---|
| 1054 | + v4l2_subdev_call(p->subdevs[i], video, s_stream, on); |
|---|
| 1055 | + } else if (isp_dev->isp_inp & INP_CIF && !(IS_HDR_RDBK(isp_dev->rd_mode))) { |
|---|
| 1056 | + v4l2_subdev_call(p->subdevs[0], core, ioctl, RKISP_VICAP_CMD_QUICK_STREAM, &on); |
|---|
| 1057 | + } |
|---|
| 1058 | + if (IS_HDR_RDBK(isp_dev->rd_mode)) { |
|---|
| 1059 | + spin_lock_irqsave(&hw->rdbk_lock, lock_flags); |
|---|
| 1060 | + if (!hw->is_idle && hw->cur_dev_id == isp_dev->dev_id) |
|---|
| 1061 | + isp_dev->suspend_sync = true; |
|---|
| 1062 | + spin_unlock_irqrestore(&hw->rdbk_lock, lock_flags); |
|---|
| 1063 | + } |
|---|
| 1064 | + |
|---|
| 1065 | + if (isp_dev->suspend_sync) { |
|---|
| 1066 | + wait_for_completion_timeout(&isp_dev->pm_cmpl, msecs_to_jiffies(time)); |
|---|
| 1067 | + isp_dev->suspend_sync = false; |
|---|
| 1068 | + } |
|---|
| 1069 | + |
|---|
| 1070 | + if (rkisp_link_sensor(isp_dev->isp_inp)) { |
|---|
| 1071 | + for (i = p->num_subdevs - 1; i >= 0; i--) |
|---|
| 1072 | + v4l2_subdev_call(p->subdevs[i], core, s_power, 0); |
|---|
| 1073 | + } |
|---|
| 1074 | + return 0; |
|---|
| 1075 | +} |
|---|
| 1076 | + |
|---|
| 1077 | +static void rkisp_pm_complete(struct device *dev) |
|---|
| 1078 | +{ |
|---|
| 1079 | + struct rkisp_device *isp_dev = dev_get_drvdata(dev); |
|---|
| 1080 | + struct rkisp_hw_dev *hw = isp_dev->hw_dev; |
|---|
| 1081 | + struct rkisp_pipeline *p = &isp_dev->pipe; |
|---|
| 1082 | + struct rkisp_stream *stream; |
|---|
| 1083 | + int i, on = 1, rd_mode = isp_dev->rd_mode; |
|---|
| 1084 | + u32 val; |
|---|
| 1085 | + |
|---|
| 1086 | + if (isp_dev->isp_state & ISP_STOP) { |
|---|
| 1087 | + if (pm_runtime_active(dev) && |
|---|
| 1088 | + rkisp_link_sensor(isp_dev->isp_inp)) { |
|---|
| 1089 | + struct v4l2_subdev *mipi_sensor = NULL; |
|---|
| 1090 | + |
|---|
| 1091 | + rkisp_get_remote_mipi_sensor(isp_dev, &mipi_sensor, MEDIA_ENT_F_CAM_SENSOR); |
|---|
| 1092 | + if (mipi_sensor) |
|---|
| 1093 | + v4l2_subdev_call(mipi_sensor, core, s_power, 1); |
|---|
| 1094 | + } |
|---|
| 1095 | + return; |
|---|
| 1096 | + } |
|---|
| 1097 | + |
|---|
| 1098 | + if (isp_dev->is_rtt_suspend) { |
|---|
| 1099 | + rkisp_save_tb_info(isp_dev); |
|---|
| 1100 | + v4l2_info(&isp_dev->v4l2_dev, |
|---|
| 1101 | + "tb info en:%d comp:%d cnt:%d w:%d h:%d cam:%d idx:%d mode:%d\n", |
|---|
| 1102 | + isp_dev->tb_head.enable, isp_dev->tb_head.complete, |
|---|
| 1103 | + isp_dev->tb_head.frm_total, isp_dev->tb_head.width, |
|---|
| 1104 | + isp_dev->tb_head.height, isp_dev->tb_head.camera_num, |
|---|
| 1105 | + isp_dev->tb_head.camera_index, isp_dev->tb_head.rtt_mode); |
|---|
| 1106 | + isp_dev->is_first_double = false; |
|---|
| 1107 | + switch (isp_dev->tb_head.rtt_mode) { |
|---|
| 1108 | + case RKISP_RTT_MODE_ONE_FRAME: |
|---|
| 1109 | + isp_dev->is_first_double = true; |
|---|
| 1110 | + /* switch to readback mode */ |
|---|
| 1111 | + switch (rd_mode) { |
|---|
| 1112 | + case HDR_LINEX3_DDR: |
|---|
| 1113 | + isp_dev->rd_mode = HDR_RDBK_FRAME3; |
|---|
| 1114 | + break; |
|---|
| 1115 | + case HDR_LINEX2_DDR: |
|---|
| 1116 | + isp_dev->rd_mode = HDR_RDBK_FRAME2; |
|---|
| 1117 | + break; |
|---|
| 1118 | + default: |
|---|
| 1119 | + isp_dev->rd_mode = HDR_RDBK_FRAME1; |
|---|
| 1120 | + } |
|---|
| 1121 | + break; |
|---|
| 1122 | + case RKISP_RTT_MODE_MULTI_FRAME: |
|---|
| 1123 | + default: |
|---|
| 1124 | + if (isp_dev->tb_head.rtt_mode != RKISP_RTT_MODE_MULTI_FRAME) |
|---|
| 1125 | + v4l2_warn(&isp_dev->v4l2_dev, |
|---|
| 1126 | + "invalid rtt mode:%d, change to mode:%d\n", |
|---|
| 1127 | + isp_dev->tb_head.rtt_mode, RKISP_RTT_MODE_MULTI_FRAME); |
|---|
| 1128 | + if (!hw->is_single) |
|---|
| 1129 | + break; |
|---|
| 1130 | + /* switch to online mode for single sensor */ |
|---|
| 1131 | + switch (rd_mode) { |
|---|
| 1132 | + case HDR_RDBK_FRAME3: |
|---|
| 1133 | + isp_dev->rd_mode = HDR_LINEX3_DDR; |
|---|
| 1134 | + break; |
|---|
| 1135 | + case HDR_RDBK_FRAME2: |
|---|
| 1136 | + isp_dev->rd_mode = HDR_LINEX2_DDR; |
|---|
| 1137 | + break; |
|---|
| 1138 | + default: |
|---|
| 1139 | + isp_dev->rd_mode = HDR_NORMAL; |
|---|
| 1140 | + } |
|---|
| 1141 | + } |
|---|
| 1142 | + isp_dev->hdr.op_mode = isp_dev->rd_mode; |
|---|
| 1143 | + if (rd_mode != isp_dev->rd_mode && hw->cur_dev_id == isp_dev->dev_id) { |
|---|
| 1144 | + rkisp_unite_write(isp_dev, CSI2RX_CTRL0, |
|---|
| 1145 | + SW_IBUF_OP_MODE(isp_dev->rd_mode), true); |
|---|
| 1146 | + if (IS_HDR_RDBK(isp_dev->rd_mode)) |
|---|
| 1147 | + rkisp_unite_set_bits(isp_dev, CTRL_SWS_CFG, 0, |
|---|
| 1148 | + SW_MPIP_DROP_FRM_DIS, true); |
|---|
| 1149 | + else |
|---|
| 1150 | + rkisp_unite_clear_bits(isp_dev, CTRL_SWS_CFG, |
|---|
| 1151 | + SW_MPIP_DROP_FRM_DIS, true); |
|---|
| 1152 | + } |
|---|
| 1153 | + } |
|---|
| 1154 | + |
|---|
| 1155 | + isp_dev->is_suspend = false; |
|---|
| 1156 | + isp_dev->isp_state = ISP_START | ISP_FRAME_END; |
|---|
| 1157 | + if (!hw->is_single && hw->is_multi_overflow) |
|---|
| 1158 | + hw->pre_dev_id++; |
|---|
| 1159 | + if (isp_dev->is_suspend_one_frame && !hw->is_multi_overflow) |
|---|
| 1160 | + isp_dev->is_first_double = true; |
|---|
| 1161 | + if (hw->isp_ver > ISP_V20) { |
|---|
| 1162 | + val = ISP3X_YNR_FST_FRAME | ISP3X_CNR_FST_FRAME | |
|---|
| 1163 | + ISP3X_DHAZ_FST_FRAME | ISP3X_ADRC_FST_FRAME; |
|---|
| 1164 | + if (hw->isp_ver == ISP_V32) |
|---|
| 1165 | + val |= ISP32_SHP_FST_FRAME; |
|---|
| 1166 | + rkisp_unite_set_bits(isp_dev, ISP3X_ISP_CTRL1, 0, val, false); |
|---|
| 1167 | + } |
|---|
| 1168 | + for (i = 0; i < RKISP_MAX_STREAM; i++) { |
|---|
| 1169 | + stream = &isp_dev->cap_dev.stream[i]; |
|---|
| 1170 | + if (i == RKISP_STREAM_VIR || !stream->streaming || !stream->curr_buf) |
|---|
| 1171 | + continue; |
|---|
| 1172 | + /* skip first frame due to hw no reference frame information */ |
|---|
| 1173 | + if (isp_dev->is_first_double) |
|---|
| 1174 | + stream->skip_frame = 1; |
|---|
| 1175 | + } |
|---|
| 1176 | + if (hw->cur_dev_id == isp_dev->dev_id) |
|---|
| 1177 | + rkisp_rdbk_trigger_event(isp_dev, T_CMD_QUEUE, NULL); |
|---|
| 1178 | + |
|---|
| 1179 | + if (rkisp_link_sensor(isp_dev->isp_inp)) { |
|---|
| 1180 | + for (i = 0; i < p->num_subdevs; i++) |
|---|
| 1181 | + v4l2_subdev_call(p->subdevs[i], core, s_power, 1); |
|---|
| 1182 | + for (i = 0; i < p->num_subdevs; i++) |
|---|
| 1183 | + v4l2_subdev_call(p->subdevs[i], video, s_stream, on); |
|---|
| 1184 | + } else if (isp_dev->isp_inp & INP_CIF && !(IS_HDR_RDBK(isp_dev->rd_mode))) { |
|---|
| 1185 | + v4l2_subdev_call(p->subdevs[0], core, ioctl, RKISP_VICAP_CMD_QUICK_STREAM, &on); |
|---|
| 1186 | + } |
|---|
| 1187 | +} |
|---|
| 1188 | + |
|---|
| 863 | 1189 | static const struct dev_pm_ops rkisp_plat_pm_ops = { |
|---|
| 864 | | - SET_SYSTEM_SLEEP_PM_OPS(pm_runtime_force_suspend, |
|---|
| 865 | | - pm_runtime_force_resume) |
|---|
| 1190 | + .prepare = rkisp_pm_prepare, |
|---|
| 1191 | + .complete = rkisp_pm_complete, |
|---|
| 866 | 1192 | SET_RUNTIME_PM_OPS(rkisp_runtime_suspend, rkisp_runtime_resume, NULL) |
|---|
| 867 | 1193 | }; |
|---|
| 868 | 1194 | |
|---|
| .. | .. |
|---|
| 888 | 1214 | MODULE_AUTHOR("Rockchip Camera/ISP team"); |
|---|
| 889 | 1215 | MODULE_DESCRIPTION("Rockchip ISP platform driver"); |
|---|
| 890 | 1216 | MODULE_LICENSE("Dual BSD/GPL"); |
|---|
| 1217 | +MODULE_IMPORT_NS(VFS_internal_I_am_really_a_filesystem_and_am_NOT_a_driver); |
|---|