upload android base code part4
This commit is contained in:
parent
b9e30e05b1
commit
78ea2404cd
23455 changed files with 5250148 additions and 0 deletions
|
@ -0,0 +1,66 @@
|
|||
/*
|
||||
* Copyright (C) 2007 The Android Open Source Project
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#ifndef ANDROID_AUDIO_HARDWARE_BASE_H
|
||||
#define ANDROID_AUDIO_HARDWARE_BASE_H
|
||||
|
||||
#include <hardware_legacy/AudioHardwareInterface.h>
|
||||
|
||||
#include <system/audio.h>
|
||||
|
||||
namespace android_audio_legacy {
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* AudioHardwareBase is a convenient base class used for implementing the
|
||||
* AudioHardwareInterface interface.
|
||||
*/
|
||||
class AudioHardwareBase : public AudioHardwareInterface
|
||||
{
|
||||
public:
|
||||
AudioHardwareBase();
|
||||
virtual ~AudioHardwareBase() { }
|
||||
|
||||
/**
|
||||
* setMode is called when the audio mode changes. NORMAL mode is for
|
||||
* standard audio playback, RINGTONE when a ringtone is playing, IN_CALL
|
||||
* when a telephony call is in progress, IN_COMMUNICATION when a VoIP call is in progress.
|
||||
*/
|
||||
virtual status_t setMode(int mode);
|
||||
|
||||
virtual status_t setParameters(const String8& keyValuePairs);
|
||||
virtual String8 getParameters(const String8& keys);
|
||||
|
||||
virtual size_t getInputBufferSize(uint32_t sampleRate, int format, int channelCount);
|
||||
virtual status_t getMasterVolume(float *volume);
|
||||
|
||||
/**This method dumps the state of the audio hardware */
|
||||
virtual status_t dumpState(int fd, const Vector<String16>& args);
|
||||
|
||||
protected:
|
||||
/** returns true if the given mode maps to a telephony or VoIP call is in progress */
|
||||
virtual bool isModeInCall(int mode)
|
||||
{ return ((mode == AudioSystem::MODE_IN_CALL)
|
||||
|| (mode == AudioSystem::MODE_IN_COMMUNICATION)); };
|
||||
/** returns true if a telephony or VoIP call is in progress */
|
||||
virtual bool isInCall() { return isModeInCall(mMode); };
|
||||
int mMode;
|
||||
};
|
||||
|
||||
}; // namespace android
|
||||
|
||||
#endif // ANDROID_AUDIO_HARDWARE_BASE_H
|
|
@ -0,0 +1,309 @@
|
|||
/*
|
||||
* Copyright (C) 2007 The Android Open Source Project
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#ifndef ANDROID_AUDIO_HARDWARE_INTERFACE_H
|
||||
#define ANDROID_AUDIO_HARDWARE_INTERFACE_H
|
||||
|
||||
#include <stdint.h>
|
||||
#include <sys/types.h>
|
||||
|
||||
#include <utils/Errors.h>
|
||||
#include <utils/Vector.h>
|
||||
#include <utils/String16.h>
|
||||
#include <utils/String8.h>
|
||||
|
||||
#include <media/IAudioFlinger.h>
|
||||
#include <hardware_legacy/AudioSystemLegacy.h>
|
||||
|
||||
#include <system/audio.h>
|
||||
#include <hardware/audio.h>
|
||||
|
||||
#include <cutils/bitops.h>
|
||||
|
||||
namespace android_audio_legacy {
|
||||
using android::Vector;
|
||||
using android::String16;
|
||||
using android::String8;
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* AudioStreamOut is the abstraction interface for the audio output hardware.
|
||||
*
|
||||
* It provides information about various properties of the audio output hardware driver.
|
||||
*/
|
||||
class AudioStreamOut {
|
||||
public:
|
||||
virtual ~AudioStreamOut() = 0;
|
||||
|
||||
/** return audio sampling rate in hz - eg. 44100 */
|
||||
virtual uint32_t sampleRate() const = 0;
|
||||
|
||||
/** returns size of output buffer - eg. 4800 */
|
||||
virtual size_t bufferSize() const = 0;
|
||||
|
||||
/**
|
||||
* returns the output channel mask
|
||||
*/
|
||||
virtual uint32_t channels() const = 0;
|
||||
|
||||
/**
|
||||
* return audio format in 8bit or 16bit PCM format -
|
||||
* eg. AudioSystem:PCM_16_BIT
|
||||
*/
|
||||
virtual int format() const = 0;
|
||||
|
||||
/**
|
||||
* return the frame size (number of bytes per sample).
|
||||
*/
|
||||
uint32_t frameSize() const { return audio_channel_count_from_out_mask(channels())*
|
||||
((format()==AUDIO_FORMAT_PCM_16_BIT)?sizeof(int16_t):sizeof(int8_t)); }
|
||||
|
||||
/**
|
||||
* return the audio hardware driver latency in milli seconds.
|
||||
*/
|
||||
virtual uint32_t latency() const = 0;
|
||||
|
||||
/**
|
||||
* Use this method in situations where audio mixing is done in the
|
||||
* hardware. This method serves as a direct interface with hardware,
|
||||
* allowing you to directly set the volume as apposed to via the framework.
|
||||
* This method might produce multiple PCM outputs or hardware accelerated
|
||||
* codecs, such as MP3 or AAC.
|
||||
*/
|
||||
virtual status_t setVolume(float left, float right) = 0;
|
||||
|
||||
/** write audio buffer to driver. Returns number of bytes written */
|
||||
virtual ssize_t write(const void* buffer, size_t bytes) = 0;
|
||||
|
||||
/**
|
||||
* Put the audio hardware output into standby mode. Returns
|
||||
* status based on include/utils/Errors.h
|
||||
*/
|
||||
virtual status_t standby() = 0;
|
||||
|
||||
/** dump the state of the audio output device */
|
||||
virtual status_t dump(int fd, const Vector<String16>& args) = 0;
|
||||
|
||||
// set/get audio output parameters. The function accepts a list of parameters
|
||||
// key value pairs in the form: key1=value1;key2=value2;...
|
||||
// Some keys are reserved for standard parameters (See AudioParameter class).
|
||||
// If the implementation does not accept a parameter change while the output is
|
||||
// active but the parameter is acceptable otherwise, it must return INVALID_OPERATION.
|
||||
// The audio flinger will put the output in standby and then change the parameter value.
|
||||
virtual status_t setParameters(const String8& keyValuePairs) = 0;
|
||||
virtual String8 getParameters(const String8& keys) = 0;
|
||||
|
||||
// return the number of audio frames written by the audio dsp to DAC since
|
||||
// the output has exited standby
|
||||
virtual status_t getRenderPosition(uint32_t *dspFrames) = 0;
|
||||
|
||||
/**
|
||||
* get the local time at which the next write to the audio driver will be
|
||||
* presented
|
||||
*/
|
||||
virtual status_t getNextWriteTimestamp(int64_t *timestamp);
|
||||
|
||||
/**
|
||||
* Return a recent count of the number of audio frames presented to an external observer.
|
||||
*/
|
||||
virtual status_t getPresentationPosition(uint64_t *frames, struct timespec *timestamp);
|
||||
|
||||
};
|
||||
|
||||
/**
|
||||
* AudioStreamIn is the abstraction interface for the audio input hardware.
|
||||
*
|
||||
* It defines the various properties of the audio hardware input driver.
|
||||
*/
|
||||
class AudioStreamIn {
|
||||
public:
|
||||
virtual ~AudioStreamIn() = 0;
|
||||
|
||||
/** return audio sampling rate in hz - eg. 44100 */
|
||||
virtual uint32_t sampleRate() const = 0;
|
||||
|
||||
/** return the input buffer size allowed by audio driver */
|
||||
virtual size_t bufferSize() const = 0;
|
||||
|
||||
/** return input channel mask */
|
||||
virtual uint32_t channels() const = 0;
|
||||
|
||||
/**
|
||||
* return audio format in 8bit or 16bit PCM format -
|
||||
* eg. AudioSystem:PCM_16_BIT
|
||||
*/
|
||||
virtual int format() const = 0;
|
||||
|
||||
/**
|
||||
* return the frame size (number of bytes per sample).
|
||||
*/
|
||||
uint32_t frameSize() const { return audio_channel_count_from_in_mask(channels())*
|
||||
((format()==AudioSystem::PCM_16_BIT)?sizeof(int16_t):sizeof(int8_t)); }
|
||||
|
||||
/** set the input gain for the audio driver. This method is for
|
||||
* for future use */
|
||||
virtual status_t setGain(float gain) = 0;
|
||||
|
||||
/** read audio buffer in from audio driver */
|
||||
virtual ssize_t read(void* buffer, ssize_t bytes) = 0;
|
||||
|
||||
/** dump the state of the audio input device */
|
||||
virtual status_t dump(int fd, const Vector<String16>& args) = 0;
|
||||
|
||||
/**
|
||||
* Put the audio hardware input into standby mode. Returns
|
||||
* status based on include/utils/Errors.h
|
||||
*/
|
||||
virtual status_t standby() = 0;
|
||||
|
||||
// set/get audio input parameters. The function accepts a list of parameters
|
||||
// key value pairs in the form: key1=value1;key2=value2;...
|
||||
// Some keys are reserved for standard parameters (See AudioParameter class).
|
||||
// If the implementation does not accept a parameter change while the output is
|
||||
// active but the parameter is acceptable otherwise, it must return INVALID_OPERATION.
|
||||
// The audio flinger will put the input in standby and then change the parameter value.
|
||||
virtual status_t setParameters(const String8& keyValuePairs) = 0;
|
||||
virtual String8 getParameters(const String8& keys) = 0;
|
||||
|
||||
|
||||
// Return the number of input frames lost in the audio driver since the last call of this function.
|
||||
// Audio driver is expected to reset the value to 0 and restart counting upon returning the current value by this function call.
|
||||
// Such loss typically occurs when the user space process is blocked longer than the capacity of audio driver buffers.
|
||||
// Unit: the number of input audio frames
|
||||
virtual unsigned int getInputFramesLost() const = 0;
|
||||
|
||||
virtual status_t addAudioEffect(effect_handle_t effect) = 0;
|
||||
virtual status_t removeAudioEffect(effect_handle_t effect) = 0;
|
||||
};
|
||||
|
||||
/**
|
||||
* AudioHardwareInterface.h defines the interface to the audio hardware abstraction layer.
|
||||
*
|
||||
* The interface supports setting and getting parameters, selecting audio routing
|
||||
* paths, and defining input and output streams.
|
||||
*
|
||||
* AudioFlinger initializes the audio hardware and immediately opens an output stream.
|
||||
* You can set Audio routing to output to handset, speaker, Bluetooth, or a headset.
|
||||
*
|
||||
* The audio input stream is initialized when AudioFlinger is called to carry out
|
||||
* a record operation.
|
||||
*/
|
||||
class AudioHardwareInterface
|
||||
{
|
||||
public:
|
||||
virtual ~AudioHardwareInterface() {}
|
||||
|
||||
/**
|
||||
* check to see if the audio hardware interface has been initialized.
|
||||
* return status based on values defined in include/utils/Errors.h
|
||||
*/
|
||||
virtual status_t initCheck() = 0;
|
||||
|
||||
/** set the audio volume of a voice call. Range is between 0.0 and 1.0 */
|
||||
virtual status_t setVoiceVolume(float volume) = 0;
|
||||
|
||||
/**
|
||||
* set the audio volume for all audio activities other than voice call.
|
||||
* Range between 0.0 and 1.0. If any value other than NO_ERROR is returned,
|
||||
* the software mixer will emulate this capability.
|
||||
*/
|
||||
virtual status_t setMasterVolume(float volume) = 0;
|
||||
|
||||
/**
|
||||
* Get the current master volume value for the HAL, if the HAL supports
|
||||
* master volume control. AudioFlinger will query this value from the
|
||||
* primary audio HAL when the service starts and use the value for setting
|
||||
* the initial master volume across all HALs.
|
||||
*/
|
||||
virtual status_t getMasterVolume(float *volume) = 0;
|
||||
|
||||
/**
|
||||
* setMode is called when the audio mode changes. NORMAL mode is for
|
||||
* standard audio playback, RINGTONE when a ringtone is playing, and IN_CALL
|
||||
* when a call is in progress.
|
||||
*/
|
||||
virtual status_t setMode(int mode) = 0;
|
||||
|
||||
// mic mute
|
||||
virtual status_t setMicMute(bool state) = 0;
|
||||
virtual status_t getMicMute(bool* state) = 0;
|
||||
|
||||
// set/get global audio parameters
|
||||
virtual status_t setParameters(const String8& keyValuePairs) = 0;
|
||||
virtual String8 getParameters(const String8& keys) = 0;
|
||||
|
||||
// Returns audio input buffer size according to parameters passed or 0 if one of the
|
||||
// parameters is not supported
|
||||
virtual size_t getInputBufferSize(uint32_t sampleRate, int format, int channelCount) = 0;
|
||||
|
||||
/** This method creates and opens the audio hardware output stream */
|
||||
virtual AudioStreamOut* openOutputStream(
|
||||
uint32_t devices,
|
||||
int *format=0,
|
||||
uint32_t *channels=0,
|
||||
uint32_t *sampleRate=0,
|
||||
status_t *status=0) = 0;
|
||||
virtual AudioStreamOut* openOutputStreamWithFlags(
|
||||
uint32_t devices,
|
||||
audio_output_flags_t flags=(audio_output_flags_t)0,
|
||||
int *format=0,
|
||||
uint32_t *channels=0,
|
||||
uint32_t *sampleRate=0,
|
||||
status_t *status=0) = 0;
|
||||
virtual void closeOutputStream(AudioStreamOut* out) = 0;
|
||||
|
||||
/** This method creates and opens the audio hardware input stream */
|
||||
virtual AudioStreamIn* openInputStream(
|
||||
uint32_t devices,
|
||||
int *format,
|
||||
uint32_t *channels,
|
||||
uint32_t *sampleRate,
|
||||
status_t *status,
|
||||
AudioSystem::audio_in_acoustics acoustics) = 0;
|
||||
virtual void closeInputStream(AudioStreamIn* in) = 0;
|
||||
|
||||
/**This method dumps the state of the audio hardware */
|
||||
virtual status_t dumpState(int fd, const Vector<String16>& args) = 0;
|
||||
|
||||
virtual status_t setMasterMute(bool muted) = 0;
|
||||
|
||||
static AudioHardwareInterface* create();
|
||||
|
||||
virtual int createAudioPatch(unsigned int num_sources,
|
||||
const struct audio_port_config *sources,
|
||||
unsigned int num_sinks,
|
||||
const struct audio_port_config *sinks,
|
||||
audio_patch_handle_t *handle) = 0;
|
||||
|
||||
virtual int releaseAudioPatch(audio_patch_handle_t handle) = 0;
|
||||
|
||||
virtual int getAudioPort(struct audio_port *port) = 0;
|
||||
|
||||
virtual int setAudioPortConfig(const struct audio_port_config *config) = 0;
|
||||
|
||||
protected:
|
||||
|
||||
virtual status_t dump(int fd, const Vector<String16>& args) = 0;
|
||||
};
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
extern "C" AudioHardwareInterface* createAudioHardware(void);
|
||||
|
||||
}; // namespace android
|
||||
|
||||
#endif // ANDROID_AUDIO_HARDWARE_INTERFACE_H
|
|
@ -0,0 +1,261 @@
|
|||
/*
|
||||
* Copyright (C) 2009 The Android Open Source Project
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#ifndef ANDROID_AUDIOPOLICYINTERFACE_H
|
||||
#define ANDROID_AUDIOPOLICYINTERFACE_H
|
||||
|
||||
#include <media/AudioSystem.h>
|
||||
#include <media/ToneGenerator.h>
|
||||
#include <utils/String8.h>
|
||||
|
||||
#include <hardware_legacy/AudioSystemLegacy.h>
|
||||
#include <hardware/audio_policy.h>
|
||||
|
||||
namespace android_audio_legacy {
|
||||
using android::Vector;
|
||||
using android::String8;
|
||||
using android::ToneGenerator;
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
// The AudioPolicyInterface and AudioPolicyClientInterface classes define the communication interfaces
|
||||
// between the platform specific audio policy manager and Android generic audio policy manager.
|
||||
// The platform specific audio policy manager must implement methods of the AudioPolicyInterface class.
|
||||
// This implementation makes use of the AudioPolicyClientInterface to control the activity and
|
||||
// configuration of audio input and output streams.
|
||||
//
|
||||
// The platform specific audio policy manager is in charge of the audio routing and volume control
|
||||
// policies for a given platform.
|
||||
// The main roles of this module are:
|
||||
// - keep track of current system state (removable device connections, phone state, user requests...).
|
||||
// System state changes and user actions are notified to audio policy manager with methods of the AudioPolicyInterface.
|
||||
// - process getOutput() queries received when AudioTrack objects are created: Those queries
|
||||
// return a handler on an output that has been selected, configured and opened by the audio policy manager and that
|
||||
// must be used by the AudioTrack when registering to the AudioFlinger with the createTrack() method.
|
||||
// When the AudioTrack object is released, a putOutput() query is received and the audio policy manager can decide
|
||||
// to close or reconfigure the output depending on other streams using this output and current system state.
|
||||
// - similarly process getInput() and putInput() queries received from AudioRecord objects and configure audio inputs.
|
||||
// - process volume control requests: the stream volume is converted from an index value (received from UI) to a float value
|
||||
// applicable to each output as a function of platform specific settings and current output route (destination device). It
|
||||
// also make sure that streams are not muted if not allowed (e.g. camera shutter sound in some countries).
|
||||
//
|
||||
// The platform specific audio policy manager is provided as a shared library by platform vendors (as for libaudio.so)
|
||||
// and is linked with libaudioflinger.so
|
||||
|
||||
|
||||
// Audio Policy Manager Interface
|
||||
class AudioPolicyInterface
|
||||
{
|
||||
|
||||
public:
|
||||
virtual ~AudioPolicyInterface() {}
|
||||
//
|
||||
// configuration functions
|
||||
//
|
||||
|
||||
// indicate a change in device connection status
|
||||
virtual status_t setDeviceConnectionState(audio_devices_t device,
|
||||
AudioSystem::device_connection_state state,
|
||||
const char *device_address) = 0;
|
||||
// retrieve a device connection status
|
||||
virtual AudioSystem::device_connection_state getDeviceConnectionState(audio_devices_t device,
|
||||
const char *device_address) = 0;
|
||||
// indicate a change in phone state. Valid phones states are defined by AudioSystem::audio_mode
|
||||
virtual void setPhoneState(int state) = 0;
|
||||
// force using a specific device category for the specified usage
|
||||
virtual void setForceUse(AudioSystem::force_use usage, AudioSystem::forced_config config) = 0;
|
||||
// retrieve current device category forced for a given usage
|
||||
virtual AudioSystem::forced_config getForceUse(AudioSystem::force_use usage) = 0;
|
||||
// set a system property (e.g. camera sound always audible)
|
||||
virtual void setSystemProperty(const char* property, const char* value) = 0;
|
||||
// check proper initialization
|
||||
virtual status_t initCheck() = 0;
|
||||
|
||||
//
|
||||
// Audio routing query functions
|
||||
//
|
||||
|
||||
// request an output appropriate for playback of the supplied stream type and parameters
|
||||
virtual audio_io_handle_t getOutput(AudioSystem::stream_type stream,
|
||||
uint32_t samplingRate,
|
||||
audio_format_t format,
|
||||
audio_channel_mask_t channelMask,
|
||||
AudioSystem::output_flags flags,
|
||||
const audio_offload_info_t *offloadInfo) = 0;
|
||||
// indicates to the audio policy manager that the output starts being used by corresponding stream.
|
||||
virtual status_t startOutput(audio_io_handle_t output,
|
||||
AudioSystem::stream_type stream,
|
||||
audio_session_t session = AUDIO_SESSION_NONE) = 0;
|
||||
// indicates to the audio policy manager that the output stops being used by corresponding stream.
|
||||
virtual status_t stopOutput(audio_io_handle_t output,
|
||||
AudioSystem::stream_type stream,
|
||||
audio_session_t session = AUDIO_SESSION_NONE) = 0;
|
||||
// releases the output.
|
||||
virtual void releaseOutput(audio_io_handle_t output) = 0;
|
||||
|
||||
// request an input appropriate for record from the supplied device with supplied parameters.
|
||||
virtual audio_io_handle_t getInput(int inputSource,
|
||||
uint32_t samplingRate,
|
||||
audio_format_t format,
|
||||
audio_channel_mask_t channelMask,
|
||||
AudioSystem::audio_in_acoustics acoustics) = 0;
|
||||
// indicates to the audio policy manager that the input starts being used.
|
||||
virtual status_t startInput(audio_io_handle_t input) = 0;
|
||||
// indicates to the audio policy manager that the input stops being used.
|
||||
virtual status_t stopInput(audio_io_handle_t input) = 0;
|
||||
// releases the input.
|
||||
virtual void releaseInput(audio_io_handle_t input) = 0;
|
||||
|
||||
//
|
||||
// volume control functions
|
||||
//
|
||||
|
||||
// initialises stream volume conversion parameters by specifying volume index range.
|
||||
virtual void initStreamVolume(AudioSystem::stream_type stream,
|
||||
int indexMin,
|
||||
int indexMax) = 0;
|
||||
|
||||
// sets the new stream volume at a level corresponding to the supplied index for the
|
||||
// supplied device. By convention, specifying AUDIO_DEVICE_OUT_DEFAULT means
|
||||
// setting volume for all devices
|
||||
virtual status_t setStreamVolumeIndex(AudioSystem::stream_type stream,
|
||||
int index,
|
||||
audio_devices_t device) = 0;
|
||||
|
||||
// retrieve current volume index for the specified stream and the
|
||||
// specified device. By convention, specifying AUDIO_DEVICE_OUT_DEFAULT means
|
||||
// querying the volume of the active device.
|
||||
virtual status_t getStreamVolumeIndex(AudioSystem::stream_type stream,
|
||||
int *index,
|
||||
audio_devices_t device) = 0;
|
||||
|
||||
// return the strategy corresponding to a given stream type
|
||||
virtual uint32_t getStrategyForStream(AudioSystem::stream_type stream) = 0;
|
||||
|
||||
// return the enabled output devices for the given stream type
|
||||
virtual audio_devices_t getDevicesForStream(AudioSystem::stream_type stream) = 0;
|
||||
|
||||
// Audio effect management
|
||||
virtual audio_io_handle_t getOutputForEffect(const effect_descriptor_t *desc) = 0;
|
||||
virtual status_t registerEffect(const effect_descriptor_t *desc,
|
||||
audio_io_handle_t io,
|
||||
uint32_t strategy,
|
||||
audio_session_t session,
|
||||
int id) = 0;
|
||||
virtual status_t unregisterEffect(int id) = 0;
|
||||
virtual status_t setEffectEnabled(int id, bool enabled) = 0;
|
||||
|
||||
virtual bool isStreamActive(int stream, uint32_t inPastMs = 0) const = 0;
|
||||
virtual bool isStreamActiveRemotely(int stream, uint32_t inPastMs = 0) const = 0;
|
||||
virtual bool isSourceActive(audio_source_t source) const = 0;
|
||||
|
||||
//dump state
|
||||
virtual status_t dump(int fd) = 0;
|
||||
|
||||
virtual bool isOffloadSupported(const audio_offload_info_t& offloadInfo) = 0;
|
||||
};
|
||||
|
||||
|
||||
// Audio Policy client Interface
|
||||
class AudioPolicyClientInterface
|
||||
{
|
||||
public:
|
||||
virtual ~AudioPolicyClientInterface() {}
|
||||
|
||||
//
|
||||
// Audio HW module functions
|
||||
//
|
||||
|
||||
// loads a HW module.
|
||||
virtual audio_module_handle_t loadHwModule(const char *name) = 0;
|
||||
|
||||
//
|
||||
// Audio output Control functions
|
||||
//
|
||||
|
||||
// opens an audio output with the requested parameters. The parameter values can indicate to use the default values
|
||||
// in case the audio policy manager has no specific requirements for the output being opened.
|
||||
// When the function returns, the parameter values reflect the actual values used by the audio hardware output stream.
|
||||
// The audio policy manager can check if the proposed parameters are suitable or not and act accordingly.
|
||||
virtual audio_io_handle_t openOutput(audio_module_handle_t module,
|
||||
audio_devices_t *pDevices,
|
||||
uint32_t *pSamplingRate,
|
||||
audio_format_t *pFormat,
|
||||
audio_channel_mask_t *pChannelMask,
|
||||
uint32_t *pLatencyMs,
|
||||
audio_output_flags_t flags,
|
||||
const audio_offload_info_t *offloadInfo = NULL) = 0;
|
||||
// creates a special output that is duplicated to the two outputs passed as arguments. The duplication is performed by
|
||||
// a special mixer thread in the AudioFlinger.
|
||||
virtual audio_io_handle_t openDuplicateOutput(audio_io_handle_t output1, audio_io_handle_t output2) = 0;
|
||||
// closes the output stream
|
||||
virtual status_t closeOutput(audio_io_handle_t output) = 0;
|
||||
// suspends the output. When an output is suspended, the corresponding audio hardware output stream is placed in
|
||||
// standby and the AudioTracks attached to the mixer thread are still processed but the output mix is discarded.
|
||||
virtual status_t suspendOutput(audio_io_handle_t output) = 0;
|
||||
// restores a suspended output.
|
||||
virtual status_t restoreOutput(audio_io_handle_t output) = 0;
|
||||
|
||||
//
|
||||
// Audio input Control functions
|
||||
//
|
||||
|
||||
// opens an audio input
|
||||
virtual audio_io_handle_t openInput(audio_module_handle_t module,
|
||||
audio_devices_t *pDevices,
|
||||
uint32_t *pSamplingRate,
|
||||
audio_format_t *pFormat,
|
||||
audio_channel_mask_t *pChannelMask) = 0;
|
||||
// closes an audio input
|
||||
virtual status_t closeInput(audio_io_handle_t input) = 0;
|
||||
//
|
||||
// misc control functions
|
||||
//
|
||||
|
||||
// set a stream volume for a particular output. For the same user setting, a given stream type can have different volumes
|
||||
// for each output (destination device) it is attached to.
|
||||
virtual status_t setStreamVolume(AudioSystem::stream_type stream, float volume, audio_io_handle_t output, int delayMs = 0) = 0;
|
||||
|
||||
// invalidate a stream type, causing a reroute to an unspecified new output
|
||||
virtual status_t invalidateStream(AudioSystem::stream_type stream) = 0;
|
||||
|
||||
// function enabling to send proprietary informations directly from audio policy manager to audio hardware interface.
|
||||
virtual void setParameters(audio_io_handle_t ioHandle, const String8& keyValuePairs, int delayMs = 0) = 0;
|
||||
// function enabling to receive proprietary informations directly from audio hardware interface to audio policy manager.
|
||||
virtual String8 getParameters(audio_io_handle_t ioHandle, const String8& keys) = 0;
|
||||
|
||||
// request the playback of a tone on the specified stream: used for instance to replace notification sounds when playing
|
||||
// over a telephony device during a phone call.
|
||||
virtual status_t startTone(ToneGenerator::tone_type tone, AudioSystem::stream_type stream) = 0;
|
||||
virtual status_t stopTone() = 0;
|
||||
|
||||
// set down link audio volume.
|
||||
virtual status_t setVoiceVolume(float volume, int delayMs = 0) = 0;
|
||||
|
||||
// move effect to the specified output
|
||||
virtual status_t moveEffects(audio_session_t session,
|
||||
audio_io_handle_t srcOutput,
|
||||
audio_io_handle_t dstOutput) = 0;
|
||||
|
||||
};
|
||||
|
||||
extern "C" AudioPolicyInterface* createAudioPolicyManager(AudioPolicyClientInterface *clientInterface);
|
||||
extern "C" void destroyAudioPolicyManager(AudioPolicyInterface *interface);
|
||||
|
||||
|
||||
}; // namespace android
|
||||
|
||||
#endif // ANDROID_AUDIOPOLICYINTERFACE_H
|
|
@ -0,0 +1,600 @@
|
|||
/*
|
||||
* Copyright (C) 2009 The Android Open Source Project
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
|
||||
#include <stdint.h>
|
||||
#include <sys/types.h>
|
||||
#include <cutils/config_utils.h>
|
||||
#include <cutils/misc.h>
|
||||
#include <utils/Timers.h>
|
||||
#include <utils/Errors.h>
|
||||
#include <utils/KeyedVector.h>
|
||||
#include <utils/SortedVector.h>
|
||||
#include <hardware_legacy/AudioPolicyInterface.h>
|
||||
|
||||
|
||||
namespace android_audio_legacy {
|
||||
using android::KeyedVector;
|
||||
using android::DefaultKeyedVector;
|
||||
using android::SortedVector;
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
#define MAX_DEVICE_ADDRESS_LEN 20
|
||||
// Attenuation applied to STRATEGY_SONIFICATION streams when a headset is connected: 6dB
|
||||
#define SONIFICATION_HEADSET_VOLUME_FACTOR 0.5
|
||||
// Min volume for STRATEGY_SONIFICATION streams when limited by music volume: -36dB
|
||||
#define SONIFICATION_HEADSET_VOLUME_MIN 0.016
|
||||
// Time in milliseconds during which we consider that music is still active after a music
|
||||
// track was stopped - see computeVolume()
|
||||
#define SONIFICATION_HEADSET_MUSIC_DELAY 5000
|
||||
// Time in milliseconds after media stopped playing during which we consider that the
|
||||
// sonification should be as unobtrusive as during the time media was playing.
|
||||
#define SONIFICATION_RESPECTFUL_AFTER_MUSIC_DELAY 5000
|
||||
// Time in milliseconds during witch some streams are muted while the audio path
|
||||
// is switched
|
||||
#define MUTE_TIME_MS 2000
|
||||
|
||||
#define NUM_TEST_OUTPUTS 5
|
||||
|
||||
#define NUM_VOL_CURVE_KNEES 2
|
||||
|
||||
// Default minimum length allowed for offloading a compressed track
|
||||
// Can be overridden by the audio.offload.min.duration.secs property
|
||||
#define OFFLOAD_DEFAULT_MIN_DURATION_SECS 60
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
// AudioPolicyManagerBase implements audio policy manager behavior common to all platforms.
|
||||
// Each platform must implement an AudioPolicyManager class derived from AudioPolicyManagerBase
|
||||
// and override methods for which the platform specific behavior differs from the implementation
|
||||
// in AudioPolicyManagerBase. Even if no specific behavior is required, the AudioPolicyManager
|
||||
// class must be implemented as well as the class factory function createAudioPolicyManager()
|
||||
// and provided in a shared library libaudiopolicy.so.
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
class AudioPolicyManagerBase: public AudioPolicyInterface
|
||||
#ifdef AUDIO_POLICY_TEST
|
||||
, public Thread
|
||||
#endif //AUDIO_POLICY_TEST
|
||||
{
|
||||
|
||||
public:
|
||||
AudioPolicyManagerBase(AudioPolicyClientInterface *clientInterface);
|
||||
virtual ~AudioPolicyManagerBase();
|
||||
|
||||
// AudioPolicyInterface
|
||||
virtual status_t setDeviceConnectionState(audio_devices_t device,
|
||||
AudioSystem::device_connection_state state,
|
||||
const char *device_address);
|
||||
virtual AudioSystem::device_connection_state getDeviceConnectionState(audio_devices_t device,
|
||||
const char *device_address);
|
||||
virtual void setPhoneState(int state);
|
||||
virtual void setForceUse(AudioSystem::force_use usage, AudioSystem::forced_config config);
|
||||
virtual AudioSystem::forced_config getForceUse(AudioSystem::force_use usage);
|
||||
virtual void setSystemProperty(const char* property, const char* value);
|
||||
virtual status_t initCheck();
|
||||
virtual audio_io_handle_t getOutput(AudioSystem::stream_type stream,
|
||||
uint32_t samplingRate,
|
||||
audio_format_t format,
|
||||
audio_channel_mask_t channelMask,
|
||||
AudioSystem::output_flags flags,
|
||||
const audio_offload_info_t *offloadInfo);
|
||||
virtual status_t startOutput(audio_io_handle_t output,
|
||||
AudioSystem::stream_type stream,
|
||||
audio_session_t session = AUDIO_SESSION_NONE);
|
||||
virtual status_t stopOutput(audio_io_handle_t output,
|
||||
AudioSystem::stream_type stream,
|
||||
audio_session_t session = AUDIO_SESSION_NONE);
|
||||
virtual void releaseOutput(audio_io_handle_t output);
|
||||
virtual audio_io_handle_t getInput(int inputSource,
|
||||
uint32_t samplingRate,
|
||||
audio_format_t format,
|
||||
audio_channel_mask_t channelMask,
|
||||
AudioSystem::audio_in_acoustics acoustics);
|
||||
|
||||
// indicates to the audio policy manager that the input starts being used.
|
||||
virtual status_t startInput(audio_io_handle_t input);
|
||||
|
||||
// indicates to the audio policy manager that the input stops being used.
|
||||
virtual status_t stopInput(audio_io_handle_t input);
|
||||
virtual void releaseInput(audio_io_handle_t input);
|
||||
virtual void closeAllInputs();
|
||||
virtual void initStreamVolume(AudioSystem::stream_type stream,
|
||||
int indexMin,
|
||||
int indexMax);
|
||||
virtual status_t setStreamVolumeIndex(AudioSystem::stream_type stream,
|
||||
int index,
|
||||
audio_devices_t device);
|
||||
virtual status_t getStreamVolumeIndex(AudioSystem::stream_type stream,
|
||||
int *index,
|
||||
audio_devices_t device);
|
||||
|
||||
// return the strategy corresponding to a given stream type
|
||||
virtual uint32_t getStrategyForStream(AudioSystem::stream_type stream);
|
||||
|
||||
// return the enabled output devices for the given stream type
|
||||
virtual audio_devices_t getDevicesForStream(AudioSystem::stream_type stream);
|
||||
|
||||
virtual audio_io_handle_t getOutputForEffect(const effect_descriptor_t *desc = NULL);
|
||||
virtual status_t registerEffect(const effect_descriptor_t *desc,
|
||||
audio_io_handle_t io,
|
||||
uint32_t strategy,
|
||||
audio_session_t session,
|
||||
int id);
|
||||
virtual status_t unregisterEffect(int id);
|
||||
virtual status_t setEffectEnabled(int id, bool enabled);
|
||||
|
||||
virtual bool isStreamActive(int stream, uint32_t inPastMs = 0) const;
|
||||
// return whether a stream is playing remotely, override to change the definition of
|
||||
// local/remote playback, used for instance by notification manager to not make
|
||||
// media players lose audio focus when not playing locally
|
||||
virtual bool isStreamActiveRemotely(int stream, uint32_t inPastMs = 0) const;
|
||||
virtual bool isSourceActive(audio_source_t source) const;
|
||||
|
||||
virtual status_t dump(int fd);
|
||||
|
||||
virtual bool isOffloadSupported(const audio_offload_info_t& offloadInfo);
|
||||
|
||||
protected:
|
||||
|
||||
enum routing_strategy {
|
||||
STRATEGY_MEDIA,
|
||||
STRATEGY_PHONE,
|
||||
STRATEGY_SONIFICATION,
|
||||
STRATEGY_SONIFICATION_RESPECTFUL,
|
||||
STRATEGY_DTMF,
|
||||
STRATEGY_ENFORCED_AUDIBLE,
|
||||
NUM_STRATEGIES
|
||||
};
|
||||
|
||||
// 4 points to define the volume attenuation curve, each characterized by the volume
|
||||
// index (from 0 to 100) at which they apply, and the attenuation in dB at that index.
|
||||
// we use 100 steps to avoid rounding errors when computing the volume in volIndexToAmpl()
|
||||
|
||||
enum { VOLMIN = 0, VOLKNEE1 = 1, VOLKNEE2 = 2, VOLMAX = 3, VOLCNT = 4};
|
||||
|
||||
class VolumeCurvePoint
|
||||
{
|
||||
public:
|
||||
int mIndex;
|
||||
float mDBAttenuation;
|
||||
};
|
||||
|
||||
// device categories used for volume curve management.
|
||||
enum device_category {
|
||||
DEVICE_CATEGORY_HEADSET,
|
||||
DEVICE_CATEGORY_SPEAKER,
|
||||
DEVICE_CATEGORY_EARPIECE,
|
||||
DEVICE_CATEGORY_CNT
|
||||
};
|
||||
|
||||
class IOProfile;
|
||||
|
||||
class HwModule {
|
||||
public:
|
||||
HwModule(const char *name);
|
||||
~HwModule();
|
||||
|
||||
void dump(int fd);
|
||||
|
||||
const char *const mName; // base name of the audio HW module (primary, a2dp ...)
|
||||
audio_module_handle_t mHandle;
|
||||
Vector <IOProfile *> mOutputProfiles; // output profiles exposed by this module
|
||||
Vector <IOProfile *> mInputProfiles; // input profiles exposed by this module
|
||||
};
|
||||
|
||||
// the IOProfile class describes the capabilities of an output or input stream.
|
||||
// It is currently assumed that all combination of listed parameters are supported.
|
||||
// It is used by the policy manager to determine if an output or input is suitable for
|
||||
// a given use case, open/close it accordingly and connect/disconnect audio tracks
|
||||
// to/from it.
|
||||
class IOProfile
|
||||
{
|
||||
public:
|
||||
IOProfile(HwModule *module);
|
||||
~IOProfile();
|
||||
|
||||
bool isCompatibleProfile(audio_devices_t device,
|
||||
uint32_t samplingRate,
|
||||
audio_format_t format,
|
||||
audio_channel_mask_t channelMask,
|
||||
audio_output_flags_t flags) const;
|
||||
|
||||
void dump(int fd);
|
||||
void log();
|
||||
|
||||
// by convention, "0' in the first entry in mSamplingRates, mChannelMasks or mFormats
|
||||
// indicates the supported parameters should be read from the output stream
|
||||
// after it is opened for the first time
|
||||
Vector <uint32_t> mSamplingRates; // supported sampling rates
|
||||
Vector <audio_channel_mask_t> mChannelMasks; // supported channel masks
|
||||
Vector <audio_format_t> mFormats; // supported audio formats
|
||||
audio_devices_t mSupportedDevices; // supported devices (devices this output can be
|
||||
// routed to)
|
||||
audio_output_flags_t mFlags; // attribute flags (e.g primary output,
|
||||
// direct output...). For outputs only.
|
||||
HwModule *mModule; // audio HW module exposing this I/O stream
|
||||
};
|
||||
|
||||
// default volume curve
|
||||
static const VolumeCurvePoint sDefaultVolumeCurve[AudioPolicyManagerBase::VOLCNT];
|
||||
// default volume curve for media strategy
|
||||
static const VolumeCurvePoint sDefaultMediaVolumeCurve[AudioPolicyManagerBase::VOLCNT];
|
||||
// volume curve for media strategy on speakers
|
||||
static const VolumeCurvePoint sSpeakerMediaVolumeCurve[AudioPolicyManagerBase::VOLCNT];
|
||||
// volume curve for sonification strategy on speakers
|
||||
static const VolumeCurvePoint sSpeakerSonificationVolumeCurve[AudioPolicyManagerBase::VOLCNT];
|
||||
static const VolumeCurvePoint sSpeakerSonificationVolumeCurveDrc[AudioPolicyManagerBase::VOLCNT];
|
||||
static const VolumeCurvePoint sDefaultSystemVolumeCurve[AudioPolicyManagerBase::VOLCNT];
|
||||
static const VolumeCurvePoint sDefaultSystemVolumeCurveDrc[AudioPolicyManagerBase::VOLCNT];
|
||||
static const VolumeCurvePoint sHeadsetSystemVolumeCurve[AudioPolicyManagerBase::VOLCNT];
|
||||
static const VolumeCurvePoint sDefaultVoiceVolumeCurve[AudioPolicyManagerBase::VOLCNT];
|
||||
static const VolumeCurvePoint sSpeakerVoiceVolumeCurve[AudioPolicyManagerBase::VOLCNT];
|
||||
// default volume curves per stream and device category. See initializeVolumeCurves()
|
||||
static const VolumeCurvePoint *sVolumeProfiles[AudioSystem::NUM_STREAM_TYPES][DEVICE_CATEGORY_CNT];
|
||||
|
||||
// descriptor for audio outputs. Used to maintain current configuration of each opened audio output
|
||||
// and keep track of the usage of this output by each audio stream type.
|
||||
class AudioOutputDescriptor
|
||||
{
|
||||
public:
|
||||
AudioOutputDescriptor(const IOProfile *profile);
|
||||
|
||||
status_t dump(int fd);
|
||||
|
||||
audio_devices_t device() const;
|
||||
void changeRefCount(AudioSystem::stream_type stream, int delta);
|
||||
|
||||
bool isDuplicated() const { return (mOutput1 != NULL && mOutput2 != NULL); }
|
||||
audio_devices_t supportedDevices();
|
||||
uint32_t latency();
|
||||
bool sharesHwModuleWith(const AudioOutputDescriptor *outputDesc);
|
||||
bool isActive(uint32_t inPastMs = 0) const;
|
||||
bool isStreamActive(AudioSystem::stream_type stream,
|
||||
uint32_t inPastMs = 0,
|
||||
nsecs_t sysTime = 0) const;
|
||||
bool isStrategyActive(routing_strategy strategy,
|
||||
uint32_t inPastMs = 0,
|
||||
nsecs_t sysTime = 0) const;
|
||||
|
||||
audio_io_handle_t mId; // output handle
|
||||
uint32_t mSamplingRate; //
|
||||
audio_format_t mFormat; //
|
||||
audio_channel_mask_t mChannelMask; // output configuration
|
||||
uint32_t mLatency; //
|
||||
audio_output_flags_t mFlags; //
|
||||
audio_devices_t mDevice; // current device this output is routed to
|
||||
uint32_t mRefCount[AudioSystem::NUM_STREAM_TYPES]; // number of streams of each type using this output
|
||||
nsecs_t mStopTime[AudioSystem::NUM_STREAM_TYPES];
|
||||
AudioOutputDescriptor *mOutput1; // used by duplicated outputs: first output
|
||||
AudioOutputDescriptor *mOutput2; // used by duplicated outputs: second output
|
||||
float mCurVolume[AudioSystem::NUM_STREAM_TYPES]; // current stream volume
|
||||
int mMuteCount[AudioSystem::NUM_STREAM_TYPES]; // mute request counter
|
||||
const IOProfile *mProfile; // I/O profile this output derives from
|
||||
bool mStrategyMutedByDevice[NUM_STRATEGIES]; // strategies muted because of incompatible
|
||||
// device selection. See checkDeviceMuteStrategies()
|
||||
uint32_t mDirectOpenCount; // number of clients using this output (direct outputs only)
|
||||
bool mForceRouting; // Next routing for this output will be forced as current device routed is null
|
||||
};
|
||||
|
||||
// descriptor for audio inputs. Used to maintain current configuration of each opened audio input
|
||||
// and keep track of the usage of this input.
|
||||
class AudioInputDescriptor
|
||||
{
|
||||
public:
|
||||
AudioInputDescriptor(const IOProfile *profile);
|
||||
|
||||
status_t dump(int fd);
|
||||
|
||||
audio_io_handle_t mId; // input handle
|
||||
uint32_t mSamplingRate; //
|
||||
audio_format_t mFormat; // input configuration
|
||||
audio_channel_mask_t mChannelMask; //
|
||||
audio_devices_t mDevice; // current device this input is routed to
|
||||
uint32_t mRefCount; // number of AudioRecord clients using this output
|
||||
int mInputSource; // input source selected by application (mediarecorder.h)
|
||||
const IOProfile *mProfile; // I/O profile this output derives from
|
||||
};
|
||||
|
||||
// stream descriptor used for volume control
|
||||
class StreamDescriptor
|
||||
{
|
||||
public:
|
||||
StreamDescriptor();
|
||||
|
||||
int getVolumeIndex(audio_devices_t device);
|
||||
void dump(int fd);
|
||||
|
||||
int mIndexMin; // min volume index
|
||||
int mIndexMax; // max volume index
|
||||
KeyedVector<audio_devices_t, int> mIndexCur; // current volume index per device
|
||||
bool mCanBeMuted; // true is the stream can be muted
|
||||
|
||||
const VolumeCurvePoint *mVolumeCurve[DEVICE_CATEGORY_CNT];
|
||||
};
|
||||
|
||||
// stream descriptor used for volume control
|
||||
class EffectDescriptor
|
||||
{
|
||||
public:
|
||||
|
||||
status_t dump(int fd);
|
||||
|
||||
int mIo; // io the effect is attached to
|
||||
routing_strategy mStrategy; // routing strategy the effect is associated to
|
||||
audio_session_t mSession; // audio session the effect is on
|
||||
effect_descriptor_t mDesc; // effect descriptor
|
||||
bool mEnabled; // enabled state: CPU load being used or not
|
||||
};
|
||||
|
||||
void addOutput(audio_io_handle_t id, AudioOutputDescriptor *outputDesc);
|
||||
void addInput(audio_io_handle_t id, AudioInputDescriptor *inputDesc);
|
||||
|
||||
// return the strategy corresponding to a given stream type
|
||||
static routing_strategy getStrategy(AudioSystem::stream_type stream);
|
||||
|
||||
// return appropriate device for streams handled by the specified strategy according to current
|
||||
// phone state, connected devices...
|
||||
// if fromCache is true, the device is returned from mDeviceForStrategy[],
|
||||
// otherwise it is determine by current state
|
||||
// (device connected,phone state, force use, a2dp output...)
|
||||
// This allows to:
|
||||
// 1 speed up process when the state is stable (when starting or stopping an output)
|
||||
// 2 access to either current device selection (fromCache == true) or
|
||||
// "future" device selection (fromCache == false) when called from a context
|
||||
// where conditions are changing (setDeviceConnectionState(), setPhoneState()...) AND
|
||||
// before updateDevicesAndOutputs() is called.
|
||||
virtual audio_devices_t getDeviceForStrategy(routing_strategy strategy,
|
||||
bool fromCache);
|
||||
|
||||
// change the route of the specified output. Returns the number of ms we have slept to
|
||||
// allow new routing to take effect in certain cases.
|
||||
uint32_t setOutputDevice(audio_io_handle_t output,
|
||||
audio_devices_t device,
|
||||
bool force = false,
|
||||
int delayMs = 0);
|
||||
|
||||
// select input device corresponding to requested audio source
|
||||
virtual audio_devices_t getDeviceForInputSource(int inputSource);
|
||||
|
||||
// return io handle of active input or 0 if no input is active
|
||||
// Only considers inputs from physical devices (e.g. main mic, headset mic) when
|
||||
// ignoreVirtualInputs is true.
|
||||
audio_io_handle_t getActiveInput(bool ignoreVirtualInputs = true);
|
||||
|
||||
// initialize volume curves for each strategy and device category
|
||||
void initializeVolumeCurves();
|
||||
|
||||
// compute the actual volume for a given stream according to the requested index and a particular
|
||||
// device
|
||||
virtual float computeVolume(int stream, int index, audio_io_handle_t output, audio_devices_t device);
|
||||
|
||||
// check that volume change is permitted, compute and send new volume to audio hardware
|
||||
status_t checkAndSetVolume(int stream, int index, audio_io_handle_t output, audio_devices_t device, int delayMs = 0, bool force = false);
|
||||
|
||||
// apply all stream volumes to the specified output and device
|
||||
void applyStreamVolumes(audio_io_handle_t output, audio_devices_t device, int delayMs = 0, bool force = false);
|
||||
|
||||
// Mute or unmute all streams handled by the specified strategy on the specified output
|
||||
void setStrategyMute(routing_strategy strategy,
|
||||
bool on,
|
||||
audio_io_handle_t output,
|
||||
int delayMs = 0,
|
||||
audio_devices_t device = (audio_devices_t)0);
|
||||
|
||||
// Mute or unmute the stream on the specified output
|
||||
void setStreamMute(int stream,
|
||||
bool on,
|
||||
audio_io_handle_t output,
|
||||
int delayMs = 0,
|
||||
audio_devices_t device = (audio_devices_t)0);
|
||||
|
||||
// handle special cases for sonification strategy while in call: mute streams or replace by
|
||||
// a special tone in the device used for communication
|
||||
void handleIncallSonification(int stream, bool starting, bool stateChange);
|
||||
|
||||
// true if device is in a telephony or VoIP call
|
||||
virtual bool isInCall();
|
||||
|
||||
// true if given state represents a device in a telephony or VoIP call
|
||||
virtual bool isStateInCall(int state);
|
||||
|
||||
// when a device is connected, checks if an open output can be routed
|
||||
// to this device. If none is open, tries to open one of the available outputs.
|
||||
// Returns an output suitable to this device or 0.
|
||||
// when a device is disconnected, checks if an output is not used any more and
|
||||
// returns its handle if any.
|
||||
// transfers the audio tracks and effects from one output thread to another accordingly.
|
||||
status_t checkOutputsForDevice(audio_devices_t device,
|
||||
AudioSystem::device_connection_state state,
|
||||
SortedVector<audio_io_handle_t>& outputs,
|
||||
const String8 paramStr);
|
||||
|
||||
status_t checkInputsForDevice(audio_devices_t device,
|
||||
AudioSystem::device_connection_state state,
|
||||
SortedVector<audio_io_handle_t>& inputs,
|
||||
const String8 paramStr);
|
||||
|
||||
// close an output and its companion duplicating output.
|
||||
void closeOutput(audio_io_handle_t output);
|
||||
|
||||
// checks and if necessary changes outputs used for all strategies.
|
||||
// must be called every time a condition that affects the output choice for a given strategy
|
||||
// changes: connected device, phone state, force use...
|
||||
// Must be called before updateDevicesAndOutputs()
|
||||
void checkOutputForStrategy(routing_strategy strategy);
|
||||
|
||||
// Same as checkOutputForStrategy() but for a all strategies in order of priority
|
||||
void checkOutputForAllStrategies();
|
||||
|
||||
// manages A2DP output suspend/restore according to phone state and BT SCO usage
|
||||
void checkA2dpSuspend();
|
||||
|
||||
// returns the A2DP output handle if it is open or 0 otherwise
|
||||
audio_io_handle_t getA2dpOutput();
|
||||
|
||||
// selects the most appropriate device on output for current state
|
||||
// must be called every time a condition that affects the device choice for a given output is
|
||||
// changed: connected device, phone state, force use, output start, output stop..
|
||||
// see getDeviceForStrategy() for the use of fromCache parameter
|
||||
|
||||
audio_devices_t getNewDevice(audio_io_handle_t output, bool fromCache);
|
||||
// updates cache of device used by all strategies (mDeviceForStrategy[])
|
||||
// must be called every time a condition that affects the device choice for a given strategy is
|
||||
// changed: connected device, phone state, force use...
|
||||
// cached values are used by getDeviceForStrategy() if parameter fromCache is true.
|
||||
// Must be called after checkOutputForAllStrategies()
|
||||
|
||||
void updateDevicesAndOutputs();
|
||||
|
||||
virtual uint32_t getMaxEffectsCpuLoad();
|
||||
virtual uint32_t getMaxEffectsMemory();
|
||||
#ifdef AUDIO_POLICY_TEST
|
||||
virtual bool threadLoop();
|
||||
void exit();
|
||||
int testOutputIndex(audio_io_handle_t output);
|
||||
#endif //AUDIO_POLICY_TEST
|
||||
|
||||
status_t setEffectEnabled(EffectDescriptor *pDesc, bool enabled);
|
||||
|
||||
// returns the category the device belongs to with regard to volume curve management
|
||||
static device_category getDeviceCategory(audio_devices_t device);
|
||||
|
||||
// extract one device relevant for volume control from multiple device selection
|
||||
static audio_devices_t getDeviceForVolume(audio_devices_t device);
|
||||
|
||||
SortedVector<audio_io_handle_t> getOutputsForDevice(audio_devices_t device,
|
||||
DefaultKeyedVector<audio_io_handle_t, AudioOutputDescriptor *> openOutputs);
|
||||
bool vectorsEqual(SortedVector<audio_io_handle_t>& outputs1,
|
||||
SortedVector<audio_io_handle_t>& outputs2);
|
||||
|
||||
// mute/unmute strategies using an incompatible device combination
|
||||
// if muting, wait for the audio in pcm buffer to be drained before proceeding
|
||||
// if unmuting, unmute only after the specified delay
|
||||
// Returns the number of ms waited
|
||||
uint32_t checkDeviceMuteStrategies(AudioOutputDescriptor *outputDesc,
|
||||
audio_devices_t prevDevice,
|
||||
uint32_t delayMs);
|
||||
|
||||
audio_io_handle_t selectOutput(const SortedVector<audio_io_handle_t>& outputs,
|
||||
AudioSystem::output_flags flags);
|
||||
IOProfile *getInputProfile(audio_devices_t device,
|
||||
uint32_t samplingRate,
|
||||
audio_format_t format,
|
||||
audio_channel_mask_t channelMask);
|
||||
IOProfile *getProfileForDirectOutput(audio_devices_t device,
|
||||
uint32_t samplingRate,
|
||||
audio_format_t format,
|
||||
audio_channel_mask_t channelMask,
|
||||
audio_output_flags_t flags);
|
||||
|
||||
audio_io_handle_t selectOutputForEffects(const SortedVector<audio_io_handle_t>& outputs);
|
||||
|
||||
bool isNonOffloadableEffectEnabled();
|
||||
|
||||
//
|
||||
// Audio policy configuration file parsing (audio_policy.conf)
|
||||
//
|
||||
static uint32_t stringToEnum(const struct StringToEnum *table,
|
||||
size_t size,
|
||||
const char *name);
|
||||
static bool stringToBool(const char *value);
|
||||
static audio_output_flags_t parseFlagNames(char *name);
|
||||
static audio_devices_t parseDeviceNames(char *name);
|
||||
void loadSamplingRates(char *name, IOProfile *profile);
|
||||
void loadFormats(char *name, IOProfile *profile);
|
||||
void loadOutChannels(char *name, IOProfile *profile);
|
||||
void loadInChannels(char *name, IOProfile *profile);
|
||||
status_t loadOutput(cnode *root, HwModule *module);
|
||||
status_t loadInput(cnode *root, HwModule *module);
|
||||
void loadHwModule(cnode *root);
|
||||
void loadHwModules(cnode *root);
|
||||
void loadGlobalConfig(cnode *root);
|
||||
status_t loadAudioPolicyConfig(const char *path);
|
||||
void defaultAudioPolicyConfig(void);
|
||||
|
||||
|
||||
AudioPolicyClientInterface *mpClientInterface; // audio policy client interface
|
||||
audio_io_handle_t mPrimaryOutput; // primary output handle
|
||||
// list of descriptors for outputs currently opened
|
||||
DefaultKeyedVector<audio_io_handle_t, AudioOutputDescriptor *> mOutputs;
|
||||
// copy of mOutputs before setDeviceConnectionState() opens new outputs
|
||||
// reset to mOutputs when updateDevicesAndOutputs() is called.
|
||||
DefaultKeyedVector<audio_io_handle_t, AudioOutputDescriptor *> mPreviousOutputs;
|
||||
|
||||
// list of input descriptors currently opened
|
||||
DefaultKeyedVector<audio_io_handle_t, AudioInputDescriptor *> mInputs;
|
||||
|
||||
audio_devices_t mAvailableOutputDevices; // bit field of all available output devices
|
||||
audio_devices_t mAvailableInputDevices; // bit field of all available input devices
|
||||
// without AUDIO_DEVICE_BIT_IN to allow direct bit
|
||||
// field comparisons
|
||||
int mPhoneState; // current phone state
|
||||
AudioSystem::forced_config mForceUse[AudioSystem::NUM_FORCE_USE]; // current forced use configuration
|
||||
|
||||
StreamDescriptor mStreams[AudioSystem::NUM_STREAM_TYPES]; // stream descriptors for volume control
|
||||
String8 mA2dpDeviceAddress; // A2DP device MAC address
|
||||
String8 mScoDeviceAddress; // SCO device MAC address
|
||||
String8 mUsbOutCardAndDevice; // USB audio ALSA card and device numbers:
|
||||
// card=<card_number>;device=<><device_number>
|
||||
bool mLimitRingtoneVolume; // limit ringtone volume to music volume if headset connected
|
||||
audio_devices_t mDeviceForStrategy[NUM_STRATEGIES];
|
||||
float mLastVoiceVolume; // last voice volume value sent to audio HAL
|
||||
|
||||
// Maximum CPU load allocated to audio effects in 0.1 MIPS (ARMv5TE, 0 WS memory) units
|
||||
static const uint32_t MAX_EFFECTS_CPU_LOAD = 1000;
|
||||
// Maximum memory allocated to audio effects in KB
|
||||
static const uint32_t MAX_EFFECTS_MEMORY = 512;
|
||||
uint32_t mTotalEffectsCpuLoad; // current CPU load used by effects
|
||||
uint32_t mTotalEffectsMemory; // current memory used by effects
|
||||
KeyedVector<int, EffectDescriptor *> mEffects; // list of registered audio effects
|
||||
bool mA2dpSuspended; // true if A2DP output is suspended
|
||||
bool mHasA2dp; // true on platforms with support for bluetooth A2DP
|
||||
bool mHasUsb; // true on platforms with support for USB audio
|
||||
bool mHasRemoteSubmix; // true on platforms with support for remote presentation of a submix
|
||||
audio_devices_t mAttachedOutputDevices; // output devices always available on the platform
|
||||
audio_devices_t mDefaultOutputDevice; // output device selected by default at boot time
|
||||
// (must be in mAttachedOutputDevices)
|
||||
bool mSpeakerDrcEnabled;// true on devices that use DRC on the DEVICE_CATEGORY_SPEAKER path
|
||||
// to boost soft sounds, used to adjust volume curves accordingly
|
||||
|
||||
Vector <HwModule *> mHwModules;
|
||||
|
||||
#ifdef AUDIO_POLICY_TEST
|
||||
Mutex mLock;
|
||||
Condition mWaitWorkCV;
|
||||
|
||||
int mCurOutput;
|
||||
bool mDirectOutput;
|
||||
audio_io_handle_t mTestOutputs[NUM_TEST_OUTPUTS];
|
||||
int mTestInput;
|
||||
uint32_t mTestDevice;
|
||||
uint32_t mTestSamplingRate;
|
||||
uint32_t mTestFormat;
|
||||
uint32_t mTestChannels;
|
||||
uint32_t mTestLatencyMs;
|
||||
#endif //AUDIO_POLICY_TEST
|
||||
|
||||
private:
|
||||
static float volIndexToAmpl(audio_devices_t device, const StreamDescriptor& streamDesc,
|
||||
int indexInUi);
|
||||
// updates device caching and output for streams that can influence the
|
||||
// routing of notifications
|
||||
void handleNotificationRoutingForStream(AudioSystem::stream_type stream);
|
||||
static bool isVirtualInputDevice(audio_devices_t device);
|
||||
};
|
||||
|
||||
};
|
|
@ -0,0 +1,362 @@
|
|||
/*
|
||||
* Copyright (C) 2008 The Android Open Source Project
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#ifndef ANDROID_AUDIOSYSTEM_LEGACY_H_
|
||||
#define ANDROID_AUDIOSYSTEM_LEGACY_H_
|
||||
|
||||
#include <utils/Errors.h>
|
||||
#include <media/AudioParameter.h>
|
||||
|
||||
#include <system/audio.h>
|
||||
#include <system/audio_policy.h>
|
||||
|
||||
namespace android_audio_legacy {
|
||||
|
||||
using android::status_t;
|
||||
using android::AudioParameter;
|
||||
|
||||
enum {
|
||||
OK = android::OK,
|
||||
NO_ERROR = android::NO_ERROR,
|
||||
|
||||
UNKNOWN_ERROR = android::UNKNOWN_ERROR,
|
||||
|
||||
NO_MEMORY = android::NO_MEMORY,
|
||||
INVALID_OPERATION = android::INVALID_OPERATION,
|
||||
BAD_VALUE = android::BAD_VALUE,
|
||||
BAD_TYPE = android::BAD_TYPE,
|
||||
NAME_NOT_FOUND = android::NAME_NOT_FOUND,
|
||||
PERMISSION_DENIED = android::PERMISSION_DENIED,
|
||||
NO_INIT = android::NO_INIT,
|
||||
ALREADY_EXISTS = android::ALREADY_EXISTS,
|
||||
DEAD_OBJECT = android::DEAD_OBJECT,
|
||||
FAILED_TRANSACTION = android::FAILED_TRANSACTION,
|
||||
BAD_INDEX = android::BAD_INDEX,
|
||||
NOT_ENOUGH_DATA = android::NOT_ENOUGH_DATA,
|
||||
WOULD_BLOCK = android::WOULD_BLOCK,
|
||||
TIMED_OUT = android::TIMED_OUT,
|
||||
UNKNOWN_TRANSACTION = android::UNKNOWN_TRANSACTION,
|
||||
};
|
||||
|
||||
enum audio_source {
|
||||
AUDIO_SOURCE_DEFAULT = 0,
|
||||
AUDIO_SOURCE_MIC = 1,
|
||||
AUDIO_SOURCE_VOICE_UPLINK = 2,
|
||||
AUDIO_SOURCE_VOICE_DOWNLINK = 3,
|
||||
AUDIO_SOURCE_VOICE_CALL = 4,
|
||||
AUDIO_SOURCE_CAMCORDER = 5,
|
||||
AUDIO_SOURCE_VOICE_RECOGNITION = 6,
|
||||
AUDIO_SOURCE_VOICE_COMMUNICATION = 7,
|
||||
AUDIO_SOURCE_MAX = AUDIO_SOURCE_VOICE_COMMUNICATION,
|
||||
|
||||
AUDIO_SOURCE_LIST_END // must be last - used to validate audio source type
|
||||
};
|
||||
|
||||
class AudioSystem {
|
||||
public:
|
||||
#if 1
|
||||
enum stream_type {
|
||||
DEFAULT =-1,
|
||||
VOICE_CALL = 0,
|
||||
SYSTEM = 1,
|
||||
RING = 2,
|
||||
MUSIC = 3,
|
||||
ALARM = 4,
|
||||
NOTIFICATION = 5,
|
||||
BLUETOOTH_SCO = 6,
|
||||
ENFORCED_AUDIBLE = 7, // Sounds that cannot be muted by user and must be routed to speaker
|
||||
DTMF = 8,
|
||||
TTS = 9,
|
||||
NUM_STREAM_TYPES
|
||||
};
|
||||
|
||||
// Audio sub formats (see AudioSystem::audio_format).
|
||||
enum pcm_sub_format {
|
||||
PCM_SUB_16_BIT = 0x1, // must be 1 for backward compatibility
|
||||
PCM_SUB_8_BIT = 0x2, // must be 2 for backward compatibility
|
||||
};
|
||||
|
||||
enum audio_sessions {
|
||||
SESSION_OUTPUT_STAGE = AUDIO_SESSION_OUTPUT_STAGE,
|
||||
SESSION_OUTPUT_MIX = AUDIO_SESSION_OUTPUT_MIX,
|
||||
};
|
||||
|
||||
// MP3 sub format field definition : can use 11 LSBs in the same way as MP3 frame header to specify
|
||||
// bit rate, stereo mode, version...
|
||||
enum mp3_sub_format {
|
||||
//TODO
|
||||
};
|
||||
|
||||
// AMR NB/WB sub format field definition: specify frame block interleaving, bandwidth efficient or octet aligned,
|
||||
// encoding mode for recording...
|
||||
enum amr_sub_format {
|
||||
//TODO
|
||||
};
|
||||
|
||||
// AAC sub format field definition: specify profile or bitrate for recording...
|
||||
enum aac_sub_format {
|
||||
//TODO
|
||||
};
|
||||
|
||||
// VORBIS sub format field definition: specify quality for recording...
|
||||
enum vorbis_sub_format {
|
||||
//TODO
|
||||
};
|
||||
|
||||
// Audio format consists in a main format field (upper 8 bits) and a sub format field (lower 24 bits).
|
||||
// The main format indicates the main codec type. The sub format field indicates options and parameters
|
||||
// for each format. The sub format is mainly used for record to indicate for instance the requested bitrate
|
||||
// or profile. It can also be used for certain formats to give informations not present in the encoded
|
||||
// audio stream (e.g. octet alignement for AMR).
|
||||
enum audio_format {
|
||||
INVALID_FORMAT = -1,
|
||||
FORMAT_DEFAULT = 0,
|
||||
PCM = 0x00000000, // must be 0 for backward compatibility
|
||||
MP3 = 0x01000000,
|
||||
AMR_NB = 0x02000000,
|
||||
AMR_WB = 0x03000000,
|
||||
AAC = 0x04000000,
|
||||
HE_AAC_V1 = 0x05000000,
|
||||
HE_AAC_V2 = 0x06000000,
|
||||
VORBIS = 0x07000000,
|
||||
MAIN_FORMAT_MASK = 0xFF000000,
|
||||
SUB_FORMAT_MASK = 0x00FFFFFF,
|
||||
// Aliases
|
||||
PCM_16_BIT = (PCM|PCM_SUB_16_BIT),
|
||||
PCM_8_BIT = (PCM|PCM_SUB_8_BIT)
|
||||
};
|
||||
|
||||
enum audio_channels {
|
||||
// output channels
|
||||
CHANNEL_OUT_FRONT_LEFT = 0x1,
|
||||
CHANNEL_OUT_FRONT_RIGHT = 0x2,
|
||||
CHANNEL_OUT_FRONT_CENTER = 0x4,
|
||||
CHANNEL_OUT_LOW_FREQUENCY = 0x8,
|
||||
CHANNEL_OUT_BACK_LEFT = 0x10,
|
||||
CHANNEL_OUT_BACK_RIGHT = 0x20,
|
||||
CHANNEL_OUT_FRONT_LEFT_OF_CENTER = 0x40,
|
||||
CHANNEL_OUT_FRONT_RIGHT_OF_CENTER = 0x80,
|
||||
CHANNEL_OUT_BACK_CENTER = 0x100,
|
||||
CHANNEL_OUT_SIDE_LEFT = 0x200,
|
||||
CHANNEL_OUT_SIDE_RIGHT = 0x400,
|
||||
CHANNEL_OUT_TOP_CENTER = 0x800,
|
||||
CHANNEL_OUT_TOP_FRONT_LEFT = 0x1000,
|
||||
CHANNEL_OUT_TOP_FRONT_CENTER = 0x2000,
|
||||
CHANNEL_OUT_TOP_FRONT_RIGHT = 0x4000,
|
||||
CHANNEL_OUT_TOP_BACK_LEFT = 0x8000,
|
||||
CHANNEL_OUT_TOP_BACK_CENTER = 0x10000,
|
||||
CHANNEL_OUT_TOP_BACK_RIGHT = 0x20000,
|
||||
|
||||
CHANNEL_OUT_MONO = CHANNEL_OUT_FRONT_LEFT,
|
||||
CHANNEL_OUT_STEREO = (CHANNEL_OUT_FRONT_LEFT | CHANNEL_OUT_FRONT_RIGHT),
|
||||
CHANNEL_OUT_QUAD = (CHANNEL_OUT_FRONT_LEFT | CHANNEL_OUT_FRONT_RIGHT |
|
||||
CHANNEL_OUT_BACK_LEFT | CHANNEL_OUT_BACK_RIGHT),
|
||||
CHANNEL_OUT_SURROUND = (CHANNEL_OUT_FRONT_LEFT | CHANNEL_OUT_FRONT_RIGHT |
|
||||
CHANNEL_OUT_FRONT_CENTER | CHANNEL_OUT_BACK_CENTER),
|
||||
CHANNEL_OUT_5POINT1 = (CHANNEL_OUT_FRONT_LEFT | CHANNEL_OUT_FRONT_RIGHT |
|
||||
CHANNEL_OUT_FRONT_CENTER | CHANNEL_OUT_LOW_FREQUENCY |
|
||||
CHANNEL_OUT_BACK_LEFT | CHANNEL_OUT_BACK_RIGHT),
|
||||
// matches the correct AudioFormat.CHANNEL_OUT_7POINT1_SURROUND definition for 7.1
|
||||
CHANNEL_OUT_7POINT1 = (CHANNEL_OUT_FRONT_LEFT | CHANNEL_OUT_FRONT_RIGHT |
|
||||
CHANNEL_OUT_FRONT_CENTER | CHANNEL_OUT_LOW_FREQUENCY |
|
||||
CHANNEL_OUT_BACK_LEFT | CHANNEL_OUT_BACK_RIGHT |
|
||||
CHANNEL_OUT_SIDE_LEFT | CHANNEL_OUT_SIDE_RIGHT),
|
||||
CHANNEL_OUT_ALL = (CHANNEL_OUT_FRONT_LEFT | CHANNEL_OUT_FRONT_RIGHT |
|
||||
CHANNEL_OUT_FRONT_CENTER | CHANNEL_OUT_LOW_FREQUENCY | CHANNEL_OUT_BACK_LEFT |
|
||||
CHANNEL_OUT_BACK_RIGHT | CHANNEL_OUT_FRONT_LEFT_OF_CENTER |
|
||||
CHANNEL_OUT_FRONT_RIGHT_OF_CENTER | CHANNEL_OUT_BACK_CENTER |
|
||||
CHANNEL_OUT_SIDE_LEFT | CHANNEL_OUT_SIDE_RIGHT | CHANNEL_OUT_TOP_CENTER |
|
||||
CHANNEL_OUT_TOP_FRONT_LEFT | CHANNEL_OUT_TOP_FRONT_CENTER |
|
||||
CHANNEL_OUT_TOP_FRONT_RIGHT | CHANNEL_OUT_TOP_BACK_LEFT |
|
||||
CHANNEL_OUT_TOP_BACK_CENTER | CHANNEL_OUT_TOP_BACK_RIGHT),
|
||||
|
||||
// input channels
|
||||
CHANNEL_IN_LEFT = 0x4,
|
||||
CHANNEL_IN_RIGHT = 0x8,
|
||||
CHANNEL_IN_FRONT = 0x10,
|
||||
CHANNEL_IN_BACK = 0x20,
|
||||
CHANNEL_IN_LEFT_PROCESSED = 0x40,
|
||||
CHANNEL_IN_RIGHT_PROCESSED = 0x80,
|
||||
CHANNEL_IN_FRONT_PROCESSED = 0x100,
|
||||
CHANNEL_IN_BACK_PROCESSED = 0x200,
|
||||
CHANNEL_IN_PRESSURE = 0x400,
|
||||
CHANNEL_IN_X_AXIS = 0x800,
|
||||
CHANNEL_IN_Y_AXIS = 0x1000,
|
||||
CHANNEL_IN_Z_AXIS = 0x2000,
|
||||
CHANNEL_IN_VOICE_UPLINK = 0x4000,
|
||||
CHANNEL_IN_VOICE_DNLINK = 0x8000,
|
||||
CHANNEL_IN_MONO = CHANNEL_IN_FRONT,
|
||||
CHANNEL_IN_STEREO = (CHANNEL_IN_LEFT | CHANNEL_IN_RIGHT),
|
||||
CHANNEL_IN_ALL = (CHANNEL_IN_LEFT | CHANNEL_IN_RIGHT | CHANNEL_IN_FRONT | CHANNEL_IN_BACK|
|
||||
CHANNEL_IN_LEFT_PROCESSED | CHANNEL_IN_RIGHT_PROCESSED | CHANNEL_IN_FRONT_PROCESSED | CHANNEL_IN_BACK_PROCESSED|
|
||||
CHANNEL_IN_PRESSURE | CHANNEL_IN_X_AXIS | CHANNEL_IN_Y_AXIS | CHANNEL_IN_Z_AXIS |
|
||||
CHANNEL_IN_VOICE_UPLINK | CHANNEL_IN_VOICE_DNLINK)
|
||||
};
|
||||
|
||||
enum audio_mode {
|
||||
MODE_INVALID = -2,
|
||||
MODE_CURRENT = -1,
|
||||
MODE_NORMAL = 0,
|
||||
MODE_RINGTONE,
|
||||
MODE_IN_CALL,
|
||||
MODE_IN_COMMUNICATION,
|
||||
NUM_MODES // not a valid entry, denotes end-of-list
|
||||
};
|
||||
|
||||
enum audio_in_acoustics {
|
||||
AGC_ENABLE = 0x0001,
|
||||
AGC_DISABLE = 0,
|
||||
NS_ENABLE = 0x0002,
|
||||
NS_DISABLE = 0,
|
||||
TX_IIR_ENABLE = 0x0004,
|
||||
TX_DISABLE = 0
|
||||
};
|
||||
|
||||
// DO NOT USE: the "audio_devices" enumeration below is obsolete, use type "audio_devices_t" and
|
||||
// audio device enumeration from system/audio.h instead.
|
||||
enum audio_devices {
|
||||
// output devices
|
||||
DEVICE_OUT_EARPIECE = 0x1,
|
||||
DEVICE_OUT_SPEAKER = 0x2,
|
||||
DEVICE_OUT_WIRED_HEADSET = 0x4,
|
||||
DEVICE_OUT_WIRED_HEADPHONE = 0x8,
|
||||
DEVICE_OUT_BLUETOOTH_SCO = 0x10,
|
||||
DEVICE_OUT_BLUETOOTH_SCO_HEADSET = 0x20,
|
||||
DEVICE_OUT_BLUETOOTH_SCO_CARKIT = 0x40,
|
||||
DEVICE_OUT_BLUETOOTH_A2DP = 0x80,
|
||||
DEVICE_OUT_BLUETOOTH_A2DP_HEADPHONES = 0x100,
|
||||
DEVICE_OUT_BLUETOOTH_A2DP_SPEAKER = 0x200,
|
||||
DEVICE_OUT_AUX_DIGITAL = 0x400,
|
||||
DEVICE_OUT_ANLG_DOCK_HEADSET = 0x800,
|
||||
DEVICE_OUT_DGTL_DOCK_HEADSET = 0x1000,
|
||||
DEVICE_OUT_DEFAULT = 0x8000,
|
||||
DEVICE_OUT_ALL = (DEVICE_OUT_EARPIECE | DEVICE_OUT_SPEAKER | DEVICE_OUT_WIRED_HEADSET |
|
||||
DEVICE_OUT_WIRED_HEADPHONE | DEVICE_OUT_BLUETOOTH_SCO | DEVICE_OUT_BLUETOOTH_SCO_HEADSET |
|
||||
DEVICE_OUT_BLUETOOTH_SCO_CARKIT | DEVICE_OUT_BLUETOOTH_A2DP | DEVICE_OUT_BLUETOOTH_A2DP_HEADPHONES |
|
||||
DEVICE_OUT_BLUETOOTH_A2DP_SPEAKER | DEVICE_OUT_AUX_DIGITAL |
|
||||
DEVICE_OUT_ANLG_DOCK_HEADSET | DEVICE_OUT_DGTL_DOCK_HEADSET |
|
||||
DEVICE_OUT_DEFAULT),
|
||||
DEVICE_OUT_ALL_A2DP = (DEVICE_OUT_BLUETOOTH_A2DP | DEVICE_OUT_BLUETOOTH_A2DP_HEADPHONES |
|
||||
DEVICE_OUT_BLUETOOTH_A2DP_SPEAKER),
|
||||
|
||||
// input devices
|
||||
DEVICE_IN_COMMUNICATION = 0x10000,
|
||||
DEVICE_IN_AMBIENT = 0x20000,
|
||||
DEVICE_IN_BUILTIN_MIC = 0x40000,
|
||||
DEVICE_IN_BLUETOOTH_SCO_HEADSET = 0x80000,
|
||||
DEVICE_IN_WIRED_HEADSET = 0x100000,
|
||||
DEVICE_IN_AUX_DIGITAL = 0x200000,
|
||||
DEVICE_IN_VOICE_CALL = 0x400000,
|
||||
DEVICE_IN_BACK_MIC = 0x800000,
|
||||
DEVICE_IN_DEFAULT = 0x80000000,
|
||||
|
||||
DEVICE_IN_ALL = (DEVICE_IN_COMMUNICATION | DEVICE_IN_AMBIENT | DEVICE_IN_BUILTIN_MIC |
|
||||
DEVICE_IN_BLUETOOTH_SCO_HEADSET | DEVICE_IN_WIRED_HEADSET | DEVICE_IN_AUX_DIGITAL |
|
||||
DEVICE_IN_VOICE_CALL | DEVICE_IN_BACK_MIC | DEVICE_IN_DEFAULT)
|
||||
};
|
||||
|
||||
// request to open a direct output with getOutput() (by opposition to sharing an output with other AudioTracks)
|
||||
enum output_flags {
|
||||
OUTPUT_FLAG_INDIRECT = 0x0,
|
||||
OUTPUT_FLAG_DIRECT = 0x1
|
||||
};
|
||||
|
||||
// device categories used for setForceUse()
|
||||
enum forced_config {
|
||||
FORCE_NONE,
|
||||
FORCE_SPEAKER,
|
||||
FORCE_HEADPHONES,
|
||||
FORCE_BT_SCO,
|
||||
FORCE_BT_A2DP,
|
||||
FORCE_WIRED_ACCESSORY,
|
||||
FORCE_BT_CAR_DOCK,
|
||||
FORCE_BT_DESK_DOCK,
|
||||
FORCE_ANALOG_DOCK,
|
||||
FORCE_DIGITAL_DOCK,
|
||||
FORCE_NO_BT_A2DP,
|
||||
FORCE_SYSTEM_ENFORCED,
|
||||
NUM_FORCE_CONFIG,
|
||||
FORCE_DEFAULT = FORCE_NONE
|
||||
};
|
||||
|
||||
// usages used for setForceUse()
|
||||
enum force_use {
|
||||
FOR_COMMUNICATION,
|
||||
FOR_MEDIA,
|
||||
FOR_RECORD,
|
||||
FOR_DOCK,
|
||||
FOR_SYSTEM,
|
||||
NUM_FORCE_USE
|
||||
};
|
||||
|
||||
//
|
||||
// AudioPolicyService interface
|
||||
//
|
||||
|
||||
// device connection states used for setDeviceConnectionState()
|
||||
enum device_connection_state {
|
||||
DEVICE_STATE_UNAVAILABLE,
|
||||
DEVICE_STATE_AVAILABLE,
|
||||
NUM_DEVICE_STATES
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
static uint32_t popCount(uint32_t u) {
|
||||
return popcount(u);
|
||||
}
|
||||
|
||||
#if 1
|
||||
static bool isOutputDevice(audio_devices device) {
|
||||
if ((popcount(device) == 1) && ((device & ~DEVICE_OUT_ALL) == 0))
|
||||
return true;
|
||||
else
|
||||
return false;
|
||||
}
|
||||
static bool isInputDevice(audio_devices device) {
|
||||
if ((popcount(device) == 1) && ((device & ~DEVICE_IN_ALL) == 0))
|
||||
return true;
|
||||
else
|
||||
return false;
|
||||
}
|
||||
static bool isA2dpDevice(audio_devices device) {
|
||||
return audio_is_a2dp_device((audio_devices_t)device);
|
||||
}
|
||||
static bool isBluetoothScoDevice(audio_devices device) {
|
||||
return audio_is_bluetooth_sco_device((audio_devices_t)device);
|
||||
}
|
||||
static bool isLowVisibility(stream_type stream) {
|
||||
return audio_is_low_visibility((audio_stream_type_t)stream);
|
||||
}
|
||||
static bool isValidFormat(uint32_t format) {
|
||||
return audio_is_valid_format((audio_format_t) format);
|
||||
}
|
||||
static bool isLinearPCM(uint32_t format) {
|
||||
return audio_is_linear_pcm((audio_format_t) format);
|
||||
}
|
||||
static bool isOutputChannel(uint32_t channel) {
|
||||
return audio_is_output_channel(channel);
|
||||
}
|
||||
static bool isInputChannel(uint32_t channel) {
|
||||
return audio_is_input_channel(channel);
|
||||
}
|
||||
|
||||
#endif
|
||||
};
|
||||
|
||||
}; // namespace android
|
||||
|
||||
#endif // ANDROID_AUDIOSYSTEM_LEGACY_H_
|
|
@ -0,0 +1,66 @@
|
|||
/*
|
||||
* Copyright (C) 2007 The Android Open Source Project
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
//
|
||||
#ifndef ANDROID_HARDWARE_IMOUNTSERVICE_H
|
||||
#define ANDROID_HARDWARE_IMOUNTSERVICE_H
|
||||
|
||||
#include <binder/IInterface.h>
|
||||
#include <utils/String16.h>
|
||||
|
||||
namespace android {
|
||||
|
||||
// ----------------------------------------------------------------------
|
||||
|
||||
class IMountService : public IInterface
|
||||
{
|
||||
public:
|
||||
static const int OperationSucceeded = 0;
|
||||
static const int OperationFailedInternalError = -1;
|
||||
static const int OperationFailedNoMedia = -2;
|
||||
static const int OperationFailedMediaBlank = -3;
|
||||
static const int OperationFailedMediaCorrupt = -4;
|
||||
static const int OperationFailedVolumeNotMounted = -5;
|
||||
|
||||
|
||||
public:
|
||||
DECLARE_META_INTERFACE(MountService);
|
||||
|
||||
virtual void getShareMethodList() = 0;
|
||||
virtual bool getShareMethodAvailable(String16 method) = 0;
|
||||
virtual int shareVolume(String16 path, String16 method) = 0;
|
||||
virtual int unshareVolume(String16 path, String16 method) = 0;
|
||||
virtual bool getVolumeShared(String16 path, String16 method) = 0;
|
||||
virtual int mountVolume(String16 path) = 0;
|
||||
virtual int unmountVolume(String16 path) = 0;
|
||||
virtual int formatVolume(String16 path) = 0;
|
||||
virtual String16 getVolumeState(String16 mountPoint) = 0;
|
||||
virtual int createSecureContainer(String16 id, int sizeMb, String16 fstype, String16 key, int ownerUid) = 0;
|
||||
virtual int finalizeSecureContainer(String16 id) = 0;
|
||||
virtual int destroySecureContainer(String16 id) = 0;
|
||||
virtual int mountSecureContainer(String16 id, String16 key, int ownerUid) = 0;
|
||||
virtual int unmountSecureContainer(String16 id) = 0;
|
||||
virtual int renameSecureContainer(String16 oldId, String16 newId) = 0;
|
||||
virtual String16 getSecureContainerPath(String16 id) = 0;
|
||||
virtual void getSecureContainerList() = 0;
|
||||
virtual void shutdown() = 0;
|
||||
};
|
||||
|
||||
// ----------------------------------------------------------------------
|
||||
|
||||
}; // namespace android
|
||||
|
||||
#endif // ANDROID_HARDWARE_IMOUNTSERVICE_H
|
|
@ -0,0 +1,55 @@
|
|||
/*
|
||||
* Copyright (C) 2012 The Android Open Source Project
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
|
||||
#ifndef ANDROID_AUDIO_POLICY_CONF_H
|
||||
#define ANDROID_AUDIO_POLICY_CONF_H
|
||||
|
||||
|
||||
/////////////////////////////////////////////////
|
||||
// Definitions for audio policy configuration file (audio_policy.conf)
|
||||
/////////////////////////////////////////////////
|
||||
|
||||
#define AUDIO_HARDWARE_MODULE_ID_MAX_LEN 32
|
||||
|
||||
#define AUDIO_POLICY_CONFIG_FILE "/system/etc/audio_policy.conf"
|
||||
#define AUDIO_POLICY_VENDOR_CONFIG_FILE "/vendor/etc/audio_policy.conf"
|
||||
|
||||
// global configuration
|
||||
#define GLOBAL_CONFIG_TAG "global_configuration"
|
||||
|
||||
#define ATTACHED_OUTPUT_DEVICES_TAG "attached_output_devices"
|
||||
#define DEFAULT_OUTPUT_DEVICE_TAG "default_output_device"
|
||||
#define ATTACHED_INPUT_DEVICES_TAG "attached_input_devices"
|
||||
#define SPEAKER_DRC_ENABLED_TAG "speaker_drc_enabled"
|
||||
|
||||
// hw modules descriptions
|
||||
#define AUDIO_HW_MODULE_TAG "audio_hw_modules"
|
||||
|
||||
#define OUTPUTS_TAG "outputs"
|
||||
#define INPUTS_TAG "inputs"
|
||||
|
||||
#define SAMPLING_RATES_TAG "sampling_rates"
|
||||
#define FORMATS_TAG "formats"
|
||||
#define CHANNELS_TAG "channel_masks"
|
||||
#define DEVICES_TAG "devices"
|
||||
#define FLAGS_TAG "flags"
|
||||
|
||||
#define DYNAMIC_VALUE_TAG "dynamic" // special value for "channel_masks", "sampling_rates" and
|
||||
// "formats" in outputs descriptors indicating that supported
|
||||
// values should be queried after opening the output.
|
||||
|
||||
#endif // ANDROID_AUDIO_POLICY_CONF_H
|
|
@ -0,0 +1,430 @@
|
|||
#include "wifi_hal.h"
|
||||
|
||||
#ifndef __WIFI_HAL_GSCAN_H__
|
||||
#define __WIFI_HAL_GSCAN_H__
|
||||
|
||||
// Define static_assert() unless already defined by compiler.
|
||||
#ifndef __has_feature
|
||||
#define __has_feature(__x) 0
|
||||
#endif
|
||||
#if !(__has_feature(cxx_static_assert)) && !defined(static_assert)
|
||||
#define static_assert(__b, __m) \
|
||||
extern int compile_time_assert_failed[ ( __b ) ? 1 : -1 ] \
|
||||
__attribute__( ( unused ) );
|
||||
#endif
|
||||
|
||||
/* AP Scans */
|
||||
|
||||
typedef enum {
|
||||
WIFI_BAND_UNSPECIFIED,
|
||||
WIFI_BAND_BG = 1, // 2.4 GHz
|
||||
WIFI_BAND_A = 2, // 5 GHz without DFS
|
||||
WIFI_BAND_A_DFS = 4, // 5 GHz DFS only
|
||||
WIFI_BAND_A_WITH_DFS = 6, // 5 GHz with DFS
|
||||
WIFI_BAND_ABG = 3, // 2.4 GHz + 5 GHz; no DFS
|
||||
WIFI_BAND_ABG_WITH_DFS = 7, // 2.4 GHz + 5 GHz with DFS
|
||||
} wifi_band;
|
||||
|
||||
#define MAX_CHANNELS 16
|
||||
#define MAX_BUCKETS 16
|
||||
#define MAX_HOTLIST_APS 128
|
||||
#define MAX_SIGNIFICANT_CHANGE_APS 64
|
||||
#define MAX_EPNO_NETWORKS 64
|
||||
#define MAX_HOTLIST_SSID 8
|
||||
#define MAX_AP_CACHE_PER_SCAN 32
|
||||
|
||||
wifi_error wifi_get_valid_channels(wifi_interface_handle handle,
|
||||
int band, int max_channels, wifi_channel *channels, int *num_channels);
|
||||
|
||||
typedef struct {
|
||||
int max_scan_cache_size; // total space allocated for scan (in bytes)
|
||||
int max_scan_buckets; // maximum number of channel buckets
|
||||
int max_ap_cache_per_scan; // maximum number of APs that can be stored per scan
|
||||
int max_rssi_sample_size; // number of RSSI samples used for averaging RSSI
|
||||
int max_scan_reporting_threshold; // max possible report_threshold as described
|
||||
// in wifi_scan_cmd_params
|
||||
int max_hotlist_bssids; // maximum number of entries for hotlist BSSIDs
|
||||
int max_hotlist_ssids; // maximum number of entries for hotlist SSIDs
|
||||
int max_significant_wifi_change_aps; // maximum number of entries for
|
||||
// significant wifi change APs
|
||||
int max_bssid_history_entries; // number of BSSID/RSSI entries that device can hold
|
||||
int max_number_epno_networks; // max number of epno entries
|
||||
int max_number_epno_networks_by_ssid; // max number of epno entries if ssid is specified,
|
||||
// that is, epno entries for which an exact match is
|
||||
// required, or entries corresponding to hidden ssids
|
||||
int max_number_of_white_listed_ssid; // max number of white listed SSIDs, M target is 2 to 4
|
||||
} wifi_gscan_capabilities;
|
||||
|
||||
wifi_error wifi_get_gscan_capabilities(wifi_interface_handle handle,
|
||||
wifi_gscan_capabilities *capabilities);
|
||||
|
||||
typedef enum {
|
||||
WIFI_SCAN_RESULTS_AVAILABLE, // reported when REPORT_EVENTS_EACH_SCAN is set and a scan
|
||||
// completes. WIFI_SCAN_THRESHOLD_NUM_SCANS or
|
||||
// WIFI_SCAN_THRESHOLD_PERCENT can be reported instead if the
|
||||
// reason for the event is available; however, at most one of
|
||||
// these events should be reported per scan. If there are
|
||||
// multiple buckets that were scanned this period and one has the
|
||||
// EACH_SCAN flag set then this event should be prefered.
|
||||
WIFI_SCAN_THRESHOLD_NUM_SCANS, // can be reported when REPORT_EVENTS_EACH_SCAN is not set and
|
||||
// report_threshold_num_scans is reached.
|
||||
WIFI_SCAN_THRESHOLD_PERCENT, // can be reported when REPORT_EVENTS_EACH_SCAN is not set and
|
||||
// report_threshold_percent is reached.
|
||||
WIFI_SCAN_FAILED, // reported when currently executing gscans have failed.
|
||||
// start_gscan will need to be called again in order to continue
|
||||
// scanning. This is intended to indicate abnormal scan
|
||||
// terminations (not those as a result of stop_gscan).
|
||||
} wifi_scan_event;
|
||||
|
||||
|
||||
/* Format of information elements found in the beacon */
|
||||
typedef struct {
|
||||
byte id; // element identifier
|
||||
byte len; // number of bytes to follow
|
||||
byte data[];
|
||||
} wifi_information_element;
|
||||
|
||||
typedef struct {
|
||||
wifi_timestamp ts; // time since boot (in microsecond) when the result was
|
||||
// retrieved
|
||||
char ssid[32+1]; // null terminated
|
||||
mac_addr bssid;
|
||||
wifi_channel channel; // channel frequency in MHz
|
||||
wifi_rssi rssi; // in db
|
||||
wifi_timespan rtt; // in nanoseconds
|
||||
wifi_timespan rtt_sd; // standard deviation in rtt
|
||||
unsigned short beacon_period; // period advertised in the beacon
|
||||
unsigned short capability; // capabilities advertised in the beacon
|
||||
unsigned int ie_length; // size of the ie_data blob
|
||||
char ie_data[1]; // blob of all the information elements found in the
|
||||
// beacon; this data should be a packed list of
|
||||
// wifi_information_element objects, one after the other.
|
||||
// other fields
|
||||
} wifi_scan_result;
|
||||
|
||||
static_assert(MAX_BUCKETS <= 8 * sizeof(unsigned),
|
||||
"The buckets_scanned bitset is represented by an unsigned int and cannot support this many "
|
||||
"buckets on this platform.");
|
||||
typedef struct {
|
||||
/* reported when each probe response is received, if report_events
|
||||
* enabled in wifi_scan_cmd_params. buckets_scanned is a bitset of the
|
||||
* buckets that are currently being scanned. See the buckets_scanned field
|
||||
* in the wifi_cached_scan_results struct for more details.
|
||||
*/
|
||||
void (*on_full_scan_result) (wifi_request_id id, wifi_scan_result *result,
|
||||
unsigned buckets_scanned);
|
||||
|
||||
/* indicates progress of scanning statemachine */
|
||||
void (*on_scan_event) (wifi_request_id id, wifi_scan_event event);
|
||||
|
||||
} wifi_scan_result_handler;
|
||||
|
||||
typedef struct {
|
||||
wifi_channel channel; // frequency
|
||||
int dwellTimeMs; // dwell time hint
|
||||
int passive; // 0 => active, 1 => passive scan; ignored for DFS
|
||||
/* Add channel class */
|
||||
} wifi_scan_channel_spec;
|
||||
|
||||
#define REPORT_EVENTS_EACH_SCAN (1 << 0)
|
||||
#define REPORT_EVENTS_FULL_RESULTS (1 << 1)
|
||||
#define REPORT_EVENTS_NO_BATCH (1 << 2)
|
||||
|
||||
typedef struct {
|
||||
int bucket; // bucket index, 0 based
|
||||
wifi_band band; // when UNSPECIFIED, use channel list
|
||||
int period; // desired period, in millisecond; if this is too
|
||||
// low, the firmware should choose to generate results as
|
||||
// fast as it can instead of failing the command.
|
||||
// for exponential backoff bucket this is the min_period
|
||||
/* report_events semantics -
|
||||
* This is a bit field; which defines following bits -
|
||||
* REPORT_EVENTS_EACH_SCAN => report a scan completion event after scan. If this is not set
|
||||
* then scan completion events should be reported if
|
||||
* report_threshold_percent or report_threshold_num_scans is
|
||||
* reached.
|
||||
* REPORT_EVENTS_FULL_RESULTS => forward scan results (beacons/probe responses + IEs)
|
||||
* in real time to HAL, in addition to completion events
|
||||
* Note: To keep backward compatibility, fire completion
|
||||
* events regardless of REPORT_EVENTS_EACH_SCAN.
|
||||
* REPORT_EVENTS_NO_BATCH => controls if scans for this bucket should be placed in the
|
||||
* history buffer
|
||||
*/
|
||||
byte report_events;
|
||||
int max_period; // if max_period is non zero or different than period, then this bucket is
|
||||
// an exponential backoff bucket and the scan period will grow exponentially
|
||||
// as per formula: actual_period(N) = period * (base ^ (N/step_count))
|
||||
// to a maximum period of max_period
|
||||
int base; // for exponential back off bucket: multiplier: new_period=old_period*base
|
||||
int step_count; // for exponential back off bucket, number of scans to perform for a given
|
||||
// period
|
||||
|
||||
int num_channels;
|
||||
// channels to scan; these may include DFS channels
|
||||
// Note that a given channel may appear in multiple buckets
|
||||
wifi_scan_channel_spec channels[MAX_CHANNELS];
|
||||
} wifi_scan_bucket_spec;
|
||||
|
||||
typedef struct {
|
||||
int base_period; // base timer period in ms
|
||||
int max_ap_per_scan; // number of access points to store in each scan entry in
|
||||
// the BSSID/RSSI history buffer (keep the highest RSSI
|
||||
// access points)
|
||||
int report_threshold_percent; // in %, when scan buffer is this much full, wake up apps
|
||||
// processor
|
||||
int report_threshold_num_scans; // in number of scans, wake up AP after these many scans
|
||||
int num_buckets;
|
||||
wifi_scan_bucket_spec buckets[MAX_BUCKETS];
|
||||
} wifi_scan_cmd_params;
|
||||
|
||||
/*
|
||||
* Start periodic GSCAN
|
||||
* When this is called all requested buckets should be scanned, starting the beginning of the cycle
|
||||
*
|
||||
* For example:
|
||||
* If there are two buckets specified
|
||||
* - Bucket 1: period=10s
|
||||
* - Bucket 2: period=20s
|
||||
* - Bucket 3: period=30s
|
||||
* Then the following scans should occur
|
||||
* - t=0 buckets 1, 2, and 3 are scanned
|
||||
* - t=10 bucket 1 is scanned
|
||||
* - t=20 bucket 1 and 2 are scanned
|
||||
* - t=30 bucket 1 and 3 are scanned
|
||||
* - t=40 bucket 1 and 2 are scanned
|
||||
* - t=50 bucket 1 is scanned
|
||||
* - t=60 buckets 1, 2, and 3 are scanned
|
||||
* - and the patter repeats
|
||||
*
|
||||
* If any scan does not occur or is incomplete (error, interrupted, etc) then a cached scan result
|
||||
* should still be recorded with the WIFI_SCAN_FLAG_INTERRUPTED flag set.
|
||||
*/
|
||||
wifi_error wifi_start_gscan(wifi_request_id id, wifi_interface_handle iface,
|
||||
wifi_scan_cmd_params params, wifi_scan_result_handler handler);
|
||||
|
||||
/* Stop periodic GSCAN */
|
||||
wifi_error wifi_stop_gscan(wifi_request_id id, wifi_interface_handle iface);
|
||||
|
||||
typedef enum {
|
||||
WIFI_SCAN_FLAG_INTERRUPTED = 1 // Indicates that scan results are not complete because
|
||||
// probes were not sent on some channels
|
||||
} wifi_scan_flags;
|
||||
|
||||
/* Get the GSCAN cached scan results */
|
||||
typedef struct {
|
||||
int scan_id; // a unique identifier for the scan unit
|
||||
int flags; // a bitmask with additional
|
||||
// information about scan.
|
||||
unsigned buckets_scanned; // a bitset of the buckets that were scanned.
|
||||
// for example a value of 13 (0b1101) would
|
||||
// indicate that buckets 0, 2 and 3 were
|
||||
// scanned to produce this list of results.
|
||||
// should be set to 0 if this information is
|
||||
// not available.
|
||||
int num_results; // number of bssids retrieved by the scan
|
||||
wifi_scan_result results[MAX_AP_CACHE_PER_SCAN]; // scan results - one for each bssid
|
||||
} wifi_cached_scan_results;
|
||||
|
||||
wifi_error wifi_get_cached_gscan_results(wifi_interface_handle iface, byte flush,
|
||||
int max, wifi_cached_scan_results *results, int *num);
|
||||
|
||||
/* BSSID Hotlist */
|
||||
typedef struct {
|
||||
void (*on_hotlist_ap_found)(wifi_request_id id,
|
||||
unsigned num_results, wifi_scan_result *results);
|
||||
void (*on_hotlist_ap_lost)(wifi_request_id id,
|
||||
unsigned num_results, wifi_scan_result *results);
|
||||
} wifi_hotlist_ap_found_handler;
|
||||
|
||||
typedef struct {
|
||||
mac_addr bssid; // AP BSSID
|
||||
wifi_rssi low; // low threshold
|
||||
wifi_rssi high; // high threshold
|
||||
} ap_threshold_param;
|
||||
|
||||
typedef struct {
|
||||
int lost_ap_sample_size;
|
||||
int num_bssid; // number of hotlist APs
|
||||
ap_threshold_param ap[MAX_HOTLIST_APS]; // hotlist APs
|
||||
} wifi_bssid_hotlist_params;
|
||||
|
||||
/* Set the BSSID Hotlist */
|
||||
wifi_error wifi_set_bssid_hotlist(wifi_request_id id, wifi_interface_handle iface,
|
||||
wifi_bssid_hotlist_params params, wifi_hotlist_ap_found_handler handler);
|
||||
|
||||
/* Clear the BSSID Hotlist */
|
||||
wifi_error wifi_reset_bssid_hotlist(wifi_request_id id, wifi_interface_handle iface);
|
||||
|
||||
/* SSID Hotlist */
|
||||
typedef struct {
|
||||
void (*on_hotlist_ssid_found)(wifi_request_id id,
|
||||
unsigned num_results, wifi_scan_result *results);
|
||||
void (*on_hotlist_ssid_lost)(wifi_request_id id,
|
||||
unsigned num_results, wifi_scan_result *results);
|
||||
} wifi_hotlist_ssid_handler;
|
||||
|
||||
typedef struct {
|
||||
char ssid[32+1]; // SSID
|
||||
wifi_band band; // band for this set of threshold params
|
||||
wifi_rssi low; // low threshold
|
||||
wifi_rssi high; // high threshold
|
||||
} ssid_threshold_param;
|
||||
|
||||
typedef struct {
|
||||
int lost_ssid_sample_size;
|
||||
int num_ssid; // number of hotlist SSIDs
|
||||
ssid_threshold_param ssid[MAX_HOTLIST_SSID]; // hotlist SSIDs
|
||||
} wifi_ssid_hotlist_params;
|
||||
|
||||
/* Significant wifi change */
|
||||
typedef struct {
|
||||
mac_addr bssid; // BSSID
|
||||
wifi_channel channel; // channel frequency in MHz
|
||||
int num_rssi; // number of rssi samples
|
||||
wifi_rssi rssi[]; // RSSI history in db
|
||||
} wifi_significant_change_result;
|
||||
|
||||
typedef struct {
|
||||
void (*on_significant_change)(wifi_request_id id,
|
||||
unsigned num_results, wifi_significant_change_result **results);
|
||||
} wifi_significant_change_handler;
|
||||
|
||||
// The sample size parameters in the wifi_significant_change_params structure
|
||||
// represent the number of occurence of a g-scan where the BSSID was seen and RSSI was
|
||||
// collected for that BSSID, or, the BSSID was expected to be seen and didn't.
|
||||
// for instance: lost_ap_sample_size : number of time a g-scan was performed on the
|
||||
// channel the BSSID was seen last, and the BSSID was not seen during those g-scans
|
||||
typedef struct {
|
||||
int rssi_sample_size; // number of samples for averaging RSSI
|
||||
int lost_ap_sample_size; // number of samples to confirm AP loss
|
||||
int min_breaching; // number of APs breaching threshold
|
||||
int num_bssid; // max 64
|
||||
ap_threshold_param ap[MAX_SIGNIFICANT_CHANGE_APS];
|
||||
} wifi_significant_change_params;
|
||||
|
||||
/* Set the Signifcant AP change list */
|
||||
wifi_error wifi_set_significant_change_handler(wifi_request_id id, wifi_interface_handle iface,
|
||||
wifi_significant_change_params params, wifi_significant_change_handler handler);
|
||||
|
||||
/* Clear the Signifcant AP change list */
|
||||
wifi_error wifi_reset_significant_change_handler(wifi_request_id id, wifi_interface_handle iface);
|
||||
|
||||
/* Random MAC OUI for PNO */
|
||||
wifi_error wifi_set_scanning_mac_oui(wifi_interface_handle handle, oui scan_oui);
|
||||
|
||||
|
||||
// Enhanced PNO:
|
||||
// Enhanced PNO feature is expected to be enabled all of the time (e.g. screen lit) and may thus
|
||||
// require firmware to store a large number of networks, covering the whole list of known networks.
|
||||
// Therefore, it is acceptable for firmware to store a crc24, crc32 or other short hash of the SSID,
|
||||
// such that a low but non-zero probability of collision exist. With that scheme it should be
|
||||
// possible for firmware to keep an entry as small as 4 bytes for each pno network.
|
||||
// For instance, a firmware pn0 entry can be implemented in the form of:
|
||||
// PNO ENTRY = crc24(3 bytes) | flags>>3 (5 bits) | auth flags(3 bits)
|
||||
//
|
||||
// No scans should be automatically performed by the chip. Instead all scan results from gscan
|
||||
// should be scored and the wifi_epno_handler on_network_found callback should be called with
|
||||
// the scan results.
|
||||
//
|
||||
// A PNO network shall be reported once, that is, once a network is reported by firmware
|
||||
// its entry shall be marked as "done" until framework calls wifi_set_epno_list again.
|
||||
// Calling wifi_set_epno_list shall reset the "done" status of pno networks in firmware.
|
||||
//
|
||||
// A network should only be considered found if its RSSI is above the minimum RSSI for its
|
||||
// frequency range (min5GHz_rssi and min24GHz_rssi for 5GHz and 2.4GHz networks respectively).
|
||||
// When disconnected the list of scan results should be returned if any network is found.
|
||||
// When connected the scan results shall be reported only if the score of any network in the scan
|
||||
// is greater than that of the currently connected BSSID.
|
||||
//
|
||||
// The FW should calculate the score of all the candidates (including currently connected one)
|
||||
// with following equation:
|
||||
// RSSI score = (RSSI + 85) * 4;
|
||||
// If RSSI score > initial_score_max , RSSI score = initial_score_max;
|
||||
// final score = RSSI score
|
||||
// + current_connection_bonus (if currently connected BSSID)
|
||||
// + same_network_bonus (if network has SAME_NETWORK flag)
|
||||
// + secure_bonus (if the network is not open)
|
||||
// + band5GHz_bonus (if BSSID is on 5G)
|
||||
// If there is a BSSID’s score > current BSSID’s score, then report the cached scan results
|
||||
// at the end of the scan (excluding the ones on blacklist) to the upper layer.
|
||||
// Additionally, all BSSIDs that are in the BSSID blacklist should be ignored by Enhanced PNO
|
||||
|
||||
// Whether directed scan needs to be performed (for hidden SSIDs)
|
||||
#define WIFI_PNO_FLAG_DIRECTED_SCAN (1 << 0)
|
||||
// Whether PNO event shall be triggered if the network is found on A band
|
||||
#define WIFI_PNO_FLAG_A_BAND (1 << 1)
|
||||
// Whether PNO event shall be triggered if the network is found on G band
|
||||
#define WIFI_PNO_FLAG_G_BAND (1 << 2)
|
||||
// Whether strict matching is required
|
||||
// If required then the firmware must store the network's SSID and not just a hash
|
||||
#define WIFI_PNO_FLAG_STRICT_MATCH (1 << 3)
|
||||
// If this SSID should be considered the same network as the currently connected one for scoring
|
||||
#define WIFI_PNO_FLAG_SAME_NETWORK (1 << 4)
|
||||
|
||||
// Code for matching the beacon AUTH IE - additional codes TBD
|
||||
#define WIFI_PNO_AUTH_CODE_OPEN (1 << 0) // open
|
||||
#define WIFI_PNO_AUTH_CODE_PSK (1 << 1) // WPA_PSK or WPA2PSK
|
||||
#define WIFI_PNO_AUTH_CODE_EAPOL (1 << 2) // any EAPOL
|
||||
|
||||
typedef struct {
|
||||
char ssid[32+1]; // null terminated
|
||||
byte flags; // WIFI_PNO_FLAG_XXX
|
||||
byte auth_bit_field; // auth bit field for matching WPA IE
|
||||
} wifi_epno_network;
|
||||
|
||||
/* ePNO Parameters */
|
||||
typedef struct {
|
||||
int min5GHz_rssi; // minimum 5GHz RSSI for a BSSID to be considered
|
||||
int min24GHz_rssi; // minimum 2.4GHz RSSI for a BSSID to be considered
|
||||
int initial_score_max; // the maximum score that a network can have before bonuses
|
||||
int current_connection_bonus; // only report when there is a network's score this much higher
|
||||
// than the current connection.
|
||||
int same_network_bonus; // score bonus for all networks with the same network flag
|
||||
int secure_bonus; // score bonus for networks that are not open
|
||||
int band5GHz_bonus; // 5GHz RSSI score bonus (applied to all 5GHz networks)
|
||||
int num_networks; // number of wifi_epno_network objects
|
||||
wifi_epno_network networks[MAX_EPNO_NETWORKS]; // PNO networks
|
||||
} wifi_epno_params;
|
||||
|
||||
typedef struct {
|
||||
// on results
|
||||
void (*on_network_found)(wifi_request_id id,
|
||||
unsigned num_results, wifi_scan_result *results);
|
||||
} wifi_epno_handler;
|
||||
|
||||
|
||||
/* Set the ePNO list - enable ePNO with the given parameters */
|
||||
wifi_error wifi_set_epno_list(wifi_request_id id, wifi_interface_handle iface,
|
||||
const wifi_epno_params *epno_params, wifi_epno_handler handler);
|
||||
|
||||
/* Reset the ePNO list - no ePNO networks should be matched after this */
|
||||
wifi_error wifi_reset_epno_list(wifi_request_id id, wifi_interface_handle iface);
|
||||
|
||||
|
||||
typedef struct {
|
||||
int id; // identifier of this network block, report this in event
|
||||
char realm[256]; // null terminated UTF8 encoded realm, 0 if unspecified
|
||||
int64_t roamingConsortiumIds[16]; // roaming consortium ids to match, 0s if unspecified
|
||||
byte plmn[3]; // mcc/mnc combination as per rules, 0s if unspecified
|
||||
} wifi_passpoint_network;
|
||||
|
||||
typedef struct {
|
||||
void (*on_passpoint_network_found)(
|
||||
wifi_request_id id,
|
||||
int net_id, // network block identifier for the matched network
|
||||
wifi_scan_result *result, // scan result, with channel and beacon information
|
||||
int anqp_len, // length of ANQP blob
|
||||
byte *anqp // ANQP data, in the information_element format
|
||||
);
|
||||
} wifi_passpoint_event_handler;
|
||||
|
||||
/* Sets a list for passpoint networks for PNO purposes; it should be matched
|
||||
* against any passpoint networks (designated by Interworking element) found
|
||||
* during regular PNO scan. */
|
||||
wifi_error wifi_set_passpoint_list(wifi_request_id id, wifi_interface_handle iface, int num,
|
||||
wifi_passpoint_network *networks, wifi_passpoint_event_handler handler);
|
||||
|
||||
/* Reset passpoint network list - no Passpoint networks should be matched after this */
|
||||
wifi_error wifi_reset_passpoint_list(wifi_request_id id, wifi_interface_handle iface);
|
||||
|
||||
#endif
|
|
@ -0,0 +1,259 @@
|
|||
#include "wifi_hal.h"
|
||||
|
||||
#ifndef __WIFI_HAL_STATS_H
|
||||
#define __WIFI_HAL_STATS_H
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C"
|
||||
{
|
||||
#endif /* __cplusplus */
|
||||
|
||||
#define STATS_MAJOR_VERSION 1
|
||||
#define STATS_MINOR_VERSION 0
|
||||
#define STATS_MICRO_VERSION 0
|
||||
|
||||
typedef enum {
|
||||
WIFI_DISCONNECTED = 0,
|
||||
WIFI_AUTHENTICATING = 1,
|
||||
WIFI_ASSOCIATING = 2,
|
||||
WIFI_ASSOCIATED = 3,
|
||||
WIFI_EAPOL_STARTED = 4, // if done by firmware/driver
|
||||
WIFI_EAPOL_COMPLETED = 5, // if done by firmware/driver
|
||||
} wifi_connection_state;
|
||||
|
||||
typedef enum {
|
||||
WIFI_ROAMING_IDLE = 0,
|
||||
WIFI_ROAMING_ACTIVE = 1,
|
||||
} wifi_roam_state;
|
||||
|
||||
typedef enum {
|
||||
WIFI_INTERFACE_STA = 0,
|
||||
WIFI_INTERFACE_SOFTAP = 1,
|
||||
WIFI_INTERFACE_IBSS = 2,
|
||||
WIFI_INTERFACE_P2P_CLIENT = 3,
|
||||
WIFI_INTERFACE_P2P_GO = 4,
|
||||
WIFI_INTERFACE_NAN = 5,
|
||||
WIFI_INTERFACE_MESH = 6,
|
||||
WIFI_INTERFACE_UNKNOWN = -1
|
||||
} wifi_interface_mode;
|
||||
|
||||
#define WIFI_CAPABILITY_QOS 0x00000001 // set for QOS association
|
||||
#define WIFI_CAPABILITY_PROTECTED 0x00000002 // set for protected association (802.11 beacon frame control protected bit set)
|
||||
#define WIFI_CAPABILITY_INTERWORKING 0x00000004 // set if 802.11 Extended Capabilities element interworking bit is set
|
||||
#define WIFI_CAPABILITY_HS20 0x00000008 // set for HS20 association
|
||||
#define WIFI_CAPABILITY_SSID_UTF8 0x00000010 // set is 802.11 Extended Capabilities element UTF-8 SSID bit is set
|
||||
#define WIFI_CAPABILITY_COUNTRY 0x00000020 // set is 802.11 Country Element is present
|
||||
|
||||
typedef struct {
|
||||
wifi_interface_mode mode; // interface mode
|
||||
u8 mac_addr[6]; // interface mac address (self)
|
||||
wifi_connection_state state; // connection state (valid for STA, CLI only)
|
||||
wifi_roam_state roaming; // roaming state
|
||||
u32 capabilities; // WIFI_CAPABILITY_XXX (self)
|
||||
u8 ssid[33]; // null terminated SSID
|
||||
u8 bssid[6]; // bssid
|
||||
u8 ap_country_str[3]; // country string advertised by AP
|
||||
u8 country_str[3]; // country string for this association
|
||||
} wifi_interface_link_layer_info;
|
||||
|
||||
/* channel information */
|
||||
typedef struct {
|
||||
wifi_channel_width width; // channel width (20, 40, 80, 80+80, 160)
|
||||
wifi_channel center_freq; // primary 20 MHz channel
|
||||
wifi_channel center_freq0; // center frequency (MHz) first segment
|
||||
wifi_channel center_freq1; // center frequency (MHz) second segment
|
||||
} wifi_channel_info;
|
||||
|
||||
/* wifi rate */
|
||||
typedef struct {
|
||||
u32 preamble :3; // 0: OFDM, 1:CCK, 2:HT 3:VHT 4..7 reserved
|
||||
u32 nss :2; // 0:1x1, 1:2x2, 3:3x3, 4:4x4
|
||||
u32 bw :3; // 0:20MHz, 1:40Mhz, 2:80Mhz, 3:160Mhz
|
||||
u32 rateMcsIdx :8; // OFDM/CCK rate code would be as per ieee std in the units of 0.5mbps
|
||||
// HT/VHT it would be mcs index
|
||||
u32 reserved :16; // reserved
|
||||
u32 bitrate; // units of 100 Kbps
|
||||
} wifi_rate;
|
||||
|
||||
/* channel statistics */
|
||||
typedef struct {
|
||||
wifi_channel_info channel; // channel
|
||||
u32 on_time; // msecs the radio is awake (32 bits number accruing over time)
|
||||
u32 cca_busy_time; // msecs the CCA register is busy (32 bits number accruing over time)
|
||||
} wifi_channel_stat;
|
||||
|
||||
// Max number of tx power levels. The actual number vary per device and is specified by |num_tx_levels|
|
||||
#define RADIO_STAT_MAX_TX_LEVELS 256
|
||||
|
||||
/* radio statistics */
|
||||
typedef struct {
|
||||
wifi_radio radio; // wifi radio (if multiple radio supported)
|
||||
u32 on_time; // msecs the radio is awake (32 bits number accruing over time)
|
||||
u32 tx_time; // msecs the radio is transmitting (32 bits number accruing over time)
|
||||
u32 num_tx_levels; // number of radio transmit power levels
|
||||
u32 *tx_time_per_levels; // pointer to an array of radio transmit per power levels in
|
||||
// msecs accured over time
|
||||
u32 rx_time; // msecs the radio is in active receive (32 bits number accruing over time)
|
||||
u32 on_time_scan; // msecs the radio is awake due to all scan (32 bits number accruing over time)
|
||||
u32 on_time_nbd; // msecs the radio is awake due to NAN (32 bits number accruing over time)
|
||||
u32 on_time_gscan; // msecs the radio is awake due to G?scan (32 bits number accruing over time)
|
||||
u32 on_time_roam_scan; // msecs the radio is awake due to roam?scan (32 bits number accruing over time)
|
||||
u32 on_time_pno_scan; // msecs the radio is awake due to PNO scan (32 bits number accruing over time)
|
||||
u32 on_time_hs20; // msecs the radio is awake due to HS2.0 scans and GAS exchange (32 bits number accruing over time)
|
||||
u32 num_channels; // number of channels
|
||||
wifi_channel_stat channels[]; // channel statistics
|
||||
} wifi_radio_stat;
|
||||
|
||||
/**
|
||||
* Packet statistics reporting by firmware is performed on MPDU basi (i.e. counters increase by 1 for each MPDU)
|
||||
* As well, "data packet" in associated comments, shall be interpreted as 802.11 data packet,
|
||||
* that is, 802.11 frame control subtype == 2 and excluding management and control frames.
|
||||
*
|
||||
* As an example, in the case of transmission of an MSDU fragmented in 16 MPDUs which are transmitted
|
||||
* OTA in a 16 units long a-mpdu, for which a block ack is received with 5 bits set:
|
||||
* tx_mpdu : shall increase by 5
|
||||
* retries : shall increase by 16
|
||||
* tx_ampdu : shall increase by 1
|
||||
* data packet counters shall not increase regardless of the number of BAR potentially sent by device for this a-mpdu
|
||||
* data packet counters shall not increase regardless of the number of BA received by device for this a-mpdu
|
||||
*
|
||||
* For each subsequent retransmission of the 11 remaining non ACK'ed mpdus
|
||||
* (regardless of the fact that they are transmitted in a-mpdu or not)
|
||||
* retries : shall increase by 1
|
||||
*
|
||||
* If no subsequent BA or ACK are received from AP, until packet lifetime expires for those 11 packet that were not ACK'ed
|
||||
* mpdu_lost : shall increase by 11
|
||||
*/
|
||||
|
||||
/* per rate statistics */
|
||||
typedef struct {
|
||||
wifi_rate rate; // rate information
|
||||
u32 tx_mpdu; // number of successfully transmitted data pkts (ACK rcvd)
|
||||
u32 rx_mpdu; // number of received data pkts
|
||||
u32 mpdu_lost; // number of data packet losses (no ACK)
|
||||
u32 retries; // total number of data pkt retries
|
||||
u32 retries_short; // number of short data pkt retries
|
||||
u32 retries_long; // number of long data pkt retries
|
||||
} wifi_rate_stat;
|
||||
|
||||
/* access categories */
|
||||
typedef enum {
|
||||
WIFI_AC_VO = 0,
|
||||
WIFI_AC_VI = 1,
|
||||
WIFI_AC_BE = 2,
|
||||
WIFI_AC_BK = 3,
|
||||
WIFI_AC_MAX = 4,
|
||||
} wifi_traffic_ac;
|
||||
|
||||
/* wifi peer type */
|
||||
typedef enum
|
||||
{
|
||||
WIFI_PEER_STA,
|
||||
WIFI_PEER_AP,
|
||||
WIFI_PEER_P2P_GO,
|
||||
WIFI_PEER_P2P_CLIENT,
|
||||
WIFI_PEER_NAN,
|
||||
WIFI_PEER_TDLS,
|
||||
WIFI_PEER_INVALID,
|
||||
} wifi_peer_type;
|
||||
|
||||
/* per peer statistics */
|
||||
typedef struct {
|
||||
wifi_peer_type type; // peer type (AP, TDLS, GO etc.)
|
||||
u8 peer_mac_address[6]; // mac address
|
||||
u32 capabilities; // peer WIFI_CAPABILITY_XXX
|
||||
u32 num_rate; // number of rates
|
||||
wifi_rate_stat rate_stats[]; // per rate statistics, number of entries = num_rate
|
||||
} wifi_peer_info;
|
||||
|
||||
/* Per access category statistics */
|
||||
typedef struct {
|
||||
wifi_traffic_ac ac; // access category (VI, VO, BE, BK)
|
||||
u32 tx_mpdu; // number of successfully transmitted unicast data pkts (ACK rcvd)
|
||||
u32 rx_mpdu; // number of received unicast data packets
|
||||
u32 tx_mcast; // number of succesfully transmitted multicast data packets
|
||||
// STA case: implies ACK received from AP for the unicast packet in which mcast pkt was sent
|
||||
u32 rx_mcast; // number of received multicast data packets
|
||||
u32 rx_ampdu; // number of received unicast a-mpdus; support of this counter is optional
|
||||
u32 tx_ampdu; // number of transmitted unicast a-mpdus; support of this counter is optional
|
||||
u32 mpdu_lost; // number of data pkt losses (no ACK)
|
||||
u32 retries; // total number of data pkt retries
|
||||
u32 retries_short; // number of short data pkt retries
|
||||
u32 retries_long; // number of long data pkt retries
|
||||
u32 contention_time_min; // data pkt min contention time (usecs)
|
||||
u32 contention_time_max; // data pkt max contention time (usecs)
|
||||
u32 contention_time_avg; // data pkt avg contention time (usecs)
|
||||
u32 contention_num_samples; // num of data pkts used for contention statistics
|
||||
} wifi_wmm_ac_stat;
|
||||
|
||||
/* interface statistics */
|
||||
typedef struct {
|
||||
wifi_interface_handle iface; // wifi interface
|
||||
wifi_interface_link_layer_info info; // current state of the interface
|
||||
u32 beacon_rx; // access point beacon received count from connected AP
|
||||
u64 average_tsf_offset; // average beacon offset encountered (beacon_TSF - TBTT)
|
||||
// The average_tsf_offset field is used so as to calculate the
|
||||
// typical beacon contention time on the channel as well may be
|
||||
// used to debug beacon synchronization and related power consumption issue
|
||||
u32 leaky_ap_detected; // indicate that this AP typically leaks packets beyond the driver guard time.
|
||||
u32 leaky_ap_avg_num_frames_leaked; // average number of frame leaked by AP after frame with PM bit set was ACK'ed by AP
|
||||
u32 leaky_ap_guard_time; // guard time currently in force (when implementing IEEE power management based on
|
||||
// frame control PM bit), How long driver waits before shutting down the radio and
|
||||
// after receiving an ACK for a data frame with PM bit set)
|
||||
u32 mgmt_rx; // access point mgmt frames received count from connected AP (including Beacon)
|
||||
u32 mgmt_action_rx; // action frames received count
|
||||
u32 mgmt_action_tx; // action frames transmit count
|
||||
wifi_rssi rssi_mgmt; // access Point Beacon and Management frames RSSI (averaged)
|
||||
wifi_rssi rssi_data; // access Point Data Frames RSSI (averaged) from connected AP
|
||||
wifi_rssi rssi_ack; // access Point ACK RSSI (averaged) from connected AP
|
||||
wifi_wmm_ac_stat ac[WIFI_AC_MAX]; // per ac data packet statistics
|
||||
u32 num_peers; // number of peers
|
||||
wifi_peer_info peer_info[]; // per peer statistics
|
||||
} wifi_iface_stat;
|
||||
|
||||
/* configuration params */
|
||||
typedef struct {
|
||||
u32 mpdu_size_threshold; // threshold to classify the pkts as short or long
|
||||
// packet size < mpdu_size_threshold => short
|
||||
u32 aggressive_statistics_gathering; // set for field debug mode. Driver should collect all statistics regardless of performance impact.
|
||||
} wifi_link_layer_params;
|
||||
|
||||
/* API to trigger the link layer statistics collection.
|
||||
Unless his API is invoked - link layer statistics will not be collected.
|
||||
Radio statistics (once started) do not stop or get reset unless wifi_clear_link_stats is invoked
|
||||
Interface statistics (once started) reset and start afresh after each connection */
|
||||
wifi_error wifi_set_link_stats(wifi_interface_handle iface, wifi_link_layer_params params);
|
||||
|
||||
/* callback for reporting link layer stats */
|
||||
typedef struct {
|
||||
void (*on_link_stats_results) (wifi_request_id id, wifi_iface_stat *iface_stat,
|
||||
int num_radios, wifi_radio_stat *radio_stat);
|
||||
} wifi_stats_result_handler;
|
||||
|
||||
/* api to collect the link layer statistics for a given iface and all the radio stats */
|
||||
wifi_error wifi_get_link_stats(wifi_request_id id,
|
||||
wifi_interface_handle iface, wifi_stats_result_handler handler);
|
||||
|
||||
/* wifi statistics bitmap */
|
||||
#define WIFI_STATS_RADIO 0x00000001 // all radio statistics
|
||||
#define WIFI_STATS_RADIO_CCA 0x00000002 // cca_busy_time (within radio statistics)
|
||||
#define WIFI_STATS_RADIO_CHANNELS 0x00000004 // all channel statistics (within radio statistics)
|
||||
#define WIFI_STATS_RADIO_SCAN 0x00000008 // all scan statistics (within radio statistics)
|
||||
#define WIFI_STATS_IFACE 0x00000010 // all interface statistics
|
||||
#define WIFI_STATS_IFACE_TXRATE 0x00000020 // all tx rate statistics (within interface statistics)
|
||||
#define WIFI_STATS_IFACE_AC 0x00000040 // all ac statistics (within interface statistics)
|
||||
#define WIFI_STATS_IFACE_CONTENTION 0x00000080 // all contention (min, max, avg) statistics (within ac statisctics)
|
||||
|
||||
/* clear api to reset statistics, stats_clear_rsp_mask identifies what stats have been cleared
|
||||
stop_req = 1 will imply whether to stop the statistics collection.
|
||||
stop_rsp = 1 will imply that stop_req was honored and statistics collection was stopped.
|
||||
*/
|
||||
wifi_error wifi_clear_link_stats(wifi_interface_handle iface,
|
||||
u32 stats_clear_req_mask, u32 *stats_clear_rsp_mask, u8 stop_req, u8 *stop_rsp);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif /* __cplusplus */
|
||||
|
||||
#endif /*__WIFI_HAL_STATS_ */
|
||||
|
|
@ -0,0 +1,41 @@
|
|||
/*
|
||||
* Copyright (C) 2008 The Android Open Source Project
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#ifndef _HARDWARE_POWER_H
|
||||
#define _HARDWARE_POWER_H
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
#if __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
enum {
|
||||
PARTIAL_WAKE_LOCK = 1, // the cpu stays on, but the screen is off
|
||||
FULL_WAKE_LOCK = 2 // the screen is also on
|
||||
};
|
||||
|
||||
// while you have a lock held, the device will stay on at least at the
|
||||
// level you request.
|
||||
int acquire_wake_lock(int lock, const char* id);
|
||||
int release_wake_lock(const char* id);
|
||||
|
||||
|
||||
#if __cplusplus
|
||||
} // extern "C"
|
||||
#endif
|
||||
|
||||
#endif // _HARDWARE_POWER_H
|
|
@ -0,0 +1,61 @@
|
|||
/*
|
||||
* Copyright (C) 2016 The Android Open Source Project
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#ifndef __WIFI_HAL_ROAM_H__
|
||||
#define __WIFI_HAL_ROAM_H__
|
||||
|
||||
#include "wifi_hal.h"
|
||||
|
||||
#define MAX_BLACKLIST_BSSID 16
|
||||
#define MAX_WHITELIST_SSID 8
|
||||
#define MAX_SSID_LENGTH 32
|
||||
|
||||
typedef struct {
|
||||
u32 max_blacklist_size;
|
||||
u32 max_whitelist_size;
|
||||
} wifi_roaming_capabilities;
|
||||
|
||||
typedef enum {
|
||||
ROAMING_DISABLE,
|
||||
ROAMING_ENABLE
|
||||
} fw_roaming_state_t;
|
||||
|
||||
typedef struct {
|
||||
u32 length;
|
||||
char ssid_str[MAX_SSID_LENGTH];
|
||||
} ssid_t;
|
||||
|
||||
typedef struct {
|
||||
u32 num_blacklist_bssid; // Number of bssids valid in blacklist_bssid[].
|
||||
mac_addr blacklist_bssid[MAX_BLACKLIST_BSSID]; // List of bssids which should not be considered
|
||||
// for romaing by firmware/driver.
|
||||
u32 num_whitelist_ssid; // Number of ssids valid in whitelist_ssid[].
|
||||
ssid_t whitelist_ssid[MAX_WHITELIST_SSID]; // List of ssids to which firmware/driver can
|
||||
// consider to roam to.
|
||||
} wifi_roaming_config;
|
||||
|
||||
/* Get the chipset roaming capabilities. */
|
||||
wifi_error wifi_get_roaming_capabilities(wifi_interface_handle handle,
|
||||
wifi_roaming_capabilities *caps);
|
||||
/* Enable/disable firmware roaming */
|
||||
wifi_error wifi_enable_firmware_roaming(wifi_interface_handle handle,
|
||||
fw_roaming_state_t state);
|
||||
|
||||
/* Pass down the blacklist BSSID and whitelist SSID to firmware. */
|
||||
wifi_error wifi_configure_roaming(wifi_interface_handle handle,
|
||||
wifi_roaming_config *roaming_config);
|
||||
|
||||
#endif /* __WIFI_HAL_ROAM_H__ */
|
|
@ -0,0 +1,305 @@
|
|||
|
||||
#include "wifi_hal.h"
|
||||
#include "gscan.h"
|
||||
|
||||
#ifndef __WIFI_HAL_RTT_H__
|
||||
#define __WIFI_HAL_RTT_H__
|
||||
|
||||
/* Ranging status */
|
||||
typedef enum {
|
||||
RTT_STATUS_SUCCESS = 0,
|
||||
RTT_STATUS_FAILURE = 1, // general failure status
|
||||
RTT_STATUS_FAIL_NO_RSP = 2, // target STA does not respond to request
|
||||
RTT_STATUS_FAIL_REJECTED = 3, // request rejected. Applies to 2-sided RTT only
|
||||
RTT_STATUS_FAIL_NOT_SCHEDULED_YET = 4,
|
||||
RTT_STATUS_FAIL_TM_TIMEOUT = 5, // timing measurement times out
|
||||
RTT_STATUS_FAIL_AP_ON_DIFF_CHANNEL = 6, // Target on different channel, cannot range
|
||||
RTT_STATUS_FAIL_NO_CAPABILITY = 7, // ranging not supported
|
||||
RTT_STATUS_ABORTED = 8, // request aborted for unknown reason
|
||||
RTT_STATUS_FAIL_INVALID_TS = 9, // Invalid T1-T4 timestamp
|
||||
RTT_STATUS_FAIL_PROTOCOL = 10, // 11mc protocol failed
|
||||
RTT_STATUS_FAIL_SCHEDULE = 11, // request could not be scheduled
|
||||
RTT_STATUS_FAIL_BUSY_TRY_LATER = 12, // responder cannot collaborate at time of request
|
||||
RTT_STATUS_INVALID_REQ = 13, // bad request args
|
||||
RTT_STATUS_NO_WIFI = 14, // WiFi not enabled
|
||||
RTT_STATUS_FAIL_FTM_PARAM_OVERRIDE = 15 // Responder overrides param info, cannot range with new params
|
||||
} wifi_rtt_status;
|
||||
|
||||
/* RTT peer type */
|
||||
typedef enum {
|
||||
RTT_PEER_AP = 0x1,
|
||||
RTT_PEER_STA = 0x2,
|
||||
RTT_PEER_P2P_GO = 0x3,
|
||||
RTT_PEER_P2P_CLIENT = 0x4,
|
||||
RTT_PEER_NAN = 0x5
|
||||
} rtt_peer_type;
|
||||
|
||||
/* RTT Measurement Bandwidth */
|
||||
typedef enum {
|
||||
WIFI_RTT_BW_5 = 0x01,
|
||||
WIFI_RTT_BW_10 = 0x02,
|
||||
WIFI_RTT_BW_20 = 0x04,
|
||||
WIFI_RTT_BW_40 = 0x08,
|
||||
WIFI_RTT_BW_80 = 0x10,
|
||||
WIFI_RTT_BW_160 = 0x20
|
||||
} wifi_rtt_bw;
|
||||
|
||||
/* RTT Measurement Preamble */
|
||||
typedef enum {
|
||||
WIFI_RTT_PREAMBLE_LEGACY = 0x1,
|
||||
WIFI_RTT_PREAMBLE_HT = 0x2,
|
||||
WIFI_RTT_PREAMBLE_VHT = 0x4
|
||||
} wifi_rtt_preamble;
|
||||
|
||||
/* RTT Type */
|
||||
typedef enum {
|
||||
RTT_TYPE_1_SIDED = 0x1,
|
||||
RTT_TYPE_2_SIDED = 0x2,
|
||||
} wifi_rtt_type;
|
||||
|
||||
/* RTT configuration */
|
||||
typedef struct {
|
||||
mac_addr addr; // peer device mac address
|
||||
wifi_rtt_type type; // 1-sided or 2-sided RTT
|
||||
rtt_peer_type peer; // optional - peer device hint (STA, P2P, AP)
|
||||
wifi_channel_info channel; // Required for STA-AP mode, optional for P2P, NBD etc.
|
||||
unsigned burst_period; // Time interval between bursts (units: 100 ms).
|
||||
// Applies to 1-sided and 2-sided RTT multi-burst requests.
|
||||
// Range: 0-31, 0: no preference by initiator (2-sided RTT)
|
||||
unsigned num_burst; // Total number of RTT bursts to be executed. It will be
|
||||
// specified in the same way as the parameter "Number of
|
||||
// Burst Exponent" found in the FTM frame format. It
|
||||
// applies to both: 1-sided RTT and 2-sided RTT. Valid
|
||||
// values are 0 to 15 as defined in 802.11mc std.
|
||||
// 0 means single shot
|
||||
// The implication of this parameter on the maximum
|
||||
// number of RTT results is the following:
|
||||
// for 1-sided RTT: max num of RTT results = (2^num_burst)*(num_frames_per_burst)
|
||||
// for 2-sided RTT: max num of RTT results = (2^num_burst)*(num_frames_per_burst - 1)
|
||||
unsigned num_frames_per_burst; // num of frames per burst.
|
||||
// Minimum value = 1, Maximum value = 31
|
||||
// For 2-sided this equals the number of FTM frames
|
||||
// to be attempted in a single burst. This also
|
||||
// equals the number of FTM frames that the
|
||||
// initiator will request that the responder send
|
||||
// in a single frame.
|
||||
unsigned num_retries_per_rtt_frame; // number of retries for a failed RTT frame. Applies
|
||||
// to 1-sided RTT only. Minimum value = 0, Maximum value = 3
|
||||
|
||||
//following fields are only valid for 2-side RTT
|
||||
unsigned num_retries_per_ftmr; // Maximum number of retries that the initiator can
|
||||
// retry an FTMR frame.
|
||||
// Minimum value = 0, Maximum value = 3
|
||||
byte LCI_request; // 1: request LCI, 0: do not request LCI
|
||||
byte LCR_request; // 1: request LCR, 0: do not request LCR
|
||||
unsigned burst_duration; // Applies to 1-sided and 2-sided RTT. Valid values will
|
||||
// be 2-11 and 15 as specified by the 802.11mc std for
|
||||
// the FTM parameter burst duration. In a multi-burst
|
||||
// request, if responder overrides with larger value,
|
||||
// the initiator will return failure. In a single-burst
|
||||
// request if responder overrides with larger value,
|
||||
// the initiator will sent TMR_STOP to terminate RTT
|
||||
// at the end of the burst_duration it requested.
|
||||
wifi_rtt_preamble preamble; // RTT preamble to be used in the RTT frames
|
||||
wifi_rtt_bw bw; // RTT BW to be used in the RTT frames
|
||||
} wifi_rtt_config;
|
||||
|
||||
/* RTT results */
|
||||
typedef struct {
|
||||
mac_addr addr; // device mac address
|
||||
unsigned burst_num; // burst number in a multi-burst request
|
||||
unsigned measurement_number; // Total RTT measurement frames attempted
|
||||
unsigned success_number; // Total successful RTT measurement frames
|
||||
byte number_per_burst_peer; // Maximum number of "FTM frames per burst" supported by
|
||||
// the responder STA. Applies to 2-sided RTT only.
|
||||
// If reponder overrides with larger value:
|
||||
// - for single-burst request initiator will truncate the
|
||||
// larger value and send a TMR_STOP after receiving as
|
||||
// many frames as originally requested.
|
||||
// - for multi-burst request, initiator will return
|
||||
// failure right away.
|
||||
wifi_rtt_status status; // ranging status
|
||||
byte retry_after_duration; // When status == RTT_STATUS_FAIL_BUSY_TRY_LATER,
|
||||
// this will be the time provided by the responder as to
|
||||
// when the request can be tried again. Applies to 2-sided
|
||||
// RTT only. In sec, 1-31sec.
|
||||
wifi_rtt_type type; // RTT type
|
||||
wifi_rssi rssi; // average rssi in 0.5 dB steps e.g. 143 implies -71.5 dB
|
||||
wifi_rssi rssi_spread; // rssi spread in 0.5 dB steps e.g. 5 implies 2.5 dB spread (optional)
|
||||
wifi_rate tx_rate; // 1-sided RTT: TX rate of RTT frame.
|
||||
// 2-sided RTT: TX rate of initiator's Ack in response to FTM frame.
|
||||
wifi_rate rx_rate; // 1-sided RTT: TX rate of Ack from other side.
|
||||
// 2-sided RTT: TX rate of FTM frame coming from responder.
|
||||
wifi_timespan rtt; // round trip time in picoseconds
|
||||
wifi_timespan rtt_sd; // rtt standard deviation in picoseconds
|
||||
wifi_timespan rtt_spread; // difference between max and min rtt times recorded in picoseconds
|
||||
int distance_mm; // distance in mm (optional)
|
||||
int distance_sd_mm; // standard deviation in mm (optional)
|
||||
int distance_spread_mm; // difference between max and min distance recorded in mm (optional)
|
||||
wifi_timestamp ts; // time of the measurement (in microseconds since boot)
|
||||
int burst_duration; // in ms, actual time taken by the FW to finish one burst
|
||||
// measurement. Applies to 1-sided and 2-sided RTT.
|
||||
int negotiated_burst_num; // Number of bursts allowed by the responder. Applies
|
||||
// to 2-sided RTT only.
|
||||
wifi_information_element *LCI; // for 11mc only
|
||||
wifi_information_element *LCR; // for 11mc only
|
||||
} wifi_rtt_result;
|
||||
|
||||
/* RTT result callback */
|
||||
typedef struct {
|
||||
void (*on_rtt_results) (wifi_request_id id, unsigned num_results, wifi_rtt_result *rtt_result[]);
|
||||
} wifi_rtt_event_handler;
|
||||
|
||||
/* API to request RTT measurement */
|
||||
wifi_error wifi_rtt_range_request(wifi_request_id id, wifi_interface_handle iface,
|
||||
unsigned num_rtt_config, wifi_rtt_config rtt_config[], wifi_rtt_event_handler handler);
|
||||
|
||||
/* API to cancel RTT measurements */
|
||||
wifi_error wifi_rtt_range_cancel(wifi_request_id id, wifi_interface_handle iface,
|
||||
unsigned num_devices, mac_addr addr[]);
|
||||
|
||||
/* NBD ranging channel map */
|
||||
typedef struct {
|
||||
wifi_channel availablity[32]; // specifies the channel map for each of the 16 TU windows
|
||||
// frequency of 0 => unspecified; which means firmware is
|
||||
// free to do whatever it wants in this window.
|
||||
} wifi_channel_map;
|
||||
|
||||
/* API to start publishing the channel map on responder device in a NBD cluster.
|
||||
Responder device will take this request and schedule broadcasting the channel map
|
||||
in a NBD ranging attribute in a SDF. DE will automatically remove the ranging
|
||||
attribute from the OTA queue after number of DW specified by num_dw
|
||||
where Each DW is 512 TUs apart */
|
||||
wifi_error wifi_rtt_channel_map_set(wifi_request_id id,
|
||||
wifi_interface_handle iface, wifi_channel_map *params, unsigned num_dw);
|
||||
|
||||
/* API to clear the channel map on the responder device in a NBD cluster.
|
||||
Responder device will cancel future ranging channel request, starting from next
|
||||
DW interval and will also stop broadcasting NBD ranging attribute in SDF */
|
||||
wifi_error wifi_rtt_channel_map_clear(wifi_request_id id, wifi_interface_handle iface);
|
||||
|
||||
// Preamble definition for bit mask used in wifi_rtt_capabilities
|
||||
#define PREAMBLE_LEGACY 0x1
|
||||
#define PREAMBLE_HT 0x2
|
||||
#define PREAMBLE_VHT 0x4
|
||||
|
||||
// BW definition for bit mask used in wifi_rtt_capabilities
|
||||
#define BW_5_SUPPORT 0x1
|
||||
#define BW_10_SUPPORT 0x2
|
||||
#define BW_20_SUPPORT 0x4
|
||||
#define BW_40_SUPPORT 0x8
|
||||
#define BW_80_SUPPORT 0x10
|
||||
#define BW_160_SUPPORT 0x20
|
||||
|
||||
/* RTT Capabilities */
|
||||
typedef struct {
|
||||
byte rtt_one_sided_supported; // if 1-sided rtt data collection is supported
|
||||
byte rtt_ftm_supported; // if ftm rtt data collection is supported
|
||||
byte lci_support; // if initiator supports LCI request. Applies to 2-sided RTT
|
||||
byte lcr_support; // if initiator supports LCR request. Applies to 2-sided RTT
|
||||
byte preamble_support; // bit mask indicates what preamble is supported by initiator
|
||||
byte bw_support; // bit mask indicates what BW is supported by initiator
|
||||
byte responder_supported; // if 11mc responder mode is supported
|
||||
byte mc_version; // draft 11mc spec version supported by chip. For instance,
|
||||
// version 4.0 should be 40 and version 4.3 should be 43 etc.
|
||||
} wifi_rtt_capabilities;
|
||||
|
||||
/* RTT capabilities of the device */
|
||||
wifi_error wifi_get_rtt_capabilities(wifi_interface_handle iface, wifi_rtt_capabilities *capabilities);
|
||||
|
||||
/* debugging definitions */
|
||||
enum {
|
||||
RTT_DEBUG_DISABLE,
|
||||
RTT_DEBUG_LOG,
|
||||
RTT_DEBUG_PROTO,
|
||||
RTT_DEBUG_BURST,
|
||||
RTT_DEBUG_ACCURACY,
|
||||
RTT_DEBUG_LOGDETAIL
|
||||
}; //rtt debug type
|
||||
|
||||
enum {
|
||||
RTT_DEBUG_FORMAT_TXT,
|
||||
RTT_DEBUG_FORMAT_BINARY
|
||||
}; //rtt debug format
|
||||
|
||||
typedef struct rtt_debug {
|
||||
unsigned version;
|
||||
unsigned len; // total length of after len field
|
||||
unsigned type; // rtt debug type
|
||||
unsigned format; //rtt debug format
|
||||
char dbuf[0]; // debug content
|
||||
} rtt_debug_t;
|
||||
|
||||
/* set configuration for debug */
|
||||
wifi_error wifi_rtt_debug_cfg(wifi_interface_handle h, unsigned rtt_dbg_type, char *cfgbuf, unsigned cfg_buf_size);
|
||||
/* get the debug information */
|
||||
wifi_error wifi_rtt_debug_get(wifi_interface_handle h, rtt_debug_t **debugbuf);
|
||||
/* free the debug buffer */
|
||||
wifi_error wifi_rtt_debug_free(wifi_interface_handle h, rtt_debug_t *debugbuf);
|
||||
|
||||
/* API for setting LCI/LCR information to be provided to a requestor */
|
||||
typedef enum {
|
||||
WIFI_MOTION_NOT_EXPECTED = 0, // Not expected to change location
|
||||
WIFI_MOTION_EXPECTED = 1, // Expected to change location
|
||||
WIFI_MOTION_UNKNOWN = 2, // Movement pattern unknown
|
||||
} wifi_motion_pattern;
|
||||
|
||||
typedef struct {
|
||||
long latitude; // latitude in degrees * 2^25 , 2's complement
|
||||
long longitude; // latitude in degrees * 2^25 , 2's complement
|
||||
int altitude; // Altitude in units of 1/256 m
|
||||
byte latitude_unc; // As defined in Section 2.3.2 of IETF RFC 6225
|
||||
byte longitude_unc; // As defined in Section 2.3.2 of IETF RFC 6225
|
||||
byte altitude_unc; // As defined in Section 2.4.5 from IETF RFC 6225:
|
||||
|
||||
//Following element for configuring the Z subelement
|
||||
wifi_motion_pattern motion_pattern;
|
||||
int floor; // floor in units of 1/16th of floor. 0x80000000 if unknown.
|
||||
int height_above_floor; // in units of 1/64 m
|
||||
int height_unc; // in units of 1/64 m. 0 if unknown
|
||||
} wifi_lci_information;
|
||||
|
||||
typedef struct {
|
||||
char country_code[2]; // country code
|
||||
int length; // length of the info field
|
||||
char civic_info[256]; // Civic info to be copied in FTM frame
|
||||
} wifi_lcr_information;
|
||||
|
||||
// API to configure the LCI. Used in RTT Responder mode only
|
||||
wifi_error wifi_set_lci(wifi_request_id id, wifi_interface_handle iface,
|
||||
wifi_lci_information *lci);
|
||||
|
||||
// API to configure the LCR. Used in RTT Responder mode only.
|
||||
wifi_error wifi_set_lcr(wifi_request_id id, wifi_interface_handle iface,
|
||||
wifi_lcr_information *lcr);
|
||||
|
||||
/**
|
||||
* RTT Responder information
|
||||
*/
|
||||
typedef struct {
|
||||
wifi_channel_info channel;
|
||||
wifi_rtt_preamble preamble;
|
||||
} wifi_rtt_responder;
|
||||
|
||||
/**
|
||||
* Get RTT responder information e.g. WiFi channel to enable responder on.
|
||||
*/
|
||||
wifi_error wifi_rtt_get_responder_info(wifi_interface_handle iface,
|
||||
wifi_rtt_responder *responder_info);
|
||||
|
||||
/**
|
||||
* Enable RTT responder mode.
|
||||
* channel_hint - hint of the channel information where RTT responder should be enabled on.
|
||||
* max_duration_seconds - timeout of responder mode.
|
||||
* channel_used - channel used for RTT responder, NULL if responder is not enabled.
|
||||
*/
|
||||
wifi_error wifi_enable_responder(wifi_request_id id, wifi_interface_handle iface,
|
||||
wifi_channel_info channel_hint, unsigned max_duration_seconds,
|
||||
wifi_rtt_responder *responder_info);
|
||||
|
||||
/**
|
||||
* Disable RTT responder mode.
|
||||
*/
|
||||
wifi_error wifi_disable_responder(wifi_request_id id, wifi_interface_handle iface);
|
||||
|
||||
#endif
|
|
@ -0,0 +1,85 @@
|
|||
|
||||
#include "wifi_hal.h"
|
||||
|
||||
#ifndef _TDLS_H_
|
||||
#define _TDLS_H_
|
||||
|
||||
typedef enum {
|
||||
WIFI_TDLS_DISABLED = 1, /* TDLS is not enabled, default status for all STAs */
|
||||
WIFI_TDLS_ENABLED, /* TDLS is enabled, but not yet tried */
|
||||
WIFI_TDLS_ESTABLISHED, /* Direct link is established */
|
||||
WIFI_TDLS_ESTABLISHED_OFF_CHANNEL, /* Direct link is established using MCC */
|
||||
WIFI_TDLS_DROPPED, /* Direct link was established,
|
||||
* but is temporarily dropped now */
|
||||
WIFI_TDLS_FAILED /* TDLS permanent failed. Inform error to upper layer
|
||||
* and go back to WIFI_TDLS_DISABLED */
|
||||
} wifi_tdls_state;
|
||||
|
||||
typedef enum {
|
||||
WIFI_TDLS_SUCCESS, /* Success */
|
||||
WIFI_TDLS_UNSPECIFIED = -1, /* Unspecified reason */
|
||||
WIFI_TDLS_NOT_SUPPORTED = -2, /* Remote side doesn't support TDLS */
|
||||
WIFI_TDLS_UNSUPPORTED_BAND = -3, /* Remote side doesn't support this band */
|
||||
WIFI_TDLS_NOT_BENEFICIAL = -4, /* Going to AP is better than going direct */
|
||||
WIFI_TDLS_DROPPED_BY_REMOTE = -5 /* Remote side doesn't want it anymore */
|
||||
} wifi_tdls_reason;
|
||||
|
||||
typedef struct {
|
||||
int channel; /* channel hint, in channel number (NOT frequency ) */
|
||||
int global_operating_class; /* operating class to use */
|
||||
int max_latency_ms; /* max latency that can be tolerated by apps */
|
||||
int min_bandwidth_kbps; /* bandwidth required by apps, in kilo bits per second */
|
||||
} wifi_tdls_params;
|
||||
|
||||
typedef struct {
|
||||
int channel;
|
||||
int global_operating_class;
|
||||
wifi_tdls_state state;
|
||||
wifi_tdls_reason reason;
|
||||
} wifi_tdls_status;
|
||||
|
||||
typedef struct {
|
||||
int max_concurrent_tdls_session_num; /* Maximum TDLS session number can be supported by the
|
||||
* Firmware and hardware*/
|
||||
int is_global_tdls_supported; /* 1 -- support, 0 -- not support */
|
||||
int is_per_mac_tdls_supported; /* 1 -- support, 0 -- not support */
|
||||
int is_off_channel_tdls_supported; /* 1 -- support, 0 -- not support */
|
||||
} wifi_tdls_capabilities;
|
||||
|
||||
typedef struct {
|
||||
/* on_tdls_state_changed - reports state of TDLS link to framework
|
||||
* Report this event when the state of TDLS link changes */
|
||||
void (*on_tdls_state_changed)(mac_addr addr, wifi_tdls_status status);
|
||||
} wifi_tdls_handler;
|
||||
|
||||
|
||||
/* wifi_enable_tdls - enables TDLS-auto mode for a specific route
|
||||
*
|
||||
* params specifies hints, which provide more information about
|
||||
* why TDLS is being sought. The firmware should do its best to
|
||||
* honor the hints before downgrading regular AP link
|
||||
* If upper layer has no specific values, this should be NULL
|
||||
*
|
||||
* handler is used to inform the upper layer about the status change and the corresponding reason
|
||||
*/
|
||||
wifi_error wifi_enable_tdls(wifi_interface_handle iface, mac_addr addr,
|
||||
wifi_tdls_params *params, wifi_tdls_handler handler);
|
||||
|
||||
/* wifi_disable_tdls - disables TDLS-auto mode for a specific route
|
||||
*
|
||||
* This terminates any existing TDLS with addr device, and frees the
|
||||
* device resources to make TDLS connections on new routes.
|
||||
*
|
||||
* DON'T fire any more events on 'handler' specified in earlier call to
|
||||
* wifi_enable_tdls after this action.
|
||||
*/
|
||||
wifi_error wifi_disable_tdls(wifi_interface_handle iface, mac_addr addr);
|
||||
|
||||
/* wifi_get_tdls_status - allows getting the status of TDLS for a specific route */
|
||||
wifi_error wifi_get_tdls_status(wifi_interface_handle iface, mac_addr addr,
|
||||
wifi_tdls_status *status);
|
||||
|
||||
/* return the current HW + Firmware combination's TDLS capabilities */
|
||||
wifi_error wifi_get_tdls_capabilities(wifi_interface_handle iface,
|
||||
wifi_tdls_capabilities *capabilities);
|
||||
#endif
|
|
@ -0,0 +1,35 @@
|
|||
/*
|
||||
* Copyright (C) 2008 The Android Open Source Project
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#ifndef _HARDWARE_UEVENT_H
|
||||
#define _HARDWARE_UEVENT_H
|
||||
|
||||
#if __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
int uevent_init();
|
||||
int uevent_get_fd();
|
||||
int uevent_next_event(char* buffer, int buffer_length);
|
||||
int uevent_add_native_handler(void (*handler)(void *data, const char *msg, int msg_len),
|
||||
void *handler_data);
|
||||
int uevent_remove_native_handler(void (*handler)(void *data, const char *msg, int msg_len));
|
||||
|
||||
#if __cplusplus
|
||||
} // extern "C"
|
||||
#endif
|
||||
|
||||
#endif // _HARDWARE_UEVENT_H
|
|
@ -0,0 +1,47 @@
|
|||
#include "wifi_hal.h"
|
||||
|
||||
#ifndef __WIFI_HAL_CONFIG_H
|
||||
#define __WIFI_HAL_CONFIG_H
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C"
|
||||
{
|
||||
#endif /* __cplusplus */
|
||||
|
||||
#define CONFIG_MAJOR_VERSION 1
|
||||
#define CONFIG_MINOR_VERSION 0
|
||||
#define CONFIG_MICRO_VERSION 0
|
||||
|
||||
typedef int wifi_radio;
|
||||
|
||||
// whether the wifi chipset wakes at every dtim beacon or a multiple of the dtim period
|
||||
// if extended_dtim is set to 3, the STA shall wake up every 3 DTIM beacons
|
||||
wifi_error wifi_extended_dtim_config_set(wifi_request_id id,
|
||||
wifi_interface_handle iface, int extended_dtim);
|
||||
|
||||
//set the country code to driver
|
||||
wifi_error wifi_set_country_code(wifi_interface_handle iface, const char* country_code);
|
||||
|
||||
//set the wifi_iface stats averaging factor used to calculate
|
||||
// statistics like average the TSF offset or average number of frame leaked
|
||||
// For instance, upon beacon reception:
|
||||
// current_avg = ((beacon_TSF - TBTT) * factor + previous_avg * (0x10000 - factor) ) / 0x10000
|
||||
// For instance, when evaluating leaky APs:
|
||||
// current_avg = ((num frame received within guard time) * factor + previous_avg * (0x10000 - factor)) / 0x10000
|
||||
|
||||
wifi_error wifi_set_beacon_wifi_iface_stats_averaging_factor(wifi_request_id id, wifi_interface_handle iface,
|
||||
u16 factor);
|
||||
|
||||
// configure guard time, i.e. when implementing IEEE power management based on
|
||||
// frame control PM bit, how long driver waits before shutting down the radio and
|
||||
// after receiving an ACK for a data frame with PM bit set
|
||||
wifi_error wifi_set_guard_time(wifi_request_id id, wifi_interface_handle iface,
|
||||
u32 guard_time);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
|
||||
#endif /* __cplusplus */
|
||||
|
||||
#endif /*__WIFI_HAL_STATS_ */
|
||||
|
|
@ -0,0 +1,420 @@
|
|||
/*
|
||||
* Copyright (C) 2016 The Android Open Source Project
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#ifndef __WIFI_HAL_H__
|
||||
#define __WIFI_HAL_H__
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C"
|
||||
{
|
||||
#endif
|
||||
#include <stdint.h>
|
||||
|
||||
/* WiFi Common definitions */
|
||||
/* channel operating width */
|
||||
typedef enum {
|
||||
WIFI_CHAN_WIDTH_20 = 0,
|
||||
WIFI_CHAN_WIDTH_40 = 1,
|
||||
WIFI_CHAN_WIDTH_80 = 2,
|
||||
WIFI_CHAN_WIDTH_160 = 3,
|
||||
WIFI_CHAN_WIDTH_80P80 = 4,
|
||||
WIFI_CHAN_WIDTH_5 = 5,
|
||||
WIFI_CHAN_WIDTH_10 = 6,
|
||||
WIFI_CHAN_WIDTH_INVALID = -1
|
||||
} wifi_channel_width;
|
||||
|
||||
/* Pre selected Power scenarios to be applied from BDF file */
|
||||
typedef enum {
|
||||
WIFI_POWER_SCENARIO_VOICE_CALL = 0,
|
||||
} wifi_power_scenario;
|
||||
|
||||
typedef int wifi_radio;
|
||||
typedef int wifi_channel;
|
||||
|
||||
typedef struct {
|
||||
wifi_channel_width width;
|
||||
int center_frequency0;
|
||||
int center_frequency1;
|
||||
int primary_frequency;
|
||||
} wifi_channel_spec;
|
||||
|
||||
typedef enum {
|
||||
WIFI_SUCCESS = 0,
|
||||
WIFI_ERROR_NONE = 0,
|
||||
WIFI_ERROR_UNKNOWN = -1,
|
||||
WIFI_ERROR_UNINITIALIZED = -2,
|
||||
WIFI_ERROR_NOT_SUPPORTED = -3,
|
||||
WIFI_ERROR_NOT_AVAILABLE = -4, // Not available right now, but try later
|
||||
WIFI_ERROR_INVALID_ARGS = -5,
|
||||
WIFI_ERROR_INVALID_REQUEST_ID = -6,
|
||||
WIFI_ERROR_TIMED_OUT = -7,
|
||||
WIFI_ERROR_TOO_MANY_REQUESTS = -8, // Too many instances of this request
|
||||
WIFI_ERROR_OUT_OF_MEMORY = -9,
|
||||
WIFI_ERROR_BUSY = -10,
|
||||
} wifi_error;
|
||||
|
||||
typedef unsigned char byte;
|
||||
typedef unsigned char u8;
|
||||
typedef signed char s8;
|
||||
typedef uint16_t u16;
|
||||
typedef uint32_t u32;
|
||||
typedef int32_t s32;
|
||||
typedef uint64_t u64;
|
||||
typedef int64_t s64;
|
||||
typedef int wifi_request_id;
|
||||
typedef int wifi_channel; // indicates channel frequency in MHz
|
||||
typedef int wifi_rssi;
|
||||
typedef byte mac_addr[6];
|
||||
typedef byte oui[3];
|
||||
typedef int64_t wifi_timestamp; // In microseconds (us)
|
||||
typedef int64_t wifi_timespan; // In picoseconds (ps)
|
||||
|
||||
struct wifi_info;
|
||||
struct wifi_interface_info;
|
||||
typedef struct wifi_info *wifi_handle;
|
||||
typedef struct wifi_interface_info *wifi_interface_handle;
|
||||
|
||||
/* Initialize/Cleanup */
|
||||
|
||||
wifi_error wifi_initialize(wifi_handle *handle);
|
||||
typedef void (*wifi_cleaned_up_handler) (wifi_handle handle);
|
||||
void wifi_cleanup(wifi_handle handle, wifi_cleaned_up_handler handler);
|
||||
void wifi_event_loop(wifi_handle handle);
|
||||
|
||||
/* Error handling */
|
||||
void wifi_get_error_info(wifi_error err, const char **msg); // return a pointer to a static string
|
||||
|
||||
/* Feature enums */
|
||||
#define WIFI_FEATURE_INFRA 0x0001 // Basic infrastructure mode
|
||||
#define WIFI_FEATURE_INFRA_5G 0x0002 // Support for 5 GHz Band
|
||||
#define WIFI_FEATURE_HOTSPOT 0x0004 // Support for GAS/ANQP
|
||||
#define WIFI_FEATURE_P2P 0x0008 // Wifi-Direct
|
||||
#define WIFI_FEATURE_SOFT_AP 0x0010 // Soft AP
|
||||
#define WIFI_FEATURE_GSCAN 0x0020 // Google-Scan APIs
|
||||
#define WIFI_FEATURE_NAN 0x0040 // Neighbor Awareness Networking
|
||||
#define WIFI_FEATURE_D2D_RTT 0x0080 // Device-to-device RTT
|
||||
#define WIFI_FEATURE_D2AP_RTT 0x0100 // Device-to-AP RTT
|
||||
#define WIFI_FEATURE_BATCH_SCAN 0x0200 // Batched Scan (legacy)
|
||||
#define WIFI_FEATURE_PNO 0x0400 // Preferred network offload
|
||||
#define WIFI_FEATURE_ADDITIONAL_STA 0x0800 // Support for two STAs
|
||||
#define WIFI_FEATURE_TDLS 0x1000 // Tunnel directed link setup
|
||||
#define WIFI_FEATURE_TDLS_OFFCHANNEL 0x2000 // Support for TDLS off channel
|
||||
#define WIFI_FEATURE_EPR 0x4000 // Enhanced power reporting
|
||||
#define WIFI_FEATURE_AP_STA 0x8000 // Support for AP STA Concurrency
|
||||
#define WIFI_FEATURE_LINK_LAYER_STATS 0x10000 // Link layer stats collection
|
||||
#define WIFI_FEATURE_LOGGER 0x20000 // WiFi Logger
|
||||
#define WIFI_FEATURE_HAL_EPNO 0x40000 // WiFi PNO enhanced
|
||||
#define WIFI_FEATURE_RSSI_MONITOR 0x80000 // RSSI Monitor
|
||||
#define WIFI_FEATURE_MKEEP_ALIVE 0x100000 // WiFi mkeep_alive
|
||||
#define WIFI_FEATURE_CONFIG_NDO 0x200000 // ND offload configure
|
||||
#define WIFI_FEATURE_TX_TRANSMIT_POWER 0x400000 // Capture Tx transmit power levels
|
||||
#define WIFI_FEATURE_CONTROL_ROAMING 0x800000 // Enable/Disable firmware roaming
|
||||
#define WIFI_FEATURE_IE_WHITELIST 0x1000000 // Support Probe IE white listing
|
||||
#define WIFI_FEATURE_SCAN_RAND 0x2000000 // Support MAC & Probe Sequence Number randomization
|
||||
#define WIFI_FEATURE_SET_TX_POWER_LIMIT 0x4000000 // Support Tx Power Limit setting
|
||||
// Add more features here
|
||||
|
||||
|
||||
typedef int feature_set;
|
||||
|
||||
#define IS_MASK_SET(mask, flags) (((flags) & (mask)) == (mask))
|
||||
|
||||
#define IS_SUPPORTED_FEATURE(feature, featureSet) IS_MASK_SET(feature, featureSet)
|
||||
|
||||
/* Feature set */
|
||||
wifi_error wifi_get_supported_feature_set(wifi_interface_handle handle, feature_set *set);
|
||||
|
||||
/*
|
||||
* Each row represents a valid feature combination;
|
||||
* all other combinations are invalid!
|
||||
*/
|
||||
wifi_error wifi_get_concurrency_matrix(wifi_interface_handle handle, int set_size_max,
|
||||
feature_set set[], int *set_size);
|
||||
|
||||
/* multiple interface support */
|
||||
|
||||
wifi_error wifi_get_ifaces(wifi_handle handle, int *num_ifaces, wifi_interface_handle **ifaces);
|
||||
wifi_error wifi_get_iface_name(wifi_interface_handle iface, char *name, size_t size);
|
||||
wifi_interface_handle wifi_get_iface_handle(wifi_handle handle, char *name);
|
||||
|
||||
/* Configuration events */
|
||||
|
||||
typedef struct {
|
||||
void (*on_country_code_changed)(char code[2]); // We can get this from supplicant too
|
||||
|
||||
// More event handlers
|
||||
} wifi_event_handler;
|
||||
|
||||
typedef struct {
|
||||
void (*on_rssi_threshold_breached)(wifi_request_id id, u8 *cur_bssid, s8 cur_rssi);
|
||||
} wifi_rssi_event_handler;
|
||||
|
||||
wifi_error wifi_set_iface_event_handler(wifi_request_id id, wifi_interface_handle iface, wifi_event_handler eh);
|
||||
wifi_error wifi_reset_iface_event_handler(wifi_request_id id, wifi_interface_handle iface);
|
||||
|
||||
wifi_error wifi_set_nodfs_flag(wifi_interface_handle handle, u32 nodfs);
|
||||
wifi_error wifi_select_tx_power_scenario(wifi_interface_handle handle, wifi_power_scenario scenario);
|
||||
wifi_error wifi_reset_tx_power_scenario(wifi_interface_handle handle);
|
||||
|
||||
typedef struct rx_data_cnt_details_t {
|
||||
int rx_unicast_cnt; /*Total rx unicast packet which woke up host */
|
||||
int rx_multicast_cnt; /*Total rx multicast packet which woke up host */
|
||||
int rx_broadcast_cnt; /*Total rx broadcast packet which woke up host */
|
||||
} RX_DATA_WAKE_CNT_DETAILS;
|
||||
|
||||
typedef struct rx_wake_pkt_type_classification_t {
|
||||
int icmp_pkt; /*wake icmp packet count */
|
||||
int icmp6_pkt; /*wake icmp6 packet count */
|
||||
int icmp6_ra; /*wake icmp6 RA packet count */
|
||||
int icmp6_na; /*wake icmp6 NA packet count */
|
||||
int icmp6_ns; /*wake icmp6 NS packet count */
|
||||
//ToDo: Any more interesting classification to add?
|
||||
} RX_WAKE_PKT_TYPE_CLASSFICATION;
|
||||
|
||||
typedef struct rx_multicast_cnt_t{
|
||||
int ipv4_rx_multicast_addr_cnt; /*Rx wake packet was ipv4 multicast */
|
||||
int ipv6_rx_multicast_addr_cnt; /*Rx wake packet was ipv6 multicast */
|
||||
int other_rx_multicast_addr_cnt;/*Rx wake packet was non-ipv4 and non-ipv6*/
|
||||
} RX_MULTICAST_WAKE_DATA_CNT;
|
||||
|
||||
/*
|
||||
* Structure holding all the driver/firmware wake count reasons.
|
||||
*
|
||||
* Buffers for the array fields (cmd_event_wake_cnt/driver_fw_local_wake_cnt)
|
||||
* are allocated and freed by the framework. The size of each allocated
|
||||
* array is indicated by the corresponding |_cnt| field. HAL needs to fill in
|
||||
* the corresponding |_used| field to indicate the number of elements used in
|
||||
* the array.
|
||||
*/
|
||||
typedef struct wlan_driver_wake_reason_cnt_t {
|
||||
int total_cmd_event_wake; /* Total count of cmd event wakes */
|
||||
int *cmd_event_wake_cnt; /* Individual wake count array, each index a reason */
|
||||
int cmd_event_wake_cnt_sz; /* Max number of cmd event wake reasons */
|
||||
int cmd_event_wake_cnt_used; /* Number of cmd event wake reasons specific to the driver */
|
||||
|
||||
int total_driver_fw_local_wake; /* Total count of drive/fw wakes, for local reasons */
|
||||
int *driver_fw_local_wake_cnt; /* Individual wake count array, each index a reason */
|
||||
int driver_fw_local_wake_cnt_sz; /* Max number of local driver/fw wake reasons */
|
||||
int driver_fw_local_wake_cnt_used; /* Number of local driver/fw wake reasons specific to the driver */
|
||||
|
||||
int total_rx_data_wake; /* total data rx packets, that woke up host */
|
||||
RX_DATA_WAKE_CNT_DETAILS rx_wake_details;
|
||||
RX_WAKE_PKT_TYPE_CLASSFICATION rx_wake_pkt_classification_info;
|
||||
RX_MULTICAST_WAKE_DATA_CNT rx_multicast_wake_pkt_info;
|
||||
} WLAN_DRIVER_WAKE_REASON_CNT;
|
||||
|
||||
/* include various feature headers */
|
||||
|
||||
#include "gscan.h"
|
||||
#include "link_layer_stats.h"
|
||||
#include "rtt.h"
|
||||
#include "tdls.h"
|
||||
#include "wifi_logger.h"
|
||||
#include "wifi_config.h"
|
||||
#include "wifi_nan.h"
|
||||
#include "wifi_offload.h"
|
||||
#include "roam.h"
|
||||
|
||||
//wifi HAL function pointer table
|
||||
typedef struct {
|
||||
wifi_error (* wifi_initialize) (wifi_handle *);
|
||||
void (* wifi_cleanup) (wifi_handle, wifi_cleaned_up_handler);
|
||||
void (*wifi_event_loop)(wifi_handle);
|
||||
void (* wifi_get_error_info) (wifi_error , const char **);
|
||||
wifi_error (* wifi_get_supported_feature_set) (wifi_interface_handle, feature_set *);
|
||||
wifi_error (* wifi_get_concurrency_matrix) (wifi_interface_handle, int, feature_set *, int *);
|
||||
wifi_error (* wifi_set_scanning_mac_oui) (wifi_interface_handle, unsigned char *);
|
||||
wifi_error (* wifi_get_supported_channels)(wifi_handle, int *, wifi_channel *);
|
||||
wifi_error (* wifi_is_epr_supported)(wifi_handle);
|
||||
wifi_error (* wifi_get_ifaces) (wifi_handle , int *, wifi_interface_handle **);
|
||||
wifi_error (* wifi_get_iface_name) (wifi_interface_handle, char *name, size_t);
|
||||
wifi_error (* wifi_set_iface_event_handler) (wifi_request_id,wifi_interface_handle ,
|
||||
wifi_event_handler);
|
||||
wifi_error (* wifi_reset_iface_event_handler) (wifi_request_id, wifi_interface_handle);
|
||||
wifi_error (* wifi_start_gscan) (wifi_request_id, wifi_interface_handle, wifi_scan_cmd_params,
|
||||
wifi_scan_result_handler);
|
||||
wifi_error (* wifi_stop_gscan)(wifi_request_id, wifi_interface_handle);
|
||||
wifi_error (* wifi_get_cached_gscan_results)(wifi_interface_handle, byte, int,
|
||||
wifi_cached_scan_results *, int *);
|
||||
wifi_error (* wifi_set_bssid_hotlist)(wifi_request_id, wifi_interface_handle,
|
||||
wifi_bssid_hotlist_params, wifi_hotlist_ap_found_handler);
|
||||
wifi_error (* wifi_reset_bssid_hotlist)(wifi_request_id, wifi_interface_handle);
|
||||
wifi_error (* wifi_set_significant_change_handler)(wifi_request_id, wifi_interface_handle,
|
||||
wifi_significant_change_params, wifi_significant_change_handler);
|
||||
wifi_error (* wifi_reset_significant_change_handler)(wifi_request_id, wifi_interface_handle);
|
||||
wifi_error (* wifi_get_gscan_capabilities)(wifi_interface_handle, wifi_gscan_capabilities *);
|
||||
wifi_error (* wifi_set_link_stats) (wifi_interface_handle, wifi_link_layer_params);
|
||||
wifi_error (* wifi_get_link_stats) (wifi_request_id,wifi_interface_handle,
|
||||
wifi_stats_result_handler);
|
||||
wifi_error (* wifi_clear_link_stats)(wifi_interface_handle,u32, u32 *, u8, u8 *);
|
||||
wifi_error (* wifi_get_valid_channels)(wifi_interface_handle,int, int, wifi_channel *, int *);
|
||||
wifi_error (* wifi_rtt_range_request)(wifi_request_id, wifi_interface_handle, unsigned,
|
||||
wifi_rtt_config[], wifi_rtt_event_handler);
|
||||
wifi_error (* wifi_rtt_range_cancel)(wifi_request_id, wifi_interface_handle, unsigned,
|
||||
mac_addr[]);
|
||||
wifi_error (* wifi_get_rtt_capabilities)(wifi_interface_handle, wifi_rtt_capabilities *);
|
||||
wifi_error (* wifi_rtt_get_responder_info)(wifi_interface_handle iface,
|
||||
wifi_rtt_responder *responder_info);
|
||||
wifi_error (* wifi_enable_responder)(wifi_request_id id, wifi_interface_handle iface,
|
||||
wifi_channel_info channel_hint, unsigned max_duration_seconds,
|
||||
wifi_rtt_responder *responder_info);
|
||||
wifi_error (* wifi_disable_responder)(wifi_request_id id, wifi_interface_handle iface);
|
||||
wifi_error (* wifi_set_nodfs_flag)(wifi_interface_handle, u32);
|
||||
wifi_error (* wifi_start_logging)(wifi_interface_handle, u32, u32, u32, u32, char *);
|
||||
wifi_error (* wifi_set_epno_list)(wifi_request_id, wifi_interface_handle,
|
||||
const wifi_epno_params *, wifi_epno_handler);
|
||||
wifi_error (* wifi_reset_epno_list)(wifi_request_id, wifi_interface_handle);
|
||||
wifi_error (* wifi_set_country_code)(wifi_interface_handle, const char *);
|
||||
wifi_error (* wifi_get_firmware_memory_dump)( wifi_interface_handle iface,
|
||||
wifi_firmware_memory_dump_handler handler);
|
||||
wifi_error (* wifi_set_log_handler)(wifi_request_id id, wifi_interface_handle iface,
|
||||
wifi_ring_buffer_data_handler handler);
|
||||
wifi_error (* wifi_reset_log_handler)(wifi_request_id id, wifi_interface_handle iface);
|
||||
wifi_error (* wifi_set_alert_handler)(wifi_request_id id, wifi_interface_handle iface,
|
||||
wifi_alert_handler handler);
|
||||
wifi_error (* wifi_reset_alert_handler)(wifi_request_id id, wifi_interface_handle iface);
|
||||
wifi_error (* wifi_get_firmware_version)(wifi_interface_handle iface, char *buffer,
|
||||
int buffer_size);
|
||||
wifi_error (* wifi_get_ring_buffers_status)(wifi_interface_handle iface,
|
||||
u32 *num_rings, wifi_ring_buffer_status *status);
|
||||
wifi_error (* wifi_get_logger_supported_feature_set)(wifi_interface_handle iface,
|
||||
unsigned int *support);
|
||||
wifi_error (* wifi_get_ring_data)(wifi_interface_handle iface, char *ring_name);
|
||||
wifi_error (* wifi_enable_tdls)(wifi_interface_handle, mac_addr, wifi_tdls_params *,
|
||||
wifi_tdls_handler);
|
||||
wifi_error (* wifi_disable_tdls)(wifi_interface_handle, mac_addr);
|
||||
wifi_error (*wifi_get_tdls_status) (wifi_interface_handle, mac_addr, wifi_tdls_status *);
|
||||
wifi_error (*wifi_get_tdls_capabilities)(wifi_interface_handle iface,
|
||||
wifi_tdls_capabilities *capabilities);
|
||||
wifi_error (* wifi_get_driver_version)(wifi_interface_handle iface, char *buffer,
|
||||
int buffer_size);
|
||||
wifi_error (* wifi_set_passpoint_list)(wifi_request_id id, wifi_interface_handle iface,
|
||||
int num, wifi_passpoint_network *networks, wifi_passpoint_event_handler handler);
|
||||
wifi_error (* wifi_reset_passpoint_list)(wifi_request_id id, wifi_interface_handle iface);
|
||||
wifi_error (*wifi_set_lci) (wifi_request_id id, wifi_interface_handle iface,
|
||||
wifi_lci_information *lci);
|
||||
wifi_error (*wifi_set_lcr) (wifi_request_id id, wifi_interface_handle iface,
|
||||
wifi_lcr_information *lcr);
|
||||
wifi_error (*wifi_start_sending_offloaded_packet)(wifi_request_id id,
|
||||
wifi_interface_handle iface, u8 *ip_packet, u16 ip_packet_len,
|
||||
u8 *src_mac_addr, u8 *dst_mac_addr, u32 period_msec);
|
||||
wifi_error (*wifi_stop_sending_offloaded_packet)(wifi_request_id id,
|
||||
wifi_interface_handle iface);
|
||||
wifi_error (*wifi_start_rssi_monitoring)(wifi_request_id id, wifi_interface_handle
|
||||
iface, s8 max_rssi, s8 min_rssi, wifi_rssi_event_handler eh);
|
||||
wifi_error (*wifi_stop_rssi_monitoring)(wifi_request_id id, wifi_interface_handle iface);
|
||||
wifi_error (*wifi_get_wake_reason_stats)(wifi_interface_handle iface,
|
||||
WLAN_DRIVER_WAKE_REASON_CNT *wifi_wake_reason_cnt);
|
||||
wifi_error (*wifi_configure_nd_offload)(wifi_interface_handle iface, u8 enable);
|
||||
wifi_error (*wifi_get_driver_memory_dump)(wifi_interface_handle iface,
|
||||
wifi_driver_memory_dump_callbacks callbacks);
|
||||
wifi_error (*wifi_start_pkt_fate_monitoring)(wifi_interface_handle iface);
|
||||
wifi_error (*wifi_get_tx_pkt_fates)(wifi_interface_handle handle,
|
||||
wifi_tx_report *tx_report_bufs,
|
||||
size_t n_requested_fates,
|
||||
size_t *n_provided_fates);
|
||||
wifi_error (*wifi_get_rx_pkt_fates)(wifi_interface_handle handle,
|
||||
wifi_rx_report *rx_report_bufs,
|
||||
size_t n_requested_fates,
|
||||
size_t *n_provided_fates);
|
||||
|
||||
/* NAN functions */
|
||||
wifi_error (*wifi_nan_enable_request)(transaction_id id,
|
||||
wifi_interface_handle iface,
|
||||
NanEnableRequest* msg);
|
||||
wifi_error (*wifi_nan_disable_request)(transaction_id id,
|
||||
wifi_interface_handle iface);
|
||||
wifi_error (*wifi_nan_publish_request)(transaction_id id,
|
||||
wifi_interface_handle iface,
|
||||
NanPublishRequest* msg);
|
||||
wifi_error (*wifi_nan_publish_cancel_request)(transaction_id id,
|
||||
wifi_interface_handle iface,
|
||||
NanPublishCancelRequest* msg);
|
||||
wifi_error (*wifi_nan_subscribe_request)(transaction_id id,
|
||||
wifi_interface_handle iface,
|
||||
NanSubscribeRequest* msg);
|
||||
wifi_error (*wifi_nan_subscribe_cancel_request)(transaction_id id,
|
||||
wifi_interface_handle iface,
|
||||
NanSubscribeCancelRequest* msg);
|
||||
wifi_error (*wifi_nan_transmit_followup_request)(transaction_id id,
|
||||
wifi_interface_handle iface,
|
||||
NanTransmitFollowupRequest* msg);
|
||||
wifi_error (*wifi_nan_stats_request)(transaction_id id,
|
||||
wifi_interface_handle iface,
|
||||
NanStatsRequest* msg);
|
||||
wifi_error (*wifi_nan_config_request)(transaction_id id,
|
||||
wifi_interface_handle iface,
|
||||
NanConfigRequest* msg);
|
||||
wifi_error (*wifi_nan_tca_request)(transaction_id id,
|
||||
wifi_interface_handle iface,
|
||||
NanTCARequest* msg);
|
||||
wifi_error (*wifi_nan_beacon_sdf_payload_request)(transaction_id id,
|
||||
wifi_interface_handle iface,
|
||||
NanBeaconSdfPayloadRequest* msg);
|
||||
wifi_error (*wifi_nan_register_handler)(wifi_interface_handle iface,
|
||||
NanCallbackHandler handlers);
|
||||
wifi_error (*wifi_nan_get_version)(wifi_handle handle,
|
||||
NanVersion* version);
|
||||
wifi_error (*wifi_nan_get_capabilities)(transaction_id id,
|
||||
wifi_interface_handle iface);
|
||||
wifi_error (*wifi_nan_data_interface_create)(transaction_id id,
|
||||
wifi_interface_handle iface,
|
||||
char *iface_name);
|
||||
wifi_error (*wifi_nan_data_interface_delete)(transaction_id id,
|
||||
wifi_interface_handle iface,
|
||||
char *iface_name);
|
||||
wifi_error (*wifi_nan_data_request_initiator)(
|
||||
transaction_id id, wifi_interface_handle iface,
|
||||
NanDataPathInitiatorRequest *msg);
|
||||
wifi_error (*wifi_nan_data_indication_response)(
|
||||
transaction_id id, wifi_interface_handle iface,
|
||||
NanDataPathIndicationResponse *msg);
|
||||
wifi_error (*wifi_nan_data_end)(transaction_id id,
|
||||
wifi_interface_handle iface,
|
||||
NanDataPathEndRequest *msg);
|
||||
wifi_error (*wifi_select_tx_power_scenario)(wifi_interface_handle iface,
|
||||
wifi_power_scenario scenario);
|
||||
wifi_error (*wifi_reset_tx_power_scenario)(wifi_interface_handle iface);
|
||||
|
||||
/**
|
||||
* Returns the chipset's hardware filtering capabilities:
|
||||
* @param version pointer to version of the packet filter interpreter
|
||||
* supported, filled in upon return. 0 indicates no support.
|
||||
* @param max_len pointer to maximum size of the filter bytecode, filled in
|
||||
* upon return.
|
||||
*/
|
||||
wifi_error (*wifi_get_packet_filter_capabilities)(wifi_interface_handle handle,
|
||||
u32 *version, u32 *max_len);
|
||||
/**
|
||||
* Programs the packet filter.
|
||||
* @param program pointer to the program byte-code.
|
||||
* @param len length of the program byte-code.
|
||||
*/
|
||||
wifi_error (*wifi_set_packet_filter)(wifi_interface_handle handle,
|
||||
const u8 *program, u32 len);
|
||||
wifi_error (*wifi_get_roaming_capabilities)(wifi_interface_handle handle,
|
||||
wifi_roaming_capabilities *caps);
|
||||
wifi_error (*wifi_enable_firmware_roaming)(wifi_interface_handle handle,
|
||||
fw_roaming_state_t state);
|
||||
wifi_error (*wifi_configure_roaming)(wifi_interface_handle handle,
|
||||
wifi_roaming_config *roaming_config);
|
||||
} wifi_hal_fn;
|
||||
wifi_error init_wifi_vendor_hal_func_table(wifi_hal_fn *fn);
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
|
@ -0,0 +1,37 @@
|
|||
/*
|
||||
* Copyright (C) 2008 The Android Open Source Project
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#ifndef _WIFI_HARDWARE_INFO_H
|
||||
#define _WIFI_HARDWARE_INFO_H
|
||||
|
||||
#if __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
const char *get_wifi_vendor_name();
|
||||
const char *get_wifi_module_name();
|
||||
const char *get_wifi_driver_name();
|
||||
const char *get_fw_path_sta();
|
||||
const char *get_fw_path_ap();
|
||||
const char *get_fw_path_p2p();
|
||||
void get_driver_module_arg(char* arg);
|
||||
const char *get_supplicant_para(int set_p2p_supported);
|
||||
|
||||
#if __cplusplus
|
||||
}; // extern "C"
|
||||
#endif
|
||||
|
||||
#endif // _WIFI_HARDWARE_INFO_H
|
|
@ -0,0 +1,647 @@
|
|||
#include "wifi_hal.h"
|
||||
|
||||
#ifndef __WIFI_HAL_LOGGER_H
|
||||
#define __WIFI_HAL_LOGGER_H
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C"
|
||||
{
|
||||
#endif /* __cplusplus */
|
||||
|
||||
#define LOGGER_MAJOR_VERSION 1
|
||||
#define LOGGER_MINOR_VERSION 0
|
||||
#define LOGGER_MICRO_VERSION 0
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* WiFi logger life cycle is as follow:
|
||||
*
|
||||
* - At initialization time, framework will call wifi_get_ring_buffers_status
|
||||
* so as to obtain the names and list of supported buffers.
|
||||
* - When WiFi operation start framework will call wifi_start_logging
|
||||
* so as to trigger log collection.
|
||||
* - Developper UI will provide an option to the user, so as it can set the verbose level
|
||||
* of individual buffer as reported by wifi_get_ring_buffers_status.
|
||||
* - During wifi operations, driver will periodically report per ring data to framework
|
||||
* by invoking the on_ring_buffer_data call back.
|
||||
* - when capturing a bug report, framework will indicate to driver that all the data
|
||||
* has to be uploaded, urgently, by calling wifi_get_ring_data.
|
||||
*
|
||||
* The data uploaded by driver will be stored by framework in separate files, with one stream
|
||||
* of file per ring.
|
||||
* Framework will store the files in pcapng format, allowing for easy merging and parsing
|
||||
* with network analyzer tools.
|
||||
*/
|
||||
|
||||
|
||||
typedef int wifi_radio;
|
||||
typedef int wifi_ring_buffer_id;
|
||||
|
||||
#define PER_PACKET_ENTRY_FLAGS_DIRECTION_TX 1 // 0: TX, 1: RX
|
||||
#define PER_PACKET_ENTRY_FLAGS_TX_SUCCESS 2 // whether packet was transmitted or
|
||||
// received/decrypted successfully
|
||||
#define PER_PACKET_ENTRY_FLAGS_80211_HEADER 4 // has full 802.11 header, else has 802.3 header
|
||||
#define PER_PACKET_ENTRY_FLAGS_PROTECTED 8 // whether packet was encrypted
|
||||
|
||||
typedef struct {
|
||||
u8 flags;
|
||||
u8 tid; // transmit or received tid
|
||||
u16 MCS; // modulation and bandwidth
|
||||
u8 rssi; // TX: RSSI of ACK for that packet
|
||||
// RX: RSSI of packet
|
||||
u8 num_retries; // number of attempted retries
|
||||
u16 last_transmit_rate; // last transmit rate in .5 mbps
|
||||
u16 link_layer_transmit_sequence; // transmit/reeive sequence for that MPDU packet
|
||||
u64 firmware_entry_timestamp; // TX: firmware timestamp (us) when packet is queued within
|
||||
// firmware buffer for SDIO/HSIC or into PCIe buffer
|
||||
// RX: firmware receive timestamp
|
||||
u64 start_contention_timestamp; // firmware timestamp (us) when packet start contending for the
|
||||
// medium for the first time, at head of its AC queue,
|
||||
// or as part of an MPDU or A-MPDU. This timestamp is
|
||||
// not updated for each retry, only the first transmit attempt.
|
||||
u64 transmit_success_timestamp; // fimrware timestamp (us) when packet is successfully
|
||||
// transmitted or aborted because it has exhausted
|
||||
// its maximum number of retries.
|
||||
u8 data[0]; // packet data. The length of packet data is determined by the entry_size field of
|
||||
// the wifi_ring_buffer_entry structure. It is expected that first bytes of the
|
||||
// packet, or packet headers only (up to TCP or RTP/UDP headers)
|
||||
// will be copied into the ring
|
||||
} __attribute__((packed)) wifi_ring_per_packet_status_entry;
|
||||
|
||||
|
||||
/* Below events refer to the wifi_connectivity_event ring and shall be supported */
|
||||
#define WIFI_EVENT_ASSOCIATION_REQUESTED 0 // driver receives association command from kernel
|
||||
#define WIFI_EVENT_AUTH_COMPLETE 1
|
||||
#define WIFI_EVENT_ASSOC_COMPLETE 2
|
||||
#define WIFI_EVENT_FW_AUTH_STARTED 3 // fw event indicating auth frames are sent
|
||||
#define WIFI_EVENT_FW_ASSOC_STARTED 4 // fw event indicating assoc frames are sent
|
||||
#define WIFI_EVENT_FW_RE_ASSOC_STARTED 5 // fw event indicating reassoc frames are sent
|
||||
#define WIFI_EVENT_DRIVER_SCAN_REQUESTED 6
|
||||
#define WIFI_EVENT_DRIVER_SCAN_RESULT_FOUND 7
|
||||
#define WIFI_EVENT_DRIVER_SCAN_COMPLETE 8
|
||||
#define WIFI_EVENT_G_SCAN_STARTED 9
|
||||
#define WIFI_EVENT_G_SCAN_COMPLETE 10
|
||||
#define WIFI_EVENT_DISASSOCIATION_REQUESTED 11
|
||||
#define WIFI_EVENT_RE_ASSOCIATION_REQUESTED 12
|
||||
#define WIFI_EVENT_ROAM_REQUESTED 13
|
||||
#define WIFI_EVENT_BEACON_RECEIVED 14 // received beacon from AP (event enabled
|
||||
// only in verbose mode)
|
||||
#define WIFI_EVENT_ROAM_SCAN_STARTED 15 // firmware has triggered a roam scan (not g-scan)
|
||||
#define WIFI_EVENT_ROAM_SCAN_COMPLETE 16 // firmware has completed a roam scan (not g-scan)
|
||||
#define WIFI_EVENT_ROAM_SEARCH_STARTED 17 // firmware has started searching for roam
|
||||
// candidates (with reason =xx)
|
||||
#define WIFI_EVENT_ROAM_SEARCH_STOPPED 18 // firmware has stopped searching for roam
|
||||
// candidates (with reason =xx)
|
||||
#define WIFI_EVENT_CHANNEL_SWITCH_ANOUNCEMENT 20 // received channel switch anouncement from AP
|
||||
#define WIFI_EVENT_FW_EAPOL_FRAME_TRANSMIT_START 21 // fw start transmit eapol frame, with
|
||||
// EAPOL index 1-4
|
||||
#define WIFI_EVENT_FW_EAPOL_FRAME_TRANSMIT_STOP 22 // fw gives up eapol frame, with rate,
|
||||
// success/failure and number retries
|
||||
#define WIFI_EVENT_DRIVER_EAPOL_FRAME_TRANSMIT_REQUESTED 23 // kernel queue EAPOL for transmission
|
||||
// in driver with EAPOL index 1-4
|
||||
#define WIFI_EVENT_FW_EAPOL_FRAME_RECEIVED 24 // with rate, regardless of the fact that
|
||||
// EAPOL frame is accepted or rejected by fw
|
||||
#define WIFI_EVENT_DRIVER_EAPOL_FRAME_RECEIVED 26 // with rate, and eapol index, driver has
|
||||
// received EAPOL frame and will queue it up
|
||||
// to wpa_supplicant
|
||||
#define WIFI_EVENT_BLOCK_ACK_NEGOTIATION_COMPLETE 27 // with success/failure, parameters
|
||||
#define WIFI_EVENT_BT_COEX_BT_SCO_START 28
|
||||
#define WIFI_EVENT_BT_COEX_BT_SCO_STOP 29
|
||||
#define WIFI_EVENT_BT_COEX_BT_SCAN_START 30 // for paging/scan etc., when BT starts transmiting
|
||||
// twice per BT slot
|
||||
#define WIFI_EVENT_BT_COEX_BT_SCAN_STOP 31
|
||||
#define WIFI_EVENT_BT_COEX_BT_HID_START 32
|
||||
#define WIFI_EVENT_BT_COEX_BT_HID_STOP 33
|
||||
#define WIFI_EVENT_ROAM_AUTH_STARTED 34 // fw sends auth frame in roaming to next candidate
|
||||
#define WIFI_EVENT_ROAM_AUTH_COMPLETE 35 // fw receive auth confirm from ap
|
||||
#define WIFI_EVENT_ROAM_ASSOC_STARTED 36 // firmware sends assoc/reassoc frame in
|
||||
// roaming to next candidate
|
||||
#define WIFI_EVENT_ROAM_ASSOC_COMPLETE 37 // firmware receive assoc/reassoc confirm from ap
|
||||
#define WIFI_EVENT_G_SCAN_STOP 38 // firmware sends stop G_SCAN
|
||||
#define WIFI_EVENT_G_SCAN_CYCLE_STARTED 39 // firmware indicates G_SCAN scan cycle started
|
||||
#define WIFI_EVENT_G_SCAN_CYCLE_COMPLETED 40 // firmware indicates G_SCAN scan cycle completed
|
||||
#define WIFI_EVENT_G_SCAN_BUCKET_STARTED 41 // firmware indicates G_SCAN scan start
|
||||
// for a particular bucket
|
||||
#define WIFI_EVENT_G_SCAN_BUCKET_COMPLETED 42 // firmware indicates G_SCAN scan completed for
|
||||
// for a particular bucket
|
||||
#define WIFI_EVENT_G_SCAN_RESULTS_AVAILABLE 43 // Event received from firmware about G_SCAN scan
|
||||
// results being available
|
||||
#define WIFI_EVENT_G_SCAN_CAPABILITIES 44 // Event received from firmware with G_SCAN
|
||||
// capabilities
|
||||
#define WIFI_EVENT_ROAM_CANDIDATE_FOUND 45 // Event received from firmware when eligible
|
||||
// candidate is found
|
||||
#define WIFI_EVENT_ROAM_SCAN_CONFIG 46 // Event received from firmware when roam scan
|
||||
// configuration gets enabled or disabled
|
||||
#define WIFI_EVENT_AUTH_TIMEOUT 47 // firmware/driver timed out authentication
|
||||
#define WIFI_EVENT_ASSOC_TIMEOUT 48 // firmware/driver timed out association
|
||||
#define WIFI_EVENT_MEM_ALLOC_FAILURE 49 // firmware/driver encountered allocation failure
|
||||
#define WIFI_EVENT_DRIVER_PNO_ADD 50 // driver added a PNO network in firmware
|
||||
#define WIFI_EVENT_DRIVER_PNO_REMOVE 51 // driver removed a PNO network in firmware
|
||||
#define WIFI_EVENT_DRIVER_PNO_NETWORK_FOUND 52 // driver received PNO networks
|
||||
// found indication from firmware
|
||||
#define WIFI_EVENT_DRIVER_PNO_SCAN_REQUESTED 53 // driver triggered a scan for PNO networks
|
||||
#define WIFI_EVENT_DRIVER_PNO_SCAN_RESULT_FOUND 54 // driver received scan results
|
||||
// of PNO networks
|
||||
#define WIFI_EVENT_DRIVER_PNO_SCAN_COMPLETE 55 // driver updated scan results from
|
||||
// PNO networks to cfg80211
|
||||
|
||||
/**
|
||||
* Parameters of wifi logger events are TLVs
|
||||
* Event parameters tags are defined as:
|
||||
*/
|
||||
#define WIFI_TAG_VENDOR_SPECIFIC 0 // take a byte stream as parameter
|
||||
#define WIFI_TAG_BSSID 1 // takes a 6 bytes MAC address as parameter
|
||||
#define WIFI_TAG_ADDR 2 // takes a 6 bytes MAC address as parameter
|
||||
#define WIFI_TAG_SSID 3 // takes a 32 bytes SSID address as parameter
|
||||
#define WIFI_TAG_STATUS 4 // takes an integer as parameter
|
||||
#define WIFI_TAG_CHANNEL_SPEC 5 // takes one or more wifi_channel_spec as parameter
|
||||
#define WIFI_TAG_WAKE_LOCK_EVENT 6 // takes a wake_lock_event struct as parameter
|
||||
#define WIFI_TAG_ADDR1 7 // takes a 6 bytes MAC address as parameter
|
||||
#define WIFI_TAG_ADDR2 8 // takes a 6 bytes MAC address as parameter
|
||||
#define WIFI_TAG_ADDR3 9 // takes a 6 bytes MAC address as parameter
|
||||
#define WIFI_TAG_ADDR4 10 // takes a 6 bytes MAC address as parameter
|
||||
#define WIFI_TAG_TSF 11 // take a 64 bits TSF value as parameter
|
||||
#define WIFI_TAG_IE 12 // take one or more specific 802.11 IEs parameter,
|
||||
// IEs are in turn indicated in TLV format as per
|
||||
// 802.11 spec
|
||||
#define WIFI_TAG_INTERFACE 13 // take interface name as parameter
|
||||
#define WIFI_TAG_REASON_CODE 14 // take a reason code as per 802.11 as parameter
|
||||
#define WIFI_TAG_RATE_MBPS 15 // take a wifi rate in 0.5 mbps
|
||||
#define WIFI_TAG_REQUEST_ID 16 // take an integer as parameter
|
||||
#define WIFI_TAG_BUCKET_ID 17 // take an integer as parameter
|
||||
#define WIFI_TAG_GSCAN_PARAMS 18 // takes a wifi_scan_cmd_params struct as parameter
|
||||
#define WIFI_TAG_GSCAN_CAPABILITIES 19 // takes a wifi_gscan_capabilities struct as parameter
|
||||
#define WIFI_TAG_SCAN_ID 20 // take an integer as parameter
|
||||
#define WIFI_TAG_RSSI 21 // take an integer as parameter
|
||||
#define WIFI_TAG_CHANNEL 22 // take an integer as parameter
|
||||
#define WIFI_TAG_LINK_ID 23 // take an integer as parameter
|
||||
#define WIFI_TAG_LINK_ROLE 24 // take an integer as parameter
|
||||
#define WIFI_TAG_LINK_STATE 25 // take an integer as parameter
|
||||
#define WIFI_TAG_LINK_TYPE 26 // take an integer as parameter
|
||||
#define WIFI_TAG_TSCO 27 // take an integer as parameter
|
||||
#define WIFI_TAG_RSCO 28 // take an integer as parameter
|
||||
#define WIFI_TAG_EAPOL_MESSAGE_TYPE 29 // take an integer as parameter
|
||||
// M1-1, M2-2, M3-3, M4-4
|
||||
|
||||
typedef struct {
|
||||
u16 tag;
|
||||
u16 length; // length of value
|
||||
u8 value[0];
|
||||
} __attribute__((packed)) tlv_log;
|
||||
|
||||
typedef struct {
|
||||
u16 event;
|
||||
tlv_log tlvs[0]; // separate parameter structure per event to be provided and optional data
|
||||
// the event_data is expected to include an official android part, with some
|
||||
// parameter as transmit rate, num retries, num scan result found etc...
|
||||
// as well, event_data can include a vendor proprietary part which is
|
||||
// understood by the developer only.
|
||||
} __attribute__((packed)) wifi_ring_buffer_driver_connectivity_event;
|
||||
|
||||
|
||||
/**
|
||||
* Ring buffer name for power events ring. note that power event are extremely frequents
|
||||
* and thus should be stored in their own ring/file so as not to clobber connectivity events.
|
||||
*/
|
||||
typedef struct {
|
||||
int status; // 0 taken, 1 released
|
||||
int reason; // reason why this wake lock is taken
|
||||
char name[0]; // null terminated
|
||||
} __attribute__((packed)) wake_lock_event;
|
||||
|
||||
typedef struct {
|
||||
u16 event;
|
||||
tlv_log tlvs[0];
|
||||
} __attribute__((packed)) wifi_power_event;
|
||||
|
||||
|
||||
/**
|
||||
* This structure represent a logger entry within a ring buffer.
|
||||
* Wifi driver are responsible to manage the ring buffer and write the debug
|
||||
* information into those rings.
|
||||
*
|
||||
* In general, the debug entries can be used to store meaningful 802.11 information (SME, MLME,
|
||||
* connection and packet statistics) as well as vendor proprietary data that is specific to a
|
||||
* specific driver or chipset.
|
||||
* Binary entries can be used so as to store packet data or vendor specific information and
|
||||
* will be treated as blobs of data by android.
|
||||
*
|
||||
* A user land process will be started by framework so as to periodically retrieve the
|
||||
* data logged by drivers into their ring buffer, store the data into log files and include
|
||||
* the logs into android bugreports.
|
||||
*/
|
||||
enum {
|
||||
RING_BUFFER_ENTRY_FLAGS_HAS_BINARY = (1 << (0)), // set for binary entries
|
||||
RING_BUFFER_ENTRY_FLAGS_HAS_TIMESTAMP = (1 << (1)) // set if 64 bits timestamp is present
|
||||
};
|
||||
|
||||
enum {
|
||||
ENTRY_TYPE_CONNECT_EVENT = 1,
|
||||
ENTRY_TYPE_PKT,
|
||||
ENTRY_TYPE_WAKE_LOCK,
|
||||
ENTRY_TYPE_POWER_EVENT,
|
||||
ENTRY_TYPE_DATA
|
||||
};
|
||||
|
||||
typedef struct {
|
||||
u16 entry_size; // the size of payload excluding the header.
|
||||
u8 flags;
|
||||
u8 type; // entry type
|
||||
u64 timestamp; // present if has_timestamp bit is set.
|
||||
} __attribute__((packed)) wifi_ring_buffer_entry;
|
||||
|
||||
#define WIFI_RING_BUFFER_FLAG_HAS_BINARY_ENTRIES 0x00000001 // set if binary entries are present
|
||||
#define WIFI_RING_BUFFER_FLAG_HAS_ASCII_ENTRIES 0x00000002 // set if ascii entries are present
|
||||
|
||||
|
||||
/* ring buffer params */
|
||||
/**
|
||||
* written_bytes and read_bytes implement a producer consumer API
|
||||
* hence written_bytes >= read_bytes
|
||||
* a modulo arithmetic of the buffer size has to be applied to those counters:
|
||||
* actual offset into ring buffer = written_bytes % ring_buffer_byte_size
|
||||
*
|
||||
*/
|
||||
typedef struct {
|
||||
u8 name[32];
|
||||
u32 flags;
|
||||
wifi_ring_buffer_id ring_id; // unique integer representing the ring
|
||||
u32 ring_buffer_byte_size; // total memory size allocated for the buffer
|
||||
u32 verbose_level; // verbose level for ring buffer
|
||||
u32 written_bytes; // number of bytes that was written to the buffer by driver,
|
||||
// monotonously increasing integer
|
||||
u32 read_bytes; // number of bytes that was read from the buffer by user land,
|
||||
// monotonously increasing integer
|
||||
u32 written_records; // number of records that was written to the buffer by driver,
|
||||
// monotonously increasing integer
|
||||
} wifi_ring_buffer_status;
|
||||
|
||||
|
||||
/**
|
||||
* Callback for reporting ring data
|
||||
*
|
||||
* The ring buffer data collection is event based:
|
||||
* - Driver calls on_ring_buffer_data when new records are available, the wifi_ring_buffer_status
|
||||
* passed up to framework in the call back indicates to framework if more data is available in
|
||||
* the ring buffer. It is not expected that driver will necessarily always empty the ring
|
||||
* immediately as data is available, instead driver will report data every X seconds or if
|
||||
* N bytes are available.
|
||||
* - In the case where a bug report has to be captured, framework will require driver to upload
|
||||
* all data immediately. This is indicated to driver when framework calls wifi_get_ringdata.
|
||||
* When framework calls wifi_get_ring_data, driver will start sending all available data in the
|
||||
* indicated ring by repeatedly invoking the on_ring_buffer_data callback.
|
||||
*
|
||||
* The callback is called by log handler whenever ring data comes in driver.
|
||||
*/
|
||||
typedef struct {
|
||||
void (*on_ring_buffer_data) (char *ring_name, char *buffer, int buffer_size,
|
||||
wifi_ring_buffer_status *status);
|
||||
} wifi_ring_buffer_data_handler;
|
||||
|
||||
/**
|
||||
* API to set the log handler for getting ring data
|
||||
* - Only a single instance of log handler can be instantiated for each ring buffer.
|
||||
*/
|
||||
wifi_error wifi_set_log_handler(wifi_request_id id, wifi_interface_handle iface,
|
||||
wifi_ring_buffer_data_handler handler);
|
||||
|
||||
/* API to reset the log handler */
|
||||
wifi_error wifi_reset_log_handler(wifi_request_id id, wifi_interface_handle iface);
|
||||
|
||||
|
||||
/**
|
||||
* Callback for reporting FW dump
|
||||
*
|
||||
* The buffer data collection is event based such as FW health check or FW dump.
|
||||
* The callback is called by alert handler.
|
||||
*/
|
||||
typedef struct {
|
||||
void (*on_alert) (wifi_request_id id, char *buffer, int buffer_size, int err_code);
|
||||
} wifi_alert_handler;
|
||||
|
||||
/*
|
||||
* API to set the alert handler for the alert case in Wi-Fi Chip
|
||||
* - Only a single instance of alert handler can be instantiated.
|
||||
*/
|
||||
wifi_error wifi_set_alert_handler(wifi_request_id id, wifi_interface_handle iface,
|
||||
wifi_alert_handler handler);
|
||||
|
||||
/* API to reset the alert handler */
|
||||
wifi_error wifi_reset_alert_handler(wifi_request_id id, wifi_interface_handle iface);
|
||||
|
||||
/* API for framework to indicate driver has to upload and drain all data of a given ring */
|
||||
wifi_error wifi_get_ring_data(wifi_interface_handle iface, char *ring_name);
|
||||
|
||||
|
||||
/**
|
||||
* API to trigger the debug collection.
|
||||
* Unless his API is invoked - logging is not triggered.
|
||||
* - Verbose_level 0 corresponds to no collection,
|
||||
* and it makes log handler stop by no more events from driver.
|
||||
* - Verbose_level 1 correspond to normal log level, with minimal user impact.
|
||||
* This is the default value.
|
||||
* - Verbose_level 2 are enabled when user is lazily trying to reproduce a problem,
|
||||
* wifi performances and power can be impacted but device should not otherwise be
|
||||
* significantly impacted.
|
||||
* - Verbose_level 3+ are used when trying to actively debug a problem.
|
||||
*
|
||||
* ring_name represent the name of the ring for which data collection shall start.
|
||||
*
|
||||
* flags: TBD parameter used to enable/disable specific events on a ring
|
||||
* max_interval: maximum interval in seconds for driver to invoke on_ring_buffer_data,
|
||||
* ignore if zero
|
||||
* min_data_size: minimum data size in buffer for driver to invoke on_ring_buffer_data,
|
||||
* ignore if zero
|
||||
*/
|
||||
wifi_error wifi_start_logging(wifi_interface_handle iface, u32 verbose_level, u32 flags,
|
||||
u32 max_interval_sec, u32 min_data_size, char *ring_name);
|
||||
|
||||
/**
|
||||
* API to get the status of all ring buffers supported by driver.
|
||||
* - Caller is responsible to allocate / free ring buffer status.
|
||||
* - Maximum no of ring buffer would be 10.
|
||||
*/
|
||||
wifi_error wifi_get_ring_buffers_status(wifi_interface_handle iface, u32 *num_rings,
|
||||
wifi_ring_buffer_status *status);
|
||||
|
||||
/**
|
||||
* Synchronous memory dump by user request.
|
||||
* - Caller is responsible to store memory dump data into a local,
|
||||
* e.g., /data/misc/wifi/memdump.bin
|
||||
*/
|
||||
typedef struct {
|
||||
void (*on_firmware_memory_dump) (char *buffer, int buffer_size);
|
||||
} wifi_firmware_memory_dump_handler;
|
||||
|
||||
/**
|
||||
* API to collect a firmware memory dump for a given iface by async memdump event.
|
||||
* - Triggered by Alerthandler, esp. when FW problem or FW health check happens
|
||||
* - Caller is responsible to store fw dump data into a local,
|
||||
* e.g., /data/misc/wifi/alertdump-1.bin
|
||||
*/
|
||||
wifi_error wifi_get_firmware_memory_dump(wifi_interface_handle iface,
|
||||
wifi_firmware_memory_dump_handler handler);
|
||||
|
||||
/**
|
||||
* API to collect a firmware version string.
|
||||
* - Caller is responsible to allocate / free a buffer to retrieve firmware verion info.
|
||||
* - Max string will be at most 256 bytes.
|
||||
*/
|
||||
wifi_error wifi_get_firmware_version(wifi_interface_handle iface, char *buffer, int buffer_size);
|
||||
|
||||
/**
|
||||
* API to collect a driver version string.
|
||||
* - Caller is responsible to allocate / free a buffer to retrieve driver verion info.
|
||||
* - Max string will be at most 256 bytes.
|
||||
*/
|
||||
wifi_error wifi_get_driver_version(wifi_interface_handle iface, char *buffer, int buffer_size);
|
||||
|
||||
|
||||
/* Feature set */
|
||||
enum {
|
||||
WIFI_LOGGER_MEMORY_DUMP_SUPPORTED = (1 << (0)), // Memory dump of FW
|
||||
WIFI_LOGGER_PER_PACKET_TX_RX_STATUS_SUPPORTED = (1 << (1)), // PKT status
|
||||
WIFI_LOGGER_CONNECT_EVENT_SUPPORTED = (1 << (2)), // Connectivity event
|
||||
WIFI_LOGGER_POWER_EVENT_SUPPORTED = (1 << (3)), // POWER of Driver
|
||||
WIFI_LOGGER_WAKE_LOCK_SUPPORTED = (1 << (4)), // WAKE LOCK of Driver
|
||||
WIFI_LOGGER_VERBOSE_SUPPORTED = (1 << (5)), // verbose log of FW
|
||||
WIFI_LOGGER_WATCHDOG_TIMER_SUPPORTED = (1 << (6)), // monitor the health of FW
|
||||
WIFI_LOGGER_DRIVER_DUMP_SUPPORTED = (1 << (7)), // dumps driver state
|
||||
WIFI_LOGGER_PACKET_FATE_SUPPORTED = (1 << (8)), // tracks connection packets' fate
|
||||
};
|
||||
|
||||
/**
|
||||
* API to retrieve the current supportive features.
|
||||
* - An integer variable is enough to have bit mapping info by caller.
|
||||
*/
|
||||
wifi_error wifi_get_logger_supported_feature_set(wifi_interface_handle iface,
|
||||
unsigned int *support);
|
||||
|
||||
typedef struct {
|
||||
/* Buffer is to be allocated and freed by HAL implementation. */
|
||||
void (*on_driver_memory_dump) (char *buffer, int buffer_size);
|
||||
} wifi_driver_memory_dump_callbacks;
|
||||
|
||||
/**
|
||||
API to collect driver state.
|
||||
|
||||
Framework will call this API soon before or after (but not
|
||||
concurrently with) wifi_get_firmware_memory_dump(). Capturing
|
||||
firmware and driver dumps is intended to help identify
|
||||
inconsistent state between these components.
|
||||
|
||||
- In response to this call, HAL implementation should make one or
|
||||
more calls to callbacks.on_driver_memory_dump(). Framework will
|
||||
copy data out of the received |buffer|s, and concatenate the
|
||||
contents thereof.
|
||||
- HAL implemention will indicate completion of the driver memory
|
||||
dump by returning from this call.
|
||||
*/
|
||||
wifi_error wifi_get_driver_memory_dump(
|
||||
wifi_interface_handle iface,
|
||||
wifi_driver_memory_dump_callbacks callbacks);
|
||||
|
||||
|
||||
/* packet fate logs */
|
||||
|
||||
#define MD5_PREFIX_LEN 4
|
||||
#define MAX_FATE_LOG_LEN 32
|
||||
#define MAX_FRAME_LEN_ETHERNET 1518
|
||||
#define MAX_FRAME_LEN_80211_MGMT 2352 // 802.11-2012 Fig. 8-34
|
||||
|
||||
typedef enum {
|
||||
// Sent over air and ACKed.
|
||||
TX_PKT_FATE_ACKED,
|
||||
|
||||
// Sent over air but not ACKed. (Normal for broadcast/multicast.)
|
||||
TX_PKT_FATE_SENT,
|
||||
|
||||
// Queued within firmware, but not yet sent over air.
|
||||
TX_PKT_FATE_FW_QUEUED,
|
||||
|
||||
// Dropped by firmware as invalid. E.g. bad source address, bad checksum,
|
||||
// or invalid for current state.
|
||||
TX_PKT_FATE_FW_DROP_INVALID,
|
||||
|
||||
// Dropped by firmware due to lack of buffer space.
|
||||
TX_PKT_FATE_FW_DROP_NOBUFS,
|
||||
|
||||
// Dropped by firmware for any other reason. Includes frames that
|
||||
// were sent by driver to firmware, but unaccounted for by
|
||||
// firmware.
|
||||
TX_PKT_FATE_FW_DROP_OTHER,
|
||||
|
||||
// Queued within driver, not yet sent to firmware.
|
||||
TX_PKT_FATE_DRV_QUEUED,
|
||||
|
||||
// Dropped by driver as invalid. E.g. bad source address, or
|
||||
// invalid for current state.
|
||||
TX_PKT_FATE_DRV_DROP_INVALID,
|
||||
|
||||
// Dropped by driver due to lack of buffer space.
|
||||
TX_PKT_FATE_DRV_DROP_NOBUFS,
|
||||
|
||||
// Dropped by driver for any other reason.
|
||||
TX_PKT_FATE_DRV_DROP_OTHER,
|
||||
} wifi_tx_packet_fate;
|
||||
|
||||
typedef enum {
|
||||
// Valid and delivered to network stack (e.g., netif_rx()).
|
||||
RX_PKT_FATE_SUCCESS,
|
||||
|
||||
// Queued within firmware, but not yet sent to driver.
|
||||
RX_PKT_FATE_FW_QUEUED,
|
||||
|
||||
// Dropped by firmware due to host-programmable filters.
|
||||
RX_PKT_FATE_FW_DROP_FILTER,
|
||||
|
||||
// Dropped by firmware as invalid. E.g. bad checksum, decrypt failed,
|
||||
// or invalid for current state.
|
||||
RX_PKT_FATE_FW_DROP_INVALID,
|
||||
|
||||
// Dropped by firmware due to lack of buffer space.
|
||||
RX_PKT_FATE_FW_DROP_NOBUFS,
|
||||
|
||||
// Dropped by firmware for any other reason.
|
||||
RX_PKT_FATE_FW_DROP_OTHER,
|
||||
|
||||
// Queued within driver, not yet delivered to network stack.
|
||||
RX_PKT_FATE_DRV_QUEUED,
|
||||
|
||||
// Dropped by driver due to filter rules.
|
||||
RX_PKT_FATE_DRV_DROP_FILTER,
|
||||
|
||||
// Dropped by driver as invalid. E.g. not permitted in current state.
|
||||
RX_PKT_FATE_DRV_DROP_INVALID,
|
||||
|
||||
// Dropped by driver due to lack of buffer space.
|
||||
RX_PKT_FATE_DRV_DROP_NOBUFS,
|
||||
|
||||
// Dropped by driver for any other reason.
|
||||
RX_PKT_FATE_DRV_DROP_OTHER,
|
||||
} wifi_rx_packet_fate;
|
||||
|
||||
typedef enum {
|
||||
FRAME_TYPE_UNKNOWN,
|
||||
FRAME_TYPE_ETHERNET_II,
|
||||
FRAME_TYPE_80211_MGMT,
|
||||
} frame_type;
|
||||
|
||||
typedef struct {
|
||||
// The type of MAC-layer frame that this frame_info holds.
|
||||
// - For data frames, use FRAME_TYPE_ETHERNET_II.
|
||||
// - For management frames, use FRAME_TYPE_80211_MGMT.
|
||||
// - If the type of the frame is unknown, use FRAME_TYPE_UNKNOWN.
|
||||
frame_type payload_type;
|
||||
|
||||
// The number of bytes included in |frame_content|. If the frame
|
||||
// contents are missing (e.g. RX frame dropped in firmware),
|
||||
// |frame_len| should be set to 0.
|
||||
size_t frame_len;
|
||||
|
||||
// Host clock when this frame was received by the driver (either
|
||||
// outbound from the host network stack, or inbound from the
|
||||
// firmware).
|
||||
// - The timestamp should be taken from a clock which includes time
|
||||
// the host spent suspended (e.g. ktime_get_boottime()).
|
||||
// - If no host timestamp is available (e.g. RX frame was dropped in
|
||||
// firmware), this field should be set to 0.
|
||||
u32 driver_timestamp_usec;
|
||||
|
||||
// Firmware clock when this frame was received by the firmware
|
||||
// (either outbound from the host, or inbound from a remote
|
||||
// station).
|
||||
// - The timestamp should be taken from a clock which includes time
|
||||
// firmware spent suspended (if applicable).
|
||||
// - If no firmware timestamp is available (e.g. TX frame was
|
||||
// dropped by driver), this field should be set to 0.
|
||||
// - Consumers of |frame_info| should _not_ assume any
|
||||
// synchronization between driver and firmware clocks.
|
||||
u32 firmware_timestamp_usec;
|
||||
|
||||
// Actual frame content.
|
||||
// - Should be provided for TX frames originated by the host.
|
||||
// - Should be provided for RX frames received by the driver.
|
||||
// - Optionally provided for TX frames originated by firmware. (At
|
||||
// discretion of HAL implementation.)
|
||||
// - Optionally provided for RX frames dropped in firmware. (At
|
||||
// discretion of HAL implementation.)
|
||||
// - If frame content is not provided, |frame_len| should be set
|
||||
// to 0.
|
||||
union {
|
||||
char ethernet_ii_bytes[MAX_FRAME_LEN_ETHERNET];
|
||||
char ieee_80211_mgmt_bytes[MAX_FRAME_LEN_80211_MGMT];
|
||||
} frame_content;
|
||||
} frame_info;
|
||||
|
||||
typedef struct {
|
||||
// Prefix of MD5 hash of |frame_inf.frame_content|. If frame
|
||||
// content is not provided, prefix of MD5 hash over the same data
|
||||
// that would be in frame_content, if frame content were provided.
|
||||
char md5_prefix[MD5_PREFIX_LEN];
|
||||
wifi_tx_packet_fate fate;
|
||||
frame_info frame_inf;
|
||||
} wifi_tx_report;
|
||||
|
||||
typedef struct {
|
||||
// Prefix of MD5 hash of |frame_inf.frame_content|. If frame
|
||||
// content is not provided, prefix of MD5 hash over the same data
|
||||
// that would be in frame_content, if frame content were provided.
|
||||
char md5_prefix[MD5_PREFIX_LEN];
|
||||
wifi_rx_packet_fate fate;
|
||||
frame_info frame_inf;
|
||||
} wifi_rx_report;
|
||||
|
||||
/**
|
||||
API to start packet fate monitoring.
|
||||
- Once stared, monitoring should remain active until HAL is unloaded.
|
||||
- When HAL is unloaded, all packet fate buffers should be cleared.
|
||||
*/
|
||||
wifi_error wifi_start_pkt_fate_monitoring(wifi_interface_handle handle);
|
||||
|
||||
/**
|
||||
API to retrieve fates of outbound packets.
|
||||
- HAL implementation should fill |tx_report_bufs| with fates of
|
||||
_first_ min(n_requested_fates, actual packets) frames
|
||||
transmitted for the most recent association. The fate reports
|
||||
should follow the same order as their respective packets.
|
||||
- HAL implementation may choose (but is not required) to include
|
||||
reports for management frames.
|
||||
- Packets reported by firmware, but not recognized by driver,
|
||||
should be included. However, the ordering of the corresponding
|
||||
reports is at the discretion of HAL implementation.
|
||||
- Framework may call this API multiple times for the same association.
|
||||
- Framework will ensure |n_requested_fates <= MAX_FATE_LOG_LEN|.
|
||||
- Framework will allocate and free the referenced storage.
|
||||
*/
|
||||
wifi_error wifi_get_tx_pkt_fates(wifi_interface_handle handle,
|
||||
wifi_tx_report *tx_report_bufs,
|
||||
size_t n_requested_fates,
|
||||
size_t *n_provided_fates);
|
||||
|
||||
/**
|
||||
API to retrieve fates of inbound packets.
|
||||
- HAL implementation should fill |rx_report_bufs| with fates of
|
||||
_first_ min(n_requested_fates, actual packets) frames
|
||||
received for the most recent association. The fate reports
|
||||
should follow the same order as their respective packets.
|
||||
- HAL implementation may choose (but is not required) to include
|
||||
reports for management frames.
|
||||
- Packets reported by firmware, but not recognized by driver,
|
||||
should be included. However, the ordering of the corresponding
|
||||
reports is at the discretion of HAL implementation.
|
||||
- Framework may call this API multiple times for the same association.
|
||||
- Framework will ensure |n_requested_fates <= MAX_FATE_LOG_LEN|.
|
||||
- Framework will allocate and free the referenced storage.
|
||||
*/
|
||||
wifi_error wifi_get_rx_pkt_fates(wifi_interface_handle handle,
|
||||
wifi_rx_report *rx_report_bufs,
|
||||
size_t n_requested_fates,
|
||||
size_t *n_provided_fates);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif /* __cplusplus */
|
||||
|
||||
#endif /*__WIFI_HAL_STATS_ */
|
File diff suppressed because it is too large
Load diff
|
@ -0,0 +1,31 @@
|
|||
#include "wifi_hal.h"
|
||||
|
||||
#ifndef __WIFI_HAL_OFFLOAD_H
|
||||
#define __WIFI_HAL_OFFLOAD_H
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C"
|
||||
{
|
||||
#endif /* __cplusplus */
|
||||
|
||||
#define ETHER_ADDR_LEN 6 // Ethernet frame address length
|
||||
#define N_AVAIL_ID 3 // available mkeep_alive IDs from 1 to 3
|
||||
#define MKEEP_ALIVE_IP_PKT_MAX 256 // max size of IP packet for keep alive
|
||||
|
||||
/**
|
||||
* Send specified keep alive packet periodically.
|
||||
*/
|
||||
wifi_error wifi_start_sending_offloaded_packet(wifi_request_id id, wifi_interface_handle iface,
|
||||
u8 *ip_packet, u16 ip_packet_len, u8 *src_mac_addr, u8 *dst_mac_addr, u32 period_msec);
|
||||
|
||||
/**
|
||||
* Stop sending keep alive packet.
|
||||
*/
|
||||
wifi_error wifi_stop_sending_offloaded_packet(wifi_request_id id, wifi_interface_handle iface);
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif /* __cplusplus */
|
||||
|
||||
#endif /*__WIFI_HAL_OFFLOAD_H */
|
Loading…
Add table
Add a link
Reference in a new issue