[tyndur-devel] [PATCH 1/6] + cdi: video-Header
Kevin Wolf ·
On Mon, Sep 21, 2009 at 12:54:08PM +0200, Alexander Siol wrote: > Signed-off-by: Alexander Siol <alex at tyndur.org> > --- > src/modules/cdi/include/cdi.h | 1 + > src/modules/cdi/include/cdi/vesa.h | 92 ++++++++++++ > src/modules/cdi/include/cdi/video.h | 274 +++++++++++++++++++++++++++++++++++ > 3 files changed, 367 insertions(+), 0 deletions(-) > create mode 100644 src/modules/cdi/include/cdi/vesa.h > create mode 100644 src/modules/cdi/include/cdi/video.h > > diff --git a/src/modules/cdi/include/cdi.h b/src/modules/cdi/include/cdi.h > index 7bcf9e4..fee8976 100644 > --- a/src/modules/cdi/include/cdi.h > +++ b/src/modules/cdi/include/cdi.h > @@ -26,6 +26,7 @@ typedef enum { > CDI_NETWORK = 1, > CDI_STORAGE = 2, > CDI_SCSI = 3, > + CDI_VIDEO = 4, > } cdi_device_type_t; > > struct cdi_driver; > diff --git a/src/modules/cdi/include/cdi/vesa.h b/src/modules/cdi/include/cdi/vesa.h > new file mode 100644 > index 0000000..f8ff636 > --- /dev/null > +++ b/src/modules/cdi/include/cdi/vesa.h > @@ -0,0 +1,92 @@ > +/* > + * Copyright (c) 2008-2009 Mathias Gottschlag, Janosch Graef, Alexander Siol > + * > + * This program is free software. It comes without any warranty, to > + * the extent permitted by applicable law. You can redistribute it > + * and/or modify it under the terms of the Do What The Fuck You Want > + * To Public License, Version 2, as published by Sam Hocevar. See > + * http://sam.zoy.org/projects/COPYING.WTFPL for more details. > + */ > + > +#ifndef _CDI_VESA_H_ > +#define _CDI_VESA_H_ > + > +#include <stdint.h> > +#include <cdi/lists.h> > +#include <cdi/video.h> > + > +/** > + * VESA information block, used to get information about the card like video > + * modes > + */ Kommentare sind deutsch oder zweisprachig (für letzteres müsste man die doxygen-Regeln noch bauen). > +struct cdi_video_vesa_info_block { > + char signature[4]; > + char version[2]; > + uint32_t oemname; > + uint32_t capabilities; > + uint32_t modeptr; > + uint16_t videomem; > + // VBE 2.0 > + uint16_t oemversion; > + uint32_t vendornameptr; > + uint32_t productnameptr; > + uint32_t revisionptr; > + uint16_t modes[111]; > + uint8_t oem[256]; > +} __attribute__ ((packed)); > + > +struct cdi_video_vesa_mode_info { > + uint16_t modeattr; > + uint8_t windowattra; > + uint8_t windowattrb; > + uint16_t windowgran; > + uint16_t windowsize; > + uint16_t startsega; > + uint16_t startsegb; > + uint32_t posfunc; > + uint16_t scanline; > + > + uint16_t width; > + uint16_t height; > + uint8_t charwidth; > + uint8_t charheight; > + uint8_t planecount; > + uint8_t depth; > + uint8_t banks; > + uint8_t type; > + uint8_t banksize; > + uint8_t imagepages; > + uint8_t reserved; > + // VBE v1.2+ > + uint8_t redmasksize; > + uint8_t redfieldpos; > + uint8_t greenmasksize; > + uint8_t greenfieldpos; > + uint8_t bluemasksize; > + uint8_t bluefieldpos; > + uint8_t resmasksize; > + uint8_t resfieldsize; > + uint8_t dircolormode; > + // VBE v2.0 > + uint32_t linearfb; > + uint32_t offscreenmem; > + uint32_t offscreensize; > + > + char reserved2[206]; > +} __attribute__ ((packed)); > + > +struct cdi_video_vesa_mode { > + struct cdi_video_displaymode mode; > + uint16_t vesamode; > +}; > + > +struct cdi_video_vesa_info_block cdi_vesa_infoblock; > + > +int cdi_video_vesa_initialize > + (struct cdi_video_vesa_info_block **vesainfo, > + void (*mode_callback)(int modenum, struct cdi_video_vesa_mode_info *mode)); > + > +struct cdi_video_vesa_mode_info* cdi_video_vesa_get_mode(int modenum); > +int cdi_video_vesa_change_mode(int modenum); > + > +#endif > diff --git a/src/modules/cdi/include/cdi/video.h b/src/modules/cdi/include/cdi/video.h > new file mode 100644 > index 0000000..c42dbfe > --- /dev/null > +++ b/src/modules/cdi/include/cdi/video.h > @@ -0,0 +1,274 @@ > +/* > + * Copyright (c) 2007-2009 Mathias Gottschlag, Janosch Graef, Alexander Siol > + * > + * This program is free software. It comes without any warranty, to > + * the extent permitted by applicable law. You can redistribute it > + * and/or modify it under the terms of the Do What The Fuck You Want > + * To Public License, Version 2, as published by Sam Hocevar. See > + * http://sam.zoy.org/projects/COPYING.WTFPL for more details. > + */ > + > +#ifndef _CDI_VIDEO_H_ > +#define _CDI_VIDEO_H_ > + > +#include "cdi.h" > +#include "cdi/lists.h" > + > +struct cdi_video_displaymode { > + unsigned int width; > + unsigned int height; > + unsigned int depth; > + int refreshrate; // 0 f??r Irrelevant Bei depth und refreshrate wäre ein Kommentar hilfreich, der angibt, in welcher Einheit das denn sein soll. > +}; > + > +enum cdi_video_bitmap_usage_hint { > + CDI_VIDEO_PRIO_HIGH, > + CDI_VIDEO_PRIO_NORMAL, > + CDI_VIDEO_PRIO_LOW, > +}; > + > +struct cdi_video_pixel_format { > + char bpp; char oder uint8_t? > + uint32_t red_bits, red_offset; > + uint32_t green_bits, green_offset; > + uint32_t blue_bits, blue_offset; > + uint32_t alpha_bits, alpha_offset; Eine Variable pro Zeile macht die Sache übersichtlicher. > +}; > + > +struct cdi_video_bitmap { > + int width; > + int height; > + struct cdi_video_pixel_format format; > + int pitch; > + > + struct cdi_video_device *device; Der Stern gehört zum Typen (wiederholt sich einige Male). > + > + /// 1 wenn im VRAM, 0 wenn im RAM > + int in_vram; > + > + /// Addresse > + int *pixeldata; > +}; > + > +enum cdi_video_raster_op { > + CDI_VIDEO_ROP_COPY, > + CDI_VIDEO_ROP_OR, > + CDI_VIDEO_ROP_AND, > + CDI_VIDEO_ROP_XOR, > + // TODO: Erweitern > +}; > + > +struct cdi_video_device { > + /// CDI-Geraet > + struct cdi_device dev; > + > + /// Liste der Bildschirme > + cdi_list_t displays; > + > + /// Aktuelle RasterOP (fuer Software-Helfer noetig) > + enum cdi_video_raster_op raster_op; > + > + /// Daten zur Moduswiederherstellung > + void* restore_data; > + > + /// Pointer zum Beginn des (gemappten) VRAM > + void* vram; > + > + /// Groesse des VRAM > + size_t vram_size; > +}; > + > +struct cdi_video_display { > + /// Videogeraet, dem dieser Bildschirm angehoert > + struct cdi_video_device *device; > + > + /// Momentaner Modus > + struct cdi_video_displaymode *mode; > + > + /// Liste mit verfuegbaren Modi > + cdi_list_t modes; > + > + /// Zeichenbuffer fuer Display > + struct cdi_video_bitmap *frontbuffer; > +}; > + > +struct cdi_video_color { > + uint8_t alpha; > + uint8_t red; > + uint8_t green; > + uint8_t blue; > +}; > + > +struct cdi_video_driver { > + /// CDI-Treiber > + struct cdi_driver drv; > + > + // Basis-Funktionen > + /** > + * Sichert die aktiven Modi der Displays zur spaeteren Wiederherstellung > + * @param device Das zu sichernde Device > + * @return 0 = Erfolg; -1 = Fehlschlag > + */ Bei diesem und den folgenden Kommentaren sind die Sterne verrutscht > + int (*driver_save)(struct cdi_video_device *device); > + > + /** > + * Stellt den gesicherten Zustand wieder her. > + * @param device Das Device das wiederherstellen soll > + * @return 0 = Erfolg; -1 = Fehlschlag > + */ > + int (*driver_restore)(struct cdi_video_device *device); Geht es da wirklich nur um den Modus? In dem Fall ist der Name driver_save/restore vielleicht etwas hochgegriffen. mode_save/restore wäre dann wohl passender. > + > + > + > + // Anzeigenkontrolle > + > + /** > + * Setzt die Aufloesung eines Bildschirms > + * @param display Bildschirm > + * @param mode Modus > + * @return 0 = Erfolg; -1 = Fehlschlag > + */ > + int (*display_set_mode) > + (struct cdi_video_device *device, struct cdi_video_display *display, > + struct cdi_video_displaymode *mode); > + > + > + > + // Bitmap-Funktionen > + > + /** > + * Erstellt ein Bitmap > + * @param width Breite des Bitmaps > + * @param height Hoehe des Bitmaps > + * @param data Pixeldaten, oder 0, wenn das Bitmap vom Treiber beschrieben wird > + */ > + struct cdi_video_bitmap* (*bitmap_create) > + (struct cdi_video_device *device, unsigned int width, > + unsigned int height, void *data); > + > + /** > + * Loescht ein Bitmap > + * @param bitmap Zu loeschendes Bitmap > + */ > + void (*bitmap_destroy) > + (struct cdi_video_device *device, struct cdi_video_bitmap *bitmap); > + > + /** > + * Setzt den Gebrauchsmodus eines Bitmaps (bestimmt zB, ob ein Bitmap gecacht wird) > + * @param device Videogeraet > + * @param bitmap Betroffenes Bitmap > + * @param hint Hinweis auf die Priorit??t des Bitmaps > + */ > + void (*bitmap_set_usage_hint) > + (struct cdi_video_device *device, struct cdi_video_bitmap *bitmap, > + enum cdi_video_bitmap_usage_hint hint); > + > + > + > + // Zeichen-Funktionen > + > + /** > + * Setzt den Raster-Op f??r die folgenden Zeichenfunktionen. Umlaut im Kommentar > + * Der Raster-Op bestimmt, auf welche Art Grafik gezeichnet wird. > + * @param display Display, auf das gezeichnet wird > + * @param rop Raster-Op > + * @note Kann nur angewendet werden wenn der Bildschirm aktiviert ist > + */ > + void (*set_raster_op) > + (struct cdi_video_device *device, enum cdi_video_raster_op rop); > + > + /** > + * Zeichnet eine Linie > + * @param display Display, auf das gezeichnet wird > + * @param x1 X-Koordinate des Anfangs > + * @param y1 Y-Koordinate des Anfangs > + * @param x1 X-Koordinate des Endpunktes > + * @param y1 Y-Koordinate des Endpunktes > + * @param color Farbe der Linie > + * @note Kann nur angewendet werden wenn der Bildschirm aktiviert ist > + */ > + > + void (*draw_line) > + (struct cdi_video_bitmap *target, unsigned int x1, unsigned int y1, > + unsigned int x2, unsigned int y2, struct cdi_video_color color); Übergibt man structs wie color nicht normal als Pointer? (Wiederholt sich) > + /** > + * Zeichnet ein Rechteck > + * @param display Display, auf das gezeichnet wird > + * @param x X-Koordinate > + * @param y Y-Koordinate > + * @param width Breite > + * @param height Hoehe > + * @param color Farbe des Rechtecks > + */ > + void (*draw_rectangle) > + (struct cdi_video_bitmap *target, unsigned int x, unsigned int y, > + unsigned int width, unsigned int height, struct cdi_video_color color); > + > + /** > + * Zeichnet eine Ellipse > + * @param display Display, auf das gezeichnet wird > + * @param x X-Koordinate > + * @param y Y-Koordinate > + * @param width Breite > + * @param height Hoehe > + * @param color Farbe der Ellipse > + */ > + void (*draw_ellipse) > + (struct cdi_video_bitmap *target, unsigned int x, unsigned int y, > + unsigned int width, unsigned int height, struct cdi_video_color color); > + > + /** > + * Zeichnet ein Bitmap > + * @param display Display, auf das gezeichnet wird > + * @param bitmap Zu zeichnendes Bitmap > + * @param x X-Koordinate > + * @param y Y-Koordinate > + * @note Es wird nur so viel kopiert wie das Zielbitmap aufnehmen kann > + */ > + void (*draw_bitmap) > + (struct cdi_video_bitmap *target, struct cdi_video_bitmap *bitmap, > + unsigned int x, unsigned int y); > + > + /** > + * Zeichnet einen Teil einer Bitmap > + * @param display Display, auf das gezeichnet wird > + * @param bitmap Zu zeichnendes Bitmap > + * @param x X-Koordinate (Ziel) > + * @param y Y-Koordinate (Ziel) > + * @param srcx X-Koordinate (Quelle) > + * @param srcy Y-Koordinate (Quelle) > + * @param width Breite > + * @param height Hoehe > + */ > + void (*draw_bitmap_part) > + (struct cdi_video_bitmap *target, struct cdi_video_bitmap *bitmap, > + unsigned int x, unsigned int y, unsigned int srcx, unsigned int srcy, > + unsigned int width, unsigned int height); > + > + /** > + * Zeichnet einen Punkt > + * @param display Display, auf dem gezeichnet wird > + * @param x X-Koordinate (Ziel) > + * @param y Y-Koordinate (Ziel) > + * @note Kann nur angewendet werden wenn der Bildschirm aktiviert ist > + */ > + void (*draw_dot) > + (struct cdi_video_bitmap *target, unsigned int x, unsigned int y, > + struct cdi_video_color color); > +}; > + > +/** > + * Initialisiert die Datenstrukturen fuer einen Grafikkartentreiber > + */ > +void cdi_video_driver_init(struct cdi_video_driver* driver); > +/** > + * Deinitialisiert die Datenstrukturen fuer einen Grafikkartentreiber > + */ > +void cdi_video_driver_destroy(struct cdi_video_driver* driver); > +/** > + * Registiert einen Grafikkartentreiber > + */ > +void cdi_video_driver_register(struct cdi_video_driver* driver); > + > + > +#endif > -- > 1.6.0.4 > > _______________________________________________ > tyndur-devel mailing list > tyndur-devel at tyndur.org > http://list.tyndur.org/mailman/listinfo/tyndur-devel