Initial commit: Linux kernel 4.19 for Unplugged OS

This commit is contained in:
ziv committed 2025-10-06 13:52:42 +00:00
commit d30235b04c
80519 files changed
+35800681

No files matched your search

@@ -0,0 +1,98 @@
// SPDX-License-Identifier: GPL-2.0
/*
* Copyright (C) 2020 MediaTek Inc.
*/
#define pr_fmt(fmt) "test_sensor " fmt
#include <linux/module.h>
#include <linux/string.h>
#include <linux/kthread.h>
#include <linux/slab.h>
#include <linux/workqueue.h>
#include <linux/hrtimer.h>
#include "hf_sensor_type.h"
#include "sensor_comm.h"
#include "ready.h"
struct test_sensor_t {
char *name;
struct hrtimer test_timer;
struct work_struct test_work;
struct workqueue_struct *workqueue;
};
static struct test_sensor_t test_sensor = {
.name = "test_sensor",
};
static int enable_disable_count;
static void test_work_func(struct work_struct *work)
{
int ret = 0;
struct sensor_comm_ctrl *ctrl;
struct sensor_comm_batch *batch;
if (enable_disable_count++ % 2) {
ctrl = kzalloc(sizeof(*ctrl), GFP_KERNEL);
ctrl->sensor_type = SENSOR_TYPE_ACCELEROMETER;
ctrl->command = SENS_COMM_CTRL_DISABLE_CMD;
ctrl->length = 0;
} else {
ctrl = kzalloc(sizeof(*ctrl) + sizeof(*batch), GFP_KERNEL);
ctrl->sensor_type = SENSOR_TYPE_ACCELEROMETER;
ctrl->command = SENS_COMM_CTRL_ENABLE_CMD;
ctrl->length = sizeof(*batch);
batch = (struct sensor_comm_batch *)ctrl->data;
batch->delay = 20000000;
batch->latency = 1000000000;
}
ret = sensor_comm_ctrl_send(ctrl, sizeof(*ctrl) + ctrl->length);
if (ret < 0)
pr_err("enable disable fail %d\n", ret);
kfree(ctrl);
}
static enum hrtimer_restart test_timer_func(struct hrtimer *timer)
{
queue_work(test_sensor.workqueue, &test_sensor.test_work);
hrtimer_forward_now(&test_sensor.test_timer, ns_to_ktime(10000000000));
return HRTIMER_RESTART;
}
static int test_ready_notifier_call(struct notifier_block *this,
unsigned long event, void *ptr)
{
return NOTIFY_DONE;
}
static struct notifier_block test_ready_notifier = {
.notifier_call = test_ready_notifier_call,
.priority = READY_STDPRI,
};
static int __init test_init(void)
{
INIT_WORK(&test_sensor.test_work, test_work_func);
test_sensor.workqueue = create_singlethread_workqueue(test_sensor.name);
hrtimer_init(&test_sensor.test_timer,
CLOCK_MONOTONIC, HRTIMER_MODE_REL);
test_sensor.test_timer.function = test_timer_func;
hrtimer_start(&test_sensor.test_timer,
ns_to_ktime(10000000000), HRTIMER_MODE_REL);
sensor_ready_notifier_chain_register(&test_ready_notifier);
return 0;
}
static void __exit test_exit(void)
{
}
module_init(test_init);
module_exit(test_exit);
MODULE_AUTHOR("Mediatek");
MODULE_DESCRIPTION("test driver");
MODULE_LICENSE("GPL");
@@ -0,0 +1,80 @@
// SPDX-License-Identifier: GPL-2.0
/*
* Copyright (C) 2020 MediaTek Inc.
*/
#define pr_fmt(fmt) "test_sensor1 " fmt
#include <linux/module.h>
#include <linux/string.h>
#include <linux/kthread.h>
#include <linux/slab.h>
#include <linux/workqueue.h>
#include <linux/hrtimer.h>
#include <linux/time.h>
#include <asm/arch_timer.h>
#include "hf_sensor_type.h"
#include "sensor_comm.h"
struct test_sensor_t {
char *name;
struct hrtimer test_timer;
struct work_struct test_work;
struct workqueue_struct *workqueue;
};
static struct test_sensor_t test_sensor = {
.name = "test_sensor1",
};
static void test_work_func(struct work_struct *work)
{
int ret = 0;
struct sensor_comm_ctrl *ctrl = NULL;
struct sensor_comm_timesync *timesync = NULL;
ctrl = kzalloc(sizeof(*ctrl) + sizeof(*timesync), GFP_KERNEL);
ctrl->sensor_type = SENSOR_TYPE_INVALID;
ctrl->command = SENS_COMM_CTRL_TIMESYNC_CMD;
ctrl->length = sizeof(*timesync);
timesync = (struct sensor_comm_timesync *)ctrl->data;
local_irq_disable();
timesync->host_timestamp = ktime_get_boot_ns();
timesync->host_archcounter = arch_counter_get_cntvct();
local_irq_enable();
ret = sensor_comm_ctrl_send(ctrl, sizeof(*ctrl) + ctrl->length);
if (ret < 0)
pr_err("timesync fail %d\n", ret);
kfree(ctrl);
}
static enum hrtimer_restart test_timer_func(struct hrtimer *timer)
{
queue_work(test_sensor.workqueue, &test_sensor.test_work);
hrtimer_forward_now(&test_sensor.test_timer, ns_to_ktime(10000000000));
return HRTIMER_RESTART;
}
static int __init test_init(void)
{
INIT_WORK(&test_sensor.test_work, test_work_func);
test_sensor.workqueue = create_singlethread_workqueue(test_sensor.name);
hrtimer_init(&test_sensor.test_timer,
CLOCK_MONOTONIC, HRTIMER_MODE_REL);
test_sensor.test_timer.function = test_timer_func;
hrtimer_start(&test_sensor.test_timer,
ns_to_ktime(10000000000), HRTIMER_MODE_REL);
return 0;
}
static void __exit test_exit(void)
{
}
module_init(test_init);
module_exit(test_exit);
MODULE_AUTHOR("Mediatek");
MODULE_DESCRIPTION("test driver");
MODULE_LICENSE("GPL");
@@ -0,0 +1,85 @@
// SPDX-License-Identifier: GPL-2.0
/*
* Copyright (C) 2020 MediaTek Inc.
*/
#define pr_fmt(fmt) "test_sensor2 " fmt
#include <linux/module.h>
#include <linux/string.h>
#include <linux/kthread.h>
#include <linux/slab.h>
#include <linux/workqueue.h>
#include <linux/hrtimer.h>
#include "hf_sensor_type.h"
#include "sensor_comm.h"
struct test_sensor_t {
char *name;
struct hrtimer test_timer;
struct work_struct test_work;
struct workqueue_struct *workqueue;
};
static struct test_sensor_t test_sensor = {
.name = "test_sensor2",
};
static int enable_disable_count;
static void test_work_func(struct work_struct *work)
{
int ret = 0;
struct sensor_comm_ctrl *ctrl;
struct sensor_comm_batch *batch;
if (enable_disable_count++ % 2) {
ctrl = kzalloc(sizeof(*ctrl), GFP_KERNEL);
ctrl->sensor_type = SENSOR_TYPE_MAGNETIC_FIELD;
ctrl->command = SENS_COMM_CTRL_DISABLE_CMD;
ctrl->length = 0;
} else {
ctrl = kzalloc(sizeof(*ctrl) + sizeof(*batch), GFP_KERNEL);
ctrl->sensor_type = SENSOR_TYPE_MAGNETIC_FIELD;
ctrl->command = SENS_COMM_CTRL_ENABLE_CMD;
ctrl->length = sizeof(*batch);
batch = (struct sensor_comm_batch *)ctrl->data;
batch->delay = 20000000;
batch->latency = 2000000000;
}
ret = sensor_comm_ctrl_send(ctrl, sizeof(*ctrl) + ctrl->length);
if (ret < 0)
pr_err("enable disable fail %d\n", ret);
kfree(ctrl);
}
static enum hrtimer_restart test_timer_func(struct hrtimer *timer)
{
queue_work(test_sensor.workqueue, &test_sensor.test_work);
hrtimer_forward_now(&test_sensor.test_timer, ns_to_ktime(10000000000));
return HRTIMER_RESTART;
}
static int __init test_init(void)
{
INIT_WORK(&test_sensor.test_work, test_work_func);
test_sensor.workqueue = create_singlethread_workqueue(test_sensor.name);
hrtimer_init(&test_sensor.test_timer,
CLOCK_MONOTONIC, HRTIMER_MODE_REL);
test_sensor.test_timer.function = test_timer_func;
hrtimer_start(&test_sensor.test_timer,
ns_to_ktime(10000000000), HRTIMER_MODE_REL);
return 0;
}
static void __exit test_exit(void)
{
}
module_init(test_init);
module_exit(test_exit);
MODULE_AUTHOR("Mediatek");
MODULE_DESCRIPTION("test driver");
MODULE_LICENSE("GPL");
@@ -0,0 +1,90 @@
// SPDX-License-Identifier: GPL-2.0
/*
* Copyright (C) 2020 MediaTek Inc.
*/
#define pr_fmt(fmt) "test_sensor3 " fmt
#include <linux/module.h>
#include <linux/string.h>
#include <linux/kthread.h>
#include <linux/slab.h>
#include <linux/workqueue.h>
#include <linux/hrtimer.h>
#include <linux/time.h>
#include <asm/arch_timer.h>
#include "hf_sensor_type.h"
#include "sensor_comm.h"
#include "debug.h"
struct test_sensor_t {
char *name;
struct hrtimer test_timer;
struct work_struct test_work;
struct workqueue_struct *workqueue;
};
static struct test_sensor_t test_sensor = {
.name = "test_sensor3",
};
static void test_config(void)
{
int ret = 0;
struct sensor_comm_ctrl *ctrl = NULL;
int32_t cfg[3] = {500, 100, 203};
ctrl = kzalloc(sizeof(*ctrl) + sizeof(cfg), GFP_KERNEL);
ctrl->sensor_type = SENSOR_TYPE_ACCELEROMETER;
ctrl->command = SENS_COMM_CTRL_CONFIG_CMD;
ctrl->length = sizeof(cfg);
memcpy(ctrl->data, cfg, sizeof(cfg));
ret = sensor_comm_ctrl_send(ctrl, sizeof(*ctrl) + ctrl->length);
if (ret < 0)
pr_err("config fail %d\n", ret);
kfree(ctrl);
}
static void test_work_func(struct work_struct *work)
{
int ret = 0;
unsigned int len = 1024;
uint8_t *buffer = kzalloc(len, GFP_KERNEL);
ret = debug_get_debug(SENSOR_TYPE_INVALID, buffer, len);
if (ret > 0)
pr_err("\n%s\n", buffer);
kfree(buffer);
test_config();
}
static enum hrtimer_restart test_timer_func(struct hrtimer *timer)
{
queue_work(test_sensor.workqueue, &test_sensor.test_work);
hrtimer_forward_now(&test_sensor.test_timer, ns_to_ktime(10000000000));
return HRTIMER_RESTART;
}
static int __init test_init(void)
{
INIT_WORK(&test_sensor.test_work, test_work_func);
test_sensor.workqueue = create_singlethread_workqueue(test_sensor.name);
hrtimer_init(&test_sensor.test_timer,
CLOCK_MONOTONIC, HRTIMER_MODE_REL);
test_sensor.test_timer.function = test_timer_func;
hrtimer_start(&test_sensor.test_timer,
ns_to_ktime(10000000000), HRTIMER_MODE_REL);
return 0;
}
static void __exit test_exit(void)
{
}
module_init(test_init);
module_exit(test_exit);
MODULE_AUTHOR("Mediatek");
MODULE_DESCRIPTION("test driver");
MODULE_LICENSE("GPL");
@@ -0,0 +1,102 @@
// SPDX-License-Identifier: GPL-2.0
/*
* Copyright (C) 2020 MediaTek Inc.
*/
#define pr_fmt(fmt) "test_sensor4 " fmt
#include <linux/module.h>
#include <linux/string.h>
#include <linux/kthread.h>
#include <linux/slab.h>
#include <linux/workqueue.h>
#include <linux/hrtimer.h>
#include "hf_sensor_type.h"
#include "hf_manager.h"
#include "sensor_comm.h"
#include "sensor_list.h"
struct test_sensor_t {
int count;
char *name;
struct hrtimer test_timer;
struct work_struct test_work;
struct workqueue_struct *workqueue;
};
static struct test_sensor_t test_sensor = {
.name = "test_sensor4",
};
static struct sensor_info sensor_list[SENSOR_TYPE_SENSOR_MAX];
static void test_work_func(struct work_struct *work)
{
int ret = 0;
struct sensor_comm_notify notify;
unsigned int i = 0;
notify.sequence = 0;
notify.sensor_type = SENSOR_TYPE_ACCELEROMETER;
notify.command = SENS_COMM_NOTIFY_TEST_CMD;
notify.length = sizeof(notify.value[0]);
notify.value[0] = test_sensor.count++;
ret = sensor_comm_notify(&notify);
if (ret < 0)
pr_err("notify failed %d\n", ret);
memset(sensor_list, 0, sizeof(sensor_list));
ret = sensor_list_get_list(sensor_list, ARRAY_SIZE(sensor_list));
if (ret < 0) {
pr_err("get sensor list failed %d\n", ret);
return;
}
for (i = 0; i < ret; i++) {
if (sensor_list[i].sensor_type == SENSOR_TYPE_INVALID)
continue;
pr_err("sensor list type:%u, gain:%u, name:%s, vendor:%s\n",
sensor_list[i].sensor_type,
sensor_list[i].gain, sensor_list[i].name,
sensor_list[i].vendor);
}
}
static enum hrtimer_restart test_timer_func(struct hrtimer *timer)
{
queue_work(test_sensor.workqueue, &test_sensor.test_work);
return HRTIMER_NORESTART;
}
static void notify_func(struct sensor_comm_notify *n, void *private_data)
{
hrtimer_start(&test_sensor.test_timer,
ns_to_ktime(10000000000), HRTIMER_MODE_REL);
}
static int __init test_init(void)
{
sensor_comm_notify_handler_register(
SENS_COMM_NOTIFY_TEST_CMD, notify_func, NULL);
INIT_WORK(&test_sensor.test_work, test_work_func);
test_sensor.workqueue = create_singlethread_workqueue(test_sensor.name);
hrtimer_init(&test_sensor.test_timer,
CLOCK_MONOTONIC, HRTIMER_MODE_REL);
test_sensor.test_timer.function = test_timer_func;
hrtimer_start(&test_sensor.test_timer,
ns_to_ktime(10000000000), HRTIMER_MODE_REL);
return 0;
}
static void __exit test_exit(void)
{
}
module_init(test_init);
module_exit(test_exit);
MODULE_AUTHOR("Mediatek");
MODULE_DESCRIPTION("test driver");
MODULE_LICENSE("GPL");