Fixed MTP to work with TWRP

This commit is contained in:
awab228 2018-06-19 23:16:04 +02:00
commit f6dfaef42e
50820 changed files with 20846062 additions and 0 deletions

344
drivers/sensors/Kconfig Executable file
View file

@ -0,0 +1,344 @@
#
# Sensor drivers configuration
#
menuconfig SENSORS
bool "Sensor devices"
help
Say Y here, and a list of sensors drivers will be displayed.
Everything that didn't fit into the other categories is here. This option
doesn't affect the kernel.
config SENSORS_K2HH
depends on I2C
tristate "SENSORS_K2HH"
default n
help
Say Y here if you use SENSORS_K2HH.
This option enables accelerometer sensors using
STMicroelectronic K2HH device driver.
config SENSORS_K2HH_VDD
depends on SENSORS_K2HH
tristate "SENSORS_K2HH_VDD"
default n
help
Say Y here if you use SENSORS_K2HH_VDD.
This option enables accelerometer sensors using VDD.
config SENSORS_PPSX60
tristate "PARTRON & TI PPSX60 HRM Sensor"
default n
depends on I2C
help
If you say yes here you get support for the PPSX60
HRM sensor.
This driver can also be built as a module. If so, the module
will be called PPSX60.
config SENSORS_BH1733
depends on I2C
tristate "BH1733 driver"
default n
help
Say Y here if you use bh1733.
This option enables light sensors using
Rohm bh1733 device driver.
config SENSORS_CM3323
depends on I2C
tristate "CM3323 driver"
default n
help
Say Y here if you use cm3323.
This option enables RGB sensors using
Capella cm3323 device driver.
Say N here if you do not use cm3323.
config SENSORS_CM36652
depends on I2C
tristate "CM36652 driver"
default n
help
This option enables proximity & light sensors using CM36652 driver.
config SENSORS_CM36652_LEDA_EN_GPIO
depends on I2C
tristate "CM36652 leda_en controlled by GPIO"
default n
help
This option enables leda_en controlled by GPIO using CM36652 driver.
config SENSORS_CM36652_SENSOR_EN_GPIO
depends on I2C
tristate "CM36652 sensor_en controlled by GPIO"
default n
help
This option enables leda_en controlled by GPIO using CM36652 driver.
config SENSORS_CM36655
depends on I2C
tristate "CM36655 driver"
default n
help
This option enables proximity & light sensors using CM36655 driver.
config SENSORS_CM36655_LEDA_EN_GPIO
depends on I2C
tristate "CM36655 leda_en controlled by GPIO"
default n
help
This option enables leda_en controlled by GPIO using CM36655 driver.
config SENSORS_CM36655_SENSOR_EN_GPIO
depends on I2C
tristate "CM36655 sensor_en controlled by GPIO"
default n
help
This option enables leda_en controlled by GPIO using CM36655 driver.
config SENSORS_TCS3490
depends on I2C
tristate "TCS3490 driver"
default n
help
This option enables light sensor using TCS3490 driver.
config SENSORS_TMD3782
depends on I2C
tristate "TMD3782 driver"
default n
help
This option enables proximity & light sensors using TMD3782 driver.
config SENSORS_TMD3782_PROX_ABS
depends on I2C
tristate "TMD3782 driver"
default n
help
This option enables TMD3782 proximity sensor input report by ABS.
config SENSORS_STK3013
depends on I2C
tristate "STK3013 driver"
default n
help
This option enables proximity sensor using STK3013 driver.
config SENSORS_SX9306
depends on I2C
tristate "SX9306 driver"
default n
help
This option enables grip sensors using SemTech sx9306 device driver.
config SENSORS_SX9306_NORMAL_TOUCH_THRESHOLD
int "SX9306 Grip sensor threshold for normal touch"
depends on SENSORS_SX9306
default "17"
help
This value is the standard of normal touch using SemTech sx9306 device driver.
config SENSORS_SX9306_WIFI
depends on I2C
tristate "SX9306 wifi driver"
default n
help
This option enables grip sensors using
SemTech sx9306 wifi device driver.
config SENSORS_SX9310
depends on I2C
tristate "SX9310 driver"
default n
help
Say Y here if you use sx9310.
This option enables grip sensors using
SemTech sx9310 device driver.
Say N here if you do not use sx9310.
config SENSORS_SX9310_INIT_TOUCH_THRESHOLD
int "SX9310 Grip sensor threshold for init touch"
depends on SENSORS_SX9310
default "3000"
help
This value is the standard of init touch using
SemTech sx9310 device driver.
config SENSORS_SX9310_NORMAL_TOUCH_THRESHOLD
int "SX9310 Grip sensor threshold for normal touch"
depends on SENSORS_SX9310
default "193"
help
This value is the standard of normal touch using
SemTech sx9310 device driver.
config SENSORS_SX9310_WIFI
depends on I2C
tristate "SX9310 driver"
default n
help
Say Y here if you use sx9310.
This option enables grip sensors using
SemTech sx9310 device driver.
Say N here if you do not use sx9310.
config SENSORS_SX9310_WIFI_INIT_TOUCH_THRESHOLD
int "SX9310 Grip sensor threshold for init touch"
depends on SENSORS_SX9310_WIFI
default "3000"
help
This value is the standard of init touch using
SemTech sx9310 device driver.
config SENSORS_SX9310_WIFI_NORMAL_TOUCH_THRESHOLD
int "SX9310 Grip sensor threshold for normal touch"
depends on SENSORS_SX9310_WIFI
default "17"
help
This value is the standard of normal touch using
SemTech sx9310 device driver.
config SENSORS_SX9500
depends on I2C
tristate "SX9500 driver"
default n
help
Say Y here if you use sx9500.
This option enables grip sensors using
SemTech sx9500 device driver.
Say N here if you do not use sx9500.
config SENSORS_SX9500_INIT_TOUCH_THRESHOLD
int "SX9500 Grip sensor threshold for init touch"
depends on SENSORS_SX9500
default "3000"
help
This value is the standard of init touch using
SemTech sx9500 device driver.
config SENSORS_SX9500_NORMAL_TOUCH_THRESHOLD
int "SX9500 Grip sensor threshold for normal touch"
depends on SENSORS_SX9500
default "17"
help
This value is the standard of normal touch using
SemTech sx9500 device driver.
config SENSORS_SX9500_TEMPERATURE_COMPENSATION
depends on SENSORS_SX9500
tristate "SX9500 Grip sensor temperature compensation"
default n
help
Say Y here if you use temperature compensation code.
This option enables grip sensors using
temperature compensation code.
config SENSORS_SX9500_REGULATOR_ONOFF
depends on SENSORS_SX9500
tristate "SX9500 Grip sensor Regulator"
default n
help
Say Y here if you use regulator for grip sensor.
This option enables regulator for grip sensor using
SemTech sx9500 device driver.
config SENSORS_SX9500_WIFI
depends on I2C
tristate "SX9500 driver for wifi"
default n
help
Say Y here if you use sx9500 for wifi.
This option enables grip sensors using
SemTech sx9500 device driver for wifi.
Say N here if you do not use sx9500 for wifi.
config SENSORS_SX9500_WIFI_INIT_TOUCH_THRESHOLD
int "SX9500 Grip sensor threshold for init touch for wifi"
depends on SENSORS_SX9500_WIFI
default "3000"
help
This value is the standard of init touch using
SemTech sx9500 device driver for wifi.
config SENSORS_SX9500_WIFI_NORMAL_TOUCH_THRESHOLD
int "SX9500 Grip sensor threshold for normal touch for wifi"
depends on SENSORS_SX9500_WIFI
default "17"
help
This value is the standard of normal touch using
SemTech sx9500 device driver for wifi.
config SENSORS_SX9500_WIFI_TEMPERATURE_COMPENSATION
depends on SENSORS_SX9500_WIFI
tristate "SX9500 Grip sensor temperature compensation for wifi"
default n
help
Say Y here if you use temperature compensation code.
This option enables grip sensors using
temperature compensation code.
config SENSORS_SX9500_WIFI_REGULATOR_ONOFF
depends on SENSORS_SX9500_WIFI
tristate "SX9500 Grip sensor Regulator for WIFI"
default n
help
Say Y here if you use regulator for grip sensor for WIFI.
This option enables regulator for grip sensor using
SemTech sx9500 device driver for WIFI.
config SENSORS_MAX86900
tristate "MAXIM MAX86900 HRM Sensor"
default n
depends on I2C
help
If you say yes here you get support for the MAX86900
HRM sensor.
This driver can also be built as a module. If so, the module
will be called max86900.
config SENSORS_MAX86902
tristate "MAXIM MAX86902 HRM & UV Sensor"
default n
depends on I2C
help
If you say yes here you get support for the MAX86902
HRM & UV sensor.
This driver can also be built as a module. If so, the module
will be called max86902.
config SENSORS_BMA2X2
tristate "BMA255/BMA250E/BMA222E/BMA280 acceleration sensor support"
depends on I2C
help
If you say yes here you get support for Bosch Sensortec's
acceleration sensors BMA255/BMA250E/BMA222E/BMA280.
config SENSORS_BMA2X2_ENABLE_INT1
tristate "BMA2X2 acceleration sensor interrupt INT1 support"
depends on SENSORS_BMA2X2
help
If you say yes here, you get INT1 support for Bosch Sensortec
acceleration sensors BMA255/BMA254/BMA355/BMA250E/BMA222E/BMA280.
config INPUT_BMA2x2_ACC_ALERT_INT
tristate "BMA255/BMA250E/BMA222E/BMA280 acceleration sensor support"
depends on I2C=y
help
If you say yes here you get support for Bosch Sensortec's
acceleration sensors BMA255/BMA250E/BMA222E/BMA280.
config SENSORS_BMM050
tristate "BMM050 Magnetic Sensor Driver"
depends on I2C
help
BMM050 Magnetic Sensor Driver implemented by Bosch-Sensortec.
config SENSORS_AK09916C
tristate "AK09916C compass support"
default n
depends on I2C
help
If you say yes here you get support for Asahi Kasei's
orientation sensor AK09916C.

