2024-04-28 06:49:01 -07:00
|
|
|
/*
|
|
|
|
* Copyright (C) 2020, Samsung Electronics Co. Ltd. All Rights Reserved.
|
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU General Public License as published by
|
|
|
|
* the Free Software Foundation; either version 2 of the License, or
|
|
|
|
* (at your option) any later version.
|
|
|
|
*
|
|
|
|
* 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 "../comm/shub_comm.h"
|
|
|
|
#include "../sensormanager/shub_sensor.h"
|
|
|
|
#include "../sensormanager/shub_sensor_manager.h"
|
|
|
|
#include "../utility/shub_utility.h"
|
|
|
|
#include "light_seamless.h"
|
|
|
|
|
|
|
|
#include <linux/slab.h>
|
|
|
|
|
2024-04-28 06:51:13 -07:00
|
|
|
#define INPUT_MAX 256
|
|
|
|
|
2024-04-28 06:49:01 -07:00
|
|
|
static int inject_light_seamless_additional_data(char *buf, int count)
|
|
|
|
{
|
2024-04-28 06:51:13 -07:00
|
|
|
int ret = 0;
|
2024-04-28 06:49:01 -07:00
|
|
|
int index = 0;
|
|
|
|
int thd[2] = {200, 1000000};
|
2024-04-28 06:51:13 -07:00
|
|
|
char input[INPUT_MAX] = {0,};
|
|
|
|
char *input_tmp = NULL, *token = NULL;
|
2024-04-28 06:49:01 -07:00
|
|
|
|
2024-04-28 06:51:13 -07:00
|
|
|
if (count > INPUT_MAX) {
|
|
|
|
shub_errf("bufsize too long(%d)", count);
|
2024-04-28 06:49:01 -07:00
|
|
|
return -EINVAL;
|
|
|
|
}
|
2024-04-28 06:51:13 -07:00
|
|
|
|
|
|
|
memcpy(input, buf, count);
|
|
|
|
input_tmp = input;
|
|
|
|
|
|
|
|
while ((token = strsep(&input_tmp, ",")) != NULL && index < 2) {
|
|
|
|
ret = kstrtoint(token, 10, &thd[index++]);
|
|
|
|
if (ret < 0) {
|
|
|
|
shub_errf("%s - kstrtoint failed.(%d)\n", __func__, ret);
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
shub_info("%s - thd[0] = %d thd[1] = %d", __func__, thd[0], thd[1]);
|
2024-04-28 06:49:01 -07:00
|
|
|
|
|
|
|
ret = shub_send_command(CMD_SETVALUE, SENSOR_TYPE_LIGHT_SEAMLESS, LIGHT_SUBCMD_THRESHOLD, (char *)&thd, sizeof(thd));
|
|
|
|
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
2024-04-28 06:51:13 -07:00
|
|
|
static struct sensor_funcs light_seamless_sensor_funcs = {
|
|
|
|
.inject_additional_data = inject_light_seamless_additional_data,
|
|
|
|
};
|
|
|
|
|
2024-04-28 06:49:01 -07:00
|
|
|
int init_light_seamless(bool en)
|
|
|
|
{
|
2024-04-28 06:51:13 -07:00
|
|
|
int ret = 0;
|
2024-04-28 06:49:01 -07:00
|
|
|
struct shub_sensor *sensor = get_sensor(SENSOR_TYPE_LIGHT_SEAMLESS);
|
|
|
|
|
|
|
|
if (!sensor)
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
if (en) {
|
2024-04-28 06:51:13 -07:00
|
|
|
ret = init_default_func(sensor, "light_seamless_sensor", 4, 4, sizeof(struct light_seamless_event));
|
2024-04-28 06:49:01 -07:00
|
|
|
|
2024-04-28 06:51:13 -07:00
|
|
|
sensor->funcs = &light_seamless_sensor_funcs;
|
|
|
|
} else {
|
|
|
|
destroy_default_func(sensor);
|
2024-04-28 06:49:01 -07:00
|
|
|
}
|
|
|
|
|
2024-04-28 06:51:13 -07:00
|
|
|
return ret;
|
2024-04-28 06:49:01 -07:00
|
|
|
}
|