video: tegra: dc_ext: Add head status ioctl
Robert Morell [Wed, 25 May 2011 02:27:57 +0000 (19:27 -0700)]
This change adds a new tegra_dc_ext ioctl to allow userspace to query
whether a head is currently enabled or not.  This is necessary for the X
server to be able to restore the outputs that were enabled before it was
started.

bug 818525

Original-Change-Id: I6d209894081312621f623a722cdd3fcb53553c61
Signed-off-by: Robert Morell <rmorell@nvidia.com>
Reviewed-by: Aaron Plattner <aplattner@nvidia.com>
Reviewed-by: Olof Johansson <olofj@chromium.org>
Reviewed-on: http://git-master/r/40530
Reviewed-by: Varun Colbert <vcolbert@nvidia.com>
Tested-by: Varun Colbert <vcolbert@nvidia.com>

Rebase-Id: Re42eae066099587529fbcc677c06ddefef18d36d

drivers/video/tegra/dc/ext/dev.c
include/video/tegra_dc_ext.h

index eba7063..6e11107 100644 (file)
@@ -483,6 +483,19 @@ static u32 tegra_dc_ext_get_vblank_syncpt(struct tegra_dc_ext_user *user)
        return dc->vblank_syncpt;
 }
 
+static int tegra_dc_ext_get_status(struct tegra_dc_ext_user *user,
+                                  struct tegra_dc_ext_status *status)
+{
+       struct tegra_dc *dc = user->ext->dc;
+
+       memset(status, 0, sizeof(*status));
+
+       if (dc->enabled)
+               status->flags |= TEGRA_DC_EXT_FLAGS_ENABLED;
+
+       return 0;
+}
+
 static long tegra_dc_ioctl(struct file *filp, unsigned int cmd,
                           unsigned long arg)
 {
@@ -557,6 +570,19 @@ static long tegra_dc_ioctl(struct file *filp, unsigned int cmd,
                return 0;
        }
 
+       case TEGRA_DC_EXT_GET_STATUS:
+       {
+               struct tegra_dc_ext_status args;
+               int ret;
+
+               ret = tegra_dc_ext_get_status(user, &args);
+
+               if (copy_to_user(user_arg, &args, sizeof(args)))
+                       return -EFAULT;
+
+               return ret;
+       }
+
        default:
                return -EINVAL;
        }
index 5ac7899..1181848 100644 (file)
@@ -161,6 +161,14 @@ struct tegra_dc_ext_csc {
        __u16 kvb;      /* s.2.8 */
 };
 
+
+#define TEGRA_DC_EXT_FLAGS_ENABLED     1
+struct tegra_dc_ext_status {
+       __u32 flags;
+       /* Leave some wiggle room for future expansion */
+       __u32 pad[3];
+};
+
 #define TEGRA_DC_EXT_SET_NVMAP_FD \
        _IOW('D', 0x00, __s32)
 
@@ -184,6 +192,9 @@ struct tegra_dc_ext_csc {
 #define TEGRA_DC_EXT_SET_CSC \
        _IOW('D', 0x08, struct tegra_dc_ext_csc)
 
+#define TEGRA_DC_EXT_GET_STATUS \
+       _IOR('D', 0x09, struct tegra_dc_ext_status)
+
 /*
  * Returns the auto-incrementing vblank syncpoint for the head associated with
  * this device node