video: tegra: add IOCTL for querying modes
Erik Gilling [Tue, 26 Oct 2010 21:25:48 +0000 (14:25 -0700)]
Change-Id: Ic312271b96a8bb8d8b2696448d3ff7fd73a7a851
Signed-off-by: Erik Gilling <konkers@android.com>

drivers/video/tegra/fb.c
include/video/tegrafb.h

index ef4e4c3..a104595 100644 (file)
@@ -499,6 +499,9 @@ static int tegra_fb_ioctl(struct fb_info *info, unsigned int cmd, unsigned long
 {
        struct tegra_fb_info *tegra_fb = info->par;
        struct tegra_fb_flip_args flip_args;
+       struct tegra_fb_modedb modedb;
+       struct fb_modelist *modelist;
+       int i;
        int fd;
        int ret;
 
@@ -520,6 +523,29 @@ static int tegra_fb_ioctl(struct fb_info *info, unsigned int cmd, unsigned long
 
                return ret;
 
+       case FBIO_TEGRA_GET_MODEDB:
+               if (copy_from_user(&modedb, (void __user *)arg, sizeof(modedb)))
+                       return -EFAULT;
+
+               i = 0;
+               list_for_each_entry(modelist, &info->modelist, list) {
+                       struct fb_var_screeninfo var;
+
+                       if (i >= modedb.modedb_len)
+                               break;
+                       fb_videomode_to_var(&var, &modelist->mode);
+
+                       if (copy_to_user((void __user *)&modedb.modedb[i],
+                                        &var, sizeof(var)))
+                               return -EFAULT;
+                       i++;
+               }
+               modedb.modedb_len = i;
+
+               if (copy_to_user((void __user *)arg, &modedb, sizeof(modedb)))
+                       return -EFAULT;
+               break;
+
        default:
                return -ENOTTY;
        }
index 3d7a5a9..79578c3 100644 (file)
@@ -18,6 +18,7 @@
 #ifndef _LINUX_TEGRAFB_H_
 #define _LINUX_TEGRAFB_H_
 
+#include <linux/fb.h>
 #include <linux/types.h>
 #include <asm/ioctl.h>
 
@@ -77,7 +78,13 @@ struct tegra_fb_flip_args {
        __u32 post_syncpt_val;
 };
 
+struct tegra_fb_modedb {
+       struct fb_var_screeninfo *modedb;
+       __u32 modedb_len;
+};
+
 #define FBIO_TEGRA_SET_NVMAP_FD        _IOW('F', 0x40, __u32)
 #define FBIO_TEGRA_FLIP                _IOW('F', 0x41, struct tegra_fb_flip_args)
+#define FBIO_TEGRA_GET_MODEDB  _IOWR('F', 0x42, struct tegra_fb_modedb)
 
 #endif