# Architecture Source: [https://docs.qualcomm.com/doc/80-70015-7/topic/architecture.html](https://docs.qualcomm.com/doc/80-70015-7/topic/architecture.html) Note: - To continue reading about the APIs or set up sensor information, proceed directly to [Interfaces](https://docs.qualcomm.com/bundle/publicresource/topics/80-70015-7/qsh_api_reference.html). - Source code of the low-power processor (aDSP), including the QSH framework, is available only to licensed users with authorized access. To upgrade your access, go to: [www.qualcomm.com/support/working-with-qualcomm](https://www.qualcomm.com/support/working-with-qualcomm). QSH, which is synonymous with the Qualcomm® Snapdragon™ sensor core (SSC), offers a unified event-driven framework for drivers and algorithms. QSH supports the same set of APIs for both the hardware-based and software-based sensors. Additionally, QSH supports asynchronous bus transfer and is easily extendable for new or custom driver features. QSH consists of various components that include the QSH client APIs, sensor APIs, a core framework, pre-implemented platform sensors, vendor-implemented sensors, and the test modules. It serves external clients and provides a simple interface to access the sensor data. The following table describes the terms used in the QSH framework: Table : QSH terminology | **Item** | **Description** | | --- | --- | | Sensor | | | Sensor instance | | | Sensor unique identifier (SUID) | A unique 128‑bit ID for each sensor | | Service | A module that provides a synchronous interface for common
utilities | | Data stream | A unique connection between a client and data source | | Request | A configuration message that a client sends to a sensor (see
`sns_request.h` file) | | Event | Asynchronous output data message that a sensor instance generates
(see `sns_sensor_event.h` file) | | Nanopb | A small code-size protocol buffer implemented in ANSI C | The following figure shows the components of QSH architecture: Figure : QSH architecture components Page-1 Sheet.120 Sheet.5 Sheet.6 Sheet.7 Qualcomm Sensing Hub Qualcomm Sensing Hub Sheet.8 Sheet.9 Sheet.10 Client Manager Client Manager Sheet.12 Sheet.13 Client Application Client Application Sheet.15 Sheet.16 QSH Client API QSH Client API Sheet.17 Application processor Application processor Sheet.18 Low power processor Low power processor Sheet.19 Sheet.21 Sheet.22 Sheet.23 Sheet.24 Sheet.25 Sheet.26 Sheet.27 Sheet.28 Hardware Based Hardware Based Sheet.29 Sensor Drivers Sensor Drivers Sheet.30 Sheet.31 Sheet.32 Sheet.33 Sheet.34 Sheet.35 Sheet.36 Software Based Software Based Sheet.37 Sensors Sensors Sheet.38 Sheet.39 Sheet.40 Serial Buses Serial Buses Sheet.41 Sheet.42 Sheet.43 Platform Platform Sheet.44 Sensors Sensors Sheet.45 Sheet.46 Sheet.47 Service Service Sheet.48 Manager Manager Sheet.49 Linux OS Linux OS Sheet.50 QuRT QuRT Sheet.51 OS OS Sheet.52 Sheet.53 Sheet.54 Sheet.55 Utilities Utilities Sheet.56 Sheet.57 QSH Sensor API QSH Sensor API Sheet.58 Sheet.59 Sheet.61 Sheet.62 Sheet.63 Sheet.64 Sheet.65 Sheet.66 Sheet.67 Sheet.68 Sheet.69 Sheet.70 Sensor Hardware Sensor Hardware Rounded Rectangle Accelerometer Accelerometer Rounded Rectangle.126 Sheet.76 Gyroscope Gyroscope Rounded Rectangle.128 Magnetometer Magnetometer Rounded Rectangle.130 Other Sensors Other Sensors Sheet.88 Sheet.89 Sheet.90 Sheet.91 Sheet.92 Sheet.93 Sheet.94 Sheet.95 Sheet.96 I3C I3C Sheet.97 Sheet.98 Sheet.99 SPI SPI Sheet.100 Sheet.101 Sheet.102 I2C I2C Sheet.103 Sheet.104 Sheet.105 UART UART Rounded Rectangle.129 ALS/Prox ALS/Prox Round Corner Rectangle Third-party Third-party Round Corner Rectangle.114 Upstream Upstream Round Corner Rectangle.116 Qualcomm Qualcomm Round Corner Rectangle.118 Hardware Hardware - **Application processor software modules** - **Client application**: It contains the *application main()* or *entry function* that interacts with the QSH client APIs on the application processor side. - **QSH client APIs**: It offers high-level APIs to access services offered by the QSH. It simplifies application development by abstracting system complexities and focusing on the application logic. For more information, see [Interfaces](https://docs.qualcomm.com/bundle/publicresource/topics/80-70015-7/qsh_api_reference.html). - **Low-power processor software modules** - **Client manager**: The client manager is in-charge of all communications of the low-power processor with the application processor. It is responsible for the following: Table : Client manager functions | Function | Description | | --- | --- | | Translate incoming requests | The client manager takes incoming requests and
translates them into a format that the QSH can
understand. | | Translate outgoing indications | The client manager receives event messages from the
QSH and translates these event messages into outgoing
indications in a format that is understandable outside
the QSH. | | Guarantees batching options | If a client specifies certain batching
(store/accumulate locally) options, then the client
manager ensures that the batching options are met. This
means it checks that the data is grouped and sent in the
way that the client has specified. | - **Service manager**: QSH offers synchronous services through its service manager. The sensor and sensor instance APIs use a callback to connect to this service manager. The `adsp_proc/qsh_platform/inc/sns_service.h` file lists the services available in the QSH, also referred as QSH services. The following table describes the key QSH services that are essential for device drivers. Table : QSH services | QSH service | Description | | --- | --- | | Stream service | | | Attribute service | | | Diagnostic service | | | Event service | | | Power rail service | | | Synchronous COM port (SCP) service | | | GPIO service | | | Island service | | | File system service | | - **Platform sensor**: QSH provides some built-in sensors for platform or hardware-specific abstraction that other sensors and sensor instances can use. The following table describes the platform sensors: Table : Platform sensors | Platform sensor | Description | | --- | --- | | Registry sensor | | | Timer sensor | | | Interrupt sensor | | | Asynchronous COM port (ASCP) sensor |


Note: The ASCP sensor is typically used by the physical
sensor drivers to read large FIFO. | | SUID lookup sensor | | | Test sensor | | - **QSH utilities**: QSH provides several helper utilities for sensors and sensor instances. All the utilities are available in the `adsp_proc/qsh_platform/inc/utils` directory. The following table describes the key utilities: Table : QSH utilities | QSH utility | Description | | --- | --- | | Nanopb encode/decode | | | Sensor utils | | | Attribute utils | | | Memory utils | | | Math utils | | | Printf utils | | ## Communication among sensors Source: [https://docs.qualcomm.com/doc/80-70015-7/topic/architecture.html](https://docs.qualcomm.com/doc/80-70015-7/topic/architecture.html) Every algorithm and sensor driver within the QSH framework is referred to as a sensor with the standard QSH APIs. Information exchange across these sensors is necessary for any real use case. All communication to, from, and among the sensors is performed through the request and event messages over data streams. The message payloads are defined in the protocol buffer format, using the nanopb generator, encoder, and decoder. The message payload length, message ID, and timestamp (for events) are communicated within metadata managed by the QSH framework. The following figure shows communication between data client and data source, using the data stream: Figure : Sensor communication between client and source VBackground-1 Solid Page-1 Rounded Rectangle.2 Rounded Rectangle.3 Simple Arrow.30 Simple Arrow.29 Rounded Rectangle.22 PB Encode/Decode PB Encode/Decode Rounded Rectangle.21 PB Encode/Decode PB Encode/Decode Sheet.23 Request Request Sheet.24 Event Event Sheet.25 Data Client Data Client Sheet.26 Data Source Data Source Dynamic connector.27 Sheet.31 Data Stream Data Stream Round Corner Rectangle Third-party Third-party Request messages are sent to enable, disable, and/or reconfigure a sensor. Request messages are always addressed to a specific SUID. After the target sensor receives the request message, it sends the request to the sensor instance for proper handling. Sensor instances send event messages asynchronously to their registered clients, which may be other sensors or sensor instances. ### Sensor and sensor instances - Sensors are producers, consumers, or a combination of producers and consumers of asynchronous data. - Each sensor can have one or more sensor instances. - Each sensor instance operates with a specific configuration. - Any request to a sensor for data results in the creation of a sensor instance or sharing of an existing sensor instance. - Sensor instances are created on-demand, as determined by the sensor. - Sensors fully manage the lifecycle and configuration of their corresponding instances and are responsible for sending configuration updates and initial state events to their clients. - Vendors must serve all client requests with a minimal number of sensor instances. - A stream of data generated by a sensor instance is sent to all the active clients. - Multiple sensors can share and configure a single sensor instance – this mode of operation is typical to a combo driver for hardware sensors. Here, the sensors represent the supported data types, and the sensor instance is the sole module that communicates and configures the hardware. ## Nanopb protocol buffer in QSH Source: [https://docs.qualcomm.com/doc/80-70015-7/topic/architecture.html](https://docs.qualcomm.com/doc/80-70015-7/topic/architecture.html) The QSH uses nanopb protocol buffer for: - All the request and event messages exchanged between the sensors. - A sensor or sensor instance must encode the payload (if present) for all requests it sends to its dependants. - A sensor or sensor instance must decode the payload (if present) for all requests it receives. - A sensor or sensor instance must encode the payload (if present) for all events it publishes. - A sensor or sensor instance must decode the payload (if present) for all events it receives from its dependants. Note: Some requests or events do not have a message body. In this case, decoding or encoding the payload is not expected. Process these messages based on their message ID. - Representing the attribute data - All attribute values are in the nanopb-encoded format - Diagnostic log packet payload - All payloads in the diagnostic log packets are in the nanopb-encoded format Note: For more information on Google protocol buffers and nanopb respectively, see [Protocol-buffers](https://developers.google.com/protocol-buffers/) and [nanopb](https://jpa.kapsi.fi/nanopb/). ## Sensor API messages Source: [https://docs.qualcomm.com/doc/80-70015-7/topic/architecture.html](https://docs.qualcomm.com/doc/80-70015-7/topic/architecture.html) The following files refer to the API messages, which contain message definitions, and are used for communication between sensors: - The `.proto` files contain protocol buffer message definitions and documentation to communicate between sensors. - The following table lists the standard message defined in the `/build-qcom-wayland/workspace/sources/sensinghub/sensing-hub/apis/proto/sns_std_*.proto` file: Table : Standard proto files | File | Description | | --- | --- | | `sns_std.proto` | This file includes standard definitions, such as: | | `sns_std_sensor.proto` | This file includes definitions, such as: | | `sns_std_type.proto` | This file includes common API-type definitions, such as: | | `sns_std_event_gated_sensor.proto` | This file includes the API for event gated sensors,
encompassing the configuration message ID and API
documentation. | - Physical sensor-specific API definitions and documentation are present in the sensor-specific `.proto` files. For example, `sns_accel.proto`, `sns_proximity.proto` and `sns_motion_detect.proto`. - Platform sensor API definitions and documentation are present in the `adsp_proc/qsh_platform/api/` directory. For example, `sns_timer.proto`, `sns_interrupt.proto`, and `sns_async_com_port.proto`. - Framework-related APIs for SUID, registry, and diagnostics are defined in the following proto files: - `sns_suid.proto` - `sns_registry.proto` - `sns_diag.proto` Last Published: Oct 14, 2024 [Previous Topic Features](https://docs.qualcomm.com/bundle/publicresource/80-70015-7/topics/supported_features.md) [Next Topic Interfaces](https://docs.qualcomm.com/bundle/publicresource/80-70015-7/topics/qsh_api_reference.md)