34
drivers/sensors/Makefile Executable file
View file

@ -0,0 +1,34 @@
#
# Makefile for the sensors drivers.
#
# Each configuration option enables a list of files.
obj-$(CONFIG_SENSORS) += sensors_core.o
# accelerometer_sensor
obj-$(CONFIG_SENSORS_K2HH) += k2hh.o
obj-$(CONFIG_SENSORS_BMA2X2) += bma2x2.o
# optical_sensor
obj-$(CONFIG_SENSORS_BH1733) += bh1733.o
obj-$(CONFIG_SENSORS_TCS3490) += tcs3490.o
obj-$(CONFIG_SENSORS_CM3323) += cm3323.o
obj-$(CONFIG_SENSORS_CM36652) += cm36652.o
obj-$(CONFIG_SENSORS_CM36655) += cm36655.o
obj-$(CONFIG_SENSORS_TMD3782) += tmd3782.o
obj-$(CONFIG_SENSORS_STK3013) += stk3013.o
# grip_sensor
obj-$(CONFIG_SENSORS_SX9306) += sx9306.o
obj-$(CONFIG_SENSORS_SX9306_WIFI) += sx9306_wifi.o
obj-$(CONFIG_SENSORS_SX9310) += sx9310.o
obj-$(CONFIG_SENSORS_SX9310_WIFI) += sx9310_wifi.o
obj-$(CONFIG_SENSORS_SX9500) += sx9500.o
obj-$(CONFIG_SENSORS_SX9500_WIFI) += sx9500_wifi.o
# hrm_sensor
obj-$(CONFIG_SENSORS_PPSX60) += ppsx60.o
obj-$(CONFIG_SENSORS_MAX86900) += max86900.o
obj-$(CONFIG_SENSORS_MAX86902) += max86902.o
# obj-$(CONFIG_SENSORS_MAX_NOTCHFILTER) += max_notchfilter/
# magnetic_sensor
obj-$(CONFIG_SENSORS_BMM050) += bmm050_driver.o bmm050.o
obj-$(CONFIG_SENSORS_AK09916C) += ak09916c.o

