Add mono invert and cutoff as parameters
This commit is contained in:
parent
b943a10b37
commit
1017da3aab
1
Makefile
1
Makefile
@ -1,4 +1,5 @@
|
|||||||
obj-m += sharp.o
|
obj-m += sharp.o
|
||||||
|
sharp-objs += main.o params_iface.o
|
||||||
|
|
||||||
export KROOT=/lib/modules/$(shell uname -r)/build
|
export KROOT=/lib/modules/$(shell uname -r)/build
|
||||||
|
|
||||||
|
@ -29,6 +29,8 @@
|
|||||||
#include <drm/drm_probe_helper.h>
|
#include <drm/drm_probe_helper.h>
|
||||||
#include <drm/drm_simple_kms_helper.h>
|
#include <drm/drm_simple_kms_helper.h>
|
||||||
|
|
||||||
|
#include "params_iface.h"
|
||||||
|
|
||||||
#define GPIO_DISP 22
|
#define GPIO_DISP 22
|
||||||
#define GPIO_SCS 8
|
#define GPIO_SCS 8
|
||||||
#define GPIO_VCOM 23
|
#define GPIO_VCOM 23
|
||||||
@ -148,11 +150,16 @@ static size_t sharp_memory_gray8_to_mono_tagged(u8 *buf, int width, int height,
|
|||||||
for (b1 = 0; b1 < 8; b1++) {
|
for (b1 = 0; b1 < 8; b1++) {
|
||||||
|
|
||||||
// Change at what gray level the mono pixel is active here
|
// Change at what gray level the mono pixel is active here
|
||||||
if (buf[(line * width) + b8 + b1] >= 32) {
|
if (buf[(line * width) + b8 + b1] >= g_param_mono_cutoff) {
|
||||||
d |= 0b10000000 >> b1;
|
d |= 0b10000000 >> b1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Apply inversion
|
||||||
|
if (g_param_mono_invert) {
|
||||||
|
d = ~d;
|
||||||
|
}
|
||||||
|
|
||||||
// Without the line number and trailer tags, each destination
|
// Without the line number and trailer tags, each destination
|
||||||
// mono line would have a length `width / 8`. However, we are
|
// mono line would have a length `width / 8`. However, we are
|
||||||
// inserting the line number at the beginning of the line and
|
// inserting the line number at the beginning of the line and
|
32
params_iface.c
Normal file
32
params_iface.c
Normal file
@ -0,0 +1,32 @@
|
|||||||
|
#include <linux/types.h>
|
||||||
|
#include <linux/module.h>
|
||||||
|
#include <linux/moduleparam.h>
|
||||||
|
|
||||||
|
#include "params_iface.h"
|
||||||
|
|
||||||
|
int g_param_mono_cutoff = 32;
|
||||||
|
int g_param_mono_invert = 0;
|
||||||
|
|
||||||
|
static int set_param_u8(const char *val, const struct kernel_param *kp)
|
||||||
|
{
|
||||||
|
int rc, result;
|
||||||
|
|
||||||
|
// Parse string value
|
||||||
|
if ((rc = kstrtoint(val, 10, &result)) || (result < 0) || (result > 0xff)) {
|
||||||
|
return -EINVAL;
|
||||||
|
}
|
||||||
|
|
||||||
|
return param_set_int(val, kp);
|
||||||
|
}
|
||||||
|
|
||||||
|
static const struct kernel_param_ops u8_param_ops = {
|
||||||
|
.set = set_param_u8,
|
||||||
|
.get = param_get_int,
|
||||||
|
};
|
||||||
|
|
||||||
|
module_param_cb(mono_cutoff, &u8_param_ops, &g_param_mono_cutoff, 0660);
|
||||||
|
MODULE_PARM_DESC(mono_cutoff,
|
||||||
|
"Greyscale value from 0-255 after which a mono pixel will be activated");
|
||||||
|
|
||||||
|
module_param_cb(mono_invert, &u8_param_ops, &g_param_mono_invert, 0660);
|
||||||
|
MODULE_PARM_DESC(mono_invert, "0 for no inversion, 1 for inversion");
|
7
params_iface.h
Normal file
7
params_iface.h
Normal file
@ -0,0 +1,7 @@
|
|||||||
|
#ifndef PARAMS_IFACE_H_
|
||||||
|
#define PARAMS_IFACE_H_
|
||||||
|
|
||||||
|
extern int g_param_mono_cutoff;
|
||||||
|
extern int g_param_mono_invert;
|
||||||
|
|
||||||
|
#endif
|
Loading…
Reference in New Issue
Block a user