]> rtime.felk.cvut.cz Git - hercules2020/nv-tegra/linux-4.4.git/commitdiff
media:platform:tegra: Make bypass working
authorWenjia Zhou <wenjiaz@nvidia.com>
Fri, 22 Jul 2016 23:53:17 +0000 (16:53 -0700)
committerWenjia Zhou <wenjiaz@nvidia.com>
Wed, 27 Jul 2016 22:25:12 +0000 (15:25 -0700)
Comment out unimplemented T186 part to avoid crashing system.

Change-Id: I20a59968591fb1cb78e5572db7b28bdf22dc4723

drivers/media/platform/tegra/camera/channel.c
drivers/media/platform/tegra/camera/mc_common.c
drivers/media/platform/tegra/csi/csi.c

index 1b9d4946a22508a9e8920b25d8919c3b75137fe8..6bd8f132d4888398f2eaed856d43accf040260f1 100644 (file)
@@ -196,6 +196,8 @@ static void tegra_channel_fmts_bitmap_init(struct tegra_channel *chan)
 
 static int tegra_channel_capture_setup(struct tegra_channel *chan)
 {
+       if (!chan->fops)
+               return 0;
        return chan->fops->soc_channel_capture_setup(chan);
 }
 
@@ -234,6 +236,8 @@ static int tegra_channel_enable_stream(struct tegra_channel *chan)
 
 static int tegra_channel_error_status(struct tegra_channel *chan)
 {
+       if (!chan->fops)
+               return 0;
        return chan->fops->soc_channel_error_status(chan);
 }
 
@@ -342,7 +346,8 @@ static void tegra_channel_ec_init(struct tegra_channel *chan)
         * TODO: Get frame rate from sub-device and adopt timeout
         */
        chan->timeout = 20;
-
+        if (!chan->fops)
+               return;
        chan->fops->soc_channel_ec_init(chan);
 }
 
@@ -352,7 +357,8 @@ static void tegra_channel_ec_recover(struct tegra_channel *chan)
 
        /* Disable pad power to start recovery */
        tegra_csi_pad_control(chan->vi->csi, chan->port, DISABLE);
-
+        if (!chan->fops)
+               return;
        chan->fops->soc_channel_ec_recover(chan);
 
        /* Re-init VI and CSI */
