[PATCH 2/6] add vc support for rpi bsp

YANG QIAO yangqiao0505 at me.com
Wed Aug 12 22:08:01 UTC 2015


From: YANG Qiao <yangqiao0505 at me.com>

---
 c/src/lib/libbsp/arm/raspberrypi/Makefile.am       |   4 +
 c/src/lib/libbsp/arm/raspberrypi/include/vc.h      | 140 +++++++
 c/src/lib/libbsp/arm/raspberrypi/misc/vc.c         | 248 ++++++++++++
 c/src/lib/libbsp/arm/raspberrypi/misc/vc_defines.h | 436 +++++++++++++++++++++
 c/src/lib/libbsp/arm/raspberrypi/preinstall.am     |   4 +
 5 files changed, 832 insertions(+)
 create mode 100644 c/src/lib/libbsp/arm/raspberrypi/include/vc.h
 create mode 100644 c/src/lib/libbsp/arm/raspberrypi/misc/vc.c
 create mode 100644 c/src/lib/libbsp/arm/raspberrypi/misc/vc_defines.h

diff --git a/c/src/lib/libbsp/arm/raspberrypi/Makefile.am b/c/src/lib/libbsp/arm/raspberrypi/Makefile.am
index e1398bb..3593e60 100644
--- a/c/src/lib/libbsp/arm/raspberrypi/Makefile.am
+++ b/c/src/lib/libbsp/arm/raspberrypi/Makefile.am
@@ -46,6 +46,7 @@ include_bsp_HEADERS += include/usart.h
 include_bsp_HEADERS += include/raspberrypi.h
 include_bsp_HEADERS += include/rpi-gpio.h
 include_bsp_HEADERS += include/mailbox.h
+include_bsp_HEADERS += include/vc.h
 
 include_libcpu_HEADERS = ../../../libcpu/arm/shared/include/cache_.h \
     ../../../libcpu/arm/shared/include/arm-cp15.h
@@ -132,6 +133,9 @@ libbsp_a_SOURCES += gpio/rpi-gpio.c
 # Mailbox
 libbsp_a_SOURCES += misc/mailbox.c
 
+# VideoCore
+libbsp_a_SOURCES += misc/vc.c
+
 # Cache
 libbsp_a_SOURCES += ../../../libcpu/shared/src/cache_manager.c
 libbsp_a_SOURCES += ../../../libcpu/arm/shared/include/cache_.h
