|
| 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_ |
0 commit comments