mirror of
https://github.com/tsukumijima/px4_drv.git
synced 2025-07-23 04:03:01 +02:00
@@ -1295,7 +1295,8 @@ int px4_device_init(struct px4_device *px4, struct device *dev,
|
||||
if (px4_mldev_search(px4->serial.serial_number, &px4->mldev))
|
||||
ret = px4_mldev_add(px4->mldev, px4);
|
||||
else
|
||||
ret = px4_mldev_alloc(&px4->mldev, PX4_MLDEV_ALL_MODE,
|
||||
ret = px4_mldev_alloc(&px4->mldev,
|
||||
px4_device_params.multi_device_power_control_mode,
|
||||
px4, px4_backend_set_power);
|
||||
|
||||
if (ret)
|
||||
|
@@ -8,16 +8,64 @@
|
||||
#include "px4_device_params.h"
|
||||
|
||||
#include <linux/kernel.h>
|
||||
#include <linux/string.h>
|
||||
#include <linux/module.h>
|
||||
|
||||
static const struct {
|
||||
enum px4_mldev_mode mode;
|
||||
char str[8];
|
||||
} mldev_mode_table[] = {
|
||||
{ PX4_MLDEV_ALL_MODE, "all" },
|
||||
{ PX4_MLDEV_S_ONLY_MODE, "s-only" },
|
||||
{ PX4_MLDEV_S0_ONLY_MODE, "s0-only" },
|
||||
{ PX4_MLDEV_S1_ONLY_MODE, "s1-only" },
|
||||
};
|
||||
|
||||
struct px4_device_param_set px4_device_params = {
|
||||
.tsdev_max_packets = 2048,
|
||||
.psb_purge_timeout = 2000,
|
||||
.disable_multi_device_power_control = false,
|
||||
.multi_device_power_control_mode = PX4_MLDEV_ALL_MODE,
|
||||
.s_tuner_no_sleep = false,
|
||||
.discard_null_packets = false
|
||||
};
|
||||
|
||||
static int set_multi_device_power_control_mode(const char *val,
|
||||
const struct kernel_param *kp)
|
||||
{
|
||||
int i;
|
||||
enum px4_mldev_mode mode;
|
||||
|
||||
for (i = 0; i < ARRAY_SIZE(mldev_mode_table); i++) {
|
||||
if (sysfs_streq(val, mldev_mode_table[i].str)) {
|
||||
mode = mldev_mode_table[i].mode;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (i == ARRAY_SIZE(mldev_mode_table))
|
||||
return -EINVAL;
|
||||
|
||||
px4_device_params.multi_device_power_control_mode = mode;
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int get_multi_device_power_control_mode(char *buffer,
|
||||
const struct kernel_param *kp)
|
||||
{
|
||||
enum px4_mldev_mode mode = px4_device_params.multi_device_power_control_mode;
|
||||
|
||||
if (mode < PX4_MLDEV_ALL_MODE && mode > PX4_MLDEV_S1_ONLY_MODE)
|
||||
return -EINVAL;
|
||||
|
||||
return scnprintf(buffer, 4096, "%s\n", mldev_mode_table[mode].str);
|
||||
}
|
||||
|
||||
static const struct kernel_param_ops multi_device_power_control_mode_ops = {
|
||||
.set = set_multi_device_power_control_mode,
|
||||
.get = get_multi_device_power_control_mode
|
||||
};
|
||||
|
||||
module_param_named(tsdev_max_packets, px4_device_params.tsdev_max_packets,
|
||||
uint, S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH);
|
||||
MODULE_PARM_DESC(tsdev_max_packets,
|
||||
@@ -30,6 +78,10 @@ module_param_named(disable_multi_device_power_control,
|
||||
px4_device_params.disable_multi_device_power_control,
|
||||
bool, S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH);
|
||||
|
||||
module_param_cb(multi_device_power_control_mode,
|
||||
&multi_device_power_control_mode_ops,
|
||||
NULL, S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH);
|
||||
|
||||
module_param_named(s_tuner_no_sleep, px4_device_params.s_tuner_no_sleep,
|
||||
bool, S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH);
|
||||
|
||||
|
@@ -5,10 +5,13 @@
|
||||
|
||||
#include <linux/types.h>
|
||||
|
||||
#include "px4_mldev.h"
|
||||
|
||||
struct px4_device_param_set {
|
||||
unsigned int tsdev_max_packets;
|
||||
int psb_purge_timeout;
|
||||
bool disable_multi_device_power_control;
|
||||
enum px4_mldev_mode multi_device_power_control_mode;
|
||||
bool s_tuner_no_sleep;
|
||||
bool discard_null_packets;
|
||||
};
|
||||
|
Reference in New Issue
Block a user