X-Git-Url: https://git.sur5r.net/?a=blobdiff_plain;f=include%2Fvideo_console.h;h=7621a189d2a2855e906ef620e44142670e140641;hb=9925f1dbc38c0ef7220c6fca5968c708b8e48764;hp=eeba368d6391512ea49fbed561e7523d4e786be9;hpb=f266178698307608ee23741e69b9626196e66481;p=u-boot diff --git a/include/video_console.h b/include/video_console.h index eeba368d63..7621a189d2 100644 --- a/include/video_console.h +++ b/include/video_console.h @@ -7,11 +7,37 @@ #ifndef __video_console_h #define __video_console_h +#include + #define VID_FRAC_DIV 256 #define VID_TO_PIXEL(x) ((x) / VID_FRAC_DIV) #define VID_TO_POS(x) ((x) * VID_FRAC_DIV) +/* + * The 16 colors supported by the console + */ +enum color_idx { + VID_BLACK = 0, + VID_RED, + VID_GREEN, + VID_BROWN, + VID_BLUE, + VID_MAGENTA, + VID_CYAN, + VID_LIGHT_GRAY, + VID_GRAY, + VID_LIGHT_RED, + VID_LIGTH_GREEN, + VID_YELLOW, + VID_LIGHT_BLUE, + VID_LIGHT_MAGENTA, + VID_LIGHT_CYAN, + VID_WHITE, + + VID_COLOR_COUNT +}; + /** * struct vidconsole_priv - uclass-private data about a console device * @@ -27,6 +53,11 @@ * @y_charsize: Character height in pixels * @tab_width_frac: Tab width in fractional units * @xsize_frac: Width of the display in fractional units + * @xstart_frac: Left margin for the text console in fractional units + * @last_ch: Last character written to the text console on this line + * @escape: TRUE if currently accumulating an ANSI escape sequence + * @escape_len: Length of accumulated escape sequence so far + * @escape_buf: Buffer to accumulate escape sequence */ struct vidconsole_priv { struct stdio_dev sdev; @@ -38,6 +69,16 @@ struct vidconsole_priv { int y_charsize; int tab_width_frac; int xsize_frac; + int xstart_frac; + int last_ch; + /* + * ANSI escape sequences are accumulated character by character, + * starting after the ESC char (0x1b) until the entire sequence + * is consumed at which point it is acted upon. + */ + int escape; + int escape_len; + char escape_buf[32]; }; /** @@ -85,6 +126,32 @@ struct vidconsole_ops { * @return 0 if OK, -ve on error */ int (*set_row)(struct udevice *dev, uint row, int clr); + + /** + * entry_start() - Indicate that text entry is starting afresh + * + * Consoles which use proportional fonts need to track the position of + * each character output so that backspace will return to the correct + * place. This method signals to the console driver that a new entry + * line is being start (e.g. the user pressed return to start a new + * command). The driver can use this signal to empty its list of + * positions. + */ + int (*entry_start)(struct udevice *dev); + + /** + * backspace() - Handle erasing the last character + * + * With proportional fonts the vidconsole uclass cannot itself erase + * the previous character. This optional method will be called when + * a backspace is needed. The driver should erase the previous + * character and update the cursor position (xcur_frac, ycur) to the + * start of the previous character. + * + * If not implement, default behaviour will work for fixed-width + * characters. + */ + int (*backspace)(struct udevice *dev); }; /* Get a pointer to the driver operations for a video console device */ @@ -155,4 +222,21 @@ int vidconsole_put_char(struct udevice *dev, char ch); void vidconsole_position_cursor(struct udevice *dev, unsigned col, unsigned row); +#ifdef CONFIG_DM_VIDEO + +/** + * vid_console_color() - convert a color code to a pixel's internal + * representation + * + * The caller has to guarantee that the color index is less than + * VID_COLOR_COUNT. + * + * @priv private data of the console device + * @idx color index + * @return color value + */ +u32 vid_console_color(struct video_priv *priv, unsigned int idx); + +#endif + #endif