1167c5898Swdenk /* 21acafc73SSimon Glass * Video uclass and legacy implementation 31acafc73SSimon Glass * 41acafc73SSimon Glass * Copyright (c) 2015 Google, Inc 51acafc73SSimon Glass * 61acafc73SSimon Glass * MPC823 Video Controller 71acafc73SSimon Glass * ======================= 81acafc73SSimon Glass * (C) 2000 by Paolo Scaffardi (arsenio@tin.it) 91acafc73SSimon Glass * AIRVENT SAM s.p.a - RIMINI(ITALY) 101acafc73SSimon Glass * 11167c5898Swdenk */ 12167c5898Swdenk 13167c5898Swdenk #ifndef _VIDEO_H_ 14167c5898Swdenk #define _VIDEO_H_ 15167c5898Swdenk 161acafc73SSimon Glass #ifdef CONFIG_DM_VIDEO 171acafc73SSimon Glass 181acafc73SSimon Glass #include <stdio_dev.h> 191acafc73SSimon Glass 201acafc73SSimon Glass struct video_uc_platdata { 211acafc73SSimon Glass uint align; 221acafc73SSimon Glass uint size; 231acafc73SSimon Glass ulong base; 241acafc73SSimon Glass }; 251acafc73SSimon Glass 2621c561b7SSimon Glass enum video_polarity { 2721c561b7SSimon Glass VIDEO_ACTIVE_HIGH, /* Pins are active high */ 2821c561b7SSimon Glass VIDEO_ACTIVE_LOW, /* Pins are active low */ 2921c561b7SSimon Glass }; 3021c561b7SSimon Glass 311acafc73SSimon Glass /* 321acafc73SSimon Glass * Bits per pixel selector. Each value n is such that the bits-per-pixel is 331acafc73SSimon Glass * 2 ^ n 341acafc73SSimon Glass */ 351acafc73SSimon Glass enum video_log2_bpp { 361acafc73SSimon Glass VIDEO_BPP1 = 0, 371acafc73SSimon Glass VIDEO_BPP2, 381acafc73SSimon Glass VIDEO_BPP4, 391acafc73SSimon Glass VIDEO_BPP8, 401acafc73SSimon Glass VIDEO_BPP16, 411acafc73SSimon Glass VIDEO_BPP32, 421acafc73SSimon Glass }; 431acafc73SSimon Glass 441acafc73SSimon Glass /* 451acafc73SSimon Glass * Convert enum video_log2_bpp to bytes and bits. Note we omit the outer 461acafc73SSimon Glass * brackets to allow multiplication by fractional pixels. 471acafc73SSimon Glass */ 481acafc73SSimon Glass #define VNBYTES(bpix) (1 << (bpix)) / 8 491acafc73SSimon Glass 501acafc73SSimon Glass #define VNBITS(bpix) (1 << (bpix)) 511acafc73SSimon Glass 521acafc73SSimon Glass /** 531acafc73SSimon Glass * struct video_priv - Device information used by the video uclass 541acafc73SSimon Glass * 551acafc73SSimon Glass * @xsize: Number of pixel columns (e.g. 1366) 561acafc73SSimon Glass * @ysize: Number of pixels rows (e.g.. 768) 578cdae1daSSimon Glass * @rot: Display rotation (0=none, 1=90 degrees clockwise, etc.) 581acafc73SSimon Glass * @bpix: Encoded bits per pixel 59826f35f9SSimon Glass * @vidconsole_drv_name: Driver to use for the text console, NULL to 60826f35f9SSimon Glass * select automatically 61826f35f9SSimon Glass * @font_size: Font size in pixels (0 to use a default value) 621acafc73SSimon Glass * @fb: Frame buffer 631acafc73SSimon Glass * @fb_size: Frame buffer size 641acafc73SSimon Glass * @line_length: Length of each frame buffer line, in bytes 651acafc73SSimon Glass * @colour_fg: Foreground colour (pixel value) 661acafc73SSimon Glass * @colour_bg: Background colour (pixel value) 671acafc73SSimon Glass * @flush_dcache: true to enable flushing of the data cache after 681acafc73SSimon Glass * the LCD is updated 691acafc73SSimon Glass * @cmap: Colour map for 8-bit-per-pixel displays 701acafc73SSimon Glass */ 711acafc73SSimon Glass struct video_priv { 721acafc73SSimon Glass /* Things set up by the driver: */ 731acafc73SSimon Glass ushort xsize; 741acafc73SSimon Glass ushort ysize; 751acafc73SSimon Glass ushort rot; 761acafc73SSimon Glass enum video_log2_bpp bpix; 77826f35f9SSimon Glass const char *vidconsole_drv_name; 78826f35f9SSimon Glass int font_size; 791acafc73SSimon Glass 801acafc73SSimon Glass /* 811acafc73SSimon Glass * Things that are private to the uclass: don't use these in the 821acafc73SSimon Glass * driver 831acafc73SSimon Glass */ 841acafc73SSimon Glass void *fb; 851acafc73SSimon Glass int fb_size; 861acafc73SSimon Glass int line_length; 871acafc73SSimon Glass int colour_fg; 881acafc73SSimon Glass int colour_bg; 891acafc73SSimon Glass bool flush_dcache; 901acafc73SSimon Glass ushort *cmap; 911acafc73SSimon Glass }; 921acafc73SSimon Glass 931acafc73SSimon Glass /* Placeholder - there are no video operations at present */ 941acafc73SSimon Glass struct video_ops { 951acafc73SSimon Glass }; 961acafc73SSimon Glass 971acafc73SSimon Glass #define video_get_ops(dev) ((struct video_ops *)(dev)->driver->ops) 981acafc73SSimon Glass 991acafc73SSimon Glass /** 1001acafc73SSimon Glass * video_reserve() - Reserve frame-buffer memory for video devices 1011acafc73SSimon Glass * 1021acafc73SSimon Glass * Note: This function is for internal use. 1031acafc73SSimon Glass * 1041acafc73SSimon Glass * This uses the uclass platdata's @size and @align members to figure out 1051acafc73SSimon Glass * a size and position for each frame buffer as part of the pre-relocation 1061acafc73SSimon Glass * process of determining the post-relocation memory layout. 1071acafc73SSimon Glass * 1081acafc73SSimon Glass * gd->video_top is set to the initial value of *@addrp and gd->video_bottom 1091acafc73SSimon Glass * is set to the final value. 1101acafc73SSimon Glass * 1111acafc73SSimon Glass * @addrp: On entry, the top of available memory. On exit, the new top, 1121acafc73SSimon Glass * after allocating the required memory. 1131acafc73SSimon Glass * @return 0 1141acafc73SSimon Glass */ 1151acafc73SSimon Glass int video_reserve(ulong *addrp); 1161acafc73SSimon Glass 1171acafc73SSimon Glass /** 1181acafc73SSimon Glass * video_sync() - Sync a device's frame buffer with its hardware 1191acafc73SSimon Glass * 1201acafc73SSimon Glass * Some frame buffers are cached or have a secondary frame buffer. This 1211acafc73SSimon Glass * function syncs these up so that the current contents of the U-Boot frame 1221acafc73SSimon Glass * buffer are displayed to the user. 1231acafc73SSimon Glass * 1241acafc73SSimon Glass * @dev: Device to sync 1251acafc73SSimon Glass */ 1261acafc73SSimon Glass void video_sync(struct udevice *vid); 1271acafc73SSimon Glass 1281acafc73SSimon Glass /** 1291acafc73SSimon Glass * video_sync_all() - Sync all devices' frame buffers with there hardware 1301acafc73SSimon Glass * 1311acafc73SSimon Glass * This calls video_sync() on all active video devices. 1321acafc73SSimon Glass */ 1331acafc73SSimon Glass void video_sync_all(void); 1341acafc73SSimon Glass 1351acafc73SSimon Glass /** 1361acafc73SSimon Glass * video_bmp_display() - Display a BMP file 1371acafc73SSimon Glass * 1381acafc73SSimon Glass * @dev: Device to display the bitmap on 1391acafc73SSimon Glass * @bmp_image: Address of bitmap image to display 1401acafc73SSimon Glass * @x: X position in pixels from the left 1411acafc73SSimon Glass * @y: Y position in pixels from the top 1421acafc73SSimon Glass * @align: true to adjust the coordinates to centre the image. If false 1431acafc73SSimon Glass * the coordinates are used as is. If true: 1441acafc73SSimon Glass * 1451acafc73SSimon Glass * - if a coordinate is 0x7fff then the image will be centred in 1461acafc73SSimon Glass * that direction 1471acafc73SSimon Glass * - if a coordinate is -ve then it will be offset to the 1481acafc73SSimon Glass * left/top of the centre by that many pixels 1491acafc73SSimon Glass * - if a coordinate is positive it will be used unchnaged. 1501acafc73SSimon Glass * @return 0 if OK, -ve on error 1511acafc73SSimon Glass */ 1521acafc73SSimon Glass int video_bmp_display(struct udevice *dev, ulong bmp_image, int x, int y, 1531acafc73SSimon Glass bool align); 1541acafc73SSimon Glass 1551acafc73SSimon Glass /** 1561acafc73SSimon Glass * video_get_xsize() - Get the width of the display in pixels 1571acafc73SSimon Glass * 1581acafc73SSimon Glass * @dev: Device to check 1591acafc73SSimon Glass * @return device frame buffer width in pixels 1601acafc73SSimon Glass */ 1611acafc73SSimon Glass int video_get_xsize(struct udevice *dev); 1621acafc73SSimon Glass 1631acafc73SSimon Glass /** 1641acafc73SSimon Glass * video_get_ysize() - Get the height of the display in pixels 1651acafc73SSimon Glass * 1661acafc73SSimon Glass * @dev: Device to check 1671acafc73SSimon Glass * @return device frame buffer height in pixels 1681acafc73SSimon Glass */ 1691acafc73SSimon Glass int video_get_ysize(struct udevice *dev); 1701acafc73SSimon Glass 17168dcdc99SSimon Glass /** 17268dcdc99SSimon Glass * Set whether we need to flush the dcache when changing the image. This 17368dcdc99SSimon Glass * defaults to off. 17468dcdc99SSimon Glass * 17568dcdc99SSimon Glass * @param flush non-zero to flush cache after update, 0 to skip 17668dcdc99SSimon Glass */ 17768dcdc99SSimon Glass void video_set_flush_dcache(struct udevice *dev, bool flush); 17868dcdc99SSimon Glass 1791acafc73SSimon Glass #endif /* CONFIG_DM_VIDEO */ 1801acafc73SSimon Glass 1811acafc73SSimon Glass #ifndef CONFIG_DM_VIDEO 1821acafc73SSimon Glass 183167c5898Swdenk /* Video functions */ 184167c5898Swdenk 185709ea543SSimon Glass struct stdio_dev; 186709ea543SSimon Glass 187167c5898Swdenk int video_init(void *videobase); 188709ea543SSimon Glass void video_putc(struct stdio_dev *dev, const char c); 189709ea543SSimon Glass void video_puts(struct stdio_dev *dev, const char *s); 190167c5898Swdenk 191f674f7cfSStefan Reinauer /** 192f674f7cfSStefan Reinauer * Display a BMP format bitmap on the screen 193f674f7cfSStefan Reinauer * 194f674f7cfSStefan Reinauer * @param bmp_image Address of BMP image 195f674f7cfSStefan Reinauer * @param x X position to draw image 196f674f7cfSStefan Reinauer * @param y Y position to draw image 197f674f7cfSStefan Reinauer */ 198f674f7cfSStefan Reinauer int video_display_bitmap(ulong bmp_image, int x, int y); 199f674f7cfSStefan Reinauer 200f674f7cfSStefan Reinauer /** 201f674f7cfSStefan Reinauer * Get the width of the screen in pixels 202f674f7cfSStefan Reinauer * 203f674f7cfSStefan Reinauer * @return width of screen in pixels 204f674f7cfSStefan Reinauer */ 205f674f7cfSStefan Reinauer int video_get_pixel_width(void); 206f674f7cfSStefan Reinauer 207f674f7cfSStefan Reinauer /** 208f674f7cfSStefan Reinauer * Get the height of the screen in pixels 209f674f7cfSStefan Reinauer * 210f674f7cfSStefan Reinauer * @return height of screen in pixels 211f674f7cfSStefan Reinauer */ 212f674f7cfSStefan Reinauer int video_get_pixel_height(void); 213f674f7cfSStefan Reinauer 214f674f7cfSStefan Reinauer /** 215f674f7cfSStefan Reinauer * Get the number of text lines/rows on the screen 216f674f7cfSStefan Reinauer * 217f674f7cfSStefan Reinauer * @return number of rows 218f674f7cfSStefan Reinauer */ 219f674f7cfSStefan Reinauer int video_get_screen_rows(void); 220f674f7cfSStefan Reinauer 221f674f7cfSStefan Reinauer /** 222f674f7cfSStefan Reinauer * Get the number of text columns on the screen 223f674f7cfSStefan Reinauer * 224f674f7cfSStefan Reinauer * @return number of columns 225f674f7cfSStefan Reinauer */ 226f674f7cfSStefan Reinauer int video_get_screen_columns(void); 227f674f7cfSStefan Reinauer 228f674f7cfSStefan Reinauer /** 229f674f7cfSStefan Reinauer * Set the position of the text cursor 230f674f7cfSStefan Reinauer * 231f674f7cfSStefan Reinauer * @param col Column to place cursor (0 = left side) 232f674f7cfSStefan Reinauer * @param row Row to place cursor (0 = top line) 233f674f7cfSStefan Reinauer */ 234f674f7cfSStefan Reinauer void video_position_cursor(unsigned col, unsigned row); 235f674f7cfSStefan Reinauer 236f674f7cfSStefan Reinauer /* Clear the display */ 237f674f7cfSStefan Reinauer void video_clear(void); 238f674f7cfSStefan Reinauer 239b26354cfSHeiko Schocher #if defined(CONFIG_FORMIKE) 240b26354cfSHeiko Schocher int kwh043st20_f01_spi_startup(unsigned int bus, unsigned int cs, 241b26354cfSHeiko Schocher unsigned int max_hz, unsigned int spi_mode); 242b26354cfSHeiko Schocher #endif 243fc1a79d9SHeiko Schocher #if defined(CONFIG_LG4573) 244fc1a79d9SHeiko Schocher int lg4573_spi_startup(unsigned int bus, unsigned int cs, 245fc1a79d9SHeiko Schocher unsigned int max_hz, unsigned int spi_mode); 246fc1a79d9SHeiko Schocher #endif 2471acafc73SSimon Glass 248*0a6eac84SSimon Glass /* 249*0a6eac84SSimon Glass * video_get_info_str() - obtain a board string: type, speed, etc. 250*0a6eac84SSimon Glass * 251*0a6eac84SSimon Glass * This is called if CONFIG_CONSOLE_EXTRA_INFO is enabled. 252*0a6eac84SSimon Glass * 253*0a6eac84SSimon Glass * line_number: location to place info string beside logo 254*0a6eac84SSimon Glass * info: buffer for info string (empty if nothing to display on this 255*0a6eac84SSimon Glass * line) 256*0a6eac84SSimon Glass */ 257*0a6eac84SSimon Glass void video_get_info_str(int line_number, char *info); 258*0a6eac84SSimon Glass 2591acafc73SSimon Glass #endif /* CONFIG_DM_VIDEO */ 2601acafc73SSimon Glass 261167c5898Swdenk #endif 262