video: tegra: use public APIs exposed by host1x driver
Mayuresh Kulkarni [Mon, 18 Jun 2012 07:05:40 +0000 (12:05 +0530)]
Bug 961009

Change-Id: Ifdcc7bc8a40d270e70a63329f46caff541bf01e2
Signed-off-by: Mayuresh Kulkarni <mkulkarni@nvidia.com>
Reviewed-on: http://git-master/r/109461
Reviewed-by: Rohan Somvanshi <rsomvanshi@nvidia.com>
Tested-by: Rohan Somvanshi <rsomvanshi@nvidia.com>

drivers/media/video/tegra/nvavp/nvavp_dev.c
drivers/video/tegra/dc/bandwidth.c
drivers/video/tegra/dc/dc.c
drivers/video/tegra/dc/dc_priv.h
drivers/video/tegra/dc/dsi.c

index cfe0332..e0a3d89 100644 (file)
 #include <mach/legacy_irq.h>
 #include <linux/nvmap.h>
 
-#include "../../../../video/tegra/host/host1x/host1x_syncpt.h"
-#include "../../../../video/tegra/host/dev.h"
-#include "../../../../video/tegra/host/nvhost_acm.h"
-
 #if defined(CONFIG_TEGRA_AVP_KERNEL_ON_MMU)
 #include "../avp/headavp.h"
 #endif
