From ccd8727801227f93df9ffcf70a7c437f6133204f Mon Sep 17 00:00:00 2001 From: Steve Markgraf Date: Sun, 15 Dec 2024 01:05:38 +0100 Subject: [PATCH] remove some stale code --- include/hsdaoh.h | 19 ------------------- include/hsdaoh_i2c.h | 7 ------- src/hsdaoh_file.c | 14 +------------- src/hsdaoh_tcp.c | 33 +-------------------------------- src/hsdaoh_test.c | 10 ++++------ src/libhsdaoh.c | 39 --------------------------------------- 6 files changed, 6 insertions(+), 116 deletions(-) delete mode 100644 include/hsdaoh_i2c.h diff --git a/include/hsdaoh.h b/include/hsdaoh.h index dd7037d..d3ad647 100644 --- a/include/hsdaoh.h +++ b/include/hsdaoh.h @@ -87,25 +87,6 @@ HSDAOH_API int hsdaoh_close(hsdaoh_dev_t *dev); HSDAOH_API int hsdaoh_get_usb_strings(hsdaoh_dev_t *dev, char *manufact, char *product, char *serial); -/*! - * Set the sample rate for the device - * - * \param dev the device handle given by hsdaoh_open() - * \param samp_rate the sample rate to be set - * \param ext_clock if true, use the IFCLK input insteafd of internal clock source - * if a Si5351 is connected, it will be configured - * \return 0 on success, -EINVAL on invalid rate - */ -HSDAOH_API int hsdaoh_set_sample_rate(hsdaoh_dev_t *dev, uint32_t rate, bool ext_clock); - -/*! - * Get actual sample rate the device is configured to. - * - * \param dev the device handle given by hsdaoh_open() - * \return 0 on error, sample rate in Hz otherwise - */ -HSDAOH_API uint32_t hsdaoh_get_sample_rate(hsdaoh_dev_t *dev); - /* streaming functions */ typedef void(*hsdaoh_read_cb_t)(unsigned char *buf, uint32_t len, void *ctx); diff --git a/include/hsdaoh_i2c.h b/include/hsdaoh_i2c.h deleted file mode 100644 index 89d8193..0000000 --- a/include/hsdaoh_i2c.h +++ /dev/null @@ -1,7 +0,0 @@ -#ifndef __I2C_H -#define __I2C_H - -int hsdaoh_i2c_write_fn(void *dev, uint8_t i2c_addr, uint8_t *buffer, uint16_t len); -int hsdaoh_i2c_read_fn(void *dev, uint8_t i2c_addr, uint8_t *buffer, uint16_t len); - -#endif diff --git a/src/hsdaoh_file.c b/src/hsdaoh_file.c index c56ae9a..cf27cf2 100644 --- a/src/hsdaoh_file.c +++ b/src/hsdaoh_file.c @@ -37,8 +37,6 @@ #include "hsdaoh.h" -#define DEFAULT_SAMPLE_RATE 30000000 - static int do_exit = 0; static uint32_t bytes_to_read = 0; static hsdaoh_dev_t *dev = NULL; @@ -48,7 +46,6 @@ void usage(void) fprintf(stderr, "hsdaoh_file, HDMI data acquisition tool\n\n" "Usage:\n" - "\t[-s samplerate (default: 30 MHz)]\n" "\t[-d device_index (default: 0)]\n" "\t[-p ppm_error (default: 0)]\n" "\t[-n number of samples to read (default: 0, infinite)]\n" @@ -119,16 +116,12 @@ int main(int argc, char **argv) int ppm_error = 0; FILE *file; int dev_index = 0; - uint32_t samp_rate = DEFAULT_SAMPLE_RATE; - while ((opt = getopt(argc, argv, "d:s:n:p:d:")) != -1) { + while ((opt = getopt(argc, argv, "d:n:p:d:")) != -1) { switch (opt) { case 'd': dev_index = (uint32_t)atoi(optarg); break; - case 's': - samp_rate = (uint32_t)atof(optarg); - break; case 'p': ppm_error = atoi(optarg); break; @@ -168,11 +161,6 @@ int main(int argc, char **argv) SetConsoleCtrlHandler( (PHANDLER_ROUTINE) sighandler, TRUE ); #endif - /* Set the sample rate */ - r = hsdaoh_set_sample_rate(dev, samp_rate, 0); - if (r < 0) - fprintf(stderr, "WARNING: Failed to set sample rate.\n"); - if (strcmp(filename, "-") == 0) { /* Write samples to stdout */ file = stdout; #ifdef _WIN32 diff --git a/src/hsdaoh_tcp.c b/src/hsdaoh_tcp.c index 16a96c8..900c80b 100644 --- a/src/hsdaoh_tcp.c +++ b/src/hsdaoh_tcp.c @@ -60,7 +60,6 @@ typedef int socklen_t; #endif #define DEFAULT_PORT_STR "1234" -#define DEFAULT_SAMPLE_RATE_HZ 30000000 #define DEFAULT_MAX_NUM_BUFFERS 500 static SOCKET s; @@ -102,7 +101,6 @@ void usage(void) fprintf(stderr, "\t[-b number of buffers (default: 15, set by library)]\n"); fprintf(stderr, "\t[-n max number of linked list buffers to keep (default: %d)]\n", DEFAULT_MAX_NUM_BUFFERS); fprintf(stderr, "\t[-d device index (default: 0)]\n"); - fprintf(stderr, "\t[-P ppm_error (default: 0)]\n"); exit(1); } @@ -291,25 +289,6 @@ static void *command_worker(void *arg) pthread_exit(NULL); } } - switch(cmd.cmd) { - case 0x01: - break; - case 0x02: - fprintf(stderr, "set sample rate %d\n", ntohl(cmd.param)); - hsdaoh_set_sample_rate(dev, ntohl(cmd.param), false); - break; - case 0x03: - fprintf(stderr, "set gain mode %d\n", ntohl(cmd.param)); - //hsdaoh_set_tuner_gain_mode(dev, ntohl(cmd.param)); - break; - case 0x04: - fprintf(stderr, "set gain %d\n", ntohl(cmd.param)); - // hsdaoh_set_tuner_gain(dev, ntohl(cmd.param)); - break; - default: - break; - } - cmd.cmd = 0xff; } } @@ -318,7 +297,6 @@ int main(int argc, char **argv) int r, opt, i; char *addr = "127.0.0.1"; const char *port = DEFAULT_PORT_STR; - uint32_t frequency = 100000000, samp_rate = DEFAULT_SAMPLE_RATE_HZ; struct sockaddr_storage local, remote; struct addrinfo *ai; struct addrinfo *aiHead; @@ -330,7 +308,6 @@ int main(int argc, char **argv) int aiErr; uint32_t buf_num = 0; int dev_index = 0; - int ppm_error = 0; struct llist *curelem,*prev; pthread_attr_t attr; void *status; @@ -349,14 +326,11 @@ int main(int argc, char **argv) struct sigaction sigact, sigign; #endif - while ((opt = getopt(argc, argv, "a:p:s:v:b:n:d:e")) != -1) { + while ((opt = getopt(argc, argv, "a:p:b:n:d")) != -1) { switch (opt) { case 'd': dev_index = (uint32_t)atoi(optarg); break; - case 's': - samp_rate = (uint32_t)atof(optarg); - break; case 'a': addr = strdup(optarg); break; @@ -401,11 +375,6 @@ int main(int argc, char **argv) SetConsoleCtrlHandler( (PHANDLER_ROUTINE) sighandler, TRUE ); #endif - /* Set the sample rate */ - r = hsdaoh_set_sample_rate(dev, samp_rate, false); - if (r < 0) - fprintf(stderr, "WARNING: Failed to set sample rate.\n"); - pthread_mutex_init(&exit_cond_lock, NULL); pthread_mutex_init(&ll_mutex, NULL); pthread_mutex_init(&exit_cond_lock, NULL); diff --git a/src/hsdaoh_test.c b/src/hsdaoh_test.c index a7145b3..802d95e 100644 --- a/src/hsdaoh_test.c +++ b/src/hsdaoh_test.c @@ -86,6 +86,7 @@ void usage(void) "hsdaoh_test, a test tool for hsdaoh\n\n" "Usage:\n" "\t[-d device_index (default: 0)]\n" + "\t[-s expected samplerate (default: 30 MHz)]\n" "\t[-p[seconds] enable PPM error measurement (default: 10 seconds)]\n"); exit(1); } @@ -244,7 +245,7 @@ int main(int argc, char **argv) int n_read, r, opt, i; int dev_index = 0; - while ((opt = getopt(argc, argv, "d:s:p:he")) != -1) { + while ((opt = getopt(argc, argv, "d:s:p:h")) != -1) { switch (opt) { case 'd': dev_index = (uint32_t)atoi(optarg); @@ -263,9 +264,8 @@ int main(int argc, char **argv) } } - if (dev_index < 0) { + if (dev_index < 0) exit(1); - } r = hsdaoh_open(&dev, (uint32_t)dev_index); if (r < 0) { @@ -289,10 +289,8 @@ int main(int argc, char **argv) r = hsdaoh_start_stream(dev, hsdaoh_callback, NULL); - - while (!do_exit) { + while (!do_exit) usleep(50000); - } if (do_exit) fprintf(stderr, "\nUser cancel, exiting...\n"); diff --git a/src/libhsdaoh.c b/src/libhsdaoh.c index 9c333e7..5cb13bf 100644 --- a/src/libhsdaoh.c +++ b/src/libhsdaoh.c @@ -42,20 +42,9 @@ #include #include #include -#include #include #include -/* - * All libusb callback functions should be marked with the LIBUSB_CALL macro - * to ensure that they are compiled with the same calling convention as libusb. - * - * If the macro isn't available in older libusb versions, we simply define it. - */ -#ifndef LIBUSB_CALL -#define LIBUSB_CALL -#endif - enum hsdaoh_async_status { HSDAOH_INACTIVE = 0, HSDAOH_CANCELING, @@ -77,8 +66,6 @@ struct hsdaoh_dev { uvc_device_t *uvc_dev; uvc_device_handle_t *uvc_devh; - uint32_t rate; /* Hz */ - int hid_interface; uint8_t edid_seq_cnt; @@ -245,18 +232,6 @@ void hsdaoh_ms_enable_transparent_mode(hsdaoh_dev_t *dev) hsdaoh_ms_write_register(dev, 0xf600, 0x80); } -int hsdaoh_i2c_write_fn(void *dev, uint8_t addr, uint8_t *buf, uint16_t len) -{ - - return -1; -} - -int hsdaoh_i2c_read_fn(void *dev, uint8_t addr, uint8_t *buf, uint16_t len) -{ - - return -1; -} - int hsdaoh_get_usb_strings(hsdaoh_dev_t *dev, char *manufact, char *product, char *serial) { @@ -298,19 +273,6 @@ int hsdaoh_get_usb_strings(hsdaoh_dev_t *dev, char *manufact, char *product, return 0; } -int hsdaoh_set_sample_rate(hsdaoh_dev_t *dev, uint32_t samp_rate, bool ext_clock) -{ - return 0; -} - -uint32_t hsdaoh_get_sample_rate(hsdaoh_dev_t *dev) -{ - if (!dev) - return 0; - - return dev->rate; -} - static hsdaoh_adapter_t *find_known_device(uint16_t vid, uint16_t pid) { unsigned int i; @@ -550,7 +512,6 @@ int hsdaoh_open(hsdaoh_dev_t **out_dev, uint32_t index) if (hsdaoh_clear_endpoint_halt(dev) < 0) goto err; - //dev->rate = DEFAULT_SAMPLERATE; dev->dev_lost = 0; found: