From aea70da22466d1d0fc7949020b32310d584c77d1 Mon Sep 17 00:00:00 2001 From: Luc Verhaegen Date: Fri, 11 Mar 2011 15:02:49 +0100 Subject: [PATCH] gpu: pvr: pdumpfs: make frame_count_max configurable Both through a Kconfig option and through debugfs. Signed-off-by: Luc Verhaegen Signed-off-by: Imre Deak --- pvr/Kconfig | 9 ++++++ pvr/pvr_pdumpfs.c | 71 ++++++++++++++++++++++++++++++++++++++++++++++- 2 files changed, 79 insertions(+), 1 deletion(-) diff --git a/pvr/Kconfig b/pvr/Kconfig index bcbc8a4..0da11a0 100644 --- a/pvr/Kconfig +++ b/pvr/Kconfig @@ -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" diff --git a/pvr/pvr_pdumpfs.c b/pvr/pvr_pdumpfs.c index b642ac1..e16e4f7 100644 --- a/pvr/pvr_pdumpfs.c +++ b/pvr/pvr_pdumpfs.c @@ -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; } -- 2.39.5