Graphics Processing Unit Driver(2D)

Graphics Processing Unit(GPU) manipulates and alters the contents of the frame buffer in system RAM or DRAM memory to accelerate the generation of images for eventual pixel display. Hardware acceleration is brought to numerous 2-D applications, such as graphic user interfaces (menus, objects, etc.), touch screen user interfaces, Flash animation and gaming among others.

Summary of the API's Functional Features

The API provides functions to:
  • Initializing and de-initializing the driver and associated hardware

  • Enabling and Disabling

  • Register Interrupt Callback function

  • Invoke GPU instruction(FILL, COPY, BLEND) to manipulate and alters the contents of the frame buffer.

Summary of Configuration Options

Depend on the device, GPU parameters can be configured in START.

Driver Implementation Description

The driver support FILL, COPY, BLEND GPU instruction to manipulates and alters the contents of the frame buffer. Those functions are asynchronous, an application can call the gpu_register_callback function to register a callback function. The callback function will be invoked when one GPU operation finished or an error occurs.

Example of Usage

The following shows an example of using the Graphic Processing Unit. The GPU driver must have been initialized firstly. This initialization configures the hardware Graphic Processing Unit instance.

This example will invoke a FILL instruction to fill an area (10x10 pixel) with BLUE color(ARGB format 0x000000FF).

          # include <utils.h>
          /* Frame buffer for 10x10 pixel, ARGB 32bit format */
          COMPILER_ALIGNED(4) uint32_t framebuffer[100];
          /* Indicate end of execute instruction */
          volatile uint8_t gpu_end = 0;
          void gpu_cb(uint8_t state)
          {
              gpu_end = state;
          }
          /**
           * Example of using GPU to fill a frame buffer with color.
           */
          void GPU_example(void)
          {
              struct gpu_buffer     dst;
              struct gpu_rectangle  rect;
              uint32_t i;
              gpu_enable(ringbuffer, 0x40);
              gpu_register_callback(gpu_callback);
              dst.width = 10;
              dst.height = 10;
              dst.fmt = GPU_ARGB8888;
              dst.addr = framebuffer;
              rect.x = 0;
              rect.y = 0;
              rect.width = 10;
              rect.height = 10;
              gpu_fill(&dst, &rect, GPU_COLOR(0,0,0,0xFF));
              /* Wait for instruction process finished */
              while (gpu_end == 0) {
              };
              /* Check if all data in framebuffer was set to 0x000000FF */
              for (i = 0; i < 100; i ++) {
                  if (((uint32_t *)framebuffer)[i] != 0x000000FF) {
                      /* Error happened */
                      while (1) {};
                  }
              }
              /* Success */
              return;
          }
        

Dependencies

  • 2D Graphic Engine peripheral.