diff options
author | The Android Open Source Project <initial-contribution@android.com> | 2009-01-15 16:12:14 -0800 |
---|---|---|
committer | The Android Open Source Project <initial-contribution@android.com> | 2009-01-15 16:12:14 -0800 |
commit | 5ce01674d44addab570009ceddeaa08d64534092 (patch) | |
tree | 7efa8951d39fd254c9a0eba20180548670228ae5 /include | |
download | hardware_libhardware_legacy-5ce01674d44addab570009ceddeaa08d64534092.zip hardware_libhardware_legacy-5ce01674d44addab570009ceddeaa08d64534092.tar.gz hardware_libhardware_legacy-5ce01674d44addab570009ceddeaa08d64534092.tar.bz2 |
auto import from //branches/cupcake/...@126645
Diffstat (limited to 'include')
-rw-r--r-- | include/hardware_legacy/AudioHardwareBase.h | 74 | ||||
-rw-r--r-- | include/hardware_legacy/AudioHardwareInterface.h | 239 | ||||
-rw-r--r-- | include/hardware_legacy/IMountService.h | 63 | ||||
-rw-r--r-- | include/hardware_legacy/flashlight.h | 32 | ||||
-rw-r--r-- | include/hardware_legacy/gps.h | 261 | ||||
-rw-r--r-- | include/hardware_legacy/led.h | 44 | ||||
-rw-r--r-- | include/hardware_legacy/power.h | 60 | ||||
-rw-r--r-- | include/hardware_legacy/qemu_tracing.h | 33 | ||||
-rw-r--r-- | include/hardware_legacy/uevent.h | 31 | ||||
-rw-r--r-- | include/hardware_legacy/vibrator.h | 42 | ||||
-rw-r--r-- | include/hardware_legacy/wifi.h | 171 |
11 files changed, 1050 insertions, 0 deletions
diff --git a/include/hardware_legacy/AudioHardwareBase.h b/include/hardware_legacy/AudioHardwareBase.h new file mode 100644 index 0000000..1065c39 --- /dev/null +++ b/include/hardware_legacy/AudioHardwareBase.h @@ -0,0 +1,74 @@ +/* + * 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" + + +namespace android { + +// ---------------------------------------------------------------------------- + +/** + * AudioHardwareBase is a convenient base class used for implementing the + * AudioHardwareInterface interface. + */ +class AudioHardwareBase : public AudioHardwareInterface +{ +public: + AudioHardwareBase(); + virtual ~AudioHardwareBase() { } + + /** + * Audio routing methods. Routes defined in include/hardware_legacy/AudioSystem.h. + * Audio routes can be (ROUTE_EARPIECE | ROUTE_SPEAKER | ROUTE_BLUETOOTH + * | ROUTE_HEADSET) + * + * setRouting sets the routes for a mode. This is called at startup. It is + * also called when a new device is connected, such as a wired headset is + * plugged in or a Bluetooth headset is paired. + */ + virtual status_t setRouting(int mode, uint32_t routes); + + virtual status_t getRouting(int mode, uint32_t* routes); + + /** + * 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); + virtual status_t getMode(int* mode); + + // Temporary interface, do not use + // TODO: Replace with a more generic key:value get/set mechanism + virtual status_t setParameter(const char* key, const char* value); + + virtual size_t getInputBufferSize(uint32_t sampleRate, int format, int channelCount); + + /**This method dumps the state of the audio hardware */ + virtual status_t dumpState(int fd, const Vector<String16>& args); + +protected: + int mMode; + uint32_t mRoutes[AudioSystem::NUM_MODES]; +}; + +}; // namespace android + +#endif // ANDROID_AUDIO_HARDWARE_BASE_H diff --git a/include/hardware_legacy/AudioHardwareInterface.h b/include/hardware_legacy/AudioHardwareInterface.h new file mode 100644 index 0000000..371ee48 --- /dev/null +++ b/include/hardware_legacy/AudioHardwareInterface.h @@ -0,0 +1,239 @@ +/* + * 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 <media/IAudioFlinger.h> +#include "media/AudioSystem.h" + + +namespace android { + +// ---------------------------------------------------------------------------- + +/** + * 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; + + /** + * return number of output audio channels. + * Acceptable values are 1 (mono) or 2 (stereo) + */ + virtual int channelCount() 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 channelCount()*((format()==AudioSystem::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 volume) = 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; +}; + +/** + * 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 the input buffer size allowed by audio driver */ + virtual size_t bufferSize() const = 0; + + /** return the number of audio input channels */ + virtual int channelCount() 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 channelCount()*((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; + +}; + +/** + * 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: + /** + * 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; + + /** + * Audio routing methods. Routes defined in include/hardware_legacy/AudioSystem.h. + * Audio routes can be (ROUTE_EARPIECE | ROUTE_SPEAKER | ROUTE_BLUETOOTH + * | ROUTE_HEADSET) + * + * setRouting sets the routes for a mode. This is called at startup. It is + * also called when a new device is connected, such as a wired headset is + * plugged in or a Bluetooth headset is paired. + */ + virtual status_t setRouting(int mode, uint32_t routes) = 0; + + virtual status_t getRouting(int mode, uint32_t* routes) = 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; + virtual status_t getMode(int* mode) = 0; + + // mic mute + virtual status_t setMicMute(bool state) = 0; + virtual status_t getMicMute(bool* state) = 0; + + // Temporary interface, do not use + // TODO: Replace with a more generic key:value get/set mechanism + virtual status_t setParameter(const char* key, const char* value) = 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( + int format=0, + int channelCount=0, + uint32_t sampleRate=0, + status_t *status=0) = 0; + + /** This method creates and opens the audio hardware input stream */ + virtual AudioStreamIn* openInputStream( + int format, + int channelCount, + uint32_t sampleRate, + status_t *status) = 0; + + /**This method dumps the state of the audio hardware */ + virtual status_t dumpState(int fd, const Vector<String16>& args) = 0; + + static AudioHardwareInterface* create(); + +protected: + /** + * doRouting actually initiates the routing. A call to setRouting + * or setMode may result in a routing change. The generic logic calls + * doRouting when required. If the device has any special requirements these + * methods can be overriden. + */ + virtual status_t doRouting() = 0; + + virtual status_t dump(int fd, const Vector<String16>& args) = 0; +}; + +// ---------------------------------------------------------------------------- + +extern "C" AudioHardwareInterface* createAudioHardware(void); + +}; // namespace android + +#endif // ANDROID_AUDIO_HARDWARE_INTERFACE_H diff --git a/include/hardware_legacy/IMountService.h b/include/hardware_legacy/IMountService.h new file mode 100644 index 0000000..6737dcf --- /dev/null +++ b/include/hardware_legacy/IMountService.h @@ -0,0 +1,63 @@ +/* + * 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 <utils/IInterface.h> +#include <utils/String16.h> + +namespace android { + +// ---------------------------------------------------------------------- + +class IMountService : public IInterface +{ +public: + DECLARE_META_INTERFACE(MountService); + + /** + * Is mass storage support enabled? + */ + virtual bool getMassStorageEnabled() = 0; + + /** + * Enable or disable mass storage support. + */ + virtual void setMassStorageEnabled(bool enabled) = 0; + + /** + * Is mass storage connected? + */ + virtual bool getMassStorageConnected() = 0; + + /** + * Mount external storage at given mount point. + */ + virtual void mountMedia(String16 mountPoint) = 0; + + /** + * Safely unmount external storage at given mount point. + */ + virtual void unmountMedia(String16 mountPoint) = 0; +}; + +// ---------------------------------------------------------------------- + +}; // namespace android + +#endif // ANDROID_HARDWARE_IMOUNTSERVICE_H diff --git a/include/hardware_legacy/flashlight.h b/include/hardware_legacy/flashlight.h new file mode 100644 index 0000000..d372307 --- /dev/null +++ b/include/hardware_legacy/flashlight.h @@ -0,0 +1,32 @@ +/* + * 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_FLASHLIGHT_H
+#define _HARDWARE_FLASHLIGHT_H
+
+#if __cplusplus
+extern "C" {
+#endif
+
+int get_flashlight_enabled();
+int set_flashlight_enabled(int on);
+int enable_camera_flash(int milliseconds);
+
+#if __cplusplus
+} // extern "C"
+#endif
+
+#endif // _HARDWARE_FLASHLIGHT_H
diff --git a/include/hardware_legacy/gps.h b/include/hardware_legacy/gps.h new file mode 100644 index 0000000..5f8740f --- /dev/null +++ b/include/hardware_legacy/gps.h @@ -0,0 +1,261 @@ +/* + * 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_GPS_H +#define _HARDWARE_GPS_H + +#include <stdint.h> + +#if __cplusplus +extern "C" { +#endif + +/** Milliseconds since January 1, 1970 */ +typedef int64_t GpsUtcTime; + +/** Maximum number of SVs for gps_sv_status_callback(). */ +#define GPS_MAX_SVS 32 + +/** Requested mode for GPS operation. */ +typedef uint16_t GpsPositionMode; +// IMPORTANT: Note that the following values must match +// constants in GpsLocationProvider.java. +/** Mode for running GPS standalone (no assistance). */ +#define GPS_POSITION_MODE_STANDALONE 0 +/** SUPL MS-Based mode. */ +#define GPS_POSITION_MODE_MS_BASED 1 +/** SUPL MS-Assisted mode. */ +#define GPS_POSITION_MODE_MS_ASSISTED 2 + +/** GPS status event values. */ +typedef uint16_t GpsStatusValue; +// IMPORTANT: Note that the following values must match +// constants in GpsLocationProvider.java. +/** GPS status unknown. */ +#define GPS_STATUS_NONE 0 +/** GPS has begun navigating. */ +#define GPS_STATUS_SESSION_BEGIN 1 +/** GPS has stopped navigating. */ +#define GPS_STATUS_SESSION_END 2 +/** GPS has powered on but is not navigating. */ +#define GPS_STATUS_ENGINE_ON 3 +/** GPS is powered off. */ +#define GPS_STATUS_ENGINE_OFF 4 + +/** Flags to indicate which values are valid in a GpsLocation. */ +typedef uint16_t GpsLocationFlags; +// IMPORTANT: Note that the following values must match +// constants in GpsLocationProvider.java. +/** GpsLocation has valid latitude and longitude. */ +#define GPS_LOCATION_HAS_LAT_LONG 0x0001 +/** GpsLocation has valid altitude. */ +#define GPS_LOCATION_HAS_ALTITUDE 0x0002 +/** GpsLocation has valid speed. */ +#define GPS_LOCATION_HAS_SPEED 0x0004 +/** GpsLocation has valid bearing. */ +#define GPS_LOCATION_HAS_BEARING 0x0008 +/** GpsLocation has valid accuracy. */ +#define GPS_LOCATION_HAS_ACCURACY 0x0010 + +/** Flags used to specify which aiding data to delete + when calling delete_aiding_data(). */ +typedef uint16_t GpsAidingData; +// IMPORTANT: Note that the following values must match +// constants in GpsLocationProvider.java. +#define GPS_DELETE_EPHEMERIS 0x0001 +#define GPS_DELETE_ALMANAC 0x0002 +#define GPS_DELETE_POSITION 0x0004 +#define GPS_DELETE_TIME 0x0008 +#define GPS_DELETE_IONO 0x0010 +#define GPS_DELETE_UTC 0x0020 +#define GPS_DELETE_HEALTH 0x0040 +#define GPS_DELETE_SVDIR 0x0080 +#define GPS_DELETE_SVSTEER 0x0100 +#define GPS_DELETE_SADATA 0x0200 +#define GPS_DELETE_RTI 0x0400 +#define GPS_DELETE_CELLDB_INFO 0x8000 +#define GPS_DELETE_ALL 0xFFFF + +/** + * Name for the GPS XTRA interface. + */ +#define GPS_XTRA_INTERFACE "gps-xtra" + +/** + * Name for the GPS SUPL interface. + */ +#define GPS_SUPL_INTERFACE "gps-supl" + +/** Represents a location. */ +typedef struct { + /** Contains GpsLocationFlags bits. */ + uint16_t flags; + /** Represents latitude in degrees. */ + double latitude; + /** Represents longitude in degrees. */ + double longitude; + /** Represents altitude in meters above the WGS 84 reference + * ellipsoid. */ + double altitude; + /** Represents speed in meters per second. */ + float speed; + /** Represents heading in degrees. */ + float bearing; + /** Represents expected accuracy in meters. */ + float accuracy; + /** Timestamp for the location fix. */ + GpsUtcTime timestamp; +} GpsLocation; + +/** Represents the status. */ +typedef struct { + GpsStatusValue status; +} GpsStatus; + +/** Represents SV information. */ +typedef struct { + /** Pseudo-random number for the SV. */ + int prn; + /** Signal to noise ratio. */ + float snr; + /** Elevation of SV in degrees. */ + float elevation; + /** Azimuth of SV in degrees. */ + float azimuth; +} GpsSvInfo; + +/** Represents SV status. */ +typedef struct { + /** Number of SVs currently visible. */ + int num_svs; + + /** Contains an array of SV information. */ + GpsSvInfo sv_list[GPS_MAX_SVS]; + + /** Represents a bit mask indicating which SVs + * have ephemeris data. + */ + uint32_t ephemeris_mask; + + /** Represents a bit mask indicating which SVs + * have almanac data. + */ + uint32_t almanac_mask; + + /** + * Represents a bit mask indicating which SVs + * were used for computing the most recent position fix. + */ + uint32_t used_in_fix_mask; +} GpsSvStatus; + +/** Callback with location information. */ +typedef void (* gps_location_callback)(GpsLocation* location); + +/** Callback with status information. */ +typedef void (* gps_status_callback)(GpsStatus* status); + +/** Callback with SV status information. */ +typedef void (* gps_sv_status_callback)(GpsSvStatus* sv_info); + +/** GPS callback structure. */ +typedef struct { + gps_location_callback location_cb; + gps_status_callback status_cb; + gps_sv_status_callback sv_status_cb; +} GpsCallbacks; + + +/** Represents the standard GPS interface. */ +typedef struct { + /** + * Opens the interface and provides the callback routines + * to the implemenation of this interface. + */ + int (*init)( GpsCallbacks* callbacks ); + + /** Starts navigating. */ + int (*start)( void ); + + /** Stops navigating. */ + int (*stop)( void ); + + /** Sets requested frequency of fixes in seconds. */ + void (*set_fix_frequency)( int frequency ); + + /** Closes the interface. */ + void (*cleanup)( void ); + + /** Injects the current time. */ + int (*inject_time)(GpsUtcTime time, int64_t timeReference, + int uncertainty); + + /** + * Specifies that the next call to start will not use the + * information defined in the flags. GPS_DELETE_ALL is passed for + * a cold start. + */ + void (*delete_aiding_data)(GpsAidingData flags); + + /** + * fix_frequency represents the time between fixes in seconds. + * Set fix_frequency to zero for a single-shot fix. + */ + int (*set_position_mode)(GpsPositionMode mode, int fix_frequency); + + /** Get a pointer to extension information. */ + const void* (*get_extension)(const char* name); +} GpsInterface; + +/** Callback to request the client to download XTRA data. + The client should download XTRA data and inject it by calling + inject_xtra_data(). */ +typedef void (* gps_xtra_download_request)(); + +/** Callback structure for the XTRA interface. */ +typedef struct { + gps_xtra_download_request download_request_cb; +} GpsXtraCallbacks; + +/** Extended interface for XTRA support. */ +typedef struct { + /** + * Opens the XTRA interface and provides the callback routines + * to the implemenation of this interface. + */ + int (*init)( GpsXtraCallbacks* callbacks ); + /** Injects XTRA data into the GPS. */ + int (*inject_xtra_data)( char* data, int length ); +} GpsXtraInterface; + +/** Returns the hardware GPS interface. */ +const GpsInterface* gps_get_hardware_interface(); + +/** + * Returns the qemu emulated GPS interface. + */ +const GpsInterface* gps_get_qemu_interface(); + +/** + * Returns the default GPS interface. + */ +const GpsInterface* gps_get_interface(); + +#if __cplusplus +} // extern "C" +#endif + +#endif // _HARDWARE_GPS_H diff --git a/include/hardware_legacy/led.h b/include/hardware_legacy/led.h new file mode 100644 index 0000000..b5acb73 --- /dev/null +++ b/include/hardware_legacy/led.h @@ -0,0 +1,44 @@ +/* + * 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_LED_H +#define _HARDWARE_LED_H + +#if __cplusplus +extern "C" { +#endif + +/** + * Changes the state of the LED. + * + * -# Turn on LED: Alpha != 0 and RBG != 0, onMS == 0 && offMS == 0. + * -# Blink LED: Alpha != 0 and RBG != 0, onMS != 0 && offMS != 0. + * -# Turn off LED: Alpha == 0 or RGB == 0. + * + * @param colorARGB represents the LED's color: Alpha=31:24, Red=23:16 + * Green=15:8 Blue=7:0 + * @param onMS represents the time the LED is on in milliseconds + * @param offMS represents the time the LED is off in milliseconds + * + * @return 0 if successful + */ +int set_led_state(unsigned colorARGB, int onMS, int offMS); + +#if __cplusplus +} // extern "C" +#endif + +#endif // _HARDWARE_LED_H diff --git a/include/hardware_legacy/power.h b/include/hardware_legacy/power.h new file mode 100644 index 0000000..993bca5 --- /dev/null +++ b/include/hardware_legacy/power.h @@ -0,0 +1,60 @@ +/* + * 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); + + +enum { + KEYBOARD_LIGHT = 0x00000001, + SCREEN_LIGHT = 0x00000002, + BUTTON_LIGHT = 0x00000004, +}; + +// set the lights identified in mask to the brightness specified +// in value. for example +// set_light_brightness(SCREEN_LIGHT | KEYBOARD_LIGHT, 200); +// sets the screen and keyboard lights to brightness 200 +int set_light_brightness(unsigned int mask, unsigned int brightness); + +// true if you want the screen on, false if you want it off +int set_screen_state(int on); + +// set how long to stay awake after the last user activity in seconds +int set_last_user_activity_timeout(int64_t delay); + + +#if __cplusplus +} // extern "C" +#endif + +#endif // _HARDWARE_POWER_H diff --git a/include/hardware_legacy/qemu_tracing.h b/include/hardware_legacy/qemu_tracing.h new file mode 100644 index 0000000..645a0be --- /dev/null +++ b/include/hardware_legacy/qemu_tracing.h @@ -0,0 +1,33 @@ +/* + * 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_QEMU_TRACING_H +#define _HARDWARE_QEMU_TRACING_H + +#if __cplusplus +extern "C" { +#endif + +int qemu_start_tracing(); +int qemu_stop_tracing(); +int qemu_add_mapping(unsigned int addr, const char *name); +int qemu_remove_mapping(unsigned int addr); + +#if __cplusplus +} // extern "C" +#endif + +#endif // _HARDWARE_QEMU_TRACING_H diff --git a/include/hardware_legacy/uevent.h b/include/hardware_legacy/uevent.h new file mode 100644 index 0000000..7a5ce58 --- /dev/null +++ b/include/hardware_legacy/uevent.h @@ -0,0 +1,31 @@ +/* + * 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_next_event(char* buffer, int buffer_length); + +#if __cplusplus +} // extern "C" +#endif + +#endif // _HARDWARE_UEVENT_H diff --git a/include/hardware_legacy/vibrator.h b/include/hardware_legacy/vibrator.h new file mode 100644 index 0000000..5245aeb --- /dev/null +++ b/include/hardware_legacy/vibrator.h @@ -0,0 +1,42 @@ +/* + * 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_VIBRATOR_H +#define _HARDWARE_VIBRATOR_H + +#if __cplusplus +extern "C" { +#endif + +/** + * Turn on vibrator + * + * @return 0 if successful, -1 if error + */ +int vibrator_on(); + +/** + * Turn off vibrator + * + * @return 0 if successful, -1 if error + */ +int vibrator_off(); + +#if __cplusplus +} // extern "C" +#endif + +#endif // _HARDWARE_VIBRATOR_H diff --git a/include/hardware_legacy/wifi.h b/include/hardware_legacy/wifi.h new file mode 100644 index 0000000..23cc92a --- /dev/null +++ b/include/hardware_legacy/wifi.h @@ -0,0 +1,171 @@ +/* + * 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_H +#define _WIFI_H + +#if __cplusplus +extern "C" { +#endif + +/** + * Load the Wi-Fi driver. + * + * @return 0 on success, < 0 on failure. + */ +int wifi_load_driver(); + +/** + * Unload the Wi-Fi driver. + * + * @return 0 on success, < 0 on failure. + */ +int wifi_unload_driver(); + +/** + * Start supplicant. + * + * @return 0 on success, < 0 on failure. + */ +int wifi_start_supplicant(); + +/** + * Stop supplicant. + * + * @return 0 on success, < 0 on failure. + */ +int wifi_stop_supplicant(); + +/** + * Open a connection to supplicant. + * + * @return 0 on success, < 0 on failure. + */ +int wifi_connect_to_supplicant(); + +/** + * Close connection supplicant. + * + * @return 0 on success, < 0 on failure. + */ +void wifi_close_supplicant_connection(); + +/** + * wifi_wait_for_event() performs a blocking call to + * get a Wi-Fi event and returns a string representing + * a Wi-Fi event when it occurs. + * + * @param buf is the buffer that receives the event + * @param len is the maximum length of the buffer + * + * @returns number of bytes in buffer, 0 if no + * event (for instance, no connection), and less than 0 + * if there is an error. + */ +int wifi_wait_for_event(char *buf, size_t len); + +/** + * wifi_command() issues a command to the Wi-Fi driver. + * + * Android extends the standard commands listed at + * /link http://hostap.epitest.fi/wpa_supplicant/devel/ctrl_iface_page.html + * to include support for sending commands to the driver: + * + * <table border="2" cellspacing="2" cellpadding="2"> + * <tr> + * <td><strong>Command / Command summary</strong></td> + * <td><strong>Form of Response</strong></td> + * <td><strong>Processing</strong></td> + * </tr> + * <tr> + * <td>DRIVER START<BR> Turn on Wi-Fi Hardware</td> + * <td>OK if successful</td> + * <td>OK ? true : false</td> + * </tr> + * <tr> + * <td>DRIVER STOP<BR> Turn off Wi-Fi hardware</td> + * <td>OK if successful</td> + * <td>OK ? true : false</td> + * </tr> + * <tr> + * <td>DRIVER RSSI<BR> Return received signal strength indicator in -db for current AP</td> + * <td><ssid> Rssi xx</td> + * <td>%*s %*s %d", &rssi</td> + * </tr> + * <tr> + * <td>DRIVER LINKSPEED<BR> Return link speed in MBPS</td> + * <td>LinkSpeed xx</td> + * <td>%*s %d", &linkspd</td> + * </tr> + * <tr> + * <td>DRIVER MACADDR<BR> Return mac address of the station</td> + * <td>Macaddr = xx.xx.xx.xx.xx.xx</td> + * <td>"%*s = %s", &macadr</td> + * </tr> + * <tr> + * <td>DRIVER SCAN-ACTIVE<BR> Set scan type to active</td> + * <td>"OK" if successful</td> + * <td>"OK" ? true : false</td> + * </tr> + * <tr> + * <td>DRIVER SCAN-PASSIVE<BR> Set scan type to passive</td> + * <td>"OK" if successful</td> + * <td>"OK" ? true : false</td> + * </tr> + * </table> + * + * See libs/android_runtime/android_net_wifi_Wifi.cpp for more information + * describing how these and other commands are invoked. + * + * @param command is the string command + * @param reply is a buffer to receive a reply string + * @param reply_len on entry, this is the maximum length of + * the reply buffer. On exit, the number of + * bytes in the reply buffer. + * + * @return 0 if successful, < 0 if an error. + */ +int wifi_command(const char *command, char *reply, size_t *reply_len); + +/** + * do_dhcp_request() issues a dhcp request and returns the acquired + * information. + * + * All IPV4 addresses/mask are in network byte order. + * + * @param ipaddr return the assigned IPV4 address + * @param gateway return the gateway being used + * @param mask return the IPV4 mask + * @param dns1 return the IPV4 address of a DNS server + * @param dns2 return the IPV4 address of a DNS server + * @param server return the IPV4 address of DHCP server + * @param lease return the length of lease in seconds. + * + * @return 0 if successful, < 0 if error. + */ +int do_dhcp_request(int *ipaddr, int *gateway, int *mask, + int *dns1, int *dns2, int *server, int *lease); + +/** + * Return the error string of the last do_dhcp_request(). + */ +const char *get_dhcp_error_string(); + +#if __cplusplus +}; // extern "C" +#endif + +#endif // _WIFI_H |