From c7cb971cd394ac9c66174a3c07e50bfc4fcd6e7a Mon Sep 17 00:00:00 2001 From: root Date: Mon, 28 Dec 2015 11:26:32 +0000 Subject: original framebuffer-utils for kobo-mini from marek --- Makefile | 9 +++ eink_disable_autoupdate.c | 22 ++++++ eink_enable_autoupdate.c | 22 ++++++ eink_full_monochrome.c | 28 ++++++++ eink_full_update.c | 28 ++++++++ mxcfb.h | 168 ++++++++++++++++++++++++++++++++++++++++++++++ 6 files changed, 277 insertions(+) create mode 100644 Makefile create mode 100644 eink_disable_autoupdate.c create mode 100644 eink_enable_autoupdate.c create mode 100644 eink_full_monochrome.c create mode 100644 eink_full_update.c create mode 100644 mxcfb.h diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..4f49406 --- /dev/null +++ b/Makefile @@ -0,0 +1,9 @@ +PROGS= eink_disable_autoupdate eink_enable_autoupdate eink_full_monochrome eink_full_update + +all: ${PROGS} + +clean: + /bin/rm -f ${PROGS} *.o *~ core + +install: ${PROGS} + for i in ${PROGS}; do install -m 755 -c $$i /usr/local/bin/$$i ; done diff --git a/eink_disable_autoupdate.c b/eink_disable_autoupdate.c new file mode 100644 index 0000000..cf89582 --- /dev/null +++ b/eink_disable_autoupdate.c @@ -0,0 +1,22 @@ +#include +#include +#include +#include "mxcfb.h" +#include + + + +int main(int argc, char *argv[]) +{ + int mode = AUTO_UPDATE_MODE_REGION_MODE; + int framebuffer = open("/dev/fb0", O_RDWR); /* 0_RDONLY */ + if (framebuffer != -1) + { + ioctl(framebuffer, MXCFB_SET_AUTO_UPDATE_MODE, &mode); + close(framebuffer); + + printf("E-ink display autoupdate disabled.\n"); + } + return 0; +} + diff --git a/eink_enable_autoupdate.c b/eink_enable_autoupdate.c new file mode 100644 index 0000000..3742115 --- /dev/null +++ b/eink_enable_autoupdate.c @@ -0,0 +1,22 @@ +#include +#include +#include +#include "mxcfb.h" +#include + + + +int main(int argc, char *argv[]) +{ + int mode = AUTO_UPDATE_MODE_AUTOMATIC_MODE; + int framebuffer = open("/dev/fb0", O_RDWR); /* 0_RDONLY */ + if (framebuffer != -1) + { + ioctl(framebuffer, MXCFB_SET_AUTO_UPDATE_MODE, &mode); + close(framebuffer); + + printf("E-ink display autoupdate enabled.\n"); + } + return 0; +} + diff --git a/eink_full_monochrome.c b/eink_full_monochrome.c new file mode 100644 index 0000000..da4ecaa --- /dev/null +++ b/eink_full_monochrome.c @@ -0,0 +1,28 @@ +#include +#include +#include +#include "mxcfb.h" +#include + + +int main(int argc, char *argv[]) +{ + struct mxcfb_update_data update_data = { + 0, 0, 800, 600, + WAVEFORM_MODE_AUTO, + }; + update_data.update_mode = UPDATE_MODE_PARTIAL; + update_data.flags = EPDC_FLAG_FORCE_MONOCHROME; + + + int framebuffer = open("/dev/fb0", O_RDWR); /* 0_RDONLY */ + if (framebuffer != -1) + { + ioctl(framebuffer, MXCFB_SET_UPDATE_SCHEME, UPDATE_SCHEME_QUEUE); + ioctl(framebuffer, MXCFB_SEND_UPDATE, &update_data); + close(framebuffer); + + printf("E-ink display fully updated (monochrome).\n"); + } + return 0; +} diff --git a/eink_full_update.c b/eink_full_update.c new file mode 100644 index 0000000..396de57 --- /dev/null +++ b/eink_full_update.c @@ -0,0 +1,28 @@ +#include +#include +#include +#include "mxcfb.h" +#include + + +int main(int argc, char *argv[]) +{ + struct mxcfb_update_data update_data = { + 0, 0, 800, 600, + WAVEFORM_MODE_AUTO, + }; + update_data.update_mode = UPDATE_MODE_FULL; + + + int framebuffer = open("/dev/fb0", O_RDWR); /* 0_RDONLY */ + if (framebuffer != -1) + { + ioctl(framebuffer, MXCFB_SET_UPDATE_SCHEME, UPDATE_SCHEME_QUEUE); + ioctl(framebuffer, MXCFB_SEND_UPDATE, &update_data); + close(framebuffer); + + printf("E-ink display fully updated.\n"); + } + return 0; +} + diff --git a/mxcfb.h b/mxcfb.h new file mode 100644 index 0000000..1e27af6 --- /dev/null +++ b/mxcfb.h @@ -0,0 +1,168 @@ +/* + * Copyright 2004-2011 Freescale Semiconductor, Inc. All Rights Reserved. + */ + +/* + * The code contained herein is licensed under the GNU Lesser General + * Public License. You may obtain a copy of the GNU Lesser General + * Public License Version 2.1 or later at the following locations: + * + * http://www.opensource.org/licenses/lgpl-license.html + * http://www.gnu.org/copyleft/lgpl.html + */ + +/* + * @file arch-mxc/ mxcfb.h + * + * @brief Global header file for the MXC Frame buffer + * + * @ingroup Framebuffer + */ +#ifndef __ASM_ARCH_MXCFB_H__ +#define __ASM_ARCH_MXCFB_H__ + +#include + +#define FB_SYNC_OE_LOW_ACT 0x80000000 +#define FB_SYNC_CLK_LAT_FALL 0x40000000 +#define FB_SYNC_DATA_INVERT 0x20000000 +#define FB_SYNC_CLK_IDLE_EN 0x10000000 +#define FB_SYNC_SHARP_MODE 0x08000000 +#define FB_SYNC_SWAP_RGB 0x04000000 + +struct mxcfb_gbl_alpha { + int enable; + int alpha; +}; + +struct mxcfb_loc_alpha { + int enable; + int alpha_in_pixel; + unsigned long alpha_phy_addr0; + unsigned long alpha_phy_addr1; +}; + +struct mxcfb_color_key { + int enable; + __u32 color_key; +}; + +struct mxcfb_pos { + __u16 x; + __u16 y; +}; + +struct mxcfb_gamma { + int enable; + int constk[16]; + int slopek[16]; +}; + +struct mxcfb_rect { + __u32 top; + __u32 left; + __u32 width; + __u32 height; +}; + +#define GRAYSCALE_8BIT 0x1 +#define GRAYSCALE_8BIT_INVERTED 0x2 + +#define AUTO_UPDATE_MODE_REGION_MODE 0 +#define AUTO_UPDATE_MODE_AUTOMATIC_MODE 1 + +#define UPDATE_SCHEME_SNAPSHOT 0 +#define UPDATE_SCHEME_QUEUE 1 +#define UPDATE_SCHEME_QUEUE_AND_MERGE 2 + +#define UPDATE_MODE_PARTIAL 0x0 +#define UPDATE_MODE_FULL 0x1 + +#define WAVEFORM_MODE_AUTO 257 + +#define TEMP_USE_AMBIENT 0x1000 + +#define EPDC_FLAG_ENABLE_INVERSION 0x01 +#define EPDC_FLAG_FORCE_MONOCHROME 0x02 +#define EPDC_FLAG_USE_ALT_BUFFER 0x100 + +#define FB_POWERDOWN_DISABLE -1 +#define FB_TEMP_AUTO_UPDATE_DISABLE -1 + +struct mxcfb_alt_buffer_data { + void *virt_addr; + __u32 phys_addr; + __u32 width; /* width of entire buffer */ + __u32 height; /* height of entire buffer */ + struct mxcfb_rect alt_update_region; /* region within buffer to update */ +}; + +struct mxcfb_update_data { + struct mxcfb_rect update_region; + __u32 waveform_mode; + __u32 update_mode; + __u32 update_marker; + int temp; + int flags; + struct mxcfb_alt_buffer_data alt_buffer_data; +}; + +/* + * Structure used to define waveform modes for driver + * Needed for driver to perform auto-waveform selection + */ +struct mxcfb_waveform_modes { + int mode_init; + int mode_du; + int mode_gc4; + int mode_gc8; + int mode_gc16; + int mode_gc32; +}; + +#define MXCFB_WAIT_FOR_VSYNC _IOW('F', 0x20, u_int32_t) +#define MXCFB_SET_GBL_ALPHA _IOW('F', 0x21, struct mxcfb_gbl_alpha) +#define MXCFB_SET_CLR_KEY _IOW('F', 0x22, struct mxcfb_color_key) +#define MXCFB_SET_OVERLAY_POS _IOWR('F', 0x24, struct mxcfb_pos) +#define MXCFB_GET_FB_IPU_CHAN _IOR('F', 0x25, u_int32_t) +#define MXCFB_SET_LOC_ALPHA _IOWR('F', 0x26, struct mxcfb_loc_alpha) +#define MXCFB_SET_LOC_ALP_BUF _IOW('F', 0x27, unsigned long) +#define MXCFB_SET_GAMMA _IOW('F', 0x28, struct mxcfb_gamma) +#define MXCFB_GET_FB_IPU_DI _IOR('F', 0x29, u_int32_t) +#define MXCFB_GET_DIFMT _IOR('F', 0x2A, u_int32_t) +#define MXCFB_GET_FB_BLANK _IOR('F', 0x2B, u_int32_t) +#define MXCFB_SET_DIFMT _IOW('F', 0x2C, u_int32_t) + +/* IOCTLs for E-ink panel updates */ +#define MXCFB_SET_WAVEFORM_MODES _IOW('F', 0x2B, struct mxcfb_waveform_modes) +#define MXCFB_SET_TEMPERATURE _IOW('F', 0x2C, int32_t) +#define MXCFB_SET_AUTO_UPDATE_MODE _IOW('F', 0x2D, __u32) +#define MXCFB_SEND_UPDATE _IOW('F', 0x2E, struct mxcfb_update_data) +#define MXCFB_WAIT_FOR_UPDATE_COMPLETE _IOW('F', 0x2F, __u32) +#define MXCFB_SET_PWRDOWN_DELAY _IOW('F', 0x30, int32_t) +#define MXCFB_GET_PWRDOWN_DELAY _IOR('F', 0x31, int32_t) +#define MXCFB_SET_UPDATE_SCHEME _IOW('F', 0x32, __u32) +#define MXCFB_GET_PMIC_TEMPERATURE _IOR('F', 0x32, int32_t) +#define MXCFB_SET_BORDER_MODE _IOR('F', 0x33, int32_t) +#define MXCFB_SET_EPD_PWR0_CTRL _IOR('F', 0x34, int32_t) +#define MXCFB_SET_EPD_PWR2_CTRL _IOR('F', 0x35, int32_t) +#define MXCFB_SET_TEMP_AUTO_UPDATE_PERIOD _IOR('F', 0x36, int32_t) +#define MXCFB_SET_MERGE_ON_WAVEFORM_MISMATCH _IOW('F', 0x37, int32_t) + +#ifdef __KERNEL__ + +extern struct fb_videomode mxcfb_modedb[]; +extern int mxcfb_modedb_sz; + +enum { + MXCFB_REFRESH_OFF, + MXCFB_REFRESH_AUTO, + MXCFB_REFRESH_PARTIAL, +}; + +int mxcfb_set_refresh_mode(struct fb_info *fbi, int mode, + struct mxcfb_rect *update_region); + +int mxc_elcdif_frame_addr_setup(dma_addr_t phys); +#endif /* __KERNEL__ */ +#endif -- cgit v1.2.3