diff --git a/src/rtl_eeprom.c b/src/rtl_eeprom.c index f562d73..ca35f67 100644 --- a/src/rtl_eeprom.c +++ b/src/rtl_eeprom.c @@ -43,8 +43,8 @@ typedef struct rtlsdr_config { char product[MAX_STR_SIZE]; char serial[MAX_STR_SIZE]; int have_serial; - int enable_ir; - int remote_wakeup; + int enable_bt; + int direct_sampling_on; } rtlsdr_config_t; void dump_config(rtlsdr_config_t *conf) @@ -57,10 +57,10 @@ void dump_config(rtlsdr_config_t *conf) fprintf(stderr, "Serial number:\t\t%s\n", conf->serial); fprintf(stderr, "Serial number enabled:\t"); fprintf(stderr, conf->have_serial ? "yes\n": "no\n"); - fprintf(stderr, "IR endpoint enabled:\t"); - fprintf(stderr, conf->enable_ir ? "yes\n": "no\n"); - fprintf(stderr, "Remote wakeup enabled:\t"); - fprintf(stderr, conf->remote_wakeup ? "yes\n": "no\n"); + fprintf(stderr, "Bias-T Always ON:\t"); + fprintf(stderr, conf->enable_bt ? "no\n": "yes\n"); // 0 is ON for this + fprintf(stderr, "Direct Sampling Always ON:\t"); + fprintf(stderr, conf->direct_sampling_on ? "yes\n": "no\n"); fprintf(stderr, "__________________________________________\n"); } @@ -74,7 +74,8 @@ void usage(void) "\t[-m set manufacturer string]\n" "\t[-p set product string]\n" "\t[-s set serial number string]\n" - "\t[-i <0,1> disable/enable IR-endpoint]\n" + "\t[-b <\"y\",\"n\"> enable/disable bias tee always ON]\n" + "\t[-q <\"y\",\"n\"> enable/disable direct sampling always ON]\n" "\t[-g generate default config and write to device]\n" "\t[ can be one of:]\n" "\t[ realtek\t\tRealtek default (as without EEPROM)]\n" @@ -139,8 +140,8 @@ int parse_eeprom_to_conf(rtlsdr_config_t *conf, uint8_t *dat) conf->vendor_id = dat[2] | (dat[3] << 8); conf->product_id = dat[4] | (dat[5] << 8); conf->have_serial = (dat[6] == 0xa5) ? 1 : 0; - conf->remote_wakeup = (dat[7] & 0x01) ? 1 : 0; - conf->enable_ir = (dat[7] & 0x02) ? 1 : 0; + conf->direct_sampling_on = (dat[7] & 0x01) ? 1 : 0; + conf->enable_bt = (dat[7] & 0x02) ? 1 : 0; pos = get_string_descriptor(STR_OFFSET, dat, conf->manufacturer); pos = get_string_descriptor(pos, dat, conf->product); @@ -161,8 +162,8 @@ int gen_eeprom_from_conf(rtlsdr_config_t *conf, uint8_t *dat) dat[5] = (conf->product_id >> 8) & 0xff; dat[6] = conf->have_serial ? 0xa5 : 0x00; dat[7] = 0x14; - dat[7] |= conf->remote_wakeup ? 0x01 : 0x00; - dat[7] |= conf->enable_ir ? 0x02 : 0x00; + dat[7] |= conf->direct_sampling_on ? 0x01 : 0x00; + dat[7] |= conf->enable_bt ? 0x02 : 0x00; dat[8] = 0x02; pos = set_string_descriptor(STR_OFFSET, dat, conf->manufacturer); @@ -194,8 +195,8 @@ void gen_default_conf(rtlsdr_config_t *conf, int config) strcpy(conf->product, "RTL2832U DVB-T"); strcpy(conf->serial, "0"); conf->have_serial = 1; - conf->enable_ir = 0; - conf->remote_wakeup = 1; + conf->enable_bt = 0; + conf->direct_sampling_on = 1; break; case REALTEK_EEPROM: fprintf(stderr, "Realtek default OEM with EEPROM\n"); @@ -205,8 +206,8 @@ void gen_default_conf(rtlsdr_config_t *conf, int config) strcpy(conf->product, "RTL2838UHIDIR"); strcpy(conf->serial, "00000001"); conf->have_serial = 1; - conf->enable_ir = 1; - conf->remote_wakeup = 0; + conf->enable_bt = 1; + conf->direct_sampling_on = 0; break; case TERRATEC_NOXON: fprintf(stderr, "Terratec NOXON DAB Stick\n"); @@ -216,8 +217,8 @@ void gen_default_conf(rtlsdr_config_t *conf, int config) strcpy(conf->product, "DAB Stick"); strcpy(conf->serial, "0"); conf->have_serial = 1; - conf->enable_ir = 0; - conf->remote_wakeup = 1; + conf->enable_bt = 0; + conf->direct_sampling_on = 1; break; case TERRATEC_T_BLACK: fprintf(stderr, "Terratec T Stick Black\n"); @@ -227,8 +228,8 @@ void gen_default_conf(rtlsdr_config_t *conf, int config) strcpy(conf->product, "RTL2838UHIDIR"); strcpy(conf->serial, "00000001"); conf->have_serial = 1; - conf->enable_ir = 1; - conf->remote_wakeup = 0; + conf->enable_bt = 1; + conf->direct_sampling_on = 0; break; case TERRATEC_T_PLUS: fprintf(stderr, "Terratec ran T Stick+\n"); @@ -238,8 +239,8 @@ void gen_default_conf(rtlsdr_config_t *conf, int config) strcpy(conf->product, "RTL2838UHIDIR"); strcpy(conf->serial, "00000001"); conf->have_serial = 1; - conf->enable_ir = 1; - conf->remote_wakeup = 0; + conf->enable_bt = 1; + conf->direct_sampling_on = 0; break; default: break; @@ -261,10 +262,11 @@ int main(int argc, char **argv) int flash_file = 0; int default_config = 0; int change = 0; - int ir_endpoint = 0; + int enable_bt = 0; + int direct_sampling_on = 0; char ch; - while ((opt = getopt(argc, argv, "d:m:p:s:i:g:w:r:h?")) != -1) { + while ((opt = getopt(argc, argv, "d:m:p:s:b:q:g:w:r:h?")) != -1) { switch (opt) { case 'd': dev_index = atoi(optarg); @@ -281,8 +283,30 @@ int main(int argc, char **argv) serial_str = optarg; change = 1; break; - case 'i': - ir_endpoint = (atoi(optarg) > 0) ? 1 : -1; + case 'b': + if(strcmp(optarg, "y") == 0) + { + enable_bt = 1; + } + else if(strcmp(optarg, "n") == 0) + { + enable_bt = -1; + } + //enable_bt = (!strcmp(optarg, "y")) ? 1 : -1; + //ir_endpoint = (atoi(optarg) > 0) ? 1 : -1; + change = 1; + break; + case 'q': + if(strcmp(optarg, "y") == 0) + { + direct_sampling_on = 1; + } + else if(strcmp(optarg, "n") == 0) + { + direct_sampling_on = -1; + } + //direct_sampling_on = (!strcmp(optarg, "y")) ? 1 : -1; + //direct_sampling_on = (atoi(optarg) > 0) ? 1 : -1; change = 1; break; case 'g': @@ -380,8 +404,11 @@ int main(int argc, char **argv) strncpy((char*)&conf.serial, serial_str, MAX_STR_SIZE); } - if (ir_endpoint != 0) - conf.enable_ir = (ir_endpoint > 0) ? 1 : 0; + if (enable_bt != 0) + conf.enable_bt = (enable_bt > 0) ? 0 : 1; + + if (direct_sampling_on != 0) + conf.direct_sampling_on = (direct_sampling_on > 0) ? 1 : 0; if (!change) goto exit;