summaryrefslogtreecommitdiffstats
path: root/src/radio_impl.h
diff options
context:
space:
mode:
authorScott Murray <scott.murray@konsulko.com>2023-01-03 00:51:50 -0500
committerScott Murray <scott.murray@konsulko.com>2023-01-19 00:37:11 +0000
commit7f26a2d06410fd3a2768612b9c9daf869778e480 (patch)
tree4dfffa78e14c8eadb42a731ae15cc87137e17723 /src/radio_impl.h
parent6191be9c1e4b628f60ccaeabcef2aaa9de00800b (diff)
Repurpose into gRPC servicequillback_17.0.0quillback/17.0.017.0.0
Repurpose repository into a spiritual successor of the previous binding. The backend code is retained behind a new gRPC API defined in protos/radio.proto. The simpler synchronous gRPC API had been used for expediency, this may warrant revisiting to rework into an async or callback API based server instead. As well, authentication has been left until some consensus on an approach can be worked out. Bug-AGL: SPEC-4665 Signed-off-by: Scott Murray <scott.murray@konsulko.com> Change-Id: I28b122ce6e0ecfc7504aa08b90394cb1b9e22976 (cherry picked from commit dd23c157bdba1b25bbb50cdb99a60aa597735f43)
Diffstat (limited to 'src/radio_impl.h')
-rw-r--r--src/radio_impl.h128
1 files changed, 128 insertions, 0 deletions
diff --git a/src/radio_impl.h b/src/radio_impl.h
new file mode 100644
index 0000000..96909f5
--- /dev/null
+++ b/src/radio_impl.h
@@ -0,0 +1,128 @@
+/*
+ * Copyright (C) 2017 Konsulko Group
+ *
+ * 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 _RADIO_IMPL_H
+#define _RADIO_IMPL_H
+
+#include <stdint.h>
+
+typedef enum {
+ RADIO_BAND_UNSPECIFIED = 0,
+ RADIO_BAND_AM,
+ RADIO_BAND_FM
+} radio_band_t;
+
+typedef enum {
+ RADIO_SCAN_UNSPECIFIED = 0,
+ RADIO_SCAN_FORWARD,
+ RADIO_SCAN_BACKWARD
+} radio_scan_direction_t;
+
+typedef void (*radio_scan_callback_t)(uint32_t frequency, void *data);
+
+typedef void (*radio_freq_callback_t)(uint32_t frequency, void *data);
+
+typedef void (*radio_rds_callback_t)(void *rds_data, void *dat);
+
+typedef enum {
+ RADIO_MODE_UNSPECIFIED = 0,
+ RADIO_MODE_MONO,
+ RADIO_MODE_STEREO
+} radio_stereo_mode_t;
+
+/*
+ * AF_update
+ * true if quality belongs to an alternative frequency
+ *
+ * time_stamp
+ * if time_stamp is zero, quality data won't be valid
+ * reliability depending on time stamp
+ * it takes some time after tuning to get valid quality data
+ *
+ * rssi
+ * (signed)
+ * level detector result(RF input level)
+ *
+ * usn
+ * FM ultrasonic noise detector (relative usn detector result)
+ *
+ * bandwidth
+ * IF bandwidth
+ */
+typedef struct
+{
+ bool af_update;
+ uint16_t time_stamp;
+ int16_t rssi;
+ uint16_t usn;
+ uint16_t bandw;
+} station_quality_t;
+
+typedef struct {
+ char *name;
+
+ int (*probe)(void);
+
+ /* NOTE: init should return -1 if called before probe has been called and returned success */
+ int (*init)(void);
+
+ void (*set_output)(const char *output);
+
+ uint32_t (*get_frequency)(void);
+
+ void (*set_frequency)(uint32_t frequency);
+
+ void (*set_frequency_callback)(radio_freq_callback_t callback,
+ void *data);
+
+ void (*set_rds_callback)(radio_rds_callback_t callback);
+
+ radio_band_t (*get_band)(void);
+
+ void (*set_band)(radio_band_t band);
+
+ int (*band_supported)(radio_band_t band);
+
+ uint32_t (*get_min_frequency)(radio_band_t band);
+
+ uint32_t (*get_max_frequency)(radio_band_t band);
+
+ uint32_t (*get_frequency_step)(radio_band_t band);
+
+ bool (*get_corking_state)(void);
+
+ void (*start)(void);
+
+ void (*stop)(void);
+
+ void (*scan_start)(radio_scan_direction_t direction,
+ radio_scan_callback_t callback,
+ void *data);
+
+ void (*scan_stop)(void);
+
+ radio_stereo_mode_t (*get_stereo_mode)(void);
+
+ void (*set_stereo_mode)(radio_stereo_mode_t mode);
+
+ char * (*get_rds_info)(void);
+
+ station_quality_t * (*get_quality_info)(void);
+
+ void (*set_alternative_frequency)(uint32_t frequency);
+} radio_impl_ops_t;
+
+#endif /* _RADIO_IMPL_H */