[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$ |
---|
| 17 | // |
---|
| 18 | ///////////////////////////////////////////////////////////////////////////// |
---|
| 19 | */ |
---|
| 20 | |
---|
| 21 | #include <sys/ioctl.h> |
---|
| 22 | #include <rtems/mw_fb.h> |
---|
| 23 | |
---|
| 24 | |
---|
| 25 | /* |
---|
| 26 | * This function returns the information regarding the display. |
---|
| 27 | * It is called just after the driver be opened to get all needed |
---|
| 28 | * information about the driver. No change in the mode of operation |
---|
| 29 | * of the driver is done with this call. |
---|
| 30 | */ |
---|
| 31 | int ufb_get_screen_info( int fd, struct fb_screeninfo *info ) |
---|
| 32 | { |
---|
| 33 | return ioctl( fd, FB_SCREENINFO, ( void *)info); |
---|
| 34 | } |
---|
| 35 | |
---|
| 36 | |
---|
| 37 | |
---|
| 38 | /* |
---|
| 39 | * Returns the mode of the graphics subsystem |
---|
| 40 | */ |
---|
| 41 | int ufb_get_mode( int fd, int *mode ) |
---|
| 42 | { |
---|
| 43 | struct fb_exec_function exec; |
---|
| 44 | exec.func_no = FB_FUNC_GET_MODE; |
---|
| 45 | exec.param = ( void *)mode; |
---|
| 46 | return ioctl( fd, FB_EXEC_FUNCTION , ( void *)&exec ); |
---|
| 47 | } |
---|
| 48 | |
---|
| 49 | |
---|
| 50 | /* |
---|
| 51 | * Returns the current collor pallete |
---|
| 52 | */ |
---|
| 53 | int ufb_get_palette( int fd, struct fb_cmap *color ) |
---|
| 54 | { |
---|
| 55 | return ioctl( fd, FB_GETPALETTE, ( void *)color ); |
---|
| 56 | } |
---|
| 57 | |
---|
| 58 | |
---|
| 59 | /* |
---|
| 60 | * Set the current collor pallete |
---|
| 61 | */ |
---|
| 62 | int ufb_set_palette( int fd, struct fb_cmap *color ) |
---|
| 63 | { |
---|
| 64 | return ioctl( fd, FB_SETPALETTE, ( void *)color ); |
---|
| 65 | } |
---|
| 66 | |
---|
| 67 | /* |
---|
| 68 | * Does all necessary initialization to put the device in |
---|
| 69 | * graphics mode |
---|
| 70 | */ |
---|
| 71 | int ufb_enter_graphics( int fd, int mode ) |
---|
| 72 | { |
---|
| 73 | struct fb_exec_function exec; |
---|
| 74 | exec.func_no = FB_FUNC_ENTER_GRAPHICS; |
---|
| 75 | exec.param = ( void *)mode; |
---|
| 76 | return ioctl( fd, FB_EXEC_FUNCTION , ( void *)&exec ); |
---|
| 77 | } |
---|
| 78 | |
---|
| 79 | |
---|
| 80 | /* |
---|
| 81 | * Switch the device back to the default mode of operation. |
---|
| 82 | * In most cases it put the device back to plain text mode. |
---|
| 83 | */ |
---|
| 84 | int ufb_exit_graphics( int fd ) |
---|
| 85 | { |
---|
| 86 | struct fb_exec_function exec; |
---|
| 87 | exec.func_no = FB_FUNC_EXIT_GRAPHICS; |
---|
| 88 | exec.param = 0; |
---|
| 89 | return ioctl( fd, FB_EXEC_FUNCTION , ( void *)&exec ); |
---|
| 90 | } |
---|
| 91 | |
---|
| 92 | /* |
---|
| 93 | * Tell the driver that the "virtual buffer" is dirty, and an update |
---|
| 94 | * of it to the real device, maybe a serial/parallel LCD or whatever |
---|
| 95 | * is required |
---|
| 96 | */ |
---|
| 97 | int ufb_buffer_is_dirty( int fd ) |
---|
| 98 | { |
---|
| 99 | struct fb_exec_function exec; |
---|
| 100 | exec.func_no = FB_FUNC_IS_DIRTY; |
---|
| 101 | exec.param = 0; |
---|
| 102 | return ioctl( fd, FB_EXEC_FUNCTION , ( void *)&exec ); |
---|
| 103 | } |
---|
| 104 | |
---|
| 105 | |
---|
| 106 | |
---|
| 107 | /* |
---|
| 108 | * This function maps the physical ( kernel mode ) address of the framebuffer device |
---|
| 109 | * and maps it to the user space address. |
---|
| 110 | */ |
---|
| 111 | int ufb_mmap_to_user_space( int fd, void **fb_addr, void *physical_addr, unsigned long size ) |
---|
| 112 | { |
---|
| 113 | #ifdef __rtems__ |
---|
| 114 | /* RTEMS runs in ring 0, and there is no distinction between |
---|
| 115 | user space and kernel space, so we just return the same |
---|
| 116 | pointer to the caller. |
---|
| 117 | */ |
---|
| 118 | *fb_addr = physical_addr; |
---|
| 119 | return 0; |
---|
| 120 | #else |
---|
| 121 | /* other kernels might want to map it to the user space, |
---|
| 122 | maybe using mmap() |
---|
| 123 | */ |
---|
| 124 | return 0; |
---|
| 125 | #endif |
---|
| 126 | |
---|
| 127 | } |
---|
| 128 | |
---|
| 129 | |
---|
| 130 | /* |
---|
| 131 | * This function unmaps memory of the FB from the user's space |
---|
| 132 | */ |
---|
| 133 | int ufb_unmmap_from_user_space( int fd, void *addr ) |
---|
| 134 | { |
---|
| 135 | return 0; |
---|
| 136 | } |
---|
| 137 | |
---|