+
+config EXYNOS_HDR_TUNABLE_TONEMAPPING
+ bool "HDR Tuneable debugfs nodes for Tone mapping"
+ ---help---
+ Creates hdr/tm_x and hdr/tm_y nodes under debugfs for overriding the
+ tone mapping LUT coefficients configured in G2D and DPU with the
+ values stored in the nodes. Configuring 33 integer values to both
+ nodes immediately replaces the tone mapping LUT coefficients used by
+ G2D and DPU. Writing 0 to one of both nodes stops overriding.
+
+ This is just for display tunning purpose only for HDR videos.
+
menu "Exynos Graphic Devices"
source "drivers/gpu/exynos/g2d/Kconfig"
endmenu
--- /dev/null
+/*
+ * linux/drivers/gpu/exynos/hdr_tunables.c
+ *
+ * Copyright (C) 2017 Samsung Electronics Co., Ltd.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * version 2 as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * General Public License for more details.
+ */
+
+#include <linux/module.h>
+#include <linux/stat.h>
+
+#include <video/exynos_hdr_tunables.h>
+
+static unsigned int nr_tm_lut_x_values = NR_TM_LUT_VALUES;
+static unsigned int nr_tm_lut_y_values = NR_TM_LUT_VALUES;
+
+static uint tm_lut_x[NR_TM_LUT_VALUES];
+static uint tm_lut_y[NR_TM_LUT_VALUES];
+static uint tm_override_enable;
+
+int exynos_hdr_get_tm_lut_xy(u32 lut_x[], u32 lut_y[])
+{
+ int i;
+
+ if (!tm_override_enable)
+ return 0;
+
+ for (i = 0; i < nr_tm_lut_x_values; i++)
+ lut_x[i] = tm_lut_x[i] & 0x3FFF;
+ for (; i < NR_TM_LUT_VALUES; i++)
+ lut_x[i] = 0;
+
+ for (i = 0; i < nr_tm_lut_y_values; i++)
+ lut_y[i] = tm_lut_y[i] & 0xFFF;
+ for (; i < NR_TM_LUT_VALUES; i++)
+ lut_y[i] = 0;
+
+ return NR_TM_LUT_VALUES;
+}
+
+int exynos_hdr_get_tm_lut(u32 lut[])
+{
+ int i = 0;
+
+ if (!tm_override_enable)
+ return 0;
+
+ for (i = 0; i < nr_tm_lut_x_values; i++)
+ lut[i] = tm_lut_x[i] & 0x3FFF;
+ for (; i < NR_TM_LUT_VALUES; i++)
+ lut[i] = 0;
+
+ for (i = 0; i < nr_tm_lut_y_values; i++)
+ lut[i] |= (tm_lut_y[i] & 0xFFF) << 16;
+
+ return NR_TM_LUT_VALUES;
+}
+
+module_param_array(tm_lut_x, uint, &nr_tm_lut_x_values, 0644);
+module_param_array(tm_lut_y, uint, &nr_tm_lut_y_values, 0644);
+module_param(tm_override_enable, uint, 0644);
--- /dev/null
+#ifndef _LINUX_EXYNOS_HDR_TUNABLES_H
+#define _LINUX_EXYNOS_HDR_TUNABLES_H
+
+#include <linux/types.h>
+
+#define NR_TM_LUT_VALUES 33
+
+#ifdef CONFIG_EXYNOS_HDR_TUNABLE_TONEMAPPING
+int exynos_hdr_get_tm_lut_xy(u32 lut_x[], u32 lut_y[]);
+int exynos_hdr_get_tm_lut(u32 lut[]);
+#else
+static inline int exynos_hdr_get_tm_lut_xy(u32 lut_x[], u32 lut_y[])
+{
+ return 0;
+}
+static inline int exynos_hdr_get_tm_lut(u32 lut[])
+{
+ return 0;
+}
+#endif
+
+#endif /* _LINUX_EXYNOS_HDR_TUNABLES_H */