From dc85abd9cd0de732b0373baffad728b509c5680a Mon Sep 17 00:00:00 2001 From: Kano Date: Thu, 3 Oct 2013 23:19:18 +1000 Subject: [PATCH] Klondike update code to current git --- Makefile.am | 4 ++++ cgminer.c | 24 ++++++++++++++++++++++++ configure.ac | 23 ++++++++++++++++++++--- driver-klondike.c | 7 +++---- miner.h | 6 +++++- usbutils.c | 26 ++++++++++++++++++++++++++ usbutils.h | 1 + 7 files changed, 83 insertions(+), 8 deletions(-) diff --git a/Makefile.am b/Makefile.am index 2389d670..ae6b8293 100644 --- a/Makefile.am +++ b/Makefile.am @@ -88,6 +88,10 @@ if HAS_AVALON cgminer_SOURCES += driver-avalon.c driver-avalon.h endif +if HAS_KLONDIKE +cgminer_SOURCES += driver-klondike.c +endif + if HAS_MODMINER cgminer_SOURCES += driver-modminer.c bitstreamsdir = $(bindir)/bitstreams diff --git a/cgminer.c b/cgminer.c index 337722a7..7f136cd8 100644 --- a/cgminer.c +++ b/cgminer.c @@ -166,6 +166,9 @@ bool opt_worktime; #ifdef USE_AVALON char *opt_avalon_options = NULL; #endif +#ifdef USE_KLONDIKE +char *opt_klondike_options = NULL; +#endif #ifdef USE_USBUTILS char *opt_usb_select = NULL; int opt_usbdump = -1; @@ -1026,6 +1029,15 @@ static char *set_avalon_options(const char *arg) } #endif +#ifdef USE_KLONDIKE +static char *set_klondike_options(const char *arg) +{ + opt_set_charp(arg, &opt_klondike_options); + + return NULL; +} +#endif + #ifdef USE_USBUTILS static char *set_usb_select(const char *arg) { @@ -1231,6 +1243,11 @@ static struct opt_table opt_config_table[] = { OPT_WITH_ARG("--bitburner-voltage", opt_set_intval, NULL, &opt_bitburner_core_voltage, "Set BitBurner core voltage, in millivolts"), +#endif +#ifdef USE_KLONDIKE + OPT_WITH_ARG("--klondike-options", + set_klondike_options, NULL, NULL, + "Set klondike options clock:temp1:temp2:fan"), #endif OPT_WITHOUT_ARG("--load-balance", set_loadbalance, &pool_strategy, @@ -1572,6 +1589,9 @@ static char *opt_verusage_and_exit(const char *extra) #ifdef USE_ICARUS "icarus " #endif +#ifdef USE_KLONDIKE + "klondike " +#endif #ifdef USE_MODMINER "modminer " #endif @@ -4430,6 +4450,10 @@ void write_config(FILE *fcfg) fprintf(fcfg, ",\n\"icarus-options\" : \"%s\"", json_escape(opt_icarus_options)); if (opt_icarus_timing) fprintf(fcfg, ",\n\"icarus-timing\" : \"%s\"", json_escape(opt_icarus_timing)); +#ifdef USE_KLONDIKE + if (opt_klondike_options) + fprintf(fcfg, ",\n\"klondike-options\" : \"%s\"", json_escape(opt_icarus_options)); +#endif #ifdef USE_USBUTILS if (opt_usb_select) fprintf(fcfg, ",\n\"usb\" : \"%s\"", json_escape(opt_usb_select)); diff --git a/configure.ac b/configure.ac index 95795bc5..9781f9df 100644 --- a/configure.ac +++ b/configure.ac @@ -275,6 +275,17 @@ if test "x$avalon" = xyes; then fi AM_CONDITIONAL([HAS_AVALON], [test x$avalon = xyes]) +klondike="no" + +AC_ARG_ENABLE([klondike], + [AC_HELP_STRING([--enable-klondike],[Compile support for Klondike (default disabled)])], + [klondike=$enableval] + ) +if test "x$klondike" = xyes; then + AC_DEFINE([USE_KLONDIKE], [1], [Defined to 1 if Klondike support is wanted]) +fi +AM_CONDITIONAL([HAS_KLONDIKE], [test x$klondike = xyes]) + modminer="no" AC_ARG_ENABLE([modminer], @@ -321,7 +332,7 @@ else ]) fi -if test x$avalon$bitforce$bitfury$modminer$bflsc$icarus != xnononononono; then +if test x$avalon$bitforce$bitfury$modminer$bflsc$icarus$klondike != xnonononononono; then want_usbutils=true else want_usbutils=false @@ -493,14 +504,14 @@ if test "x$opencl" != xno; then else echo " OpenCL...............: NOT FOUND. GPU mining support DISABLED" - if test "x$avalon$bitforce$bitfury$icarus$ztex$modminer$bflsc" = xnonononononono; then + if test "x$avalon$bitforce$bitfury$icarus$ztex$modminer$bflsc$klondike" = xnononononononono; then AC_MSG_ERROR([No mining configured in]) fi echo " scrypt...............: Disabled (needs OpenCL)" fi else echo " OpenCL...............: Detection overrided. GPU mining support DISABLED" - if test "x$avalon$bitforce$bitfury$icarus$ztex$modminer$bflsc" = xnonononononono; then + if test "x$avalon$bitforce$bitfury$icarus$ztex$modminer$bflsc$klondike" = xnononononononono; then AC_MSG_ERROR([No mining configured in]) fi echo " scrypt...............: Disabled (needs OpenCL)" @@ -547,6 +558,12 @@ else echo " Icarus.FPGAs.........: Disabled" fi +if test "x$klondike" = xyes; then + echo " Klondike.ASICs.......: Enabled" +else + echo " Klondike.ASICs.......: Disabled" +fi + if test "x$modminer" = xyes; then echo " ModMiner.FPGAs.......: Enabled" else diff --git a/driver-klondike.c b/driver-klondike.c index 27e0196b..8480d949 100644 --- a/driver-klondike.c +++ b/driver-klondike.c @@ -29,7 +29,6 @@ #include "miner.h" #include "usbutils.h" -#define KLN "KLN" #define K1 "K1" #define K16 "K16" #define K64 "K64" @@ -295,7 +294,7 @@ static bool klondike_detect_one(struct libusb_device *dev, struct usb_find_devic return false; } -static void klondike_detect(void) +static void klondike_detect(bool __maybe_unused hotplug) { usb_detect(&klondike_drv, klondike_detect_one); } @@ -602,9 +601,9 @@ static struct api_data *klondike_api_stats(struct cgpu_info *klncgpu) } struct device_drv klondike_drv = { - .drv_id = DRIVER_KLONDIKE, + .drv_id = DRIVER_klondike, .dname = "Klondike", - .name = KLN, + .name = "KLN", .drv_detect = klondike_detect, .get_api_stats = klondike_api_stats, .get_statline_before = get_klondike_statline_before, diff --git a/miner.h b/miner.h index 7bafed01..6dab8366 100644 --- a/miner.h +++ b/miner.h @@ -243,7 +243,8 @@ static inline int fsync (int fd) #define ASIC_PARSE_COMMANDS(DRIVER_ADD_COMMAND) \ DRIVER_ADD_COMMAND(bflsc) \ DRIVER_ADD_COMMAND(bitfury) \ - DRIVER_ADD_COMMAND(avalon) + DRIVER_ADD_COMMAND(avalon) \ + DRIVER_ADD_COMMAND(klondike) #define DRIVER_PARSE_COMMANDS(DRIVER_ADD_COMMAND) \ DRIVER_ADD_COMMAND(opencl) \ @@ -943,6 +944,9 @@ extern bool opt_worktime; #ifdef USE_AVALON extern char *opt_avalon_options; #endif +#ifdef USE_KLONDIKE +extern char *opt_klondike_options; +#endif #ifdef USE_USBUTILS extern char *opt_usb_select; extern int opt_usbdump; diff --git a/usbutils.c b/usbutils.c index 40bef6a0..e2fa88b9 100644 --- a/usbutils.c +++ b/usbutils.c @@ -50,6 +50,7 @@ #define BITFURY_TIMEOUT_MS 999 #define MODMINER_TIMEOUT_MS 999 #define AVALON_TIMEOUT_MS 999 +#define KLONDIKE_TIMEOUT_MS 999 #define ICARUS_TIMEOUT_MS 999 #else #define BFLSC_TIMEOUT_MS 300 @@ -57,6 +58,7 @@ #define BITFURY_TIMEOUT_MS 100 #define MODMINER_TIMEOUT_MS 100 #define AVALON_TIMEOUT_MS 200 +#define KLONDIKE_TIMEOUT_MS 200 #define ICARUS_TIMEOUT_MS 200 #endif @@ -139,6 +141,17 @@ static struct usb_intinfo ava_ints[] = { }; #endif +#ifdef USE_KLONDIKE +static struct usb_epinfo kln_epinfos[] = { + { LIBUSB_TRANSFER_TYPE_BULK, 64, EPI(1), 0, 0, 0 }, + { LIBUSB_TRANSFER_TYPE_BULK, 64, EPO(1), 0, 0, 0 } +}; + +static struct usb_intinfo kln_ints[] = { + USB_EPS(0, kln_epinfos) +}; +#endif + #ifdef USE_ICARUS static struct usb_epinfo ica_epinfos[] = { { LIBUSB_TRANSFER_TYPE_BULK, 64, EPI(3), 0, 0, 0 }, @@ -292,6 +305,18 @@ static struct usb_find_devices find_dev[] = { .latency = 10, INTINFO(ava_ints) }, #endif +#ifdef USE_KLONDIKE + { + .drv = DRIVER_klondike, + .name = "KLN", + .ident = IDENT_KLN, + .idVendor = 0x04D8, + .idProduct = 0xF60A, + .config = 1, + .timeout = KLONDIKE_TIMEOUT_MS, + .latency = 10, + INTINFO(kln_ints) }, +#endif #ifdef USE_ICARUS { .drv = DRIVER_icarus, @@ -3103,6 +3128,7 @@ void usb_cleanup() case DRIVER_modminer: case DRIVER_icarus: case DRIVER_avalon: + case DRIVER_klondike: mutex_lock(cgpu->usbinfo.devlock); release_cgpu(cgpu); mutex_unlock(cgpu->usbinfo.devlock); diff --git a/usbutils.h b/usbutils.h index 457381d0..7b499eeb 100644 --- a/usbutils.h +++ b/usbutils.h @@ -144,6 +144,7 @@ enum sub_ident { IDENT_MMQ, IDENT_AVA, IDENT_BTB, + IDENT_KLN, IDENT_ICA, IDENT_AMU, IDENT_BLT,