| 1 | /* $Id$ |
|---|
| 2 | * $URL$ |
|---|
| 3 | * |
|---|
| 4 | * new framework for display drivers |
|---|
| 5 | * |
|---|
| 6 | * Copyright (C) 2003 Michael Reinelt <michael@reinelt.co.at> |
|---|
| 7 | * Copyright (C) 2004 The LCD4Linux Team <lcd4linux-devel@users.sourceforge.net> |
|---|
| 8 | * |
|---|
| 9 | * This file is part of LCD4Linux. |
|---|
| 10 | * |
|---|
| 11 | * LCD4Linux is free software; you can redistribute it and/or modify |
|---|
| 12 | * it under the terms of the GNU General Public License as published by |
|---|
| 13 | * the Free Software Foundation; either version 2, or (at your option) |
|---|
| 14 | * any later version. |
|---|
| 15 | * |
|---|
| 16 | * LCD4Linux is distributed in the hope that it will be useful, |
|---|
| 17 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
|---|
| 18 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|---|
| 19 | * GNU General Public License for more details. |
|---|
| 20 | * |
|---|
| 21 | * You should have received a copy of the GNU General Public License |
|---|
| 22 | * along with this program; if not, write to the Free Software |
|---|
| 23 | * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. |
|---|
| 24 | * |
|---|
| 25 | */ |
|---|
| 26 | |
|---|
| 27 | /* |
|---|
| 28 | * exported functions: |
|---|
| 29 | * |
|---|
| 30 | * drv_list (void) |
|---|
| 31 | * lists all available drivers to stdout |
|---|
| 32 | * |
|---|
| 33 | * drv_init (char *driver) |
|---|
| 34 | * initializes the named driver |
|---|
| 35 | * |
|---|
| 36 | * int drv_quit (void) |
|---|
| 37 | * de-initializes the driver |
|---|
| 38 | */ |
|---|
| 39 | |
|---|
| 40 | #include "config.h" |
|---|
| 41 | |
|---|
| 42 | #include <stdlib.h> |
|---|
| 43 | #include <stdio.h> |
|---|
| 44 | #include <string.h> |
|---|
| 45 | |
|---|
| 46 | #include "debug.h" |
|---|
| 47 | #include "cfg.h" |
|---|
| 48 | #include "drv.h" |
|---|
| 49 | |
|---|
| 50 | extern DRIVER drv_BeckmannEgle; |
|---|
| 51 | extern DRIVER drv_BWCT; |
|---|
| 52 | extern DRIVER drv_Crystalfontz; |
|---|
| 53 | extern DRIVER drv_Curses; |
|---|
| 54 | extern DRIVER drv_Cwlinux; |
|---|
| 55 | extern DRIVER drv_D4D; |
|---|
| 56 | extern DRIVER drv_EA232graphic; |
|---|
| 57 | extern DRIVER drv_G15; |
|---|
| 58 | extern DRIVER drv_HD44780; |
|---|
| 59 | extern DRIVER drv_Image; |
|---|
| 60 | extern DRIVER drv_IRLCD; |
|---|
| 61 | extern DRIVER drv_LCD2USB; |
|---|
| 62 | extern DRIVER drv_LCDLinux; |
|---|
| 63 | extern DRIVER drv_LCDTerm; |
|---|
| 64 | extern DRIVER drv_LEDMatrix; |
|---|
| 65 | extern DRIVER drv_LPH7508; |
|---|
| 66 | extern DRIVER drv_LUIse; |
|---|
| 67 | extern DRIVER drv_M50530; |
|---|
| 68 | extern DRIVER drv_MatrixOrbital; |
|---|
| 69 | extern DRIVER drv_MilfordInstruments; |
|---|
| 70 | extern DRIVER drv_Noritake; |
|---|
| 71 | extern DRIVER drv_NULL; |
|---|
| 72 | extern DRIVER drv_Pertelian; |
|---|
| 73 | extern DRIVER drv_picoLCD; |
|---|
| 74 | extern DRIVER drv_picoLCDGraphic; |
|---|
| 75 | extern DRIVER drv_RouterBoard; |
|---|
| 76 | extern DRIVER drv_Sample; |
|---|
| 77 | extern DRIVER drv_st2205; |
|---|
| 78 | extern DRIVER drv_serdisplib; |
|---|
| 79 | extern DRIVER drv_SimpleLCD; |
|---|
| 80 | extern DRIVER drv_T6963; |
|---|
| 81 | extern DRIVER drv_Trefon; |
|---|
| 82 | extern DRIVER drv_ula200; |
|---|
| 83 | extern DRIVER drv_USBHUB; |
|---|
| 84 | extern DRIVER drv_USBLCD; |
|---|
| 85 | extern DRIVER drv_WincorNixdorf; |
|---|
| 86 | extern DRIVER drv_X11; |
|---|
| 87 | |
|---|
| 88 | /* output file for Image driver |
|---|
| 89 | * has to be defined here because it's referenced |
|---|
| 90 | * even if the raster driver is not included! |
|---|
| 91 | */ |
|---|
| 92 | char *output = NULL; |
|---|
| 93 | |
|---|
| 94 | DRIVER *Driver[] = { |
|---|
| 95 | #ifdef WITH_BECKMANNEGLE |
|---|
| 96 | &drv_BeckmannEgle, |
|---|
| 97 | #endif |
|---|
| 98 | #ifdef WITH_BWCT |
|---|
| 99 | &drv_BWCT, |
|---|
| 100 | #endif |
|---|
| 101 | #ifdef WITH_CRYSTALFONTZ |
|---|
| 102 | &drv_Crystalfontz, |
|---|
| 103 | #endif |
|---|
| 104 | #ifdef WITH_CURSES |
|---|
| 105 | &drv_Curses, |
|---|
| 106 | #endif |
|---|
| 107 | #ifdef WITH_CWLINUX |
|---|
| 108 | &drv_Cwlinux, |
|---|
| 109 | #endif |
|---|
| 110 | #ifdef WITH_D4D |
|---|
| 111 | &drv_D4D, |
|---|
| 112 | #endif |
|---|
| 113 | #ifdef WITH_EA232graphic |
|---|
| 114 | &drv_EA232graphic, |
|---|
| 115 | #endif |
|---|
| 116 | #ifdef WITH_G15 |
|---|
| 117 | &drv_G15, |
|---|
| 118 | #endif |
|---|
| 119 | #ifdef WITH_HD44780 |
|---|
| 120 | &drv_HD44780, |
|---|
| 121 | #endif |
|---|
| 122 | #if (defined(WITH_PNG) && defined(WITH_GD)) || defined(WITH_PPM) |
|---|
| 123 | &drv_Image, |
|---|
| 124 | #endif |
|---|
| 125 | #ifdef WITH_IRLCD |
|---|
| 126 | &drv_IRLCD, |
|---|
| 127 | #endif |
|---|
| 128 | #ifdef WITH_LCD2USB |
|---|
| 129 | &drv_LCD2USB, |
|---|
| 130 | #endif |
|---|
| 131 | #ifdef WITH_LCDLINUX |
|---|
| 132 | &drv_LCDLinux, |
|---|
| 133 | #endif |
|---|
| 134 | #ifdef WITH_LCDTERM |
|---|
| 135 | &drv_LCDTerm, |
|---|
| 136 | #endif |
|---|
| 137 | #ifdef WITH_LEDMATRIX |
|---|
| 138 | &drv_LEDMatrix, |
|---|
| 139 | #endif |
|---|
| 140 | #ifdef WITH_LPH7508 |
|---|
| 141 | &drv_LPH7508, |
|---|
| 142 | #endif |
|---|
| 143 | #ifdef WITH_LUISE |
|---|
| 144 | &drv_LUIse, |
|---|
| 145 | #endif |
|---|
| 146 | #ifdef WITH_M50530 |
|---|
| 147 | &drv_M50530, |
|---|
| 148 | #endif |
|---|
| 149 | #ifdef WITH_MATRIXORBITAL |
|---|
| 150 | &drv_MatrixOrbital, |
|---|
| 151 | #endif |
|---|
| 152 | #ifdef WITH_MILINST |
|---|
| 153 | &drv_MilfordInstruments, |
|---|
| 154 | #endif |
|---|
| 155 | #ifdef WITH_NORITAKE |
|---|
| 156 | &drv_Noritake, |
|---|
| 157 | #endif |
|---|
| 158 | #ifdef WITH_NULL |
|---|
| 159 | &drv_NULL, |
|---|
| 160 | #endif |
|---|
| 161 | #ifdef WITH_PERTELIAN |
|---|
| 162 | &drv_Pertelian, |
|---|
| 163 | #endif |
|---|
| 164 | #ifdef WITH_PICOLCD |
|---|
| 165 | &drv_picoLCD, |
|---|
| 166 | #endif |
|---|
| 167 | #ifdef WITH_PICOLCDGRAPHIC |
|---|
| 168 | &drv_picoLCDGraphic, |
|---|
| 169 | #endif |
|---|
| 170 | #ifdef WITH_ROUTERBOARD |
|---|
| 171 | &drv_RouterBoard, |
|---|
| 172 | #endif |
|---|
| 173 | #ifdef WITH_SAMPLE |
|---|
| 174 | &drv_Sample, |
|---|
| 175 | #endif |
|---|
| 176 | #ifdef WITH_ST2205 |
|---|
| 177 | &drv_st2205, |
|---|
| 178 | #endif |
|---|
| 179 | #ifdef WITH_SERDISPLIB |
|---|
| 180 | &drv_serdisplib, |
|---|
| 181 | #endif |
|---|
| 182 | #ifdef WITH_SIMPLELCD |
|---|
| 183 | &drv_SimpleLCD, |
|---|
| 184 | #endif |
|---|
| 185 | #ifdef WITH_T6963 |
|---|
| 186 | &drv_T6963, |
|---|
| 187 | #endif |
|---|
| 188 | #ifdef WITH_TREFON |
|---|
| 189 | &drv_Trefon, |
|---|
| 190 | #endif |
|---|
| 191 | #ifdef WITH_ULA200 |
|---|
| 192 | &drv_ula200, |
|---|
| 193 | #endif |
|---|
| 194 | #ifdef WITH_USBHUB |
|---|
| 195 | &drv_USBHUB, |
|---|
| 196 | #endif |
|---|
| 197 | #ifdef WITH_USBLCD |
|---|
| 198 | &drv_USBLCD, |
|---|
| 199 | #endif |
|---|
| 200 | #ifdef WITH_WINCORNIXDORF |
|---|
| 201 | &drv_WincorNixdorf, |
|---|
| 202 | #endif |
|---|
| 203 | #ifdef WITH_X11 |
|---|
| 204 | &drv_X11, |
|---|
| 205 | #endif |
|---|
| 206 | |
|---|
| 207 | NULL, |
|---|
| 208 | }; |
|---|
| 209 | |
|---|
| 210 | |
|---|
| 211 | static DRIVER *Drv = NULL; |
|---|
| 212 | |
|---|
| 213 | |
|---|
| 214 | int drv_list(void) |
|---|
| 215 | { |
|---|
| 216 | int i; |
|---|
| 217 | |
|---|
| 218 | printf("available display drivers:"); |
|---|
| 219 | |
|---|
| 220 | for (i = 0; Driver[i]; i++) { |
|---|
| 221 | printf("\n %-20s: ", Driver[i]->name); |
|---|
| 222 | if (Driver[i]->list) |
|---|
| 223 | Driver[i]->list(); |
|---|
| 224 | } |
|---|
| 225 | printf("\n"); |
|---|
| 226 | return 0; |
|---|
| 227 | } |
|---|
| 228 | |
|---|
| 229 | |
|---|
| 230 | int drv_init(const char *section, const char *driver, const int quiet) |
|---|
| 231 | { |
|---|
| 232 | int i; |
|---|
| 233 | for (i = 0; Driver[i]; i++) { |
|---|
| 234 | if (strcmp(Driver[i]->name, driver) == 0) { |
|---|
| 235 | Drv = Driver[i]; |
|---|
| 236 | if (Drv->init == NULL) |
|---|
| 237 | return 0; |
|---|
| 238 | return Drv->init(section, quiet); |
|---|
| 239 | } |
|---|
| 240 | } |
|---|
| 241 | error("drv_init(%s) failed: no such driver", driver); |
|---|
| 242 | return -1; |
|---|
| 243 | } |
|---|
| 244 | |
|---|
| 245 | |
|---|
| 246 | int drv_quit(const int quiet) |
|---|
| 247 | { |
|---|
| 248 | if (Drv->quit == NULL) |
|---|
| 249 | return 0; |
|---|
| 250 | return Drv->quit(quiet); |
|---|
| 251 | } |
|---|