forked from ~ljy/RK356X_SDK_RELEASE

hc
2023-12-11 072de836f53be56a70cecf70b43ae43b7ce17376
kernel/drivers/media/platform/rockchip/isp/dev.c
....@@ -63,6 +63,14 @@
6363 module_param_named(monitor, rkisp_monitor, bool, 0644);
6464 MODULE_PARM_DESC(monitor, "rkisp abnormal restart monitor");
6565
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");
73
+
6674 static bool rkisp_clk_dbg;
6775 module_param_named(clk_dbg, rkisp_clk_dbg, bool, 0644);
6876 MODULE_PARM_DESC(clk_dbg, "rkisp clk set by user");
....@@ -78,6 +86,10 @@
7886 static unsigned int rkisp_wait_line;
7987 module_param_named(wait_line, rkisp_wait_line, uint, 0644);
8088 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");
8193
8294 static DEFINE_MUTEX(rkisp_dev_mutex);
8395 static LIST_HEAD(rkisp_device_list);
....@@ -126,7 +138,7 @@
126138 p->num_subdevs = 0;
127139 memset(p->subdevs, 0, sizeof(p->subdevs));
128140
129
- if (!(dev->isp_inp & (INP_CSI | INP_DVP | INP_LVDS)))
141
+ if (!(dev->isp_inp & (INP_CSI | INP_DVP | INP_LVDS | INP_CIF)))
130142 return 0;
131143
132144 while (1) {
....@@ -164,21 +176,35 @@
164176 {
165177 struct rkisp_device *dev = container_of(p, struct rkisp_device, pipe);
166178 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;
168179 struct v4l2_subdev *sd;
169180 struct v4l2_ctrl *ctrl;
170
- u64 data_rate;
171
- int i;
181
+ u64 data_rate = 0;
182
+ int i, fps;
172183
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;
177207 }
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;
182208 goto end;
183209 }
184210
....@@ -187,11 +213,12 @@
187213 return 0;
188214 }
189215
190
- /* find the subdev of active sensor */
216
+ /* find the subdev of active sensor or vicap itf */
191217 sd = p->subdevs[0];
192218 for (i = 0; i < p->num_subdevs; i++) {
193219 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)
195222 break;
196223 }
197224
....@@ -210,7 +237,10 @@
210237 data_rate = v4l2_ctrl_g_ctrl_int64(ctrl) *
211238 dev->isp_sdev.in_fmt.bus_width;
212239 data_rate >>= 3;
240
+end:
213241 do_div(data_rate, 1000 * 1000);
242
+ if (hw_dev->unite == ISP_UNITE_ONE)
243
+ data_rate *= 4;
214244
215245 /* increase 25% margin */
216246 data_rate += data_rate >> 2;
....@@ -221,10 +251,15 @@
221251 break;
222252 if (i == hw_dev->num_clk_rate_tbl)
223253 i--;
224
-end:
254
+
225255 /* set isp clock rate */
226256 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]));
257
+ if (hw_dev->unite == ISP_UNITE_TWO)
258
+ rkisp_set_clk_rate(hw_dev->clks[5], hw_dev->clk_rate_tbl[i].clk_rate * 1000000UL);
259
+ /* aclk equal to core clk */
260
+ if (dev->isp_ver == ISP_V32)
261
+ rkisp_set_clk_rate(hw_dev->clks[1], hw_dev->clk_rate_tbl[i].clk_rate * 1000000UL);
262
+ dev_info(hw_dev->dev, "set isp clk = %luHz\n", clk_get_rate(hw_dev->clks[0]));
228263
229264 return 0;
230265 }
....@@ -259,8 +294,15 @@
259294
260295 static int rkisp_pipeline_close(struct rkisp_pipeline *p)
261296 {
262
- atomic_dec(&p->power_cnt);
297
+ struct rkisp_device *dev = container_of(p, struct rkisp_device, pipe);
263298
299
+ if (atomic_dec_return(&p->power_cnt))
300
+ return 0;
301
+
302
+ rkisp_rx_buf_pool_free(dev);
303
+ dev->hw_dev->isp_size[dev->dev_id].is_on = false;
304
+ if (dev->hw_dev->is_runing && (dev->isp_ver >= ISP_V30) && !rkisp_clk_dbg)
305
+ dev->hw_dev->is_dvfs = true;
264306 return 0;
265307 }
266308
....@@ -281,17 +323,32 @@
281323 if (dev->vs_irq >= 0)
282324 enable_irq(dev->vs_irq);
283325 rockchip_set_system_status(SYS_STATUS_ISP);
284
- v4l2_subdev_call(&dev->isp_sdev.sd, video, s_stream, true);
326
+ ret = v4l2_subdev_call(&dev->isp_sdev.sd, video, s_stream, true);
327
+ if (ret < 0)
328
+ goto err;
285329 /* phy -> sensor */
286330 for (i = 0; i < p->num_subdevs; ++i) {
331
+ if ((dev->vicap_in.merge_num > 1) &&
332
+ (p->subdevs[i]->entity.function == MEDIA_ENT_F_CAM_SENSOR))
333
+ continue;
287334 ret = v4l2_subdev_call(p->subdevs[i], video, s_stream, on);
288335 if (on && ret < 0 && ret != -ENOIOCTLCMD && ret != -ENODEV)
289336 goto err_stream_off;
290337 }
291338 } else {
339
+ if (dev->hw_dev->monitor.is_en) {
340
+ dev->hw_dev->monitor.is_en = 0;
341
+ dev->hw_dev->monitor.state = ISP_STOP;
342
+ if (!completion_done(&dev->hw_dev->monitor.cmpl))
343
+ complete(&dev->hw_dev->monitor.cmpl);
344
+ }
292345 /* sensor -> phy */
293
- for (i = p->num_subdevs - 1; i >= 0; --i)
346
+ for (i = p->num_subdevs - 1; i >= 0; --i) {
347
+ if ((dev->vicap_in.merge_num > 1) &&
348
+ (p->subdevs[i]->entity.function == MEDIA_ENT_F_CAM_SENSOR))
349
+ continue;
294350 v4l2_subdev_call(p->subdevs[i], video, s_stream, on);
351
+ }
295352 if (dev->vs_irq >= 0)
296353 disable_irq(dev->vs_irq);
297354 v4l2_subdev_call(&dev->isp_sdev.sd, video, s_stream, false);
....@@ -304,7 +361,9 @@
304361 for (--i; i >= 0; --i)
305362 v4l2_subdev_call(p->subdevs[i], video, s_stream, false);
306363 v4l2_subdev_call(&dev->isp_sdev.sd, video, s_stream, false);
364
+err:
307365 rockchip_clear_system_status(SYS_STATUS_ISP);
366
+ atomic_dec_return(&p->stream_cnt);
308367 return ret;
309368 }
310369
....@@ -320,7 +379,7 @@
320379 for (s = 0; s < dev->num_sensors; ++s) {
321380 struct rkisp_sensor_info *sensor = &dev->sensors[s];
322381 u32 type = sensor->sd->entity.function;
323
- bool en = s ? 0 : MEDIA_LNK_FL_ENABLED;
382
+ bool en = s ? 0 : true;
324383
325384 for (pad = 0; pad < sensor->sd->entity.num_pads; pad++)
326385 if (sensor->sd->entity.pads[pad].flags & MEDIA_PAD_FL_SOURCE)
....@@ -342,8 +401,8 @@
342401 ret = media_create_pad_link(&sensor->sd->entity, pad,
343402 &dev->isp_sdev.sd.entity, RKISP_ISP_PAD_SINK, en);
344403 } else {
345
- v4l2_subdev_call(sensor->sd, video,
346
- g_mbus_config, &sensor->mbus);
404
+ v4l2_subdev_call(sensor->sd, pad,
405
+ get_mbus_config, 0, &sensor->mbus);
347406 if (sensor->mbus.type == V4L2_MBUS_CCP2) {
348407 /* mipi-phy lvds link -> isp */
349408 dev->isp_inp = INP_LVDS;
....@@ -366,16 +425,27 @@
366425 return ret;
367426 }
368427
369
-static int _set_pipeline_default_fmt(struct rkisp_device *dev)
428
+static int _set_pipeline_default_fmt(struct rkisp_device *dev, bool is_init)
370429 {
371430 struct v4l2_subdev *isp;
372431 struct v4l2_subdev_format fmt;
373432 struct v4l2_subdev_selection sel;
374
- u32 width, height, code;
433
+ u32 i, width, height, code;
375434
435
+ memset(&sel, 0, sizeof(sel));
436
+ memset(&fmt, 0, sizeof(fmt));
376437 isp = &dev->isp_sdev.sd;
377438
378
- fmt = dev->active_sensor->fmt[0];
439
+ if (dev->active_sensor) {
440
+ fmt = dev->active_sensor->fmt[0];
441
+ if (!is_init &&
442
+ fmt.format.code == dev->isp_sdev.in_frm.code &&
443
+ fmt.format.width == dev->isp_sdev.in_frm.width &&
444
+ fmt.format.height == dev->isp_sdev.in_frm.height)
445
+ return 0;
446
+ } else {
447
+ fmt.format = dev->isp_sdev.in_frm;
448
+ }
379449 code = fmt.format.code;
380450 fmt.which = V4L2_SUBDEV_FORMAT_ACTIVE;
381451 fmt.pad = RKISP_ISP_PAD_SINK;
....@@ -411,7 +481,7 @@
411481 rkisp_set_stream_def_fmt(dev, RKISP_STREAM_SP,
412482 width, height, V4L2_PIX_FMT_NV12);
413483 if ((dev->isp_ver == ISP_V20 || dev->isp_ver == ISP_V21) &&
414
- dev->isp_inp == INP_CSI) {
484
+ dev->isp_inp == INP_CSI && dev->active_sensor) {
415485 width = dev->active_sensor->fmt[1].format.width;
416486 height = dev->active_sensor->fmt[1].format.height;
417487 code = dev->active_sensor->fmt[1].format.code;
....@@ -431,12 +501,49 @@
431501 width, height, rkisp_mbus_pixelcode_to_v4l2(code));
432502 }
433503
434
- if (dev->isp_ver == ISP_V20 && dev->isp_inp == INP_CSI) {
504
+ if (dev->isp_ver == ISP_V20 &&
505
+ dev->isp_inp == INP_CSI && dev->active_sensor) {
435506 width = dev->active_sensor->fmt[2].format.width;
436507 height = dev->active_sensor->fmt[2].format.height;
437508 code = dev->active_sensor->fmt[2].format.code;
438509 rkisp_set_stream_def_fmt(dev, RKISP_STREAM_DMATX1,
439510 width, height, rkisp_mbus_pixelcode_to_v4l2(code));
511
+ }
512
+
513
+ if (dev->isp_ver == ISP_V30) {
514
+ struct v4l2_pix_format_mplane pixm = {
515
+ .width = width,
516
+ .height = height,
517
+ .pixelformat = rkisp_mbus_pixelcode_to_v4l2(code),
518
+ };
519
+
520
+ for (i = RKISP_STREAM_RAWRD0; i <= RKISP_STREAM_RAWRD2; i++)
521
+ rkisp_dmarx_set_fmt(&dev->dmarx_dev.stream[i], pixm);
522
+ rkisp_set_stream_def_fmt(dev, RKISP_STREAM_FBC,
523
+ width, height, V4L2_PIX_FMT_FBC0);
524
+#ifdef RKISP_STREAM_BP_EN
525
+ rkisp_set_stream_def_fmt(dev, RKISP_STREAM_BP,
526
+ width, height, V4L2_PIX_FMT_NV12);
527
+#endif
528
+ }
529
+
530
+ if (dev->isp_ver == ISP_V32 || dev->isp_ver == ISP_V32_L) {
531
+ struct v4l2_pix_format_mplane pixm = {
532
+ .width = width,
533
+ .height = height,
534
+ .pixelformat = rkisp_mbus_pixelcode_to_v4l2(code),
535
+ };
536
+
537
+ rkisp_dmarx_set_fmt(&dev->dmarx_dev.stream[RKISP_STREAM_RAWRD0], pixm);
538
+ rkisp_dmarx_set_fmt(&dev->dmarx_dev.stream[RKISP_STREAM_RAWRD2], pixm);
539
+ if (dev->isp_ver == ISP_V32) {
540
+ rkisp_set_stream_def_fmt(dev, RKISP_STREAM_BP,
541
+ width, height, V4L2_PIX_FMT_NV12);
542
+ rkisp_set_stream_def_fmt(dev, RKISP_STREAM_MPDS,
543
+ width / 4, height / 4, V4L2_PIX_FMT_NV12);
544
+ rkisp_set_stream_def_fmt(dev, RKISP_STREAM_BPDS,
545
+ width / 4, height / 4, V4L2_PIX_FMT_NV12);
546
+ }
440547 }
441548 return 0;
442549 }
....@@ -456,13 +563,16 @@
456563 if (ret < 0)
457564 goto unlock;
458565
459
- ret = rkisp_update_sensor_info(dev);
460
- if (ret < 0) {
461
- v4l2_err(&dev->v4l2_dev, "update sensor failed\n");
462
- goto unlock;
566
+ if (dev->isp_inp) {
567
+ ret = rkisp_update_sensor_info(dev);
568
+ if (ret < 0) {
569
+ v4l2_err(&dev->v4l2_dev, "update sensor failed\n");
570
+ goto unlock;
571
+ }
572
+ dev->is_hw_link = true;
463573 }
464574
465
- ret = _set_pipeline_default_fmt(dev);
575
+ ret = _set_pipeline_default_fmt(dev, true);
466576 if (ret < 0)
467577 goto unlock;
468578
....@@ -470,6 +580,8 @@
470580
471581 unlock:
472582 mutex_unlock(&dev->media_dev.graph_mutex);
583
+ if (!ret && dev->is_thunderboot)
584
+ schedule_work(&dev->cap_dev.fast_work);
473585 return ret;
474586 }
475587
....@@ -521,9 +633,28 @@
521633 return 0;
522634 }
523635
636
+static void subdev_notifier_unbind(struct v4l2_async_notifier *notifier,
637
+ struct v4l2_subdev *subdev,
638
+ struct v4l2_async_subdev *asd)
639
+{
640
+ struct rkisp_device *isp_dev = container_of(notifier, struct rkisp_device, notifier);
641
+ struct rkisp_isp_subdev *isp_sdev = &isp_dev->isp_sdev;
642
+ struct v4l2_subdev *isp_sd = &isp_sdev->sd;
643
+ int i;
644
+
645
+ for (i = 0; i < isp_dev->num_sensors; i++) {
646
+ if (isp_dev->sensors[i].sd == subdev) {
647
+ media_entity_call(&isp_sd->entity, link_setup,
648
+ isp_sd->entity.pads, subdev->entity.pads, 0);
649
+ isp_dev->sensors[i].sd = NULL;
650
+ }
651
+ }
652
+}
653
+
524654 static const struct v4l2_async_notifier_operations subdev_notifier_ops = {
525655 .bound = subdev_notifier_bound,
526656 .complete = subdev_notifier_complete,
657
+ .unbind = subdev_notifier_unbind,
527658 };
528659
529660 static int isp_subdev_notifier(struct rkisp_device *isp_dev)
....@@ -532,14 +663,13 @@
532663 struct device *dev = isp_dev->dev;
533664 int ret;
534665
666
+ v4l2_async_notifier_init(ntf);
667
+
535668 ret = v4l2_async_notifier_parse_fwnode_endpoints(
536669 dev, ntf, sizeof(struct rkisp_async_subdev),
537670 rkisp_fwnode_parse);
538671 if (ret < 0)
539672 return ret;
540
-
541
- if (!ntf->num_subdevs)
542
- return -ENODEV; /* no endpoint */
543673
544674 ntf->ops = &subdev_notifier_ops;
545675
....@@ -588,10 +718,6 @@
588718 if (ret < 0) {
589719 v4l2_err(&dev->v4l2_dev,
590720 "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;
595721 goto err_unreg_luma_vdev;
596722 }
597723
....@@ -688,12 +814,8 @@
688814 sizeof(struct rkisp_thunderboot_resmem_head),
689815 DMA_BIDIRECTIONAL);
690816 ret = dma_mapping_error(dev, isp_dev->resmem_addr);
691
-
692817 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);
818
+ dev_info(dev, "Allocated reserved memory, paddr: 0x%x\n", (u32)isp_dev->resmem_pa);
697819 return ret;
698820 }
699821
....@@ -702,41 +824,49 @@
702824 struct device *dev = &pdev->dev;
703825 struct v4l2_device *v4l2_dev;
704826 struct rkisp_device *isp_dev;
705
- int i, ret;
827
+ int i, ret, mult = 1;
706828
707
- sprintf(rkisp_version, "v%02x.%02x.%02x",
708
- RKISP_DRIVER_VERSION >> 16,
709
- (RKISP_DRIVER_VERSION & 0xff00) >> 8,
710
- RKISP_DRIVER_VERSION & 0x00ff);
829
+ snprintf(rkisp_version, sizeof(rkisp_version),
830
+ "v%02x.%02x.%02x",
831
+ RKISP_DRIVER_VERSION >> 16,
832
+ (RKISP_DRIVER_VERSION & 0xff00) >> 8,
833
+ RKISP_DRIVER_VERSION & 0x00ff);
711834
712835 dev_info(dev, "rkisp driver version: %s\n", rkisp_version);
713836
714837 isp_dev = devm_kzalloc(dev, sizeof(*isp_dev), GFP_KERNEL);
715838 if (!isp_dev)
716839 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;
720840
721841 dev_set_drvdata(dev, isp_dev);
722842 isp_dev->dev = dev;
843
+ ret = rkisp_attach_hw(isp_dev);
844
+ if (ret)
845
+ return ret;
846
+
847
+ if (isp_dev->hw_dev->unite)
848
+ mult = 2;
849
+ isp_dev->sw_base_addr = devm_kzalloc(dev, RKISP_ISP_SW_MAX_SIZE * mult, GFP_KERNEL);
850
+ if (!isp_dev->sw_base_addr)
851
+ return -ENOMEM;
723852
724853 ret = rkisp_vs_irq_parse(dev);
725854 if (ret)
726855 return ret;
727856
728
- ret = rkisp_attach_hw(isp_dev);
857
+ snprintf(isp_dev->media_dev.model, sizeof(isp_dev->media_dev.model),
858
+ "%s%d", DRIVER_NAME, isp_dev->dev_id);
859
+ if (!isp_dev->hw_dev->unite)
860
+ strscpy(isp_dev->name, dev_name(dev), sizeof(isp_dev->name));
861
+ else
862
+ snprintf(isp_dev->name, sizeof(isp_dev->name),
863
+ "%s%d", "rkisp-unite", isp_dev->dev_id);
864
+ strscpy(isp_dev->media_dev.driver_name, isp_dev->name,
865
+ sizeof(isp_dev->media_dev.driver_name));
866
+
867
+ ret = rkisp_get_reserved_mem(isp_dev);
729868 if (ret)
730869 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
- }
740870
741871 mutex_init(&isp_dev->apilock);
742872 mutex_init(&isp_dev->iqlock);
....@@ -755,9 +885,6 @@
755885 }
756886 }
757887
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));
761888 isp_dev->media_dev.dev = dev;
762889 isp_dev->media_dev.ops = &rkisp_media_ops;
763890
....@@ -780,11 +907,13 @@
780907 goto err_unreg_v4l2_dev;
781908 }
782909
910
+ pm_runtime_enable(dev);
783911 /* create & register platefom subdev (from of_node) */
784912 ret = rkisp_register_platform_subdevs(isp_dev);
785
- if (ret < 0)
913
+ if (ret < 0) {
914
+ v4l2_err(v4l2_dev, "Failed to register platform subdevs:%d\n", ret);
786915 goto err_unreg_media_dev;
787
-
916
+ }
788917 rkisp_wait_line = 0;
789918 of_property_read_u32(dev->of_node, "wait-line", &rkisp_wait_line);
790919
....@@ -793,10 +922,7 @@
793922 mutex_lock(&rkisp_dev_mutex);
794923 list_add_tail(&isp_dev->list, &rkisp_device_list);
795924 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);
925
+ isp_dev->is_probe_end = true;
800926 return 0;
801927
802928 err_unreg_media_dev:
....@@ -810,11 +936,17 @@
810936 {
811937 struct rkisp_device *isp_dev = platform_get_drvdata(pdev);
812938
939
+ isp_dev->is_hw_link = false;
940
+ isp_dev->hw_dev->isp[isp_dev->dev_id] = NULL;
941
+
813942 pm_runtime_disable(&pdev->dev);
814943
815944 rkisp_proc_cleanup(isp_dev);
816945 media_device_unregister(&isp_dev->media_dev);
946
+ v4l2_async_notifier_unregister(&isp_dev->notifier);
947
+ v4l2_async_notifier_cleanup(&isp_dev->notifier);
817948 v4l2_device_unregister(&isp_dev->v4l2_dev);
949
+ v4l2_ctrl_handler_free(&isp_dev->ctrl_handler);
818950 rkisp_unregister_luma_vdev(&isp_dev->luma_vdev);
819951 rkisp_unregister_params_vdev(&isp_dev->params_vdev);
820952 rkisp_unregister_stats_vdev(&isp_dev->stats_vdev);
....@@ -843,7 +975,21 @@
843975 struct rkisp_device *isp_dev = dev_get_drvdata(dev);
844976 int ret;
845977
978
+ /* power on to config default format from sensor */
979
+ if (isp_dev->isp_inp & (INP_CSI | INP_DVP | INP_LVDS | INP_CIF) &&
980
+ rkisp_update_sensor_info(isp_dev) >= 0)
981
+ _set_pipeline_default_fmt(isp_dev, false);
982
+
983
+ if (isp_dev->hw_dev->is_assigned_clk)
984
+ rkisp_clk_dbg = true;
985
+
986
+ if (isp_dev->hw_dev->unite == ISP_UNITE_ONE &&
987
+ !(isp_dev->isp_inp & INP_RAWRD2))
988
+ rkisp_rdbk_auto = true;
989
+
846990 isp_dev->cap_dev.wait_line = rkisp_wait_line;
991
+ isp_dev->cap_dev.wrap_line = rkisp_wrap_line;
992
+ isp_dev->is_rdbk_auto = rkisp_rdbk_auto;
847993 mutex_lock(&isp_dev->hw_dev->dev_lock);
848994 ret = pm_runtime_get_sync(isp_dev->hw_dev->dev);
849995 mutex_unlock(&isp_dev->hw_dev->dev_lock);
....@@ -888,3 +1034,4 @@
8881034 MODULE_AUTHOR("Rockchip Camera/ISP team");
8891035 MODULE_DESCRIPTION("Rockchip ISP platform driver");
8901036 MODULE_LICENSE("Dual BSD/GPL");
1037
+MODULE_IMPORT_NS(VFS_internal_I_am_really_a_filesystem_and_am_NOT_a_driver);