The GPU service API allows you to manage the GPU frequency using a multiplier factor. In some scenarios, the 3D performance of an application is not as critical as the temperature or the energy the module is consuming.

You can use this API to scale the GPU operating frequency. The frequency is always divided by 64 and then multiplied by a value that can range from 1 to 64. You can control this multiplier factor to have better control over module temperature and power consumption.

In addition to managing the GPU frequency, this API allows you to configure the minimum frequency multiplier that will be applied when the module’s temperature reaches the hot trip point. The hot trip point is an Android security mechanism that reduces CPU and GPU frequencies when the device reaches a temperature configured in this trip point. See the Digi APIx javadoc for a complete list of the available methods in this API.

Unless noted, all GPU API methods require the com.digi.android.permission.GPU permission.

If your application does not have the com.digi.android.permission.GPU permission, it will not have access to any GPU service feature.

You must instantiate a GPUManager object to manage the GPU frequency multiplier. To do so, you must provide the application Context.

Instantiate the GPUManager
import android.app.Activity;
import android.os.Bundle;

import com.digi.android.system.gpu.GPUManager;

public class GPUSampleActivity extends Activity {

    GPUManager gpuManager;

    [...]

    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceStace);

        // Instantiate the GPU manager object.
        gpuManager = new GPUManager(this);

        [...]
    }

    [...]
}

Once the GPUManager object is instantiated you will be able to:

Manage the GPU frequency multiplier

One of the main features of the GPUManager is to control the GPU frequency using a multiplier factor that can range from 1 to 64. A value of 64 means that the GPU frequency is configured at its maximum, while 1 means that the frequency is configured at its minimum. The GPU frequency is directly associated to the temperature and power consumption of the module. The lower the frequency is, the lower the temperature and consumption will be.

Two methods allow you to get and set the GPU frequency multiplier.

Method Description

setMultiplier(int)

Sets the frequency multiplier. It can range from 1 to 64.

This method returns the configured frequency. If the operation was successful, it returns a value equal to the specified multiplier.

getMultiplier()

Gets the frequency multiplier.

In some module variants, the minimum allowed frequency multiplier is greater than one. To ensure the new multiplier was successfully configured, compare the value returned by the setMultiplier(int) method with the desired one. They must be equal.

These methods may fail for the following reasons:

  • The functionality is not supported, throwing a UnsupportedOperationException.

  • The specified multiplier is out of range, throwing an IllegalArgumentException.

  • An error occurs when setting or getting the multiplier, throwing an IOException.

Get and set the frequency multiplier
import com.digi.android.system.gpu.GPUManager;

[...]

// Get the GPU manager.
GPUManager gpuManager = new GPUManager(context);

// Get the current frequency multiplier.
int currentMultiplier = gpuManager.getMultiplier();

// Set the the frequency multiplier to 48.
gpuManager.setMultiplier(48);

[...]

Change the minimum GPU frequency multiplier

When the temperature of the module reaches the hot trip point, Android sets the CPU and GPU frequencies to their minimums. When the temperature is 10 degrees below the hot trip point, Android configures the CPU and GPU frequencies to their previous values.

You can get and set the hot trip point temperature value using the getHotTemperature() and setHotTemperature(int) methods of the CPU service.

You can use the following methods to configure the minimum frequency multiplier value of the GPU:

Method Description

setMinMultiplier(int)

Sets the minimum frequency multiplier. It can range from 1 to 64.

This method returns the configured minimum frequency. If the operation was successful, it returns a value equal to the specified multiplier.

getMinMultiplier()

Gets the minimum frequency multiplier.

In some module variants, the minimum allowed frequency multiplier is greater than one. To ensure the new multiplier was successfully configured, compare the value returned by the setMinMultiplier(int) method with the desired value. They must be equal.

These methods may fail for the following reasons:

  • The specified multiplier is out of range, throwing an IllegalArgumentException.

  • An error occurs when setting or getting the multiplier, throwing an IOException.

Get and set the minimum frequency multiplier
import com.digi.android.system.gpu.GPUManager;

[...]

// Get the GPU manager.
GPUManager gpuManager = new GPUManager(context);

// Get the minimum frequency multiplier.
int minimumMultiplier = gpuManager.getMinMultiplier();

// Set the the minimum frequency multiplier to 2.
gpuManager.setMinMultiplier(2);

[...]

GPU example

Example: GPU management

The GPU Management Sample Application demonstrates the GPU API. In this example, you can modify the GPU frequency multiplier value with a slice bar and see how it impacts the GPU performance and temperature of the module.

You can import the example using Digi’s Android Studio plugin. For more information, see Import a Digi sample application. To look at the application source code, go to the GitHub repository .