Re: [PATCH 4/6] add fb support for rpi bsp

2015-08-24 Thread Pavel Pisa
Hello Giao, Joel and Gedare,

there are more technical problems to discuss.
But I start with question if RPi video support
should be unconditional. I am not sure if VideoCore
activation has some consequences to ARM system throughput
but at least it slows down startup.

So there can be resons to disable video initialization.
We have two options now

  --video=WxH
  --console=fbdev

If --video is not specified then VideoCore is initialized
and best fitting mode for monitor is selected. That is great,
but I suggest two more valid options for --video option.
The value off should disable graphics even if monitor
is connected. The option auto should behave as it behaves now.
The default behavior then can be changed to even to not
start video automatically but only when --video option is present.
This is behavior of pc386 BSP for now. But default behavior with
graphic enabled if monitor is connected is more appropriate
for RPi. But disable option even in case of problem localization
is important.

The default console output to serial line is right according
to me.

The critical part is memory setup which has still some
problems to solve. Comments inlined.


On Thursday 13 of August 2015 00:08:03 YANG QIAO wrote:
 From: YANG Qiao yangqiao0...@me.com

 ---
  c/src/lib/libbsp/arm/raspberrypi/Makefile.am   |   5 +-
  c/src/lib/libbsp/arm/raspberrypi/console/fb.c  | 331
 + c/src/lib/libbsp/arm/raspberrypi/include/bsp.h | 
  2 +
  .../arm/raspberrypi/startup/bspgetworkarea.c   |  61 
  c/src/lib/libbsp/arm/raspberrypi/startup/linkcmds  |   5 +-
  c/src/lib/libbsp/arm/raspberrypi/startup/mminit.c  |  42 +++
  6 files changed, 442 insertions(+), 4 deletions(-)
  create mode 100644 c/src/lib/libbsp/arm/raspberrypi/console/fb.c
  create mode 100644
 c/src/lib/libbsp/arm/raspberrypi/startup/bspgetworkarea.c create mode
 100644 c/src/lib/libbsp/arm/raspberrypi/startup/mminit.c

 diff --git a/c/src/lib/libbsp/arm/raspberrypi/Makefile.am
 b/c/src/lib/libbsp/arm/raspberrypi/Makefile.am index e0b4806..b4853a6
 100644
 --- a/c/src/lib/libbsp/arm/raspberrypi/Makefile.am
 +++ b/c/src/lib/libbsp/arm/raspberrypi/Makefile.am
 @@ -79,7 +79,6 @@ libbsp_a_LIBADD =
  # Shared
  libbsp_a_SOURCES += ../../shared/bootcard.c
  libbsp_a_SOURCES += ../../shared/bspclean.c
 -libbsp_a_SOURCES += ../../shared/bspgetworkarea.c
  libbsp_a_SOURCES += ../../shared/bsplibc.c
  libbsp_a_SOURCES += ../../shared/bsppost.c
  libbsp_a_SOURCES += ../../shared/bsppredriverhook.c
 @@ -97,6 +96,7 @@ libbsp_a_SOURCES += ../shared/arm-cp15-set-ttb-entries.c
  libbsp_a_SOURCES += ../../shared/bspreset_loop.c
  libbsp_a_SOURCES += startup/bspstart.c
  libbsp_a_SOURCES += startup/cmdline.c
 +libbsp_a_SOURCES += startup/bspgetworkarea.c

  # IRQ
  libbsp_a_SOURCES += ../shared/arm-cp15-set-exception-handler.c
 @@ -115,6 +115,7 @@ libbsp_a_SOURCES += ../../shared/console_select.c
  libbsp_a_SOURCES += ../../shared/console_write.c
  libbsp_a_SOURCES += console/console-config.c
  libbsp_a_SOURCES += console/usart.c
 +libbsp_a_SOURCES += console/fb.c

  # clock
  libbsp_a_SOURCES += clock/clockdrv.c ../../../shared/clockdrv_shell.h
 @@ -147,7 +148,7 @@ libbsp_a_SOURCES += startup/bspstarthooks.c

  # LIBMM
  libbsp_a_SOURCES += startup/mm_config_table.c
 -libbsp_a_SOURCES += ../shared/mminit.c
 +libbsp_a_SOURCES += startup/mminit.c

 
 ###
 # Network#
 diff --git a/c/src/lib/libbsp/arm/raspberrypi/console/fb.c
 b/c/src/lib/libbsp/arm/raspberrypi/console/fb.c new file mode 100644
 index 000..a83d560
 --- /dev/null
 +++ b/c/src/lib/libbsp/arm/raspberrypi/console/fb.c
 @@ -0,0 +1,331 @@
 +/**
 + * @file
 + *
 + * @ingroup raspberrypi
 + *
 + * @brief framebuffer support.
 + */
 +
 +/*
 + * Copyright (c) 2015 Yang Qiao
 + *
 + *  The license and distribution terms for this file may be
 + *  found in the file LICENSE in this distribution or at
 + *
 + *  http://www.rtems.org/license/LICENSE
 + *
 + */
 +
 +#include stdlib.h
 +#include stdio.h
 +#include errno.h
 +#include sys/types.h
 +
 +#include bsp.h
 +#include bsp/raspberrypi.h
 +#include bsp/mailbox.h
 +#include bsp/vc.h
 +
 +#include rtems.h
 +#include rtems/libio.h
 +#include rtems/fb.h
 +#include rtems/framebuffer.h
 +#include rtems/score/atomic.h
 +
 +#define SCREEN_WIDTH 1024
 +#define SCREEN_HEIGHT 768
 +#define BPP 32
 +#define BUFFER_SIZE (SCREEN_WIDTH*SCREEN_HEIGHT*BPP/8)
 +
 +/* flag to limit driver to protect against multiple opens */
 +static Atomic_Flag driver_mutex;
 +
 +/*
 + * screen information for the driver (fb0).
 + */
 +
 +static struct fb_var_screeninfo fb_var_info = {
 +  .xres= SCREEN_WIDTH,
 +  .yres= SCREEN_HEIGHT,
 +  .bits_per_pixel  = BPP
 +};
 +
 +static struct fb_fix_screeninfo fb_fix_info = {
 +  .smem_start  = (void *) NULL,
 +  .smem_len= 0,
 +  .type 

Re: [PATCH 4/6] add fb support for rpi bsp

2015-08-24 Thread Gedare Bloom
On Mon, Aug 24, 2015 at 1:50 PM, Pavel Pisa p...@cmp.felk.cvut.cz wrote:
 Hello Giao, Joel and Gedare,

 there are more technical problems to discuss.
 But I start with question if RPi video support
 should be unconditional. I am not sure if VideoCore
 activation has some consequences to ARM system throughput
 but at least it slows down startup.

 So there can be resons to disable video initialization.
 We have two options now

   --video=WxH
   --console=fbdev

 If --video is not specified then VideoCore is initialized
 and best fitting mode for monitor is selected. That is great,
 but I suggest two more valid options for --video option.
 The value off should disable graphics even if monitor
 is connected. The option auto should behave as it behaves now.
 The default behavior then can be changed to even to not
 start video automatically but only when --video option is present.
 This is behavior of pc386 BSP for now. But default behavior with
 graphic enabled if monitor is connected is more appropriate
 for RPi. But disable option even in case of problem localization
 is important.

Yes that is good.

 The default console output to serial line is right according
 to me.

 The critical part is memory setup which has still some
 problems to solve. Comments inlined.


 On Thursday 13 of August 2015 00:08:03 YANG QIAO wrote:
 From: YANG Qiao yangqiao0...@me.com

 ---
  c/src/lib/libbsp/arm/raspberrypi/Makefile.am   |   5 +-
  c/src/lib/libbsp/arm/raspberrypi/console/fb.c  | 331
 + c/src/lib/libbsp/arm/raspberrypi/include/bsp.h |
  2 +
  .../arm/raspberrypi/startup/bspgetworkarea.c   |  61 
  c/src/lib/libbsp/arm/raspberrypi/startup/linkcmds  |   5 +-
  c/src/lib/libbsp/arm/raspberrypi/startup/mminit.c  |  42 +++
  6 files changed, 442 insertions(+), 4 deletions(-)
  create mode 100644 c/src/lib/libbsp/arm/raspberrypi/console/fb.c
  create mode 100644
 c/src/lib/libbsp/arm/raspberrypi/startup/bspgetworkarea.c create mode
 100644 c/src/lib/libbsp/arm/raspberrypi/startup/mminit.c

 diff --git a/c/src/lib/libbsp/arm/raspberrypi/Makefile.am
 b/c/src/lib/libbsp/arm/raspberrypi/Makefile.am index e0b4806..b4853a6
 100644
 --- a/c/src/lib/libbsp/arm/raspberrypi/Makefile.am
 +++ b/c/src/lib/libbsp/arm/raspberrypi/Makefile.am
 @@ -79,7 +79,6 @@ libbsp_a_LIBADD =
  # Shared
  libbsp_a_SOURCES += ../../shared/bootcard.c
  libbsp_a_SOURCES += ../../shared/bspclean.c
 -libbsp_a_SOURCES += ../../shared/bspgetworkarea.c
  libbsp_a_SOURCES += ../../shared/bsplibc.c
  libbsp_a_SOURCES += ../../shared/bsppost.c
  libbsp_a_SOURCES += ../../shared/bsppredriverhook.c
 @@ -97,6 +96,7 @@ libbsp_a_SOURCES += ../shared/arm-cp15-set-ttb-entries.c
  libbsp_a_SOURCES += ../../shared/bspreset_loop.c
  libbsp_a_SOURCES += startup/bspstart.c
  libbsp_a_SOURCES += startup/cmdline.c
 +libbsp_a_SOURCES += startup/bspgetworkarea.c

  # IRQ
  libbsp_a_SOURCES += ../shared/arm-cp15-set-exception-handler.c
 @@ -115,6 +115,7 @@ libbsp_a_SOURCES += ../../shared/console_select.c
  libbsp_a_SOURCES += ../../shared/console_write.c
  libbsp_a_SOURCES += console/console-config.c
  libbsp_a_SOURCES += console/usart.c
 +libbsp_a_SOURCES += console/fb.c

  # clock
  libbsp_a_SOURCES += clock/clockdrv.c ../../../shared/clockdrv_shell.h
 @@ -147,7 +148,7 @@ libbsp_a_SOURCES += startup/bspstarthooks.c

  # LIBMM
  libbsp_a_SOURCES += startup/mm_config_table.c
 -libbsp_a_SOURCES += ../shared/mminit.c
 +libbsp_a_SOURCES += startup/mminit.c


 ###
 # Network#
 diff --git a/c/src/lib/libbsp/arm/raspberrypi/console/fb.c
 b/c/src/lib/libbsp/arm/raspberrypi/console/fb.c new file mode 100644
 index 000..a83d560
 --- /dev/null
 +++ b/c/src/lib/libbsp/arm/raspberrypi/console/fb.c
 @@ -0,0 +1,331 @@
 +/**
 + * @file
 + *
 + * @ingroup raspberrypi
 + *
 + * @brief framebuffer support.
 + */
 +
 +/*
 + * Copyright (c) 2015 Yang Qiao
 + *
 + *  The license and distribution terms for this file may be
 + *  found in the file LICENSE in this distribution or at
 + *
 + *  http://www.rtems.org/license/LICENSE
 + *
 + */
 +
 +#include stdlib.h
 +#include stdio.h
 +#include errno.h
 +#include sys/types.h
 +
 +#include bsp.h
 +#include bsp/raspberrypi.h
 +#include bsp/mailbox.h
 +#include bsp/vc.h
 +
 +#include rtems.h
 +#include rtems/libio.h
 +#include rtems/fb.h
 +#include rtems/framebuffer.h
 +#include rtems/score/atomic.h
 +
 +#define SCREEN_WIDTH 1024
 +#define SCREEN_HEIGHT 768
 +#define BPP 32
 +#define BUFFER_SIZE (SCREEN_WIDTH*SCREEN_HEIGHT*BPP/8)
 +
 +/* flag to limit driver to protect against multiple opens */
 +static Atomic_Flag driver_mutex;
 +
 +/*
 + * screen information for the driver (fb0).
 + */
 +
 +static struct fb_var_screeninfo fb_var_info = {
 +  .xres= SCREEN_WIDTH,
 +  .yres= SCREEN_HEIGHT,
 +  .bits_per_pixel  = BPP
 +};
 +
 +static struct 

[PATCH 4/6] add fb support for rpi bsp

2015-08-12 Thread YANG QIAO
From: YANG Qiao yangqiao0...@me.com

---
 c/src/lib/libbsp/arm/raspberrypi/Makefile.am   |   5 +-
 c/src/lib/libbsp/arm/raspberrypi/console/fb.c  | 331 +
 c/src/lib/libbsp/arm/raspberrypi/include/bsp.h |   2 +
 .../arm/raspberrypi/startup/bspgetworkarea.c   |  61 
 c/src/lib/libbsp/arm/raspberrypi/startup/linkcmds  |   5 +-
 c/src/lib/libbsp/arm/raspberrypi/startup/mminit.c  |  42 +++
 6 files changed, 442 insertions(+), 4 deletions(-)
 create mode 100644 c/src/lib/libbsp/arm/raspberrypi/console/fb.c
 create mode 100644 c/src/lib/libbsp/arm/raspberrypi/startup/bspgetworkarea.c
 create mode 100644 c/src/lib/libbsp/arm/raspberrypi/startup/mminit.c

diff --git a/c/src/lib/libbsp/arm/raspberrypi/Makefile.am 
b/c/src/lib/libbsp/arm/raspberrypi/Makefile.am
index e0b4806..b4853a6 100644
--- a/c/src/lib/libbsp/arm/raspberrypi/Makefile.am
+++ b/c/src/lib/libbsp/arm/raspberrypi/Makefile.am
@@ -79,7 +79,6 @@ libbsp_a_LIBADD =
 # Shared
 libbsp_a_SOURCES += ../../shared/bootcard.c
 libbsp_a_SOURCES += ../../shared/bspclean.c
-libbsp_a_SOURCES += ../../shared/bspgetworkarea.c
 libbsp_a_SOURCES += ../../shared/bsplibc.c
 libbsp_a_SOURCES += ../../shared/bsppost.c
 libbsp_a_SOURCES += ../../shared/bsppredriverhook.c
@@ -97,6 +96,7 @@ libbsp_a_SOURCES += ../shared/arm-cp15-set-ttb-entries.c
 libbsp_a_SOURCES += ../../shared/bspreset_loop.c
 libbsp_a_SOURCES += startup/bspstart.c
 libbsp_a_SOURCES += startup/cmdline.c
+libbsp_a_SOURCES += startup/bspgetworkarea.c
 
 # IRQ
 libbsp_a_SOURCES += ../shared/arm-cp15-set-exception-handler.c
@@ -115,6 +115,7 @@ libbsp_a_SOURCES += ../../shared/console_select.c
 libbsp_a_SOURCES += ../../shared/console_write.c
 libbsp_a_SOURCES += console/console-config.c
 libbsp_a_SOURCES += console/usart.c
+libbsp_a_SOURCES += console/fb.c
 
 # clock
 libbsp_a_SOURCES += clock/clockdrv.c ../../../shared/clockdrv_shell.h
@@ -147,7 +148,7 @@ libbsp_a_SOURCES += startup/bspstarthooks.c
 
 # LIBMM
 libbsp_a_SOURCES += startup/mm_config_table.c
-libbsp_a_SOURCES += ../shared/mminit.c
+libbsp_a_SOURCES += startup/mminit.c
 
 ###
 # Network#
diff --git a/c/src/lib/libbsp/arm/raspberrypi/console/fb.c 
b/c/src/lib/libbsp/arm/raspberrypi/console/fb.c
new file mode 100644
index 000..a83d560
--- /dev/null
+++ b/c/src/lib/libbsp/arm/raspberrypi/console/fb.c
@@ -0,0 +1,331 @@
+/**
+ * @file
+ *
+ * @ingroup raspberrypi
+ *
+ * @brief framebuffer support.
+ */
+
+/*
+ * Copyright (c) 2015 Yang Qiao
+ *
+ *  The license and distribution terms for this file may be
+ *  found in the file LICENSE in this distribution or at
+ *
+ *  http://www.rtems.org/license/LICENSE
+ *
+ */
+
+#include stdlib.h
+#include stdio.h
+#include errno.h
+#include sys/types.h
+
+#include bsp.h
+#include bsp/raspberrypi.h
+#include bsp/mailbox.h
+#include bsp/vc.h
+
+#include rtems.h
+#include rtems/libio.h
+#include rtems/fb.h
+#include rtems/framebuffer.h
+#include rtems/score/atomic.h
+
+#define SCREEN_WIDTH 1024
+#define SCREEN_HEIGHT 768
+#define BPP 32
+#define BUFFER_SIZE (SCREEN_WIDTH*SCREEN_HEIGHT*BPP/8)
+
+/* flag to limit driver to protect against multiple opens */
+static Atomic_Flag driver_mutex;
+
+/*
+ * screen information for the driver (fb0).
+ */
+
+static struct fb_var_screeninfo fb_var_info = {
+  .xres= SCREEN_WIDTH,
+  .yres= SCREEN_HEIGHT,
+  .bits_per_pixel  = BPP
+};
+
+static struct fb_fix_screeninfo fb_fix_info = {
+  .smem_start  = (void *) NULL,
+  .smem_len= 0,
+  .type= FB_TYPE_PACKED_PIXELS,
+  .visual  = FB_VISUAL_TRUECOLOR,
+  .line_length = 0
+};
+
+int raspberrypi_get_fix_screen_info( struct fb_fix_screeninfo *info )
+{
+  *info = fb_fix_info;
+  return 0;
+}
+
+int raspberrypi_get_var_screen_info( struct fb_var_screeninfo *info )
+{
+  *info = fb_var_info;
+  return 0;
+}
+
+static int
+find_mode_from_cmdline(void)
+{
+  const char* opt;
+  char* endptr;
+  uint32_t width;
+  uint32_t height;
+  uint32_t bpp;
+  opt = rpi_cmdline_arg(--video=);
+  if (opt)
+  {
+  opt += sizeof(--video=)-1;
+  width = strtol(opt, endptr, 10);
+  if (*endptr != 'x')
+  {
+  return -2;
+  }
+  opt = endptr+1;
+  height = strtol(opt, endptr, 10);
+  switch (*endptr)
+  {
+  case '-':
+  opt = endptr+1;
+  if (strlen(opt) = 2)
+  bpp = strtol(opt, endptr, 10);
+  else
+  {
+  bpp = strtol(opt, endptr, 10);
+  if (*endptr != ' ')
+  {
+  return -4;
+  }
+  }
+  case ' ':
+  case 0:
+  break;
+  default:
+  return -3;
+  }
+  }
+  else
+return -1;
+
+  fb_var_info.xres= width;
+  fb_var_info.yres