2
* Copyright (C) ST-Ericsson SA 2010
3
* Copyright (C) 2010 The Android Open Source Project
5
* Licensed under the Apache License, Version 2.0 (the "License");
6
* you may not use this file except in compliance with the License.
7
* You may obtain a copy of the License at
9
* http://www.apache.org/licenses/LICENSE-2.0
11
* Unless required by applicable law or agreed to in writing, software
12
* distributed under the License is distributed on an "AS IS" BASIS,
13
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
* See the License for the specific language governing permissions and
15
* limitations under the License.
17
* Author: johan.xj.palmaeus@stericsson.com for ST-Ericsson
21
* Interface file between the vendor specific drivers and the fmradio
22
* jni layer. The vendor driver need to define register function with
23
* name defined by FMRADIO_REGISTER_FUNC of type fmradio_reg_func_t that
24
* will return a pointer to a signature (FMRADIO_SIGNATURE) to make sure
25
* it executed correctly and fill struct fmradio_vendor_methods with
26
* functions implementing functions (or NULL if not supported).
29
#ifndef ANDROID_FMRADIO_INTERFACE_H
30
#define ANDROID_FMRADIO_INTERFACE_H
34
#define FMRADIO_REGISTER_FUNC "register_fmradio_functions"
36
#define FMRADIO_SIGNATURE 0xDEADBABE
38
#define FMRADIO_CAPABILITY_RECEIVER 0x0001
39
#define FMRADIO_CAPABILITY_TRANSMITTER 0x0002
40
#define FMRADIO_CAPABILITY_TUNER_WRAP_AROUND 0x0004
41
#define FMRADIO_CAPABILITY_RDS_SUPPORTED 0x0008
44
* return values. Not defined as enum since some functions either
45
* return a positive value or these codes, like getFrequency.
48
#define FMRADIO_INVALID_STATE -1 /* internally in jni layer */
49
#define FMRADIO_UNSUPPORTED_OPERATION -2
50
#define FMRADIO_IO_ERROR -3
51
#define FMRADIO_INVALID_PARAMETER -4
52
#define FMRADIO_FORCED_RESET -5
55
#define RDS_MAX_AFS 25
56
#define RDS_PSN_MAX_LENGTH 8
57
#define RDS_RT_MAX_LENGTH 64
58
#define RDS_CT_MAX_LENGTH 14
59
#define RDS_PTYN_MAX_LENGTH 8
60
#define RDS_NUMBER_OF_TMC 3
69
enum fmradio_seek_direction_t {
74
enum fmradio_reset_reason_t {
75
FMRADIO_RESET_NON_CRITICAL = 0,
76
FMRADIO_RESET_CRITICAL,
77
FMRADIO_RESET_OTHER_IN_USE, /* internally in jni layer */
78
FMRADIO_RESET_RADIO_FORBIDDEN, /* internally in java layer */
81
enum fmradio_extra_command_type_t {
86
enum fmradio_switch_reason_t {
92
union fmradio_extra_data_t {
97
struct fmradio_rds_bundle_t {
105
char psn[RDS_PSN_MAX_LENGTH + 1];
106
char rt[RDS_RT_MAX_LENGTH + 1];
107
char ct[RDS_CT_MAX_LENGTH + 1];
108
char ptyn[RDS_PTYN_MAX_LENGTH + 1];
109
short tmc[RDS_NUMBER_OF_TMC];
113
struct fmradio_extra_command_ret_item_t {
115
enum fmradio_extra_command_type_t type;
116
union fmradio_extra_data_t data;
119
/* vendor callbacks only for RX */
120
struct fmradio_vendor_callbacks_t {
121
void (*on_playing_in_stereo_changed) (int is_stereo);
122
void (*on_rds_data_found) (struct fmradio_rds_bundle_t * rds_bundle,
124
void (*on_signal_strength_changed) (int new_level);
125
void (*on_automatic_switch) (int new_freq,
126
enum fmradio_switch_reason_t reason);
127
void (*on_forced_reset) (enum fmradio_reset_reason_t reason);
130
struct fmradio_vendor_methods_t {
131
int (*rx_start) (void ** session_data,
132
const struct fmradio_vendor_callbacks_t * callbacks,
133
int low_freq, int high_freq, int default_freq, int grid);
134
int (*tx_start) (void ** session_data,
135
const struct fmradio_vendor_callbacks_t * callbacks,
136
int low_freq, int high_freq, int default_freq, int grid);
137
int (*pause) (void ** session_data);
138
int (*resume) (void ** session_data);
139
int (*reset) (void ** session_data);
140
int (*set_frequency) (void ** session_data, int frequency);
141
int (*get_frequency) (void ** session_data);
142
int (*stop_scan) (void ** session_data);
143
int (*send_extra_command) (void ** session_data, const char * command,
145
struct fmradio_extra_command_ret_item_t ** out_parameters);
147
int (*scan) (void ** session_data, enum fmradio_seek_direction_t direction);
149
int (*full_scan) (void ** session_data, int ** found_freqs,
150
int ** signal_strenghts);
151
int (*get_signal_strength) (void ** session_data);
152
int (*is_playing_in_stereo) (void ** session_data);
153
int (*is_rds_data_supported) (void ** session_data);
154
int (*is_tuned_to_valid_channel) (void ** session_data);
155
int (*set_automatic_af_switching) (void ** session_data, int automatic);
156
int (*set_automatic_ta_switching) (void ** session_data, int automatic);
157
int (*set_force_mono) (void ** session_data, int force_mono);
158
int (*get_threshold) (void ** session_data);
159
int (*set_threshold) (void ** session_data, int threshold);
160
int (*set_rds_reception) (void ** session_data, int use_rds);
162
int (*block_scan) (void ** session_data, int low_freq, int high_freq,
163
int ** found_freqs, int ** signal_strenghts);
164
int (*set_rds_data) (void ** session_data, char * key, void * value);
167
typedef int (*fmradio_reg_func_t) (unsigned int * signature_p,
168
struct fmradio_vendor_methods_t * vendor_funcs_p);
172
#endif // ANDROID_FMRADIO_INTERFACE_H