Home | History | Annotate | Download | only in include
      1 /*
      2  * Copyright (C) 2015 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 ANDROID_RADIO_METADATA_HIDDEN_H
     18 #define ANDROID_RADIO_METADATA_HIDDEN_H
     19 
     20 #include <stdbool.h>
     21 #include <system/radio.h>
     22 #include <system/radio_metadata.h>
     23 
     24 /* default size allocated for a metadata buffer in 32 bits units */
     25 #define RADIO_METADATA_DEFAULT_SIZE 64
     26 /* maximum size allocated for a metadata buffer in 32 bits units */
     27 #define RADIO_METADATA_MAX_SIZE (RADIO_METADATA_DEFAULT_SIZE << 12)
     28 
     29 /* meta data entry in a meta data buffer */
     30 typedef struct radio_metadata_entry {
     31     radio_metadata_key_t    key;
     32     radio_metadata_type_t   type;
     33     unsigned int            size;
     34     unsigned char           data[];
     35 } radio_metadata_entry_t;
     36 
     37 
     38 /**
     39 * meta data buffer layout:
     40 *
     41 *   |    <---  32 bit   --->    |
     42 *   |---------------------------|
     43 *   | channel                   |
     44 *   |---------------------------|
     45 *   | sub_channel               |
     46 *   |---------------------------|
     47 *   | size_int                  | total size in 32 bit units including header and index
     48 *   |---------------------------|
     49 *   | count                     | number of entries
     50 *   |---------------------------|<--+
     51 *   | first entry               |   |
     52 *   |                           |   |
     53 *   |---------------------------|<+ |
     54 *   | second entry              | | |
     55 *   |                           | | |
     56 *   |                           | | |
     57 *   |---------------------------| | |
     58 *   |     :                     | | |
     59 *   |---------------------------| | |       \
     60 *   | offset of next free space | | |       |
     61 *   |---------------------------| | |       |
     62 *   |     :                     | | |       |
     63 *   |---------------------------| | |       >  index
     64 *   | offset of second entry    |-+ |       |
     65 *   |---------------------------|   |       |
     66 *   | offset of first entry     |---+       |
     67 *   |---------------------------|           /
     68 *
     69 *   A radio meta data buffer is allocated with radio_metadata_allocate() and released with
     70 *   radio_metadata_deallocate().
     71 *   Meta data entries are added with radio_metadata_add_xxx() where xxx is int, text or raw.
     72 *   The buffer is allocated with a default size (RADIO_METADATA_DEFAULT_SIZE entries)
     73 *   by radio_metadata_allocate() and reallocated if needed by radio_metadata_add_xxx()
     74 */
     75 
     76 /* Radio meta data buffer header */
     77 typedef struct radio_metadata_buffer {
     78     unsigned int channel;       /* channel (frequency) this meta data is associated with */
     79     unsigned int sub_channel;   /* sub channel this meta data is associated with */
     80     unsigned int size_int;      /* Total size in 32 bit word units */
     81     unsigned int count;         /* number of meta data entries */
     82 } radio_metadata_buffer_t;
     83 
     84 
     85 
     86 #endif  // ANDROID_RADIO_METADATA_HIDDEN_H
     87