[152b1e3] | 1 | /* |
---|
| 2 | ///////////////////////////////////////////////////////////////////////////// |
---|
| 3 | // $Header$ |
---|
| 4 | // |
---|
| 5 | // Copyright (c) 2000 - Rosimildo da Silva |
---|
| 6 | // |
---|
| 7 | // MODULE DESCRIPTION: |
---|
| 8 | // Wrapper API around the ioctls calls for the Micro FrameBuffer |
---|
| 9 | // interface for Embedded Systems |
---|
| 10 | // |
---|
| 11 | // All functions returns 0 on success. Any other value should be |
---|
| 12 | // decoded as an error. A list of errors will be created over time. |
---|
| 13 | // |
---|
| 14 | // MODIFICATION/HISTORY: |
---|
| 15 | // |
---|
| 16 | // $Log$ |
---|
[550c3df7] | 17 | // Revision 1.1 2000/08/30 08:21:24 joel |
---|
| 18 | // 2000-08-26 Rosimildo da Silva <rdasilva@connecttel.com> |
---|
| 19 | // |
---|
| 20 | // * Added generic Micro FrameBuffer interface for MicroWindows. |
---|
| 21 | // This interface allows MicroWindows to under RTEMS. A sample |
---|
| 22 | // driver has been developed for the pc386 BSP. See |
---|
| 23 | // pc386/fb_vga.c as a sample. |
---|
| 24 | // * Added Uniform Input Device interface for MicroWindows. |
---|
| 25 | // See PC386 bsp for sample drivers for mouse and keyboard (console). |
---|
| 26 | // * mw-bf: New directory. |
---|
| 27 | // * Makefile.am, configure.in, wrapup/Makefile.am: Account for mw-fb. |
---|
| 28 | // * mw-fb/Makefile.am: New file. |
---|
| 29 | // * mw-fb/mw_fb.c: New file. |
---|
| 30 | // * mw-fb/mw_fb.h: New file. |
---|
| 31 | // * mw-fb/mw_uid.c: New file. |
---|
| 32 | // * mw-fb/mw_uid.h: New file. |
---|
| 33 | // |
---|
[152b1e3] | 34 | // |
---|
| 35 | ///////////////////////////////////////////////////////////////////////////// |
---|
| 36 | */ |
---|
| 37 | |
---|
[550c3df7] | 38 | #ifdef HAVE_CONFIG_H |
---|
| 39 | #include "config.h" |
---|
| 40 | #endif |
---|
| 41 | |
---|
[152b1e3] | 42 | #include <sys/ioctl.h> |
---|
| 43 | #include <rtems/mw_fb.h> |
---|
| 44 | |
---|
| 45 | |
---|
| 46 | /* |
---|
| 47 | * This function returns the information regarding the display. |
---|
| 48 | * It is called just after the driver be opened to get all needed |
---|
| 49 | * information about the driver. No change in the mode of operation |
---|
| 50 | * of the driver is done with this call. |
---|
| 51 | */ |
---|
| 52 | int ufb_get_screen_info( int fd, struct fb_screeninfo *info ) |
---|
| 53 | { |
---|
| 54 | return ioctl( fd, FB_SCREENINFO, ( void *)info); |
---|
| 55 | } |
---|
| 56 | |
---|
| 57 | |
---|
| 58 | |
---|
| 59 | /* |
---|
| 60 | * Returns the mode of the graphics subsystem |
---|
| 61 | */ |
---|
| 62 | int ufb_get_mode( int fd, int *mode ) |
---|
| 63 | { |
---|
| 64 | struct fb_exec_function exec; |
---|
| 65 | exec.func_no = FB_FUNC_GET_MODE; |
---|
| 66 | exec.param = ( void *)mode; |
---|
| 67 | return ioctl( fd, FB_EXEC_FUNCTION , ( void *)&exec ); |
---|
| 68 | } |
---|
| 69 | |
---|
| 70 | |
---|
| 71 | /* |
---|
| 72 | * Returns the current collor pallete |
---|
| 73 | */ |
---|
| 74 | int ufb_get_palette( int fd, struct fb_cmap *color ) |
---|
| 75 | { |
---|
| 76 | return ioctl( fd, FB_GETPALETTE, ( void *)color ); |
---|
| 77 | } |
---|
| 78 | |
---|
| 79 | |
---|
| 80 | /* |
---|
| 81 | * Set the current collor pallete |
---|
| 82 | */ |
---|
| 83 | int ufb_set_palette( int fd, struct fb_cmap *color ) |
---|
| 84 | { |
---|
| 85 | return ioctl( fd, FB_SETPALETTE, ( void *)color ); |
---|
| 86 | } |
---|
| 87 | |
---|
| 88 | /* |
---|
| 89 | * Does all necessary initialization to put the device in |
---|
| 90 | * graphics mode |
---|
| 91 | */ |
---|
| 92 | int ufb_enter_graphics( int fd, int mode ) |
---|
| 93 | { |
---|
| 94 | struct fb_exec_function exec; |
---|
| 95 | exec.func_no = FB_FUNC_ENTER_GRAPHICS; |
---|
| 96 | exec.param = ( void *)mode; |
---|
| 97 | return ioctl( fd, FB_EXEC_FUNCTION , ( void *)&exec ); |
---|
| 98 | } |
---|
| 99 | |
---|
| 100 | |
---|
| 101 | /* |
---|
| 102 | * Switch the device back to the default mode of operation. |
---|
| 103 | * In most cases it put the device back to plain text mode. |
---|
| 104 | */ |
---|
| 105 | int ufb_exit_graphics( int fd ) |
---|
| 106 | { |
---|
| 107 | struct fb_exec_function exec; |
---|
| 108 | exec.func_no = FB_FUNC_EXIT_GRAPHICS; |
---|
| 109 | exec.param = 0; |
---|
| 110 | return ioctl( fd, FB_EXEC_FUNCTION , ( void *)&exec ); |
---|
| 111 | } |
---|
| 112 | |
---|
| 113 | /* |
---|
| 114 | * Tell the driver that the "virtual buffer" is dirty, and an update |
---|
| 115 | * of it to the real device, maybe a serial/parallel LCD or whatever |
---|
| 116 | * is required |
---|
| 117 | */ |
---|
| 118 | int ufb_buffer_is_dirty( int fd ) |
---|
| 119 | { |
---|
| 120 | struct fb_exec_function exec; |
---|
| 121 | exec.func_no = FB_FUNC_IS_DIRTY; |
---|
| 122 | exec.param = 0; |
---|
| 123 | return ioctl( fd, FB_EXEC_FUNCTION , ( void *)&exec ); |
---|
| 124 | } |
---|
| 125 | |
---|
| 126 | |
---|
| 127 | |
---|
| 128 | /* |
---|
| 129 | * This function maps the physical ( kernel mode ) address of the framebuffer device |
---|
| 130 | * and maps it to the user space address. |
---|
| 131 | */ |
---|
| 132 | int ufb_mmap_to_user_space( int fd, void **fb_addr, void *physical_addr, unsigned long size ) |
---|
| 133 | { |
---|
| 134 | #ifdef __rtems__ |
---|
| 135 | /* RTEMS runs in ring 0, and there is no distinction between |
---|
| 136 | user space and kernel space, so we just return the same |
---|
| 137 | pointer to the caller. |
---|
| 138 | */ |
---|
| 139 | *fb_addr = physical_addr; |
---|
| 140 | return 0; |
---|
| 141 | #else |
---|
| 142 | /* other kernels might want to map it to the user space, |
---|
| 143 | maybe using mmap() |
---|
| 144 | */ |
---|
| 145 | return 0; |
---|
| 146 | #endif |
---|
| 147 | |
---|
| 148 | } |
---|
| 149 | |
---|
| 150 | |
---|
| 151 | /* |
---|
| 152 | * This function unmaps memory of the FB from the user's space |
---|
| 153 | */ |
---|
| 154 | int ufb_unmmap_from_user_space( int fd, void *addr ) |
---|
| 155 | { |
---|
| 156 | return 0; |
---|
| 157 | } |
---|
| 158 | |
---|