source: rtems/c/src/lib/libbsp/i386/pc386/console/fb_vga.c @ cd62f7a

4.104.115
Last change on this file since cd62f7a was cd62f7a, checked in by Joel Sherrill <joel.sherrill@…>, on 07/24/09 at 13:28:44

2009-07-24 Roxana Leontie <roxana.leontie@…>

  • console/fb_vga.c: divided fb_screeninfo structure into fb_var_screeninfo and fb_fix_screeninfo; same with get_screen_info
  • Property mode set to 100644
File size: 6.1 KB
Line 
1/*
2 * Copyright (c) 2000 - Rosimildo da Silva ( rdasilva@connecttel.com )
3 *
4 * MODULE DESCRIPTION:
5 * This module implements the micro FB driver for "Bare VGA". It uses the
6 * routines for "bare hardware" that comes with MicroWindows.
7 *
8 *  $Id$
9 *
10 */
11
12#include <stdlib.h>
13#include <stdio.h>
14#include <errno.h>
15#include <sys/types.h>
16
17#include <bsp.h>
18#include <bsp/irq.h>
19#include <rtems/libio.h>
20
21#include <rtems/mw_fb.h>
22
23/* these routines are defined in the microwindows code. This
24   driver is here more as an example of how to implement and
25   use the micro FB interface
26*/
27extern void ega_hwinit( void );
28extern void ega_hwterm( void );
29
30/* screen information for the VGA driver */
31static struct fb_var_screeninfo fb_var =
32{
33   640, 480,                     /* screen size x, y  */
34   4                             /* bits per pixel    */
35};
36
37static struct fb_fix_screeninfo fb_fix =
38{
39   (volatile char *)0xA0000,     /* buffer pointer    */
40   0x10000,                      /* buffer size       */
41   FB_TYPE_VGA_PLANES,           /* type of dsplay    */
42   FB_VISUAL_PSEUDOCOLOR,        /* color scheme used */
43   80                            /* chars per line    */
44};
45
46static uint16_t red16[] = {
47    0x0000, 0x0000, 0x0000, 0x0000, 0xaaaa, 0xaaaa, 0xaaaa, 0xaaaa,
48    0x5555, 0x5555, 0x5555, 0x5555, 0xffff, 0xffff, 0xffff, 0xffff
49};
50static uint16_t green16[] = {
51    0x0000, 0x0000, 0xaaaa, 0xaaaa, 0x0000, 0x0000, 0x5555, 0xaaaa,
52    0x5555, 0x5555, 0xffff, 0xffff, 0x5555, 0x5555, 0xffff, 0xffff
53};
54static uint16_t blue16[] = {
55    0x0000, 0xaaaa, 0x0000, 0xaaaa, 0x0000, 0xaaaa, 0x0000, 0xaaaa,
56    0x5555, 0xffff, 0x5555, 0xffff, 0x5555, 0xffff, 0x5555, 0xffff
57};
58
59/*
60 * fbvga device driver INITIALIZE entry point.
61 */
62rtems_device_driver
63fbvga_initialize(  rtems_device_major_number major,
64                   rtems_device_minor_number minor,
65                   void                      *arg)
66{
67   rtems_status_code status;
68
69  printk( "FBVGA -- driver initializing..\n" );
70  /*
71   * Register the device
72   */
73  status = rtems_io_register_name ("/dev/fb0", major, 0);
74  if (status != RTEMS_SUCCESSFUL)
75  {
76      printk("Error registering FBVGA device!\n");
77      rtems_fatal_error_occurred( status );
78  }
79  return RTEMS_SUCCESSFUL;
80}
81
82/*
83 * fbvga device driver OPEN entry point
84 */
85rtems_device_driver
86fbvga_open( rtems_device_major_number major,
87            rtems_device_minor_number minor,
88            void                      *arg)
89{
90/*  rtems_status_code status; */
91  printk( "FBVGA open called.\n" );
92  return RTEMS_SUCCESSFUL;
93}
94
95/*
96 * fbvga device driver CLOSE entry point
97 */
98rtems_device_driver
99fbvga_close(rtems_device_major_number major,
100            rtems_device_minor_number minor,
101            void                      *arg)
102{
103  printk( "FBVGA close called.\n" );
104  return RTEMS_SUCCESSFUL;
105}
106
107/*
108 * fbvga device driver READ entry point.
109 * Read characters from the PS/2 mouse.
110 */
111rtems_device_driver
112fbvga_read( rtems_device_major_number major,
113            rtems_device_minor_number minor,
114            void                      *arg)
115{
116  rtems_libio_rw_args_t *rw_args = (rtems_libio_rw_args_t *)arg;
117  printk( "FBVGA read called.\n" );
118  rw_args->bytes_moved = 0;
119  return RTEMS_SUCCESSFUL;
120}
121
122/*
123 * fbvga device driver WRITE entry point.
124 * Write characters to the PS/2 mouse.
125 */
126rtems_device_driver
127fbvga_write( rtems_device_major_number major,
128             rtems_device_minor_number minor,
129             void                    * arg)
130{
131  rtems_libio_rw_args_t *rw_args = (rtems_libio_rw_args_t *)arg;
132  printk( "FBVGA write called.\n" );
133  rw_args->bytes_moved = 0;
134  return RTEMS_SUCCESSFUL;
135}
136
137static int get_fix_screen_info( struct fb_fix_screeninfo *info )
138{
139  *info = fb_fix;
140  return 0;
141}
142
143static int get_var_screen_info( struct fb_var_screeninfo *info )
144{
145  *info = fb_var;
146  return 0;
147}
148
149static int get_palette( struct fb_cmap *cmap )
150{
151  uint32_t i;
152
153  if( cmap->start + cmap->len >= 16 )
154      return 1;
155
156  for( i = 0; i < cmap->len; i++ )
157  {
158    cmap->red[ cmap->start + i ]   = red16[ cmap->start + i ];
159    cmap->green[ cmap->start + i ] = green16[ cmap->start + i ];
160    cmap->blue[ cmap->start + i ]  = blue16[ cmap->start + i ];
161  }
162  return 0;
163}
164
165static int set_palette( struct fb_cmap *cmap )
166{
167  uint32_t i;
168
169  if( cmap->start + cmap->len >= 16 )
170      return 1;
171
172  for( i = 0; i < cmap->len; i++ )
173  {
174    red16[ cmap->start + i ] = cmap->red[ cmap->start + i ];
175    green16[ cmap->start + i ] = cmap->green[ cmap->start + i ];
176    blue16[ cmap->start + i ] = cmap->blue[ cmap->start + i ];
177  }
178  return 0;
179}
180
181/*
182 * IOCTL entry point -- This method is called to carry
183 * all services of this interface.
184 */
185rtems_device_driver
186fbvga_control( rtems_device_major_number major,
187               rtems_device_minor_number minor,
188               void                      * arg
189)
190{
191        rtems_libio_ioctl_args_t *args = arg;
192   printk( "FBVGA ioctl called, cmd=%x\n", args->command  );
193   switch( args->command )
194   {
195      case FBIOGET_FSCREENINFO:
196      args->ioctl_return =  get_fix_screen_info( args->buffer );
197      break;
198      case FBIOGET_VSCREENINFO:
199      args->ioctl_return =  get_var_screen_info( args->buffer );
200      break;
201      case FBIOPUT_VSCREENINFO:
202      /* not implemented yet*/
203      break;
204      case FBIOGETCMAP:
205      args->ioctl_return =  get_palette( args->buffer );
206      break;
207      case FBIOPUTCMAP:
208      args->ioctl_return =  set_palette( args->buffer );
209      break;
210
211      /* this function would execute one of the routines of the
212       * interface based on the operation requested
213       */
214      case FB_EXEC_FUNCTION:
215      {
216         struct fb_exec_function *env = args->buffer;
217         switch( env->func_no )
218         {
219           case FB_FUNC_ENTER_GRAPHICS:
220           /* enter graphics mode*/
221           ega_hwinit();
222           break;
223
224           case FB_FUNC_EXIT_GRAPHICS:
225           /* leave graphics mode*/
226           ega_hwterm();
227           break;
228
229           case FB_FUNC_IS_DIRTY:
230           break;
231
232           case FB_FUNC_GET_MODE:
233           break;
234
235           default:
236           break;
237         }
238      }
239      /* no break on purpose */
240           default:
241      args->ioctl_return = 0;
242                break;
243
244   }
245   return RTEMS_SUCCESSFUL;
246}
Note: See TracBrowser for help on using the repository browser.