diff options
-rw-r--r-- | .gitignore | 5 | ||||
-rw-r--r-- | Kconfig | 11 | ||||
-rw-r--r-- | Makefile | 14 | ||||
-rw-r--r-- | README.md | 6 | ||||
-rw-r--r-- | codec/Kconfig | 0 | ||||
-rw-r--r-- | config.h | 13 | ||||
-rw-r--r-- | config/config_bsd.h | 12 | ||||
-rw-r--r-- | config/config_linux.h | 14 | ||||
-rw-r--r-- | core/Kconfig | 28 | ||||
-rw-r--r-- | draw/Kconfig | 20 | ||||
-rw-r--r-- | fft/Kconfig | 0 | ||||
-rw-r--r-- | filt/Kconfig | 0 | ||||
-rw-r--r-- | hw/Kconfig | 39 | ||||
-rw-r--r-- | mod/Kconfig | 51 | ||||
-rw-r--r-- | net/Kconfig | 0 | ||||
-rw-r--r-- | plug/Kconfig | 0 | ||||
-rw-r--r-- | radiola.c | 1 | ||||
-rw-r--r-- | test/sdr_fm.c | 9 | ||||
-rw-r--r-- | test/ui_gl_waterfall.c | 2 | ||||
-rw-r--r-- | test/ui_tui_waterfall.c | 2 | ||||
-rw-r--r-- | tools/kconf2h/Makefile | 20 | ||||
-rw-r--r-- | tools/kconf2h/kconf2h.c | 50 | ||||
-rw-r--r-- | tools/kconf2h/kconf2h.h | 10 | ||||
-rw-r--r-- | tools/kconf2h/kconf2h_parser.c | 327 | ||||
-rw-r--r-- | utils/Kconfig | 0 |
25 files changed, 627 insertions, 7 deletions
@@ -1,3 +1,8 @@ radiola radiola.o build/ +*.o +kconf2h +.config +.config.old +mconf @@ -0,0 +1,11 @@ +source "codec/Kconfig" +source "core/Kconfig" +source "draw/Kconfig" +source "fft/Kconfig" +source "filt/Kconfig" +source "hw/Kconfig" +source "mod/Kconfig" +source "plug/Kconfig" +source "utils/Kconfig" + + @@ -15,6 +15,8 @@ include filt/make.mk include hw/make.mk include mod/make.mk + + make: $(OBJECTS) $(CC) $(OBJECTS_FINAL) $(PROJECT).c -o $(PROJECT) $(LDFLAGS) ld -r $(OBJECTS_FINAL) -o $(PROJECT).o @@ -30,3 +32,15 @@ clean: distclean: clean rm -rf $(BUILD_DIR) + +kconf2h: tools/kconf2h/kconf2h + $(CC) -c tools/kconf2h/kconf2h_parser.c -o tools/kconf2h/kconf2h_parser.o + $(CC) tools/kconf2h/kconf2h.c tools/kconf2h/kconf2h_parser.o -o tools/kconf2h/kconf2h + +menuconfig: kconf2h + ./mconf Kconfig + tools/kconf2h/kconf2h .config config/config_linux.h + +bsd: kconf2h + ./mconf Kconfig + tools/kconf2h/kconf2h .config config/config_bsd.h
\ No newline at end of file @@ -2,9 +2,9 @@ rtlsdr based sdr software, early prototype -basic support for terminal waterfall, -basic support for graphical waterfall, -basic support for fm demodulation (ready to listen fm station) +* basic support for terminal waterfall, +* basic support for graphical waterfall, +* basic support for fm demodulation (ready to listen fm station) ## terminal waterfall diff --git a/codec/Kconfig b/codec/Kconfig new file mode 100644 index 0000000..e69de29 --- /dev/null +++ b/codec/Kconfig diff --git a/config.h b/config.h new file mode 100644 index 0000000..df2d1f5 --- /dev/null +++ b/config.h @@ -0,0 +1,13 @@ +#ifndef ___CONFIG_H +#define ___CONFIG_H +/* +Default configuration is linux configuration ofc +*/ + +#if defined(BSD) +#include "config/config_bsd.h" +#else +#include "config/config_linux.h" +#endif + +#endif diff --git a/config/config_bsd.h b/config/config_bsd.h new file mode 100644 index 0000000..95985f1 --- /dev/null +++ b/config/config_bsd.h @@ -0,0 +1,12 @@ +#ifndef __CONFIG_H +#define __CONFIG_H +#define CONFIG_CORE +#define CONFIG_OS_NETBSD +#define CONFIG_DRAW +#define CONFIG_TUI +#define CONFIG_HW +#define CONFIG_HW_LIB_ORIG +#define CONFIG_HW_NO_AUDIO +#define CONFIG_MOD +#define CONFIG_MOD_FM_DEMOD +#endif diff --git a/config/config_linux.h b/config/config_linux.h new file mode 100644 index 0000000..5fc9189 --- /dev/null +++ b/config/config_linux.h @@ -0,0 +1,14 @@ +#ifndef __CONFIG_H +#define __CONFIG_H +#define CONFIG_CORE +#define CONFIG_OS_LINUX +#define CONFIG_DRAW +#define CONFIG_GL +#define CONFIG_SDL2 +#define CONFIG_TUI +#define CONFIG_HW +#define CONFIG_HW_LIB_ORIG +#define CONFIG_HW_ALSA +#define CONFIG_MOD +#define CONFIG_MOD_FM_DEMOD +#endif diff --git a/core/Kconfig b/core/Kconfig new file mode 100644 index 0000000..28befc6 --- /dev/null +++ b/core/Kconfig @@ -0,0 +1,28 @@ +menuconfig CORE + bool "Set core features" + default y + +if CORE + choice + prompt "OS support" + help + OS support configuration. Not all OS'es support all stuff + + config OS_LINUX + bool "Linux" + default y + + config OS_NETBSD + bool "NetBSD" + default n + + endchoice + + config FUTURE + bool "Future features that planned to be added" + default n + +endif + + + diff --git a/draw/Kconfig b/draw/Kconfig new file mode 100644 index 0000000..486461f --- /dev/null +++ b/draw/Kconfig @@ -0,0 +1,20 @@ +menuconfig DRAW + bool "Graphic library support" + default y + +if DRAW + config GL + bool "OpenGL support" + default y + + config SDL2 + bool "SDL2 support" + default y + + config TUI + bool "Terminal interface support" + default y +endif + + + diff --git a/fft/Kconfig b/fft/Kconfig new file mode 100644 index 0000000..e69de29 --- /dev/null +++ b/fft/Kconfig diff --git a/filt/Kconfig b/filt/Kconfig new file mode 100644 index 0000000..e69de29 --- /dev/null +++ b/filt/Kconfig diff --git a/hw/Kconfig b/hw/Kconfig new file mode 100644 index 0000000..f95a0f5 --- /dev/null +++ b/hw/Kconfig @@ -0,0 +1,39 @@ +menuconfig HW + bool "Hardware support" + default y + +if HW + choice + prompt "RTLSDR library" + help + RTLSDR library + + config HW_LIB_ORIG + bool "librtlsdr original version" + default y + + config HW_LIB_R820T + bool "libr820t for of librtlsdr by radiola" + default n + + + endchoice + + choice + prompt "Audio" + + config HW_ALSA + bool "Linux ALSA" + default y + depends on OS_LINUX + + config HW_NO_AUDIO + bool "No audio support" + default n + + endchoice + +endif + + + diff --git a/mod/Kconfig b/mod/Kconfig new file mode 100644 index 0000000..50413a0 --- /dev/null +++ b/mod/Kconfig @@ -0,0 +1,51 @@ +menuconfig MOD + bool "Modulation support" + default y + +if MOD + config MOD_FM + bool "FM mod" + default n + depends on FUTURE + + config MOD_FM_DEMOD + bool "FM demod" + default n + + config MOD_WBFM_DEMOD + bool "WBFM demod" + default n + depends on FUTURE + + config MOD_AM_DEMOD + bool "AM demod" + default n + depends on FUTURE + + config MOD_PSK_DEMOD + bool "PSK demod" + default n + depends on FUTURE + + config MOD_PSK31_DEMOD + bool "PSK31 demod" + default n + depends on FUTURE + +endif + +menuconfig PROTO + bool "Protocol support" + default n + +if PROTO + config PROTO_AX25 + bool "AX.25 radio packet support" + default n + depends on FUTURE + + config PROTO_NOAA + bool "NOAA satelite recieving" + default n + depends on FUTURE +endif diff --git a/net/Kconfig b/net/Kconfig new file mode 100644 index 0000000..e69de29 --- /dev/null +++ b/net/Kconfig diff --git a/plug/Kconfig b/plug/Kconfig new file mode 100644 index 0000000..e69de29 --- /dev/null +++ b/plug/Kconfig @@ -1,6 +1,7 @@ #include <stdio.h> #include <stdlib.h> +#include "config.h" #include "hw/hw.h" int main() diff --git a/test/sdr_fm.c b/test/sdr_fm.c index 24c69d0..80df657 100644 --- a/test/sdr_fm.c +++ b/test/sdr_fm.c @@ -6,6 +6,8 @@ #include <unistd.h> #include <complex.h> +#include <sys/timeb.h> + #include <hw/hw.h> #include <hw/sdr.h> @@ -13,7 +15,7 @@ #define RESAMPLE_RATE 50000 #define CENTER_FREQ 101100000 -#define FFT_LEVEL 18 +#define FFT_LEVEL 10 #define FFT_SIZE (1 << FFT_LEVEL) #define SAMPLE_LENGHT (2 * FFT_SIZE) #define PRESCALE 8 @@ -224,7 +226,6 @@ void delay_filt( uint8_t *buf, int buf_len ) cyc_buffer_i[cycle] = avg_i; cyc_buffer_q[cycle] = avg_q; cycle = cycle + 1; - //cycle += 1; if ( cycle >= n ) { cycle = 0; @@ -263,6 +264,8 @@ int main( int argc, char **argv ) sdr_t *sdr = NULL; dongle_t *dongle = NULL; + struct timeb tb; + // get all argument configs opterr = 0; while ( (c = getopt(argc, argv, "f:s:d:")) != -1 ) @@ -377,6 +380,8 @@ int main( int argc, char **argv ) //write to play write(1, sound_buf, ((SAMPLE_LENGHT/20)*sizeof(signed short))); + //ftime(&tb); + //printf("%d\n",tb.millitm); //exit(0); //usleep(1); //printf("Sample\n"); diff --git a/test/ui_gl_waterfall.c b/test/ui_gl_waterfall.c index 72dec46..837383f 100644 --- a/test/ui_gl_waterfall.c +++ b/test/ui_gl_waterfall.c @@ -302,7 +302,7 @@ int main( int argc, char **argv ) sample_buf = malloc( sample_len ); srand(0); //fake seed - for ( i=0; i<400;i++ ) + for ( i=0; i<4000;i++ ) { //for (j=0; j<buf_len; j++) // sample_buf[j] = (uint8_t)((rand()&0xff)); diff --git a/test/ui_tui_waterfall.c b/test/ui_tui_waterfall.c index c322670..355751f 100644 --- a/test/ui_tui_waterfall.c +++ b/test/ui_tui_waterfall.c @@ -247,7 +247,7 @@ int main() sample_buf = malloc( sample_len ); srand(0); //fake seed - for ( i=0; i<400;i++ ) + for ( i=0; i<40;i++ ) { //for (j=0; j<buf_len; j++) // sample_buf[j] = (uint8_t)((rand()&0xff)); diff --git a/tools/kconf2h/Makefile b/tools/kconf2h/Makefile new file mode 100644 index 0000000..b5a42c3 --- /dev/null +++ b/tools/kconf2h/Makefile @@ -0,0 +1,20 @@ +PROJECT=kconf2h +CC=gcc +CFLAGS= +SOURCES=$(PROJECT)_parser.c +OBJECTS=$(SOURCES:.c=.o) + +all: clean ragel $(OBJECTS) $(PROJECT) + +$(PROJECT): + $(CC) $(CFLAGS) $(OBJECTS) $(PROJECT).c -o $(PROJECT) + +ragel: + ragel $(PROJECT)_parser.ragel + +%.o: %.c + $(CC) $(CFLAGS) -c $< + +clean: + rm -f $(PROJECT) + rm -f *.o diff --git a/tools/kconf2h/kconf2h.c b/tools/kconf2h/kconf2h.c new file mode 100644 index 0000000..91ef6c7 --- /dev/null +++ b/tools/kconf2h/kconf2h.c @@ -0,0 +1,50 @@ +#include <stdio.h> +#include <stdlib.h> + +#include <sys/stat.h> + +#include "kconf2h.h" + +int main( int argc, char **argv ) +{ + FILE *fin = NULL; + FILE *fout = NULL; + struct stat st; + + char *buf=NULL; + if ( argc == 3 ) + { + fin = fopen( argv[1], "r+" ); + fout = fopen( argv[2], "w+" ); + fseek( fin, 0, SEEK_SET ); + if ( fin && fout ) + { + if ( stat( argv[1], &st ) ) + { + goto error_exit; + } + buf = malloc( st.st_size ); memset( buf, 0, st.st_size ); + size_t r_size = fread( buf, 1, st.st_size, fin ); + if ( r_size > 0 ) + { + int ret = parse_kconf2h( buf, fout ); + printf("Kconfig file parsed %d %d bytes\n", ret, r_size ); + } else + { + printf("ERR: while reading file %s [%d]\n", argv[1], r_size); + } +error_exit: + if ( buf ) free( buf ); + fclose( fin ); + fclose( fout ); + } else + { + printf("ERR: Cannot open file\n"); + } + } else + { + printf("ERR: usage ./kconf2h [conffile] [outputheader]\n"); + return -1; + } + return 0; +} diff --git a/tools/kconf2h/kconf2h.h b/tools/kconf2h/kconf2h.h new file mode 100644 index 0000000..165d4cc --- /dev/null +++ b/tools/kconf2h/kconf2h.h @@ -0,0 +1,10 @@ +#ifndef __KCONF2H_H +#define __KCONF2H_H + +#include <stdio.h> +#include <stdlib.h> +#include <string.h> + +int parse_kconf2h( const char*, FILE* ); + +#endif diff --git a/tools/kconf2h/kconf2h_parser.c b/tools/kconf2h/kconf2h_parser.c new file mode 100644 index 0000000..6a25dbc --- /dev/null +++ b/tools/kconf2h/kconf2h_parser.c @@ -0,0 +1,327 @@ + +#line 1 "kconf2h_parser.ragel" +#include <stdio.h> +#include <stdlib.h> +#include <stdint.h> +#include <string.h> + +#include "kconf2h.h" + +#define TYPE_YM 1 +#define TYPE_HEX 2 +#define TYPE_STR 3 +#define TYPE_DEC 4 + +char *new_string( const char *start, const char *end ) +{ + int str_s = end-start+1; + char *new_str=malloc( str_s+1 ); + memcpy( new_str, start, str_s ); + if ( new_str != NULL ) + new_str[str_s]=0x0; + return new_str; +} + +int o_head_def( FILE *f, int type, const char *s_define, const char *e_define, + const char *s_value, const char *e_value ) +{ + if ( f != NULL ) + { + if ( (s_define != NULL) && (e_define != NULL) && (s_define <= e_define) && + (s_value != NULL) && ( e_value != NULL ) && ( s_value <= e_value )) + { + char *def = new_string( s_define, e_define ); + char *val = NULL; + //printf( "%s\n", def ); + fprintf( f, "#define %s", def ); + free( def ); + + if ( type != TYPE_YM ) + { + val = new_string( s_value, e_value ); + fprintf( f, " %s", val ); + free( val ); + } + /* + switch ( type ) + { + case TYPE_HEX: + fprintf( f, " %s", val ); + break; + case TYPE_STR: + fprintf( f, " %s", val ); + break; + case TYPE_DEC: + fprintf( f, " %s", val ); + break; + default: + printf("Unknown Kconfig type %d\n", type); + } + */ + + fprintf( f, "\n" ); + return 1; + } + } + return 0; +} + + +#line 71 "kconf2h_parser.c" +static const char _k2h_actions[] = { + 0, 1, 0, 1, 2, 1, 7, 1, + 11, 2, 9, 1, 4, 3, 8, 10, + 11, 4, 4, 8, 10, 11, 4, 5, + 8, 10, 11, 4, 6, 8, 10, 11 + +}; + +static const char _k2h_key_offsets[] = { + 0, 0, 3, 6, 7, 8, 9, 10, + 11, 12, 17, 23, 30, 33, 37, 39, + 42, 46, 52, 59, 60 +}; + +static const char _k2h_trans_keys[] = { + 10, 35, 67, 10, 32, 126, 79, 78, + 70, 73, 71, 95, 95, 48, 57, 65, + 90, 61, 95, 48, 57, 65, 90, 34, + 45, 48, 109, 121, 49, 57, 34, 32, + 126, 10, 34, 32, 126, 48, 57, 10, + 48, 57, 10, 120, 48, 57, 48, 57, + 65, 70, 97, 102, 10, 48, 57, 65, + 70, 97, 102, 10, 10, 35, 67, 0 +}; + +static const char _k2h_single_lengths[] = { + 0, 3, 1, 1, 1, 1, 1, 1, + 1, 1, 2, 5, 1, 2, 0, 1, + 2, 0, 1, 1, 3 +}; + +static const char _k2h_range_lengths[] = { + 0, 0, 1, 0, 0, 0, 0, 0, + 0, 2, 2, 1, 1, 1, 1, 1, + 1, 3, 3, 0, 0 +}; + +static const char _k2h_index_offsets[] = { + 0, 0, 4, 7, 9, 11, 13, 15, + 17, 19, 23, 28, 35, 38, 42, 44, + 47, 51, 55, 60, 62 +}; + +static const char _k2h_indicies[] = { + 0, 2, 3, 1, 0, 4, 1, 5, + 1, 6, 1, 7, 1, 8, 1, 9, + 1, 10, 1, 11, 11, 11, 1, 12, + 11, 11, 11, 1, 13, 14, 15, 17, + 17, 16, 1, 19, 18, 1, 20, 19, + 18, 1, 21, 1, 22, 21, 1, 22, + 23, 21, 1, 24, 24, 24, 1, 25, + 24, 24, 24, 1, 26, 1, 0, 2, + 3, 1, 0 +}; + +static const char _k2h_trans_targs[] = { + 20, 0, 2, 3, 2, 4, 5, 6, + 7, 8, 9, 10, 11, 12, 14, 16, + 15, 19, 12, 13, 20, 15, 20, 17, + 18, 20, 20 +}; + +static const char _k2h_trans_actions[] = { + 7, 0, 1, 9, 0, 0, 0, 0, + 0, 0, 0, 0, 3, 5, 5, 5, + 5, 5, 0, 0, 22, 0, 17, 0, + 0, 27, 12 +}; + +static const int k2h_start = 1; +static const int k2h_first_final = 20; +static const int k2h_error = 0; + +static const int k2h_en_main = 1; + + +#line 87 "kconf2h_parser.ragel" + + +int parse_kconf2h( const char *str, FILE *outf ) +{ + + + + static uint8_t cs; + const int stacksize = 10; + int res=0, *top=0, *stack=NULL; + stack = malloc( sizeof(stack)*stacksize ); + char *p=(char *)str, *pe = (char *)str + strlen( str ), *eof=NULL; + + /* + variables used in state machine + */ + char *token_s=NULL, *token_e=NULL; + char *value_s=NULL, *value_e=NULL; + int token_type=0; + fprintf( outf, "#ifndef __CONFIG_H\n" ); + fprintf( outf, "#define __CONFIG_H\n" ); + + +#line 172 "kconf2h_parser.c" + { + cs = k2h_start; + } + +#line 110 "kconf2h_parser.ragel" + +#line 179 "kconf2h_parser.c" + { + int _klen; + unsigned int _trans; + const char *_acts; + unsigned int _nacts; + const char *_keys; + + if ( p == pe ) + goto _test_eof; + if ( cs == 0 ) + goto _out; +_resume: + _keys = _k2h_trans_keys + _k2h_key_offsets[cs]; + _trans = _k2h_index_offsets[cs]; + + _klen = _k2h_single_lengths[cs]; + if ( _klen > 0 ) { + const char *_lower = _keys; + const char *_mid; + const char *_upper = _keys + _klen - 1; + while (1) { + if ( _upper < _lower ) + break; + + _mid = _lower + ((_upper-_lower) >> 1); + if ( (*p) < *_mid ) + _upper = _mid - 1; + else if ( (*p) > *_mid ) + _lower = _mid + 1; + else { + _trans += (unsigned int)(_mid - _keys); + goto _match; + } + } + _keys += _klen; + _trans += _klen; + } + + _klen = _k2h_range_lengths[cs]; + if ( _klen > 0 ) { + const char *_lower = _keys; + const char *_mid; + const char *_upper = _keys + (_klen<<1) - 2; + while (1) { + if ( _upper < _lower ) + break; + + _mid = _lower + (((_upper-_lower) >> 1) & ~1); + if ( (*p) < _mid[0] ) + _upper = _mid - 2; + else if ( (*p) > _mid[1] ) + _lower = _mid + 2; + else { + _trans += (unsigned int)((_mid - _keys)>>1); + goto _match; + } + } + _trans += _klen; + } + +_match: + _trans = _k2h_indicies[_trans]; + cs = _k2h_trans_targs[_trans]; + + if ( _k2h_trans_actions[_trans] == 0 ) + goto _again; + + _acts = _k2h_actions + _k2h_trans_actions[_trans]; + _nacts = (unsigned int) *_acts++; + while ( _nacts-- > 0 ) + { + switch ( *_acts++ ) + { + case 0: +#line 72 "kconf2h_parser.ragel" + {} + break; + case 1: +#line 73 "kconf2h_parser.ragel" + {token_s = p;} + break; + case 2: +#line 73 "kconf2h_parser.ragel" + {token_e = p-1;} + break; + case 3: +#line 76 "kconf2h_parser.ragel" + {token_type=TYPE_YM;} + break; + case 4: +#line 77 "kconf2h_parser.ragel" + {token_type=TYPE_DEC;} + break; + case 5: +#line 78 "kconf2h_parser.ragel" + {token_type=TYPE_STR;} + break; + case 6: +#line 79 "kconf2h_parser.ragel" + {token_type=TYPE_HEX;} + break; + case 7: +#line 79 "kconf2h_parser.ragel" + {value_s = p;} + break; + case 8: +#line 79 "kconf2h_parser.ragel" + {value_e = p-1;} + break; + case 9: +#line 80 "kconf2h_parser.ragel" + {} + break; + case 10: +#line 80 "kconf2h_parser.ragel" + { o_head_def( outf, token_type, token_s, token_e, value_s, value_e ); } + break; + case 11: +#line 82 "kconf2h_parser.ragel" + {} + break; +#line 301 "kconf2h_parser.c" + } + } + +_again: + if ( cs == 0 ) + goto _out; + if ( ++p != pe ) + goto _resume; + _test_eof: {} + _out: {} + } + +#line 111 "kconf2h_parser.ragel" + + if ( cs == k2h_error ) + { + printf("ERR state [%d] pos[%d]:[%s]\n", res, p-str, p); + res = -1; + } + + fprintf( outf, "#endif\n" ); + + return res; +} + + + diff --git a/utils/Kconfig b/utils/Kconfig new file mode 100644 index 0000000..e69de29 --- /dev/null +++ b/utils/Kconfig |