# azizulhakim/beagleusb architecture

> Architecture diagram of the GitHub repository azizulhakim/beagleusb, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-01-05). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/azizulhakim/beagleusb
- Repository: https://github.com/azizulhakim/beagleusb

## Overview

##### Main Components

A. Hardware Layer:
- BeagleBoard Hardware
- Android Device (USB-connected)

B. Driver Components:
- USB Core Driver (beagleusb.c/h as the main interface)
- Audio Driver (beagle-audio.c/h)
- Video Driver (beagle-video.c/h)
- Input Driver (input.c/h)

C. Protocol Handlers:
- Android Debug Kit (ADK) Implementation (adk folder)
- Android Open Accessory (AOA) Protocol (aoa.c/h)

D. Android Application Layer:
- BeagleRemoteDisplay APK

**[Android Device Layer]**
- ↕ USB Connection
**[BeagleBoard Hardware Layer]**
- ↕ Driver Layer
**[Core USB Driver]**
- ↓
**[Specialized Drivers]**

**Audio     Video    Input**
- ↓         ↓        ↓
**[Protocol Handlers (ADK/AOA)]**

##### Important Elements to Highlight

a. Driver Integration Points:
- How beagleusb.c acts as the main integration point
- Relationship between the three main drivers (Audio, Video, Input)

b. Protocol Implementation:
- How ADK and AOA protocols interface between the Android device and drivers
- Relationship with the Android application

c. Data Flow:
- Audio stream path
- Video frame buffer path
- Input device events path

##### Implementation Details

**[Configuration]**
- ↓
**[Hardware Interface]**
- ↓
**[Driver Core]**
- ↓
**[Specialized Drivers]**
- ↓
**[Protocol Layer]**
- ↓
**[Application Layer]**

##### Key Relationships

- How the input system processes keyboard and mouse events
- How audio data flows from Android to BeagleBoard
- How video data is captured and displayed
- The role of ADK/AOA in facilitating communication

## Diagram (Mermaid)

```mermaid
graph TB
    %% Hardware Layer
    subgraph Hardware
        AD[Android Device]:::hardware
        BB[BeagleBoard]:::hardware
        AD <--> |USB Connection| BB
    end

    %% Driver Core Layer
    subgraph DriverCore
        USB[USB Core Driver]:::driver
        click USB "https://github.com/azizulhakim/beagleusb/blob/master/beagleusb.c"
        BB --> USB
    end

    %% Specialized Drivers Layer
    subgraph Drivers
        AD1[Audio Driver]:::driver
        VD1[Video Driver]:::driver
        ID1[Input Driver]:::driver
        
        click AD1 "https://github.com/azizulhakim/beagleusb/blob/master/beagle-audio.c"
        click VD1 "https://github.com/azizulhakim/beagleusb/blob/master/beagle-video.c"
        click ID1 "https://github.com/azizulhakim/beagleusb/blob/master/input.c"

        USB --> AD1
        USB --> VD1
        USB --> ID1
    end

    %% Protocol Handlers Layer
    subgraph Protocols
        ADK[ADK Protocol]:::protocol
        AOA[AOA Protocol]:::protocol
        
        click ADK "https://github.com/azizulhakim/beagleusb/blob/master/adk/adk.c"
        click AOA "https://github.com/azizulhakim/beagleusb/blob/master/aoa.c"

        AD1 --> ADK
        VD1 --> ADK
        ID1 --> ADK
        
        AD1 --> AOA
        VD1 --> AOA
        ID1 --> AOA
    end

    %% Configuration Components
    subgraph Config
        ASOUND[Audio Config]:::config
        DEV[Device Definitions]:::config
        FEAT[Feature Definitions]:::config
        INPUT[Input Control]:::config
        
        click ASOUND "https://github.com/azizulhakim/beagleusb/tree/master/res/asoundrc"
        click DEV "https://github.com/azizulhakim/beagleusb/blob/master/adk/devices.h"
        click FEAT "https://github.com/azizulhakim/beagleusb/blob/master/features.h"
        click INPUT "https://github.com/azizulhakim/beagleusb/blob/master/inputcontrol.h"
    end

    %% Application Layer
    subgraph Application
        APK[BeagleRemoteDisplay APK]:::app
        click APK "https://github.com/azizulhakim/beagleusb/blob/master/APK/BeagleRemoteDisplay.apk"
    end

    %% Configuration Relationships
    ASOUND --> AD1
    DEV --> USB
    FEAT --> USB
    INPUT --> ID1

    %% Protocol to App Relationships
    ADK --> APK
    AOA --> APK

    %% Styling
    classDef hardware fill:#a8d1f0,stroke:#333,stroke-width:2px
    classDef driver fill:#90EE90,stroke:#333,stroke-width:2px
    classDef protocol fill:#FFE5B4,stroke:#333,stroke-width:2px
    classDef app fill:#FFA07A,stroke:#333,stroke-width:2px
    classDef config fill:#E6E6FA,stroke:#333,stroke-width:2px

    %% Legend
    subgraph Legend
        H[Hardware Component]:::hardware
        D[Driver Component]:::driver
        P[Protocol Handler]:::protocol
        A[Application]:::app
        C[Configuration]:::config
    end
```
