mirror of
https://github.com/GOSTSec/sgminer
synced 2025-02-02 10:04:33 +00:00
Create a macro list of drivers to enable easier addition of further drivers.
This commit is contained in:
parent
c50b13a602
commit
8875197466
32
api.c
32
api.c
@ -1220,15 +1220,15 @@ static int numascs()
|
||||
rd_lock(&devices_lock);
|
||||
for (i = 0; i < total_devices; i++) {
|
||||
#ifdef USE_AVALON
|
||||
if (devices[i]->drv->drv_id == DRIVER_AVALON)
|
||||
if (devices[i]->drv->drv_id == DRIVER_avalon)
|
||||
count++;
|
||||
#endif
|
||||
#ifdef USE_BFLSC
|
||||
if (devices[i]->drv->drv_id == DRIVER_BFLSC)
|
||||
if (devices[i]->drv->drv_id == DRIVER_bflsc)
|
||||
count++;
|
||||
#endif
|
||||
#ifdef USE_BITFURY
|
||||
if (devices[i]->drv->drv_id == DRIVER_BITFURY)
|
||||
if (devices[i]->drv->drv_id == DRIVER_bitfury)
|
||||
count++;
|
||||
#endif
|
||||
}
|
||||
@ -1244,15 +1244,15 @@ static int ascdevice(int ascid)
|
||||
rd_lock(&devices_lock);
|
||||
for (i = 0; i < total_devices; i++) {
|
||||
#ifdef USE_AVALON
|
||||
if (devices[i]->drv->drv_id == DRIVER_AVALON)
|
||||
if (devices[i]->drv->drv_id == DRIVER_avalon)
|
||||
count++;
|
||||
#endif
|
||||
#ifdef USE_BFLSC
|
||||
if (devices[i]->drv->drv_id == DRIVER_BFLSC)
|
||||
if (devices[i]->drv->drv_id == DRIVER_bflsc)
|
||||
count++;
|
||||
#endif
|
||||
#ifdef USE_BITFURY
|
||||
if (devices[i]->drv->drv_id == DRIVER_BITFURY)
|
||||
if (devices[i]->drv->drv_id == DRIVER_bitfury)
|
||||
count++;
|
||||
#endif
|
||||
if (count == (ascid + 1))
|
||||
@ -1278,19 +1278,19 @@ static int numpgas()
|
||||
rd_lock(&devices_lock);
|
||||
for (i = 0; i < total_devices; i++) {
|
||||
#ifdef USE_BITFORCE
|
||||
if (devices[i]->drv->drv_id == DRIVER_BITFORCE)
|
||||
if (devices[i]->drv->drv_id == DRIVER_bitforce)
|
||||
count++;
|
||||
#endif
|
||||
#ifdef USE_ICARUS
|
||||
if (devices[i]->drv->drv_id == DRIVER_ICARUS)
|
||||
if (devices[i]->drv->drv_id == DRIVER_icarus)
|
||||
count++;
|
||||
#endif
|
||||
#ifdef USE_ZTEX
|
||||
if (devices[i]->drv->drv_id == DRIVER_ZTEX)
|
||||
if (devices[i]->drv->drv_id == DRIVER_ztex)
|
||||
count++;
|
||||
#endif
|
||||
#ifdef USE_MODMINER
|
||||
if (devices[i]->drv->drv_id == DRIVER_MODMINER)
|
||||
if (devices[i]->drv->drv_id == DRIVER_modminer)
|
||||
count++;
|
||||
#endif
|
||||
}
|
||||
@ -1306,19 +1306,19 @@ static int pgadevice(int pgaid)
|
||||
rd_lock(&devices_lock);
|
||||
for (i = 0; i < total_devices; i++) {
|
||||
#ifdef USE_BITFORCE
|
||||
if (devices[i]->drv->drv_id == DRIVER_BITFORCE)
|
||||
if (devices[i]->drv->drv_id == DRIVER_bitforce)
|
||||
count++;
|
||||
#endif
|
||||
#ifdef USE_ICARUS
|
||||
if (devices[i]->drv->drv_id == DRIVER_ICARUS)
|
||||
if (devices[i]->drv->drv_id == DRIVER_icarus)
|
||||
count++;
|
||||
#endif
|
||||
#ifdef USE_ZTEX
|
||||
if (devices[i]->drv->drv_id == DRIVER_ZTEX)
|
||||
if (devices[i]->drv->drv_id == DRIVER_ztex)
|
||||
count++;
|
||||
#endif
|
||||
#ifdef USE_MODMINER
|
||||
if (devices[i]->drv->drv_id == DRIVER_MODMINER)
|
||||
if (devices[i]->drv->drv_id == DRIVER_modminer)
|
||||
count++;
|
||||
#endif
|
||||
if (count == (pgaid + 1))
|
||||
@ -1770,11 +1770,11 @@ static void pgastatus(struct io_data *io_data, int pga, bool isjson, bool precom
|
||||
dev_runtime = 1.0;
|
||||
|
||||
#ifdef USE_ZTEX
|
||||
if (cgpu->drv->drv_id == DRIVER_ZTEX && cgpu->device_ztex)
|
||||
if (cgpu->drv->drv_id == DRIVER_ztex && cgpu->device_ztex)
|
||||
frequency = cgpu->device_ztex->freqM1 * (cgpu->device_ztex->freqM + 1);
|
||||
#endif
|
||||
#ifdef USE_MODMINER
|
||||
if (cgpu->drv->drv_id == DRIVER_MODMINER)
|
||||
if (cgpu->drv->drv_id == DRIVER_modminer)
|
||||
frequency = cgpu->clock;
|
||||
#endif
|
||||
|
||||
|
@ -7496,7 +7496,7 @@ void enable_device(struct cgpu_info *cgpu)
|
||||
#endif
|
||||
}
|
||||
#ifdef HAVE_OPENCL
|
||||
if (cgpu->drv->drv_id == DRIVER_OPENCL) {
|
||||
if (cgpu->drv->drv_id == DRIVER_opencl) {
|
||||
gpu_threads += cgpu->threads;
|
||||
}
|
||||
#endif
|
||||
|
@ -1600,7 +1600,7 @@ static char *avalon_set_device(struct cgpu_info *avalon, char *option, char *set
|
||||
}
|
||||
|
||||
struct device_drv avalon_drv = {
|
||||
.drv_id = DRIVER_AVALON,
|
||||
.drv_id = DRIVER_avalon,
|
||||
.dname = "avalon",
|
||||
.name = "AVA",
|
||||
.drv_detect = avalon_detect,
|
||||
|
@ -1915,7 +1915,7 @@ else a whole lot of something like these ... etc
|
||||
}
|
||||
|
||||
struct device_drv bflsc_drv = {
|
||||
.drv_id = DRIVER_BFLSC,
|
||||
.drv_id = DRIVER_bflsc,
|
||||
.dname = "BitForceSC",
|
||||
.name = BFLSC_SINGLE,
|
||||
.drv_detect = bflsc_detect,
|
||||
|
@ -742,7 +742,7 @@ static struct api_data *bitforce_api_stats(struct cgpu_info *cgpu)
|
||||
}
|
||||
|
||||
struct device_drv bitforce_drv = {
|
||||
.drv_id = DRIVER_BITFORCE,
|
||||
.drv_id = DRIVER_bitforce,
|
||||
.dname = "BitForce",
|
||||
.name = "BFL",
|
||||
.drv_detect = bitforce_detect,
|
||||
|
@ -310,7 +310,7 @@ static void bitfury_shutdown(struct thr_info *thr)
|
||||
|
||||
/* Currently hardcoded to BF1 devices */
|
||||
struct device_drv bitfury_drv = {
|
||||
.drv_id = DRIVER_BITFURY,
|
||||
.drv_id = DRIVER_bitfury,
|
||||
.dname = "bitfury",
|
||||
.name = "BF1",
|
||||
.drv_detect = bitfury_detect,
|
||||
|
@ -1210,7 +1210,7 @@ static void icarus_shutdown(__maybe_unused struct thr_info *thr)
|
||||
}
|
||||
|
||||
struct device_drv icarus_drv = {
|
||||
.drv_id = DRIVER_ICARUS,
|
||||
.drv_id = DRIVER_icarus,
|
||||
.dname = "Icarus",
|
||||
.name = "ICA",
|
||||
.drv_detect = icarus_detect,
|
||||
|
@ -1132,7 +1132,7 @@ static char *modminer_set_device(struct cgpu_info *modminer, char *option, char
|
||||
}
|
||||
|
||||
struct device_drv modminer_drv = {
|
||||
.drv_id = DRIVER_MODMINER,
|
||||
.drv_id = DRIVER_modminer,
|
||||
.dname = "ModMiner",
|
||||
.name = "MMQ",
|
||||
.drv_detect = modminer_detect,
|
||||
|
@ -753,7 +753,7 @@ retry:
|
||||
for (i = 0; i < mining_threads; ++i) {
|
||||
thr = get_thread(i);
|
||||
cgpu = thr->cgpu;
|
||||
if (cgpu->drv->drv_id != DRIVER_OPENCL)
|
||||
if (cgpu->drv->drv_id != DRIVER_opencl)
|
||||
continue;
|
||||
if (dev_from_id(i) != selected)
|
||||
continue;
|
||||
@ -1148,7 +1148,7 @@ select_cgpu:
|
||||
for (thr_id = 0; thr_id < mining_threads; ++thr_id) {
|
||||
thr = get_thread(thr_id);
|
||||
cgpu = thr->cgpu;
|
||||
if (cgpu->drv->drv_id != DRIVER_OPENCL)
|
||||
if (cgpu->drv->drv_id != DRIVER_opencl)
|
||||
continue;
|
||||
if (dev_from_id(thr_id) != gpu)
|
||||
continue;
|
||||
@ -1173,7 +1173,7 @@ select_cgpu:
|
||||
|
||||
thr = get_thread(thr_id);
|
||||
cgpu = thr->cgpu;
|
||||
if (cgpu->drv->drv_id != DRIVER_OPENCL)
|
||||
if (cgpu->drv->drv_id != DRIVER_opencl)
|
||||
continue;
|
||||
if (dev_from_id(thr_id) != gpu)
|
||||
continue;
|
||||
@ -1210,7 +1210,7 @@ select_cgpu:
|
||||
for (thr_id = 0; thr_id < mining_threads; ++thr_id) {
|
||||
thr = get_thread(thr_id);
|
||||
cgpu = thr->cgpu;
|
||||
if (cgpu->drv->drv_id != DRIVER_OPENCL)
|
||||
if (cgpu->drv->drv_id != DRIVER_opencl)
|
||||
continue;
|
||||
if (dev_from_id(thr_id) != gpu)
|
||||
continue;
|
||||
@ -1575,7 +1575,7 @@ static void opencl_thread_shutdown(struct thr_info *thr)
|
||||
}
|
||||
|
||||
struct device_drv opencl_drv = {
|
||||
.drv_id = DRIVER_OPENCL,
|
||||
.drv_id = DRIVER_opencl,
|
||||
.dname = "opencl",
|
||||
.name = "GPU",
|
||||
.drv_detect = opencl_detect,
|
||||
|
@ -413,7 +413,7 @@ static void ztex_disable(struct thr_info *thr)
|
||||
}
|
||||
|
||||
struct device_drv ztex_drv = {
|
||||
.drv_id = DRIVER_ZTEX,
|
||||
.drv_id = DRIVER_ztex,
|
||||
.dname = "ztex",
|
||||
.name = "ZTX",
|
||||
.drv_detect = ztex_detect,
|
||||
|
22
miner.h
22
miner.h
@ -230,17 +230,23 @@ static inline int fsync (int fd)
|
||||
#define MIN(x, y) ((x) > (y) ? (y) : (x))
|
||||
#define MAX(x, y) ((x) > (y) ? (x) : (y))
|
||||
|
||||
#define DRIVER_PARSE_COMMANDS \
|
||||
DRIVER_ADD_COMMAND(avalon) \
|
||||
DRIVER_ADD_COMMAND(bflsc) \
|
||||
DRIVER_ADD_COMMAND(bitforce) \
|
||||
DRIVER_ADD_COMMAND(bitfury) \
|
||||
DRIVER_ADD_COMMAND(icarus) \
|
||||
DRIVER_ADD_COMMAND(modminer) \
|
||||
DRIVER_ADD_COMMAND(opencl) \
|
||||
DRIVER_ADD_COMMAND(ztex)
|
||||
|
||||
/* Create drv_driver enum from DRIVER_PARSE_COMMANDS macro */
|
||||
#define DRIVER_ADD_COMMAND(X) DRIVER_##X,
|
||||
enum drv_driver {
|
||||
DRIVER_OPENCL = 0,
|
||||
DRIVER_ICARUS,
|
||||
DRIVER_BITFORCE,
|
||||
DRIVER_BITFURY,
|
||||
DRIVER_MODMINER,
|
||||
DRIVER_ZTEX,
|
||||
DRIVER_BFLSC,
|
||||
DRIVER_AVALON,
|
||||
DRIVER_PARSE_COMMANDS
|
||||
DRIVER_MAX
|
||||
};
|
||||
#undef DRIVER_ADD_COMMAND
|
||||
|
||||
enum alive {
|
||||
LIFE_WELL,
|
||||
|
24
usbutils.c
24
usbutils.c
@ -1899,32 +1899,32 @@ static struct usb_find_devices *usb_check(__maybe_unused struct device_drv *drv,
|
||||
}
|
||||
|
||||
#ifdef USE_BFLSC
|
||||
if (drv->drv_id == DRIVER_BFLSC)
|
||||
if (drv->drv_id == DRIVER_bflsc)
|
||||
return usb_check_each(DRV_BFLSC, drv, dev);
|
||||
#endif
|
||||
|
||||
#ifdef USE_BITFORCE
|
||||
if (drv->drv_id == DRIVER_BITFORCE)
|
||||
if (drv->drv_id == DRIVER_bitforce)
|
||||
return usb_check_each(DRV_BITFORCE, drv, dev);
|
||||
#endif
|
||||
|
||||
#ifdef USE_BITFURY
|
||||
if (drv->drv_id == DRIVER_BITFURY)
|
||||
if (drv->drv_id == DRIVER_bitfury)
|
||||
return usb_check_each(DRV_BITFURY, drv, dev);
|
||||
#endif
|
||||
|
||||
#ifdef USE_MODMINER
|
||||
if (drv->drv_id == DRIVER_MODMINER)
|
||||
if (drv->drv_id == DRIVER_modminer)
|
||||
return usb_check_each(DRV_MODMINER, drv, dev);
|
||||
#endif
|
||||
|
||||
#ifdef USE_ICARUS
|
||||
if (drv->drv_id == DRIVER_ICARUS)
|
||||
if (drv->drv_id == DRIVER_icarus)
|
||||
return usb_check_each(DRV_ICARUS, drv, dev);
|
||||
#endif
|
||||
|
||||
#ifdef USE_AVALON
|
||||
if (drv->drv_id == DRIVER_AVALON)
|
||||
if (drv->drv_id == DRIVER_avalon)
|
||||
return usb_check_each(DRV_AVALON, drv, dev);
|
||||
#endif
|
||||
|
||||
@ -3151,12 +3151,12 @@ void usb_cleanup()
|
||||
for (i = 0; i < total_devices; i++) {
|
||||
cgpu = devices[i];
|
||||
switch (cgpu->drv->drv_id) {
|
||||
case DRIVER_BFLSC:
|
||||
case DRIVER_BITFORCE:
|
||||
case DRIVER_BITFURY:
|
||||
case DRIVER_MODMINER:
|
||||
case DRIVER_ICARUS:
|
||||
case DRIVER_AVALON:
|
||||
case DRIVER_bflsc:
|
||||
case DRIVER_bitforce:
|
||||
case DRIVER_bitfury:
|
||||
case DRIVER_modminer:
|
||||
case DRIVER_icarus:
|
||||
case DRIVER_avalon:
|
||||
wr_lock(cgpu->usbinfo.devlock);
|
||||
release_cgpu(cgpu);
|
||||
wr_unlock(cgpu->usbinfo.devlock);
|
||||
|
Loading…
x
Reference in New Issue
Block a user