@@ -377,6 +383,8 @@ static int tegra_channel_capture_frame(struct tegra_channel *chan,
        int state = VB2_BUF_STATE_DONE;
 
        /* Init registers related to each frames */
+       if (!chan->fops)
+               return 0;
        chan->fops->soc_channel_capture_frame_init(chan, buf, thresh);
 
        if (!chan->bfirst_fstart) {
@@ -388,10 +396,14 @@ static int tegra_channel_capture_frame(struct tegra_channel *chan,
                        return err;
                }
                /* Enable input stream once the VI registers are configured */
+               if (!chan->fops)
+                       return 0;
                chan->fops->soc_channel_capture_frame_enable(chan);
        }
 
        /* Arm capture and wait for notifier or syncpoint */
+       if (!chan->fops)
+               return 0;
        err = chan->fops->soc_channel_capture_frame(chan, &ts, thresh);
        if (err) {
                state = VB2_BUF_STATE_ERROR;
@@ -445,7 +457,8 @@ static void tegra_channel_capture_done(struct tegra_channel *chan)
        buf = dequeue_buffer(chan);
        if (!buf)
                return;
-
+        if (!chan->fops)
+               return;
        err = chan->fops->soc_channel_capture_done(chan, buf, &ts);
        if (err) {
                state = VB2_BUF_STATE_ERROR;
@@ -696,7 +709,6 @@ static int tegra_channel_start_streaming(struct vb2_queue *vq, u32 count)
                nvhost_module_disable_clk(chan->vi->dev);*/
                return ret;
        }
-
        chan->capture_state = CAPTURE_IDLE;
        for (i = 0; i < chan->valid_ports; i++) {
                tegra_csi_start_streaming(chan->vi->csi, chan->port[i]);
@@ -1167,6 +1179,7 @@ int tegra_channel_init_subdevices(struct tegra_channel *chan)
                entity = pad->entity;
                chan->subdev[num_sd++] = media_entity_to_v4l2_subdev(entity);
 
+               chan->subdev_on_csi = sd;
                index = pad->index - 1;
        }
        chan->num_subdevs = num_sd;
@@ -1450,7 +1463,7 @@ static int tegra_channel_open(struct file *fp)
        int ret;
        struct video_device *vdev = video_devdata(fp);
        struct tegra_channel *chan = video_get_drvdata(vdev);
-       struct vi *tegra_vi;
+       //struct vi *tegra_vi;
        struct tegra_mc_vi *vi;
        struct tegra_csi_device *csi;
 
@@ -1465,31 +1478,35 @@ static int tegra_channel_open(struct file *fp)
        }
 
        vi = chan->vi;
-       tegra_vi = vi->vi;
+       //tegra_vi = vi->vi;
        csi = vi->csi;
 
        /* TPG mode and a real sensor is open, return busy */
+       /*
        if (vi->pg_mode && tegra_vi->sensor_opened)
-               return -EBUSY;
+               return -EBUSY;*/
 
        /* None TPG mode and a TPG channel is opened, return busy */
+       /*
        if (!vi->pg_mode && tegra_vi->tpg_opened)
                return -EBUSY;
+        */
 
        /* The first open then turn on power */
        if (atomic_add_return(1, &vi->power_on_refcnt) == 1) {
-               tegra_vi_power_on(vi);
+               /*tegra_vi_power_on(vi);
                tegra_csi_power_on(csi);
                if (vi->pg_mode)
                        tegra_vi->tpg_opened = true;
                else
                        tegra_vi->sensor_opened = true;
+                       */
        }
 
        if (!vi->pg_mode &&
                (atomic_add_return(1, &chan->power_on_refcnt) == 1)) {
                /* power on sensors connected in channel */
-               tegra_csi_channel_power_on(csi, chan->port);
+               //tegra_csi_channel_power_on(csi, chan->port);
                ret = tegra_channel_set_power(chan, 1);
                if (ret < 0)
                        goto unlock;
@@ -1508,8 +1525,8 @@ static int tegra_channel_close(struct file *fp)
        struct video_device *vdev = video_devdata(fp);
        struct tegra_channel *chan = video_get_drvdata(vdev);
        struct tegra_mc_vi *vi = chan->vi;
-       struct vi *tegra_vi = vi->vi;
-       struct tegra_csi_device *csi = vi->csi;
+       //struct vi *tegra_vi = vi->vi;
+       //struct tegra_csi_device *csi = vi->csi;
        bool is_singular;
 
        mutex_lock(&chan->video_lock);
@@ -1524,7 +1541,7 @@ static int tegra_channel_close(struct file *fp)
        if (!vi->pg_mode &&
                atomic_dec_and_test(&chan->power_on_refcnt)) {
                /* power off sensors connected in channel */
-               tegra_csi_channel_power_off(csi, chan->port);
+               //tegra_csi_channel_power_off(csi, chan->port);
                ret = tegra_channel_set_power(chan, 0);
                if (ret < 0)
                        dev_err(vi->dev, "Failed to power off subdevices\n");
@@ -1532,12 +1549,13 @@ static int tegra_channel_close(struct file *fp)
 
        /* The last release then turn off power */
        if (atomic_dec_and_test(&vi->power_on_refcnt)) {
-               tegra_csi_power_off(csi);
+               /*tegra_csi_power_off(csi);
                tegra_vi_power_off(vi);
                if (vi->pg_mode)
                        tegra_vi->tpg_opened = false;
                else
                        tegra_vi->sensor_opened = false;
+                       */
        }
 
        mutex_unlock(&chan->video_lock);
@@ -1574,6 +1592,7 @@ static void vi_channel_syncpt_free(struct tegra_channel *chan)
                nvhost_syncpt_put_ref_ext(chan->vi->ndev, chan->syncpt[i]);
 }
 
+static void tegra_channel_csi_init(struct tegra_mc_vi *vi, unsigned int index) __maybe_unused;
 static void tegra_channel_csi_init(struct tegra_mc_vi *vi, unsigned int index)
 {
        int numlanes = 0;
@@ -1609,12 +1628,12 @@ static int tegra_channel_init(struct tegra_mc_vi *vi, unsigned int index)
        struct tegra_channel *chan = &vi->chans[index];
 
        /* VI/CSI is in bypass mode, then channel has to be in bypass */
-       if (vi->vi->bypass)
-               chan->bypass = true;
+       //if (vi->vi->bypass)
+       chan->bypass = true;
 
        chan->vi = vi;
-       chan->fops = vi->vi->data->channel_fops;
-       tegra_channel_csi_init(vi, index);
+       //chan->fops = vi->vi->data->channel_fops;
+       //tegra_channel_csi_init(vi, index);
 
        chan->width_align = TEGRA_WIDTH_ALIGNMENT;
        chan->stride_align = TEGRA_STRIDE_ALIGNMENT;
index b787fe049252ee0cbc1487b42dd443af5e7fa8be..4d1d25539d07e762f9a3acc0650933544dca530b 100644 (file)
@@ -170,7 +170,6 @@ int tegra_vi_v4l2_init(struct tegra_mc_vi *vi)
        int ret;
 
        vi_tpg_fmts_bitmap_init(vi);
-
        /*
         * TPG mode need to reuse the real media_device struct of tegra_vi,
         * so bypass the media_device_register() here.
@@ -292,8 +291,9 @@ int tegra_vi_media_controller_init(struct tegra_mc_vi *mc_vi,
        set_vi_register_base(mc_vi, pdata->aperture[0]);
 
        err = vi_get_clks(mc_vi, pdev);
-       if (err)
-               return err;
+       if (err) {
+                dev_err(&pdev->dev, "Failed to init vi clks\n");
+       }
 
        if (mc_vi->pg_mode) {
                mc_vi->chans = devm_kzalloc(&pdev->dev,
index e270fa4a10186aae5a40a25a4306420ed16a21e6..1c8f6abf838cc83d8087fa88025679a753a676f8 100644 (file)
@@ -62,12 +62,12 @@ void tegra_csi_pad_control(struct tegra_csi_device *csi,
        if (enable) {
                for (i = 0; csi_port_is_valid(port_num[i]); i++) {
                        port = port_num[i];
-                       camera_common_dpd_disable(&csi->s_data[port]);
+                       //camera_common_dpd_disable(&csi->s_data[port]);
                }
        } else {
                for (i = 0; csi_port_is_valid(port_num[i]); i++) {
                        port = port_num[i];
-                       camera_common_dpd_enable(&csi->s_data[port]);
+                      // camera_common_dpd_enable(&csi->s_data[port]);
                }
        }
 }
@@ -87,13 +87,13 @@ int tegra_csi_channel_power(struct tegra_csi_device *csi,
                                csi->cil[cil_num], csi->clk_freq);
                        if (err)
                                dev_err(csi->dev, "cil clk start error\n");
-                       camera_common_dpd_disable(&csi->s_data[port]);
+                       //camera_common_dpd_disable(&csi->s_data[port]);
                }
        } else {
                for (i = 0; csi_port_is_valid(port_num[i]); i++) {
                        port = port_num[i];
                        cil_num = port >> 1;
-                       camera_common_dpd_enable(&csi->s_data[port]);
+                       //camera_common_dpd_enable(&csi->s_data[port]);
                        clk_disable_unprepare(csi->cil[cil_num]);
                }
        }
@@ -159,6 +159,8 @@ void tegra_csi_tpg_start_streaming(struct tegra_csi_device *csi,
 void tegra_csi_start_streaming(struct tegra_csi_device *csi,
                                enum tegra_csi_port_num port_num)
 {
+       if (!csi->fops)
+               return;
        csi->fops->soc_start_streaming(csi, port_num);
 }
 EXPORT_SYMBOL(tegra_csi_start_streaming);
@@ -166,12 +168,16 @@ EXPORT_SYMBOL(tegra_csi_start_streaming);
 int tegra_csi_error(struct tegra_csi_device *csi,
                        enum tegra_csi_port_num port_num)
 {
+       if (!csi->fops)
+               return 0;
        return csi->fops->soc_error(csi, port_num);
 }
 
 void tegra_csi_status(struct tegra_csi_device *csi,
                        enum tegra_csi_port_num port_num)
 {
+       if (!csi->fops)
+               return;
        csi->fops->soc_status(csi, port_num);
 }
 EXPORT_SYMBOL(tegra_csi_status);
@@ -179,12 +185,16 @@ EXPORT_SYMBOL(tegra_csi_status);
 void tegra_csi_error_recover(struct tegra_csi_device *csi,
                                enum tegra_csi_port_num port_num)
 {
+       if (!csi->fops)
+               return;
        csi->fops->soc_error_recover(csi, port_num);
 }
 
 void tegra_csi_stop_streaming(struct tegra_csi_device *csi,
                                enum tegra_csi_port_num port_num)
 {
+       if (!csi->fops)
+               return;
        csi->fops->soc_stop_streaming(csi, port_num);
 }
 EXPORT_SYMBOL(tegra_csi_stop_streaming);
@@ -195,6 +205,8 @@ static int tegra_csi_s_stream(struct v4l2_subdev *subdev, int enable)
        struct tegra_channel *chan;
        int index;
 
+       return 0;
+
        if (csi->pg_mode)
                return 0;
 
@@ -360,6 +372,9 @@ static int tegra_csi_g_input_status(struct v4l2_subdev *sd, u32 *status)
  * V4L2 Subdevice Pad Operations
  */
 
+static int tegra_csi_get_format(struct v4l2_subdev *subdev,
+                          struct v4l2_subdev_pad_config *cfg,
+                          struct v4l2_subdev_format *fmt) __maybe_unused;
 static int tegra_csi_get_format(struct v4l2_subdev *subdev,
                           struct v4l2_subdev_pad_config *cfg,
                           struct v4l2_subdev_format *fmt)
@@ -376,6 +391,9 @@ static int tegra_csi_get_format(struct v4l2_subdev *subdev,
        return 0;
 }
 
+static int tegra_csi_set_format(struct v4l2_subdev *subdev,
+                          struct v4l2_subdev_pad_config *cfg,
+                          struct v4l2_subdev_format *fmt) __maybe_unused;
 static int tegra_csi_set_format(struct v4l2_subdev *subdev,
                           struct v4l2_subdev_pad_config *cfg,
                           struct v4l2_subdev_format *fmt)
@@ -407,8 +425,8 @@ static struct v4l2_subdev_video_ops tegra_csi_video_ops = {
 };
 
 static struct v4l2_subdev_pad_ops tegra_csi_pad_ops = {
-       .get_fmt        = tegra_csi_get_format,
-       .set_fmt        = tegra_csi_set_format,
+       //.get_fmt      = tegra_csi_get_format,
+       //.set_fmt      = tegra_csi_set_format,
        .enum_frame_size = tegra_csi_enum_framesizes,
        .enum_frame_interval = tegra_csi_enum_frameintervals,
 };
@@ -532,8 +550,9 @@ int tegra_csi_media_controller_init(struct tegra_csi_device *csi,
                return ret;
 
        ret = tegra_csi_init(csi, pdev);
-       if (ret < 0)
-               return ret;
+       if (ret < 0) {
+               dev_err(&pdev->dev, "Failed to init csi property,clks\n");
+       }
 
        /* Initialize V4L2 subdevice and media entity */
        subdev = &csi->subdev;