Browse Source

CGPU API for device names

Luke Dashjr 14 years ago
parent
commit
f05a319e01
5 changed files with 18 additions and 1 deletions
  1. 3 0
      adl.c
  2. 5 1
      cgminer.c
  3. 7 0
      driver-bitforce.c
  4. 2 0
      driver-opencl.c
  5. 1 0
      miner.h

+ 3 - 0
adl.c

@@ -340,6 +340,9 @@ void init_adl(int nDevs)
 		}
 
 		applog(LOG_INFO, "GPU %d %s hardware monitoring enabled", gpu, lpInfo[i].strAdapterName);
+		if (gpus[gpu].name)
+			free(gpus[gpu].name);
+		gpus[gpu].name = lpInfo[i].strAdapterName;
 		gpus[gpu].has_adl = true;
 		/* Flag adl as active if any card is successfully activated */
 		adl_active = true;

+ 5 - 1
cgminer.c

@@ -4455,7 +4455,11 @@ int main (int argc, char *argv[])
 	if (devices_enabled == -1) {
 		applog(LOG_ERR, "Devices detected:");
 		for (i = 0; i < total_devices; ++i) {
-			applog(LOG_ERR, " %2d. %s%d (driver: %s)", i, devices[i]->api->name, devices[i]->device_id, devices[i]->api->dname);
+			struct cgpu_info *cgpu = devices[i];
+			if (cgpu->name)
+				applog(LOG_ERR, " %2d. %s %d: %s (driver: %s)", i, cgpu->api->name, cgpu->device_id, cgpu->name, cgpu->api->dname);
+			else
+				applog(LOG_ERR, " %2d. %s %d (driver: %s)", i, cgpu->api->name, cgpu->device_id, cgpu->api->dname);
 		}
 		quit(0, "%d devices listed", total_devices);
 	}

+ 7 - 0
driver-bitforce.c

@@ -91,6 +91,7 @@ static void BFwrite(int fd, const void *buf, ssize_t bufLen)
 
 static bool bitforce_detect_one(const char *devpath)
 {
+	char *s;
 	char pdevbuf[0x100];
 
 	if (total_devices == MAX_DEVICES)
@@ -120,6 +121,12 @@ static bool bitforce_detect_one(const char *devpath)
 	bitforce->device_path = strdup(devpath);
 	bitforce->deven = DEV_ENABLED;
 	bitforce->threads = 1;
+	if (likely((!memcmp(pdevbuf, ">>>ID: ", 7)) && (s = strstr(pdevbuf + 3, ">>>"))))
+	{
+		s[0] = '\0';
+		bitforce->name = strdup(pdevbuf + 7);
+	}
+
 	return add_cgpu(bitforce);
 }
 

+ 2 - 0
driver-opencl.c

@@ -1188,6 +1188,8 @@ static bool opencl_thread_prepare(struct thr_info *thr)
 		cgpu->status = LIFE_NOSTART;
 		return false;
 	}
+	if (name && !cgpu->name)
+		cgpu->name = strdup(name);
 	applog(LOG_INFO, "initCl() finished. Found %s", name);
 	gettimeofday(&now, NULL);
 	get_datestamp(cgpu->init, &now);

+ 1 - 0
miner.h

@@ -226,6 +226,7 @@ struct cgpu_info {
 	int cgminer_id;
 	struct device_api *api;
 	int device_id;
+	char *name;
 	char *device_path;
 	FILE *device_file;
 	int device_fd;