Skip to content

Commit

Permalink
add "-t" option for TEfix method of st7789sfb.ko (#4)
Browse files Browse the repository at this point in the history
* add "-t" option for TEfix method

* add SET & GET_TEFIX IO offsets + add missing
  • Loading branch information
Apaczer authored May 22, 2023
1 parent 39a7bd3 commit 28154bb
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 7 deletions.
5 changes: 3 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ A command line program for Miyoo devices (bittboy, pocket go v1, powkiddy v90/q9

## Usage

`miyooctl [-h] [-i] [-v] [-V volume(0-10)] [-k keypad_ver(1-7)] [-l layout_ver(1-6)] [-m rumble_ver(1-3)] [-M rumble_mode(0-1)] [-s screen_ver(1-4)] [-f fpbp_hexbyte]`
`miyooctl [-h] [-i] [-v] [-V volume(0-10)] [-k keypad_ver(1-7)] [-l layout_ver(1-6)] [-m rumble_ver(1-3)] [-M rumble_mode(0-1)] [-s screen_ver(1-4)] [-f fpbp_hexbyte] [-t tefix(0-3)]`

* `-h` prints the above help line
* `-i` prints the information that the modules report (currently the volume, keypad version & layout)
Expand All @@ -16,8 +16,9 @@ A command line program for Miyoo devices (bittboy, pocket go v1, powkiddy v90/q9
* `-M` sets the vibration/rumble motor on/off; 0=on, 1=off
* `-s` sets the screen version; range 1 to 4. Note that an incorrect version will effectively disable your screen until you shut down the device.
* `-f` sets FP/BP for the screen driver
* `-t` sets Tearing effect FIX method of the ST7789 screen driver; range 0 to 3.

**Note**: In the latest Miyoo cfw builds you can use it in the `normalboot.custom.sh` bash file located on `boot/variants/<CONSOLE_VARIANT>`
**Note**: In the latest Miyoo cfw builds you can use it in the `normalboot.custom.sh` bash file located on `boot/<CONSOLE_VARIANT>`

## Compiling

Expand Down
40 changes: 35 additions & 5 deletions main.c
Original file line number Diff line number Diff line change
Expand Up @@ -38,14 +38,18 @@
#define MIYOO_SND_GET_VOLUME _IOWR(0x101, 0, unsigned long)
#define MIYOO_KBD_GET_HOTKEY _IOWR(0x100, 0, unsigned long)
#define MIYOO_KBD_SET_VER _IOWR(0x101, 0, unsigned long)
#define MIYOO_KBD_LOCK_KEY _IOWR(0x102, 0, unsigned long) //unused
#define MIYOO_LAY_SET_VER _IOWR(0x103, 0, unsigned long)
#define MIYOO_KBD_GET_VER _IOWR(0x104, 0, unsigned long)
#define MIYOO_LAY_GET_VER _IOWR(0x105, 0, unsigned long)
#define MIYOO_FB0_PUT_OSD _IOWR(0x100, 0, unsigned long)
#define MIYOO_FB0_SET_MODE _IOWR(0x101, 0, unsigned long)
#define MIYOO_FB0_GET_VER _IOWR(0x102, 0, unsigned long)
#define MIYOO_FB0_SET_FLIP _IOWR(0x103, 0, unsigned long) //unused
#define MIYOO_FB0_SET_FPBP _IOWR(0x104, 0, unsigned long)
#define MIYOO_FB0_GET_FPBP _IOWR(0x105, 0, unsigned long)
#define MIYOO_FB0_SET_TEFIX _IOWR(0x106, 0, unsigned long)
#define MIYOO_FB0_GET_TEFIX _IOWR(0x107, 0, unsigned long)

#define MIYOO_FBP_FILE "/mnt/.fpbp.conf"
#define MIYOO_LID_FILE "/mnt/.backlight.conf"
Expand All @@ -59,8 +63,8 @@
#define MIYOO_KBD_FILE "/dev/miyoo_kbd"
#define MIYOO_VIR_FILE "/dev/miyoo_vir"

#define OPTSTR "hivV:k:l:m:M:s:f:"
#define USAGE_FMT "%s [-h] [-i] [-v] [-V volume(0-10)] [-m rumble_ver(1-4)] [-M rumble_mode(0-1)] [-s screen_ver(1-4)]\n [-f fpbp_hexbyte]\n [-k keypad_ver(1-7)]\n [-l layout_ver(1-6)]\n"
#define OPTSTR "hivV:k:l:m:M:s:f:t:"
#define USAGE_FMT "%s [-h] [-i] [-v] [-V volume(0-10)] [-m rumble_ver(1-4)] [-M rumble_mode(0-1)] [-s screen_ver(1-4)]\n [-f fpbp_hexbyte]\n [-k keypad_ver(1-7)]\n [-l layout_ver(1-6)]\n [-t tefix(0-3)]\n"
#define DEFAULT_PROGNAME "miyooctl"
#define ERR_DO_THE_DEED "the main action went wrong somehow"
#define ERR_OPEN_FILE(x) "open('"x"')"
Expand Down Expand Up @@ -96,6 +100,7 @@ typedef struct {
int verbose;
int screen_ver;
int fpbp;
int tefix;
int keypad_ver;
int layout_ver;
int rumble_ver;
Expand All @@ -108,7 +113,7 @@ int do_the_deed(options_t *opts);

int main(int argc, char** argv) {
int opt;
options_t options = { 0, 0, -1, -1, -1, -1, -1, -1, -1, basename(argv[0]) };
options_t options = { 0, 0, -1, -1, -1, -1, -1, -1, -1, -1, basename(argv[0]) };
opterr = 0;

while ((opt = getopt(argc, argv, OPTSTR)) != EOF) {
Expand All @@ -128,6 +133,9 @@ int main(int argc, char** argv) {
case 'l':
options.layout_ver = parse_int(optarg, 10, 1, 6);
break;
case 't':
options.tefix = parse_int(optarg, 10, 0, 3);
break;
case 'm':
options.rumble_ver = parse_int(optarg, 10, 1, 4);
break;
Expand All @@ -138,7 +146,7 @@ int main(int argc, char** argv) {
options.screen_ver = parse_int(optarg, 10, 1, 4);
break;
case 'f':
options.fpbp = parse_int(optarg, 16, 0, 4);
options.fpbp = parse_int(optarg, 16, 1, 4);
break;
case 'h':
default:
Expand All @@ -158,7 +166,7 @@ int main(int argc, char** argv) {
}

int do_the_deed(options_t *opts) {
options_t current = { 0, 0, -1, -1, -1, -1, -1, -1, -1, NULL };
options_t current = { 0, 0, -1, -1, -1, -1, -1, -1, -1, -1, NULL };
int f;

if(opts->volume != -1) {
Expand Down Expand Up @@ -200,6 +208,20 @@ int do_the_deed(options_t *opts) {
close(f);
}

if(opts->tefix != -1) {
if(!(f = open(MIYOO_FB0_FILE, O_RDWR))) {
perror(ERR_OPEN_FILE(MIYOO_FB0_FILE));
return EXIT_FAILURE;
/* NOTREACHED */
}
ioctl(f, MIYOO_FB0_GET_TEFIX, &(current.tefix));
if(opts->verbose) {
fprintf(stdout, "%s: setting TEfix to %d\n", opts->progname, opts->tefix);
}
ioctl(f, MIYOO_FB0_SET_TEFIX, opts->tefix);
close(f);
}

if(opts->keypad_ver != -1) {
if(!(f = open(MIYOO_KBD_FILE, O_RDWR))) {
perror(ERR_OPEN_FILE(MIYOO_KBD_FILE));
Expand Down Expand Up @@ -242,6 +264,13 @@ int do_the_deed(options_t *opts) {
}
ioctl(f, MIYOO_SND_GET_VOLUME, &(current.volume));
close(f);
if(!(f = open(MIYOO_FB0_FILE, O_RDWR))) {
perror(ERR_OPEN_FILE(MIYOO_FB0_FILE));
return EXIT_FAILURE;
/* NOTREACHED */
}
ioctl(f, MIYOO_FB0_GET_TEFIX, &(current.tefix));
close(f);
}

if(opts->rumble_ver != -1 || opts->rumble_mode != -1) {
Expand Down Expand Up @@ -272,6 +301,7 @@ int do_the_deed(options_t *opts) {
// ((uint16_t)current.fpbp&0x0F00)>>8,
// ((uint16_t)current.fpbp&0x00F0)>>4,
// ((uint16_t)current.fpbp&0x000F));
fprintf(stdout, "%s: current TEfix method: %d\n", opts->progname, current.tefix);
fprintf(stdout, "%s: current keypad version: %d\n", opts->progname, current.keypad_ver);
fprintf(stdout, "%s: current keypad layout version: %d\n", opts->progname, current.layout_ver);
fprintf(stdout, "%s: current volume: %d\n", opts->progname, current.volume);
Expand Down

0 comments on commit 28154bb

Please sign in to comment.