media: nvmap: Few tweaks in nvmap
Vikram Fugro [Wed, 30 Oct 2013 08:10:20 +0000 (13:10 +0530)]
The tweaks are only specific to r16-r2 branch
and will not go into mainline.
 - Pass nvmap memory handle to the user through
   the mmap'd buffer allocated by videobuf2 client.
 - Allow the "user" nvmap client to access the
   nvmap memory handle of "videobuf2-dma-nvmap" client.

Re-arranging the copyright message in nvmap_dev.c
for Automatic validation to pass.

Bug 1369083

Change-Id: Ia27d172253860e79557911c2e848bc9084d662d4
Signed-off-by: Vikram Fugro <vfugro@nvidia.com>
Reviewed-on: http://git-master/r/309494
Reviewed-by: Automatic_Commit_Validation_User
Reviewed-by: Krishna Reddy <vdumpa@nvidia.com>
Reviewed-by: Kaustubh Purandare <kpurandare@nvidia.com>
Reviewed-by: Winnie Hsu <whsu@nvidia.com>
Reviewed-by: Matthew Pedro <mapedro@nvidia.com>

drivers/media/video/videobuf2-dma-nvmap.c
drivers/video/tegra/nvmap/nvmap_dev.c

index 5ab3c62..4ba8fed 100644 (file)
@@ -82,6 +82,8 @@ static void *vb2_dma_nvmap_alloc(void *alloc_ctx, unsigned long size)
        buf->handler.put = vb2_dma_nvmap_put;
        buf->handler.arg = buf;
 
+       *((unsigned long *)buf->vaddr) = (unsigned long)buf->nvmap_ref->handle;
+
        atomic_inc(&buf->refcount);
 
        return buf;
index 0c12348..3b0db14 100644 (file)
@@ -1,10 +1,10 @@
 /*
+ * Copyright (c) 2011-2013, NVIDIA CORPORATION. All rights reserved.
+ *
  * drivers/video/tegra/nvmap/nvmap_dev.c
  *
  * User-space interface to nvmap
  *
- * Copyright (c) 2011-2012, NVIDIA Corporation.
- *
  * 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
@@ -231,6 +231,14 @@ struct nvmap_handle *nvmap_get_handle_id(struct nvmap_client *client,
        struct nvmap_handle_ref *ref;
        struct nvmap_handle *h = NULL;
 
+       /* Allow the handle to be accessed by other (non-owner)
+       clients only if the owner is "videobuf2-dma-nvmap",
+       which is a V4L2 capture kernel module. This handle can
+       be accessed by the "user" client for rendering */
+       if (!strcmp(((struct nvmap_handle *)id)->owner->name,
+                               "videobuf2-dma-nvmap"))
+               client = ((struct nvmap_handle *)id)->owner;
+
        nvmap_ref_lock(client);
        ref = _nvmap_validate_id_locked(client, id);
        if (ref)