Title: TFT-LCD Device Driver
1TFT-LCD Device Driver
2? ?
- TFT-LCD ??
- Frame Buffer Device
- ??? ??
- PXA255 LCD Controller
- 6.4 inch LCD Module
- Device Driver Source
- Linux??? JPEG Library ??
- Web Camera ?? ??
- Web Camera? ??? ??
3TFT-LCD ??
- LCD(Liquid Crystal Display)
- ?? ????, ? ??? ??? ????? ??
- ??? ?????? ??? ?? ??? ?? ??? ???, ??? ??? ? ???
?? ????? ?? ??? ??. - LCD ???? ??? ??? ??? ??? ??? ??? ??? ?? ???? ??
???? ??? ?? ?? ????. - ?? Display ??? ?? ???? LCD? ??(pixel) ?????
?????? ???? ?? ??? ???? ??? ??? ?? ???? ??? ? ??
TFT(Thin Film Transistor) LDT? ???? ???? ?? ??
??? ?? ? ??. - LCD ???? ?? ??(Pixel Pitch)?? ? ??? ????. CRT
???? ?? ??? ?? ??? ???? ????.
4Frame Buffer Device(1)
- Frame Buffer
- Linux system?? graphic? ??? ? ?? hardware? ??.
- Application software? ? ??? interface? ??
graphics hardware? access? ? ??? ???? ??? ?? - ? software? low-level(hardware register)? ???
?? ? ??? ?? - PC? ??? ??? ??, PXA255? ??? LCD controller? Frame
Buffer ???? ? ? ??. - Frame? ? ?? ??? ????, Frame Buffer? frame? ????
?? buffer? ????. - user ???? ??? device file? ??? ????.
- ?? /dev/fb? ????.
- Frame Buffer Device Driver
- Frame buffer ??? user level application? ??? ?
??? ???? Device Driver
5Frame Buffer Device(2)
- Video Mode Timings
- Display device? ??? ?? ??? ?? ??? ???? ???.
- Scan lines? ???? ????? ?? ?? ????? ??? ???? ????
???.
6Frame Buffer Device(3)
- Video Mode Timings
- Display device? ??? ???? ?? ? new scanline? new
frame? ?? graphics controller? ???? ??? ??
Synchronization Pulse(Horizontal sync, Vertical
sync)? ????. - Synchronization? ?? ??? ??
7Frame Buffer Device(4)
- PXA255 LCD Controller - Active Mode Timing (1)
8Frame Buffer Device(5)
- PXA255 LCD Controller - Active Mode Timing (2)
- VSW Vertical Sync Pulse Width 1
- HWS Horizontal Sync Pulse Width 1
- BFW Beginning of Frame Horizontal Sync Clock
Wait Count - BLW Beginning of Line Pixel Clock Wait Count
1 - ELW End of Line Pixel Clock Wait Count 1
- PPL Pixels Per Line 1
9??? ??
L_FCLK LCD ??? ????? ????. High? ??? ? pixel?
new frame? ??? ????. ?, LCD
data? ??? ??? ??? ??? ??. L_LCLK LCD ??? ?? ???
????. ????? High ? ?, Line ??? ???
????, Low? ??? ? Line ???? ????. L_PCLK LCD
pixel clock, active mode?? lcd controller? enable
?? ????? toggle ??. L_BIAS
L_PCLK? ???? L_BIAS? assert??? ? LCD? L_DD data?
latch??. Output enable.
PXA255
LCD 6.4 inch
L_DD150 LCD? ??? data line
BKL_ON LCD backlight on/off
10PXA255 LCD Controller
- Block-diagram
- ???? DMA controller? ???? ?????(SDRAM)??? ????
FIFO buffer? load??. - Palette? ???? ??(1,2,4,8 bit) Encoded pixel data?
Palette RAM? ??? Raw pixel data? ????, 16bit per
pixel frame buffer entries??? palette RAM? ????. - ???? 16bit Active Color Mode? ????(bypasses
palette, dither). - ????? ???? 16 pin? 6.4inch LCD ??? ????.
11LCD Module Spec. (1)
- 6.4-inch LCD module
- ??? PRO3 ??? ???? ?? 6.4inch LCD module? ?? ??
??? ???? ?? ??? ??? ?. - ?? ??? 640480
12LCD Module Spec. (2)
13Device Driver Source (1)
- KERNEL_SRC/arm/arch/mach-pxa/pro3.c
- static struct pxafb_mode_info pro3_lcd_mode
- .pixclock 25000,
- .xres 640,
- .yres 480,
- .bpp 16,
- .hsync_len 49,
- .left_margin 96,
- .right_margin 16,
- .vsync_len 2,
- .upper_margin 33,
- .lower_margin 10,
- .sync FB_SYNC_HOR_HIGH_ACT
FB_SYNC_VERT_HIGH_ACT, - .cmap_greyscale 0,
-
- static struct pxafb_mach_info pro3_lcd
- .modes pro3_lcd_mode,
- .num_modes 1,
- .cmap_inverse 0,
? ??? ??? ??? Synce mode?? Timing? ?? ????. ??? ?
6.4inch? LCD module? ?? ??? ?? ? ? ??.
14Device Driver Source (2)
- KERNEL_SRC/arm/arch/mach-pxa/pro3.c
- static void pro3_backlight_power(int on)
-
- if (on)
- GPSR(PRO3_LCDBACKLIGHT_GPIO)
GPIO_bit(PRO3_LCDBACKLIGHT_GPIO) - else
- GPCR(PRO3_LCDBACKLIGHT_GPIO)
GPIO_bit(PRO3_LCDBACKLIGHT_GPIO) -
- static void __init pro3_init(void)
-
- set_pxa_fb_info(pro3_lcd)
-
LCD backlight ??? GPIO? ??? ???? ??.
???? ???? set_pxa_fb_info()? ??? ??? LCD
Controller? ????.
15Linux??? JPEG Library ??
- ? ?
- JPEG ?? ? ?? ??
- JPEG Library ??
- Frame buffer ??
- JPEG Image Viewer Test
16JPEG ??
- JPEG(Joint Picture Experts Group) ?????????
- ?? ??? ?? ISO/IEC JTC1 ?? SC29? Working Group
- ????? ?? ?? ?? ???? ???? ??? ??? ????? ??? ???
???? ?? - JPEG ?? ??? ?? ????? ??? ??? ?? ???? ??.
- JPEG ?? ?? ?? JPEG ??(IJG) ?? ??
- JFIF(JPEG File Interchange Format)
- JPEG ???? ??? ??? ??? ??? ?? ??? ?? ??
- EXIF JPEG ??? ???? ?? ?? ??
- ???
- ITU-T ?? T.81
- JIS X 4301
- ISO/IEC 10918-11994
17JPEG ?? ??
- ???? ?? - RGB ???? YCbCr??? ? ?? ???? ??
- ??? ?? ??? - Cb? Cr? ?? ?? ??(?? ???)
- DCT?? (?? ??? ??) - ??? 8x8 ??? ???? ???, ? ???
?? ???? ??? ?? ?????(DCT)? ???? ?? - ???(Quantization) - ??? ??? ? ??? ?? ????? ?? ??
?? ??(?? ??? ?) - ???? ???(Entropy Coding) - 8x8 ??? ????? ????? ??
?, ??? ???? ??.
18Shared Library? Static Library
- Static Library
- Object file? ???? .a ???? ??? Library.
- ????? ?? ??? ?? ??? ?? ?? ? ?? ??? ??? ?? -gt ?
??? ??? ??? ???? ??. - Shared Library
- ????? ??? ? Loading?? Library - .so? ???? ??
- Library? ?????? ??????? ??? ????
- Shared Library ?? ??
- ??? ?? (soname)
- ??? lib ????? ?? .so. ????
- Ex) libreadline.so.3
- ?? ?? (realname)
- soname ??,???? ?? ?
- Ex)libreadline.so.3.0
- ????? ?????? ??? ? ???? linker name
- Soname?? ??? ?? ??
- Ex) libreadline.so
19???? JPEG ????? ?? (1)
- ?? ?? ??
- PRO3? Toolchain ?? ??
- /usr/local/arm/gcc-4.0.2-glibc-2.3.6/arm-softfloat
-linux-gnu/bin? ARM? ???? ?? - PATH? ARM? ???? ?? ?? ?? (Command echo PATH)
- ?? ????
- http//www.ijg.org/
- ???? ? ?? ???? ??
- cp jpeg-6b.tar.gz /root/work
- cd /root/work
- tar xfz jpeg-6b.tar.gz
- cd ./jped-6b
- mkdir ./build
- mkdir ./build/lib
- mkdir ./build/include
20???? JPEG ????? ?? (2)
- Configuration
- Configure ?? ??
- ./configure --help
- ./configure --prefix/root/work/jpeg-6b/build/
21???? JPEG ????? ?? (3)
- Makefile ??
- vi ./Makefile
? CCcc (23 Line) -gt CCarm-linux-gcc ? ARar rc
(63 Line) -gt ARarm-linux-ar rc ? AR2ranlib (65
Line) -gt RANLIBarm-linux-ranlib ? (AR2)
libjpeg.a (167 Line) -gt (RANLIB) libjpeg.a
22???? JPEG ????? ?? (4)
23???? JPEG ????? ?? (5)
- Library ??
- make install-lib
- Toolchain? ??
- cd ./build/
- cp -arf ./ /usr/local/arm/gcc-4.0.2-glibc-2.3.6
/arm-softfloat-linux-gnu/arm-softfloat-linux-gnu/
24JPEG Library ?? ?? ? ??? (1)
- struct jpeg_decompress_struct ? struct
jpeg_compress_struct - jpeg ???? ?? ??? ???? ???
- jpeglib.h ?? ??
- jpeg_create_decompress()
- ????? ??? ??
- jpeg_stdio_src()
- ??? ?? ?? ???? ? file?? ??
- jpeg_read_header()
- ??? ??? ???? JPEG ?? ??? ?? ??
- jpeg_start_decompress()
- JPEG ??? ?? ?? ??
25JPEG Library ?? ?? ? ??? (2)
- Jpeg_read_scanlines()
- JPEG?????? 1 line? ???? ?????? ???.
- Jpeg_fininsh_decompress()
- ?? ?? ??
- Jpeg_destroy_decompress()
- JPEG ??? ??? ??
26Frame Buffer ??
- ???? ??? ????? Frame buffer? ???? display? ??
- Frame Buffer ???? open
- Frame Buffer ??? ???
- Frame Buffer ?? ????
- Frame Buffer ?????? mmap ?? ??
fbfd open(FBDEVFILE, O_RDWR)
struct fb_var_screeninfo fbvar
ioctl(fbfd, FBIOGET_VSCREENINFO, fbvar)
mmap(0, lt?? ??gt, lt?? ???gt,
ltFramebuffer ???? ?? ???gt, 0)
27MMAP ???
- ????? ??? ??? ?? ????? ??? ???? ??(mapping)??? ?
? ?? - ?? ??, ???? ???? ??? ????? ??? ??? ??? ????? ??
???? ???? ?? ???????? ??? ? ??? ?? ??
munmap
iounmap
28Frame Buffer Open
fbfd open(FBDEVFILE, O_RDWR) if(fbfd lt 0)
perror("fbdev open") return
0 if(ioctl(fbfd, FBIOGET_VSCREENINFO,
fbvar) lt 0) perror("fbdev ioctl") return
0 if(fbvar.bits_per_pixel ! 16)
fprintf(stderr, "bpp is not 16\n") return
0 pfbmap (unsigned int )mmap(0,
fbvar.xresfbvar.yresDEPTH, PROT_READPROT_WR
ITE, MAP_SHARED, fbfd, 0) if((unsigned)pfbmap
(unsigned)-1) perror("fbdev
mmap") return 0 printf("\n xres d \t
yres d\n", fbvar.xres, fbvar.yres)
29JPEG Image Viewer Test
- jpeg viewer? ?????.
- ??? ????
- tar xfz jpeg_exam.tar.gz
- ??? ?? ?????? ???? ?????.
- cd jpeg_exam
- make
- ???? ???? jpg_sample_view ????? ????.
- jpg_sample_view? sample.jpg ??? ????? ???? ????.
- (?????? ??)
- ./jpg_sample_view ./sample.jpg
30Web Camera ?? ??
- ? ?
- Web Camera ?? ? ??
- Video4Linux ??
- Video4Linux API
- Video4Linux? ??? ?? ??
31Web Camera ?? ???
111
USB Cable
- OVA511 Chipset Web Camera
- USB2.0/1.1 ??
32Image Capture ?? ??
- ???? ????? USB ?? ??
- Full Speed 12Mbps ??
- 640x480 RGB565 ?? ??? ? ?? ??
- 640x480x16bit / 8bit 600kbyte 4800kbits
- 640x480 ???? ?? fps
- 1210241024 / 48001024 ? 2.56 (fps)
- ???? ??? ?? Capture ? ? ?? ???? ?? ???, ????
Capture?? ??? ????? ???.
33Web Camera ?? ???
Kernel Layer
Video4Linux
USB Driver Stack
USB2.0 Host Controller
H/W Layer
???
USB2.0 Host Device
USB Cable
Capture
34Video4Linux
- Video4Linux ??
- Kernel?? ???? ?? ??? TV????? ???? ?? ??
- Linux?? Video???? ???? ???? ?? API?? ??
- V4L? ?? ??? ????
- /dev/video ??? ?? ?????
- /dev/radio64 AM/FM ??? ????
- /dev/vtx Teletext(????) ????? ?
- /dev /vbi RAW VBI(Vertical Blanking Interval)
??? - Kernel menu config?? V4L ?? ?? ??
35Video4Linux? ??? ?? ??
- Viedo4Linux? ??? ???? ?? ?? ??
36Video4Linux API (1)
- int ioctl(int filedes, VIDIOCGCAP, struct
video_capability ) - ???? ??? File Descripter? ?? ????? ?????
video_capability ???? ???? ????. - struct video_capability
??? ?? ??
Char32 name ?????? ???? ??
int type ?????? ??
int channels ???/TV? ?? ??? ?
int audios ??? ????? ?
int maxwidth ??? ?? ?? ??(?? ??)
int maxheight ??? ?? ?? ??(?? ??)
int minwidth ??? ?? ?? ??(?? ??)
int minheight ??? ?? ?? ??(?? ??)
37Video4Linux API (2)
- int ioctl(int filedes, VIDIOCGCHAN, struct
video_channel ) - V4L ????? ????? ??? ?? ??? ???.
- V4L ?????? ??? ????? ??? ??? ???, ?? ??? ???.
- V4L ????? ?????? ??? ??? ??? ?????.
- struct video_channel
- int ioctl(int filedes, VIDIOCSCHAN, struct
video_channel ) - ??? ?? ??? ??? ????? ?? ??? ???.
- Channel? norm ??? ???? ????? ?.
??? ?? ??
int channel ??? ??
char32 name ??? ???? ?? ??? ???(Label)? ??
int tuners ? ??? ??? ??? ?
__u32 flags ??? ?? ?? ??
__u16 type ??? ??
__u16 norm ? ??? ?? (TV? ?? ??)
38Video4Linux API (3)
- int ioctl(int filedes, VIDIOCSWIN, struct
video_window ) - ??? ??? ???.
- struct video_window
- int Ioctl(int filedes, VIDIOCGWIN, struct
video_window) - ??? ?? ??? ???.
??? ?? ??
__u32 x X ?????? X ??
__u32 y X ?????? Y ??
__u32 width ?? ? ???? ?? ?
__u32 height ?? ? ???? ?? ??
__u32 chromakey ????? ? (RGB32 ?)
__u32 flags ???? ?? ???
struct video_clip clips ??? ? ????? ??? (Set only)
int clipcount clipcount ??? ? ????? ? (Set only)
39Video4Linux API (4)
- int ioctl(int filedes, VIDIOCGPICT, struct
video_picture ) - ??? ??? ?? ??? ???.
- struct video_picture
- int ioctl(int filedes, VIDIOCSPICT, struct
video_picture ) - ???? ??? ????.
??? ?? ??
__u16 brightness ??? ??
__u16 hue ??? ??(hue) (??)
__u16 colour ??? ?(Color) (??)
__u16 contrast ??? ??(Contrast)
__u16 whiteness ???(Whiteness) (??? ???)
__u16 depth ??? ??(Capture Depth)
__u16 palette ? ????? ?? ? ???
40Video4Linux API (5)
- int ioctl(int filedes, VIDIOCGMBUF, struct
video_mbuf ) - ????? ????? ???.
- struct video_mbuf
- ??? ???? ????? ???? mmap? ???? ????? ??? ????
????.
??? ? ? ? ?
int size ??(Mapping) ??? ???? ??
int frames ???(Frames)? ?
int offsetsVIDEO_MAX_FRAME ? ???? ???(Offset)
41Video4Linux API (6)
- int ioctl(int filedes, VIDIOCMCAPTURE, struct
video_mmap ) - Mmap?? ??? ??? ??? ??.
- struct video_mmap
- int ioctl(int filedes, VIDIOCSYNC, int )
- ??? ????? ???? ???? ???? ??.
- ??? ???? ??? ???? ??
??? ?? ? ?
unsigned int frame ?? ???? ?? ?? ? ??? ??
int width ???? ?
int height ???? ??
unsigned int format ?? ??? palette ?? ??
42V4L? ??? ?? Capture
- VIDIOCGMBUF ? ??? ??? ??? 2? ????? ?.
- ?? ??
- ??? ??? ?????, ?? ??? ??? ?? Capture??? ??
- ?? Caputre ??
- ? ?? ???? ?? Frame 0 (F0), Frame 1(F1)? ?? ?
- 1?? F0? ?? VIDIOCMCAPTURE ? capture ??
- 2?? F1? ?? VIDIOCMCAPTURE ? capture ??
- 3?? F0? ?? VIDIOCSYNC? Capture ?? ??
- 4?? F0? ?? ???? (??? Display, JPEG ???? ?)
- 5?? F0? ?? Capture ??
- 6?? F1? ?? Capture ????
- 7?? F1? ?? ????
- 3???? ??
43???? ?????? ????
- PXA255-PRO3? LCD Frame Buffer? 16bit? Depth? ??
- RGB565 ?? ??
- ??? ???? LCD ????? ? RGB565???? ???? ????? ????
- JPEG ???? ?? ?? ?? ??
- ??? Capture?? ???? JPEG?? ???? ??? ?? ?? ???
- Web Camera Capture ??
- 2?? ???? ??? ??.
- ??? ??? 64x32? ????? 640x320? ????? ??? ?????
????? ???? Capture ??? ??? ?? ? ? ??. - ?? ??? ARM CPU?? Hardware Floating ?? unit? ??
- Linux Kernel?? Floating ??? ???? Software?? ???.
- ????? ?? ?? ? Floating ??? ?? ???? ??? ????
44Web Camera? ??? ??
- ? ?
- USB Web Camera ??
- Web Camera ?? ???? ?? ? ??
- Web Camera ?? ???? ?? ?
- ???
45USB Web Camera ??
- PXA255-PRO3? USB 2.0 ??? USB Web Camera? ????
Kernel?? USB Web Camera? ???? ???? ?? USB Stack?
init ????. - ??? ?? /dev/video0?? ???? ??? ????.
46Web Camera ?? ???? ??
- CD? ??? ??? ????.
- ??? ??? ?? ????.
- tar xfz ipcctv-fb.tar.gz
- ??? ??? ????? ???? make? ?? ????? ????.
- cd ipcctv-fb
- make
- ??? ??? ?? ??? ???? ????.
- (?????? ????.)
- ./ipcam
47Web Camera ?? Sample (1)
- bool V4L_Open(Video4Linux video4linux, char
device_name) - V4L device open
- ? ?? ??? video4linux? ?????.
- ? ?? ??? ????? ?? video device??. ????
/dev/video0? ????. - ??? ??? ??, true? ????.
- bool V4L_Close(Video4Linux video4linux)
- V4L device close
- ? ?? ??? video4linux? ?????.
- ??? ??? ??, true? ????.
48Web Camera ?? Sample (2)
- bool V4L_SetChannel(Video4Linux self, int
channel_no, - int video_type, int video_mode)
- ?? ?? ?? ??
- ? ?? ??? video4linux? ?????.
- ? ?? ??? ????? ?? ??? ????.
- ? ?? ??? ??? ????.
- VIDEO_TYPE_TV TV ??
- VIDEO_TYPE_CAMERA Camera ??
- ? ?? ??? ??? ????.
- VIDEO_MODE_PAL PAL ??
- VIDEO_MODE_NTSC NTSC ??
- VIDEO_MODE_SECAM SECAM ??
- VIDEO_MODE_AUTO ?? ??
49Web Camera ?? Sample (3)
- bool V4L_SetPicture(Video4Linux self, int
brightness, int hue, - int colour, int contrast, int whiteness, int
depth, int palette) - ??????? ??? ??? ???? ??
- ? ?? ??? video4linux? ?????.
- ? ?? ??? ??, ? ?? ??? ??(hue), ? ?? ??? ?(color),
?? ?? ??? ??(contrast), ?? ?? ??? ???(whiteness),
?? ?? ??? capture depth??. - V4L_NOSET ?? 065535??? ?? ? ? ? ??.
- ??? ??? ????? ??? ???? ????.
- VIDEO_PALETTE_GREY 0255? ???? ???? ??? ???
- VIDEO_PALETTE_RGB565 RGB565? 16?? ??? ??
- VIDEO_PALETTE_RGB555 RGB555? 16?? ??? ??
- VIDEO_PALETTE_RGB24 RGB888? 24?? ??? ??
- VIDEO_PALETTE_YUV420 YUV420 ??
- VIDEO_PALETTE_YUV411 YUV411 ??
-
50Web Camera ?? Sample (4)
- bool V4L_SimpleCapture(Video4Linux self, int
frame, int width, - int height)
- ??? ????? ??? ??? ???? ??
- ? ?? ??? video4linux? ?????.
- ? ?? ??? ??? ??? ????.
- ? ??, ? ?? ??? ??? ???? ??? ????.
- ???? ?? ?? true??.
- unsigned char V4L_GetFrame(Video4Linux self)
- SimpleCapture()? ??? ??? ??? ???? ?? ???? ?? ??.
51??? (1)
52??? (2)