* [U-Boot] [PATCH 1/2] new video driver for bus vcxk framebuffers
@ 2009-04-22 14:36 Jens Scharsig
2009-07-17 22:16 ` Wolfgang Denk
` (3 more replies)
0 siblings, 4 replies; 12+ messages in thread
From: Jens Scharsig @ 2009-04-22 14:36 UTC (permalink / raw)
To: u-boot
This patch adds a new video driver
* adds common bus_vcxk framebuffer driver
Signed-off-by: Jens Scharsig <esw@bus-elektronik.de>
---
diff --git a/doc/README.bus_vcxk b/doc/README.bus_vcxk
new file mode 100644
index 0000000..44e1238
--- /dev/null
+++ b/doc/README.bus_vcxk
@@ -0,0 +1,95 @@
+/*
+ * (C) Copyright 2008-2009
+ * BuS Elektronik GmbH & Co. KG <www.bus-elektronik.de>
+ * Jens Scharsig <esw@bus-elektronik.de>
+ *
+ * Configuation settings for the EB+CPUx9K2 board.
+ *
+ * See file CREDITS for list of people who contributed to this
+ * project.
+ *
+ * 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
+ */
+
+U-Boot vcxk video controller driver
+======================================
+
+The driver can use with VC2K, VC4K and VC8K devices on following boards:
+
+board | ARCH | Vendor
+-----------------------------------------------------------------------
+EB+CPU5282-T1 | MCF5282 | BuS Elektronik GmbH & Co. KG
+EB+MCF-EVB123 | MCF5282 | BuS Elektronik GmbH & Co. KG
+EB+CPUx9K2 | AT91RM9200 | BuS Elektronik GmbH & Co. KG
+ZLSA | AT91RM9200 | Ruf Telematik AG
+
+by define CONFIG_VIDEO_VCXK
+
+Driver configuration
+--------------------
+
+The driver needs some defines to descrip the target hardware:
+
+CONFIG_SYS_VCXK_BASE
+
+base address of VCxK hardware memory
+
+CONFIG_SYS_VCXK_DEFAULT_LINEALIGN
+
+defines the physical alignment of a pixel row
+
+CONFIG_SYS_VCXK_DOUBLEBUFFERED
+
+some boards that use vcxk prevent read from framebuffer memory.
+define this option to enable double buffering (needs 16KiB RAM)
+
+CONFIG_SYS_VCXK_ACKNOWLEDGE_INIT
+
+initialize the acknowledge line from vcxk hardware
+
+#define CONFIG_SYS_VCXK_ACKNOWLEDGE
+
+should return true (1), if vcxk hardware acknowledges a viewing reqest
+
+CONFIG_SYS_VCXK_ENABLE_INIT
+
+initialize the enable line to vcxk hardware
+
+CONFIG_SYS_VCXK_DISABLE
+
+set vcxk enable line to disable level / display off
+
+CONFIG_SYS_VCXK_ENABLE
+
+set vcxk enable line enable level / display on
+
+CONFIG_SYS_VCXK_REQUEST_INIT
+
+initialize the request line to vcxk hardware
+
+CONFIG_SYS_VCXK_REQUEST
+
+should be send an request impulse to vcxk hardware
+
+CONFIG_SYS_VCXK_INVERT_INIT
+
+should initialize the invert line to vcxk hardware and set it to
+non invers mode
+
+CONFIG_SYS_VCXK_RESET_INIT
+
+initialize the reset line to vcxk hardware and release it from reset
+
diff --git a/drivers/video/Makefile b/drivers/video/Makefile
index bc00852..bb6b5a0 100644
--- a/drivers/video/Makefile
+++ b/drivers/video/Makefile
@@ -36,6 +36,7 @@ COBJS-$(CONFIG_VIDEO_SED13806) += sed13806.o
COBJS-$(CONFIG_SED156X) += sed156x.o
COBJS-$(CONFIG_VIDEO_SM501) += sm501.o
COBJS-$(CONFIG_VIDEO_SMI_LYNXEM) += smiLynxEM.o
+COBJS-$(CONFIG_VIDEO_VCXK) += bus_vcxk.o
COBJS-y += videomodes.o
COBJS := $(COBJS-y)
diff --git a/drivers/video/bus_vcxk.c b/drivers/video/bus_vcxk.c
new file mode 100644
index 0000000..db49c83
--- /dev/null
+++ b/drivers/video/bus_vcxk.c
@@ -0,0 +1,469 @@
+/*
+ * (C) Copyright 2005-2009
+ * Jens Scharsig @ BuS Elektronik GmbH & Co. KG, <esw@bus-elektronik.de>
+ *
+ * See file CREDITS for list of people who contributed to this
+ * project.
+ *
+ * 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
+ */
+
+#include <common.h>
+#include <bmp_layout.h>
+#include <asm/io.h>
+
+vu_char *vcxk_bws = ((vu_char *) (CONFIG_SYS_VCXK_BASE));
+vu_short *vcxk_bws_word = ((vu_short *)(CONFIG_SYS_VCXK_BASE));
+vu_long *vcxk_bws_long = ((vu_long *) (CONFIG_SYS_VCXK_BASE));
+
+#ifdef CONFIG_AT91RM9200
+ #include <asm/arch/hardware.h>
+ #ifndef VCBITMASK
+ #define VCBITMASK(bitno) (0x0001 << (bitno % 16))
+ #endif
+#elif defined(CONFIG_MCF52x2)
+ #include <asm/m5282.h>
+ #ifndef VCBITMASK
+ #define VCBITMASK(bitno) (0x8000 >> (bitno % 16))
+ #endif
+#else
+ #error not vcxk support for selected ARCH
+#endif
+
+#ifndef CONFIG_SYS_VCXK_DOUBLEBUFFERED
+ #define VCXK_BWS(x,data) vcxk_bws[x] = data;
+ #define VCXK_BWS_WORD_SET(x,mask) vcxk_bws_word[x] |= mask;
+ #define VCXK_BWS_WORD_CLEAR(x,mask) vcxk_bws_word[x] &= ~mask;
+ #define VCXK_BWS_LONG(x,data) vcxk_bws_long[x] = data;
+#else
+ u_char double_bws[16384];
+ u_short *double_bws_word;
+ u_long *double_bws_long;
+ #define VCXK_BWS(x,data) \
+ double_bws[x] = data; vcxk_bws[x] = data;
+ #define VCXK_BWS_WORD_SET(x,mask) \
+ double_bws_word[x] |= mask; vcxk_bws_word[x] = double_bws_word[x];
+ #define VCXK_BWS_WORD_CLEAR(x,mask) \
+ double_bws_word[x] &= ~mask; vcxk_bws_word[x] = double_bws_word[x];
+ #define VCXK_BWS_LONG(x,data) \
+ double_bws_long[x] = data; vcxk_bws_long[x] = data;
+#endif
+
+#define VC4K16_Bright1 vcxk_bws_word[0x20004 / 2]
+#define VC4K16_Bright2 vcxk_bws_word[0x20006 / 2]
+#define VC2K_Bright vcxk_bws[0x8000]
+#define VC8K_BrightH vcxk_bws[0xC000]
+#define VC8K_BrightL vcxk_bws[0xC001]
+
+static vu_long vcxk_driver;
+vu_char VC4K16;
+
+u_long display_width;
+u_long display_height;
+u_long display_bwidth;
+
+ulong search_vcxk_driver(void);
+void vcxk_cls(void);
+void vcxk_setbrightness(unsigned int side, short brightness);
+int vcxk_request(void);
+int vcxk_acknowledge_wait(void);
+void vcxk_clear(void);
+
+/*----------------------------------------------------------------------------
+ ****f* bus_vcxk/vcxk_init
+ * FUNCTION
+ * initialalize Video Controller
+ * PARAMETERS
+ * width visible display width in pixel
+ * height visible display height in pixel
+ ***
+----------------------------------------------------------------------------*/
+
+int vcxk_init(unsigned long width, unsigned long height)
+{
+ CONFIG_SYS_VCXK_RESET_INIT;
+
+#ifdef CONFIG_SYS_VCXK_DOUBLEBUFFERED
+ double_bws_word = (u_short *) double_bws;
+ double_bws_long = (u_long *)double_bws;
+ debug("%lx %lx %lx \n",double_bws,double_bws_word,double_bws_long);
+#endif
+
+ display_width = width;
+ display_height = height;
+ #if (CONFIG_SYS_VCXK_DEFAULT_LINEALIGN==4)
+ display_bwidth =((width+31) / 8) & ~0x3;
+ #elif (CONFIG_SYS_VCXK_DEFAULT_LINEALIGN==2)
+ display_bwidth =((width+15) / 8) & ~0x1;
+ #else
+ #error CONFIG_SYS_VCXK_DEFAULT_LINEALIGN is invalid
+ #endif
+ debug("linesize ((%d + 15)/8 & ~0x1) = %d\n",display_width,display_bwidth);
+
+ #ifdef CONFIG_SYS_VCXK_AUTODETECT
+ VC4K16 = 0;
+ vcxk_bws_long[1] = 0x0;
+ vcxk_bws_long[1] = 0x55AAAA55;
+ vcxk_bws_long[5] = 0x0;
+ if (vcxk_bws_long[1] == 0x55AAAA55)
+ {
+ VC4K16 = 1;
+ }
+ #else
+ VC4K16 = 1;
+ debug("No autodetect: use vc4k\n");
+ #endif
+
+ CONFIG_SYS_VCXK_INVERT_INIT;
+
+ CONFIG_SYS_VCXK_REQUEST_INIT;
+
+ CONFIG_SYS_VCXK_ACKNOWLEDGE_INIT;
+
+ CONFIG_SYS_VCXK_DISABLE;
+ CONFIG_SYS_VCXK_ENABLE_INIT;
+
+ vcxk_driver = search_vcxk_driver();
+ if (vcxk_driver)
+ {
+ /* use flash resist driver */
+ }
+ else
+ {
+ vcxk_cls();
+ vcxk_cls();
+ }
+
+ vcxk_setbrightness(3,1000);
+ CONFIG_SYS_VCXK_ENABLE;
+ return 1;
+}
+
+/*----------------------------------------------------------------------------
+ ****f* bus_vcxk/vcxk_setpixel
+ * FUNCTION
+ * set the pixel[x,y] with the given color
+ * PARAMETER
+ * x pixel colum
+ * y pixel row
+ * color <0x40 off/black
+ * >0x40 on
+ ***
+----------------------------------------------------------------------------*/
+
+void vcxk_setpixel (int x, int y, unsigned long color)
+{
+ vu_short dataptr;
+
+ if (vcxk_driver)
+ {
+ /* use flash resist driver */
+ }
+ else
+ {
+ if ((x<display_width) && (y<display_height))
+ {
+
+ dataptr = ((x / 16)) + (y * (display_bwidth>>1));
+
+ color = ((color >> 16) & 0xFF) |
+ ((color >> 8) & 0xFF) | (color & 0xFF);
+
+ if (color > 0x40)
+ {
+ VCXK_BWS_WORD_SET(dataptr,VCBITMASK(x));
+ }
+ else
+ {
+ VCXK_BWS_WORD_CLEAR(dataptr,VCBITMASK(x));
+ }
+ }
+ }
+}
+
+/*----------------------------------------------------------------------------
+ ****f* bus_vcxk/vcxk_loadimage
+ * FUNCTION
+ * copies a binary image to display memory
+ ***
+----------------------------------------------------------------------------*/
+
+void vcxk_loadimage(ulong source)
+{
+ int cnt;
+ vcxk_acknowledge_wait();
+ if (vcxk_driver)
+ {
+ /* use flash resist driver */
+ }
+ else
+ {
+ if (VC4K16)
+ {
+ for (cnt=0; cnt< (16384/4); cnt++)
+ {
+ VCXK_BWS_LONG(cnt,(*(ulong*) source));
+ source = source + 4;
+ }
+ }
+ else
+ {
+ for (cnt=0; cnt<16384; cnt++)
+ {
+ VCXK_BWS_LONG(cnt*2,(*(vu_char*) source));
+ source++;
+ }
+ }
+ }
+ vcxk_request();
+}
+
+/*----------------------------------------------------------------------------
+ ****f* bus_vcxk/vcxk_cls
+ * FUNCTION
+ * clear the display
+ ***
+----------------------------------------------------------------------------*/
+
+void vcxk_cls(void)
+{
+ vcxk_acknowledge_wait();
+ vcxk_clear();
+ vcxk_request();
+}
+
+/*----------------------------------------------------------------------------
+ ****f* bus_vcxk/vcxk_clear(void)
+ * FUNCTION
+ * clear the display memory
+ ***
+----------------------------------------------------------------------------*/
+
+void vcxk_clear(void)
+{
+ int cnt;
+ if (vcxk_driver)
+ {
+ /* use flash resist driver */
+ }
+ else
+ {
+ for (cnt=0; cnt< (16384/4); cnt++)
+ {
+ VCXK_BWS_LONG(cnt,0);
+ }
+ }
+}
+
+/*----------------------------------------------------------------------------
+ ****f* bus_vcxk/vcxk_setbrightness
+ * FUNCTION
+ * set the display brightness
+ * PARAMETER
+ * side 1 set front side brightness
+ * 2 set back side brightness
+ * 3 set brightness for both sides
+ * brightness 0..1000
+ ***
+----------------------------------------------------------------------------*/
+
+void vcxk_setbrightness(unsigned int side, short brightness)
+{
+ if (vcxk_driver)
+ {
+ /* use flash resist driver */
+ }
+ else
+ {
+ if (VC4K16)
+ {
+ if ((side==0) || (side & 0x1)) VC4K16_Bright1 = brightness + 23;
+ if ((side==0) || (side & 0x2)) VC4K16_Bright2 = brightness + 23;
+ }
+ else
+ {
+ VC2K_Bright = (brightness >> 4) +2;
+ VC8K_BrightH = (brightness + 23) >> 8;
+ VC8K_BrightL = (brightness + 23) & 0xFF;
+ }
+ }
+}
+
+/*----------------------------------------------------------------------------
+ ****f* bus_vcxk/vcxk_request
+ * FUNCTION
+ * requests viewing of display memory
+ ***
+----------------------------------------------------------------------------*/
+
+int vcxk_request(void)
+{
+ if (vcxk_driver)
+ {
+ /* use flash resist driver */
+ }
+ else
+ {
+ CONFIG_SYS_VCXK_REQUEST;
+ }
+ return 1;
+}
+
+/*----------------------------------------------------------------------------
+ ****f* bus_vcxk/vcxk_acknowledge_wait
+ * FUNCTION
+ * wait for acknowledge viewing requests
+ ***
+----------------------------------------------------------------------------*/
+
+int vcxk_acknowledge_wait(void)
+{
+ if (vcxk_driver)
+ {
+ /* use flash resist driver */
+ }
+ else
+ {
+ while (CONFIG_SYS_VCXK_ACKNOWLEDGE);
+ }
+ return 1;
+}
+
+/*----------------------------------------------------------------------------
+ ****f* bus_vcxk/search_vcxk_driver
+ * FUNCTION
+ * search for driver extentions (not implement for U-Boot)
+ ***
+----------------------------------------------------------------------------*/
+
+ulong search_vcxk_driver(void)
+{
+ return 0;
+}
+
+/*----------------------------------------------------------------------------
+ ****f* bus_vcxk/vcxk_display_bitmap
+ * FUNCTION
+ * copies a bitmap (BMP-Format) to the given position
+ * PARAMETER
+ * addr pointer to bitmap
+ * x output bitmap @ columne
+ * y output bitmap @ row
+ ***
+----------------------------------------------------------------------------*/
+
+int vcxk_display_bitmap (ulong addr, int x, int y)
+{
+ bmp_image_t *bmp;
+ unsigned long width;
+ unsigned long height;
+ unsigned long bpp;
+ unsigned long compression;
+
+ unsigned long xcnt,ycnt;
+ unsigned long linewidth;
+
+ unsigned long cp_width;
+ unsigned long cp_height;
+ unsigned char *dataptr;
+ unsigned char *lineptr;
+
+ bmp = (bmp_image_t *) addr;
+ if ((bmp->header.signature[0] == 'B') &&
+ (bmp->header.signature[1] == 'M'))
+ {
+ compression = le32_to_cpu (bmp->header.compression);
+ width = le32_to_cpu (bmp->header.width);
+ height = le32_to_cpu (bmp->header.height);
+ bpp = le16_to_cpu (bmp->header.bit_count);
+
+ dataptr = (unsigned char *) bmp + le32_to_cpu(bmp->header.data_offset);
+
+ if (display_width < (width + x))
+ {
+ cp_width = display_width - x;
+ }
+ else
+ {
+ cp_width = width;
+ }
+ if (display_height < (height + y))
+ {
+ cp_height = display_height - y;
+ }
+ else
+ {
+ cp_height = height;
+ }
+ linewidth = (((width + 7) / 8)+3) & ~0x3;
+ if (cp_height < height)
+ {
+ dataptr=dataptr + linewidth * (height-cp_height);
+ }
+ switch (bpp)
+ {
+ case 1:
+ for (ycnt=cp_height;ycnt>0; ycnt--)
+ {
+ lineptr = dataptr;
+ for (xcnt=0;xcnt<cp_width; xcnt++)
+ {
+ if ((*lineptr << (xcnt % 8)) & 0x80)
+ {
+ vcxk_setpixel(xcnt,ycnt-1,0xFFFFFF);
+ }
+ else
+ {
+ vcxk_setpixel(xcnt,ycnt-1,0);
+ }
+ if ((xcnt % 8) == 7) { lineptr++; }
+ } /* endfor xcnt */
+ dataptr=dataptr + linewidth;
+ } /* endfor ycnt */
+ break;
+ default:
+ printf("Error: %ld bit per pixel not supported by VCxK\n",
+ bpp);
+ return 0;
+ }
+ }
+ else
+ {
+ printf("Error: no valid bmp at %lx\n", (ulong) bmp);
+ return 0;
+ }
+ return 1;
+}
+
+/*----------------------------------------------------------------------------
+ ****f* bus_vcxk/video_display_bitmap
+ ***
+----------------------------------------------------------------------------*/
+
+int video_display_bitmap (ulong addr, int x, int y)
+{
+ vcxk_acknowledge_wait();
+ if (vcxk_display_bitmap (addr,x, y))
+ {
+ vcxk_request();
+ return 0;
+ }
+ return 1;
+}
+
+/*---------------------------------------------------------------------------*/
+/* EOF */
+/*---------------------------------------------------------------------------*/
diff --git a/include/bus_vcxk.h b/include/bus_vcxk.h
new file mode 100644
index 0000000..8d6a25c
--- /dev/null
+++ b/include/bus_vcxk.h
@@ -0,0 +1,36 @@
+/*
+ * (C) Copyright 2005-2009
+ * Jens Scharsig @ BuS Elektronik GmbH & Co. KG, <esw@bus-elektronik.de>
+ *
+ * See file CREDITS for list of people who contributed to this
+ * project.
+ *
+ * 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 __BUS_VCXK_H_
+#define __BUS_VCXK_H_
+
+extern int vcxk_init(unsigned long width, unsigned long height);
+extern void vcxk_setpixel (int x, int y, unsigned long color);
+extern int vcxk_acknowledge_wait(void);
+extern int vcxk_request(void);
+extern void vcxk_loadimage(ulong source);
+extern int vcxk_display_bitmap (ulong addr, int x, int y);
+extern void vcxk_setbrightness(unsigned int side, short brightness);
+extern int video_display_bitmap (ulong addr, int x, int y);
+
+#endif
^ permalink raw reply related [flat|nested] 12+ messages in thread
* [U-Boot] [PATCH 1/2] new video driver for bus vcxk framebuffers
2009-04-22 14:36 [U-Boot] [PATCH 1/2] new video driver for bus vcxk framebuffers Jens Scharsig
@ 2009-07-17 22:16 ` Wolfgang Denk
2009-07-18 16:54 ` Anatolij Gustschin
` (2 subsequent siblings)
3 siblings, 0 replies; 12+ messages in thread
From: Wolfgang Denk @ 2009-07-17 22:16 UTC (permalink / raw)
To: u-boot
Dear Anatolij,
In message <gsna1j$2tm$2@ger.gmane.org> Jens Scharsig wrote:
> This patch adds a new video driver
>
> * adds common bus_vcxk framebuffer driver
>
> Signed-off-by: Jens Scharsig <esw@bus-elektronik.de>
> ---
AFAICT this has neither been applied nor rejected yet.
Please check.
Best regards,
Wolfgang Denk
--
DENX Software Engineering GmbH, MD: Wolfgang Denk & Detlev Zundel
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: (+49)-8142-66989-10 Fax: (+49)-8142-66989-80 Email: wd at denx.de
"Wagner's music is better than it sounds." - Mark Twain
^ permalink raw reply [flat|nested] 12+ messages in thread
* [U-Boot] [PATCH 1/2] new video driver for bus vcxk framebuffers
2009-04-22 14:36 [U-Boot] [PATCH 1/2] new video driver for bus vcxk framebuffers Jens Scharsig
2009-07-17 22:16 ` Wolfgang Denk
@ 2009-07-18 16:54 ` Anatolij Gustschin
2009-07-20 6:45 ` Jens Scharsig
2009-07-21 11:08 ` [U-Boot] [PATCH 1/2 V2] " Jens Scharsig
2009-07-24 8:09 ` [U-Boot] [PATCH 1/2 V3] " Jens Scharsig
3 siblings, 1 reply; 12+ messages in thread
From: Anatolij Gustschin @ 2009-07-18 16:54 UTC (permalink / raw)
To: u-boot
Jens Scharsig wrote:
> This patch adds a new video driver
>
> * adds common bus_vcxk framebuffer driver
>
> Signed-off-by: Jens Scharsig <esw@bus-elektronik.de>
> ---
Sorry it took so long to review/comment. We need to resolve some
issues before this patch can be applied, then it can go in
for coming release.
> diff --git a/doc/README.bus_vcxk b/doc/README.bus_vcxk
> new file mode 100644
> index 0000000..44e1238
> --- /dev/null
> +++ b/doc/README.bus_vcxk
> @@ -0,0 +1,95 @@
> +/*
> + * (C) Copyright 2008-2009
> + * BuS Elektronik GmbH & Co. KG <www.bus-elektronik.de>
> + * Jens Scharsig <esw@bus-elektronik.de>
> + *
> + * Configuation settings for the EB+CPUx9K2 board.
Typo in Configuration, please fix.
> + *
> + * See file CREDITS for list of people who contributed to this
> + * project.
> + *
> + * 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
> + */
> +
> +U-Boot vcxk video controller driver
> +======================================
> +
> +The driver can use with VC2K, VC4K and VC8K devices on following boards:
> +
> +board | ARCH | Vendor
> +-----------------------------------------------------------------------
> +EB+CPU5282-T1 | MCF5282 | BuS Elektronik GmbH & Co. KG
> +EB+MCF-EVB123 | MCF5282 | BuS Elektronik GmbH & Co. KG
> +EB+CPUx9K2 | AT91RM9200 | BuS Elektronik GmbH & Co. KG
> +ZLSA | AT91RM9200 | Ruf Telematik AG
Please fix indentation/alignment in lines above, so it will look
like initially intended.
> +
> +by define CONFIG_VIDEO_VCXK
I suggest to move this to the beginning of the sentence, e.g.:
"By defining CONFIG_VIDEO_VCXK this driver can be used with VC2K, VC4K ..."
> +
> +Driver configuration
> +--------------------
> +
> +The driver needs some defines to descrip the target hardware:
s/descrip/describe
> +
> +CONFIG_SYS_VCXK_BASE
> +
> +base address of VCxK hardware memory
> +
> +CONFIG_SYS_VCXK_DEFAULT_LINEALIGN
> +
> +defines the physical alignment of a pixel row
> +
> +CONFIG_SYS_VCXK_DOUBLEBUFFERED
> +
> +some boards that use vcxk prevent read from framebuffer memory.
> +define this option to enable double buffering (needs 16KiB RAM)
It is more readable if you indent the lines describing the CONFIG_SYS_
option by tab, please fix, also in appropriate lines below, e.g.:
CONFIG_SYS_VCXK_BASE
base address of VCxK hardware memory
CONFIG_SYS_VCXK_DEFAULT_LINEALIGN
defines the physical alignment of a pixel row
and so on.
> +
> +CONFIG_SYS_VCXK_ACKNOWLEDGE_INIT
> +
> +initialize the acknowledge line from vcxk hardware
> +
> +#define CONFIG_SYS_VCXK_ACKNOWLEDGE
please remove "#define" before CONFIG_SYS_VCXK_ACKNOWLEDGE
> +
> +should return true (1), if vcxk hardware acknowledges a viewing reqest
please fix a typo, s/reqest/request
> +
> +CONFIG_SYS_VCXK_ENABLE_INIT
> +
> +initialize the enable line to vcxk hardware
> +
> +CONFIG_SYS_VCXK_DISABLE
> +
> +set vcxk enable line to disable level / display off
> +
> +CONFIG_SYS_VCXK_ENABLE
> +
> +set vcxk enable line enable level / display on
> +
> +CONFIG_SYS_VCXK_REQUEST_INIT
> +
> +initialize the request line to vcxk hardware
> +
> +CONFIG_SYS_VCXK_REQUEST
> +
> +should be send an request impulse to vcxk hardware
> +
> +CONFIG_SYS_VCXK_INVERT_INIT
> +
> +should initialize the invert line to vcxk hardware and set it to
> +non invers mode
> +
> +CONFIG_SYS_VCXK_RESET_INIT
> +
> +initialize the reset line to vcxk hardware and release it from reset
Looking on the changes to board configuration file
"include/configs/EB+MCF-EV123.h" in the second patch of this series
I now realize that most of these CONFIG_SYS_ macros above expand to
C code, so these are not configuration options any more.
I tend to reject all this. CONFIG_SYS_ options are supposed to be options
and not board specific code. VCxK.c driver you removed by this patch
series did it in more correct way, I think.
What about moving this code to functions which use board specific macros?
These functions should be placed in this new video driver then.
> +
> diff --git a/drivers/video/Makefile b/drivers/video/Makefile
> index bc00852..bb6b5a0 100644
> --- a/drivers/video/Makefile
> +++ b/drivers/video/Makefile
> @@ -36,6 +36,7 @@ COBJS-$(CONFIG_VIDEO_SED13806) += sed13806.o
> COBJS-$(CONFIG_SED156X) += sed156x.o
> COBJS-$(CONFIG_VIDEO_SM501) += sm501.o
> COBJS-$(CONFIG_VIDEO_SMI_LYNXEM) += smiLynxEM.o
> +COBJS-$(CONFIG_VIDEO_VCXK) += bus_vcxk.o
> COBJS-y += videomodes.o
>
> COBJS := $(COBJS-y)
> diff --git a/drivers/video/bus_vcxk.c b/drivers/video/bus_vcxk.c
> new file mode 100644
> index 0000000..db49c83
> --- /dev/null
> +++ b/drivers/video/bus_vcxk.c
> @@ -0,0 +1,469 @@
> +/*
> + * (C) Copyright 2005-2009
> + * Jens Scharsig @ BuS Elektronik GmbH & Co. KG, <esw@bus-elektronik.de>
> + *
> + * See file CREDITS for list of people who contributed to this
> + * project.
> + *
> + * 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
> + */
> +
> +#include <common.h>
> +#include <bmp_layout.h>
> +#include <asm/io.h>
> +
> +vu_char *vcxk_bws = ((vu_char *) (CONFIG_SYS_VCXK_BASE));
> +vu_short *vcxk_bws_word = ((vu_short *)(CONFIG_SYS_VCXK_BASE));
> +vu_long *vcxk_bws_long = ((vu_long *) (CONFIG_SYS_VCXK_BASE));
> +
> +#ifdef CONFIG_AT91RM9200
> + #include <asm/arch/hardware.h>
> + #ifndef VCBITMASK
> + #define VCBITMASK(bitno) (0x0001 << (bitno % 16))
> + #endif
> +#elif defined(CONFIG_MCF52x2)
> + #include <asm/m5282.h>
> + #ifndef VCBITMASK
> + #define VCBITMASK(bitno) (0x8000 >> (bitno % 16))
> + #endif
> +#else
> + #error not vcxk support for selected ARCH
s/not/no
> +#endif
> +
> +#ifndef CONFIG_SYS_VCXK_DOUBLEBUFFERED
> + #define VCXK_BWS(x,data) vcxk_bws[x] = data;
> + #define VCXK_BWS_WORD_SET(x,mask) vcxk_bws_word[x] |= mask;
> + #define VCXK_BWS_WORD_CLEAR(x,mask) vcxk_bws_word[x] &= ~mask;
> + #define VCXK_BWS_LONG(x,data) vcxk_bws_long[x] = data;
> +#else
> + u_char double_bws[16384];
> + u_short *double_bws_word;
> + u_long *double_bws_long;
> + #define VCXK_BWS(x,data) \
> + double_bws[x] = data; vcxk_bws[x] = data;
> + #define VCXK_BWS_WORD_SET(x,mask) \
> + double_bws_word[x] |= mask; vcxk_bws_word[x] = double_bws_word[x];
line too long, please fix to max. 80 characters.
> + #define VCXK_BWS_WORD_CLEAR(x,mask) \
> + double_bws_word[x] &= ~mask; vcxk_bws_word[x] = double_bws_word[x];
line too long, too.
> + #define VCXK_BWS_LONG(x,data) \
> + double_bws_long[x] = data; vcxk_bws_long[x] = data;
> +#endif
> +
> +#define VC4K16_Bright1 vcxk_bws_word[0x20004 / 2]
> +#define VC4K16_Bright2 vcxk_bws_word[0x20006 / 2]
> +#define VC2K_Bright vcxk_bws[0x8000]
please remove one tab in the above line.
...
> +
> +static vu_long vcxk_driver;
> +vu_char VC4K16;
> +
> +u_long display_width;
> +u_long display_height;
> +u_long display_bwidth;
> +
> +ulong search_vcxk_driver(void);
> +void vcxk_cls(void);
> +void vcxk_setbrightness(unsigned int side, short brightness);
> +int vcxk_request(void);
> +int vcxk_acknowledge_wait(void);
> +void vcxk_clear(void);
> +
> +/*----------------------------------------------------------------------------
> + ****f* bus_vcxk/vcxk_init
> + * FUNCTION
> + * initialalize Video Controller
> + * PARAMETERS
> + * width visible display width in pixel
> + * height visible display height in pixel
> + ***
> +----------------------------------------------------------------------------*/
please use this style for multi-line comments:
/*
* multi-line
* comment
*/
> +
> +int vcxk_init(unsigned long width, unsigned long height)
> +{
> + CONFIG_SYS_VCXK_RESET_INIT;
> +
> +#ifdef CONFIG_SYS_VCXK_DOUBLEBUFFERED
> + double_bws_word = (u_short *) double_bws;
> + double_bws_long = (u_long *)double_bws;
> + debug("%lx %lx %lx \n",double_bws,double_bws_word,double_bws_long);
> +#endif
> +
> + display_width = width;
> + display_height = height;
> + #if (CONFIG_SYS_VCXK_DEFAULT_LINEALIGN==4)
> + display_bwidth =((width+31) / 8) & ~0x3;
> + #elif (CONFIG_SYS_VCXK_DEFAULT_LINEALIGN==2)
> + display_bwidth =((width+15) / 8) & ~0x1;
> + #else
> + #error CONFIG_SYS_VCXK_DEFAULT_LINEALIGN is invalid
> + #endif
do not indent these 7 lines above please. Also add spaces around "+".
> + debug("linesize ((%d + 15)/8 & ~0x1) = %d\n",display_width,display_bwidth);
line too long. Add spaces around "/", before display_width and display_bwidth
please.
> +
> + #ifdef CONFIG_SYS_VCXK_AUTODETECT
> + VC4K16 = 0;
> + vcxk_bws_long[1] = 0x0;
> + vcxk_bws_long[1] = 0x55AAAA55;
> + vcxk_bws_long[5] = 0x0;
> + if (vcxk_bws_long[1] == 0x55AAAA55)
> + {
> + VC4K16 = 1;
> + }
no braces here for single line if statement, please:
if (vcxk_bws_long[1] == 0x55AAAA55)
VC4K16 = 1;
Also do not indent here, too.
> + #else
> + VC4K16 = 1;
> + debug("No autodetect: use vc4k\n");
> + #endif
> +
> + CONFIG_SYS_VCXK_INVERT_INIT;
> +
> + CONFIG_SYS_VCXK_REQUEST_INIT;
> +
> + CONFIG_SYS_VCXK_ACKNOWLEDGE_INIT;
> +
> + CONFIG_SYS_VCXK_DISABLE;
> + CONFIG_SYS_VCXK_ENABLE_INIT;
CONFIG_SYS_* expand to code, please place board dependent code
here or in inline functions.
> +
> + vcxk_driver = search_vcxk_driver();
> + if (vcxk_driver)
> + {
> + /* use flash resist driver */
> + }
> + else
> + {
> + vcxk_cls();
> + vcxk_cls();
> + }
Use this style here:
if (vcxk_driver) {
/* use flash resident driver */
} else {
vcxk_cls();
vcxk_cls();
}
Are two vcxk_cls() calls really needed? If not, then remove.
Also, will search_vcxk_driver() ever be extended to return
not 0? If not, remove these checks from the driver.
> +
> + vcxk_setbrightness(3,1000);
> + CONFIG_SYS_VCXK_ENABLE;
CONFIG_SYS_VCXK_ENABLE expands to code, just place the code
here or move to a function.
> + return 1;
> +}
> +
> +/*----------------------------------------------------------------------------
> + ****f* bus_vcxk/vcxk_setpixel
> + * FUNCTION
> + * set the pixel[x,y] with the given color
> + * PARAMETER
> + * x pixel colum
> + * y pixel row
> + * color <0x40 off/black
> + * >0x40 on
> + ***
> +----------------------------------------------------------------------------*/
Fix multi-line comment style, please.
> +void vcxk_setpixel (int x, int y, unsigned long color)
> +{
> + vu_short dataptr;
> +
> + if (vcxk_driver)
> + {
> + /* use flash resist driver */
> + }
> + else
> + {
> + if ((x<display_width) && (y<display_height))
> + {
> +
> + dataptr = ((x / 16)) + (y * (display_bwidth>>1));
> +
> + color = ((color >> 16) & 0xFF) |
> + ((color >> 8) & 0xFF) | (color & 0xFF);
> +
> + if (color > 0x40)
> + {
> + VCXK_BWS_WORD_SET(dataptr,VCBITMASK(x));
> + }
> + else
> + {
> + VCXK_BWS_WORD_CLEAR(dataptr,VCBITMASK(x));
> + }
> + }
> + }
> +}
Check for coding style issues here, too. E.g.: if statements, spaces around "<", ">", ">>", etc. Fix it anywhere in the code, please.
Best regards,
Anatolij
^ permalink raw reply [flat|nested] 12+ messages in thread
* [U-Boot] [PATCH 1/2] new video driver for bus vcxk framebuffers
2009-07-18 16:54 ` Anatolij Gustschin
@ 2009-07-20 6:45 ` Jens Scharsig
0 siblings, 0 replies; 12+ messages in thread
From: Jens Scharsig @ 2009-07-20 6:45 UTC (permalink / raw)
To: u-boot
Hello Anatolij,
>> +initialize the reset line to vcxk hardware and release it from reset
>
> Looking on the changes to board configuration file
> "include/configs/EB+MCF-EV123.h" in the second patch of this series
> I now realize that most of these CONFIG_SYS_ macros above expand to
> C code, so these are not configuration options any more.
> I tend to reject all this. CONFIG_SYS_ options are supposed to be options
> and not board specific code. VCxK.c driver you removed by this patch
> series did it in more correct way, I think.
> What about moving this code to functions which use board specific macros?
> These functions should be placed in this new video driver then.
>
I will complete review the code.
I think, i can sent a new patch set within one week
Best regards,
Jens Scharsig
^ permalink raw reply [flat|nested] 12+ messages in thread
* [U-Boot] [PATCH 1/2 V2] new video driver for bus vcxk framebuffers
2009-04-22 14:36 [U-Boot] [PATCH 1/2] new video driver for bus vcxk framebuffers Jens Scharsig
2009-07-17 22:16 ` Wolfgang Denk
2009-07-18 16:54 ` Anatolij Gustschin
@ 2009-07-21 11:08 ` Jens Scharsig
2009-07-23 19:40 ` Wolfgang Denk
2009-07-24 8:09 ` [U-Boot] [PATCH 1/2 V3] " Jens Scharsig
3 siblings, 1 reply; 12+ messages in thread
From: Jens Scharsig @ 2009-07-21 11:08 UTC (permalink / raw)
To: u-boot
This patch adds a new video driver
* adds common bus_vcxk framebuffer driver
Signed-off-by: Jens Scharsig <esw@bus-elektronik.de>
---
diff --git a/doc/README.bus_vcxk b/doc/README.bus_vcxk
new file mode 100644
index 0000000..4eb8fe8
--- /dev/null
+++ b/doc/README.bus_vcxk
@@ -0,0 +1,85 @@
+/*
+ * (C) Copyright 2008-2009
+ * BuS Elektronik GmbH & Co. KG <www.bus-elektronik.de>
+ * Jens Scharsig <esw@bus-elektronik.de>
+ *
+ * See file CREDITS for list of people who contributed to this
+ * project.
+ *
+ * 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
+ */
+
+U-Boot vcxk video controller driver
+======================================
+
+By defining CONFIG_VIDEO_VCXK this driver can be used with VC2K, VC4K and
+VC8K devices on following boards:
+
+board | ARCH | Vendor
+-----------------------------------------------------------------------
+EB+CPU5282-T1 | MCF5282 | BuS Elektronik GmbH & Co. KG
+EB+MCF-EVB123 | MCF5282 | BuS Elektronik GmbH & Co. KG
+EB+CPUx9K2 | AT91RM9200 | BuS Elektronik GmbH & Co. KG
+ZLSA | AT91RM9200 | Ruf Telematik AG
+
+Driver configuration
+--------------------
+
+The driver needs some defines to describe the target hardware:
+
+CONFIG_SYS_VCXK_BASE
+
+ base address of VCxK hardware memory
+
+CONFIG_SYS_VCXK_DEFAULT_LINEALIGN
+
+ defines the physical alignment of a pixel row
+
+CONFIG_SYS_VCXK_DOUBLEBUFFERED
+
+ some boards that use vcxk prevent read from framebuffer memory.
+ define this option to enable double buffering (needs 16KiB RAM)
+
+CONFIG_SYS_VCXK_<xxxx>_PIN
+
+ defines the number of the I/O line PIN in the port
+ valid values for <xxxx> are:
+
+ ACKNOWLEDGE
+ describes the acknowledge line from vcxk hardware
+
+ ENABLE
+ describes the enable line to vcxk hardware
+
+ INVERT
+ describes the invert line to vcxk hardware
+
+ RESET
+ describes the reset line to vcxk hardware
+
+ REQUEST
+ describes the request line to vcxk hardware
+
+CONFIG_SYS_VCXK_<xxxx>_PORT
+
+ defines the I/O port which is connected with the line
+ for valid values for <xxxx> see CONFIG_SYS_VCXK_<xxxx>_PIN
+
+CONFIG_SYS_VCXK_<xxxx>_DDR
+
+ defines the register which configures the direction
+ for valid values for <xxxx> see CONFIG_SYS_VCXK_<xxxx>_PIN
+
diff --git a/drivers/video/Makefile b/drivers/video/Makefile
index bc00852..bb6b5a0 100644
--- a/drivers/video/Makefile
+++ b/drivers/video/Makefile
@@ -36,6 +36,7 @@ COBJS-$(CONFIG_VIDEO_SED13806) += sed13806.o
COBJS-$(CONFIG_SED156X) += sed156x.o
COBJS-$(CONFIG_VIDEO_SM501) += sm501.o
COBJS-$(CONFIG_VIDEO_SMI_LYNXEM) += smiLynxEM.o
+COBJS-$(CONFIG_VIDEO_VCXK) += bus_vcxk.o
COBJS-y += videomodes.o
COBJS := $(COBJS-y)
diff --git a/drivers/video/bus_vcxk.c b/drivers/video/bus_vcxk.c
new file mode 100644
index 0000000..51c15f8
--- /dev/null
+++ b/drivers/video/bus_vcxk.c
@@ -0,0 +1,436 @@
+/*
+ * (C) Copyright 2005-2009
+ * Jens Scharsig @ BuS Elektronik GmbH & Co. KG, <esw@bus-elektronik.de>
+ *
+ * See file CREDITS for list of people who contributed to this
+ * project.
+ *
+ * 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
+ */
+
+#include <common.h>
+#include <bmp_layout.h>
+#include <asm/io.h>
+
+vu_char *vcxk_bws = ((vu_char *) (CONFIG_SYS_VCXK_BASE));
+vu_short *vcxk_bws_word = ((vu_short *)(CONFIG_SYS_VCXK_BASE));
+vu_long *vcxk_bws_long = ((vu_long *) (CONFIG_SYS_VCXK_BASE));
+
+#ifdef CONFIG_AT91RM9200
+ #include <asm/arch/hardware.h>
+ #ifndef VCBITMASK
+ #define VCBITMASK(bitno) (0x0001 << (bitno % 16))
+ #endif
+ #define VCXK_INIT_PIN(PORT,PIN,DDR,I0O1) \
+ ((AT91PS_PIO) PORT)->PIO_PER = PIN; \
+ ((AT91PS_PIO) PORT)->DDR = PIN; \
+ ((AT91PS_PIO) PORT)->PIO_MDDR = PIN; \
+ if (!I0O1) ((AT91PS_PIO) PORT)->PIO_PPUER = PIN;
+
+ #define VCXK_SET_PIN(PORT,PIN) ((AT91PS_PIO) PORT)->PIO_SODR = PIN;
+ #define VCXK_CLR_PIN(PORT,PIN) ((AT91PS_PIO) PORT)->PIO_CODR = PIN;
+
+ #define VCXK_ACKNOWLEDGE \
+ (!(((AT91PS_PIO) CONFIG_SYS_VCXK_ACKNOWLEDGE_PORT)->\
+ PIO_PDSR & CONFIG_SYS_VCXK_ACKNOWLEDGE_PIN))
+
+#elif defined(CONFIG_MCF52x2)
+ #include <asm/m5282.h>
+ #ifndef VCBITMASK
+ #define VCBITMASK(bitno) (0x8000 >> (bitno % 16))
+ #endif
+
+ #define VCXK_INIT_PIN(PORT,PIN,DDR,I0O1) \
+ if (I0O1) DDR |= PIN; else DDR &= ~PIN;
+
+ #define VCXK_SET_PIN(PORT,PIN) PORT |= PIN;
+ #define VCXK_CLR_PIN(PORT,PIN) PORT &= ~PIN;
+
+ #define VCXK_ACKNOWLEDGE \
+ (!(CONFIG_SYS_VCXK_ACKNOWLEDGE_PORT & \
+ CONFIG_SYS_VCXK_ACKNOWLEDGE_PIN))
+
+#else
+ #error no vcxk support for selected ARCH
+#endif
+
+#define VCXK_DISABLE\
+ VCXK_SET_PIN(CONFIG_SYS_VCXK_ENABLE_PORT,CONFIG_SYS_VCXK_ENABLE_PIN)
+#define VCXK_ENABLE\
+ VCXK_CLR_PIN(CONFIG_SYS_VCXK_ENABLE_PORT,CONFIG_SYS_VCXK_ENABLE_PIN)
+
+#ifndef CONFIG_SYS_VCXK_DOUBLEBUFFERED
+ #define VCXK_BWS(x,data) vcxk_bws[x] = data;
+ #define VCXK_BWS_WORD_SET(x,mask) vcxk_bws_word[x] |= mask;
+ #define VCXK_BWS_WORD_CLEAR(x,mask) vcxk_bws_word[x] &= ~mask;
+ #define VCXK_BWS_LONG(x,data) vcxk_bws_long[x] = data;
+#else
+ u_char double_bws[16384];
+ u_short *double_bws_word;
+ u_long *double_bws_long;
+ #define VCXK_BWS(x,data) \
+ double_bws[x] = data; vcxk_bws[x] = data;
+ #define VCXK_BWS_WORD_SET(x,mask) \
+ double_bws_word[x] |= mask; \
+ vcxk_bws_word[x] = double_bws_word[x];
+ #define VCXK_BWS_WORD_CLEAR(x,mask) \
+ double_bws_word[x] &= ~mask; \
+ vcxk_bws_word[x] = double_bws_word[x];
+ #define VCXK_BWS_LONG(x,data) \
+ double_bws_long[x] = data; vcxk_bws_long[x] = data;
+#endif
+
+#define VC4K16_Bright1 vcxk_bws_word[0x20004 / 2]
+#define VC4K16_Bright2 vcxk_bws_word[0x20006 / 2]
+#define VC2K_Bright vcxk_bws[0x8000]
+#define VC8K_BrightH vcxk_bws[0xC000]
+#define VC8K_BrightL vcxk_bws[0xC001]
+
+vu_char VC4K16;
+
+u_long display_width;
+u_long display_height;
+u_long display_bwidth;
+
+ulong search_vcxk_driver(void);
+void vcxk_cls(void);
+void vcxk_setbrightness(unsigned int side, short brightness);
+int vcxk_request(void);
+int vcxk_acknowledge_wait(void);
+void vcxk_clear(void);
+
+/*
+ ****f* bus_vcxk/vcxk_init
+ * FUNCTION
+ * initialalize Video Controller
+ * PARAMETERS
+ * width visible display width in pixel
+ * height visible display height in pixel
+ ***
+ */
+
+int vcxk_init(unsigned long width, unsigned long height)
+{
+#ifdef CONFIG_SYS_VCXK_RESET_PORT
+ VCXK_INIT_PIN(CONFIG_SYS_VCXK_RESET_PORT,
+ CONFIG_SYS_VCXK_RESET_PIN,CONFIG_SYS_VCXK_RESET_DDR,1)
+ VCXK_SET_PIN(CONFIG_SYS_VCXK_RESET_PORT,CONFIG_SYS_VCXK_RESET_PIN);
+#endif
+
+#ifdef CONFIG_SYS_VCXK_DOUBLEBUFFERED
+ double_bws_word = (u_short *) double_bws;
+ double_bws_long = (u_long *)double_bws;
+ debug("%lx %lx %lx \n",double_bws,double_bws_word,double_bws_long);
+#endif
+ display_width = width;
+ display_height = height;
+#if (CONFIG_SYS_VCXK_DEFAULT_LINEALIGN==4)
+ display_bwidth =((width + 31) / 8) & ~0x3;
+#elif (CONFIG_SYS_VCXK_DEFAULT_LINEALIGN==2)
+ display_bwidth =((width + 15) / 8) & ~0x1;
+#else
+ #error CONFIG_SYS_VCXK_DEFAULT_LINEALIGN is invalid
+#endif
+ debug("linesize ((%d + 15)/8 & ~0x1) = %d\n",
+ display_width,display_bwidth);
+
+#ifdef CONFIG_SYS_VCXK_AUTODETECT
+ VC4K16 = 0;
+ vcxk_bws_long[1] = 0x0;
+ vcxk_bws_long[1] = 0x55AAAA55;
+ vcxk_bws_long[5] = 0x0;
+ if (vcxk_bws_long[1] == 0x55AAAA55) VC4K16 = 1;
+#else
+ VC4K16 = 1;
+ debug("No autodetect: use vc4k\n");
+#endif
+
+ VCXK_INIT_PIN(CONFIG_SYS_VCXK_INVERT_PORT,
+ CONFIG_SYS_VCXK_INVERT_PIN,CONFIG_SYS_VCXK_INVERT_DDR,1)
+ VCXK_SET_PIN(CONFIG_SYS_VCXK_INVERT_PORT,CONFIG_SYS_VCXK_INVERT_PIN)
+
+ VCXK_SET_PIN(CONFIG_SYS_VCXK_REQUEST_PORT,CONFIG_SYS_VCXK_REQUEST_PIN);
+ VCXK_INIT_PIN(CONFIG_SYS_VCXK_REQUEST_PORT,
+ CONFIG_SYS_VCXK_REQUEST_PIN,CONFIG_SYS_VCXK_REQUEST_DDR,1)
+
+ VCXK_INIT_PIN(CONFIG_SYS_VCXK_ACKNOWLEDGE_PORT,
+ CONFIG_SYS_VCXK_ACKNOWLEDGE_PIN,
+ CONFIG_SYS_VCXK_ACKNOWLEDGE_DDR,0)
+
+ VCXK_DISABLE;
+ VCXK_INIT_PIN(CONFIG_SYS_VCXK_ENABLE_PORT,
+ CONFIG_SYS_VCXK_ENABLE_PIN,CONFIG_SYS_VCXK_ENABLE_DDR,1)
+
+ vcxk_cls();
+ vcxk_cls(); /* clear second/hidden page */
+
+ vcxk_setbrightness(3,1000);
+ VCXK_ENABLE;
+ return 1;
+}
+
+/*
+ ****f* bus_vcxk/vcxk_setpixel
+ * FUNCTION
+ * set the pixel[x,y] with the given color
+ * PARAMETER
+ * x pixel colum
+ * y pixel row
+ * color <0x40 off/black
+ * >0x40 on
+ ***
+ */
+
+void vcxk_setpixel (int x, int y, unsigned long color)
+{
+ vu_short dataptr;
+
+ if ((x < display_width) && (y < display_height)) {
+ dataptr = ((x / 16)) + (y * (display_bwidth >> 1));
+
+ color = ((color >> 16) & 0xFF) |
+ ((color >> 8) & 0xFF) | (color & 0xFF);
+
+ if (color > 0x40) {
+ VCXK_BWS_WORD_SET(dataptr,VCBITMASK(x));
+ } else {
+ VCXK_BWS_WORD_CLEAR(dataptr,VCBITMASK(x));
+ }
+ }
+}
+
+/*
+ ****f* bus_vcxk/vcxk_loadimage
+ * FUNCTION
+ * copies a binary image to display memory
+ ***
+ */
+
+void vcxk_loadimage(ulong source)
+{
+ int cnt;
+ vcxk_acknowledge_wait();
+ if (VC4K16) {
+ for (cnt = 0; cnt < (16384 / 4); cnt++) {
+ VCXK_BWS_LONG(cnt,(*(ulong*) source));
+ source = source + 4;
+ }
+ } else {
+ for (cnt = 0; cnt < 16384; cnt++) {
+ VCXK_BWS_LONG(cnt*2,(*(vu_char*) source));
+ source++;
+ }
+ }
+ vcxk_request();
+}
+
+/*
+ ****f* bus_vcxk/vcxk_cls
+ * FUNCTION
+ * clear the display
+ ***
+ */
+
+void vcxk_cls(void)
+{
+ vcxk_acknowledge_wait();
+ vcxk_clear();
+ vcxk_request();
+}
+
+/*
+ ****f* bus_vcxk/vcxk_clear(void)
+ * FUNCTION
+ * clear the display memory
+ ***
+ */
+
+void vcxk_clear(void)
+{
+ int cnt;
+ for (cnt = 0; cnt < (16384 / 4); cnt++) {
+ VCXK_BWS_LONG(cnt,0)
+ }
+}
+
+/*
+ ****f* bus_vcxk/vcxk_setbrightness
+ * FUNCTION
+ * set the display brightness
+ * PARAMETER
+ * side 1 set front side brightness
+ * 2 set back side brightness
+ * 3 set brightness for both sides
+ * brightness 0..1000
+ ***
+ */
+
+void vcxk_setbrightness(unsigned int side, short brightness)
+{
+ if (VC4K16) {
+ if ((side == 0) || (side & 0x1))
+ VC4K16_Bright1 = brightness + 23;
+ if ((side == 0) || (side & 0x2))
+ VC4K16_Bright2 = brightness + 23;
+ } else {
+ VC2K_Bright = (brightness >> 4) +2;
+ VC8K_BrightH = (brightness + 23) >> 8;
+ VC8K_BrightL = (brightness + 23) & 0xFF;
+ }
+}
+
+/*
+ ****f* bus_vcxk/vcxk_request
+ * FUNCTION
+ * requests viewing of display memory
+ ***
+ */
+
+int vcxk_request(void)
+{
+ VCXK_CLR_PIN(CONFIG_SYS_VCXK_REQUEST_PORT,
+ CONFIG_SYS_VCXK_REQUEST_PIN)
+ VCXK_SET_PIN(CONFIG_SYS_VCXK_REQUEST_PORT,
+ CONFIG_SYS_VCXK_REQUEST_PIN);
+ return 1;
+}
+
+/*
+ ****f* bus_vcxk/vcxk_acknowledge_wait
+ * FUNCTION
+ * wait for acknowledge viewing requests
+ ***
+ */
+
+int vcxk_acknowledge_wait(void)
+{
+ while (VCXK_ACKNOWLEDGE);
+ return 1;
+}
+
+/*
+ ****f* bus_vcxk/vcxk_display_bitmap
+ * FUNCTION
+ * copies a bitmap (BMP-Format) to the given position
+ * PARAMETER
+ * addr pointer to bitmap
+ * x output bitmap @ columne
+ * y output bitmap @ row
+ ***
+ */
+
+int vcxk_display_bitmap (ulong addr, int x, int y)
+{
+ bmp_image_t *bmp;
+ unsigned long width;
+ unsigned long height;
+ unsigned long bpp;
+ unsigned long compression;
+
+ unsigned long xcnt,ycnt;
+ unsigned long linewidth;
+
+ unsigned long cp_width;
+ unsigned long cp_height;
+ unsigned char *dataptr;
+ unsigned char *lineptr;
+
+ bmp = (bmp_image_t *) addr;
+ if ((bmp->header.signature[0] == 'B') &&
+ (bmp->header.signature[1] == 'M'))
+ {
+ compression = le32_to_cpu (bmp->header.compression);
+ width = le32_to_cpu (bmp->header.width);
+ height = le32_to_cpu (bmp->header.height);
+ bpp = le16_to_cpu (bmp->header.bit_count);
+
+ dataptr = (unsigned char *) bmp +
+ le32_to_cpu(bmp->header.data_offset);
+
+ if (display_width < (width + x))
+ {
+ cp_width = display_width - x;
+ }
+ else
+ {
+ cp_width = width;
+ }
+ if (display_height < (height + y))
+ {
+ cp_height = display_height - y;
+ }
+ else
+ {
+ cp_height = height;
+ }
+ linewidth = (((width + 7) / 8) + 3) & ~0x3;
+ if (cp_height < height)
+ {
+ dataptr=dataptr + linewidth * (height - cp_height);
+ }
+ switch (bpp)
+ {
+ case 1:
+ for (ycnt = cp_height;ycnt > 0; ycnt--)
+ {
+ lineptr = dataptr;
+ for (xcnt = 0;xcnt < cp_width; xcnt++)
+ {
+ if ((*lineptr << (xcnt % 8))
+ & 0x80) {
+ vcxk_setpixel(xcnt,
+ ycnt - 1,
+ 0xFFFFFF);
+ } else {
+ vcxk_setpixel(xcnt,
+ ycnt-1,0);
+ }
+ if ((xcnt % 8) == 7) lineptr++;
+ } /* endfor xcnt */
+ dataptr = dataptr + linewidth;
+ } /* endfor ycnt */
+ break;
+ default:
+ printf("Error: %ld bit per pixel "
+ "not supported by VCxK\n",bpp);
+ return 0;
+ }
+ }
+ else
+ {
+ printf("Error: no valid bmp at %lx\n", (ulong) bmp);
+ return 0;
+ }
+ return 1;
+}
+
+/*
+ ****f* bus_vcxk/video_display_bitmap
+ ***
+ */
+
+int video_display_bitmap (ulong addr, int x, int y)
+{
+ vcxk_acknowledge_wait();
+ if (vcxk_display_bitmap (addr,x, y))
+ {
+ vcxk_request();
+ return 0;
+ }
+ return 1;
+}
+
+/* EOF */
diff --git a/include/bus_vcxk.h b/include/bus_vcxk.h
new file mode 100644
index 0000000..8d6a25c
--- /dev/null
+++ b/include/bus_vcxk.h
@@ -0,0 +1,36 @@
+/*
+ * (C) Copyright 2005-2009
+ * Jens Scharsig @ BuS Elektronik GmbH & Co. KG, <esw@bus-elektronik.de>
+ *
+ * See file CREDITS for list of people who contributed to this
+ * project.
+ *
+ * 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 __BUS_VCXK_H_
+#define __BUS_VCXK_H_
+
+extern int vcxk_init(unsigned long width, unsigned long height);
+extern void vcxk_setpixel (int x, int y, unsigned long color);
+extern int vcxk_acknowledge_wait(void);
+extern int vcxk_request(void);
+extern void vcxk_loadimage(ulong source);
+extern int vcxk_display_bitmap (ulong addr, int x, int y);
+extern void vcxk_setbrightness(unsigned int side, short brightness);
+extern int video_display_bitmap (ulong addr, int x, int y);
+
+#endif
^ permalink raw reply related [flat|nested] 12+ messages in thread
* [U-Boot] [PATCH 1/2 V2] new video driver for bus vcxk framebuffers
2009-07-21 11:08 ` [U-Boot] [PATCH 1/2 V2] " Jens Scharsig
@ 2009-07-23 19:40 ` Wolfgang Denk
2009-07-24 8:09 ` Jens Scharsig
0 siblings, 1 reply; 12+ messages in thread
From: Wolfgang Denk @ 2009-07-23 19:40 UTC (permalink / raw)
To: u-boot
Dear Jens Scharsig,
In message <4A65A19E.6060605@bus-elektronik.de> you wrote:
> This patch adds a new video driver
...
> +int vcxk_display_bitmap (ulong addr, int x, int y)
> +{
...
> + if ((bmp->header.signature[0] == 'B') &&
> + (bmp->header.signature[1] == 'M'))
> + {
> + compression = le32_to_cpu (bmp->header.compression);
> + width = le32_to_cpu (bmp->header.width);
> + height = le32_to_cpu (bmp->header.height);
> + bpp = le16_to_cpu (bmp->header.bit_count);
> +
> + dataptr = (unsigned char *) bmp +
> + le32_to_cpu(bmp->header.data_offset);
> +
> + if (display_width < (width + x))
> + {
> + cp_width = display_width - x;
> + }
> + else
> + {
> + cp_width = width;
> + }
> + if (display_height < (height + y))
> + {
> + cp_height = display_height - y;
> + }
> + else
> + {
> + cp_height = height;
> + }
...
Incorrect brace style.
...
> + switch (bpp)
> + {
> + case 1:
> + for (ycnt = cp_height;ycnt > 0; ycnt--)
> + {
> + lineptr = dataptr;
> + for (xcnt = 0;xcnt < cp_width; xcnt++)
> + {
> + if ((*lineptr << (xcnt % 8))
> + & 0x80) {
> + vcxk_setpixel(xcnt,
> + ycnt - 1,
> + 0xFFFFFF);
> + } else {
> + vcxk_setpixel(xcnt,
> + ycnt-1,0);
> + }
Quoting the CodingStyle:
Now, some people will claim that having 8-character
indentations makes the code move too far to the right, and
makes it hard to read on a 80-character terminal screen. The
answer to that is that if you need more than 3 levels of
indentation, you're screwed anyway, and should fix your
program.
Please clean up and resubmit.
Best regards,
Wolfgang Denk
--
DENX Software Engineering GmbH, MD: Wolfgang Denk & Detlev Zundel
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: (+49)-8142-66989-10 Fax: (+49)-8142-66989-80 Email: wd at denx.de
Shakespeare's Law of Prototyping: (Hamlet III, iv, 156-160)
O, throw away the worser part of it,
And live the purer with the other half.
^ permalink raw reply [flat|nested] 12+ messages in thread
* [U-Boot] [PATCH 1/2 V3] new video driver for bus vcxk framebuffers
2009-04-22 14:36 [U-Boot] [PATCH 1/2] new video driver for bus vcxk framebuffers Jens Scharsig
` (2 preceding siblings ...)
2009-07-21 11:08 ` [U-Boot] [PATCH 1/2 V2] " Jens Scharsig
@ 2009-07-24 8:09 ` Jens Scharsig
2009-07-26 11:46 ` Anatolij Gustschin
3 siblings, 1 reply; 12+ messages in thread
From: Jens Scharsig @ 2009-07-24 8:09 UTC (permalink / raw)
To: u-boot
This patch adds a new video driver
* adds common bus_vcxk framebuffer driver
Signed-off-by: Jens Scharsig <esw@bus-elektronik.de>
---
diff --git a/doc/README.bus_vcxk b/doc/README.bus_vcxk
new file mode 100644
index 0000000..4eb8fe8
--- /dev/null
+++ b/doc/README.bus_vcxk
@@ -0,0 +1,85 @@
+/*
+ * (C) Copyright 2008-2009
+ * BuS Elektronik GmbH & Co. KG <www.bus-elektronik.de>
+ * Jens Scharsig <esw@bus-elektronik.de>
+ *
+ * See file CREDITS for list of people who contributed to this
+ * project.
+ *
+ * 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
+ */
+
+U-Boot vcxk video controller driver
+======================================
+
+By defining CONFIG_VIDEO_VCXK this driver can be used with VC2K, VC4K and
+VC8K devices on following boards:
+
+board | ARCH | Vendor
+-----------------------------------------------------------------------
+EB+CPU5282-T1 | MCF5282 | BuS Elektronik GmbH & Co. KG
+EB+MCF-EVB123 | MCF5282 | BuS Elektronik GmbH & Co. KG
+EB+CPUx9K2 | AT91RM9200 | BuS Elektronik GmbH & Co. KG
+ZLSA | AT91RM9200 | Ruf Telematik AG
+
+Driver configuration
+--------------------
+
+The driver needs some defines to describe the target hardware:
+
+CONFIG_SYS_VCXK_BASE
+
+ base address of VCxK hardware memory
+
+CONFIG_SYS_VCXK_DEFAULT_LINEALIGN
+
+ defines the physical alignment of a pixel row
+
+CONFIG_SYS_VCXK_DOUBLEBUFFERED
+
+ some boards that use vcxk prevent read from framebuffer memory.
+ define this option to enable double buffering (needs 16KiB RAM)
+
+CONFIG_SYS_VCXK_<xxxx>_PIN
+
+ defines the number of the I/O line PIN in the port
+ valid values for <xxxx> are:
+
+ ACKNOWLEDGE
+ describes the acknowledge line from vcxk hardware
+
+ ENABLE
+ describes the enable line to vcxk hardware
+
+ INVERT
+ describes the invert line to vcxk hardware
+
+ RESET
+ describes the reset line to vcxk hardware
+
+ REQUEST
+ describes the request line to vcxk hardware
+
+CONFIG_SYS_VCXK_<xxxx>_PORT
+
+ defines the I/O port which is connected with the line
+ for valid values for <xxxx> see CONFIG_SYS_VCXK_<xxxx>_PIN
+
+CONFIG_SYS_VCXK_<xxxx>_DDR
+
+ defines the register which configures the direction
+ for valid values for <xxxx> see CONFIG_SYS_VCXK_<xxxx>_PIN
+
diff --git a/drivers/video/Makefile b/drivers/video/Makefile
index bc00852..bb6b5a0 100644
--- a/drivers/video/Makefile
+++ b/drivers/video/Makefile
@@ -36,6 +36,7 @@ COBJS-$(CONFIG_VIDEO_SED13806) += sed13806.o
COBJS-$(CONFIG_SED156X) += sed156x.o
COBJS-$(CONFIG_VIDEO_SM501) += sm501.o
COBJS-$(CONFIG_VIDEO_SMI_LYNXEM) += smiLynxEM.o
+COBJS-$(CONFIG_VIDEO_VCXK) += bus_vcxk.o
COBJS-y += videomodes.o
COBJS := $(COBJS-y)
diff --git a/drivers/video/bus_vcxk.c b/drivers/video/bus_vcxk.c
new file mode 100644
index 0000000..f09ed43
--- /dev/null
+++ b/drivers/video/bus_vcxk.c
@@ -0,0 +1,436 @@
+/*
+ * (C) Copyright 2005-2009
+ * Jens Scharsig @ BuS Elektronik GmbH & Co. KG, <esw@bus-elektronik.de>
+ *
+ * See file CREDITS for list of people who contributed to this
+ * project.
+ *
+ * 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
+ */
+
+#include <common.h>
+#include <bmp_layout.h>
+#include <asm/io.h>
+
+vu_char *vcxk_bws = ((vu_char *) (CONFIG_SYS_VCXK_BASE));
+vu_short *vcxk_bws_word = ((vu_short *)(CONFIG_SYS_VCXK_BASE));
+vu_long *vcxk_bws_long = ((vu_long *) (CONFIG_SYS_VCXK_BASE));
+
+#ifdef CONFIG_AT91RM9200
+ #include <asm/arch/hardware.h>
+ #ifndef VCBITMASK
+ #define VCBITMASK(bitno) (0x0001 << (bitno % 16))
+ #endif
+ #define VCXK_INIT_PIN(PORT,PIN,DDR,I0O1) \
+ ((AT91PS_PIO) PORT)->PIO_PER = PIN; \
+ ((AT91PS_PIO) PORT)->DDR = PIN; \
+ ((AT91PS_PIO) PORT)->PIO_MDDR = PIN; \
+ if (!I0O1) ((AT91PS_PIO) PORT)->PIO_PPUER = PIN;
+
+ #define VCXK_SET_PIN(PORT,PIN) ((AT91PS_PIO) PORT)->PIO_SODR = PIN;
+ #define VCXK_CLR_PIN(PORT,PIN) ((AT91PS_PIO) PORT)->PIO_CODR = PIN;
+
+ #define VCXK_ACKNOWLEDGE \
+ (!(((AT91PS_PIO) CONFIG_SYS_VCXK_ACKNOWLEDGE_PORT)->\
+ PIO_PDSR & CONFIG_SYS_VCXK_ACKNOWLEDGE_PIN))
+
+#elif defined(CONFIG_MCF52x2)
+ #include <asm/m5282.h>
+ #ifndef VCBITMASK
+ #define VCBITMASK(bitno) (0x8000 >> (bitno % 16))
+ #endif
+
+ #define VCXK_INIT_PIN(PORT,PIN,DDR,I0O1) \
+ if (I0O1) DDR |= PIN; else DDR &= ~PIN;
+
+ #define VCXK_SET_PIN(PORT,PIN) PORT |= PIN;
+ #define VCXK_CLR_PIN(PORT,PIN) PORT &= ~PIN;
+
+ #define VCXK_ACKNOWLEDGE \
+ (!(CONFIG_SYS_VCXK_ACKNOWLEDGE_PORT & \
+ CONFIG_SYS_VCXK_ACKNOWLEDGE_PIN))
+
+#else
+ #error no vcxk support for selected ARCH
+#endif
+
+#define VCXK_DISABLE\
+ VCXK_SET_PIN(CONFIG_SYS_VCXK_ENABLE_PORT,CONFIG_SYS_VCXK_ENABLE_PIN)
+#define VCXK_ENABLE\
+ VCXK_CLR_PIN(CONFIG_SYS_VCXK_ENABLE_PORT,CONFIG_SYS_VCXK_ENABLE_PIN)
+
+#ifndef CONFIG_SYS_VCXK_DOUBLEBUFFERED
+ #define VCXK_BWS(x,data) vcxk_bws[x] = data;
+ #define VCXK_BWS_WORD_SET(x,mask) vcxk_bws_word[x] |= mask;
+ #define VCXK_BWS_WORD_CLEAR(x,mask) vcxk_bws_word[x] &= ~mask;
+ #define VCXK_BWS_LONG(x,data) vcxk_bws_long[x] = data;
+#else
+ u_char double_bws[16384];
+ u_short *double_bws_word;
+ u_long *double_bws_long;
+ #define VCXK_BWS(x,data) \
+ double_bws[x] = data; vcxk_bws[x] = data;
+ #define VCXK_BWS_WORD_SET(x,mask) \
+ double_bws_word[x] |= mask; \
+ vcxk_bws_word[x] = double_bws_word[x];
+ #define VCXK_BWS_WORD_CLEAR(x,mask) \
+ double_bws_word[x] &= ~mask; \
+ vcxk_bws_word[x] = double_bws_word[x];
+ #define VCXK_BWS_LONG(x,data) \
+ double_bws_long[x] = data; vcxk_bws_long[x] = data;
+#endif
+
+#define VC4K16_Bright1 vcxk_bws_word[0x20004 / 2]
+#define VC4K16_Bright2 vcxk_bws_word[0x20006 / 2]
+#define VC2K_Bright vcxk_bws[0x8000]
+#define VC8K_BrightH vcxk_bws[0xC000]
+#define VC8K_BrightL vcxk_bws[0xC001]
+
+vu_char VC4K16;
+
+u_long display_width;
+u_long display_height;
+u_long display_bwidth;
+
+ulong search_vcxk_driver(void);
+void vcxk_cls(void);
+void vcxk_setbrightness(unsigned int side, short brightness);
+int vcxk_request(void);
+int vcxk_acknowledge_wait(void);
+void vcxk_clear(void);
+
+/*
+ ****f* bus_vcxk/vcxk_init
+ * FUNCTION
+ * initialalize Video Controller
+ * PARAMETERS
+ * width visible display width in pixel
+ * height visible display height in pixel
+ ***
+ */
+
+int vcxk_init(unsigned long width, unsigned long height)
+{
+#ifdef CONFIG_SYS_VCXK_RESET_PORT
+ VCXK_INIT_PIN(CONFIG_SYS_VCXK_RESET_PORT,
+ CONFIG_SYS_VCXK_RESET_PIN, CONFIG_SYS_VCXK_RESET_DDR, 1)
+ VCXK_SET_PIN(CONFIG_SYS_VCXK_RESET_PORT, CONFIG_SYS_VCXK_RESET_PIN);
+#endif
+
+#ifdef CONFIG_SYS_VCXK_DOUBLEBUFFERED
+ double_bws_word = (u_short *) double_bws;
+ double_bws_long = (u_long *)double_bws;
+ debug("%lx %lx %lx \n", double_bws,double_bws_word, double_bws_long);
+#endif
+ display_width = width;
+ display_height = height;
+#if (CONFIG_SYS_VCXK_DEFAULT_LINEALIGN==4)
+ display_bwidth =((width + 31) / 8) & ~0x3;
+#elif (CONFIG_SYS_VCXK_DEFAULT_LINEALIGN==2)
+ display_bwidth =((width + 15) / 8) & ~0x1;
+#else
+ #error CONFIG_SYS_VCXK_DEFAULT_LINEALIGN is invalid
+#endif
+ debug("linesize ((%d + 15) / 8 & ~0x1) = %d\n",
+ display_width, display_bwidth);
+
+#ifdef CONFIG_SYS_VCXK_AUTODETECT
+ VC4K16 = 0;
+ vcxk_bws_long[1] = 0x0;
+ vcxk_bws_long[1] = 0x55AAAA55;
+ vcxk_bws_long[5] = 0x0;
+ if (vcxk_bws_long[1] == 0x55AAAA55) VC4K16 = 1;
+#else
+ VC4K16 = 1;
+ debug("No autodetect: use vc4k\n");
+#endif
+
+ VCXK_INIT_PIN(CONFIG_SYS_VCXK_INVERT_PORT,
+ CONFIG_SYS_VCXK_INVERT_PIN, CONFIG_SYS_VCXK_INVERT_DDR, 1)
+ VCXK_SET_PIN(CONFIG_SYS_VCXK_INVERT_PORT, CONFIG_SYS_VCXK_INVERT_PIN)
+
+ VCXK_SET_PIN(CONFIG_SYS_VCXK_REQUEST_PORT, CONFIG_SYS_VCXK_REQUEST_PIN);
+ VCXK_INIT_PIN(CONFIG_SYS_VCXK_REQUEST_PORT,
+ CONFIG_SYS_VCXK_REQUEST_PIN, CONFIG_SYS_VCXK_REQUEST_DDR, 1)
+
+ VCXK_INIT_PIN(CONFIG_SYS_VCXK_ACKNOWLEDGE_PORT,
+ CONFIG_SYS_VCXK_ACKNOWLEDGE_PIN,
+ CONFIG_SYS_VCXK_ACKNOWLEDGE_DDR, 0)
+
+ VCXK_DISABLE;
+ VCXK_INIT_PIN(CONFIG_SYS_VCXK_ENABLE_PORT,
+ CONFIG_SYS_VCXK_ENABLE_PIN, CONFIG_SYS_VCXK_ENABLE_DDR, 1)
+
+ vcxk_cls();
+ vcxk_cls(); /* clear second/hidden page */
+
+ vcxk_setbrightness(3, 1000);
+ VCXK_ENABLE;
+ return 1;
+}
+
+/*
+ ****f* bus_vcxk/vcxk_setpixel
+ * FUNCTION
+ * set the pixel[x,y] with the given color
+ * PARAMETER
+ * x pixel colum
+ * y pixel row
+ * color <0x40 off/black
+ * >0x40 on
+ ***
+ */
+
+void vcxk_setpixel (int x, int y, unsigned long color)
+{
+ vu_short dataptr;
+
+ if ((x < display_width) && (y < display_height)) {
+ dataptr = ((x / 16)) + (y * (display_bwidth >> 1));
+
+ color = ((color >> 16) & 0xFF) |
+ ((color >> 8) & 0xFF) | (color & 0xFF);
+
+ if (color > 0x40) {
+ VCXK_BWS_WORD_SET(dataptr, VCBITMASK(x));
+ } else {
+ VCXK_BWS_WORD_CLEAR(dataptr, VCBITMASK(x));
+ }
+ }
+}
+
+/*
+ ****f* bus_vcxk/vcxk_loadimage
+ * FUNCTION
+ * copies a binary image to display memory
+ ***
+ */
+
+void vcxk_loadimage(ulong source)
+{
+ int cnt;
+ vcxk_acknowledge_wait();
+ if (VC4K16) {
+ for (cnt = 0; cnt < (16384 / 4); cnt++) {
+ VCXK_BWS_LONG(cnt, (*(ulong*) source));
+ source = source + 4;
+ }
+ } else {
+ for (cnt = 0; cnt < 16384; cnt++) {
+ VCXK_BWS_LONG(cnt*2, (*(vu_char*) source));
+ source++;
+ }
+ }
+ vcxk_request();
+}
+
+/*
+ ****f* bus_vcxk/vcxk_cls
+ * FUNCTION
+ * clear the display
+ ***
+ */
+
+void vcxk_cls(void)
+{
+ vcxk_acknowledge_wait();
+ vcxk_clear();
+ vcxk_request();
+}
+
+/*
+ ****f* bus_vcxk/vcxk_clear(void)
+ * FUNCTION
+ * clear the display memory
+ ***
+ */
+
+void vcxk_clear(void)
+{
+ int cnt;
+ for (cnt = 0; cnt < (16384 / 4); cnt++) {
+ VCXK_BWS_LONG(cnt, 0)
+ }
+}
+
+/*
+ ****f* bus_vcxk/vcxk_setbrightness
+ * FUNCTION
+ * set the display brightness
+ * PARAMETER
+ * side 1 set front side brightness
+ * 2 set back side brightness
+ * 3 set brightness for both sides
+ * brightness 0..1000
+ ***
+ */
+
+void vcxk_setbrightness(unsigned int side, short brightness)
+{
+ if (VC4K16) {
+ if ((side == 0) || (side & 0x1))
+ VC4K16_Bright1 = brightness + 23;
+ if ((side == 0) || (side & 0x2))
+ VC4K16_Bright2 = brightness + 23;
+ } else {
+ VC2K_Bright = (brightness >> 4) +2;
+ VC8K_BrightH = (brightness + 23) >> 8;
+ VC8K_BrightL = (brightness + 23) & 0xFF;
+ }
+}
+
+/*
+ ****f* bus_vcxk/vcxk_request
+ * FUNCTION
+ * requests viewing of display memory
+ ***
+ */
+
+int vcxk_request(void)
+{
+ VCXK_CLR_PIN(CONFIG_SYS_VCXK_REQUEST_PORT,
+ CONFIG_SYS_VCXK_REQUEST_PIN)
+ VCXK_SET_PIN(CONFIG_SYS_VCXK_REQUEST_PORT,
+ CONFIG_SYS_VCXK_REQUEST_PIN);
+ return 1;
+}
+
+/*
+ ****f* bus_vcxk/vcxk_acknowledge_wait
+ * FUNCTION
+ * wait for acknowledge viewing requests
+ ***
+ */
+
+int vcxk_acknowledge_wait(void)
+{
+ while (VCXK_ACKNOWLEDGE);
+ return 1;
+}
+
+/*
+ ****f* bus_vcxk/vcxk_draw_mono
+ * FUNCTION
+ * copies a monochrom bitmap (BMP-Format) from given memory
+ * PARAMETER
+ * dataptr pointer to bitmap
+ * x output bitmap @ columne
+ * y output bitmap @ row
+ ***
+ */
+
+void vcxk_draw_mono(unsigned char *dataptr, unsigned long linewidth,
+ unsigned long cp_width, unsigned long cp_height)
+{
+ unsigned char *lineptr;
+ unsigned long xcnt,ycnt;
+
+ for (ycnt = cp_height; ycnt > 0; ycnt--) {
+ lineptr = dataptr;
+ for (xcnt = 0; xcnt < cp_width; xcnt++) {
+ if ((*lineptr << (xcnt % 8)) & 0x80)
+ vcxk_setpixel(xcnt, ycnt - 1, 0xFFFFFF);
+ else
+ vcxk_setpixel(xcnt, ycnt-1, 0);
+
+ if ((xcnt % 8) == 7) lineptr++;
+ } /* endfor xcnt */
+ dataptr = dataptr + linewidth;
+ } /* endfor ycnt */
+}
+
+/*
+ ****f* bus_vcxk/vcxk_display_bitmap
+ * FUNCTION
+ * copies a bitmap (BMP-Format) to the given position
+ * PARAMETER
+ * addr pointer to bitmap
+ * x output bitmap @ columne
+ * y output bitmap @ row
+ ***
+ */
+
+int vcxk_display_bitmap (ulong addr, int x, int y)
+{
+ bmp_image_t *bmp;
+ unsigned long width;
+ unsigned long height;
+ unsigned long bpp;
+ unsigned long compression;
+
+ unsigned long lw;
+
+ unsigned long c_width;
+ unsigned long c_height;
+ unsigned char *dataptr;
+ unsigned char *lineptr;
+
+ bmp = (bmp_image_t *) addr;
+ if ((bmp->header.signature[0] == 'B') &&
+ (bmp->header.signature[1] == 'M')) {
+ compression = le32_to_cpu (bmp->header.compression);
+ width = le32_to_cpu (bmp->header.width);
+ height = le32_to_cpu (bmp->header.height);
+ bpp = le16_to_cpu (bmp->header.bit_count);
+
+ dataptr = (unsigned char *) bmp +
+ le32_to_cpu(bmp->header.data_offset);
+
+ if (display_width < (width + x))
+ c_width = display_width - x;
+ else
+ c_width = width;
+ if (display_height < (height + y))
+ c_height = display_height - y;
+ else
+ c_height = height;
+
+ lw = (((width + 7) / 8) + 3) & ~0x3;
+
+ if (c_height < height)
+ dataptr = dataptr + lw * (height - c_height);
+ switch (bpp) {
+ case 1:
+ vcxk_draw_mono(dataptr, lw, c_width, c_height);
+ break;
+ default:
+ printf("Error: %ld bit per pixel "
+ "not supported by VCxK\n",bpp);
+ return 0;
+ }
+ } else {
+ printf("Error: no valid bmp at %lx\n", (ulong) bmp);
+ return 0;
+ }
+ return 1;
+}
+
+/*
+ ****f* bus_vcxk/video_display_bitmap
+ ***
+ */
+
+int video_display_bitmap (ulong addr, int x, int y)
+{
+ vcxk_acknowledge_wait();
+ if (vcxk_display_bitmap (addr, x, y)) {
+ vcxk_request();
+ return 0;
+ }
+ return 1;
+}
+
+/* EOF */
diff --git a/include/bus_vcxk.h b/include/bus_vcxk.h
new file mode 100644
index 0000000..8d6a25c
--- /dev/null
+++ b/include/bus_vcxk.h
@@ -0,0 +1,36 @@
+/*
+ * (C) Copyright 2005-2009
+ * Jens Scharsig @ BuS Elektronik GmbH & Co. KG, <esw@bus-elektronik.de>
+ *
+ * See file CREDITS for list of people who contributed to this
+ * project.
+ *
+ * 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 __BUS_VCXK_H_
+#define __BUS_VCXK_H_
+
+extern int vcxk_init(unsigned long width, unsigned long height);
+extern void vcxk_setpixel (int x, int y, unsigned long color);
+extern int vcxk_acknowledge_wait(void);
+extern int vcxk_request(void);
+extern void vcxk_loadimage(ulong source);
+extern int vcxk_display_bitmap (ulong addr, int x, int y);
+extern void vcxk_setbrightness(unsigned int side, short brightness);
+extern int video_display_bitmap (ulong addr, int x, int y);
+
+#endif
^ permalink raw reply related [flat|nested] 12+ messages in thread
* [U-Boot] [PATCH 1/2 V2] new video driver for bus vcxk framebuffers
2009-07-23 19:40 ` Wolfgang Denk
@ 2009-07-24 8:09 ` Jens Scharsig
0 siblings, 0 replies; 12+ messages in thread
From: Jens Scharsig @ 2009-07-24 8:09 UTC (permalink / raw)
To: u-boot
Wolfgang Denk schrieb:
> Incorrect brace style.
> ...
>
> Quoting the CodingStyle:
>
> Now, some people will claim that having 8-character
> indentations makes the code move too far to the right, and
> makes it hard to read on a 80-character terminal screen. The
> answer to that is that if you need more than 3 levels of
> indentation, you're screwed anyway, and should fix your
> program.
>
> Please clean up and resubmit.
Fixed
Please see [PATCH 1/2 V3] new video driver for bus vcxk framebuffers
Best regards,
Jens Scharsig
^ permalink raw reply [flat|nested] 12+ messages in thread
* [U-Boot] [PATCH 1/2 V3] new video driver for bus vcxk framebuffers
2009-07-24 8:09 ` [U-Boot] [PATCH 1/2 V3] " Jens Scharsig
@ 2009-07-26 11:46 ` Anatolij Gustschin
2009-07-27 3:06 ` [U-Boot] [PATCH 1/2 V3] new video driver for bus vcxkframebuffers Robin Getz
0 siblings, 1 reply; 12+ messages in thread
From: Anatolij Gustschin @ 2009-07-26 11:46 UTC (permalink / raw)
To: u-boot
Jens Scharsig wrote:
> This patch adds a new video driver
>
> * adds common bus_vcxk framebuffer driver
>
> Signed-off-by: Jens Scharsig <esw@bus-elektronik.de>
Applied to u-boot-video. Thanks! Note that I had to fix lots
of style issues before applying. Next time please use
scripts/checkpatch.pl from the Linux source tree to
check your patches before submitting them and resolve
reported issues were it makes sence. Thanks.
Best regards,
Anatolij
^ permalink raw reply [flat|nested] 12+ messages in thread
* [U-Boot] [PATCH 1/2 V3] new video driver for bus vcxkframebuffers
2009-07-26 11:46 ` Anatolij Gustschin
@ 2009-07-27 3:06 ` Robin Getz
2009-07-27 7:49 ` Anatolij Gustschin
2009-08-09 20:46 ` Wolfgang Denk
0 siblings, 2 replies; 12+ messages in thread
From: Robin Getz @ 2009-07-27 3:06 UTC (permalink / raw)
To: u-boot
On Sun 26 Jul 2009 07:46, Anatolij Gustschin pondered:
> Jens Scharsig wrote:
> > This patch adds a new video driver
> >
> > * adds common bus_vcxk framebuffer driver
> >
> > Signed-off-by: Jens Scharsig <esw@bus-elektronik.de>
>
> Applied to u-boot-video. Thanks! Note that I had to fix lots
> of style issues before applying. Next time please use
> scripts/checkpatch.pl from the Linux source tree to
> check your patches before submitting them and resolve
> reported issues were it makes sence. Thanks.
Is there a reason not to include the checkpatch.pl in
http://www.denx.de/wiki/U-Boot/Patches or in the README (in the Submitting
Patches section) if it is going to be a requirement?
^ permalink raw reply [flat|nested] 12+ messages in thread
* [U-Boot] [PATCH 1/2 V3] new video driver for bus vcxkframebuffers
2009-07-27 3:06 ` [U-Boot] [PATCH 1/2 V3] new video driver for bus vcxkframebuffers Robin Getz
@ 2009-07-27 7:49 ` Anatolij Gustschin
2009-08-09 20:46 ` Wolfgang Denk
1 sibling, 0 replies; 12+ messages in thread
From: Anatolij Gustschin @ 2009-07-27 7:49 UTC (permalink / raw)
To: u-boot
Robin Getz wrote:
> On Sun 26 Jul 2009 07:46, Anatolij Gustschin pondered:
...
>> Applied to u-boot-video. Thanks! Note that I had to fix lots
>> of style issues before applying. Next time please use
>> scripts/checkpatch.pl from the Linux source tree to
>> check your patches before submitting them and resolve
>> reported issues were it makes sence. Thanks.
>
> Is there a reason not to include the checkpatch.pl in
> http://www.denx.de/wiki/U-Boot/Patches or in the README (in the Submitting
> Patches section) if it is going to be a requirement?
It is not a requirement, but would make submitter's and our
life easier. Some errors/warnings reported by checkpatch.pl
might cause additional confusion as they apply only for
Linux patches. In this case I suggested to use checkpatch
because v3 of the patch still had style issues pointed out
in the comments to the first version.
Best regards,
Anatolij
^ permalink raw reply [flat|nested] 12+ messages in thread
* [U-Boot] [PATCH 1/2 V3] new video driver for bus vcxkframebuffers
2009-07-27 3:06 ` [U-Boot] [PATCH 1/2 V3] new video driver for bus vcxkframebuffers Robin Getz
2009-07-27 7:49 ` Anatolij Gustschin
@ 2009-08-09 20:46 ` Wolfgang Denk
1 sibling, 0 replies; 12+ messages in thread
From: Wolfgang Denk @ 2009-08-09 20:46 UTC (permalink / raw)
To: u-boot
Dear Robin Getz,
In message <200907262306.19962.rgetz@blackfin.uclinux.org> you wrote:
>
> Is there a reason not to include the checkpatch.pl in
> http://www.denx.de/wiki/U-Boot/Patches or in the README (in the Submitting
> Patches section) if it is going to be a requirement?
No, there is not (except lack of idle resources, maybe). Please feel
free to add it.
Best regards,
Wolfgang Denk
--
DENX Software Engineering GmbH, MD: Wolfgang Denk & Detlev Zundel
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: (+49)-8142-66989-10 Fax: (+49)-8142-66989-80 Email: wd at denx.de
Be kind to unkind people - they need it the most.
^ permalink raw reply [flat|nested] 12+ messages in thread
end of thread, other threads:[~2009-08-09 20:46 UTC | newest]
Thread overview: 12+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2009-04-22 14:36 [U-Boot] [PATCH 1/2] new video driver for bus vcxk framebuffers Jens Scharsig
2009-07-17 22:16 ` Wolfgang Denk
2009-07-18 16:54 ` Anatolij Gustschin
2009-07-20 6:45 ` Jens Scharsig
2009-07-21 11:08 ` [U-Boot] [PATCH 1/2 V2] " Jens Scharsig
2009-07-23 19:40 ` Wolfgang Denk
2009-07-24 8:09 ` Jens Scharsig
2009-07-24 8:09 ` [U-Boot] [PATCH 1/2 V3] " Jens Scharsig
2009-07-26 11:46 ` Anatolij Gustschin
2009-07-27 3:06 ` [U-Boot] [PATCH 1/2 V3] new video driver for bus vcxkframebuffers Robin Getz
2009-07-27 7:49 ` Anatolij Gustschin
2009-08-09 20:46 ` Wolfgang Denk
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox