gpu: pvr: pdumpfs: make frame_count_max configurable
authorLuc Verhaegen <libv@codethink.co.uk>
Fri, 11 Mar 2011 14:02:49 +0000 (15:02 +0100)
committerGrazvydas Ignotas <notasas@gmail.com>
Sun, 20 May 2012 18:43:04 +0000 (21:43 +0300)
Both through a Kconfig option and through debugfs.

Signed-off-by: Luc Verhaegen <libv@codethink.co.uk>
Signed-off-by: Imre Deak <imre.deak@nokia.com>
pvr/Kconfig
pvr/pvr_pdumpfs.c

index bcbc8a4..0da11a0 100644 (file)
@@ -56,6 +56,15 @@ config PVR_PDUMP_MODE_FULL
 
 endchoice
 
+config PVR_PDUMP_INITIAL_MAX_FRAME_COUNT
+       int "Pdump max frame count"
+       range 1 1024
+       default 16
+       depends on PVR_DEBUG_PDUMP
+       help
+           This value sets how many frames will be retained at any time; the oldest
+           frames will be removed first. This value can be set from 1 to 1024.
+
 config PVR_EDM_DEBUG
        depends on PVR
        bool "Enable EDM trace"
index b642ac1..e16e4f7 100644 (file)
@@ -50,7 +50,7 @@ struct pdumpfs_frame {
        u32 number;
 };
 
-static u32 frame_count_max = 16;
+static u32 frame_count_max = CONFIG_PVR_PDUMP_INITIAL_MAX_FRAME_COUNT;
 static u32 frame_count;
 
 static struct pdumpfs_frame *frame_stream;
@@ -327,6 +327,72 @@ static const struct file_operations pdumpfs_modes_possible_fops = {
        .read = pdumpfs_modes_possible_read,
 };
 
+static ssize_t
+pdumpfs_frame_count_max_read(struct file *filp, char __user *buf, size_t size,
+                            loff_t *f_pos)
+{
+       char tmp[16];
+
+       tmp[0] = 0;
+
+       mutex_lock(pdumpfs_mutex);
+       snprintf(tmp, sizeof(tmp), "%d", frame_count_max);
+       mutex_unlock(pdumpfs_mutex);
+
+       if (strlen(tmp) < *f_pos)
+               return 0;
+
+       if ((strlen(tmp) + 1) < (*f_pos + size))
+               size = strlen(tmp) + 1 - *f_pos;
+
+       if (copy_to_user(buf, tmp + *f_pos, size))
+               return -EFAULT;
+
+       *f_pos += size;
+       return size;
+}
+
+static ssize_t
+pdumpfs_frame_count_max_write(struct file *filp, const char __user *buf,
+                             size_t size, loff_t *f_pos)
+{
+       static char tmp[16];
+       unsigned long result = 0;
+
+       if (*f_pos > sizeof(tmp))
+               return -EINVAL;
+
+       if (size > (sizeof(tmp) - *f_pos))
+               size = sizeof(tmp) - *f_pos;
+
+       if (copy_from_user(tmp + *f_pos, buf, size))
+               return -EFAULT;
+
+       tmp[size] = 0;
+
+       mutex_lock(pdumpfs_mutex);
+
+       if (!strict_strtoul(tmp, 0, &result)) {
+               if (result > 1024)
+                       result = 1024;
+               if (!result)
+                       result = 1;
+               frame_count_max = result;
+       }
+
+       mutex_unlock(pdumpfs_mutex);
+
+       *f_pos += size;
+       return size;
+}
+
+static const struct file_operations pdumpfs_frame_count_max_fops = {
+       .owner = THIS_MODULE,
+       .llseek = no_llseek,
+       .read = pdumpfs_frame_count_max_read,
+       .write = pdumpfs_frame_count_max_write,
+};
+
 static struct dentry *pdumpfs_dir;
 
 static void
@@ -361,6 +427,9 @@ pdumpfs_fs_init(void)
        pdumpfs_file_create("modes_possible", S_IRUSR,
                            &pdumpfs_modes_possible_fops);
 
+       pdumpfs_file_create("frame_count_max", S_IRUSR | S_IWUSR,
+                           &pdumpfs_frame_count_max_fops);
+
        return 0;
 }