source: rtems/c/src/lib/libbsp/arm/nds/fb/fb.c @ c193baad

4.104.11
Last change on this file since c193baad was c193baad, checked in by Thomas Doerfler <Thomas.Doerfler@…>, on Apr 9, 2010 at 8:24:57 PM

unify irq data types and code, merge s3c2400/s3c2410 support

  • Property mode set to 100644
File size: 5.1 KB
Line 
1/*
2 * RTEMS for Nintendo DS framebuffer display driver.
3 *
4 * Copyright (c) 2008 by Matthieu Bucchianeri <mbucchia@gmail.com>
5 *
6 * The license and distribution terms for this file may be
7 * found in the file LICENSE in this distribution or at
8 *
9 * http://www.rtems.com/license/LICENSE
10 *
11 * $Id$
12 */
13
14#include <stdlib.h>
15#include <stdio.h>
16#include <errno.h>
17#include <sys/types.h>
18
19#include <bsp.h>
20#include <rtems/irq.h>
21#include <rtems/libio.h>
22#include <nds.h>
23
24#include <rtems/fb.h>
25
26
27/*
28 * screen information for the driver (fb0).
29 */
30
31static struct fb_var_screeninfo fb_var_info = {
32  .xres                = SCREEN_WIDTH,          /* screen size x, y  */
33  .yres                = SCREEN_HEIGHT,
34  .bits_per_pixel      = 16                     /* bits per pixel    */
35};
36
37static struct fb_fix_screeninfo fb_fix_info = {
38  .smem_start          = (void *) VRAM_A,            /* buffer pointer    */
39  .smem_len            = 0x18000,                    /* buffer size       */
40  .type                = FB_TYPE_PACKED_PIXELS,      /* type of dsplay    */
41  .visual              = FB_VISUAL_TRUECOLOR,        /* color scheme used */
42  .line_length         = SCREEN_WIDTH               /* pixels per line (redundant with xres ?) */
43};
44
45/*
46 * screen information for the driver (fb1).
47 */
48
49static struct fb_var_screeninfo fb_var_info2 = {
50  .xres                = SCREEN_WIDTH,          /* screen size x, y  */
51  .yres                = SCREEN_HEIGHT,
52  .bits_per_pixel      = 16                     /* bits per pixel    */
53};
54
55static struct fb_fix_screeninfo fb_fix_info2 = {
56  .smem_start          = (void *) VRAM_B,            /* buffer pointer    */
57  .smem_len            = 0x18000,                    /* buffer size       */
58  .type                = FB_TYPE_PACKED_PIXELS,      /* type of dsplay    */
59  .visual              = FB_VISUAL_TRUECOLOR,        /* color scheme used */
60  .line_length         = SCREEN_WIDTH               /* pixels per line (redundant with xres ?) */
61};
62
63
64/*
65 * fbds device driver initialize entry point.
66 */
67
68rtems_device_driver
69frame_buffer_initialize (rtems_device_major_number major,
70                 rtems_device_minor_number minor, void *arg)
71{
72  rtems_status_code status;
73
74  printk ("[+] framebuffer started\n");
75
76  /* register the devices */
77  status = rtems_io_register_name ("/dev/fb0", major, 0);
78  if (status != RTEMS_SUCCESSFUL) {
79    printk ("[!] error registering framebuffer\n");
80    rtems_fatal_error_occurred (status);
81  }
82  status = rtems_io_register_name ("/dev/fb1", major, 1);
83  if (status != RTEMS_SUCCESSFUL) {
84    printk ("[!] error registering framebuffer\n");
85    rtems_fatal_error_occurred (status);
86  }
87  return RTEMS_SUCCESSFUL;
88}
89
90/*
91 * fbds device driver open operation.
92 */
93
94rtems_device_driver
95frame_buffer_open (rtems_device_major_number major,
96           rtems_device_minor_number minor, void *arg)
97{
98   printk ("[#] entering graphic mode on fb%d\n", minor);
99   if (!minor) {
100      videoSetMode (MODE_FB0);
101      vramSetBankA (VRAM_A_LCD);
102      memset ((void *)fb_fix_info.smem_start, 0, fb_fix_info.smem_len);
103   } else {
104      videoSetModeSub (MODE_FB0);
105      vramSetBankB (VRAM_B_LCD);
106      memset ((void *)fb_fix_info2.smem_start, 0, fb_fix_info2.smem_len);
107    }
108  return RTEMS_SUCCESSFUL;
109}
110
111/*
112 * fbds device driver close operation.
113 */
114
115rtems_device_driver
116frame_buffer_close (rtems_device_major_number major,
117            rtems_device_minor_number minor, void *arg)
118{
119  printk ("[#] leaving graphic mode on fb%d\n", minor);
120  if (!minor) {
121      memset ((void *)fb_fix_info.smem_start, 0, fb_fix_info.smem_len);
122  }
123  else {
124      memset ((void *)fb_fix_info2.smem_start, 0, fb_fix_info2.smem_len);
125      /* back to console */
126      videoSetModeSub (MODE_0_2D | DISPLAY_BG0_ACTIVE);
127      vramSetBankC (VRAM_C_SUB_BG);
128  }
129
130  return RTEMS_SUCCESSFUL;
131}
132
133/*
134 * fbds device driver read operation.
135 */
136
137rtems_device_driver
138frame_buffer_read (rtems_device_major_number major,
139           rtems_device_minor_number minor, void *arg)
140{
141  rtems_libio_rw_args_t *rw_args = (rtems_libio_rw_args_t *) arg;
142  rw_args->bytes_moved = 0;
143
144  return RTEMS_SUCCESSFUL;
145}
146
147/*
148 * fbds device driver write operation.
149 */
150
151rtems_device_driver
152frame_buffer_write (rtems_device_major_number major,
153            rtems_device_minor_number minor, void *arg)
154{
155  rtems_libio_rw_args_t *rw_args = (rtems_libio_rw_args_t *) arg;
156  rw_args->bytes_moved = 0;
157
158  return RTEMS_SUCCESSFUL;
159}
160
161/*
162 * ioctl entry point.
163 */
164
165rtems_device_driver
166frame_buffer_control (rtems_device_major_number major,
167              rtems_device_minor_number minor, void *arg)
168{
169  rtems_libio_ioctl_args_t *args = arg;
170
171  /* XXX check minor */
172
173  switch (args->command) {
174  case FBIOGET_VSCREENINFO:
175    memcpy (args->buffer, minor ? &fb_var_info2 : &fb_var_info, sizeof (fb_var_info));
176    args->ioctl_return = 0;
177    break;
178  case FBIOGET_FSCREENINFO:
179    memcpy (args->buffer, minor ? &fb_fix_info2 : &fb_fix_info, sizeof (fb_fix_info));
180    args->ioctl_return = 0;
181    break;
182  case FBIOGETCMAP:
183    args->ioctl_return = 0;     /* XXX */
184    break;
185  case FBIOPUTCMAP:
186    args->ioctl_return = 0;     /* XXX */
187    break;
188
189    /* no break on purpose */
190  default:
191    args->ioctl_return = 0;
192    break;
193
194  }
195  return RTEMS_SUCCESSFUL;
196}
Note: See TracBrowser for help on using the repository browser.