xref: /rk3399_rockchip-uboot/include/video.h (revision 8cdae1dacde7dbe74d53a8ac1a05761a53c4f191)
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 
261acafc73SSimon Glass /*
271acafc73SSimon Glass  * Bits per pixel selector. Each value n is such that the bits-per-pixel is
281acafc73SSimon Glass  * 2 ^ n
291acafc73SSimon Glass  */
301acafc73SSimon Glass enum video_log2_bpp {
311acafc73SSimon Glass 	VIDEO_BPP1	= 0,
321acafc73SSimon Glass 	VIDEO_BPP2,
331acafc73SSimon Glass 	VIDEO_BPP4,
341acafc73SSimon Glass 	VIDEO_BPP8,
351acafc73SSimon Glass 	VIDEO_BPP16,
361acafc73SSimon Glass 	VIDEO_BPP32,
371acafc73SSimon Glass };
381acafc73SSimon Glass 
391acafc73SSimon Glass /*
401acafc73SSimon Glass  * Convert enum video_log2_bpp to bytes and bits. Note we omit the outer
411acafc73SSimon Glass  * brackets to allow multiplication by fractional pixels.
421acafc73SSimon Glass  */
431acafc73SSimon Glass #define VNBYTES(bpix)	(1 << (bpix)) / 8
441acafc73SSimon Glass 
451acafc73SSimon Glass #define VNBITS(bpix)	(1 << (bpix))
461acafc73SSimon Glass 
471acafc73SSimon Glass /**
481acafc73SSimon Glass  * struct video_priv - Device information used by the video uclass
491acafc73SSimon Glass  *
501acafc73SSimon Glass  * @xsize:	Number of pixel columns (e.g. 1366)
511acafc73SSimon Glass  * @ysize:	Number of pixels rows (e.g.. 768)
52*8cdae1daSSimon Glass  * @rot:	Display rotation (0=none, 1=90 degrees clockwise, etc.)
531acafc73SSimon Glass  * @bpix:	Encoded bits per pixel
54826f35f9SSimon Glass  * @vidconsole_drv_name:	Driver to use for the text console, NULL to
55826f35f9SSimon Glass  *		select automatically
56826f35f9SSimon Glass  * @font_size:	Font size in pixels (0 to use a default value)
571acafc73SSimon Glass  * @fb:		Frame buffer
581acafc73SSimon Glass  * @fb_size:	Frame buffer size
591acafc73SSimon Glass  * @line_length:	Length of each frame buffer line, in bytes
601acafc73SSimon Glass  * @colour_fg:	Foreground colour (pixel value)
611acafc73SSimon Glass  * @colour_bg:	Background colour (pixel value)
621acafc73SSimon Glass  * @flush_dcache:	true to enable flushing of the data cache after
631acafc73SSimon Glass  *		the LCD is updated
641acafc73SSimon Glass  * @cmap:	Colour map for 8-bit-per-pixel displays
651acafc73SSimon Glass  */
661acafc73SSimon Glass struct video_priv {
671acafc73SSimon Glass 	/* Things set up by the driver: */
681acafc73SSimon Glass 	ushort xsize;
691acafc73SSimon Glass 	ushort ysize;
701acafc73SSimon Glass 	ushort rot;
711acafc73SSimon Glass 	enum video_log2_bpp bpix;
72826f35f9SSimon Glass 	const char *vidconsole_drv_name;
73826f35f9SSimon Glass 	int font_size;
741acafc73SSimon Glass 
751acafc73SSimon Glass 	/*
761acafc73SSimon Glass 	 * Things that are private to the uclass: don't use these in the
771acafc73SSimon Glass 	 * driver
781acafc73SSimon Glass 	 */
791acafc73SSimon Glass 	void *fb;
801acafc73SSimon Glass 	int fb_size;
811acafc73SSimon Glass 	int line_length;
821acafc73SSimon Glass 	int colour_fg;
831acafc73SSimon Glass 	int colour_bg;
841acafc73SSimon Glass 	bool flush_dcache;
851acafc73SSimon Glass 	ushort *cmap;
861acafc73SSimon Glass };
871acafc73SSimon Glass 
881acafc73SSimon Glass /* Placeholder - there are no video operations at present */
891acafc73SSimon Glass struct video_ops {
901acafc73SSimon Glass };
911acafc73SSimon Glass 
921acafc73SSimon Glass #define video_get_ops(dev)        ((struct video_ops *)(dev)->driver->ops)
931acafc73SSimon Glass 
941acafc73SSimon Glass /**
951acafc73SSimon Glass  * video_reserve() - Reserve frame-buffer memory for video devices
961acafc73SSimon Glass  *
971acafc73SSimon Glass  * Note: This function is for internal use.
981acafc73SSimon Glass  *
991acafc73SSimon Glass  * This uses the uclass platdata's @size and @align members to figure out
1001acafc73SSimon Glass  * a size and position for each frame buffer as part of the pre-relocation
1011acafc73SSimon Glass  * process of determining the post-relocation memory layout.
1021acafc73SSimon Glass  *
1031acafc73SSimon Glass  * gd->video_top is set to the initial value of *@addrp and gd->video_bottom
1041acafc73SSimon Glass  * is set to the final value.
1051acafc73SSimon Glass  *
1061acafc73SSimon Glass  * @addrp:	On entry, the top of available memory. On exit, the new top,
1071acafc73SSimon Glass  *		after allocating the required memory.
1081acafc73SSimon Glass  * @return 0
1091acafc73SSimon Glass  */
1101acafc73SSimon Glass int video_reserve(ulong *addrp);
1111acafc73SSimon Glass 
1121acafc73SSimon Glass /**
1131acafc73SSimon Glass  * video_sync() - Sync a device's frame buffer with its hardware
1141acafc73SSimon Glass  *
1151acafc73SSimon Glass  * Some frame buffers are cached or have a secondary frame buffer. This
1161acafc73SSimon Glass  * function syncs these up so that the current contents of the U-Boot frame
1171acafc73SSimon Glass  * buffer are displayed to the user.
1181acafc73SSimon Glass  *
1191acafc73SSimon Glass  * @dev:	Device to sync
1201acafc73SSimon Glass  */
1211acafc73SSimon Glass void video_sync(struct udevice *vid);
1221acafc73SSimon Glass 
1231acafc73SSimon Glass /**
1241acafc73SSimon Glass  * video_sync_all() - Sync all devices' frame buffers with there hardware
1251acafc73SSimon Glass  *
1261acafc73SSimon Glass  * This calls video_sync() on all active video devices.
1271acafc73SSimon Glass  */
1281acafc73SSimon Glass void video_sync_all(void);
1291acafc73SSimon Glass 
1301acafc73SSimon Glass /**
1311acafc73SSimon Glass  * video_bmp_display() - Display a BMP file
1321acafc73SSimon Glass  *
1331acafc73SSimon Glass  * @dev:	Device to display the bitmap on
1341acafc73SSimon Glass  * @bmp_image:	Address of bitmap image to display
1351acafc73SSimon Glass  * @x:		X position in pixels from the left
1361acafc73SSimon Glass  * @y:		Y position in pixels from the top
1371acafc73SSimon Glass  * @align:	true to adjust the coordinates to centre the image. If false
1381acafc73SSimon Glass  *		the coordinates are used as is. If true:
1391acafc73SSimon Glass  *
1401acafc73SSimon Glass  *		- if a coordinate is 0x7fff then the image will be centred in
1411acafc73SSimon Glass  *		  that direction
1421acafc73SSimon Glass  *		- if a coordinate is -ve then it will be offset to the
1431acafc73SSimon Glass  *		  left/top of the centre by that many pixels
1441acafc73SSimon Glass  *		- if a coordinate is positive it will be used unchnaged.
1451acafc73SSimon Glass  * @return 0 if OK, -ve on error
1461acafc73SSimon Glass  */
1471acafc73SSimon Glass int video_bmp_display(struct udevice *dev, ulong bmp_image, int x, int y,
1481acafc73SSimon Glass 		      bool align);
1491acafc73SSimon Glass 
1501acafc73SSimon Glass /**
1511acafc73SSimon Glass  * video_get_xsize() - Get the width of the display in pixels
1521acafc73SSimon Glass  *
1531acafc73SSimon Glass  * @dev:	Device to check
1541acafc73SSimon Glass  * @return device frame buffer width in pixels
1551acafc73SSimon Glass  */
1561acafc73SSimon Glass int video_get_xsize(struct udevice *dev);
1571acafc73SSimon Glass 
1581acafc73SSimon Glass /**
1591acafc73SSimon Glass  * video_get_ysize() - Get the height of the display in pixels
1601acafc73SSimon Glass  *
1611acafc73SSimon Glass  * @dev:	Device to check
1621acafc73SSimon Glass  * @return device frame buffer height in pixels
1631acafc73SSimon Glass  */
1641acafc73SSimon Glass int video_get_ysize(struct udevice *dev);
1651acafc73SSimon Glass 
16668dcdc99SSimon Glass /**
16768dcdc99SSimon Glass  * Set whether we need to flush the dcache when changing the image. This
16868dcdc99SSimon Glass  * defaults to off.
16968dcdc99SSimon Glass  *
17068dcdc99SSimon Glass  * @param flush		non-zero to flush cache after update, 0 to skip
17168dcdc99SSimon Glass  */
17268dcdc99SSimon Glass void video_set_flush_dcache(struct udevice *dev, bool flush);
17368dcdc99SSimon Glass 
1741acafc73SSimon Glass #endif /* CONFIG_DM_VIDEO */
1751acafc73SSimon Glass 
1761acafc73SSimon Glass #ifndef CONFIG_DM_VIDEO
1771acafc73SSimon Glass 
178167c5898Swdenk /* Video functions */
179167c5898Swdenk 
180709ea543SSimon Glass struct stdio_dev;
181709ea543SSimon Glass 
182167c5898Swdenk int	video_init(void *videobase);
183709ea543SSimon Glass void	video_putc(struct stdio_dev *dev, const char c);
184709ea543SSimon Glass void	video_puts(struct stdio_dev *dev, const char *s);
185167c5898Swdenk 
186f674f7cfSStefan Reinauer /**
187f674f7cfSStefan Reinauer  * Display a BMP format bitmap on the screen
188f674f7cfSStefan Reinauer  *
189f674f7cfSStefan Reinauer  * @param bmp_image	Address of BMP image
190f674f7cfSStefan Reinauer  * @param x		X position to draw image
191f674f7cfSStefan Reinauer  * @param y		Y position to draw image
192f674f7cfSStefan Reinauer  */
193f674f7cfSStefan Reinauer int video_display_bitmap(ulong bmp_image, int x, int y);
194f674f7cfSStefan Reinauer 
195f674f7cfSStefan Reinauer /**
196f674f7cfSStefan Reinauer  * Get the width of the screen in pixels
197f674f7cfSStefan Reinauer  *
198f674f7cfSStefan Reinauer  * @return width of screen in pixels
199f674f7cfSStefan Reinauer  */
200f674f7cfSStefan Reinauer int video_get_pixel_width(void);
201f674f7cfSStefan Reinauer 
202f674f7cfSStefan Reinauer /**
203f674f7cfSStefan Reinauer  * Get the height of the screen in pixels
204f674f7cfSStefan Reinauer  *
205f674f7cfSStefan Reinauer  * @return height of screen in pixels
206f674f7cfSStefan Reinauer  */
207f674f7cfSStefan Reinauer int video_get_pixel_height(void);
208f674f7cfSStefan Reinauer 
209f674f7cfSStefan Reinauer /**
210f674f7cfSStefan Reinauer  * Get the number of text lines/rows on the screen
211f674f7cfSStefan Reinauer  *
212f674f7cfSStefan Reinauer  * @return number of rows
213f674f7cfSStefan Reinauer  */
214f674f7cfSStefan Reinauer int video_get_screen_rows(void);
215f674f7cfSStefan Reinauer 
216f674f7cfSStefan Reinauer /**
217f674f7cfSStefan Reinauer  * Get the number of text columns on the screen
218f674f7cfSStefan Reinauer  *
219f674f7cfSStefan Reinauer  * @return number of columns
220f674f7cfSStefan Reinauer  */
221f674f7cfSStefan Reinauer int video_get_screen_columns(void);
222f674f7cfSStefan Reinauer 
223f674f7cfSStefan Reinauer /**
224f674f7cfSStefan Reinauer  * Set the position of the text cursor
225f674f7cfSStefan Reinauer  *
226f674f7cfSStefan Reinauer  * @param col	Column to place cursor (0 = left side)
227f674f7cfSStefan Reinauer  * @param row	Row to place cursor (0 = top line)
228f674f7cfSStefan Reinauer  */
229f674f7cfSStefan Reinauer void video_position_cursor(unsigned col, unsigned row);
230f674f7cfSStefan Reinauer 
231f674f7cfSStefan Reinauer /* Clear the display */
232f674f7cfSStefan Reinauer void video_clear(void);
233f674f7cfSStefan Reinauer 
234b26354cfSHeiko Schocher #if defined(CONFIG_FORMIKE)
235b26354cfSHeiko Schocher int kwh043st20_f01_spi_startup(unsigned int bus, unsigned int cs,
236b26354cfSHeiko Schocher 	unsigned int max_hz, unsigned int spi_mode);
237b26354cfSHeiko Schocher #endif
238fc1a79d9SHeiko Schocher #if defined(CONFIG_LG4573)
239fc1a79d9SHeiko Schocher int lg4573_spi_startup(unsigned int bus, unsigned int cs,
240fc1a79d9SHeiko Schocher 	unsigned int max_hz, unsigned int spi_mode);
241fc1a79d9SHeiko Schocher #endif
2421acafc73SSimon Glass 
2431acafc73SSimon Glass #endif /* CONFIG_DM_VIDEO */
2441acafc73SSimon Glass 
245167c5898Swdenk #endif
246