1590
drivers/sensors/k2hh.c Executable file

File diff suppressed because it is too large Load diff

374
drivers/sensors/sensors_core.c Executable file
View file

@ -0,0 +1,374 @@
/*
* Copyright (C) 2013 Samsung Electronics. 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
* 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.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
* 02110-1301 USA
*/
#include <linux/module.h>
#include <linux/types.h>
#include <linux/init.h>
#include <linux/device.h>
#include <linux/fs.h>
#include <linux/err.h>
#include <linux/input.h>
#include <linux/sensor/sensors_core.h>
#ifdef CONFIG_ADSP_FACTORY
#include <linux/kernel.h>
#endif
struct class *sensors_class;
struct class *sensors_event_class;
static struct device *symlink_dev;
static struct device *sensor_dev;
static struct input_dev *meta_input_dev;
static atomic_t sensor_count;
struct axis_remap {
int src_x:3;
int src_y:3;
int src_z:3;
int sign_x:2;
int sign_y:2;
int sign_z:2;
};
/*!
* @Description:
* definitions of placement of sensors
* P0 - P3: view from top of device
* P4 - P7: view from bottom of device
*
* P0 / P4:
* Y of device aligned with Y of OS (i.e: Android)
* y
* ^
* |
* |
* |
* o------> x
*
*
* P1 / P5:
* Y of device aligned with Y of OS (i.e.: Android)
* rotated by 90 degrees clockwise
*
* o------> y
* |
* |
* |
* v x
*
*
* P2 / P6:
* Y of device aligned with Y of OS (i.e.: Android)
* rotated by 180 degrees clockwise
*
* x <------o
* |
* |
* |
* v
* y
*
*
* P3 / P7:
* Y of device aligned with Y of OS (i.e.: Android)
* rotated by 270 degrees clockwise
*
* x
* ^
* |
* |
* |
* y <------o
*
*/
#define MAX_AXIS_REMAP_TAB_SZ 8 /* P0~P7 */
static const struct axis_remap axis_table[MAX_AXIS_REMAP_TAB_SZ] = {
/* src_x src_y src_z sign_x sign_y sign_z */
{ 0, 1, 2, 1, 1, 1 }, /* P0 */
{ 1, 0, 2, 1, -1, 1 }, /* P1 */
{ 0, 1, 2, -1, -1, 1 }, /* P2 */
{ 1, 0, 2, -1, 1, 1 }, /* P3 */
{ 0, 1, 2, -1, 1, -1 }, /* P4 */
{ 1, 0, 2, -1, -1, -1 }, /* P5 */
{ 0, 1, 2, 1, -1, -1 }, /* P6 */
{ 1, 0, 2, 1, 1, -1 }, /* P7 */
};
void remap_sensor_data(s16 *val, u32 idx)
{
s16 tmp[3];
if (idx < MAX_AXIS_REMAP_TAB_SZ) {
tmp[0] = val[axis_table[idx].src_x] * axis_table[idx].sign_x;
tmp[1] = val[axis_table[idx].src_y] * axis_table[idx].sign_y;
tmp[2] = val[axis_table[idx].src_z] * axis_table[idx].sign_z;
memcpy(val, &tmp, sizeof(tmp));
}
}
void remap_sensor_data_32(int *val, u32 idx)
{
int tmp[3];
if (idx < MAX_AXIS_REMAP_TAB_SZ) {
tmp[0] = val[axis_table[idx].src_x] * axis_table[idx].sign_x;
tmp[1] = val[axis_table[idx].src_y] * axis_table[idx].sign_y;
tmp[2] = val[axis_table[idx].src_z] * axis_table[idx].sign_z;
memcpy(val, &tmp, sizeof(tmp));
}
}
int sensors_create_symlink(struct kobject *target, const char *name)
{
int err = 0;
if (symlink_dev == NULL) {
pr_err("%s, symlink_dev is NULL!!!\n", __func__);
return err;
}
err = sysfs_create_link(&symlink_dev->kobj, target, name);
if (err < 0) {
pr_err("%s, %s failed!(%d)\n", __func__, name, err);
return err;
}
return err;
}
void sensors_remove_symlink(struct kobject *target, const char *name)
{
if (symlink_dev == NULL)
pr_err("%s, symlink_dev is NULL!!!\n", __func__);
else
sysfs_delete_link(&symlink_dev->kobj, target, name);
}
static ssize_t set_flush(struct device *dev, struct device_attribute *attr,
const char *buf, size_t size)
{
int64_t dTemp;
u8 sensor_type = 0;
if (kstrtoll(buf, 10, &dTemp) < 0)
return -EINVAL;
sensor_type = (u8)dTemp;
input_report_rel(meta_input_dev, REL_DIAL,
1); /*META_DATA_FLUSH_COMPLETE*/
input_report_rel(meta_input_dev, REL_HWHEEL, sensor_type + 1);
input_sync(meta_input_dev);
pr_info("[SENSOR] flush %d", sensor_type);
return size;
}
static DEVICE_ATTR(flush, S_IWUSR | S_IWGRP, NULL, set_flush);
static struct device_attribute *sensor_attr[] = {
&dev_attr_flush,
NULL,
};
static void set_sensor_attr(struct device *dev,
struct device_attribute *attributes[])
{
int i;
for (i = 0; attributes[i] != NULL; i++)
if ((device_create_file(dev, attributes[i])) < 0)
pr_err("[SENSOR CORE] fail device_create_file"\
"(dev, attributes[%d])\n", i);
}
int sensors_register(struct device *dev, void *drvdata,
struct device_attribute *attributes[], char *name)
{
int ret = 0;
if (sensors_class == NULL) {
sensors_class = class_create(THIS_MODULE, "sensors");
if (IS_ERR(sensors_class))
return PTR_ERR(sensors_class);
}
dev = device_create(sensors_class, NULL, 0, drvdata, "%s", name);
if (IS_ERR(dev)) {
ret = PTR_ERR(dev);
pr_err("[SENSORS CORE] device_create failed![%d]\n", ret);
return ret;
}
set_sensor_attr(dev, attributes);
atomic_inc(&sensor_count);
return ret;
}
void sensors_unregister(struct device *dev,
struct device_attribute *attributes[])
{
int i;
for (i = 0; attributes[i] != NULL; i++)
device_remove_file(dev, attributes[i]);
}
void destroy_sensor_class(void)
{
if (sensors_class) {
device_destroy(sensors_class, sensor_dev->devt);
class_destroy(sensors_class);
sensor_dev = NULL;
sensors_class = NULL;
}
if (sensors_event_class) {
device_destroy(sensors_event_class, symlink_dev->devt);
class_destroy(sensors_event_class);
symlink_dev = NULL;
sensors_event_class = NULL;
}
}
#ifdef CONFIG_ADSP_FACTORY
extern struct class* get_adsp_sensor_class(void);
#endif
int sensors_input_init(void)
{
int ret;
/* Meta Input Event Initialization */
meta_input_dev = input_allocate_device();
if (!meta_input_dev) {
pr_err("[SENSOR CORE] failed alloc meta dev\n");
return -ENOMEM;
}
meta_input_dev->name = "meta_event";
input_set_capability(meta_input_dev, EV_REL, REL_HWHEEL);
input_set_capability(meta_input_dev, EV_REL, REL_DIAL);
ret = input_register_device(meta_input_dev);
if (ret < 0) {
pr_err("[SENSOR CORE] failed register meta dev\n");
input_free_device(meta_input_dev);
}
ret = sensors_create_symlink(&meta_input_dev->dev.kobj,
meta_input_dev->name);
if (ret < 0) {
pr_err("[SENSOR CORE] failed create meta symlink\n");
input_unregister_device(meta_input_dev);
input_free_device(meta_input_dev);
}
return ret;
}
void sensors_input_clean(void)
{
sensors_remove_symlink(&meta_input_dev->dev.kobj,
meta_input_dev->name);
input_unregister_device(meta_input_dev);
input_free_device(meta_input_dev);
}
static int __init sensors_class_init(void)
{
pr_info("[SENSORS CORE] sensors_class_init\n");
#ifdef CONFIG_ADSP_FACTORY
sensors_class = get_adsp_sensor_class();
#else
sensors_class = class_create(THIS_MODULE, "sensors");
if (IS_ERR(sensors_class)) {
pr_err("%s, create sensors_class is failed.(err=%d)\n",
__func__, IS_ERR(sensors_class));
return PTR_ERR(sensors_class);
}
#endif
/* For flush sysfs */
sensor_dev = device_create(sensors_class, NULL, 0, NULL,
"%s", "sensor_dev");
if (IS_ERR(sensor_dev)) {
pr_err("[SENSORS CORE] sensor_dev create failed![%d]\n",
IS_ERR(sensor_dev));
class_destroy(sensors_class);
return PTR_ERR(sensor_dev);
} else {
if ((device_create_file(sensor_dev, *sensor_attr)) < 0)
pr_err("[SENSOR CORE] failed flush device_file\n");
}
/* For symbolic link */
sensors_event_class = class_create(THIS_MODULE, "sensor_event");
if (IS_ERR(sensors_event_class)) {
pr_err("%s, create sensors_class is failed.(err=%d)\n",
__func__, IS_ERR(sensors_event_class));
class_destroy(sensors_class);
return PTR_ERR(sensors_event_class);
}
symlink_dev = device_create(sensors_event_class, NULL, 0, NULL,
"%s", "symlink");
if (IS_ERR(symlink_dev)) {
pr_err("[SENSORS CORE] symlink_dev create failed![%d]\n",
IS_ERR(symlink_dev));
class_destroy(sensors_class);
class_destroy(sensors_event_class);
return PTR_ERR(symlink_dev);
}
atomic_set(&sensor_count, 0);
sensors_class->dev_uevent = NULL;
sensors_input_init();
return 0;
}
static void __exit sensors_class_exit(void)
{
if (meta_input_dev)
sensors_input_clean();
if (sensors_class || sensors_event_class) {
class_destroy(sensors_class);
sensors_class = NULL;
class_destroy(sensors_event_class);
sensors_event_class = NULL;
}
}
subsys_initcall(sensors_class_init);
module_exit(sensors_class_exit);
MODULE_DESCRIPTION("Universal sensors core class");
MODULE_AUTHOR("Samsung Electronics");
MODULE_LICENSE("GPL");

1817
drivers/sensors/stk3013.c Executable file

File diff suppressed because it is too large Load diff