mirror of
https://github.com/goodtft/LCD-show.git
synced 2026-06-19 02:09:18 +02:00
modift nano 2.4inch driver
This commit is contained in:
BIN
usr/ft6236.dtb
BIN
usr/ft6236.dtb
Binary file not shown.
14
usr/rpi-fbcp/CMakeLists.txt
Normal file
14
usr/rpi-fbcp/CMakeLists.txt
Normal file
@@ -0,0 +1,14 @@
|
||||
cmake_minimum_required(VERSION 2.8)
|
||||
|
||||
SET(COMPILE_DEFINITIONS -Werror)
|
||||
|
||||
include_directories(/opt/vc/include)
|
||||
include_directories(/opt/vc/include/interface/vcos/pthreads)
|
||||
include_directories(/opt/vc/include/interface/vmcs_host)
|
||||
include_directories(/opt/vc/include/interface/vmcs_host/linux)
|
||||
|
||||
link_directories(/opt/vc/lib)
|
||||
|
||||
add_executable(fbcp main.c)
|
||||
|
||||
target_link_libraries(fbcp bcm_host)
|
||||
21
usr/rpi-fbcp/LICENSE
Normal file
21
usr/rpi-fbcp/LICENSE
Normal file
@@ -0,0 +1,21 @@
|
||||
MIT License
|
||||
|
||||
Copyright (c) 2013 Tasanakorn Phaipool
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all
|
||||
copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
SOFTWARE.
|
||||
62
usr/rpi-fbcp/README.md
Normal file
62
usr/rpi-fbcp/README.md
Normal file
@@ -0,0 +1,62 @@
|
||||
Raspberry Pi Framebuffer Copy
|
||||
=============================
|
||||
This program used for copy primary framebuffer to secondary framebuffer (eg. FBTFT). It require lastest raspberry pi firmware (> 2013-07-11) to working properly.
|
||||
|
||||
Tested on Raspberry Pi 3
|
||||
========================
|
||||
2017-11-29-raspbian-stretch
|
||||
|
||||
|
||||
Requirement
|
||||
-----------
|
||||
cmake
|
||||
|
||||
$ sudo apt-get install cmake
|
||||
|
||||
Build
|
||||
-----
|
||||
|
||||
$ mkdir build
|
||||
|
||||
$ cd build
|
||||
|
||||
$ cmake ..
|
||||
|
||||
$ make
|
||||
|
||||
|
||||
How To Use
|
||||
----------
|
||||
$ ./fbcp
|
||||
|
||||
Wanna to run from booting
|
||||
-------------------------
|
||||
$ sudo cp fbcp /usr/bin
|
||||
$ sudo chmod +x /usr/bin/fbcp
|
||||
$ sudo nano /etc/rc.local -> add new line before "exit 0" with "/usr/bin/fbcp &" without quote
|
||||
$ sudo reboot
|
||||
|
||||
|
||||
License
|
||||
-------
|
||||
|
||||
|
||||
Copyright (c) 2013 Tasanakorn Phaipool
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all
|
||||
copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
SOFTWARE.
|
||||
93
usr/rpi-fbcp/main.c
Normal file
93
usr/rpi-fbcp/main.c
Normal file
@@ -0,0 +1,93 @@
|
||||
|
||||
#include <stdio.h>
|
||||
#include <syslog.h>
|
||||
#include <sys/fcntl.h>
|
||||
#include <sys/ioctl.h>
|
||||
#include <linux/fb.h>
|
||||
#include <sys/mman.h>
|
||||
|
||||
#include <bcm_host.h>
|
||||
|
||||
int process() {
|
||||
DISPMANX_DISPLAY_HANDLE_T display;
|
||||
DISPMANX_MODEINFO_T display_info;
|
||||
DISPMANX_RESOURCE_HANDLE_T screen_resource;
|
||||
VC_IMAGE_TRANSFORM_T transform;
|
||||
uint32_t image_prt;
|
||||
VC_RECT_T rect1;
|
||||
int ret;
|
||||
int fbfd = 0;
|
||||
char *fbp = 0;
|
||||
|
||||
struct fb_var_screeninfo vinfo;
|
||||
struct fb_fix_screeninfo finfo;
|
||||
|
||||
|
||||
bcm_host_init();
|
||||
|
||||
display = vc_dispmanx_display_open(0);
|
||||
if (!display) {
|
||||
syslog(LOG_ERR, "Unable to open primary display");
|
||||
return -1;
|
||||
}
|
||||
ret = vc_dispmanx_display_get_info(display, &display_info);
|
||||
if (ret) {
|
||||
syslog(LOG_ERR, "Unable to get primary display information");
|
||||
return -1;
|
||||
}
|
||||
syslog(LOG_INFO, "Primary display is %d x %d", display_info.width, display_info.height);
|
||||
|
||||
|
||||
fbfd = open("/dev/fb1", O_RDWR);
|
||||
if (fbfd == -1) {
|
||||
syslog(LOG_ERR, "Unable to open secondary display");
|
||||
return -1;
|
||||
}
|
||||
if (ioctl(fbfd, FBIOGET_FSCREENINFO, &finfo)) {
|
||||
syslog(LOG_ERR, "Unable to get secondary display information");
|
||||
return -1;
|
||||
}
|
||||
if (ioctl(fbfd, FBIOGET_VSCREENINFO, &vinfo)) {
|
||||
syslog(LOG_ERR, "Unable to get secondary display information");
|
||||
return -1;
|
||||
}
|
||||
|
||||
syslog(LOG_INFO, "Second display is %d x %d %dbps\n", vinfo.xres, vinfo.yres, vinfo.bits_per_pixel);
|
||||
|
||||
screen_resource = vc_dispmanx_resource_create(VC_IMAGE_RGB565, vinfo.xres, vinfo.yres, &image_prt);
|
||||
if (!screen_resource) {
|
||||
syslog(LOG_ERR, "Unable to create screen buffer");
|
||||
close(fbfd);
|
||||
vc_dispmanx_display_close(display);
|
||||
return -1;
|
||||
}
|
||||
|
||||
fbp = (char*) mmap(0, finfo.smem_len, PROT_READ | PROT_WRITE, MAP_SHARED, fbfd, 0);
|
||||
if (fbp <= 0) {
|
||||
syslog(LOG_ERR, "Unable to create memory mapping");
|
||||
close(fbfd);
|
||||
ret = vc_dispmanx_resource_delete(screen_resource);
|
||||
vc_dispmanx_display_close(display);
|
||||
return -1;
|
||||
}
|
||||
|
||||
vc_dispmanx_rect_set(&rect1, 0, 0, vinfo.xres, vinfo.yres);
|
||||
|
||||
while (1) {
|
||||
ret = vc_dispmanx_snapshot(display, screen_resource, 0);
|
||||
vc_dispmanx_resource_read_data(screen_resource, &rect1, fbp, vinfo.xres * vinfo.bits_per_pixel / 8);
|
||||
usleep(25 * 1000);
|
||||
}
|
||||
|
||||
munmap(fbp, finfo.smem_len);
|
||||
close(fbfd);
|
||||
ret = vc_dispmanx_resource_delete(screen_resource);
|
||||
vc_dispmanx_display_close(display);
|
||||
}
|
||||
|
||||
int main(int argc, char **argv) {
|
||||
setlogmask(LOG_UPTO(LOG_DEBUG));
|
||||
openlog("fbcp", LOG_NDELAY | LOG_PID, LOG_USER);
|
||||
|
||||
return process();
|
||||
}
|
||||
Binary file not shown.
Reference in New Issue
Block a user