source: rtems/bsps/arm/raspberrypi/console/fbcons.c @ d7d66d7

Last change on this file since d7d66d7 was d7d66d7, checked in by Sebastian Huber <sebastian.huber@…>, on Apr 19, 2018 at 4:28:01 AM

bsps: Move console drivers to bsps

This patch is a part of the BSP source reorganization.

Update #3285.

  • Property mode set to 100644
File size: 3.3 KB
Line 
1/**
2 * @file
3 *
4 * @ingroup raspberrypi_console
5 *
6 * @brief framebuffer graphic console support.
7 */
8
9/*
10 * Copyright (c) 2015 Yang Qiao
11 *
12 *  The license and distribution terms for this file may be
13 *  found in the file LICENSE in this distribution or at
14 *
15 *  http://www.rtems.org/license/LICENSE
16 *
17 */
18
19#include <rtems.h>
20#include <rtems/libio.h>
21
22#include <stdlib.h>
23
24#include <libchip/serial.h>
25#include <libchip/sersupp.h>
26
27#include <bsp.h>
28#include <bsp/fbcons.h>
29#include <bsp/vc.h>
30#include <bsp/rpi-fb.h>
31
32/*
33 *  fbcons_init
34 *
35 *  This function initializes the fb console to a quiecsent state.
36 */
37static void fbcons_init( int minor )
38{
39}
40
41/*
42 *  fbcons_open
43 *
44 *  This function opens a port for communication.
45 *
46 *  Default state is 9600 baud, 8 bits, No parity, and 1 stop bit.
47 */
48static int fbcons_open(
49  int   major,
50  int   minor,
51  void *arg
52)
53{
54  return RTEMS_SUCCESSFUL;
55}
56
57/*
58 *  fbcons_close
59 *
60 *  This function shuts down the requested port.
61 */
62static int fbcons_close(
63  int   major,
64  int   minor,
65  void *arg
66)
67{
68  return ( RTEMS_SUCCESSFUL );
69}
70
71/*
72 *  fbcons_write_polled
73 *
74 *  This routine polls out the requested character.
75 */
76static void fbcons_write_polled(
77  int  minor,
78  char c
79)
80{
81  rpi_fb_outch( c );
82
83  if ( c == '\n' )
84    rpi_fb_outch( '\r' );            /* LF = LF + CR */
85}
86
87/*
88 *  fbcons_write_support_polled
89 *
90 *  Console Termios output entry point when using polled output.
91 *
92 */
93static ssize_t fbcons_write_support_polled(
94  int         minor,
95  const char *buf,
96  size_t      len
97)
98{
99  int nwrite = 0;
100
101  /*
102   * poll each byte in the string out of the port.
103   */
104  while ( nwrite < len ) {
105    fbcons_write_polled( minor, *buf++ );
106    nwrite++;
107  }
108
109  /*
110   * return the number of bytes written.
111   */
112  return nwrite;
113}
114
115/*
116 *  fbcons_inbyte_nonblocking_polled
117 *
118 *  Console Termios polling input entry point.
119 */
120static int fbcons_inbyte_nonblocking_polled( int minor )
121{
122  // if( rtems_kbpoll() ) {
123  //   int c = getch();
124  //   return c;
125  // }
126
127  return -1;
128}
129
130/*
131 *  fbcons_set_attributes
132 *
133 *  This function sets the UART channel to reflect the requested termios
134 *  port settings.
135 */
136static int fbcons_set_attributes(
137  int                   minor,
138  const struct termios *t
139)
140{
141  return 0;
142}
143
144bool fbcons_probe( int minor )
145{
146  // rtems_status_code status;
147  static bool firstTime = true;
148  static bool ret = false;
149
150  /*
151   *  keyboard interrupt should be registered when the keyboard is available
152   */
153  if ( firstTime ) {
154    if ( !rpi_fb_hdmi_is_present() ) {
155      ret = false;
156    } else {
157      ret = true;
158    }
159  }
160
161  firstTime = false;
162
163  return ret;
164}
165
166const console_fns fbcons_fns =
167{
168  .deviceProbe = libchip_serial_default_probe,     /* deviceProbe */
169  .deviceFirstOpen = fbcons_open,                 /* deviceFirstOpen */
170  .deviceLastClose = fbcons_close,                /* deviceLastClose */
171  .deviceRead = fbcons_inbyte_nonblocking_polled, /* deviceRead */
172  .deviceWrite = fbcons_write_support_polled,     /* deviceWrite */
173  .deviceInitialize = fbcons_init,                /* deviceInitialize */
174  .deviceWritePolled = fbcons_write_polled,       /* deviceWritePolled */
175  .deviceSetAttributes = fbcons_set_attributes,   /* deviceSetAttributes */
176  .deviceOutputUsesInterrupts = FALSE,           /* deviceOutputUsesInterrupts*/
177};
Note: See TracBrowser for help on using the repository browser.