video: tegra: host: new syncpoint max interface
Michal Pecio [Wed, 29 Aug 2012 21:34:38 +0000 (14:34 -0700)]
Add the NVHOST_IOCTL_CTRL_SYNCPT_READ_MAX ioctl for reading max value
of a syncpoint.

Bug 1039058

Change-Id: I61c348c3007a4fb919fbe48993907d46f38c5fa8
Signed-off-by: Michal Pecio <mpecio@nvidia.com>
Reviewed-on: http://git-master/r/132387
Reviewed-by: Automatic_Commit_Validation_User
GVS: Gerrit_Virtual_Submit
Reviewed-by: Terje Bergstrom <tbergstrom@nvidia.com>

drivers/video/tegra/host/host1x/host1x.c
include/linux/nvhost_ioctl.h

index 31f0624..f6867d0 100644 (file)
@@ -237,6 +237,15 @@ static int nvhost_ioctl_ctrl_get_version(struct nvhost_ctrl_userctx *ctx,
        return 0;
 }
 
+static int nvhost_ioctl_ctrl_syncpt_read_max(struct nvhost_ctrl_userctx *ctx,
+       struct nvhost_ctrl_syncpt_read_args *args)
+{
+       if (args->id >= nvhost_syncpt_nb_pts(&ctx->dev->syncpt))
+               return -EINVAL;
+       args->value = nvhost_syncpt_read_max(&ctx->dev->syncpt, args->id);
+       return 0;
+}
+
 static long nvhost_ctrlctl(struct file *filp,
        unsigned int cmd, unsigned long arg)
 {
@@ -277,6 +286,9 @@ static long nvhost_ctrlctl(struct file *filp,
        case NVHOST_IOCTL_CTRL_GET_VERSION:
                err = nvhost_ioctl_ctrl_get_version(priv, (void *)buf);
                break;
+       case NVHOST_IOCTL_CTRL_SYNCPT_READ_MAX:
+               err = nvhost_ioctl_ctrl_syncpt_read_max(priv, (void *)buf);
+               break;
        default:
                err = -ENOTTY;
                break;
index 2fedfb9..85b7a12 100644 (file)
@@ -207,8 +207,11 @@ struct nvhost_ctrl_module_regrdwr_args {
 #define NVHOST_IOCTL_CTRL_GET_VERSION  \
        _IOR(NVHOST_IOCTL_MAGIC, 7, struct nvhost_get_param_args)
 
+#define NVHOST_IOCTL_CTRL_SYNCPT_READ_MAX      \
+       _IOWR(NVHOST_IOCTL_MAGIC, 8, struct nvhost_ctrl_syncpt_read_args)
+
 #define NVHOST_IOCTL_CTRL_LAST                 \
-       _IOC_NR(NVHOST_IOCTL_CTRL_GET_VERSION)
+       _IOC_NR(NVHOST_IOCTL_CTRL_SYNCPT_READ_MAX)
 #define NVHOST_IOCTL_CTRL_MAX_ARG_SIZE \
        sizeof(struct nvhost_ctrl_module_regrdwr_args)