Skip to content

GPIO, SPI and 64-bit support, platform channel refactor #39

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 12 commits into from
Feb 26, 2020
8 changes: 4 additions & 4 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
CC = cc
LD = cc
REAL_CFLAGS = -I./include $(shell pkg-config --cflags gbm libdrm glesv2 egl) -DBUILD_ELM327_PLUGIN -DBUILD_TEST_PLUGIN -ggdb $(CFLAGS)
REAL_CFLAGS = -I./include $(shell pkg-config --cflags gbm libdrm glesv2 egl) -DBUILD_ELM327_PLUGIN -DBUILD_GPIOD_PLUGIN -DBUILD_SPIDEV_PLUGIN -DBUILD_TEST_PLUGIN -ggdb $(CFLAGS)
REAL_LDFLAGS = $(shell pkg-config --libs gbm libdrm glesv2 egl) -lrt -lflutter_engine -lpthread -ldl $(LDFLAGS)

SOURCES = src/flutter-pi.c src/platformchannel.c src/pluginregistry.c src/console_keyboard.c \
src/plugins/elm327plugin.c src/plugins/services-plugin.c src/plugins/testplugin.c src/plugins/text_input.c \
src/plugins/raw_keyboard.c
src/plugins/elm327plugin.c src/plugins/services.c src/plugins/testplugin.c src/plugins/text_input.c \
src/plugins/raw_keyboard.c src/plugins/gpiod.c src/plugins/spidev.c
OBJECTS = $(patsubst src/%.c,out/obj/%.o,$(SOURCES))

all: out/flutter-pi

out/obj/%.o: src/%.c
out/obj/%.o: src/%.c
@mkdir -p $(@D)
$(CC) -c $(REAL_CFLAGS) $(REAL_LDFLAGS) $< -o $@

Expand Down
34 changes: 31 additions & 3 deletions include/flutter-pi.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@
#include <xf86drmMode.h>
#include <stdint.h>
#include <flutter_embedder.h>
#include <stdlib.h>
#include <string.h>

#define EGL_PLATFORM_GBM_KHR 0x31D7

Expand All @@ -34,6 +36,8 @@ typedef enum {
kVBlankRequest,
kVBlankReply,
kUpdateOrientation,
kSendPlatformMessage,
kRespondToPlatformMessage,
kFlutterTask
} flutterpi_task_type;

Expand All @@ -47,11 +51,26 @@ struct flutterpi_task {
intptr_t baton;
};
enum device_orientation orientation;
struct {
char *channel;
const FlutterPlatformMessageResponseHandle *responsehandle;
size_t message_size;
uint8_t *message;
};
};
uint64_t target_time;
};

void post_platform_task(struct flutterpi_task *task);
static inline void *memdup(const void *restrict src, const size_t n) {
void *__restrict__ dest;

if ((src == NULL) || (n == 0)) return NULL;

dest = malloc(n);
if (dest == NULL) return NULL;

return memcpy(dest, src, n);
}

struct drm_fb {
struct gbm_bo *bo;
Expand Down Expand Up @@ -111,8 +130,6 @@ struct mousepointer_mtslot {

#define ISSET(uint32bitmap, bit) (uint32bitmap[(bit)/32] & (1 << ((bit) & 0x1F)))

#define STREQ(a, b) (strcmp(a, b) == 0)

struct input_device {
char path[PATH_MAX];
char name[256];
Expand Down Expand Up @@ -147,4 +164,15 @@ extern struct mousepointer_mtslot mousepointer;

extern FlutterEngine engine;

void post_platform_task(struct flutterpi_task *task);

int flutterpi_send_platform_message(const char *channel,
const uint8_t *restrict message,
size_t message_size,
FlutterPlatformMessageResponseHandle *responsehandle);

int flutterpi_respond_to_platform_message(FlutterPlatformMessageResponseHandle *handle,
const uint8_t *restrict message,
size_t message_size);

#endif
Loading