Browse Source

Merge pull request #404 from kanoi/bflsc

cgminer -n to include a USB device list
nfactor-troky
Con Kolivas 12 years ago
parent
commit
e9a9a51547
  1. 27
      cgminer.c
  2. 3
      driver-opencl.c
  3. 2
      driver-opencl.h
  4. 12
      usbutils.c
  5. 1
      usbutils.h

27
cgminer.c

@ -1366,6 +1366,20 @@ static char *opt_verusage_and_exit(const char *extra) @@ -1366,6 +1366,20 @@ static char *opt_verusage_and_exit(const char *extra)
exit(0);
}
#if defined(HAVE_OPENCL) || defined(USE_USBUTILS)
char *display_devs(int *ndevs)
{
*ndevs = 0;
#ifdef HAVE_OPENCL
print_ndevs(ndevs);
#endif
#ifdef USE_USBUTILS
usb_all(0);
#endif
exit(*ndevs);
}
#endif
/* These options are available from commandline only */
static struct opt_table opt_cmdline_table[] = {
OPT_WITH_ARG("--config|-c",
@ -1379,10 +1393,17 @@ static struct opt_table opt_cmdline_table[] = { @@ -1379,10 +1393,17 @@ static struct opt_table opt_cmdline_table[] = {
OPT_WITHOUT_ARG("--help|-h",
opt_verusage_and_exit, NULL,
"Print this message"),
#ifdef HAVE_OPENCL
#if defined(HAVE_OPENCL) || defined(USE_USBUTILS)
OPT_WITHOUT_ARG("--ndevs|-n",
print_ndevs_and_exit, &nDevs,
"Display number of detected GPUs, OpenCL platform information, and exit"),
display_devs, &nDevs,
"Display "
#ifdef HAVE_OPENCL
"number of detected GPUs, OpenCL platform information, "
#endif
#ifdef USE_USBUTILS
"all USB devices, "
#endif
"and exit"),
#endif
OPT_WITHOUT_ARG("--version|-V",
opt_version_and_exit, packagename,

3
driver-opencl.c

@ -592,13 +592,12 @@ char *set_intensity(char *arg) @@ -592,13 +592,12 @@ char *set_intensity(char *arg)
return NULL;
}
char *print_ndevs_and_exit(int *ndevs)
void print_ndevs(int *ndevs)
{
opt_log_output = true;
opencl_drv.drv_detect();
clear_adl(*ndevs);
applog(LOG_INFO, "%i GPU devices max detected", *ndevs);
exit(*ndevs);
}
#endif

2
driver-opencl.h

@ -4,7 +4,7 @@ @@ -4,7 +4,7 @@
#include "miner.h"
extern char *print_ndevs_and_exit(int *ndevs);
extern void print_ndevs(int *ndevs);
extern void *reinit_gpu(void *userdata);
extern char *set_gpu_map(char *arg);
extern char *set_gpu_engine(char *arg);

12
usbutils.c

@ -411,7 +411,7 @@ static bool setgetdes(ssize_t count, libusb_device *dev, struct libusb_device_ha @@ -411,7 +411,7 @@ static bool setgetdes(ssize_t count, libusb_device *dev, struct libusb_device_ha
return true;
}
static void usb_full(ssize_t count, libusb_device *dev, char **buf, size_t *off, size_t *len)
static void usb_full(ssize_t count, libusb_device *dev, char **buf, size_t *off, size_t *len, int level)
{
struct libusb_device_descriptor desc;
uint8_t bus_number;
@ -437,7 +437,7 @@ static void usb_full(ssize_t count, libusb_device *dev, char **buf, size_t *off, @@ -437,7 +437,7 @@ static void usb_full(ssize_t count, libusb_device *dev, char **buf, size_t *off,
bus_number = libusb_get_bus_number(dev);
device_address = libusb_get_device_address(dev);
if (opt_usbdump == 0) {
if (level == 0) {
sprintf(tmp, EOL ".USB dev %d: Bus %d Device %d ID: %04x:%04x",
(int)count, (int)bus_number, (int)device_address,
desc.idVendor, desc.idProduct);
@ -471,7 +471,7 @@ static void usb_full(ssize_t count, libusb_device *dev, char **buf, size_t *off, @@ -471,7 +471,7 @@ static void usb_full(ssize_t count, libusb_device *dev, char **buf, size_t *off,
if (err < 0)
sprintf((char *)prod, "** err(%d)", err);
if (opt_usbdump == 0) {
if (level == 0) {
libusb_close(handle);
sprintf(tmp, EOL " Manufacturer: '%s'" EOL " Product: '%s'", man, prod);
append(buf, tmp, off, len);
@ -556,7 +556,7 @@ static void usb_full(ssize_t count, libusb_device *dev, char **buf, size_t *off, @@ -556,7 +556,7 @@ static void usb_full(ssize_t count, libusb_device *dev, char **buf, size_t *off,
}
// Function to dump all USB devices
static void usb_all()
void usb_all(int level)
{
libusb_device **list;
ssize_t count, i;
@ -581,7 +581,7 @@ static void usb_all() @@ -581,7 +581,7 @@ static void usb_all()
off = strlen(buf);
for (i = 0; i < count; i++)
usb_full(i, list[i], &buf, &off, &len);
usb_full(i, list[i], &buf, &off, &len, level);
applog(LOG_WARNING, "%s", buf);
@ -599,7 +599,7 @@ static void cgusb_check_init() @@ -599,7 +599,7 @@ static void cgusb_check_init()
// N.B. environment LIBUSB_DEBUG also sets libusb_set_debug()
if (opt_usbdump >= 0) {
libusb_set_debug(NULL, opt_usbdump);
usb_all();
usb_all(opt_usbdump);
}
usb_commands = malloc(sizeof(*usb_commands) * C_MAX);

1
usbutils.h

@ -129,6 +129,7 @@ enum usb_cmds { @@ -129,6 +129,7 @@ enum usb_cmds {
struct device_drv;
struct cgpu_info;
void usb_all(int level);
void usb_uninit(struct cgpu_info *cgpu);
bool usb_init(struct cgpu_info *cgpu, struct libusb_device *dev, struct usb_find_devices *found);
void usb_detect(struct device_drv *drv, bool (*device_detect)(struct libusb_device *, struct usb_find_devices *));

Loading…
Cancel
Save