Compare commits
No commits in common. "4f8931f1930ad0d76a5f2e1aa578ada1a9a33508" and "f0f671c6fb3a5bd556c98b895203a7eee68f8a07" have entirely different histories.
4f8931f193
...
f0f671c6fb
@ -8,7 +8,8 @@
|
||||
#include <linux/gpio/consumer.h>
|
||||
#include <linux/fb.h>
|
||||
|
||||
#define BPP 16
|
||||
#define BPP 8 // 8
|
||||
#define PIX_THRESHOLD 0
|
||||
|
||||
#define LMGE_GPIO 100
|
||||
#define LMGE_OTHER 99
|
||||
@ -20,9 +21,9 @@ MODULE_AUTHOR("Markus Koch");
|
||||
MODULE_DESCRIPTION("lmg6202ulyt display driver");
|
||||
MODULE_VERSION("0.1");
|
||||
|
||||
static int pix_threshold = 0;
|
||||
module_param(pix_threshold, int, 0);
|
||||
MODULE_PARM_DESC(pix_threshold, "Black / White threshold. 0-255");
|
||||
static char *testparam = "param";
|
||||
module_param(testparam, charp, S_IRUGO);
|
||||
MODULE_PARM_DESC(testparam, "A test parameter");
|
||||
|
||||
static struct of_device_id lmg6202ulyt_dt_ids[] = {
|
||||
{ .compatible = "hitachi,lmg6202ulyt", },
|
||||
@ -121,9 +122,7 @@ static int lmg6202ulyt_init_fix(struct lmg6202ulyt_priv *priv)
|
||||
else
|
||||
fix->visual = FB_VISUAL_TRUECOLOR;
|
||||
|
||||
printk(KERN_INFO "lmg6202ulyt: Using %d bpp (%s).\n",
|
||||
var->bits_per_pixel,
|
||||
(var->grayscale ? "grayscale" : "truecolor"));
|
||||
printk(KERN_INFO "lmg6202ulyt: Using %d bpp.\n", var->bits_per_pixel);
|
||||
|
||||
return 0;
|
||||
}
|
||||
@ -210,7 +209,6 @@ void lmg6202ulyt_deferred_io(struct fb_info *info, struct list_head *pagelist)
|
||||
int i;
|
||||
int blk;
|
||||
char __iomem *pixel;
|
||||
char pixval;
|
||||
int txsz;
|
||||
|
||||
spi_write(priv->spi, buf, 5);
|
||||
@ -221,13 +219,7 @@ void lmg6202ulyt_deferred_io(struct fb_info *info, struct list_head *pagelist)
|
||||
buf[0] = 1;
|
||||
|
||||
for (i = 0; i < BLOCKSIZE * 8; i++) {
|
||||
#if BPP == 8
|
||||
pixval = *(pixel);
|
||||
#else
|
||||
pixval = *(pixel + 1);
|
||||
// TODO: We should have more cases here for higher BPPs
|
||||
#endif
|
||||
if (pixval > pix_threshold) {
|
||||
if (*pixel > PIX_THRESHOLD) {
|
||||
buf[(i / 8) + 1] |= (1 << (7 - (i % 8)));
|
||||
}
|
||||
if (pixel >= info->screen_base + info->screen_size - ((info->var.bits_per_pixel) / 8))
|
||||
|
@ -6,9 +6,6 @@
|
||||
#include <linux/of_device.h>
|
||||
#include <linux/serdev.h>
|
||||
#include <linux/types.h>
|
||||
#include <linux/input.h>
|
||||
|
||||
// #define ENABLE_DEBUG ENABLE_DEBUG
|
||||
|
||||
MODULE_LICENSE("GPL");
|
||||
MODULE_AUTHOR("Markus Koch");
|
||||
@ -25,86 +22,18 @@ static struct of_device_id lw35ioc_dt_ids[] = {
|
||||
};
|
||||
MODULE_DEVICE_TABLE(of, lw35ioc_dt_ids);
|
||||
|
||||
/* Only used for initialization, not for actualy keycode mapping */
|
||||
static int keycode_map[] = {
|
||||
KEY_A, KEY_B, KEY_C, KEY_D, KEY_E, KEY_F, KEY_G, KEY_H, KEY_I, KEY_J,
|
||||
KEY_K, KEY_L, KEY_M, KEY_N, KEY_O, KEY_P, KEY_Q, KEY_R, KEY_S, KEY_T,
|
||||
KEY_U, KEY_V, KEY_W, KEY_X, KEY_Y, KEY_Z,
|
||||
KEY_0, KEY_1, KEY_2, KEY_3, KEY_4, KEY_5, KEY_6, KEY_7, KEY_8, KEY_9,
|
||||
KEY_F1, KEY_F2, KEY_F3, KEY_F4, KEY_F5, KEY_F6, KEY_F7, KEY_F8, KEY_F9,
|
||||
KEY_F10, KEY_F11, KEY_F12,
|
||||
KEY_UP, KEY_DOWN, KEY_RIGHT, KEY_LEFT, KEY_PAGEUP, KEY_PAGEDOWN,
|
||||
KEY_102ND, KEY_INSERT, KEY_HOME, KEY_END, KEY_PRINT,
|
||||
KEY_CAPSLOCK, KEY_LEFTCTRL, KEY_LEFTSHIFT, KEY_LEFTALT, KEY_TAB,
|
||||
KEY_MINUS, KEY_COMMA, KEY_SEMICOLON, KEY_RIGHTBRACE, KEY_LEFTBRACE,
|
||||
KEY_GRAVE, KEY_SPACE, KEY_EQUAL, KEY_DOT, KEY_SLASH, KEY_APOSTROPHE,
|
||||
KEY_BACKSLASH,
|
||||
KEY_DELETE, KEY_ESC, KEY_ENTER, KEY_BACKSPACE,
|
||||
KEY_SYSRQ
|
||||
};
|
||||
|
||||
enum lw35ioc_state {SYNC, TYPE, KEYBOARD, PRINTER};
|
||||
|
||||
struct lw35ioc_packet {
|
||||
enum lw35ioc_state state;
|
||||
};
|
||||
|
||||
struct lw35ioc_priv {
|
||||
struct serdev_device *serdev;
|
||||
struct input_dev *input_dev;
|
||||
|
||||
struct lw35ioc_packet packet;
|
||||
// USER VARS HERE
|
||||
};
|
||||
|
||||
static int lw35ioc_receive_buf(struct serdev_device *serdev,
|
||||
const unsigned char *data,
|
||||
size_t count)
|
||||
{
|
||||
struct lw35ioc_priv *priv = serdev_device_get_drvdata(serdev);
|
||||
unsigned char c;
|
||||
int ev;
|
||||
int i;
|
||||
|
||||
#ifdef ENABLE_DEBUG
|
||||
dev_info(&serdev->dev, "IRQ.\n");
|
||||
#endif
|
||||
for (i = 0; i < count; ++i) {
|
||||
c = data[i];
|
||||
#ifdef ENABLE_DEBUG
|
||||
dev_info(&serdev->dev, " RX [%d]: %02x\n", priv->packet.state, c);
|
||||
#endif
|
||||
switch (priv->packet.state) {
|
||||
case SYNC:
|
||||
if (c == 0xFF)
|
||||
priv->packet.state = TYPE;
|
||||
break;
|
||||
case TYPE:
|
||||
if (c == 0x55)
|
||||
priv->packet.state = KEYBOARD;
|
||||
else if (c == 0xAA)
|
||||
priv->packet.state = PRINTER;
|
||||
else
|
||||
priv->packet.state = SYNC;
|
||||
break;
|
||||
case KEYBOARD:
|
||||
if (c > 127) {
|
||||
c -= 128;
|
||||
ev = 1;
|
||||
} else {
|
||||
ev = 0;
|
||||
}
|
||||
input_report_key(priv->input_dev, c, ev);
|
||||
input_sync(priv->input_dev);
|
||||
priv->packet.state = SYNC;
|
||||
break;
|
||||
case PRINTER:
|
||||
dev_info(&serdev->dev, "Printer not yet implemented.\n");
|
||||
priv->packet.state = SYNC;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return i;
|
||||
dev_info(&serdev->dev, "RX: %c\n", data[0]);
|
||||
return 1; // TODO: return proper value
|
||||
}
|
||||
|
||||
static void lw35ioc_write_wakeup(struct serdev_device *serdev)
|
||||
@ -122,70 +51,39 @@ static int lw35ioc_probe(struct serdev_device *serdev)
|
||||
{
|
||||
struct lw35ioc_priv *priv = NULL;
|
||||
int ret;
|
||||
int i;
|
||||
u32 speed = 9600;
|
||||
struct input_dev *input_dev;
|
||||
|
||||
printk(KERN_INFO "lw35ioc: probe\n");
|
||||
|
||||
priv = devm_kzalloc(&serdev->dev,
|
||||
sizeof(struct lw35ioc_priv),
|
||||
GFP_KERNEL);
|
||||
if (!priv) {
|
||||
printk(KERN_ERR "lw35ioc: Not enough memory.\n");
|
||||
if (!priv)
|
||||
return -ENOMEM;
|
||||
}
|
||||
priv->serdev = serdev;
|
||||
priv->packet.state = SYNC;
|
||||
serdev_device_set_drvdata(serdev, priv);
|
||||
serdev_device_set_client_ops(serdev, &lw35ioc_serdev_ops);
|
||||
|
||||
input_dev = devm_input_allocate_device(&serdev->dev);
|
||||
if (!input_dev) {
|
||||
dev_err(&serdev->dev, "Unable to allocate input device.\n");
|
||||
return -ENOMEM;
|
||||
}
|
||||
priv->input_dev = input_dev;
|
||||
input_dev->name = "lw35ioc";
|
||||
input_dev->phys = "lw35ioc/input1";
|
||||
input_set_capability(input_dev, EV_MSC, MSC_SCAN);
|
||||
__set_bit(EV_KEY, input_dev->evbit);
|
||||
__set_bit(EV_REP, input_dev->evbit);
|
||||
for (i = 0; i < ARRAY_SIZE(keycode_map); i++)
|
||||
__set_bit(keycode_map[i], input_dev->keybit);
|
||||
ret = input_register_device(input_dev);
|
||||
if (ret) {
|
||||
dev_err(&serdev->dev, "Unable to register input device.\n");
|
||||
goto fail0;
|
||||
}
|
||||
|
||||
ret = serdev_device_open(serdev);
|
||||
if (ret) {
|
||||
dev_err(&serdev->dev, "Unable to open device.\n");
|
||||
goto fail1;
|
||||
goto fail0;
|
||||
}
|
||||
|
||||
speed = serdev_device_set_baudrate(serdev, speed);
|
||||
dev_info(&serdev->dev, "Using baudrate: %u\n", speed);
|
||||
|
||||
dev_info(&serdev->dev, "Loaded driver.\n");
|
||||
dev_info(&serdev->dev, "Loaded driver\n");
|
||||
|
||||
return 0;
|
||||
|
||||
fail1:
|
||||
input_unregister_device(input_dev);
|
||||
fail0:
|
||||
devm_kfree(&serdev->dev, input_dev);
|
||||
return ret;
|
||||
}
|
||||
|
||||
static void lw35ioc_remove(struct serdev_device *serdev)
|
||||
{
|
||||
struct lw35ioc_priv *priv = serdev_device_get_drvdata(serdev);
|
||||
|
||||
serdev_device_close(priv->serdev);
|
||||
input_unregister_device(priv->input_dev);
|
||||
|
||||
dev_info(&serdev->dev, "remove\n");
|
||||
return;
|
||||
}
|
||||
|
@ -146,7 +146,7 @@
|
||||
#define KEY_COMPOSE 127
|
||||
|
||||
#define SKEY_FN 255
|
||||
// #define KEYCODE_FN 127
|
||||
#define KEYCODE_FN 127
|
||||
|
||||
/*
|
||||
* Special keys:
|
||||
@ -196,35 +196,23 @@ uint8_t matrix_state_last_vector[9] = {0xFF, 0xFF, 0xFF, 0xFF,
|
||||
|
||||
uint8_t fn_active = 0;
|
||||
|
||||
void uart_putc(char c)
|
||||
{
|
||||
while (!(UCSRA & (1 << UDRE)));
|
||||
UDR = c;
|
||||
}
|
||||
|
||||
void process_key_event(uint8_t col, uint8_t row, uint8_t state)
|
||||
{
|
||||
char c;
|
||||
uint8_t keycode;
|
||||
int event = 0;
|
||||
|
||||
keycode = keycode_translation_matrix[fn_active][col][row];
|
||||
|
||||
if (keycode == SKEY_FN) {
|
||||
fn_active = state;
|
||||
#ifdef KEYCODE_FN
|
||||
c = KEYCODE_FN | (state << 7);
|
||||
event = 1;
|
||||
while (!(UCSRA & (1 << UDRE)));
|
||||
UDR = KEYCODE_FN | (state << 7);
|
||||
#endif
|
||||
} else {
|
||||
c = keycode | (state << 7);
|
||||
event = 1;
|
||||
}
|
||||
|
||||
if (event) {
|
||||
uart_putc(0xFF);
|
||||
uart_putc(0x55);
|
||||
uart_putc(c);
|
||||
while (!(UCSRA & (1 << UDRE)));
|
||||
UDR = c;
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user