summaryrefslogtreecommitdiff
path: root/drivers/video/tegra/dc/ext
diff options
context:
space:
mode:
authorRobert Morell <rmorell@nvidia.com>2011-02-22 17:15:06 -0800
committerDan Willemsen <dwillemsen@nvidia.com>2011-11-30 21:48:12 -0800
commit5197ed5e5f11b4f77bdcf9020a01bada5db45f1a (patch)
tree5c218005ce10d6483f4834c5fbf7fbce7f01abc2 /drivers/video/tegra/dc/ext
parentc1c9c8660b49eb0b67ae02a3e21e07fe7135232a (diff)
video: tegra: Move pin function to new util file
This will be used in forthcoming cursor support in addition to the existing overlay flipping support. bug 818525 Original-Change-Id: Ic27267deeaefad4ec803eb457a02b22c0d9a1373 Signed-off-by: Robert Morell <rmorell@nvidia.com> Reviewed-on: http://git-master/r/40517 Reviewed-by: Varun Colbert <vcolbert@nvidia.com> Tested-by: Varun Colbert <vcolbert@nvidia.com> Rebase-Id: Rc1e18fe5248f9dfd1f9ee23184cd2c102539ca61
Diffstat (limited to 'drivers/video/tegra/dc/ext')
-rw-r--r--drivers/video/tegra/dc/ext/Makefile1
-rw-r--r--drivers/video/tegra/dc/ext/dev.c52
-rw-r--r--drivers/video/tegra/dc/ext/tegra_dc_ext_priv.h4
-rw-r--r--drivers/video/tegra/dc/ext/util.c78
4 files changed, 86 insertions, 49 deletions
diff --git a/drivers/video/tegra/dc/ext/Makefile b/drivers/video/tegra/dc/ext/Makefile
index 44c52311b4e3..bd530c2f8164 100644
--- a/drivers/video/tegra/dc/ext/Makefile
+++ b/drivers/video/tegra/dc/ext/Makefile
@@ -1 +1,2 @@
obj-y += dev.o
+obj-y += util.o
diff --git a/drivers/video/tegra/dc/ext/dev.c b/drivers/video/tegra/dc/ext/dev.c
index b549f77222c8..2fa11d9da189 100644
--- a/drivers/video/tegra/dc/ext/dev.c
+++ b/drivers/video/tegra/dc/ext/dev.c
@@ -237,54 +237,6 @@ static void tegra_dc_ext_flip_worker(struct work_struct *work)
kfree(data);
}
-static int tegra_dc_ext_pin_window(struct tegra_dc_ext_user *user,
- struct tegra_dc_ext_flip_win *flip_win)
-{
- struct tegra_dc_ext *ext = user->ext;
- struct nvmap_handle_ref *win_dup;
- struct nvmap_handle *win_handle;
- u32 id = flip_win->attr.buff_id;
-
- if (!id) {
- flip_win->handle = NULL;
- flip_win->phys_addr = -1;
-
- return 0;
- }
-
- /*
- * Take a reference to the buffer using the user's nvmap context, to
- * make sure they have permissions to access it.
- */
- win_handle = nvmap_get_handle_id(user->nvmap, id);
- if (!win_handle)
- return -EACCES;
-
- /*
- * Duplicate the buffer's handle into the dc_ext driver's nvmap
- * context, to ensure that the handle won't be freed as long as it is
- * in use by display.
- */
- win_dup = nvmap_duplicate_handle_id(ext->nvmap, id);
-
- /* Release the reference we took in the user's context above */
- nvmap_handle_put(win_handle);
-
- if (IS_ERR(win_dup))
- return PTR_ERR(win_dup);
-
- flip_win->handle = win_dup;
-
- flip_win->phys_addr = nvmap_pin(ext->nvmap, win_dup);
- /* XXX this isn't correct for non-pointers... */
- if (IS_ERR((void *)flip_win->phys_addr)) {
- nvmap_free(ext->nvmap, win_dup);
- return PTR_ERR((void *)flip_win->phys_addr);
- }
-
- return 0;
-}
-
static int lock_windows_for_flip(struct tegra_dc_ext_user *user,
struct tegra_dc_ext_flip *args)
{
@@ -394,7 +346,9 @@ static int tegra_dc_ext_flip(struct tegra_dc_ext_user *user,
if (index < 0)
continue;
- ret = tegra_dc_ext_pin_window(user, flip_win);
+ ret = tegra_dc_ext_pin_window(user, flip_win->attr.buff_id,
+ &flip_win->handle,
+ &flip_win->phys_addr);
if (ret)
goto fail_pin;
}
diff --git a/drivers/video/tegra/dc/ext/tegra_dc_ext_priv.h b/drivers/video/tegra/dc/ext/tegra_dc_ext_priv.h
index b0a9bf65c6cd..d7d5e5506718 100644
--- a/drivers/video/tegra/dc/ext/tegra_dc_ext_priv.h
+++ b/drivers/video/tegra/dc/ext/tegra_dc_ext_priv.h
@@ -56,4 +56,8 @@ struct tegra_dc_ext {
struct tegra_dc_ext_win win[DC_N_WINDOWS];
};
+extern int tegra_dc_ext_pin_window(struct tegra_dc_ext_user *user, u32 id,
+ struct nvmap_handle_ref **handle,
+ dma_addr_t *phys_addr);
+
#endif /* __TEGRA_DC_EXT_PRIV_H */
diff --git a/drivers/video/tegra/dc/ext/util.c b/drivers/video/tegra/dc/ext/util.c
new file mode 100644
index 000000000000..747085579f15
--- /dev/null
+++ b/drivers/video/tegra/dc/ext/util.c
@@ -0,0 +1,78 @@
+/*
+ * drivers/video/tegra/dc/ext/util.c
+ *
+ * Copyright (C) 2011, NVIDIA Corporation
+ *
+ * Author: Robert Morell <rmorell@nvidia.com>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
+ * more details.
+ */
+
+#include <linux/err.h>
+#include <linux/types.h>
+
+#include <mach/dc.h>
+#include <mach/nvmap.h>
+
+/* ugh */
+#include "../../nvmap/nvmap.h"
+
+#include "tegra_dc_ext_priv.h"
+
+int tegra_dc_ext_pin_window(struct tegra_dc_ext_user *user, u32 id,
+ struct nvmap_handle_ref **handle,
+ dma_addr_t *phys_addr)
+{
+ struct tegra_dc_ext *ext = user->ext;
+ struct nvmap_handle_ref *win_dup;
+ struct nvmap_handle *win_handle;
+ dma_addr_t phys;
+
+ if (!id) {
+ *handle = NULL;
+ *phys_addr = -1;
+
+ return 0;
+ }
+
+ /*
+ * Take a reference to the buffer using the user's nvmap context, to
+ * make sure they have permissions to access it.
+ */
+ win_handle = nvmap_get_handle_id(user->nvmap, id);
+ if (!win_handle)
+ return -EACCES;
+
+ /*
+ * Duplicate the buffer's handle into the dc_ext driver's nvmap
+ * context, to ensure that the handle won't be freed as long as it is
+ * in use by display.
+ */
+ win_dup = nvmap_duplicate_handle_id(ext->nvmap, id);
+
+ /* Release the reference we took in the user's context above */
+ nvmap_handle_put(win_handle);
+
+ if (IS_ERR(win_dup))
+ return PTR_ERR(win_dup);
+
+ phys = nvmap_pin(ext->nvmap, win_dup);
+ /* XXX this isn't correct for non-pointers... */
+ if (IS_ERR((void *)phys)) {
+ nvmap_free(ext->nvmap, win_dup);
+ return PTR_ERR((void *)phys);
+ }
+
+ *phys_addr = phys;
+ *handle = win_dup;
+
+ return 0;
+}