Successfully reported this slideshow.
We use your LinkedIn profile and activity data to personalize ads and to show you more relevant ads. You can change your ad preferences anytime.

Introduction to Framebuffer

84,380 views

Published on

An introduction to framebuffer and the usage scenarios.
https://www.raspberrypi.com.tw/12793/meetup-14-data/

reference:
* https://www.kernel.org/doc/Documentation/fb/framebuffer.txt
* http://tldp.org/HOWTO/Framebuffer-HOWTO/
* http://raspberrycompote.blogspot.tw/
* http://www.myu.ac.jp/~xkozima/lab/raspTutorial3.html

Published in: Technology
  • Be the first to comment

Introduction to Framebuffer

  1. 1. Graphics Programming on Raspberry Pi - Framebuffer 介紹 台灣樹莓派 <sosorry@raspberrypi.com.tw> Jun 23, 2016/Raspberry Pi Meetup#14
  2. 2. 姓名標示 — 非商業性 — 相同方式分享 CC (Creative Commons) 姓名標示 — 你必須給予 適當表彰、提供指向本授權 條款的連結,以及 指出(本作品的原始版本)是否已 被變更。你可以任何合理方式為前述表彰,但不得以 任何方式暗示授權人為你或你的使用方式背書。 非商業性 — 你不得將本素材進行商業目的之使 用。 相同方式分享 — 若你重混、轉換本素材,或依本 素材建立新素材,你必須依本素材的授權條款來 散布你的貢獻物。
  3. 3. ● 什麼是 Framebuffer ? ● Framebuffer 怎麼用? ● Demo Outline
  4. 4. ● The frame buffer device provides an abstraction for the graphics hardware. ● It represents the frame buffer of some video hardware and allows application software to access the graphics hardware through a well-defined interface. 什麼是 Fraembuffer ? https://www.kernel.org/doc/Documentation/fb/framebuffer.txt
  5. 5. ● The frame buffer device provides an abstraction for the graphics hardware. ● It represents the frame buffer of some video hardware and allows application software to access the graphics hardware through a well-defined interface. 一塊記憶體 , 目的是抽象化顯示卡的硬體 什麼是 Fraembuffer ? https://www.kernel.org/doc/Documentation/fb/framebuffer.txt
  6. 6. 6 硬體抽象化 http://www.clivemaxfield.com/diycalculator/popup-h-console.shtml
  7. 7. Graphics Stack on Linux
  8. 8. Typical Desktop Linux https://goo.gl/6plONc
  9. 9. Raspbian https://goo.gl/6plONc
  10. 10. Raspbian without X https://goo.gl/6plONc
  11. 11. Framebuffer 怎麼用?
  12. 12. ● 螢幕截圖與還原 ● 顯示開機畫面 ● 自由繪圖 ● 鏡像畫面 常用情境
  13. 13. ● 掛在 /dev 的裝置檔 , 預設 X server 會使用 /dev/fb0 ● 截圖: $ cp /dev/fb0 fb.raw ● 還原: $ sudo cp fb.raw /dev/fb0 ● 將 raw 轉成 PNG 格式 ● 預設 320x240, 影像深度 16-bit ● $ sudo apt-get install libnetpbm10 ● $ perl iraw2png <screen.raw >screen.png 螢幕截圖與還原 https://blackfin.uclinux.org/doku.php?id=uclinux-dist:framebuffer
  14. 14. ● fbi - Linux framebuffer imageviewer ● 步驟 ● $ sudo apt-get install fbi ● 建立一個 sysvinit 服務 , 包含以下指令 ● /usr/bin/fbi -T 1 -noverbose -a /etc/splash.png ● 設定開機就啟動 顯示開機畫面 http://www.raspberry-projects.com/pi/pi-operating-systems/raspbian/custom-boot-up-screen
  15. 15. 自由繪圖 https://www.kernel.org/doc/Documentation/fb/framebuffer.txt
  16. 16. #include <linux/fb.h> int main(int argc, char* argv[]) { int fbfd = 0; struct fb_var_screeninfo var_info; fbfd = open("/dev/fb0", O_RDWR); ioctl(fbfd, FBIOGET_VSCREENINFO, &var_info); printf("%dx%d, %d bppn", var_info.xres, var_info.yres, var_info.bits_per_pixel); close(fbfd); return 0; } https://github.com/rst-/raspberry-compote
  17. 17. ● 將檔案映射到虛擬記憶體 ● void *mmap( void *addr, size_t len, int prot, int flag, int filedes, off_t off); mmap http://docs.linuxtone.org/ebooks/C&CPP/c/ch28s08.html
  18. 18. #include <linux/fb.h> int main(int argc, char* argv[]) { int fbfd = 0; ● struct fb_fix_screeninfo finfo; ● long int screensize = 0; ● char *fbp = 0; ● fbfd = open("/dev/fb0", O_RDWR); ● ioctl(fbfd, FBIOGET_FSCREENINFO, &finfo); ● screensize = finfo.smem_len; ● fbp = (char*)mmap(0, screensize, PROT_READ | PROT_WRITE, MAP_SHARED, fbfd, 0); ● memset(fbp, 0xff, screensize/2); ● memset(fbp + screensize/2, 0x18, screensize/2); ● ● munmap(fbp, screensize); ● close(fbfd); ● return 0; } https://github.com/rst-/raspberry-compote
  19. 19. 19 ● LCD 和 Framebuffer 的關係 鏡像畫面 http://www.clivemaxfield.com/diycalculator/popup-h-console.shtml
  20. 20. 20 透過 GPIO 將 RGB 寫到 TFT-LCD http://www.myu.ac.jp/~xkozima/lab/raspTutorial3.html
  21. 21. 21
  22. 22. ● https://www.kernel.org/doc/Documentation/fb/frameb uffer.txt ● http://tldp.org/HOWTO/Framebuffer-HOWTO/ ● http://raspberrycompote.blogspot.tw/ ● http://www.myu.ac.jp/~xkozima/lab/raspTutorial3.html Reference
  23. 23. 23 Raspberry Pi Rocks the World Thanks

×