hc
2024-10-22 8ac6c7a54ed1b98d142dce24b11c6de6a1e239a5
kernel/drivers/media/i2c/gc2145.c
....@@ -2105,7 +2105,7 @@
21052105
21062106 dev_dbg(&client->dev, "%s: on: %d\n", __func__, on);
21072107
2108
- if (gc2145->bus_cfg.bus_type == V4L2_MBUS_CSI2) {
2108
+ if (gc2145->bus_cfg.bus_type == V4L2_MBUS_CSI2_DPHY) {
21092109 val = on ? 0x94 : 0x84;
21102110 ret = gc2145_write(client, 0xfe, 0x03);
21112111 ret |= gc2145_write(client, 0x10, val);
....@@ -2458,13 +2458,13 @@
24582458 }
24592459 #endif
24602460
2461
-static int gc2145_g_mbus_config(struct v4l2_subdev *sd,
2461
+static int gc2145_g_mbus_config(struct v4l2_subdev *sd, unsigned int pad_id,
24622462 struct v4l2_mbus_config *config)
24632463 {
24642464 struct gc2145 *gc2145 = to_gc2145(sd);
24652465
2466
- if (gc2145->bus_cfg.bus_type == V4L2_MBUS_CSI2) {
2467
- config->type = V4L2_MBUS_CSI2;
2466
+ if (gc2145->bus_cfg.bus_type == V4L2_MBUS_CSI2_DPHY) {
2467
+ config->type = V4L2_MBUS_CSI2_DPHY;
24682468 config->flags = V4L2_MBUS_CSI2_1_LANE |
24692469 V4L2_MBUS_CSI2_CHANNEL_0 |
24702470 V4L2_MBUS_CSI2_CONTINUOUS_CLOCK;
....@@ -2483,9 +2483,7 @@
24832483 {
24842484 struct gc2145 *gc2145 = to_gc2145(sd);
24852485
2486
- mutex_lock(&gc2145->lock);
24872486 fi->interval = gc2145->frame_size->max_fps;
2488
- mutex_unlock(&gc2145->lock);
24892487
24902488 return 0;
24912489 }
....@@ -2583,8 +2581,11 @@
25832581 }
25842582
25852583 ret = gc2145_ioctl(sd, cmd, inf);
2586
- if (!ret)
2584
+ if (!ret) {
25872585 ret = copy_to_user(up, inf, sizeof(*inf));
2586
+ if (ret)
2587
+ ret = -EFAULT;
2588
+ }
25882589 kfree(inf);
25892590 break;
25902591 case RKMODULE_AWB_CFG:
....@@ -2597,12 +2598,16 @@
25972598 ret = copy_from_user(cfg, up, sizeof(*cfg));
25982599 if (!ret)
25992600 ret = gc2145_ioctl(sd, cmd, cfg);
2601
+ else
2602
+ ret = -EFAULT;
26002603 kfree(cfg);
26012604 break;
26022605 case RKMODULE_SET_QUICK_STREAM:
26032606 ret = copy_from_user(&stream, up, sizeof(u32));
26042607 if (!ret)
26052608 ret = gc2145_ioctl(sd, cmd, &stream);
2609
+ else
2610
+ ret = -EFAULT;
26062611 break;
26072612 default:
26082613 ret = -ENOIOCTLCMD;
....@@ -2621,7 +2626,7 @@
26212626
26222627 dev_info(&client->dev, "%s(%d)\n", __func__, __LINE__);
26232628
2624
- if (gc2145->bus_cfg.bus_type == V4L2_MBUS_CSI2)
2629
+ if (gc2145->bus_cfg.bus_type == V4L2_MBUS_CSI2_DPHY)
26252630 ret = gc2145_write_array(client, gc2145_mipi_init_regs);
26262631 else
26272632 ret = gc2145_write_array(client, gc2145_dvp_init_regs);
....@@ -2665,9 +2670,7 @@
26652670 if (fie->index >= gc2145->cfg_num)
26662671 return -EINVAL;
26672672
2668
- if (fie->code != MEDIA_BUS_FMT_UYVY8_2X8)
2669
- return -EINVAL;
2670
-
2673
+ fie->code = MEDIA_BUS_FMT_UYVY8_2X8;
26712674 fie->width = gc2145->framesize_cfg[fie->index].width;
26722675 fie->height = gc2145->framesize_cfg[fie->index].height;
26732676 fie->interval = gc2145->framesize_cfg[fie->index].max_fps;
....@@ -2687,7 +2690,6 @@
26872690
26882691 static const struct v4l2_subdev_video_ops gc2145_subdev_video_ops = {
26892692 .s_stream = gc2145_s_stream,
2690
- .g_mbus_config = gc2145_g_mbus_config,
26912693 .g_frame_interval = gc2145_g_frame_interval,
26922694 .s_frame_interval = gc2145_s_frame_interval,
26932695 };
....@@ -2698,6 +2700,7 @@
26982700 .enum_frame_interval = gc2145_enum_frame_interval,
26992701 .get_fmt = gc2145_get_fmt,
27002702 .set_fmt = gc2145_set_fmt,
2703
+ .get_mbus_config = gc2145_g_mbus_config,
27012704 };
27022705
27032706 #ifdef CONFIG_VIDEO_V4L2_SUBDEV_API
....@@ -2849,7 +2852,7 @@
28492852 of_node_put(endpoint);
28502853 return ret;
28512854 }
2852
- if (gc2145->bus_cfg.bus_type == V4L2_MBUS_CSI2) {
2855
+ if (gc2145->bus_cfg.bus_type == V4L2_MBUS_CSI2_DPHY) {
28532856 gc2145->framesize_cfg = gc2145_mipi_framesizes;
28542857 gc2145->cfg_num = ARRAY_SIZE(gc2145_mipi_framesizes);
28552858 } else {
....@@ -2871,7 +2874,7 @@
28712874 if (ret)
28722875 dev_info(dev, "Failed to get power regulators\n");
28732876
2874
- return __gc2145_power_on(gc2145);
2877
+ return ret;
28752878 }
28762879
28772880 static int gc2145_probe(struct i2c_client *client,
....@@ -2915,11 +2918,6 @@
29152918
29162919 ret = gc2145_parse_of(gc2145);
29172920 if (ret != 0)
2918
- return -EINVAL;
2919
-
2920
- gc2145->xvclk_frequency = clk_get_rate(gc2145->xvclk);
2921
- if (gc2145->xvclk_frequency < 6000000 ||
2922
- gc2145->xvclk_frequency > 27000000)
29232921 return -EINVAL;
29242922
29252923 v4l2_ctrl_handler_init(&gc2145->ctrls, 3);
....@@ -2972,6 +2970,12 @@
29722970 gc2145->fps = DIV_ROUND_CLOSEST(gc2145->framesize_cfg[0].max_fps.denominator,
29732971 gc2145->framesize_cfg[0].max_fps.numerator);
29742972
2973
+ __gc2145_power_on(gc2145);
2974
+ gc2145->xvclk_frequency = clk_get_rate(gc2145->xvclk);
2975
+ if (gc2145->xvclk_frequency < 6000000 ||
2976
+ gc2145->xvclk_frequency > 27000000)
2977
+ goto error;
2978
+
29752979 ret = gc2145_detect(gc2145);
29762980 if (ret < 0) {
29772981 dev_info(&client->dev, "Check id failed:\n"