Subdirectory provided by Embedded Artists
Dependencies: DM_FATFileSystem DM_HttpServer DM_USBHost EthernetInterface USBDevice mbed-rpc mbed-rtos mbed-src
Dependents: lpc4088_displaymodule_hello_world_Sept_2018
Fork of DMSupport by
Display/BiosDisplay.cpp@41:ac490f69398f, 2018-10-04 (annotated)
- Committer:
- jmitc91516
- Date:
- Thu Oct 04 08:30:19 2018 +0000
- Revision:
- 41:ac490f69398f
- Parent:
- 39:e1cb4dd9bfeb
To demonstrate a problem with the dm_board_config.h file - the project will not build if it is in its normal place in the root directory, but builds OK if I copy it to the DMSupport subdirectory.
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
embeddedartists | 22:1a58a518435c | 1 | /* |
embeddedartists | 22:1a58a518435c | 2 | * Copyright 2014 Embedded Artists AB |
embeddedartists | 22:1a58a518435c | 3 | * |
embeddedartists | 22:1a58a518435c | 4 | * Licensed under the Apache License, Version 2.0 (the "License"); |
embeddedartists | 22:1a58a518435c | 5 | * you may not use this file except in compliance with the License. |
embeddedartists | 22:1a58a518435c | 6 | * You may obtain a copy of the License at |
embeddedartists | 22:1a58a518435c | 7 | * |
embeddedartists | 22:1a58a518435c | 8 | * http://www.apache.org/licenses/LICENSE-2.0 |
embeddedartists | 22:1a58a518435c | 9 | * |
embeddedartists | 22:1a58a518435c | 10 | * Unless required by applicable law or agreed to in writing, software |
embeddedartists | 22:1a58a518435c | 11 | * distributed under the License is distributed on an "AS IS" BASIS, |
embeddedartists | 22:1a58a518435c | 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
embeddedartists | 22:1a58a518435c | 13 | * See the License for the specific language governing permissions and |
embeddedartists | 22:1a58a518435c | 14 | * limitations under the License. |
embeddedartists | 22:1a58a518435c | 15 | */ |
embeddedartists | 22:1a58a518435c | 16 | |
embeddedartists | 22:1a58a518435c | 17 | #include "mbed.h" |
embeddedartists | 22:1a58a518435c | 18 | #include "BiosDisplay.h" |
embeddedartists | 22:1a58a518435c | 19 | #include "BiosLoader.h" |
embeddedartists | 22:1a58a518435c | 20 | #include "DMBoard.h" |
embeddedartists | 22:1a58a518435c | 21 | #include "bios.h" |
embeddedartists | 22:1a58a518435c | 22 | |
embeddedartists | 22:1a58a518435c | 23 | |
embeddedartists | 22:1a58a518435c | 24 | /****************************************************************************** |
embeddedartists | 22:1a58a518435c | 25 | * Defines and typedefs |
embeddedartists | 22:1a58a518435c | 26 | *****************************************************************************/ |
embeddedartists | 22:1a58a518435c | 27 | |
embeddedartists | 22:1a58a518435c | 28 | |
embeddedartists | 22:1a58a518435c | 29 | /****************************************************************************** |
embeddedartists | 22:1a58a518435c | 30 | * Local variables |
embeddedartists | 22:1a58a518435c | 31 | *****************************************************************************/ |
embeddedartists | 22:1a58a518435c | 32 | |
embeddedartists | 22:1a58a518435c | 33 | |
embeddedartists | 22:1a58a518435c | 34 | /****************************************************************************** |
embeddedartists | 22:1a58a518435c | 35 | * Private Functions |
embeddedartists | 22:1a58a518435c | 36 | *****************************************************************************/ |
embeddedartists | 22:1a58a518435c | 37 | |
embeddedartists | 22:1a58a518435c | 38 | BiosDisplay::BiosDisplay() : |
embeddedartists | 22:1a58a518435c | 39 | _initialized(false), |
embeddedartists | 22:1a58a518435c | 40 | _poweredOn(false), |
embeddedartists | 22:1a58a518435c | 41 | _bios(NULL), |
embeddedartists | 22:1a58a518435c | 42 | _biosData(NULL), |
embeddedartists | 22:1a58a518435c | 43 | _width(0), |
embeddedartists | 22:1a58a518435c | 44 | _height(0), |
embeddedartists | 22:1a58a518435c | 45 | _bpp(0), |
embeddedartists | 22:1a58a518435c | 46 | _supportedRes(0), |
embeddedartists | 22:1a58a518435c | 47 | _activeRes(Res_16bit_rgb565), |
embeddedartists | 22:1a58a518435c | 48 | _landscape(false) |
embeddedartists | 22:1a58a518435c | 49 | { |
embeddedartists | 22:1a58a518435c | 50 | } |
embeddedartists | 22:1a58a518435c | 51 | |
embeddedartists | 22:1a58a518435c | 52 | BiosDisplay::~BiosDisplay() |
embeddedartists | 22:1a58a518435c | 53 | { |
embeddedartists | 22:1a58a518435c | 54 | // _bios and _biosData are deallocated by BiosLoader |
embeddedartists | 22:1a58a518435c | 55 | } |
embeddedartists | 22:1a58a518435c | 56 | |
embeddedartists | 22:1a58a518435c | 57 | |
embeddedartists | 22:1a58a518435c | 58 | /****************************************************************************** |
embeddedartists | 22:1a58a518435c | 59 | * Public Functions |
embeddedartists | 22:1a58a518435c | 60 | *****************************************************************************/ |
embeddedartists | 22:1a58a518435c | 61 | |
embeddedartists | 22:1a58a518435c | 62 | BiosDisplay::DisplayError BiosDisplay::init() |
embeddedartists | 22:1a58a518435c | 63 | { |
embeddedartists | 22:1a58a518435c | 64 | DisplayError err = DisplayError_Ok; |
embeddedartists | 22:1a58a518435c | 65 | if (!_initialized) { |
embeddedartists | 22:1a58a518435c | 66 | do { |
embeddedartists | 22:1a58a518435c | 67 | if (BiosLoader::instance().params(&_bios, &_biosData) != DMBoard::Ok) { |
embeddedartists | 22:1a58a518435c | 68 | err = DisplayError_ConfigError; |
embeddedartists | 22:1a58a518435c | 69 | break; |
embeddedartists | 22:1a58a518435c | 70 | } |
embeddedartists | 22:1a58a518435c | 71 | |
embeddedartists | 22:1a58a518435c | 72 | err = (DisplayError)_bios->displayInit(_biosData); |
embeddedartists | 22:1a58a518435c | 73 | if (err != DisplayError_Ok) { |
embeddedartists | 22:1a58a518435c | 74 | break; |
embeddedartists | 22:1a58a518435c | 75 | } |
embeddedartists | 22:1a58a518435c | 76 | |
embeddedartists | 22:1a58a518435c | 77 | err = (DisplayError)_bios->displayInformation(_biosData, &_width, &_height, &_bpp, &_landscape, &_supportedRes, &_activeRes); |
embeddedartists | 22:1a58a518435c | 78 | if (err != DisplayError_Ok) { |
embeddedartists | 22:1a58a518435c | 79 | break; |
embeddedartists | 22:1a58a518435c | 80 | } |
embeddedartists | 22:1a58a518435c | 81 | |
embeddedartists | 22:1a58a518435c | 82 | _initialized = true; |
embeddedartists | 22:1a58a518435c | 83 | } while(0); |
embeddedartists | 22:1a58a518435c | 84 | } |
embeddedartists | 22:1a58a518435c | 85 | return err; |
embeddedartists | 22:1a58a518435c | 86 | } |
embeddedartists | 22:1a58a518435c | 87 | |
alindvall | 39:e1cb4dd9bfeb | 88 | BiosDisplay::DisplayError BiosDisplay::powerUp(void* framebuffer, Display::Resolution res, FrameRate_t rate) |
embeddedartists | 22:1a58a518435c | 89 | { |
embeddedartists | 22:1a58a518435c | 90 | DisplayError err = DisplayError_Ok; |
embeddedartists | 22:1a58a518435c | 91 | if (!_poweredOn) { |
embeddedartists | 22:1a58a518435c | 92 | err = init(); |
embeddedartists | 22:1a58a518435c | 93 | if (err == DisplayError_Ok) { |
embeddedartists | 22:1a58a518435c | 94 | do { |
alindvall | 39:e1cb4dd9bfeb | 95 | err = (DisplayError)_bios->displayPowerUp(_biosData, framebuffer, (Resolution_t)res, rate); |
embeddedartists | 22:1a58a518435c | 96 | |
embeddedartists | 22:1a58a518435c | 97 | if (err != DisplayError_Ok) { |
embeddedartists | 22:1a58a518435c | 98 | break; |
embeddedartists | 22:1a58a518435c | 99 | } |
embeddedartists | 22:1a58a518435c | 100 | |
embeddedartists | 22:1a58a518435c | 101 | err = (DisplayError)_bios->displayInformation(_biosData, &_width, &_height, &_bpp, &_landscape, &_supportedRes, &_activeRes); |
embeddedartists | 22:1a58a518435c | 102 | if (err != DisplayError_Ok) { |
embeddedartists | 22:1a58a518435c | 103 | break; |
embeddedartists | 22:1a58a518435c | 104 | } |
embeddedartists | 22:1a58a518435c | 105 | |
embeddedartists | 22:1a58a518435c | 106 | _poweredOn = true; |
embeddedartists | 22:1a58a518435c | 107 | } while(0); |
embeddedartists | 22:1a58a518435c | 108 | } |
embeddedartists | 22:1a58a518435c | 109 | } |
embeddedartists | 22:1a58a518435c | 110 | return err; |
embeddedartists | 22:1a58a518435c | 111 | } |
embeddedartists | 22:1a58a518435c | 112 | |
embeddedartists | 22:1a58a518435c | 113 | BiosDisplay::DisplayError BiosDisplay::powerDown() |
embeddedartists | 22:1a58a518435c | 114 | { |
embeddedartists | 22:1a58a518435c | 115 | DisplayError err = DisplayError_Ok; |
embeddedartists | 22:1a58a518435c | 116 | if (_poweredOn) { |
embeddedartists | 22:1a58a518435c | 117 | err = (DisplayError)_bios->displayPowerDown(_biosData); |
embeddedartists | 22:1a58a518435c | 118 | _poweredOn = false; |
embeddedartists | 22:1a58a518435c | 119 | } |
embeddedartists | 22:1a58a518435c | 120 | return err; |
embeddedartists | 22:1a58a518435c | 121 | } |
embeddedartists | 22:1a58a518435c | 122 | |
embeddedartists | 22:1a58a518435c | 123 | BiosDisplay::DisplayError BiosDisplay::backlight(int percent) |
embeddedartists | 22:1a58a518435c | 124 | { |
embeddedartists | 22:1a58a518435c | 125 | DisplayError err = DisplayError_Ok; |
embeddedartists | 22:1a58a518435c | 126 | if (!_initialized) { |
embeddedartists | 22:1a58a518435c | 127 | err = DisplayError_NoInit; |
embeddedartists | 22:1a58a518435c | 128 | } else { |
embeddedartists | 22:1a58a518435c | 129 | err = (DisplayError)_bios->displayBacklight(_biosData, percent); |
embeddedartists | 22:1a58a518435c | 130 | } |
embeddedartists | 22:1a58a518435c | 131 | return err; |
embeddedartists | 22:1a58a518435c | 132 | } |
embeddedartists | 22:1a58a518435c | 133 | |
embeddedartists | 22:1a58a518435c | 134 | uint16_t BiosDisplay::width() |
embeddedartists | 22:1a58a518435c | 135 | { |
embeddedartists | 22:1a58a518435c | 136 | return _width; |
embeddedartists | 22:1a58a518435c | 137 | } |
embeddedartists | 22:1a58a518435c | 138 | |
embeddedartists | 22:1a58a518435c | 139 | uint16_t BiosDisplay::height() |
embeddedartists | 22:1a58a518435c | 140 | { |
embeddedartists | 22:1a58a518435c | 141 | return _height; |
embeddedartists | 22:1a58a518435c | 142 | } |
embeddedartists | 22:1a58a518435c | 143 | |
embeddedartists | 22:1a58a518435c | 144 | uint16_t BiosDisplay::bytesPerPixel() |
embeddedartists | 22:1a58a518435c | 145 | { |
embeddedartists | 22:1a58a518435c | 146 | return _bpp; |
embeddedartists | 22:1a58a518435c | 147 | } |
embeddedartists | 22:1a58a518435c | 148 | |
embeddedartists | 22:1a58a518435c | 149 | uint32_t BiosDisplay::fbSize() |
embeddedartists | 22:1a58a518435c | 150 | { |
embeddedartists | 22:1a58a518435c | 151 | return _width * _height * _bpp; |
embeddedartists | 22:1a58a518435c | 152 | } |
embeddedartists | 22:1a58a518435c | 153 | |
embeddedartists | 22:1a58a518435c | 154 | bool BiosDisplay::landscape() |
embeddedartists | 22:1a58a518435c | 155 | { |
embeddedartists | 22:1a58a518435c | 156 | return _landscape; |
embeddedartists | 22:1a58a518435c | 157 | } |
embeddedartists | 22:1a58a518435c | 158 | |
embeddedartists | 22:1a58a518435c | 159 | void* BiosDisplay::allocateFramebuffer(Display::Resolution res) |
embeddedartists | 22:1a58a518435c | 160 | { |
embeddedartists | 22:1a58a518435c | 161 | if (_initialized) { |
alindvall | 39:e1cb4dd9bfeb | 162 | return malloc(_width*_height*bpp(res)); |
embeddedartists | 22:1a58a518435c | 163 | } |
embeddedartists | 22:1a58a518435c | 164 | return NULL; |
embeddedartists | 22:1a58a518435c | 165 | } |
embeddedartists | 22:1a58a518435c | 166 | |
embeddedartists | 31:d47cffcb0a3e | 167 | void* BiosDisplay::allocateFramebuffers(uint32_t num, Display::Resolution res) |
embeddedartists | 31:d47cffcb0a3e | 168 | { |
embeddedartists | 31:d47cffcb0a3e | 169 | if (_initialized && num>0) { |
alindvall | 39:e1cb4dd9bfeb | 170 | return malloc(_width*_height*bpp(res)*num); |
embeddedartists | 31:d47cffcb0a3e | 171 | } |
embeddedartists | 31:d47cffcb0a3e | 172 | return NULL; |
embeddedartists | 31:d47cffcb0a3e | 173 | } |
embeddedartists | 31:d47cffcb0a3e | 174 | |
embeddedartists | 22:1a58a518435c | 175 | void BiosDisplay::setFramebuffer(void* buff) |
embeddedartists | 22:1a58a518435c | 176 | { |
embeddedartists | 22:1a58a518435c | 177 | LPC_LCD->UPBASE = (uint32_t)buff; |
embeddedartists | 22:1a58a518435c | 178 | } |
embeddedartists | 22:1a58a518435c | 179 | |
embeddedartists | 22:1a58a518435c | 180 | void* BiosDisplay::swapFramebuffer(void* buff) |
embeddedartists | 22:1a58a518435c | 181 | { |
embeddedartists | 22:1a58a518435c | 182 | uint32_t old = LPC_LCD->UPBASE; |
embeddedartists | 22:1a58a518435c | 183 | LPC_LCD->UPBASE = (uint32_t)buff; |
embeddedartists | 22:1a58a518435c | 184 | return (void*)old; |
embeddedartists | 22:1a58a518435c | 185 | } |
embeddedartists | 22:1a58a518435c | 186 | |
embeddedartists | 22:1a58a518435c | 187 | bool BiosDisplay::isSupported(Display::Resolution res) |
embeddedartists | 22:1a58a518435c | 188 | { |
embeddedartists | 22:1a58a518435c | 189 | return (_supportedRes & res); |
embeddedartists | 22:1a58a518435c | 190 | } |
embeddedartists | 22:1a58a518435c | 191 | |
embeddedartists | 22:1a58a518435c | 192 | BiosDisplay::Resolution BiosDisplay::currentResolution() |
embeddedartists | 22:1a58a518435c | 193 | { |
embeddedartists | 22:1a58a518435c | 194 | return (Resolution)_activeRes; |
embeddedartists | 22:1a58a518435c | 195 | } |