.. | .. |
---|
2105 | 2105 | |
---|
2106 | 2106 | dev_dbg(&client->dev, "%s: on: %d\n", __func__, on); |
---|
2107 | 2107 | |
---|
2108 | | - if (gc2145->bus_cfg.bus_type == V4L2_MBUS_CSI2) { |
---|
| 2108 | + if (gc2145->bus_cfg.bus_type == V4L2_MBUS_CSI2_DPHY) { |
---|
2109 | 2109 | val = on ? 0x94 : 0x84; |
---|
2110 | 2110 | ret = gc2145_write(client, 0xfe, 0x03); |
---|
2111 | 2111 | ret |= gc2145_write(client, 0x10, val); |
---|
.. | .. |
---|
2458 | 2458 | } |
---|
2459 | 2459 | #endif |
---|
2460 | 2460 | |
---|
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, |
---|
2462 | 2462 | struct v4l2_mbus_config *config) |
---|
2463 | 2463 | { |
---|
2464 | 2464 | struct gc2145 *gc2145 = to_gc2145(sd); |
---|
2465 | 2465 | |
---|
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; |
---|
2468 | 2468 | config->flags = V4L2_MBUS_CSI2_1_LANE | |
---|
2469 | 2469 | V4L2_MBUS_CSI2_CHANNEL_0 | |
---|
2470 | 2470 | V4L2_MBUS_CSI2_CONTINUOUS_CLOCK; |
---|
.. | .. |
---|
2483 | 2483 | { |
---|
2484 | 2484 | struct gc2145 *gc2145 = to_gc2145(sd); |
---|
2485 | 2485 | |
---|
2486 | | - mutex_lock(&gc2145->lock); |
---|
2487 | 2486 | fi->interval = gc2145->frame_size->max_fps; |
---|
2488 | | - mutex_unlock(&gc2145->lock); |
---|
2489 | 2487 | |
---|
2490 | 2488 | return 0; |
---|
2491 | 2489 | } |
---|
.. | .. |
---|
2583 | 2581 | } |
---|
2584 | 2582 | |
---|
2585 | 2583 | ret = gc2145_ioctl(sd, cmd, inf); |
---|
2586 | | - if (!ret) |
---|
| 2584 | + if (!ret) { |
---|
2587 | 2585 | ret = copy_to_user(up, inf, sizeof(*inf)); |
---|
| 2586 | + if (ret) |
---|
| 2587 | + ret = -EFAULT; |
---|
| 2588 | + } |
---|
2588 | 2589 | kfree(inf); |
---|
2589 | 2590 | break; |
---|
2590 | 2591 | case RKMODULE_AWB_CFG: |
---|
.. | .. |
---|
2597 | 2598 | ret = copy_from_user(cfg, up, sizeof(*cfg)); |
---|
2598 | 2599 | if (!ret) |
---|
2599 | 2600 | ret = gc2145_ioctl(sd, cmd, cfg); |
---|
| 2601 | + else |
---|
| 2602 | + ret = -EFAULT; |
---|
2600 | 2603 | kfree(cfg); |
---|
2601 | 2604 | break; |
---|
2602 | 2605 | case RKMODULE_SET_QUICK_STREAM: |
---|
2603 | 2606 | ret = copy_from_user(&stream, up, sizeof(u32)); |
---|
2604 | 2607 | if (!ret) |
---|
2605 | 2608 | ret = gc2145_ioctl(sd, cmd, &stream); |
---|
| 2609 | + else |
---|
| 2610 | + ret = -EFAULT; |
---|
2606 | 2611 | break; |
---|
2607 | 2612 | default: |
---|
2608 | 2613 | ret = -ENOIOCTLCMD; |
---|
.. | .. |
---|
2621 | 2626 | |
---|
2622 | 2627 | dev_info(&client->dev, "%s(%d)\n", __func__, __LINE__); |
---|
2623 | 2628 | |
---|
2624 | | - if (gc2145->bus_cfg.bus_type == V4L2_MBUS_CSI2) |
---|
| 2629 | + if (gc2145->bus_cfg.bus_type == V4L2_MBUS_CSI2_DPHY) |
---|
2625 | 2630 | ret = gc2145_write_array(client, gc2145_mipi_init_regs); |
---|
2626 | 2631 | else |
---|
2627 | 2632 | ret = gc2145_write_array(client, gc2145_dvp_init_regs); |
---|
.. | .. |
---|
2665 | 2670 | if (fie->index >= gc2145->cfg_num) |
---|
2666 | 2671 | return -EINVAL; |
---|
2667 | 2672 | |
---|
2668 | | - if (fie->code != MEDIA_BUS_FMT_UYVY8_2X8) |
---|
2669 | | - return -EINVAL; |
---|
2670 | | - |
---|
| 2673 | + fie->code = MEDIA_BUS_FMT_UYVY8_2X8; |
---|
2671 | 2674 | fie->width = gc2145->framesize_cfg[fie->index].width; |
---|
2672 | 2675 | fie->height = gc2145->framesize_cfg[fie->index].height; |
---|
2673 | 2676 | fie->interval = gc2145->framesize_cfg[fie->index].max_fps; |
---|
.. | .. |
---|
2687 | 2690 | |
---|
2688 | 2691 | static const struct v4l2_subdev_video_ops gc2145_subdev_video_ops = { |
---|
2689 | 2692 | .s_stream = gc2145_s_stream, |
---|
2690 | | - .g_mbus_config = gc2145_g_mbus_config, |
---|
2691 | 2693 | .g_frame_interval = gc2145_g_frame_interval, |
---|
2692 | 2694 | .s_frame_interval = gc2145_s_frame_interval, |
---|
2693 | 2695 | }; |
---|
.. | .. |
---|
2698 | 2700 | .enum_frame_interval = gc2145_enum_frame_interval, |
---|
2699 | 2701 | .get_fmt = gc2145_get_fmt, |
---|
2700 | 2702 | .set_fmt = gc2145_set_fmt, |
---|
| 2703 | + .get_mbus_config = gc2145_g_mbus_config, |
---|
2701 | 2704 | }; |
---|
2702 | 2705 | |
---|
2703 | 2706 | #ifdef CONFIG_VIDEO_V4L2_SUBDEV_API |
---|
.. | .. |
---|
2849 | 2852 | of_node_put(endpoint); |
---|
2850 | 2853 | return ret; |
---|
2851 | 2854 | } |
---|
2852 | | - if (gc2145->bus_cfg.bus_type == V4L2_MBUS_CSI2) { |
---|
| 2855 | + if (gc2145->bus_cfg.bus_type == V4L2_MBUS_CSI2_DPHY) { |
---|
2853 | 2856 | gc2145->framesize_cfg = gc2145_mipi_framesizes; |
---|
2854 | 2857 | gc2145->cfg_num = ARRAY_SIZE(gc2145_mipi_framesizes); |
---|
2855 | 2858 | } else { |
---|
.. | .. |
---|
2871 | 2874 | if (ret) |
---|
2872 | 2875 | dev_info(dev, "Failed to get power regulators\n"); |
---|
2873 | 2876 | |
---|
2874 | | - return __gc2145_power_on(gc2145); |
---|
| 2877 | + return ret; |
---|
2875 | 2878 | } |
---|
2876 | 2879 | |
---|
2877 | 2880 | static int gc2145_probe(struct i2c_client *client, |
---|
.. | .. |
---|
2915 | 2918 | |
---|
2916 | 2919 | ret = gc2145_parse_of(gc2145); |
---|
2917 | 2920 | 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) |
---|
2923 | 2921 | return -EINVAL; |
---|
2924 | 2922 | |
---|
2925 | 2923 | v4l2_ctrl_handler_init(&gc2145->ctrls, 3); |
---|
.. | .. |
---|
2972 | 2970 | gc2145->fps = DIV_ROUND_CLOSEST(gc2145->framesize_cfg[0].max_fps.denominator, |
---|
2973 | 2971 | gc2145->framesize_cfg[0].max_fps.numerator); |
---|
2974 | 2972 | |
---|
| 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 | + |
---|
2975 | 2979 | ret = gc2145_detect(gc2145); |
---|
2976 | 2980 | if (ret < 0) { |
---|
2977 | 2981 | dev_info(&client->dev, "Check id failed:\n" |
---|