diff --git a/c/src/lib/libbsp/arm/raspberrypi/include/vc.h b/c/src/lib/libbsp/arm/raspberrypi/include/vc.h
new file mode 100644
index 0000000..4e91fde
--- /dev/null
+++ b/c/src/lib/libbsp/arm/raspberrypi/include/vc.h
@@ -0,0 +1,140 @@
+/**
+ * @file
+ *
+ * @ingroup raspberrypi_vc
+ *
+ * @brief video core 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
+ *
+ */
+
+#ifndef LIBBSP_ARM_RASPBERRYPI_VC_H
+#define LIBBSP_ARM_RASPBERRYPI_VC_H
+
+/**
+ * @defgroup raspberrypi_vc Register Definitions
+ *
+ * @ingroup arm_raspberrypi
+ *
+ * @brief Register Definitions
+ *
+ * @{
+ */
+
+typedef struct
+{
+  uint32_t width;
+  uint32_t height;
+} bcm2835_get_display_size_entries;
+
+int
+bcm2835_mailbox_get_display_size(bcm2835_get_display_size_entries* _entries);
+
+
+typedef enum
+{
+  bcm2835_mailbox_pixel_order_bgr = 0,
+  bcm2835_mailbox_pixel_order_rgb = 1
+} bcm2835_pixel_order;
+
+typedef enum
+{
+  bcm2835_mailbox_alpha_mode_0_opaque       = 0,
+  bcm2835_mailbox_alpha_mode_0_transparent  = 1,
+  bcm2835_mailbox_alpha_mode_ignored        = 2
+} bcm2835_alpha_mode;
+
+typedef struct
+{
+  uint32_t xres;
+  uint32_t yres;
+  uint32_t xvirt;
+  uint32_t yvirt;
+  uint32_t depth;
+  bcm2835_pixel_order pixel_order;
+  bcm2835_alpha_mode alpha_mode;
+  uint32_t voffset_x;
+  uint32_t voffset_y;
+  uint32_t overscan_left;
+  uint32_t overscan_right;
+  uint32_t overscan_top;
+  uint32_t overscan_bottom;
+  uint32_t base;
+  size_t size;
+  uint32_t pitch;
+} bcm2835_init_frame_buffer_entries;
+
+int
+bcm2835_mailbox_init_frame_buffer(bcm2835_init_frame_buffer_entries* _entries);
+
+typedef struct
+{
+  uint32_t pitch;
+}bcm2835_get_pitch_entries;
+
+int
+bcm2835_mailbox_get_pitch(bcm2835_get_pitch_entries* _entries);
+
+typedef struct
+{
+  char cmdline[1024];
+} bcm2835_get_cmdline_entries;
+
+int
+bcm2835_mailbox_get_cmdline(bcm2835_get_cmdline_entries* _entries);
+
+typedef enum
+{
+  bcm2835_mailbox_power_udid_sd_card = 0x00000000u,
+  bcm2835_mailbox_power_udid_uart0 = 0x00000001u,
+  bcm2835_mailbox_power_udid_uart1 = 0x00000002u,
+  bcm2835_mailbox_power_udid_usb_hcd = 0x00000003u,
+  bcm2835_mailbox_power_udid_i2c0 = 0x00000004u,
+  bcm2835_mailbox_power_udid_i2c1 = 0x00000005u,
+  bcm2835_mailbox_power_udid_i2c2 = 0x00000006u,
+  bcm2835_mailbox_power_udid_spi = 0x00000007u,
+  bcm2835_mailbox_power_udid_ccp2tx = 0x00000008u,
+} bcm2835_power_device_id;
+
+typedef struct
+{
+  bcm2835_power_device_id dev_id;
+  uint32_t state;
+} bcm2835_set_power_state_entries;
+
+#define BCM2835_MAILBOX_SET_POWER_STATE_REQ_ON    (1 << 0)
+#define BCM2835_MAILBOX_SET_POWER_STATE_REQ_WAIT  (1 << 1)
+#define BCM2835_MAILBOX_POWER_STATE_ON       (1 << 0)
+#define BCM2835_MAILBOX_POWER_STATE_NODEV    (1 << 1)
+int
+bcm2835_mailbox_set_power_state(bcm2835_set_power_state_entries* _entries);
+
+typedef struct
+{
+  uint32_t base;
+  size_t   size;
+}bcm2835_get_arm_memory_entries;
+
+int
+bcm2835_mailbox_get_arm_memory(bcm2835_get_arm_memory_entries* _entries);
+
+typedef struct
+{
+  uint32_t base;
+  size_t   size;
+}bcm2835_get_vc_memory_entries;
+
+int
+bcm2835_mailbox_get_vc_memory(bcm2835_get_vc_memory_entries* _entries);
+/** @} */
+
+#endif /* LIBBSP_ARM_RASPBERRYPI_VC_H */
diff --git a/c/src/lib/libbsp/arm/raspberrypi/misc/vc.c b/c/src/lib/libbsp/arm/raspberrypi/misc/vc.c
new file mode 100644
index 0000000..d1d08ba
--- /dev/null
+++ b/c/src/lib/libbsp/arm/raspberrypi/misc/vc.c
@@ -0,0 +1,248 @@
+/**
+ * @file
+ *
+ * @ingroup raspberrypi_vc
+ *
+ * @brief video core 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 <pthread.h>
+
+#include <bsp.h>
+#include <bsp/raspberrypi.h>
+#include <bsp/mailbox.h>
+#include <bsp/vc.h>
+#include "vc_defines.h"
+
+#if (RPI_L2_CACHE_ENABLE == 1)
+  #define BCM2835_VC_MEMORY_MAPPING 0x40000000
+#else
+  #define BCM2835_VC_MEMORY_MAPPING 0xC0000000
+#endif
+
+static inline bool
+bcm2835_mailbox_buffer_suceeded(const bcm2835_mbox_buf_hdr *hdr)
+{
+  return (hdr->buf_code == BCM2835_MBOX_BUF_CODE_REQUEST_SUCCEED);
+}
+
+static inline int
+bcm2835_mailbox_send_read_buffer(void *buf)
+{
+  raspberrypi_mailbox_write(BCM2835_MBOX_CHANNEL_PROP_AVC,
+    buf+BCM2835_VC_MEMORY_MAPPING);
+  raspberrypi_mailbox_read(BCM2835_MBOX_CHANNEL_PROP_AVC);
+  return 0;
+}
+
+#define BCM2835_MBOX_VAL_LENGTH_MASK(_val_len) \
+  (_val_len&(~BCM2835_MBOX_TAG_VAL_LEN_RESPONSE))
+
+int
+bcm2835_mailbox_get_display_size(bcm2835_get_display_size_entries *_entries)
+{
+  struct {
+    bcm2835_mbox_buf_hdr hdr;
+    bcm2835_mbox_tag_display_size get_display_size;
+    uint32_t end_tag
+  }buffer __attribute__((aligned (16)));
+  BCM2835_MBOX_INIT_BUF(&buffer);
+  BCM2835_MBOX_INIT_TAG_NO_REQ(&buffer.get_display_size,
+    BCM2835_MAILBOX_TAG_GET_DISPLAY_SIZE);
+  if (bcm2835_mailbox_send_read_buffer(&buffer))
+    return -1;
+  _entries->width = buffer.get_display_size.body.resp.width;
+  _entries->height = buffer.get_display_size.body.resp.height;
+  if( !bcm2835_mailbox_buffer_suceeded(&buffer.hdr) )
+    return -2;
+  return 0;
+}
+
+int
+bcm2835_mailbox_init_frame_buffer(bcm2835_init_frame_buffer_entries* _entries)
+{
+  struct {
+    bcm2835_mbox_buf_hdr hdr;
+    bcm2835_mbox_tag_display_size set_display_size;
+    bcm2835_mbox_tag_virtual_size set_virtual_size;
+    bcm2835_mbox_tag_depth set_depth;
+    bcm2835_mbox_tag_pixel_order set_pixel_order;
+    bcm2835_mbox_tag_alpha_mode set_alpha_mode;
+    bcm2835_mbox_tag_virtual_offset set_virtual_offset;
+    bcm2835_mbox_tag_overscan set_overscan;
+    bcm2835_mbox_tag_allocate_buffer allocate_buffer;
+    bcm2835_mbox_tag_get_pitch get_pitch;
+    uint32_t end_tag;
+  } buffer __attribute__((aligned (16)));
+  BCM2835_MBOX_INIT_BUF(&buffer);
+  BCM2835_MBOX_INIT_TAG(&buffer.set_display_size,
+    BCM2835_MAILBOX_TAG_SET_DISPLAY_SIZE);
+  buffer.set_display_size.body.req.width = _entries->xres;
+  buffer.set_display_size.body.req.height = _entries->yres;
+  BCM2835_MBOX_INIT_TAG(&buffer.set_virtual_size,
+    BCM2835_MAILBOX_TAG_SET_VIRTUAL_SIZE);
+  buffer.set_virtual_size.body.req.vwidth = _entries->xvirt;
+  buffer.set_virtual_size.body.req.vheight = _entries->yvirt;
+  BCM2835_MBOX_INIT_TAG(&buffer.set_depth,
+    BCM2835_MAILBOX_TAG_SET_DEPTH);
+  buffer.set_depth.body.req.depth = _entries->depth;
+  BCM2835_MBOX_INIT_TAG(&buffer.set_pixel_order,
+    BCM2835_MAILBOX_TAG_SET_PIXEL_ORDER);
+  buffer.set_pixel_order.body.req.pixel_order = _entries->pixel_order;
+  BCM2835_MBOX_INIT_TAG(&buffer.set_alpha_mode,
+    BCM2835_MAILBOX_TAG_SET_ALPHA_MODE);
+  buffer.set_alpha_mode.body.req.alpha_mode = _entries->alpha_mode;
+  BCM2835_MBOX_INIT_TAG(&buffer.set_virtual_offset,
+    BCM2835_MAILBOX_TAG_SET_VIRTUAL_OFFSET);
+  buffer.set_virtual_offset.body.req.voffset_x = _entries->voffset_x;
+  buffer.set_virtual_offset.body.req.voffset_x = _entries->voffset_y;
+  BCM2835_MBOX_INIT_TAG(&buffer.set_overscan,
+    BCM2835_MAILBOX_TAG_SET_OVERSCAN);
+  buffer.set_overscan.body.req.overscan_top = _entries->overscan_top;
+  buffer.set_overscan.body.req.overscan_bottom = _entries->overscan_bottom;
+  buffer.set_overscan.body.req.overscan_left = _entries->overscan_left;
+  buffer.set_overscan.body.req.overscan_right = _entries->overscan_right;
+  BCM2835_MBOX_INIT_TAG(&buffer.allocate_buffer,
+    BCM2835_MAILBOX_TAG_ALLOCATE_BUFFER);
+  buffer.allocate_buffer.body.req.align = 0x100;
+  BCM2835_MBOX_INIT_TAG_NO_REQ(&buffer.get_pitch,
+    BCM2835_MAILBOX_TAG_GET_PITCH);
+  if (bcm2835_mailbox_send_read_buffer(&buffer))
+    return -1;
+  _entries->xres = buffer.set_display_size.body.resp.width;
+  _entries->yres = buffer.set_display_size.body.resp.height;
+  _entries->xvirt = buffer.set_virtual_size.body.resp.vwidth;
+  _entries->yvirt = buffer.set_virtual_size.body.resp.vheight;
+  _entries->depth = buffer.set_depth.body.resp.depth;
+  _entries->base = buffer.allocate_buffer.body.resp.base
+                    - BCM2835_VC_MEMORY_MAPPING;
+  _entries->size = buffer.allocate_buffer.body.resp.size;
+  _entries->pixel_order = buffer.set_pixel_order.body.resp.pixel_order;
+  _entries->alpha_mode = buffer.set_alpha_mode.body.resp.alpha_mode;
+  _entries->voffset_x = buffer.set_virtual_offset.body.resp.voffset_x;
+  _entries->voffset_y = buffer.set_virtual_offset.body.resp.voffset_y;
+  _entries->overscan_left = buffer.set_overscan.body.resp.overscan_left;
+  _entries->overscan_right = buffer.set_overscan.body.resp.overscan_right;
+  _entries->overscan_top = buffer.set_overscan.body.resp.overscan_top;
+  _entries->overscan_bottom = buffer.set_overscan.body.resp.overscan_bottom;
+  if( !bcm2835_mailbox_buffer_suceeded(&buffer.hdr) )
+    return -2;
+  return 0;
+}
+
+int
+bcm2835_mailbox_get_pitch(bcm2835_get_pitch_entries* _entries)
+{
+  struct {
+    bcm2835_mbox_buf_hdr hdr;
+    bcm2835_mbox_tag_get_pitch get_pitch;
+    uint32_t end_tag
+  }buffer __attribute__((aligned (16)));
+  BCM2835_MBOX_INIT_BUF(&buffer);
+  BCM2835_MBOX_INIT_TAG_NO_REQ(&buffer.get_pitch,
+    BCM2835_MAILBOX_TAG_GET_PITCH);
+  if (bcm2835_mailbox_send_read_buffer(&buffer))
+    return -1;
+  _entries->pitch = buffer.get_pitch.body.resp.pitch;
+  if( !bcm2835_mailbox_buffer_suceeded(&buffer.hdr) )
+    return -2;
+  return 0;
+}
+
+int
+bcm2835_mailbox_get_cmdline(bcm2835_get_cmdline_entries* _entries)
+{
+  int i;
+  struct {
+    bcm2835_mbox_buf_hdr hdr;
+    bcm2835_mbox_tag_get_cmd_line get_cmd_line;
+    uint32_t end_tag
+  }buffer __attribute__((aligned (16)));
+  BCM2835_MBOX_INIT_BUF(&buffer);
+  BCM2835_MBOX_INIT_TAG_NO_REQ(&buffer.get_cmd_line,
+    BCM2835_MAILBOX_TAG_GET_CMD_LINE);
+  if (bcm2835_mailbox_send_read_buffer(&buffer))
+    return -1;
+  for (i = 0;
+        i < BCM2835_MBOX_VAL_LENGTH_MASK(buffer.get_cmd_line.tag_hdr.val_len);
+        ++i)
+  {
+    _entries->cmdline[i] = buffer.get_cmd_line.body.resp.cmdline[i];
+  }
+  _entries->cmdline[i] = '\0';
+  if( !bcm2835_mailbox_buffer_suceeded(&buffer.hdr) )
+    return -2;
+  return 0;
+}
+
+int
+bcm2835_mailbox_set_power_state(bcm2835_set_power_state_entries *_entries)
+{
+  struct {
+    bcm2835_mbox_buf_hdr hdr;
+    bcm2835_mbox_tag_power_state set_power_state;
+    uint32_t end_tag
+  }buffer __attribute__((aligned (16)));
+  BCM2835_MBOX_INIT_BUF(&buffer);
+  BCM2835_MBOX_INIT_TAG(&buffer.set_power_state,
+    BCM2835_MAILBOX_TAG_SET_POWER_STATE);
+  buffer.set_power_state.body.req.dev_id = _entries->dev_id;
+  buffer.set_power_state.body.req.state = _entries->state;
+  if (bcm2835_mailbox_send_read_buffer(&buffer))
+    return -1;
+  _entries->dev_id = buffer.set_power_state.body.resp.dev_id;
+  _entries->state  = buffer.set_power_state.body.resp.state;
+  if( !bcm2835_mailbox_buffer_suceeded(&buffer.hdr) )
+    return -2;
+  return 0;
+}
+
+int
+bcm2835_mailbox_get_arm_memory(bcm2835_get_arm_memory_entries* _entries)
+{
+  struct {
+    bcm2835_mbox_buf_hdr hdr;
+    bcm2835_mbox_tag_get_arm_memory get_arm_memory;
+    uint32_t end_tag
+  }buffer __attribute__((aligned (16)));
+  BCM2835_MBOX_INIT_BUF(&buffer);
+  BCM2835_MBOX_INIT_TAG_NO_REQ(&buffer.get_arm_memory,
+    BCM2835_MAILBOX_TAG_GET_ARM_MEMORY);
+  if (bcm2835_mailbox_send_read_buffer(&buffer))
+    return -1;
+  _entries->base = buffer.get_arm_memory.body.resp.base;
+  _entries->size = buffer.get_arm_memory.body.resp.size;
+  if( !bcm2835_mailbox_buffer_suceeded(&buffer.hdr) )
+    return -2;
+  return 0;
+}
+
+int
+bcm2835_mailbox_get_vc_memory(bcm2835_get_vc_memory_entries* _entries)
+{
+  struct {
+    bcm2835_mbox_buf_hdr hdr;
+    bcm2835_mbox_tag_get_vc_memory get_vc_memory;
+    uint32_t end_tag
+  }buffer __attribute__((aligned (16)));
+  BCM2835_MBOX_INIT_BUF(&buffer);
+  BCM2835_MBOX_INIT_TAG_NO_REQ(&buffer.get_vc_memory,
+    BCM2835_MAILBOX_TAG_GET_VC_MEMORY);
+  if (bcm2835_mailbox_send_read_buffer(&buffer))
+    return -1;
+  _entries->base = buffer.get_vc_memory.body.resp.base;
+  _entries->size = buffer.get_vc_memory.body.resp.size;
+  if( !bcm2835_mailbox_buffer_suceeded(&buffer.hdr) )
+    return -2;
+  return 0;
+}
diff --git a/c/src/lib/libbsp/arm/raspberrypi/misc/vc_defines.h b/c/src/lib/libbsp/arm/raspberrypi/misc/vc_defines.h
new file mode 100644
index 0000000..ec387c0
--- /dev/null
+++ b/c/src/lib/libbsp/arm/raspberrypi/misc/vc_defines.h
@@ -0,0 +1,436 @@
+/**
+ * @file
+ *
+ * @ingroup raspberrypi_vc
+ *
+ * @brief video core 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
+ *
+ */
+
+#ifndef LIBBSP_ARM_RASPBERRYPI_VC_DEFINES_H
+#define LIBBSP_ARM_RASPBERRYPI_VC_DEFINES_H
+
+/**
+ * @defgroup raspberrypi_vc Register Definitions
+ *
+ * @ingroup arm_raspberrypi
+ *
+ * @brief Register Definitions
+ *
+ * @{
+ */
+
+ /**
+ * @name Mailbox Property tags (ARM <-> VC)
+ *
+ * @{
+ */
+
+#define BCM2835_MBOX_BUF_CODE_PROCESS_REQUEST         0x00000000
+#define BCM2835_MBOX_BUF_CODE_REQUEST_SUCCEED         0x80000000
+#define BCM2835_MBOX_BUF_CODE_REQUEST_PARSING_ERROR   0x80000001
+#define BCM2835_MBOX_TAG_VAL_LEN_REQUEST              0x00000000
+#define BCM2835_MBOX_TAG_VAL_LEN_RESPONSE             0x80000000
+
+/**
+ * @brief Buffer Header
+ *
+ * All message buffers should start with this header, called 'hdr'.
+ * Then it should be followed by a list of tags.
+ * An additional empty tag should be added at the end, called 'end_tag'
+ *
+ */
+typedef struct {
+
+  /**
+   * @brief Buffer Size
+   *
+   * The size of whole structure including the header(size and code),
+   *   tags, end tag and padding.
+   */
+  uint32_t buf_size;
+
+  /**
+   * @brief Buffer Code
+   *
+   * The code indicate the status of operation.
+   * Use function BCM2835_MAILBOX_BUFFER_IS_SUCCEED(bcm2835_mailbox_buffer*)
+   * to check if the operation is succeed
+   */
+  uint32_t buf_code;
+} bcm2835_mbox_buf_hdr;
+
+
+/**
+ * @brief Tag Header
+ *
+ * Tag is used for getting/testing/setting an property.
+ * All tags should start with this header.
+ * Then it should be followed by a data buffer for request and response.
+ *
+ */
+typedef struct {
+  /**
+   * @brief Property Tag ID
+   */
+  uint32_t tag;
+  /**
+   * @brief The size of request qnd responce buffer
+   */
+  uint32_t val_buf_size;
+  /**
+   * @brief The size of response buffer set by videocore.
+   *
+   * upper bit reserved for request/response indicator
+   */
+  uint32_t val_len;
+} bcm2835_mbox_tag_hdr;
+
+#define BCM2835_MBOX_INIT_BUF(_m_) { \
+    memset((_m_), 0, sizeof(*(_m_))); \
+    (_m_)->hdr.buf_size = sizeof(*(_m_)); \
+    (_m_)->hdr.buf_code = BCM2835_MBOX_BUF_CODE_PROCESS_REQUEST; \
+    (_m_)->end_tag = 0; \
+  }
+
+#define BCM2835_MBOX_INIT_TAG(_t_, _id_) { \
+    (_t_)->tag_hdr.tag = _id_; \
+    (_t_)->tag_hdr.val_buf_size = sizeof((_t_)->body); \
+    (_t_)->tag_hdr.val_len = sizeof((_t_)->body.req); \
+  }
+
+#define BCM2835_MBOX_INIT_TAG_NO_REQ(_t_, _id_) { \
+    (_t_)->tag_hdr.tag = _id_; \
+    (_t_)->tag_hdr.val_buf_size = sizeof((_t_)->body); \
+    (_t_)->tag_hdr.val_len = 0; \
+  }
+
+/* Video Core */
+#define BCM2835_MAILBOX_TAG_FIRMWARE_REVISION   0x00000001
+
+/* Hardware */
+#define BCM2835_MAILBOX_TAG_GET_BOARD_MODEL     0x00010001
+#define BCM2835_MAILBOX_TAG_GET_BOARD_VERSION   0x00010002
+
+#if (BSP_IS_RPI2 == 1)
+#define BCM2836_MAILBOX_BOARD_V_2_B             0x4
+#else
+#define BCM2835_MAILBOX_BOARD_V_B_I2C0_2        0x2
+#define BCM2835_MAILBOX_BOARD_V_B_I2C0_3        0x3
+#define BCM2835_MAILBOX_BOARD_V_B_I2C1_4        0x4
+#define BCM2835_MAILBOX_BOARD_V_B_I2C1_5        0x5
+#define BCM2835_MAILBOX_BOARD_V_B_I2C1_6        0x6
+#define BCM2835_MAILBOX_BOARD_V_A_7             0x7
+#define BCM2835_MAILBOX_BOARD_V_A_8             0x8
+#define BCM2835_MAILBOX_BOARD_V_A_9             0x9
+#define BCM2835_MAILBOX_BOARD_V_B_REV2_d        0xd
+#define BCM2835_MAILBOX_BOARD_V_B_REV2_e        0xe
+#define BCM2835_MAILBOX_BOARD_V_B_REV2_f        0xf
+#define BCM2835_MAILBOX_BOARD_V_B_PLUS          0x10
+#define BCM2835_MAILBOX_BOARD_V_CM              0x11
+#define BCM2835_MAILBOX_BOARD_V_A_PLUS          0x12
+#endif
+
+#define BCM2835_MAILBOX_TAG_GET_BOARD_MAC       0x00010003
+#define BCM2835_MAILBOX_TAG_GET_BOARD_SERIAL    0x00010004
+#define BCM2835_MAILBOX_TAG_GET_ARM_MEMORY      0x00010005
+typedef struct {
+  bcm2835_mbox_tag_hdr tag_hdr;
+  union {
+    struct {
+    } req;
+    struct {
+      uint32_t base;
+      uint32_t size;
+    } resp;
+  } body;
+} bcm2835_mbox_tag_get_arm_memory;
+
+#define BCM2835_MAILBOX_TAG_GET_VC_MEMORY       0x00010006
+typedef struct {
+  bcm2835_mbox_tag_hdr tag_hdr;
+  union {
+    struct {
+    } req;
+    struct {
+      uint32_t base;
+      uint32_t size;
+    } resp;
+  } body;
+} bcm2835_mbox_tag_get_vc_memory;
+
+#define BCM2835_MAILBOX_TAG_GET_CLOCKS          0x00010007
+
+/* Config */
+#define BCM2835_MAILBOX_TAG_GET_CMD_LINE        0x00050001
+typedef struct {
+  bcm2835_mbox_tag_hdr tag_hdr;
+  union {
+    struct {
+    } req;
+    struct {
+      uint8_t cmdline[1024]
+    } resp;
+  } body;
+} bcm2835_mbox_tag_get_cmd_line;
+
+/* Shared resource management */
+#define BCM2835_MAILBOX_TAG_GET_DMA_CHANNELS    0x00060001
+
+/* Power */
+#define BCM2835_MAILBOX_POWER_UDID_SD_Card           0x00000000
+#define BCM2835_MAILBOX_POWER_UDID_UART0             0x00000001
+#define BCM2835_MAILBOX_POWER_UDID_UART1             0x00000002
+#define BCM2835_MAILBOX_POWER_UDID_USB_HCD           0x00000003
+#define BCM2835_MAILBOX_POWER_UDID_I2C0              0x00000004
+#define BCM2835_MAILBOX_POWER_UDID_I2C1              0x00000005
+#define BCM2835_MAILBOX_POWER_UDID_I2C2              0x00000006
+#define BCM2835_MAILBOX_POWER_UDID_SPI               0x00000007
+#define BCM2835_MAILBOX_POWER_UDID_CCP2TX            0x00000008
+
+#define BCM2835_MAILBOX_TAG_GET_POWER_STATE     0x00020001
+
+#define BCM2835_MAILBOX_POWER_STATE_RESP_ON       (1 << 0)
+#define BCM2835_MAILBOX_POWER_STATE_RESP_NODEV    (1 << 1)
+
+#define BCM2835_MAILBOX_TAG_GET_TIMING          0x00020002
+#define BCM2835_MAILBOX_TAG_SET_POWER_STATE     0x00028001
+typedef struct {
+  bcm2835_mbox_tag_hdr tag_hdr;
+  union {
+    struct {
+      uint32_t dev_id;
+      uint32_t state;
+    } req;
+    struct {
+      uint32_t dev_id;
+      uint32_t state;
+    } resp;
+  } body;
+} bcm2835_mbox_tag_power_state;
+
+#define BCM2835_MAILBOX_SET_POWER_STATE_REQ_ON    (1 << 0)
+#define BCM2835_MAILBOX_SET_POWER_STATE_REQ_WAIT  (1 << 1)
+
+/* Clocks */
+#define BCM2835_MAILBOX_UCID_CLOCK_RESERVED          0x000000000
+#define BCM2835_MAILBOX_UCID_CLOCK_EMMC              0x000000001
+#define BCM2835_MAILBOX_UCID_CLOCK_UART              0x000000002
+#define BCM2835_MAILBOX_UCID_CLOCK_ARM               0x000000003
+#define BCM2835_MAILBOX_UCID_CLOCK_CORE              0x000000004
+#define BCM2835_MAILBOX_UCID_CLOCK_V3D               0x000000005
+#define BCM2835_MAILBOX_UCID_CLOCK_H264              0x000000006
+#define BCM2835_MAILBOX_UCID_CLOCK_ISP               0x000000007
+#define BCM2835_MAILBOX_UCID_CLOCK_SDRAM             0x000000008
+#define BCM2835_MAILBOX_UCID_CLOCK_PIXEL             0x000000009
+#define BCM2835_MAILBOX_UCID_CLOCK_PWM               0x00000000a
+
+#define BCM2835_MAILBOX_TAG_GET_CLOCK_STATE     0x00030001
+#define BCM2835_MAILBOX_TAG_SET_CLOCK_STATE     0x00038001
+#define BCM2835_MAILBOX_TAG_GET_CLOCK_RATE      0x00030002
+#define BCM2835_MAILBOX_TAG_SET_CLOCK_RATE      0x00038002
+#define BCM2835_MAILBOX_TAG_GET_MAX_CLOCK_RATE  0x00030004
+#define BCM2835_MAILBOX_TAG_GET_MIN_CLOCK_RATE  0x00030007
+#define BCM2835_MAILBOX_TAG_GET_TRUBO           0x00030009
+#define BCM2835_MAILBOX_TAG_SET_TURBO           0x00038009
+
+/* Voltage */
+#define BCM2835_MAILBOX_VOLTAGE_RESERVED_UVID        0x000000000
+#define BCM2835_MAILBOX_VOLTAGE_CORE_UVID            0x000000001
+#define BCM2835_MAILBOX_VOLTAGE_SDRAM_C_UVID         0x000000002
+#define BCM2835_MAILBOX_VOLTAGE_SDRAM_P_UVID         0x000000003
+#define BCM2835_MAILBOX_VOLTAGE_SDRAM_I_UVID         0x000000004
+
+#define BCM2835_MAILBOX_TAG_GET_VOLTAGE         0x00030003
+#define BCM2835_MAILBOX_TAG_SET_VOLTAGE         0x00038003
+#define BCM2835_MAILBOX_TAG_GET_MAX_VOLTAGE     0x00030005
+#define BCM2835_MAILBOX_TAG_GET_MIN_VOLTAGE     0x00030008
+#define BCM2835_MAILBOX_TAG_GET_TEMPERATURE     0x00030006
+#define BCM2835_MAILBOX_TAG_GET_MAX_TEMPERATURE 0x0003000a
+
+/* Memory */
+#define BCM2835_MAILBOX_TAG_ALLOCATE_MEMORY     0x0003000c
+#define BCM2835_MAILBOX_TAG_LOCK_MEMORY         0x0003000d
+#define BCM2835_MAILBOX_TAG_UNLOCK_MEMORY       0x0003000e
+#define BCM2835_MAILBOX_TAG_RELEASE_MEMORY      0x0003000f
+#define BCM2835_MAILBOX_TAG_EXECUTE_CODE        0x00030010
+#define BCM2835_MAILBOX_TAG_GET_DISPMANX_RESOURCE_MEM_HANDLE     0x00030014
+
+#define BCM2835_MAILBOX_TAG_GET_EDID_BLOCK      0x00030020
+
+/* Framebuffer */
+#define BCM2835_MAILBOX_TAG_ALLOCATE_BUFFER     0x00040001
+typedef struct {
+  bcm2835_mbox_tag_hdr tag_hdr;
+  union {
+    struct {
+      uint32_t align;
+    } req;
+    struct {
+      uint32_t base;
+      uint32_t size;
+    } resp;
+  } body;
+} bcm2835_mbox_tag_allocate_buffer;
+
+#define BCM2835_MAILBOX_TAG_RELEASE_BUFFER      0x00048001
+
+#define BCM2835_MAILBOX_TAG_BLANK_SCREEN        0x00040002
+
+#define BCM2835_MAILBOX_TAG_GET_DISPLAY_SIZE          0x00040003
+#define BCM2835_MAILBOX_TAG_TEST_DISPLAY_SIZE         0x00044003
+#define BCM2835_MAILBOX_TAG_SET_DISPLAY_SIZE          0x00048003
+typedef struct {
+  bcm2835_mbox_tag_hdr tag_hdr;
+  union {
+    struct {
+      uint32_t width;
+      uint32_t height;
+    } req;
+    struct {
+      uint32_t width;
+      uint32_t height;
+    } resp;
+  } body;
+} bcm2835_mbox_tag_display_size;
+
+#define BCM2835_MAILBOX_TAG_GET_VIRTUAL_SIZE     0x00040004
+#define BCM2835_MAILBOX_TAG_TEST_VIRTUAL_SIZE    0x00044004
+#define BCM2835_MAILBOX_TAG_SET_VIRTUAL_SIZE     0x00048004
+typedef struct {
+  bcm2835_mbox_tag_hdr tag_hdr;
+  union {
+    struct {
+      uint32_t vwidth;
+      uint32_t vheight;
+    } req;
+    struct {
+      uint32_t vwidth;
+      uint32_t vheight;
+    } resp;
+  } body;
+} bcm2835_mbox_tag_virtual_size;
+
+#define BCM2835_MAILBOX_TAG_GET_DEPTH           0x00040005
+#define BCM2835_MAILBOX_TAG_TEST_DEPTH          0x00044005
+#define BCM2835_MAILBOX_TAG_SET_DEPTH           0x00048005
+typedef struct {
+  bcm2835_mbox_tag_hdr tag_hdr;
+  union {
+    struct {
+      uint32_t depth;
+    } req;
+    struct {
+      uint32_t depth;
+    } resp;
+  } body;
+} bcm2835_mbox_tag_depth;
+
+#define BCM2835_MAILBOX_TAG_GET_PIXEL_ORDER     0x00040006
+#define BCM2835_MAILBOX_TAG_TEST_PIXEL_ORDER    0x00044006
+#define BCM2835_MAILBOX_TAG_SET_PIXEL_ORDER     0x00048006
+
+#define BCM2835_MAILBOX_PIXEL_ORDER_BGR    0
+#define BCM2835_MAILBOX_PIXEL_ORDER_RGB    1
+typedef struct {
+  bcm2835_mbox_tag_hdr tag_hdr;
+  union {
+    struct {
+      uint32_t pixel_order;
+    } req;
+    struct {
+      uint32_t pixel_order;
+    } resp;
+  } body;
+} bcm2835_mbox_tag_pixel_order;
+
+#define BCM2835_MAILBOX_TAG_GET_ALPHA_MODE      0x00040007
+#define BCM2835_MAILBOX_TAG_TEST_ALPHA_MODE     0x00044007
+#define BCM2835_MAILBOX_TAG_SET_ALPHA_MODE      0x00048007
+typedef struct {
+  bcm2835_mbox_tag_hdr tag_hdr;
+  union {
+    struct {
+      uint32_t alpha_mode;
+    } req;
+    struct {
+      uint32_t alpha_mode;
+    } resp;
+  } body;
+} bcm2835_mbox_tag_alpha_mode;
+
+#define BCM2835_MAILBOX_ALPHA_MODE_0_OPAQUE  0
+#define BCM2835_MAILBOX_ALPHA_MODE_0_TRANSPARENT 1
+#define BCM2835_MAILBOX_ALPHA_MODE_IGNORED   2
+
+#define BCM2835_MAILBOX_TAG_GET_PITCH           0x00040008
+typedef struct {
+  bcm2835_mbox_tag_hdr tag_hdr;
+  union {
+    struct {
+    } req;
+    struct {
+      uint32_t pitch;
+    } resp;
+  } body;
+} bcm2835_mbox_tag_get_pitch;
+
+#define BCM2835_MAILBOX_TAG_GET_VIRTUAL_OFFSET  0x00040009
+#define BCM2835_MAILBOX_TAG_TEST_VIRTUAL_OFFSET 0x00044009
+#define BCM2835_MAILBOX_TAG_SET_VIRTUAL_OFFSET  0x00048009
+typedef struct {
+  bcm2835_mbox_tag_hdr tag_hdr;
+  union {
+    struct {
+      uint32_t voffset_x;
+      uint32_t voffset_y;
+    } req;
+    struct {
+      uint32_t voffset_x;
+      uint32_t voffset_y;
+    } resp;
+  } body;
+} bcm2835_mbox_tag_virtual_offset;
+
+#define BCM2835_MAILBOX_TAG_GET_OVERSCAN        0x0004000a
+#define BCM2835_MAILBOX_TAG_TEST_OVERSCAN       0x0004400a
+#define BCM2835_MAILBOX_TAG_SET_OVERSCAN        0x0004800a
+typedef struct {
+  bcm2835_mbox_tag_hdr tag_hdr;
+  union {
+    struct {
+      uint32_t overscan_top;
+      uint32_t overscan_bottom;
+      uint32_t overscan_left;
+      uint32_t overscan_right;
+    } req;
+    struct {
+      uint32_t overscan_top;
+      uint32_t overscan_bottom;
+      uint32_t overscan_left;
+      uint32_t overscan_right;
+    } resp;
+  } body;
+} bcm2835_mbox_tag_overscan;
+
+#define BCM2835_MAILBOX_TAG_GET_PALETTE         0x0004000b
+#define BCM2835_MAILBOX_TAG_TEST_PALETTE        0x0004400b
+#define BCM2835_MAILBOX_TAG_SET_PALETTE         0x0004800b
+#define BCM2835_MAILBOX_TAG_SET_CURSOR_INFO     0x00008011
+#define BCM2835_MAILBOX_TAG_SET_CURSOR_STATE    0x00008010
+
+/** @} */
+
+/** @} */
+
+#endif /* LIBBSP_ARM_RASPBERRYPI_VC_DEFINES_H */
diff --git a/c/src/lib/libbsp/arm/raspberrypi/preinstall.am b/c/src/lib/libbsp/arm/raspberrypi/preinstall.am
index 346e557..a89e143 100644
--- a/c/src/lib/libbsp/arm/raspberrypi/preinstall.am
+++ b/c/src/lib/libbsp/arm/raspberrypi/preinstall.am
@@ -138,6 +138,10 @@ $(PROJECT_INCLUDE)/bsp/mailbox.h: include/mailbox.h $(PROJECT_INCLUDE)/bsp/$(dir
 	$(INSTALL_DATA) $< $(PROJECT_INCLUDE)/bsp/mailbox.h
 PREINSTALL_FILES += $(PROJECT_INCLUDE)/bsp/mailbox.h
 
+$(PROJECT_INCLUDE)/bsp/vc.h: include/vc.h $(PROJECT_INCLUDE)/bsp/$(dirstamp)
+	$(INSTALL_DATA) $< $(PROJECT_INCLUDE)/bsp/vc.h
+PREINSTALL_FILES += $(PROJECT_INCLUDE)/bsp/vc.h
+
 $(PROJECT_INCLUDE)/libcpu/cache_.h: ../../../libcpu/arm/shared/include/cache_.h $(PROJECT_INCLUDE)/libcpu/$(dirstamp)
 	$(INSTALL_DATA) $< $(PROJECT_INCLUDE)/libcpu/cache_.h
 PREINSTALL_FILES += $(PROJECT_INCLUDE)/libcpu/cache_.h
-- 
2.1.0




More information about the devel mailing list