Skip to content

Commit e50bc80

Browse files
committed
Update to DP4
Change-Id: I40b5c4367c5d37ca4ba42803aaca131fc7e4b814
1 parent 7e67915 commit e50bc80

File tree

7 files changed

+197
-1
lines changed

7 files changed

+197
-1
lines changed

BUILD_NUMBER

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
nyc-iot-release@3961477 NIG86K
1+
nyc-iot-release@4007815 NIH40D
Lines changed: 72 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,72 @@
1+
/*
2+
* Copyright (C) 2017 The Android Open Source Project
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
17+
#ifndef SYSTEM_PERIPHERALMANAGER_I2S_H_
18+
#define SYSTEM_PERIPHERALMANAGER_I2S_H_
19+
20+
#include <sys/cdefs.h>
21+
#include <sys/types.h>
22+
23+
__BEGIN_DECLS
24+
25+
/// @defgroup I2s I2s Interface
26+
/// @brief Functions to control I2S pins.
27+
///
28+
/// These functions can be used to control I2S.
29+
/// @{
30+
31+
/// Possible encodings
32+
typedef enum APcmEncoding {
33+
APCM_ENCODING_8_BIT,
34+
APCM_ENCODING_16_BIT,
35+
APCM_ENCODING_24_BIT,
36+
APCM_ENCODING_32_BIT
37+
} APcmEncoding;
38+
39+
typedef struct AI2sDevice AI2sDevice;
40+
41+
/// Writes raw data to the I2S device. Multi-channel audio data is interleaved.
42+
/// @param i2s Pointer to the AI2s struct.
43+
/// @param data Data to write.
44+
/// @param offset Offset to first byte in data.
45+
/// @param size Number of bytes to write.
46+
/// @param bytes_written Number of bytes written.
47+
/// @return 0 on success, errno on error.
48+
int AI2sDevice_write(const AI2sDevice* i2s,
49+
const void* data,
50+
int offset,
51+
int size,
52+
int* bytes_written);
53+
54+
/// Reads raw data from the I2S device. Multi-channel audio data is interleaved.
55+
/// @param i2s Pointer to the AI2s struct.
56+
/// @param data Buffer to fill with data read.
57+
/// @param offset Offset to first byte in data.
58+
/// @param size Number of bytes to read.
59+
/// @param bytes_read Number of bytes read.
60+
/// @return 0 on success, errno on error.
61+
int AI2sDevice_read(
62+
const AI2sDevice* i2s, void* data, int offset, int size, int* bytes_read);
63+
64+
/// Destroys an AI2s struct.
65+
/// @param i2s Pointer to the AI2s struct.
66+
void AI2sDevice_delete(AI2sDevice* i2s);
67+
68+
/// @}
69+
70+
__END_DECLS
71+
72+
#endif // SYSTEM_PERIPHERALMANAGER_I2S_H_

armeabi-v7a/include/pio/peripheral_manager_client.h

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121

2222
#include "gpio.h"
2323
#include "i2c_device.h"
24+
#include "i2s_device.h"
2425
#include "pwm.h"
2526
#include "spi_device.h"
2627
#include "uart_device.h"
@@ -126,6 +127,31 @@ int APeripheralManagerClient_openUartDevice(
126127
const char* name,
127128
AUartDevice** dev);
128129

130+
/// Returns the list of I2S buses.
131+
/// This does not take ownership into account.
132+
/// The list must be freed by the caller.
133+
/// @param client Pointer to the APeripheralManagerClient struct.
134+
/// @param num_i2s_buses Output pointer to the number of elements in the list.
135+
/// @return The list of I2S buses.
136+
char** APeripheralManagerClient_listI2sDevices(
137+
const APeripheralManagerClient* client, int* num_i2s_buses);
138+
139+
/// Opens an I2S device and takes ownership of it.
140+
/// @param client Pointer to the APeripheralManagerClient struct.
141+
/// @param name Name of the I2S device.
142+
/// @param encoding Device pcm encoding.
143+
/// @param channels Number of channels.
144+
/// @param rate Device rate in Hz.
145+
/// @param dev Output pointer to the AI2sDevice struct. Empty on error.
146+
/// @return 0 on success, errno on error
147+
int APeripheralManagerClient_openI2sDevice(
148+
const APeripheralManagerClient* client,
149+
const char* name,
150+
APcmEncoding encoding,
151+
int channels,
152+
int rate,
153+
AI2sDevice** dev);
154+
129155
/// Creates a new client.
130156
/// @return A pointer to the created client. nullptr on errors.
131157
APeripheralManagerClient* APeripheralManagerClient_new();
0 Bytes
Binary file not shown.

x86/include/pio/i2s_device.h

Lines changed: 72 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,72 @@
1+
/*
2+
* Copyright (C) 2017 The Android Open Source Project
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
17+
#ifndef SYSTEM_PERIPHERALMANAGER_I2S_H_
18+
#define SYSTEM_PERIPHERALMANAGER_I2S_H_
19+
20+
#include <sys/cdefs.h>
21+
#include <sys/types.h>
22+
23+
__BEGIN_DECLS
24+
25+
/// @defgroup I2s I2s Interface
26+
/// @brief Functions to control I2S pins.
27+
///
28+
/// These functions can be used to control I2S.
29+
/// @{
30+
31+
/// Possible encodings
32+
typedef enum APcmEncoding {
33+
APCM_ENCODING_8_BIT,
34+
APCM_ENCODING_16_BIT,
35+
APCM_ENCODING_24_BIT,
36+
APCM_ENCODING_32_BIT
37+
} APcmEncoding;
38+
39+
typedef struct AI2sDevice AI2sDevice;
40+
41+
/// Writes raw data to the I2S device. Multi-channel audio data is interleaved.
42+
/// @param i2s Pointer to the AI2s struct.
43+
/// @param data Data to write.
44+
/// @param offset Offset to first byte in data.
45+
/// @param size Number of bytes to write.
46+
/// @param bytes_written Number of bytes written.
47+
/// @return 0 on success, errno on error.
48+
int AI2sDevice_write(const AI2sDevice* i2s,
49+
const void* data,
50+
int offset,
51+
int size,
52+
int* bytes_written);
53+
54+
/// Reads raw data from the I2S device. Multi-channel audio data is interleaved.
55+
/// @param i2s Pointer to the AI2s struct.
56+
/// @param data Buffer to fill with data read.
57+
/// @param offset Offset to first byte in data.
58+
/// @param size Number of bytes to read.
59+
/// @param bytes_read Number of bytes read.
60+
/// @return 0 on success, errno on error.
61+
int AI2sDevice_read(
62+
const AI2sDevice* i2s, void* data, int offset, int size, int* bytes_read);
63+
64+
/// Destroys an AI2s struct.
65+
/// @param i2s Pointer to the AI2s struct.
66+
void AI2sDevice_delete(AI2sDevice* i2s);
67+
68+
/// @}
69+
70+
__END_DECLS
71+
72+
#endif // SYSTEM_PERIPHERALMANAGER_I2S_H_

x86/include/pio/peripheral_manager_client.h

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121

2222
#include "gpio.h"
2323
#include "i2c_device.h"
24+
#include "i2s_device.h"
2425
#include "pwm.h"
2526
#include "spi_device.h"
2627
#include "uart_device.h"
@@ -126,6 +127,31 @@ int APeripheralManagerClient_openUartDevice(
126127
const char* name,
127128
AUartDevice** dev);
128129

130+
/// Returns the list of I2S buses.
131+
/// This does not take ownership into account.
132+
/// The list must be freed by the caller.
133+
/// @param client Pointer to the APeripheralManagerClient struct.
134+
/// @param num_i2s_buses Output pointer to the number of elements in the list.
135+
/// @return The list of I2S buses.
136+
char** APeripheralManagerClient_listI2sDevices(
137+
const APeripheralManagerClient* client, int* num_i2s_buses);
138+
139+
/// Opens an I2S device and takes ownership of it.
140+
/// @param client Pointer to the APeripheralManagerClient struct.
141+
/// @param name Name of the I2S device.
142+
/// @param encoding Device pcm encoding.
143+
/// @param channels Number of channels.
144+
/// @param rate Device rate in Hz.
145+
/// @param dev Output pointer to the AI2sDevice struct. Empty on error.
146+
/// @return 0 on success, errno on error
147+
int APeripheralManagerClient_openI2sDevice(
148+
const APeripheralManagerClient* client,
149+
const char* name,
150+
APcmEncoding encoding,
151+
int channels,
152+
int rate,
153+
AI2sDevice** dev);
154+
129155
/// Creates a new client.
130156
/// @return A pointer to the created client. nullptr on errors.
131157
APeripheralManagerClient* APeripheralManagerClient_new();

x86/lib/libandroidthings.so

4 KB
Binary file not shown.

0 commit comments

Comments
 (0)