@@ -135,7 +131,6 @@ struct nvavp_info {
 
        struct nvavp_channel            channel_info[NVAVP_NUM_CHANNELS];
 
-       struct nvhost_syncpt            *nvhost_syncpt;
        u32                             syncpt_id;
        u32                             syncpt_value;
 
@@ -243,7 +238,7 @@ static struct clk *nvavp_clk_get(struct nvavp_info *nvavp, int id)
 static void nvavp_clks_enable(struct nvavp_info *nvavp)
 {
        if (nvavp->clk_enabled++ == 0) {
-               nvhost_module_busy(nvhost_get_host(nvavp->nvhost_dev)->dev);
+               nvhost_module_busy_ext(nvhost_get_parent(nvavp->nvhost_dev));
                clk_enable(nvavp->bsev_clk);
                clk_enable(nvavp->vde_clk);
                clk_set_rate(nvavp->emc_clk, nvavp->emc_clk_rate);
@@ -262,7 +257,7 @@ static void nvavp_clks_disable(struct nvavp_info *nvavp)
                clk_disable(nvavp->vde_clk);
                clk_set_rate(nvavp->emc_clk, 0);
                clk_set_rate(nvavp->sclk, 0);
-               nvhost_module_idle(nvhost_get_host(nvavp->nvhost_dev)->dev);
+               nvhost_module_idle_ext(nvhost_get_parent(nvavp->nvhost_dev));
                dev_dbg(&nvavp->nvhost_dev->dev, "%s: resetting emc_clk "
                                "and sclk\n", __func__);
        }
@@ -518,9 +513,8 @@ static int nvavp_pushbuffer_init(struct nvavp_info *nvavp)
                nvavp_set_channel_control_area(nvavp, channel_id);
                if (IS_VIDEO_CHANNEL_ID(channel_id)) {
                        nvavp->syncpt_id = NVSYNCPT_AVP_0;
-                       nvavp->syncpt_value = nvhost_syncpt_read(
-                                                       nvavp->nvhost_syncpt,
-                                                       nvavp->syncpt_id);
+                       nvavp->syncpt_value = nvhost_syncpt_read_ext(
+                               nvavp->nvhost_dev, nvavp->syncpt_id);
                }
 
        }
@@ -1412,7 +1406,6 @@ static int tegra_nvavp_probe(struct nvhost_device *ndev,
                return -EINVAL;
        }
 
-
        nvavp = kzalloc(sizeof(struct nvavp_info), GFP_KERNEL);
        if (!nvavp) {
                dev_err(&ndev->dev, "cannot allocate avp_info\n");
@@ -1421,13 +1414,6 @@ static int tegra_nvavp_probe(struct nvhost_device *ndev,
 
        memset(nvavp, 0, sizeof(*nvavp));
 
-       nvavp->nvhost_syncpt = &nvhost_get_host(ndev)->syncpt;
-       if (!nvavp->nvhost_syncpt) {
-               dev_err(&ndev->dev, "cannot get syncpt handle\n");
-               ret = -ENOENT;
-               goto err_get_syncpt;
-       }
-
        nvavp->nvmap = nvmap_create_client(nvmap_dev, "nvavp_drv");
        if (IS_ERR_OR_NULL(nvavp->nvmap)) {
                dev_err(&ndev->dev, "cannot create nvmap client\n");
index 5d0e5ee..785ec7c 100644 (file)
@@ -16,6 +16,7 @@
 
 #include <linux/module.h>
 #include <linux/kernel.h>
+#include <linux/clk.h>
 
 #include <mach/clk.h>
 #include <mach/dc.h>
index 834637d..39470e1 100644 (file)
 #include <linux/seq_file.h>
 #include <linux/backlight.h>
 #include <linux/gpio.h>
+#include <linux/nvhost.h>
 #include <video/tegrafb.h>
 #include <drm/drm_fixed.h>
 #ifdef CONFIG_SWITCH
 #include <linux/switch.h>
 #endif
 
-
 #include <mach/clk.h>
 #include <mach/dc.h>
 #include <mach/fb.h>
@@ -51,8 +51,6 @@
 #include "dc_reg.h"
 #include "dc_config.h"
 #include "dc_priv.h"
-#include "host1x/host1x.h"
-#include "host1x/host1x_syncpt.h"
 #include "nvsd.h"
 
 #define TEGRA_CRC_LATCHED_DELAY                34
@@ -1109,7 +1107,7 @@ u32 tegra_dc_incr_syncpt_max(struct tegra_dc *dc, int i)
        u32 max;
 
        mutex_lock(&dc->lock);
-       max = nvhost_syncpt_incr_max(&nvhost_get_host(dc->ndev)->syncpt,
+       max = nvhost_syncpt_incr_max_ext(dc->ndev,
                dc->syncpt[i].id, ((dc->enabled) ? 1 : 0));
        dc->syncpt[i].max = max;
        mutex_unlock(&dc->lock);
@@ -1123,9 +1121,7 @@ void tegra_dc_incr_syncpt_min(struct tegra_dc *dc, int i, u32 val)
        if ( dc->enabled )
                while (dc->syncpt[i].min < val) {
                        dc->syncpt[i].min++;
-                       nvhost_syncpt_cpu_incr(
-                                       &nvhost_get_host(dc->ndev)->syncpt,
-                                       dc->syncpt[i].id);
+                       nvhost_syncpt_cpu_incr_ext(dc->ndev, dc->syncpt[i].id);
                }
        mutex_unlock(&dc->lock);
 }
@@ -2076,7 +2072,7 @@ static irqreturn_t tegra_dc_irq(int irq, void *ptr)
        unsigned long underflow_mask;
        u32 val;
 
-       if (!nvhost_module_powered(nvhost_get_host(dc->ndev)->dev)) {
+       if (!nvhost_module_powered_ext(nvhost_get_parent(dc->ndev))) {
                WARN(1, "IRQ when DC not powered!\n");
                tegra_dc_io_start(dc);
                status = tegra_dc_readl(dc, DC_CMD_INT_STATUS);
@@ -2286,8 +2282,7 @@ static int tegra_dc_init(struct tegra_dc *dc)
                dc->syncpt[i].id = syncpt;
 
                dc->syncpt[i].min = dc->syncpt[i].max =
-                       nvhost_syncpt_read(&nvhost_get_host(dc->ndev)->syncpt,
-                                       syncpt);
+                       nvhost_syncpt_read_ext(dc->ndev, syncpt);
        }
 
        print_mode(dc, &dc->mode, __func__);
@@ -2487,9 +2482,7 @@ static void _tegra_dc_controller_disable(struct tegra_dc *dc)
                        trace_printk("%s:syncpt flush id=%d\n", dc->ndev->name,
                                dc->syncpt[i].id);
                        dc->syncpt[i].min++;
-                       nvhost_syncpt_cpu_incr(
-                               &nvhost_get_host(dc->ndev)->syncpt,
-                               dc->syncpt[i].id);
+                       nvhost_syncpt_cpu_incr_ext(dc->ndev, dc->syncpt[i].id);
                }
        }
        trace_printk("%s:disabled\n", dc->ndev->name);
index ac3a5d3..19c8656 100644 (file)
 #include <linux/fb.h>
 #include <linux/completion.h>
 #include <linux/switch.h>
+#include <linux/nvhost.h>
 
 #include <mach/dc.h>
 
-#include "../host/nvhost_acm.h"
-
 #include <mach/tegra_dc_ext.h>
 #include <mach/clk.h>
 
@@ -150,12 +149,12 @@ struct tegra_dc {
 
 static inline void tegra_dc_io_start(struct tegra_dc *dc)
 {
-       nvhost_module_busy(to_nvhost_device(dc->ndev->dev.parent));
+       nvhost_module_busy_ext(nvhost_get_parent(dc->ndev));
 }
 
 static inline void tegra_dc_io_end(struct tegra_dc *dc)
 {
-       nvhost_module_idle(to_nvhost_device(dc->ndev->dev.parent));
+       nvhost_module_idle_ext(nvhost_get_parent(dc->ndev));
 }
 
 static inline unsigned long tegra_dc_readl(struct tegra_dc *dc,
@@ -163,7 +162,7 @@ static inline unsigned long tegra_dc_readl(struct tegra_dc *dc,
 {
        unsigned long ret;
 
-       BUG_ON(!nvhost_module_powered(to_nvhost_device(dc->ndev->dev.parent)));
+       BUG_ON(!nvhost_module_powered_ext(nvhost_get_parent(dc->ndev)));
        if (!tegra_is_clk_enabled(dc->clk))
                WARN(1, "DC is clock-gated.\n");
 
@@ -175,7 +174,7 @@ static inline unsigned long tegra_dc_readl(struct tegra_dc *dc,
 static inline void tegra_dc_writel(struct tegra_dc *dc, unsigned long val,
                                   unsigned long reg)
 {
-       BUG_ON(!nvhost_module_powered(to_nvhost_device(dc->ndev->dev.parent)));
+       BUG_ON(!nvhost_module_powered_ext(nvhost_get_parent(dc->ndev)));
        if (!tegra_is_clk_enabled(dc->clk))
                WARN(1, "DC is clock-gated.\n");
 
@@ -206,7 +205,7 @@ static inline void *tegra_dc_get_outdata(struct tegra_dc *dc)
 }
 
 static inline unsigned long tegra_dc_get_default_emc_clk_rate(
-                                                       struct tegra_dc *dc)
+       struct tegra_dc *dc)
 {
        return dc->pdata->emc_clk_rate ? dc->pdata->emc_clk_rate : ULONG_MAX;
 }
index 26301ab..ff80aac 100644 (file)
  *
  */
 
+#include <linux/kernel.h>
 #include <linux/clk.h>
 #include <linux/delay.h>
 #include <linux/err.h>
 #include <linux/fb.h>
 #include <linux/gpio.h>
 #include <linux/interrupt.h>
-#include <linux/kernel.h>
 #include <linux/slab.h>
 #include <linux/spinlock.h>
 #include <linux/workqueue.h>
 #include <linux/debugfs.h>
 #include <linux/seq_file.h>
+#include <linux/nvhost.h>
 
 #include <mach/clk.h>
 #include <mach/dc.h>
@@ -36,8 +37,6 @@
 
 #include "dc_reg.h"
 #include "dc_priv.h"
-#include "host1x/host1x.h"
-#include "host1x/host1x_syncpt.h"
 #include "dsi_regs.h"
 #include "dsi.h"
 
@@ -298,7 +297,7 @@ inline unsigned long tegra_dsi_readl(struct tegra_dc_dsi_data *dsi, u32 reg)
 {
        unsigned long ret;
 
-       BUG_ON(!nvhost_module_powered(nvhost_get_host(dsi->dc->ndev)->dev));
+       BUG_ON(!nvhost_module_powered_ext(nvhost_get_parent(dsi->dc->ndev)));
        ret = readl(dsi->base + reg * 4);
        trace_printk("readl %p=%#08lx\n", dsi->base + reg * 4, ret);
        return ret;
@@ -307,7 +306,7 @@ EXPORT_SYMBOL(tegra_dsi_readl);
 
 inline void tegra_dsi_writel(struct tegra_dc_dsi_data *dsi, u32 val, u32 reg)
 {
-       BUG_ON(!nvhost_module_powered(nvhost_get_host(dsi->dc->ndev)->dev));
+       BUG_ON(!nvhost_module_powered_ext(nvhost_get_parent(dsi->dc->ndev)));
        trace_printk("writel %p=%#08x\n", dsi->base + reg * 4, val);
        writel(val, dsi->base + reg * 4);
 }
@@ -441,17 +440,15 @@ static int tegra_dsi_syncpt(struct tegra_dc_dsi_data *dsi)
 
        ret = 0;
 
-       dsi->syncpt_val = nvhost_syncpt_read(
-                       &nvhost_get_host(dsi->dc->ndev)->syncpt,
-                       dsi->syncpt_id);
+       dsi->syncpt_val = nvhost_syncpt_read_ext(dsi->dc->ndev, dsi->syncpt_id);
 
        val = DSI_INCR_SYNCPT_COND(OP_DONE) |
                DSI_INCR_SYNCPT_INDX(dsi->syncpt_id);
        tegra_dsi_writel(dsi, val, DSI_INCR_SYNCPT);
 
        /* TODO: Use interrupt rather than polling */
-       ret = nvhost_syncpt_wait(&nvhost_get_host(dsi->dc->ndev)->syncpt,
-               dsi->syncpt_id, dsi->syncpt_val + 1);
+       ret = nvhost_syncpt_wait_timeout_ext(dsi->dc->ndev, dsi->syncpt_id,
+               dsi->syncpt_val + 1, MAX_SCHEDULE_TIMEOUT, NULL);
        if (ret < 0) {
                dev_err(&dsi->dc->ndev->dev, "DSI sync point failure\n");
                goto fail;
@@ -2277,9 +2274,7 @@ static int tegra_dsi_bta(struct tegra_dc_dsi_data *dsi)
        tegra_dsi_writel(dsi, val, DSI_HOST_DSI_CONTROL);
 
 #if DSI_USE_SYNC_POINTS
-       /* FIXME: Workaround for nvhost_syncpt_read */
-       dsi->syncpt_val = nvhost_syncpt_update_min(
-                       &nvhost_get_host(dsi->dc->ndev)->syncpt,
+       dsi->syncpt_val = nvhost_syncpt_read_ext(dsi->dc->ndev,
                        dsi->syncpt_id);
 
        val = DSI_INCR_SYNCPT_COND(OP_DONE) |
@@ -2287,8 +2282,8 @@ static int tegra_dsi_bta(struct tegra_dc_dsi_data *dsi)
        tegra_dsi_writel(dsi, val, DSI_INCR_SYNCPT);
 
        /* TODO: Use interrupt rather than polling */
-       err = nvhost_syncpt_wait(&nvhost_get_host(dsi->dc->ndev)->syncpt,
-               dsi->syncpt_id, dsi->syncpt_val + 1);
+       err = nvhost_syncpt_wait_timeout_ext(dsi->dc->ndev, dsi->syncpt_id,
+               dsi->syncpt_val + 1, MAX_SCHEDULE_TIMEOUT, NULL);
        if (err < 0)
                dev_err(&dsi->dc->ndev->dev,
                        "DSI sync point failure\n");