Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit e31235ba authored by LuK1337's avatar LuK1337 Committed by MajorP93
Browse files

display: oplus: Add fp_state sysfs

This lets us to poll it in userspace.

Change-Id: I999d165b3b872475d793a60f5fac5e5d97355e11
parent e2fb3e89
Loading
Loading
Loading
Loading
+13 −6
Original line number Diff line number Diff line
@@ -56,7 +56,7 @@ static struct fp_data *fp_data_ptr = NULL;
char g_engineermode_menu_config[ENGINEER_MENU_SELECT_MAXLENTH] = ENGINEER_MENU_DEFAULT;

static DEFINE_MUTEX(opticalfp_handler_lock);
static opticalfp_handler g_opticalfp_irq_handler = NULL;
static opticalfp_handler g_opticalfp_irq_handlers[5 /* lazy */] = {0};


static int get_manufacture_id_value(struct fp_data *fp_data)
@@ -249,9 +249,15 @@ static struct file_operations fp_id_node_ctrl = {
};

void opticalfp_irq_handler_register(opticalfp_handler handler) {
    int i;
    if (handler) {
        mutex_lock(&opticalfp_handler_lock);
        g_opticalfp_irq_handler = handler;
        for (i = 0; i < ARRAY_SIZE(g_opticalfp_irq_handlers); i++) {
            if (!g_opticalfp_irq_handlers[i]) {
                g_opticalfp_irq_handlers[i] = handler;
                break;
            }
        }
        mutex_unlock(&opticalfp_handler_lock);
    } else {
        pr_err("%s handler is NULL", __func__);
@@ -259,11 +265,12 @@ void opticalfp_irq_handler_register(opticalfp_handler handler) {
}

int opticalfp_irq_handler(struct fp_underscreen_info* tp_info) {
    if (g_opticalfp_irq_handler) {
        return g_opticalfp_irq_handler(tp_info);
    } else {
        return FP_UNKNOWN;
    int i, ret = FP_UNKNOWN;
    for (i = 0; i < ARRAY_SIZE(g_opticalfp_irq_handlers); i++) {
        if (g_opticalfp_irq_handlers[i])
            ret = g_opticalfp_irq_handlers[i](tp_info);
    }
    return ret;
}
EXPORT_SYMBOL(opticalfp_irq_handler);

+27 −0
Original line number Diff line number Diff line
@@ -39,6 +39,8 @@
#include "oplus_adfr.h"
#endif

#include "../../../drivers/input/oplus_fp_drivers/include/oplus_fp_common.h"

extern int hbm_mode;
extern int spr_mode;
extern int lcd_closebl_flag;
@@ -102,6 +104,8 @@ char dimming_gamma_60hz[30] = {0};
char dimming_gamma_120hz[15] = {0};
/* #endif */

struct fp_underscreen_info fp_state = {0};

#define PANEL_CMD_MIN_TX_COUNT 2

extern int dsi_display_read_panel_reg(struct dsi_display *display, u8 cmd, void *data, size_t len);
@@ -3572,6 +3576,12 @@ static ssize_t oplus_display_get_mipi_clk_rate_hz(struct device *dev,
	return sprintf(buf, "%llu\n", clk_rate_hz);
}

static ssize_t oplus_display_get_fp_state(struct device *obj,
	struct device_attribute *attr, char *buf)
{
	return sprintf(buf, "%d,%d,%d\n", fp_state.x, fp_state.y, fp_state.touch_state);
}

static struct kobject *oplus_display_kobj;

static DEVICE_ATTR(hbm, S_IRUGO|S_IWUSR, oplus_display_get_hbm, oplus_display_set_hbm);
@@ -3612,6 +3622,7 @@ static DEVICE_ATTR(mipi_clk_rate_hz, S_IRUGO|S_IWUSR, oplus_display_get_mipi_clk
static DEVICE_ATTR(aod_area, S_IRUGO|S_IWUSR, oplus_display_get_aod_area, oplus_display_set_aod_area);
static DEVICE_ATTR(video, S_IRUGO|S_IWUSR, oplus_display_get_video, oplus_display_set_video);
#endif /* OPLUS_FEATURE_AOD_RAMLESS */
static DEVICE_ATTR(fp_state, S_IRUGO, oplus_display_get_fp_state, NULL);

#ifdef OPLUS_FEATURE_ADFR
static DEVICE_ATTR(adfr_debug, S_IRUGO|S_IWUSR, oplus_adfr_get_debug, oplus_adfr_set_debug);
@@ -3675,6 +3686,10 @@ static struct attribute *oplus_display_attrs[] = {
/*#ifdef OPLUS_BUG_STABILITY*/
	&dev_attr_dsi_cmd_log_switch.attr,
/*#endif*/

	/* fp type config */
	&dev_attr_fp_state.attr,

	NULL,	/* need to NULL terminate the list of attributes */
};

@@ -3696,6 +3711,14 @@ int oplus_display_get_resolution(unsigned int *xres, unsigned int *yres)
}
EXPORT_SYMBOL(oplus_display_get_resolution);

static int oplus_opticalfp_irq_handler(struct fp_underscreen_info *tp_info) {
	fp_state.x = tp_info->x;
	fp_state.y = tp_info->y;
	fp_state.touch_state = tp_info->touch_state;
	sysfs_notify(kernel_kobj, "oplus_display", dev_attr_fp_state.attr.name);
	return IRQ_HANDLED;
}

static int __init oplus_display_private_api_init(void)
{
	struct dsi_display *display = get_main_display();
@@ -3720,7 +3743,11 @@ static int __init oplus_display_private_api_init(void)
	if(oplus_ffl_thread_init())
		pr_err("fail to init oplus_ffl_thread\n");

	opticalfp_irq_handler_register(oplus_opticalfp_irq_handler);

	if (retval) {
		goto error_remove_sysfs_group;
	}

	return 0;