ra8-firmware 0.1.0
Bare-metal firmware for the Renesas RA8 family (RA8D2 / RA8P1)
Loading...
Searching...
No Matches
board_view_pixels.c File Reference

Bounded raw-fd RGB565 to CoreGraphics byte-range expansion. More...

#include <string.h>
#include <sys/stat.h>
#include "board_view.h"
#include "emu_host_io_internal.h"
#include "ra8_attributes.h"
Include dependency graph for board_view_pixels.c:

Go to the source code of this file.

Enumerations

enum  view_pixel_geometry_t : size_t {
  k_view_pixel_chunk = 128U ,
  k_rgb565_red_shift = 11U ,
  k_rgb565_green_shift = 5U ,
  k_rgb565_five_bit_max = 0x1FU ,
  k_rgb565_six_bit_max = 0x3FU
}
 Bounded conversion chunk and RGB565 channel geometry. More...

Functions

static size_t internal_available_bytes (int fd, off_t position, size_t count)
 Clamp one provider request to the bytes the surface can still supply.
static void internal_expand_chunk (const uint16_t *rgb565, uint32_t *rgb888, size_t pixel_count)
 Expand one bounded RGB565 chunk into packed 32-bit RGB888 words.
size_t board_view_read_rgb888_fd (int fd, off_t position, void *buffer, size_t count)
 Expand an arbitrary byte range from a sealed RGB565 descriptor.

Detailed Description

Bounded raw-fd RGB565 to CoreGraphics byte-range expansion.

Converts arbitrary provider byte ranges from the sealed RGB565 surface descriptor into RGB888 using a fixed-size stack chunk, including unaligned range boundaries and checked positional reads.

Since
0.1.0

Definition in file board_view_pixels.c.

Enumeration Type Documentation

◆ view_pixel_geometry_t

enum view_pixel_geometry_t : size_t

Bounded conversion chunk and RGB565 channel geometry.

Enumerator
k_view_pixel_chunk 

Fixed source/conversion chunk capacity.

k_rgb565_red_shift 

Red-field least-significant bit.

k_rgb565_green_shift 

Green-field least-significant bit.

k_rgb565_five_bit_max 

Five-bit channel mask.

k_rgb565_six_bit_max 

Six-bit channel mask.

Definition at line 21 of file board_view_pixels.c.

Function Documentation

◆ board_view_read_rgb888_fd()

size_t board_view_read_rgb888_fd ( int fd,
off_t position,
void * buffer,
size_t count )

Expand an arbitrary byte range from a sealed RGB565 descriptor.

Parameters
[in]fdImmutable RGB565 surface descriptor.
[in]positionByte position in the virtual 0x00RRGGBB stream.
[out]bufferCoreGraphics-supplied destination bytes.
[in]countRequested destination byte count.
Returns
Bytes expanded exactly; zero on validation or raw-read failure.
Precondition
fd remains open and immutable for the call.
Postcondition
Success matches the legacy 0x00RRGGBB little-endian upload bytes.
Note
Uses fixed stack chunks and performs no acquisition.
Since
0.1.0

Expand an arbitrary byte range from a sealed rgb565 descriptor; this step is contained within the board view model and uses bounded caller or module-owned storage.

Return values
valueThe operation-specific board view read rgb888 descriptor value.
Precondition
The call executes on the emulator's single owning thread.
Postcondition
Ownership of caller-supplied storage is unchanged.

Definition at line 87 of file board_view_pixels.c.

References internal_available_bytes(), internal_expand_chunk(), k_emu_io_ok, k_view_pixel_chunk, memcpy(), and priv_emu_io_pread_exact().

◆ internal_available_bytes()

size_t internal_available_bytes ( int fd,
off_t position,
size_t count )
static

Clamp one provider request to the bytes the surface can still supply.

Measures the sealed RGB565 descriptor, derives the virtual RGB888 stream length from it, and clamps count to what remains after position.

Parameters
[in]fdSealed RGB565 surface descriptor.
[in]positionProvider byte offset into the virtual RGB888 stream.
[in]countBytes the caller is willing to receive.
Returns
size_t Bytes obtainable at position, never more than count.
Return values
0The descriptor is unusable, or position is at or past the end.
Precondition
fd is open and position is non-negative.
count is the exact caller buffer capacity.
Postcondition
The descriptor and its file offset are unchanged.
The result never exceeds count.
Note
Not thread-safe with respect to fd.
Since
0.1.0

Definition at line 44 of file board_view_pixels.c.

References RA8_INTERNAL.

Referenced by board_view_read_rgb888_fd().

◆ internal_expand_chunk()

void internal_expand_chunk ( const uint16_t * rgb565,
uint32_t * rgb888,
size_t pixel_count )
static

Expand one bounded RGB565 chunk into packed 32-bit RGB888 words.

Replicates the high channel bits into the low ones so a full-scale RGB565 value expands to a full-scale RGB888 value.

Parameters
[in]rgb565Source chunk holding pixel_count RGB565 pixels.
[out]rgb888Destination chunk receiving pixel_count packed words.
[in]pixel_countPixels to convert, at most k_view_pixel_chunk.
Precondition
Both chunks span pixel_count elements.
The chunks do not overlap.
Postcondition
The first pixel_count words of rgb888 are initialized.
rgb565 is unchanged.
Note
Not thread-safe with respect to the caller chunks.
Since
0.1.0

Definition at line 73 of file board_view_pixels.c.

References k_rgb565_five_bit_max, k_rgb565_green_shift, k_rgb565_red_shift, and k_rgb565_six_bit_max.

Referenced by board_view_read_rgb888_fd().