Add dynamic video initialization to barebox
Subsystems (6)
PATCH v3 1/1 Add dynamic video initialization to barebox
Currently barebox uses a fixed videomode setup. Everything is compiled in. This change adds the possibility to select a videomode according to a connected display at runtime. If more than one videomode is supported by the platform, running the 'devinfo' command on the framebuffer device shows the supported videomode list. After selecting the videomode, the output can be enabled.
On my hardware I can connect a regular monitor, which supports more than one videomode. The runtime setup sequence looks like that:
tx28:/ devinfo framebuffer0
base : 0x00000000
size : 0x00000000
driver: framebuffer
Video/Mode info:
Video output not enabled
Current video mode:
No video mode selected yet
Supported video mode(s):
'VGA'
'SVGA'
'XGA'
'SXGA'
Parameters:
cdepth = 16
mode = <NULL>
enable = <NULL>
tx28:/ framebuffer0.mode=SVGA
tx28:/ bmp splash.bmp
tx28:/ framebuffer0.enable=1
After the last command the monitor shows the splash screen.
Changes in revision 2 of this patch stack:
- enabling the video output is now always required to get a picture
- driver specific data can now be added on a per videomode base
- documentation is adapted to the new behaviour
This is revision 3 of this patch stack:
- video output is now disabled as default, until enabled with 'framebuffer0.enable=1'
- framebuffer's 'dev' and 'cdev' are now part of the 'fb_info'
- using a fixed framebuffer location is only handled in the driver
- hopefully fixed all long lines
- swapping the API in '/drivers/video/fb.c' is now done in one patch
- when adding to the final repository, still these patches should be squashed to keep the result bisectable:
- "Bring in dynamic videomode selection at runtime"
- "Add verbose framebuffer device info"
- "Adapt the existing imx fb driver to support runtime videomode selection"
- "Adapt the existing imx-ipu fb driver to support runtime videomode selection"
- the videomode can now be setup more than once. To do so, just disable the video output again and start with videomode configuration once more
Note: The S3C2404 and i.MX23/i.MX28 framebuffer drivers are still for reference only.
The following changes since commit 53dbaf3fc7b8371ed1e24ef96715e41d60b8ebc3:
Merge branch 'master' into next (2010-11-19 09:35:15 +0100)
are available in the git repository at:
http://git.pengutronix.de/jbe/for_barebox_next/ next_dynamic_video_v3_for_sha
Juergen Beisert (11):
Separate framebuffer platformdata and the videomode
Add more flags for sync control
Bring in dynamic videomode selection at runtime
Add verbose framebuffer device info
Adapt the existing imx fb driver to support runtime videomode selection Adapt the existing imx-ipu fb driver to support runtime videomode selection Remove variable size restrictions
Add doxygen documentation to the framebfuffer code
Provide more driver specific data in a videomode
Add a video driver for S3C2440 bases platforms
STM378x: Add video driver for this platform
Documentation/developers_manual.dox | 1 + Documentation/users_manual.dox | 1 + arch/arm/boards/eukrea_cpuimx25/eukrea_cpuimx25.c | 39 +- arch/arm/boards/eukrea_cpuimx27/eukrea_cpuimx27.c | 41 +- arch/arm/boards/freescale-mx35-3-stack/3stack.c | 2 +- arch/arm/boards/guf-neso/board.c | 43 +- arch/arm/boards/imx21ads/imx21ads.c | 48 +- arch/arm/boards/pcm038/pcm038.c | 42 +- arch/arm/boards/pcm043/pcm043.c | 2 +- arch/arm/mach-imx/include/mach/imx-ipu-fb.h | 12 +- arch/arm/mach-imx/include/mach/imxfb.h | 21 +- arch/arm/mach-s3c24xx/include/mach/fb.h | 40 ++ arch/arm/mach-stm/include/mach/fb.h | 33 + drivers/video/Kconfig | 23 + drivers/video/Makefile | 2 + drivers/video/fb.c | 452 ++++++++++++++- drivers/video/imx-ipu-fb.c | 217 ++++--- drivers/video/imx.c | 220 ++++--- drivers/video/s3c.c | 474 +++++++++++++++ drivers/video/stm.c | 646 +++++++++++++++++++++ include/fb.h | 133 +++-- 21 files changed, 2112 insertions(+), 380 deletions(-) create mode 100644 arch/arm/mach-s3c24xx/include/mach/fb.h create mode 100644 arch/arm/mach-stm/include/mach/fb.h create mode 100644 drivers/video/s3c.c create mode 100644 drivers/video/stm.c
_______________________________________________
barebox mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/barebox
PATCH 1/11 Separate framebuffer platformdata and the videomode
This patch separates the imx platformdata and its videomode in two structures, in order to support more than one defined videomode in the boardfile. This is intended to support runtime videomode selection later on. It also uses now the same videomode setup style than the imx-fpu based systems (like the i.MX35).
--- arch/arm/boards/eukrea_cpuimx25/eukrea_cpuimx25.c | 28 +++++++++-------- arch/arm/boards/eukrea_cpuimx27/eukrea_cpuimx27.c | 28 +++++++++-------- arch/arm/boards/guf-neso/board.c | 28 +++++++++-------- arch/arm/boards/imx21ads/imx21ads.c | 34 +++++++++++---------- arch/arm/boards/pcm038/pcm038.c | 28 +++++++++-------- arch/arm/mach-imx/include/mach/imxfb.h | 2 +- drivers/video/imx.c | 6 ++-- 7 files changed, 82 insertions(+), 72 deletions(-)
arch/arm/boards/eukrea_cpuimx25/eukrea_cpuimx25.c +15 -13
@@ -107,20 +107,22 @@ struct imx_nand_platform_data nand_info = { .hw_ecc = 1, }; +static struct fb_videomode cmo_display = { + .name ="CMO-QVGA" , + .refresh =60 , + .xres =320 , + .yres =240 , + .pixclock =KHZ2PICOS (6500 ), + .hsync_len =30 , + .left_margin =38 , + .right_margin =20 , + .vsync_len =3 , + .upper_margin =15 , + .lower_margin =4 , +}; +static struct imx_fb_videomode imxfb_mode = { - .mode = { - .name ="CMO-QVGA" , - .refresh =60 , - .xres =320 , - .yres =240 , - .pixclock =KHZ2PICOS (6500 ), - .hsync_len =30 , - .left_margin =38 , - .right_margin =20 , - .vsync_len =3 , - .upper_margin =15 , - .lower_margin =4 , - }, + .mode = &cmo_display, .pcr =0xCAD08B80 , .bpp =16 , };
arch/arm/boards/eukrea_cpuimx27/eukrea_cpuimx27.c +15 -13
@@ -167,20 +167,22 @@ static void eukrea_cpuimx27_mmu_init(void)#endif #ifdef CONFIG_DRIVER_VIDEO_IMX +static struct fb_videomode cmo_display = { + .name ="CMO-QVGA" , + .refresh =60 , + .xres =320 , + .yres =240 , + .pixclock =156000 , + .hsync_len =30 , + .left_margin =38 , + .right_margin =20 , + .vsync_len =3 , + .upper_margin =15 , + .lower_margin =4 , +}; +static struct imx_fb_videomode imxfb_mode = { - .mode = { - .name ="CMO-QVGA" , - .refresh =60 , - .xres =320 , - .yres =240 , - .pixclock =156000 , - .hsync_len =30 , - .left_margin =38 , - .right_margin =20 , - .vsync_len =3 , - .upper_margin =15 , - .lower_margin =4 , - }, + .mode = &cmo_display, .pcr =0xFAD08B80 , .bpp =16 ,};
arch/arm/boards/guf-neso/board.c +15 -13
@@ -78,20 +78,22 @@ static struct imx_nand_platform_data nand_info = { .flash_bbt = 1, }; +static struct fb_videomode cpt_display = { + .name ="CPT CLAA070LC0JCT" , + .refresh =60 , + .xres =800 , + .yres =480 , + .pixclock =KHZ2PICOS (27000 ), + .hsync_len =1 ,/* DE only sync */ + .left_margin =50 , + .right_margin =50 , + .vsync_len =1 ,/* DE only sync */ + .upper_margin =10 , + .lower_margin =10 , +}; +static struct imx_fb_videomode imxfb_mode = { - .mode = { - .name ="CPT CLAA070LC0JCT" , - .refresh =60 , - .xres =800 , - .yres =480 , - .pixclock =KHZ2PICOS (27000 ), - .hsync_len =1 ,/* DE only sync */ - .left_margin =50 , - .right_margin =50 , - .vsync_len =1 ,/* DE only sync */ - .upper_margin =10 , - .lower_margin =10 , - }, + .mode = &cpt_display,/* * - TFT style panel * - clk enabled while idle
arch/arm/boards/imx21ads/imx21ads.c +18 -16
@@ -73,24 +73,26 @@ static struct device_d cs8900_dev = {// IRQ is connected to UART3_RTS }; +static struct fb_videomode sharp_display = { + .name ="Sharp-LQ035Q7" , + .refresh =60 , + .xres =240 , + .yres =320 , + .pixclock =188679 , + .left_margin =6 , + .right_margin =16 , + .upper_margin =8 , + .lower_margin =10 , + .hsync_len =2 , + .vsync_len =1 , + .sync =0 , + .vmode =FB_VMODE_NONINTERLACED , + .flag =0 , +}; +/* Sharp LQ035Q7DB02 QVGA display */ static struct imx_fb_videomode imx_fb_modedata = { - .mode = { - .name ="Sharp-LQ035Q7" , - .refresh =60 , - .xres =240 , - .yres =320 , - .pixclock =188679 , - .left_margin =6 , - .right_margin =16 , - .upper_margin =8 , - .lower_margin =10 , - .hsync_len =2 , - .vsync_len =1 , - .sync =0 , - .vmode =FB_VMODE_NONINTERLACED , - .flag =0 , - }, + .mode = &sharp_display, .pcr =0xfb108bc7 , .bpp =16 , };
arch/arm/boards/pcm038/pcm038.c +15 -13
@@ -107,20 +107,22 @@ static struct imx_nand_platform_data nand_info = { .flash_bbt = 1, }; +static struct fb_videomode sharp_display = { + .name ="Sharp-LQ035Q7" , + .refresh =60 , + .xres =240 , + .yres =320 , + .pixclock =188679 ,/* in ps (5.3MHz) */ + .hsync_len =7 , + .left_margin =5 , + .right_margin =16 , + .vsync_len =1 , + .upper_margin =7 , + .lower_margin =9 , +}; +static struct imx_fb_videomode imxfb_mode = { - .mode = { - .name ="Sharp-LQ035Q7" , - .refresh =60 , - .xres =240 , - .yres =320 , - .pixclock =188679 ,/* in ps (5.3MHz) */ - .hsync_len =7 , - .left_margin =5 , - .right_margin =16 , - .vsync_len =1 , - .upper_margin =7 , - .lower_margin =9 , - }, + .mode = &sharp_display,/* * - HSYNC active high * - VSYNC active high
arch/arm/mach-imx/include/mach/imxfb.h +1 -1
@@ -53,7 +53,7 @@#define DMACR_TM (x) ((x) & 0xf)struct imx_fb_videomode { -struct fb_videomode mode; +struct fb_videomode *mode;u32 pcr;unsigned char bpp; };
drivers/video/imx.c +3 -3
@@ -555,9 +555,9 @@ static int imxfb_probe(struct device_d *dev) fbi->enable = pdata->enable; fbi->dev = dev; info->priv = fbi; - info->mode = &pdata->mode->mode; - info->xres = pdata->mode->mode.xres; - info->yres = pdata->mode->mode.yres; + info->mode = pdata->mode->mode; + info->xres = pdata->mode->mode->xres; + info->yres = pdata->mode->mode->yres; info->bits_per_pixel = pdata->mode->bpp; info->fbops = &imxfb_ops;
Signature · 7 lines
1.7.2.3 _______________________________________________ barebox mailing list [email protected] http://lists.infradead.org/mailman/listinfo/barebox
PATCH 2/11 Add more flags for sync control
In reply to Juergen BeisertIn order to make video mode setup and initializing a runtime job (currently it is a compile time job) this patch tries to make the 'fb_videomode' structure more generic. It should also carry special settings required only for some LC displays. So, I add some additional sync flags to control the DE and CLCK to the display (something a regular CRT do not know). Also the possibility to stop the clock when outside active display data (required for (C)STN).
Further suggestions for useful flags?
--- include/fb.h | 10 ++++++++++ 1 files changed, 10 insertions(+), 0 deletions(-)
include/fb.h +10 -0
@@ -17,11 +17,21 @@/* vtotal = 144d/288n/576i => PAL */ /* vtotal = 121d/242n/484i => NTSC */ #define FB_SYNC_ON_GREEN 32/* sync on green */ +/* LC display related settings */ +#define FB_SYNC_DE_HIGH_ACT (1 << 6) +#define FB_SYNC_CLK_INVERT (1 << 7) +#define FB_SYNC_DATA_INVERT (1 << 8) +#define FB_SYNC_CLK_IDLE_EN (1 << 9) +#define FB_SYNC_SWAP_RGB (1 << 10) +#define FB_SYNC_CLK_SEL_EN (1 << 11) +#define FB_SYNC_SHARP_MODE (1 << 31)#define FB_VMODE_NONINTERLACED 0/* non interlaced */ #define FB_VMODE_INTERLACED 1/* interlaced */ #define FB_VMODE_DOUBLE 2/* double scan */ #define FB_VMODE_ODD_FLD_FIRST 4/* interlaced: top line first */ +/* LC display related settings */ +#define FB_VMODE_DUAL_SCAN 8#define FB_VMODE_MASK 255#define FB_VMODE_YWRAP 256/* ywrap instead of panning */
Signature · 7 lines
1.7.2.3 _______________________________________________ barebox mailing list [email protected] http://lists.infradead.org/mailman/listinfo/barebox
PATCH 3/11 Bring in dynamic videomode selection at runtime
In reply to Juergen BeisertThis patch mostly rewrites all parts of /drivers/video/fb.c. As it changes the API to the drivers, it must be done in one step to keep the repository bisectable. But to do it in one step makes the patches itself unreadable.
So, I decided to do it in a few steps, only for the review. All patches marked with a "patch n of m" should be merged, prior the final commit onto the repository.
This step brings in the required function for dynamic videomode selection at runtime.
This is patch 1 of 4 to keep the repository bisectable.
--- drivers/video/fb.c | 201 +++++++++++++++++++++++++++++++++++++++++++++------- include/fb.h | 31 ++++---- 2 files changed, 192 insertions(+), 40 deletions(-)
drivers/video/fb.c +176 -25
@@ -1,3 +1,4 @@ +#include <init.h> #include <common.h> #include <fb.h> #include <errno.h>
@@ -5,9 +6,14 @@#include <getopt.h> #include <fcntl.h> #include <fs.h> +#include <malloc.h> +#include <xfuncs.h> + +#define to_fb_info (x) (container_of(x, struct fb_info, fb_dev))static int fb_ioctl (struct cdev * cdev,int req,void *data) { +struct fb_host *host = cdev->dev->platform_data;struct fb_info *info = cdev->priv;switch (req) {
@@ -15,10 +21,10 @@ static int fb_ioctl(struct cdev* cdev, int req, void *data)memcpy (data, info,sizeof (*info));break ;case FBIO_ENABLE : - info->fbops->fb_enable (info); + host->fb_enable (cdev->priv);break ;case FBIO_DISABLE : - info->fbops->fb_disable (info); + host->fb_disable (cdev->priv);break ;default :return -ENOSYS ;
@@ -27,15 +33,47 @@ static int fb_ioctl(struct cdev* cdev, int req, void *data)return 0 ; } -static int fb_enable_set (struct device_d *dev,struct param_d *param, -const char *val) +static int fb_check_if_already_initialized (struct device_d *fb_dev) +{ +struct fb_info *info =to_fb_info (fb_dev); + +if (info->enabled) { +dev_err (&info->fb_dev,"Video output is active. Cannot change " +"until disabled\n" ); +return -EPERM ; + } + +return 0 ; +} + +static int fb_cdepth_set (struct device_d *fb_dev,struct param_d *param,const char *val) { -struct fb_info *info = dev->priv; +struct fb_info *info =to_fb_info (fb_dev); +unsigned cdepth; +int rc; + + rc =fb_check_if_already_initialized (fb_dev); +if (rc !=0 ) +return rc; + + cdepth =simple_strtoul (val,NULL ,0 ); +if (cdepth !=0 ) + info->bits_per_pixel = cdepth; +else +return -EINVAL ; + +return dev_param_set_generic (fb_dev, param, val); +} + +static int fb_enable_set (struct device_d *fb_dev,struct param_d *param,const char *val) +{ +struct fb_info *info =to_fb_info (fb_dev); +struct fb_host *host = info->host;int enable;char *new;if (!val) -return dev_param_set_generic (dev, param,NULL ); +return dev_param_set_generic (fb_dev, param,NULL ); enable =simple_strtoul (val,NULL ,0 );
@@ -43,20 +81,79 @@ static int fb_enable_set(struct device_d *dev, struct param_d *param,return 0 ;if (enable) { - info->fbops->fb_enable (info); + host->fb_enable (info); new ="1" ; }else { - info->fbops->fb_disable (info); + host->fb_disable (info); new ="0" ; } -dev_param_set_generic (dev, param, new); - info->enabled = !!enable; +return dev_param_set_generic (fb_dev, param, new); +} + +static void fb_list_modes (struct fb_host *host) +{ +unsigned u; + +printf (" Supported video mode(s):\n" ); +for (u =0 ; u < host->mode_cnt; u++) +printf (" '%s'\n" , host->mode[u].name); +} + +static int fb_activate_mode (struct device_d *fb_dev,const struct fb_videomode *mode) +{ +struct fb_info *info =to_fb_info (fb_dev); +struct fb_host *host = info->host; +int rc; + + rc = host->fb_mode (info, mode); +if (rc !=0 ) +return rc; + + info->active_mode = mode; +/* +* At this point of time we know the remaining information we need +* for the cdev and fb_info structure. +*/ + info->cdev.size = fb_dev->size; + info->xres = mode->xres; + info->yres = mode->yres; +return 0 ; } +static int fb_mode_set (struct device_d *fb_dev,struct param_d *param,const char *name) +{ +struct fb_host *host = fb_dev->platform_data; +unsigned u; +int rc; + +pr_debug ("%s called\n" , __func__); + + rc =fb_check_if_already_initialized (fb_dev); +if (rc !=0 ) +return rc; + +/* Search for the requested video mode by name */ +for (u =0 ; u < host->mode_cnt; u++) { +if (!strcmp (host->mode[u].name, name)) +break ; + } +if (u >= host->mode_cnt) { +fb_list_modes (host);/* no mode with 'name' found */ +return -ENODEV ; + }else { + rc =fb_activate_mode (fb_dev, &host->mode[u]); + } + +if (rc ==0 ) +dev_param_set_generic (fb_dev, param, name); + +return rc; +} +static struct file_operations fb_ops = { .read = mem_read, .write = mem_write,
@@ -65,31 +162,85 @@ static struct file_operations fb_ops = { .ioctl = fb_ioctl, }; -int register_framebuffer (struct fb_info *info) +static int add_fb_parameter (struct fb_info *info) +{ +char cd[10 ]; + +/** @todo provide base address parameter for the user. Useful? */ + +dev_add_param (&info->fb_dev,"cdepth" , fb_cdepth_set,NULL ,0 ); +if (info->bits_per_pixel ==0 ) { +dev_set_param (&info->fb_dev,"cdepth" ,"16" ); + info->bits_per_pixel =16 ; + }else { +sprintf (cd,"%u" , info->bits_per_pixel); +dev_set_param (&info->fb_dev,"cdepth" , cd); + } + +/* default is 'none' */ +dev_add_param (&info->fb_dev,"mode" , fb_mode_set,NULL ,0 ); + +/* default is '0' for 'no output enabled' */ +dev_add_param (&info->fb_dev,"enable" , fb_enable_set,NULL ,0 ); + +return 0 ; +} + +static int fb_probe (struct device_d *fb_dev) {int id =get_free_deviceid ("fb" ); -struct device_d *dev; +struct fb_info *info =to_fb_info (fb_dev); +struct fb_host *host = info->host; + + fb_dev->priv = &info->cdev;/* pointer forward */ + info->cdev.dev = fb_dev;/* pointer backward */ + info->cdev.priv = info;/* pointer backward */ info->cdev.ops = &fb_ops; info->cdev.name =asprintf ("fb%d" , id); - info->cdev.size = info->xres * info->yres * (info->bits_per_pixel >>3 ); - info->cdev.dev = &info->dev; - info->cdev.priv = info; - info->cdev.dev->map_base = (unsigned long )info->screen_base; - info->cdev.dev->size = info->cdev.size; - dev = &info->dev; - dev->priv = info; - dev->id = id; + info->host = host; -sprintf (dev->name,"fb" ); +/* setup defaults */ +if (host->bits_per_pixel !=0 ) + info->bits_per_pixel = host->bits_per_pixel; +else + info->bits_per_pixel =16 ; -register_device (&info->dev); -dev_add_param (dev,"enable" , fb_enable_set,NULL ,0 ); -dev_set_param (dev,"enable" ,"0" ); +add_fb_parameter (info);devfs_create (&info->cdev); -return 0 ; } +static struct driver_d fb_driver = { + .name ="framebuffer" , + .probe = fb_probe, +}; + +static int framebuffer_init (void ) +{ +return register_driver (&fb_driver); +} + +device_initcall (framebuffer_init); + +struct device_d *register_framebuffer (struct fb_host *host) +{ +struct fb_info *fb_info; +int rc; + + fb_info =xzalloc (sizeof (struct fb_info )); + +strcpy (fb_info->fb_dev.name, fb_driver.name); + fb_info->host = fb_info->fb_dev.platform_data = (void *)host; + + rc =register_device (&fb_info->fb_dev); +if (rc !=0 ) { +pr_debug ("Cannot register framebuffer device\n" ); +free (fb_info); +return NULL ; + } + +return &fb_info->fb_dev; +}
include/fb.h +16 -15
@@ -77,25 +77,26 @@ struct fb_bitfield {struct fb_info ; -struct fb_ops { -/* set color register */ -int (*fb_setcolreg)(unsigned regno,unsigned red,unsigned green, -unsigned blue,unsigned transp,struct fb_info *info); -void (*fb_enable)(struct fb_info *info); -void (*fb_disable)(struct fb_info *info); -}; - -struct fb_info { -struct fb_videomode *mode; +struct fb_host { +const struct fb_videomode *mode; +unsigned mode_cnt; -struct fb_ops *fbops; -struct device_d dev;/* This is this fb device */ +struct device_d *hw_dev; -void *screen_base; +/* callbacks into the video hardware driver */ +int (*fb_setcolreg)(struct fb_info *,unsigned ,unsigned ,unsigned ,unsigned ,unsigned ); +int (*fb_mode)(struct fb_info *,const struct fb_videomode *); +void (*fb_enable)(struct fb_info *); +void (*fb_disable)(struct fb_info *); -void *priv; +unsigned bits_per_pixel; +}; +struct fb_info { +struct fb_host *host; +struct device_d fb_dev;struct cdev cdev; +const struct fb_videomode *active_mode;u32 xres;/* visible resolution */ u32 yres;
@@ -111,7 +112,7 @@ struct fb_info {int enabled; }; -int register_framebuffer (struct fb_info *info); +struct device_d *register_framebuffer (struct fb_host *);#define FBIOGET_SCREENINFO _IOR('F', 1, loff_t)#define FBIO_ENABLE _IO('F', 2)
Signature · 7 lines
1.7.2.3 _______________________________________________ barebox mailing list [email protected] http://lists.infradead.org/mailman/listinfo/barebox
PATCH 4/11 Add verbose framebuffer device info
In reply to Juergen BeisertThis is patch 2 of 4 to keep the repository bisectable.
--- drivers/video/Kconfig | 10 ++++++++++ drivers/video/fb.c | 49 +++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 59 insertions(+), 0 deletions(-)
drivers/video/Kconfig +10 -0
@@ -5,6 +5,16 @@ menuconfig VIDEO if VIDEO +comment "runtime options" + +config VIDEO_INFO_VERBOSE + bool "Verbose video info" + help + Say 'y' here to be more verbose when running the 'devinfo' command + on the framebuffer device. + +comment "drivers" + config DRIVER_VIDEO_IMX bool "i.MX framebuffer driver" depends on ARCH_IMX1 || ARCH_IMX21 || ARCH_IMX25 || ARCH_IMX27
drivers/video/fb.c +49 -0
61 lines not on this page · raw message
Signature · 7 lines
1.7.2.3 _______________________________________________ barebox mailing list [email protected] http://lists.infradead.org/mailman/listinfo/barebox
PATCH 5/11 Adapt the existing imx fb driver to support runtime videomode selection
In reply to Juergen BeisertAdapt the API to the new framebuffer videomode selection at runtime.
NOTE: Due to the lack of hardware, this is compile time tested only.
This is patch 3 of 4 to keep the repository bisectable.
--- arch/arm/mach-imx/include/mach/imxfb.h | 1 + drivers/video/imx.c | 209 ++++++++++++++++++------------- 2 files changed, 122 insertions(+), 88 deletions(-)
arch/arm/mach-imx/include/mach/imxfb.h +1 -0
@@ -63,6 +63,7 @@ struct imx_fb_videomode {*/ struct imx_fb_platform_data {struct imx_fb_videomode *mode; +unsigned mode_cnt;/**< number of entries in 'mode' */ u_int cmap_greyscale:1 , cmap_inverse:1,
drivers/video/imx.c +121 -88
351 lines not on this page · raw message
Signature · 7 lines
1.7.2.3 _______________________________________________ barebox mailing list [email protected] http://lists.infradead.org/mailman/listinfo/barebox
PATCH 6/11 Adapt the existing imx-ipu fb driver to support runtime videomode selection
In reply to Juergen BeisertAdapt the API to the new framebuffer videomode selection at runtime.
NOTE: Due to the lack of hardware, this is compile time tested only.
This is patch 4 of 4 to keep the repository bisectable.
--- arch/arm/boards/freescale-mx35-3-stack/3stack.c | 2 +- arch/arm/boards/pcm043/pcm043.c | 2 +- arch/arm/mach-imx/include/mach/imx-ipu-fb.h | 12 +- drivers/video/imx-ipu-fb.c | 217 +++++++++++++---------- 4 files changed, 125 insertions(+), 108 deletions(-)
arch/arm/boards/freescale-mx35-3-stack/3stack.c +1 -1
@@ -126,7 +126,7 @@ static struct fb_videomode CTP_CLAA070LC0ACW = { .lower_margin = 10, /* whole frame should have 500 lines */ .hsync_len = 1, /* note: DE only display */ .vsync_len = 1, /* note: DE only display */ - .sync = FB_SYNC_CLK_IDLE_EN | FB_SYNC_OE_ACT_HIGH, + .sync = FB_SYNC_CLK_IDLE_EN | FB_SYNC_DE_HIGH_ACT, .vmode = FB_VMODE_NONINTERLACED, .flag = 0, };
arch/arm/boards/pcm043/pcm043.c +1 -1
@@ -111,7 +111,7 @@ static struct fb_videomode pcm043_fb_mode = { .lower_margin = 40, .hsync_len = 96, .vsync_len = 1, - .sync = FB_SYNC_VERT_HIGH_ACT | FB_SYNC_OE_ACT_HIGH, + .sync = FB_SYNC_VERT_HIGH_ACT | FB_SYNC_DE_HIGH_ACT, .vmode = FB_VMODE_NONINTERLACED, .flag = 0, };
arch/arm/mach-imx/include/mach/imx-ipu-fb.h +2 -10
@@ -12,20 +12,12 @@#include <fb.h> -/* Proprietary FB_SYNC_ flags */ -#define FB_SYNC_OE_ACT_HIGH 0x80000000 -#define FB_SYNC_CLK_INVERT 0x40000000 -#define FB_SYNC_DATA_INVERT 0x20000000 -#define FB_SYNC_CLK_IDLE_EN 0x10000000 -#define FB_SYNC_SHARP_MODE 0x08000000 -#define FB_SYNC_SWAP_RGB 0x04000000 -#define FB_SYNC_CLK_SEL_EN 0x02000000 -/* -* struct mx3fb_platform_data - mx3fb platform data +* struct imx_ipu_fb_platform_data - imx-ipu-fb's platform data */ struct imx_ipu_fb_platform_data {struct fb_videomode *mode; +unsigned mode_cnt;/**< number of entries in 'mode' */ unsigned char bpp;void __iomem *framebuffer;/** hook to enable backlight and stuff */
drivers/video/imx-ipu-fb.c +121 -96
383 lines not on this page · raw message
Signature · 7 lines
1.7.2.3 _______________________________________________ barebox mailing list [email protected] http://lists.infradead.org/mailman/listinfo/barebox
PATCH 7/11 Remove variable size restrictions
In reply to Juergen BeisertThere is no really need for restricted variable types in these structures. Replace them by standard C types with the same behaviour.
--- include/fb.h | 41 ++++++++++++++++++++--------------------- 1 files changed, 20 insertions(+), 21 deletions(-)
include/fb.h +20 -21
@@ -43,19 +43,19 @@struct fb_videomode {const char *name;/* optional */ -u32 refresh;/* optional */ -u32 xres; -u32 yres; -u32 pixclock; -u32 left_margin; -u32 right_margin; -u32 upper_margin; -u32 lower_margin; -u32 hsync_len; -u32 vsync_len; -u32 sync; -u32 vmode; -u32 flag; +unsigned refresh;/* optional */ +unsigned xres; +unsigned yres; +unsigned pixclock; +unsigned left_margin; +unsigned right_margin; +unsigned upper_margin; +unsigned lower_margin; +unsigned hsync_len; +unsigned vsync_len; +unsigned sync; +unsigned vmode; +unsigned flag; };/* Interpretation of offset for color fields: All offsets are from the right,
@@ -69,10 +69,9 @@ struct fb_videomode {* of available palette entries (i.e. # of entries = 1 << length). */ struct fb_bitfield { -u32 offset;/* beginning of bitfield */ -u32 length;/* length of bitfield */ -u32 msb_right;/* != 0 : Most significant bit is */ -/* right */ +unsigned offset;/* beginning of bitfield */ +unsigned length;/* length of bitfield */ +int msb_right;/* != 0 : Most significant bit is right */ };struct fb_info ;
@@ -98,11 +97,11 @@ struct fb_info {struct cdev cdev;const struct fb_videomode *active_mode; -u32 xres;/* visible resolution */ -u32 yres; -u32 bits_per_pixel;/* guess what */ +unsigned xres;/* visible resolution */ +unsigned yres; +unsigned bits_per_pixel;/* guess what */ -u32 grayscale;/* != 0 Graylevels instead of colors */ +int grayscale;/* != 0 Graylevels instead of colors */ struct fb_bitfield red;/* bitfield in fb mem if true color, */ struct fb_bitfield green;/* else only length is significant */
Signature · 7 lines
1.7.2.3 _______________________________________________ barebox mailing list [email protected] http://lists.infradead.org/mailman/listinfo/barebox
PATCH 8/11 Add doxygen documentation to the framebfuffer code
In reply to Juergen BeisertAdd some (hopefully) helpful documentation to the source code.
--- Documentation/developers_manual.dox | 1 + Documentation/users_manual.dox | 1 + drivers/video/fb.c | 202 +++++++++++++++++++++++++++++++++++ include/fb.h | 97 +++++++++++------ 4 files changed, 269 insertions(+), 32 deletions(-)
Documentation/developers_manual.dox +1 -0
@@ -20,5 +20,6 @@ This part of the documentation is intended for developers of @a barebox. @li @subpage barebox_simul @li @subpage io_access_functions @li @subpage mcfv4e_MCDlib +@li @subpage fb_for_developers */
Documentation/users_manual.dox +1 -0
@@ -14,5 +14,6 @@ you find a lot of nice tricks on these pages to make your life easier. @li @subpage readline_parser @li @subpage x86_bootloader @li @subpage net_netconsole +@li @subpage fb_for_users */
drivers/video/fb.c +202 -0
253 lines not on this page · raw message
include/fb.h +65 -32
146 lines not on this page · raw message
Signature · 7 lines
1.7.2.3 _______________________________________________ barebox mailing list [email protected] http://lists.infradead.org/mailman/listinfo/barebox
PATCH 9/11 Provide more driver specific data in a videomode
In reply to Juergen BeisertIn order to support more than one videomode in a binary barebox, some drivers need more specific data to setup the requested video mode in a correct manner. This patch adds the 'priv' field to the generic videomode description to give any platform a chance to forward some video hardware specific information on a per videomode base.
This is currently i.MX21/i.MX25/i.MX27 specific.
BTW: At least the 'pcr' value could be generated at runtime from the 'sync' field in 'struct fb_videomode'.
--- arch/arm/boards/eukrea_cpuimx25/eukrea_cpuimx25.c | 21 +++++----- arch/arm/boards/eukrea_cpuimx27/eukrea_cpuimx27.c | 21 +++++----- arch/arm/boards/guf-neso/board.c | 45 +++++++++++---------- arch/arm/boards/imx21ads/imx21ads.c | 24 ++++++------ arch/arm/boards/pcm038/pcm038.c | 40 +++++++++--------- arch/arm/mach-imx/include/mach/imxfb.h | 20 +++++---- drivers/video/imx.c | 19 +++++---- include/fb.h | 2 + 8 files changed, 99 insertions(+), 93 deletions(-)
arch/arm/boards/eukrea_cpuimx25/eukrea_cpuimx25.c +10 -11
@@ -107,7 +107,14 @@ struct imx_nand_platform_data nand_info = { .hw_ecc = 1, }; -static struct fb_videomode cmo_display = { +static const struct imx_fb_driver_data driver_data = { + .pwmr =0x00A903FF , + .lscr1 =0x00120300 , + .dmacr =0x80040060 , + .pcr =0xCAD08B80 , +}; + +static const struct fb_videomode cmo_display = { .name ="CMO-QVGA" , .refresh =60 , .xres =320 ,
@@ -121,17 +128,9 @@ static struct fb_videomode cmo_display = { .lower_margin = 4, }; -static struct imx_fb_videomode imxfb_mode = { - .mode = &cmo_display, - .pcr =0xCAD08B80 , - .bpp =16 , -}; -static struct imx_fb_platform_data eukrea_cpuimx25_fb_data = { - .mode = &imxfb_mode, - .pwmr =0x00A903FF , - .lscr1 =0x00120300 , - .dmacr =0x80040060 , + .mode = &cmo_display, + .mode_cnt =1 , };#ifdef CONFIG_USB
arch/arm/boards/eukrea_cpuimx27/eukrea_cpuimx27.c +11 -10
@@ -167,7 +167,14 @@ static void eukrea_cpuimx27_mmu_init(void)#endif #ifdef CONFIG_DRIVER_VIDEO_IMX -static struct fb_videomode cmo_display = { +static const struct imx_fb_driver_data driver_data = { + .pwmr =0x00A903FF , + .lscr1 =0x00120300 , + .dmacr =0x00020010 , + .pcr =0xFAD08B80 , +}; + +static const struct fb_videomode cmo_display = { .name ="CMO-QVGA" , .refresh =60 , .xres = 320,
@@ -179,18 +186,12 @@ static struct fb_videomode cmo_display = { .vsync_len = 3, .upper_margin = 15, .lower_margin = 4, + .priv = &driver_data, }; -static struct imx_fb_videomode imxfb_mode = { - .mode = &cmo_display, - .pcr =0xFAD08B80 , - .bpp =16 ,}; -static struct imx_fb_platform_data eukrea_cpuimx27_fb_data = { - .mode = &imxfb_mode, - .pwmr =0x00A903FF , - .lscr1 =0x00120300 , - .dmacr =0x00020010 , + .mode = &cmo_display, + .mode_cnt =1 , };static struct device_d imxfb_dev = {
arch/arm/boards/guf-neso/board.c +23 -22
64 lines not on this page · raw message
arch/arm/boards/imx21ads/imx21ads.c +12 -12
@@ -73,7 +73,14 @@ static struct device_d cs8900_dev = {// IRQ is connected to UART3_RTS }; -static struct fb_videomode sharp_display = { +static const struct imx_fb_driver_data driver_data = { + .pwmr =0x00a903ff , + .lscr1 =0x00120300 , + .dmacr =0x00020008 , + .pcr =0xfb108bc7 , +}; + +static const struct fb_videomode sharp_display = { .name ="Sharp-LQ035Q7" , .refresh =60 , .xres =240 ,
@@ -88,23 +95,16 @@ static struct fb_videomode sharp_display = { .sync = 0, .vmode = FB_VMODE_NONINTERLACED, .flag = 0, -}; - -/* Sharp LQ035Q7DB02 QVGA display */ -static struct imx_fb_videomode imx_fb_modedata = { - .mode = &sharp_display, - .pcr =0xfb108bc7 , - .bpp =16 , + .priv = &driver_data, };static struct imx_fb_platform_data imx_fb_data = { - .mode = &imx_fb_modedata, +/* Sharp LQ035Q7DB02 QVGA display */ + .mode = &sharp_display, + .mode_cnt =1 , .cmap_greyscale =0 , .cmap_inverse =0 , .cmap_static =0 , - .pwmr =0x00a903ff , - .lscr1 =0x00120300 , - .dmacr =0x00020008 , };static int imx21ads_timing_init (void )
arch/arm/boards/pcm038/pcm038.c +20 -20
@@ -107,7 +107,23 @@ static struct imx_nand_platform_data nand_info = { .flash_bbt = 1, }; -static struct fb_videomode sharp_display = { +static const struct imx_fb_driver_data driver_data = { +/* +* - HSYNC active high +* - VSYNC active high +* - clk notenabled while idle +* - clock not inverted +* - data not inverted +* - data enable low active +* - enable sharp mode +*/ + .pwmr =0x00A903FF , + .lscr1 =0x00120300 , + .dmacr =0x00020010 , + .pcr =0xF00080C0 , +}; + +static const struct fb_videomode sharp_display = { .name ="Sharp-LQ035Q7" , .refresh =60 , .xres =240 ,
@@ -119,28 +135,12 @@ static struct fb_videomode sharp_display = { .vsync_len = 1, .upper_margin = 7, .lower_margin = 9, -}; - -static struct imx_fb_videomode imxfb_mode = { - .mode = &sharp_display, -/* -* - HSYNC active high -* - VSYNC active high -* - clk notenabled while idle -* - clock not inverted -* - data not inverted -* - data enable low active -* - enable sharp mode -*/ - .pcr =0xF00080C0 , - .bpp =16 , + .priv = &driver_data, };static struct imx_fb_platform_data pcm038_fb_data = { - .mode = &imxfb_mode, - .pwmr =0x00A903FF , - .lscr1 =0x00120300 , - .dmacr =0x00020010 , + .mode = &sharp_display, + .mode_cnt =1 , };#ifdef CONFIG_USB
arch/arm/mach-imx/include/mach/imxfb.h +11 -9
@@ -52,28 +52,30 @@#define DMACR_HM (x) (((x) & 0xf) << 16)#define DMACR_TM (x) ((x) & 0xf) -struct imx_fb_videomode { -struct fb_videomode *mode; -u32 pcr; -unsigned char bpp; +/** +* Videomode dependent, but driver specific data +*/ +struct imx_fb_driver_data { +uint32_t pwmr;/**< refer datasheet: LPCCR register */ +uint32_t lscr1;/**< refer datasheet: LSCR register */ +uint32_t dmacr;/**< refer datasheet: LDCR register */ +uint32_t pcr;/**< refer datasheet: LPCR register */ };/** * Define relevant framebuffer information */ struct imx_fb_platform_data { -struct imx_fb_videomode *mode; +const struct fb_videomode *mode;unsigned mode_cnt;/**< number of entries in 'mode' */ +unsigned char bpp;/**< preferred colour depth for this device */ +u_int cmap_greyscale:1 , cmap_inverse:1 , cmap_static:1 , unused:29 ; -u_int pwmr; -u_int lscr1; -u_int dmacr; -/** force a memory area to be used, else NULL for dynamic allocation */ void *framebuffer;/** force a memory area to be used, else NULL for dynamic allocation */
drivers/video/imx.c +10 -9
@@ -332,6 +332,7 @@ static int imxfb_initialize_mode(struct fb_info *info,unsigned long lcd_clk;unsigned long long tmp;struct imxfb_info *fbi =fb_info_to_imxfb_info (info); +const struct imx_fb_driver_data *drv_data = mode->priv;u32 pcr;unsigned size;
@@ -342,6 +343,11 @@ static int imxfb_initialize_mode(struct fb_info *info,imxfb_memory_mmgt (info, size,MAIN_FBUFFER ); + fbi->pcr = drv_data->pcr; + fbi->pwmr = drv_data->pwmr; + fbi->lscr1 = drv_data->lscr1; + fbi->dmacr = drv_data->dmacr; +/* physical screen start address */ writel (VPW_VPW (mode->xres * info->bits_per_pixel /8 /4 ), fbi->regs +LCDC_VPW );
@@ -541,7 +547,7 @@ static int imxfb_register_overlay(struct imxfb_info *fbi, overlay->fb_setcolreg = imxfb_overlay_setcolreg;/* add runtime video info */ - overlay->mode = pdata->mode->mode; + overlay->mode = pdata->mode; overlay->mode_cnt =1 ;/* no choice */ overlay_dev =register_framebuffer (overlay);
@@ -591,17 +597,12 @@ static int imxfb_probe(struct device_d *dev) fbi->fb_host.fb_setcolreg = imxfb_setcolreg; fbi->regs = (void *)dev->map_base; - fbi->pcr = pdata->mode->pcr; - fbi->pwmr = pdata->pwmr; - fbi->lscr1 = pdata->lscr1; - fbi->dmacr = pdata->dmacr; fbi->enable = pdata->enable;/* add runtime video info */ - fbi->fb_host.mode = pdata->mode->mode; -/* to be backward compatible */ - fbi->fb_host.mode_cnt = pdata->mode_cnt ==0 ?1 : pdata->mode_cnt; - fbi->fb_host.bits_per_pixel =16 ;/* RGB565, the default */ + fbi->fb_host.mode = pdata->mode; + fbi->fb_host.mode_cnt = pdata->mode_cnt; + fbi->fb_host.bits_per_pixel = pdata->bpp; fb_dev =register_framebuffer (&fbi->fb_host);if (dev ==NULL ) {
include/fb.h +2 -0
@@ -69,6 +69,8 @@ struct fb_videomode {unsigned sync;/**< sync information, refer FB_SYNC_* macros */ unsigned vmode;/**< video mode information, refer FB_VMODE_* macros */ unsigned flag; + +const void *priv;/**< video driver related information */ };/* Interpretation of offset for color fields: All offsets are from the right,
Signature · 7 lines
1.7.2.3 _______________________________________________ barebox mailing list [email protected] http://lists.infradead.org/mailman/listinfo/barebox
PATCH 10/11 Add a video driver for S3C2440 bases platforms
In reply to Juergen BeisertFrom: Juergen Beisert <[email protected]>
--- arch/arm/mach-s3c24xx/include/mach/fb.h | 40 +++ drivers/video/Kconfig | 6 + drivers/video/Makefile | 1 + drivers/video/s3c.c | 474 +++++++++++++++++++++++++++++++ 4 files changed, 521 insertions(+), 0 deletions(-) create mode 100644 arch/arm/mach-s3c24xx/include/mach/fb.h create mode 100644 drivers/video/s3c.c
arch/arm/mach-s3c24xx/include/mach/fb.h new file +40 -0
@@ -0,0 +1,40 @@ +/* +* Copyright (C) 2010 Juergen Beisert +* +* This program is free software; you can redistribute it and/or +* modify it under the terms of the GNU General Public License as +* published by the Free Software Foundation; either version 2 of +* the License, or (at your option) any later version. +* +* This program is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU General Public License for more details. +* +* You should have received a copy of the GNU General Public License +* along with this program; if not, write to the Free Software +* Foundation, Inc., 59 Temple Place, Suite 330, Boston, +* MA 02111-1307 USA +* +*/ + +#ifndef __MACH_FB_H_ +# define __MACH_FB_H_ + +#include <fb.h> + +struct s3c_fb_platform_data { + +const struct fb_videomode *mode_list; +unsigned mode_cnt; + +int passive_display;/**< enable support for STN or CSTN displays */ + +void *framebuffer;/**< force framebuffer base address */ +unsigned size;/**< force framebuffer size */ + +/** hook to enable backlight and stuff */ +void (*enable)(int ); +}; + +#endif /* __MACH_FB_H_ */
drivers/video/Kconfig +6 -0
@@ -30,4 +30,10 @@ config DRIVER_VIDEO_IMX_IPU Add support for the IPU framebuffer device found on i.MX31 and i.MX35 CPUs. +config S3C_VIDEO + bool "S3C244x framebuffer driver" + depends on ARCH_S3C24xx + help + Add support for the S3C244x LCD controller. + endif
drivers/video/Makefile +1 -0
@@ -2,3 +2,4 @@ obj-$(CONFIG_VIDEO) += fb.o obj-$(CONFIG_DRIVER_VIDEO_IMX) += imx.o obj-$(CONFIG_DRIVER_VIDEO_IMX_IPU) += imx-ipu-fb.o +obj-$(CONFIG_S3C_VIDEO) += s3c.o
drivers/video/s3c.c new file +474 -0
474 lines not on this page · raw message
Signature · 7 lines
1.7.2.3 _______________________________________________ barebox mailing list [email protected] http://lists.infradead.org/mailman/listinfo/barebox
PATCH 11/11 STM378x: Add video driver for this platform
In reply to Juergen Beisert--- arch/arm/mach-stm/include/mach/fb.h | 33 ++ drivers/video/Kconfig | 7 + drivers/video/Makefile | 1 + drivers/video/stm.c | 646 +++++++++++++++++++++++++++++++++++ 4 files changed, 687 insertions(+), 0 deletions(-) create mode 100644 arch/arm/mach-stm/include/mach/fb.h create mode 100644 drivers/video/stm.c
arch/arm/mach-stm/include/mach/fb.h new file +33 -0
@@ -0,0 +1,33 @@ +/* +* This program is free software; you can redistribute it and/or +* modify it under the terms of the GNU General Public License +* as published by the Free Software Foundation; either version 2 +* of the License, or (at your option) any later version. +* This program is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU General Public License for more details. +*/ + +#ifndef __MACH_FB_H +# define __MACH_FB_H + +#include <fb.h> + +#define STMLCDIF_8BIT 1/** pixel data bus to the display is of 8 bit width */ +#define STMLCDIF_16BIT 0/** pixel data bus to the display is of 16 bit width */ +#define STMLCDIF_18BIT 2/** pixel data bus to the display is of 18 bit width */ +#define STMLCDIF_24BIT 3/** pixel data bus to the display is of 24 bit width */ + +struct imx_fb_videomode { +struct fb_videomode *mode_list; +unsigned mode_count; +void *framebuffer;/**< force fixed framebuffer address if != NULL */ +unsigned size;/**< force fixed size if != NULL */ + +unsigned dotclk_delay;/**< refer manual HW_LCDIF_VDCTRL4 register */ +unsigned ld_intf_width;/**< refer STMLCDIF_* macros */ +}; + +#endif /* __MACH_FB_H */ +
drivers/video/Kconfig +7 -0
@@ -36,4 +36,11 @@ config S3C_VIDEO help Add support for the S3C244x LCD controller. +config DRIVER_VIDEO_STM + bool "i.MX23/28 framebuffer driver" + depends on ARCH_STM + help + Say 'Y' here to enable framebuffer and spash screen support for + i.MX23 and i.MX28 based systems. + endif
drivers/video/Makefile +1 -0
@@ -1,5 +1,6 @@ obj-$(CONFIG_VIDEO) += fb.o +obj-$(CONFIG_DRIVER_VIDEO_STM) += stm.o obj-$(CONFIG_DRIVER_VIDEO_IMX) += imx.o obj-$(CONFIG_DRIVER_VIDEO_IMX_IPU) += imx-ipu-fb.o obj-$(CONFIG_S3C_VIDEO) += s3c.o
drivers/video/stm.c new file +646 -0
646 lines not on this page · raw message
Signature · 7 lines
1.7.2.3 _______________________________________________ barebox mailing list [email protected] http://lists.infradead.org/mailman/listinfo/barebox