arm/raspberrypi: run VideoCore and mailbox code through rtems.uncrustify.

Some changes have been reverted to keep readability.
For example squash of BCM2835_MBOX_TAG_* defines
which are visually aligned in column.
This commit is contained in:
Pavel Pisa
2016-06-28 16:15:38 +02:00
parent 48704cdebd
commit 68565b090e
5 changed files with 264 additions and 244 deletions

View File

@@ -30,31 +30,26 @@
* @{
*/
typedef struct
{
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);
int bcm2835_mailbox_get_display_size(
bcm2835_get_display_size_entries *_entries );
typedef enum
{
typedef enum {
bcm2835_mailbox_pixel_order_bgr = 0,
bcm2835_mailbox_pixel_order_rgb = 1
} bcm2835_pixel_order;
typedef enum
{
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
{
typedef struct {
uint32_t xres;
uint32_t yres;
uint32_t xvirt;
@@ -73,27 +68,22 @@ typedef struct
uint32_t pitch;
} bcm2835_init_frame_buffer_entries;
int
bcm2835_mailbox_init_frame_buffer(bcm2835_init_frame_buffer_entries* _entries);
int bcm2835_mailbox_init_frame_buffer(
bcm2835_init_frame_buffer_entries *_entries );
typedef struct
{
typedef struct {
uint32_t pitch;
} bcm2835_get_pitch_entries;
int
bcm2835_mailbox_get_pitch(bcm2835_get_pitch_entries* _entries);
int bcm2835_mailbox_get_pitch( bcm2835_get_pitch_entries *_entries );
typedef struct
{
typedef struct {
char cmdline[ 1024 ];
} bcm2835_get_cmdline_entries;
int
bcm2835_mailbox_get_cmdline(bcm2835_get_cmdline_entries* _entries);
int bcm2835_mailbox_get_cmdline( bcm2835_get_cmdline_entries *_entries );
typedef enum
{
typedef enum {
bcm2835_mailbox_power_udid_sd_card = 0x00000000u,
bcm2835_mailbox_power_udid_uart0 = 0x00000001u,
bcm2835_mailbox_power_udid_uart1 = 0x00000002u,
@@ -105,8 +95,7 @@ typedef enum
bcm2835_mailbox_power_udid_ccp2tx = 0x00000008u,
} bcm2835_power_device_id;
typedef struct
{
typedef struct {
bcm2835_power_device_id dev_id;
uint32_t state;
} bcm2835_set_power_state_entries;
@@ -115,45 +104,37 @@ typedef struct
#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);
int bcm2835_mailbox_set_power_state( bcm2835_set_power_state_entries *_entries );
typedef struct
{
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);
int bcm2835_mailbox_get_arm_memory( bcm2835_get_arm_memory_entries *_entries );
typedef struct
{
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);
int bcm2835_mailbox_get_vc_memory( bcm2835_get_vc_memory_entries *_entries );
typedef struct
{
typedef struct {
uint32_t fw_rev;
} bcm2835_mailbox_get_fw_rev_entries;
int
bcm2835_mailbox_get_firmware_revision(bcm2835_mailbox_get_fw_rev_entries* _entries);
int bcm2835_mailbox_get_firmware_revision(
bcm2835_mailbox_get_fw_rev_entries *_entries );
typedef struct
{
typedef struct {
uint32_t spec;
} bcm2835_get_board_spec_entries;
int
bcm2835_mailbox_get_board_model(bcm2835_get_board_spec_entries* _entries);
int bcm2835_mailbox_get_board_model( bcm2835_get_board_spec_entries *_entries );
int
bcm2835_mailbox_get_board_revision(bcm2835_get_board_spec_entries* _entries);
int bcm2835_mailbox_get_board_revision(
bcm2835_get_board_spec_entries *_entries );
/** @} */
#endif /* LIBBSP_ARM_RASPBERRYPI_VC_H */

View File

@@ -41,16 +41,22 @@ unsigned int raspberrypi_mailbox_read(unsigned int channel)
while ( 1 ) {
while ( bcm2835_mailbox_is_empty() ) ;
raw = BCM2835_REG( BCM2835_MBOX_READ );
read_channel = BCM2835_MBOX_CHANNEL_MASK( raw );
if ( read_channel == channel )
return BCM2835_MBOX_DATA_MASK( raw );
}
}
void raspberrypi_mailbox_write(unsigned int channel, unsigned int data)
void raspberrypi_mailbox_write(
unsigned int channel,
unsigned int data
)
{
while ( bcm2835_mailbox_is_full() ) ;
BCM2835_REG( BCM2835_MBOX_WRITE ) =
BCM2835_MBOX_DATA_MASK( data ) |
BCM2835_MBOX_CHANNEL_MASK( channel );

View File

@@ -34,17 +34,15 @@ benchmark_timer_t benchmark_timer_read(void)
{
uint32_t delta = BCM2835_REG( BCM2835_GPU_TIMER_CLO ) - benchmark_timer_base;
if (benchmark_timer_find_average_overhead)
{
if ( benchmark_timer_find_average_overhead ) {
return delta;
}
else
{
} else {
return BCM2835_REG( BCM2835_GPU_TIMER_CLO );
}
}
void benchmark_timer_disable_subtracting_average_overhead(bool find_average_overhead)
void benchmark_timer_disable_subtracting_average_overhead(
bool find_average_overhead )
{
benchmark_timer_find_average_overhead = find_average_overhead;
}

View File

@@ -31,15 +31,14 @@
#define BCM2835_VC_MEMORY_MAPPING 0xC0000000
#endif
static inline bool
bcm2835_mailbox_buffer_suceeded(const bcm2835_mbox_buf_hdr *hdr)
static inline bool bcm2835_mailbox_buffer_suceeded(
const bcm2835_mbox_buf_hdr *hdr )
{
RTEMS_COMPILER_MEMORY_BARRIER();
return ( hdr->buf_code == BCM2835_MBOX_BUF_CODE_REQUEST_SUCCEED );
}
static inline int
bcm2835_mailbox_send_read_buffer(void *buf)
static inline int bcm2835_mailbox_send_read_buffer( void *buf )
{
raspberrypi_mailbox_write( BCM2835_MBOX_CHANNEL_PROP_AVC,
(unsigned int) buf + BCM2835_VC_MEMORY_MAPPING );
@@ -52,8 +51,10 @@ bcm2835_mailbox_send_read_buffer(void *buf)
* with VideoCore has to be propagated through ARM11/Cortex-A7
* caches
*/
static inline void
bcm2835_mailbox_buffer_flush_and_invalidate(void *buf, size_t size)
static inline void bcm2835_mailbox_buffer_flush_and_invalidate(
void *buf,
size_t size
)
{
uint32_t sctlr_val;
@@ -61,6 +62,7 @@ bcm2835_mailbox_buffer_flush_and_invalidate(void *buf, size_t size)
RTEMS_COMPILER_MEMORY_BARRIER();
arm_cp15_drain_write_buffer();
if ( sctlr_val & ( ARM_CP15_CTRL_C | ARM_CP15_CTRL_M ) ) {
#if 0
/*
@@ -81,8 +83,8 @@ bcm2835_mailbox_buffer_flush_and_invalidate(void *buf, size_t size)
#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)
int bcm2835_mailbox_get_display_size(
bcm2835_get_display_size_entries *_entries )
{
struct {
bcm2835_mbox_buf_hdr hdr;
@@ -93,17 +95,21 @@ bcm2835_mailbox_get_display_size(bcm2835_get_display_size_entries *_entries)
BCM2835_MBOX_INIT_TAG_NO_REQ( &buffer.get_display_size,
BCM2835_MAILBOX_TAG_GET_DISPLAY_SIZE );
bcm2835_mailbox_buffer_flush_and_invalidate( &buffer, sizeof( &buffer ) );
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)
int bcm2835_mailbox_init_frame_buffer(
bcm2835_init_frame_buffer_entries *_entries )
{
struct {
bcm2835_mbox_buf_hdr hdr;
@@ -152,8 +158,10 @@ bcm2835_mailbox_init_frame_buffer(bcm2835_init_frame_buffer_entries* _entries)
BCM2835_MBOX_INIT_TAG_NO_REQ( &buffer.get_pitch,
BCM2835_MAILBOX_TAG_GET_PITCH );
bcm2835_mailbox_buffer_flush_and_invalidate( &buffer, sizeof( &buffer ) );
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;
@@ -162,8 +170,8 @@ bcm2835_mailbox_init_frame_buffer(bcm2835_init_frame_buffer_entries* _entries)
#if ( BSP_IS_RPI2 == 1 )
_entries->base = buffer.allocate_buffer.body.resp.base;
#else
_entries->base = buffer.allocate_buffer.body.resp.base
- BCM2835_VC_MEMORY_MAPPING;
_entries->base = buffer.allocate_buffer.body.resp.base -
BCM2835_VC_MEMORY_MAPPING;
#endif
_entries->size = buffer.allocate_buffer.body.resp.size;
_entries->pixel_order = buffer.set_pixel_order.body.resp.pixel_order;
@@ -174,13 +182,14 @@ bcm2835_mailbox_init_frame_buffer(bcm2835_init_frame_buffer_entries* _entries)
_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)
int bcm2835_mailbox_get_pitch( bcm2835_get_pitch_entries *_entries )
{
struct {
bcm2835_mbox_buf_hdr hdr;
@@ -191,18 +200,22 @@ bcm2835_mailbox_get_pitch(bcm2835_get_pitch_entries* _entries)
BCM2835_MBOX_INIT_TAG_NO_REQ( &buffer.get_pitch,
BCM2835_MAILBOX_TAG_GET_PITCH );
bcm2835_mailbox_buffer_flush_and_invalidate( &buffer, sizeof( &buffer ) );
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 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;
@@ -212,22 +225,25 @@ bcm2835_mailbox_get_cmdline(bcm2835_get_cmdline_entries* _entries)
BCM2835_MBOX_INIT_TAG_NO_REQ( &buffer.get_cmd_line,
BCM2835_MAILBOX_TAG_GET_CMD_LINE );
bcm2835_mailbox_buffer_flush_and_invalidate( &buffer, sizeof( &buffer ) );
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)
{
++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)
int bcm2835_mailbox_set_power_state( bcm2835_set_power_state_entries *_entries )
{
struct {
bcm2835_mbox_buf_hdr hdr;
@@ -240,17 +256,20 @@ bcm2835_mailbox_set_power_state(bcm2835_set_power_state_entries *_entries)
buffer.set_power_state.body.req.dev_id = _entries->dev_id;
buffer.set_power_state.body.req.state = _entries->state;
bcm2835_mailbox_buffer_flush_and_invalidate( &buffer, sizeof( &buffer ) );
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)
int bcm2835_mailbox_get_arm_memory( bcm2835_get_arm_memory_entries *_entries )
{
struct {
bcm2835_mbox_buf_hdr hdr;
@@ -261,17 +280,20 @@ bcm2835_mailbox_get_arm_memory(bcm2835_get_arm_memory_entries* _entries)
BCM2835_MBOX_INIT_TAG_NO_REQ( &buffer.get_arm_memory,
BCM2835_MAILBOX_TAG_GET_ARM_MEMORY );
bcm2835_mailbox_buffer_flush_and_invalidate( &buffer, sizeof( &buffer ) );
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)
int bcm2835_mailbox_get_vc_memory( bcm2835_get_vc_memory_entries *_entries )
{
struct {
bcm2835_mbox_buf_hdr hdr;
@@ -282,17 +304,21 @@ bcm2835_mailbox_get_vc_memory(bcm2835_get_vc_memory_entries* _entries)
BCM2835_MBOX_INIT_TAG_NO_REQ( &buffer.get_vc_memory,
BCM2835_MAILBOX_TAG_GET_VC_MEMORY );
bcm2835_mailbox_buffer_flush_and_invalidate( &buffer, sizeof( &buffer ) );
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;
}
int
bcm2835_mailbox_get_firmware_revision(bcm2835_mailbox_get_fw_rev_entries* _entries)
int bcm2835_mailbox_get_firmware_revision(
bcm2835_mailbox_get_fw_rev_entries *_entries )
{
struct {
bcm2835_mbox_buf_hdr hdr;
@@ -303,16 +329,19 @@ bcm2835_mailbox_get_firmware_revision(bcm2835_mailbox_get_fw_rev_entries* _entri
BCM2835_MBOX_INIT_TAG_NO_REQ( &buffer.get_fw_rev,
BCM2835_MAILBOX_TAG_FIRMWARE_REVISION );
bcm2835_mailbox_buffer_flush_and_invalidate( &buffer, sizeof( &buffer ) );
if ( bcm2835_mailbox_send_read_buffer( &buffer ) )
return -1;
_entries->fw_rev = buffer.get_fw_rev.body.resp.rev;
if ( !bcm2835_mailbox_buffer_suceeded( &buffer.hdr ) )
return -2;
return 0;
}
int
bcm2835_mailbox_get_board_model(bcm2835_get_board_spec_entries* _entries)
int bcm2835_mailbox_get_board_model( bcm2835_get_board_spec_entries *_entries )
{
struct {
bcm2835_mbox_buf_hdr hdr;
@@ -323,16 +352,20 @@ bcm2835_mailbox_get_board_model(bcm2835_get_board_spec_entries* _entries)
BCM2835_MBOX_INIT_TAG_NO_REQ( &buffer.get_board_model,
BCM2835_MAILBOX_TAG_GET_BOARD_MODEL );
bcm2835_mailbox_buffer_flush_and_invalidate( &buffer, sizeof( &buffer ) );
if ( bcm2835_mailbox_send_read_buffer( &buffer ) )
return -1;
_entries->spec = buffer.get_board_model.body.resp.spec;
if ( !bcm2835_mailbox_buffer_suceeded( &buffer.hdr ) )
return -2;
return 0;
}
int
bcm2835_mailbox_get_board_revision(bcm2835_get_board_spec_entries* _entries)
int bcm2835_mailbox_get_board_revision(
bcm2835_get_board_spec_entries *_entries )
{
struct {
bcm2835_mbox_buf_hdr hdr;
@@ -343,10 +376,14 @@ bcm2835_mailbox_get_board_revision(bcm2835_get_board_spec_entries* _entries)
BCM2835_MBOX_INIT_TAG_NO_REQ( &buffer.get_board_revision,
BCM2835_MAILBOX_TAG_GET_BOARD_VERSION );
bcm2835_mailbox_buffer_flush_and_invalidate( &buffer, sizeof( &buffer ) );
if ( bcm2835_mailbox_send_read_buffer( &buffer ) )
return -1;
_entries->spec = buffer.get_board_revision.body.resp.spec;
if ( !bcm2835_mailbox_buffer_suceeded( &buffer.hdr ) )
return -2;
return 0;
}

View File

@@ -51,7 +51,6 @@
*
*/
typedef struct {
/**
* @brief Buffer Size
*
@@ -70,7 +69,6 @@ typedef struct {
uint32_t buf_code;
} bcm2835_mbox_buf_hdr;
/**
* @brief Tag Header
*