Browse Source

Merge pull request #505 from nwoolls/task/refactor-gridseed-terms

gridseed: Refactor to clarify GridSeed terminology
Luke-Jr 11 years ago
parent
commit
db5f9a6e15
4 changed files with 42 additions and 51 deletions
  1. 2 2
      driver-dualminer.c
  2. 12 12
      driver-gridseed.c
  3. 23 27
      gc3355.c
  4. 5 10
      gc3355.h

+ 2 - 2
driver-dualminer.c

@@ -124,7 +124,7 @@ void dualminer_init_firstrun(struct cgpu_info *icarus)
 {
 	int fd = icarus->device_fd;
 
-	gc3355_init_usbstick(fd, opt_pll_freq, !opt_dual_mode, false);
+	gc3355_init_dualminer(fd, opt_pll_freq, !opt_dual_mode, false);
 	
 	dualminer_init_hashrate(icarus);
 
@@ -168,7 +168,7 @@ bool dualminer_detect_init(const char *devpath, int fd, struct ICARUS_INFO * __m
 {
 	dualminer_set_defaults(fd);
 	
-	gc3355_init_usbstick(fd, opt_pll_freq, !opt_dual_mode, true);
+	gc3355_init_dualminer(fd, opt_pll_freq, !opt_dual_mode, true);
 
 	return true;
 }

+ 12 - 12
driver-gridseed.c

@@ -33,7 +33,7 @@ static const struct bfg_set_device_definition gridseed_set_device_funcs_live[];
  */
 
 static
-struct cgpu_info *gridseed_alloc_device(const char *path, struct device_drv *driver, struct gc3355_orb_info *info)
+struct cgpu_info *gridseed_alloc_device(const char *path, struct device_drv *driver, struct gc3355_info *info)
 {
 	struct cgpu_info *device = calloc(1, sizeof(struct cgpu_info));
 	if (unlikely(!device))
@@ -50,11 +50,11 @@ struct cgpu_info *gridseed_alloc_device(const char *path, struct device_drv *dri
 }
 
 static
-struct gc3355_orb_info *gridseed_alloc_info()
+struct gc3355_info *gridseed_alloc_info()
 {
-	struct gc3355_orb_info *info = calloc(1, sizeof(struct gc3355_orb_info));
+	struct gc3355_info *info = calloc(1, sizeof(struct gc3355_info));
 	if (unlikely(!info))
-		quit(1, "Failed to malloc gc3355_orb_info");
+		quit(1, "Failed to malloc gc3355_info");
 	
 	info->freq = GRIDSEED_DEFAULT_FREQUENCY;
 	
@@ -73,7 +73,7 @@ void gridseed_empty_work(int fd)
  */
 
 static
-bool gridseed_detect_custom(const char *path, struct device_drv *driver, struct gc3355_orb_info *info)
+bool gridseed_detect_custom(const char *path, struct device_drv *driver, struct gc3355_info *info)
 {
 	int fd = gc3355_open(path);
 	if(fd < 0)
@@ -107,7 +107,7 @@ bool gridseed_detect_custom(const char *path, struct device_drv *driver, struct
 	if (!add_cgpu(device))
 		return false;
 	
-	gc3355_init_usborb(device->device_fd, info->freq, false, false);
+	gc3355_init_miner(device->device_fd, info->freq);
 	
 	applog(LOG_INFO, "Found %"PRIpreprv" at %s", device->proc_repr, path);
 	applog(LOG_DEBUG, "%"PRIpreprv": Init: firmware=%"PRId64", chips=%d", device->proc_repr, fw_version, info->chips);
@@ -118,7 +118,7 @@ bool gridseed_detect_custom(const char *path, struct device_drv *driver, struct
 static
 bool gridseed_detect_one(const char *path)
 {
-	struct gc3355_orb_info *info = gridseed_alloc_info();
+	struct gc3355_info *info = gridseed_alloc_info();
 	
 	if (!gridseed_detect_custom(path, &gridseed_drv, info))
 	{
@@ -167,7 +167,7 @@ static
 bool gridseed_prepare_work(struct thr_info __maybe_unused *thr, struct work *work)
 {
 	struct cgpu_info *device = thr->cgpu;
-	struct gc3355_orb_info *info = device->device_data;
+	struct gc3355_info *info = device->device_data;
 	unsigned char cmd[156];
 	
 	timer_set_now(&info->scanhash_time);
@@ -206,7 +206,7 @@ static
 int64_t gridseed_calculate_chip_hashes(struct thr_info *thr)
 {
 	struct cgpu_info *device = thr->cgpu;
-	struct gc3355_orb_info *info = device->device_data;
+	struct gc3355_info *info = device->device_data;
 	struct timeval old_scanhash_time = info->scanhash_time;
 
 	timer_set_now(&info->scanhash_time);
@@ -230,7 +230,7 @@ static
 int64_t gridseed_scanhash(struct thr_info *thr, struct work *work, int64_t __maybe_unused max_nonce)
 {
 	struct cgpu_info *device = thr->cgpu;
-	struct gc3355_orb_info *info = device->device_data;
+	struct gc3355_info *info = device->device_data;
 	struct timeval tv_nonce_range, tv_hashes_done;
 
 	// total hashrate of this device:
@@ -283,7 +283,7 @@ int64_t gridseed_scanhash(struct thr_info *thr, struct work *work, int64_t __may
 static
 const char *gridseed_set_clock(struct cgpu_info * const device, const char * const option, const char * const setting, char * const replybuf, enum bfg_set_device_replytype * const success)
 {
-	struct gc3355_orb_info * const info = device->device_data;
+	struct gc3355_info * const info = device->device_data;
 	int val = atoi(setting);
 
 	info->freq = val;
@@ -296,7 +296,7 @@ const char *gridseed_set_clock(struct cgpu_info * const device, const char * con
 static
 const char *gridseed_set_chips(struct cgpu_info * const device, const char * const option, const char * const setting, char * const replybuf, enum bfg_set_device_replytype * const success)
 {
-	struct gc3355_orb_info * const info = device->device_data;
+	struct gc3355_info * const info = device->device_data;
 	int val = atoi(setting);
 	
 	info->chips = val;

+ 23 - 27
gc3355.c

@@ -495,32 +495,38 @@ void gc3355_sha2_init(int fd)
 	gc3355_send_cmds(fd, sha2_init_cmd);
 }
 
-void gc3355_init_device(int fd, int pll_freq, bool scrypt_only, bool detect_only, bool usbstick)
+void gc3355_init_miner(int fd, int pll_freq)
 {
 	gc3355_send_cmds(fd, gcp_chip_reset_cmd);
 
 	// zzz
 	cgsleep_ms(GC3355_COMMAND_DELAY_MS);
 
-	if (usbstick)
-	{
-		gc3355_send_cmds(fd, sha2_chip_reset_cmd);
+	// initialize units
+	gc3355_send_cmds(fd, multichip_init_cmd);
+	gc3355_scrypt_init(fd);
 
-		// initialize units
-		gc3355_reset_dtr(fd);
+	//set freq
+	gc3355_set_pll_freq(fd, pll_freq);
+}
 
-		if (opt_scrypt && scrypt_only)
-			gc3355_scrypt_only_init(fd);
-		else
-		{
-			gc3355_sha2_init(fd);
-			gc3355_scrypt_init(fd);
-		}
-	}
+void gc3355_init_dualminer(int fd, int pll_freq, bool scrypt_only, bool detect_only)
+{
+	gc3355_send_cmds(fd, gcp_chip_reset_cmd);
+
+	// zzz
+	cgsleep_ms(GC3355_COMMAND_DELAY_MS);
+
+	gc3355_send_cmds(fd, sha2_chip_reset_cmd);
+
+	// initialize units
+	gc3355_reset_dtr(fd);
+
+	if (opt_scrypt && scrypt_only)
+		gc3355_scrypt_only_init(fd);
 	else
 	{
-		// initialize units
-		gc3355_send_cmds(fd, multichip_init_cmd);
+		gc3355_sha2_init(fd);
 		gc3355_scrypt_init(fd);
 	}
 
@@ -530,7 +536,7 @@ void gc3355_init_device(int fd, int pll_freq, bool scrypt_only, bool detect_only
 	// zzz
 	cgsleep_ms(GC3355_COMMAND_DELAY_MS);
 
-	if (usbstick && !detect_only)
+	if (!detect_only)
 	{
 		if (!opt_scrypt)
 			// open sha2 units
@@ -541,16 +547,6 @@ void gc3355_init_device(int fd, int pll_freq, bool scrypt_only, bool detect_only
 	}
 }
 
-void gc3355_init_usborb(int fd, int pll_freq, bool scrypt_only, bool detect_only)
-{
-	gc3355_init_device(fd, pll_freq, scrypt_only, detect_only, false);
-}
-
-void gc3355_init_usbstick(int fd, int pll_freq, bool scrypt_only, bool detect_only)
-{
-	gc3355_init_device(fd, pll_freq, scrypt_only, detect_only, true);
-}
-
 void gc3355_scrypt_reset(int fd)
 {
 	gc3355_send_cmds(fd, scrypt_reset_cmd);

+ 5 - 10
gc3355.h

@@ -31,7 +31,7 @@ int opt_pll_freq;
 #define GC3355_BLADE_DEFAULT_CHIPS	40
 #define GC3355_READ_SIZE          12
 
-struct gc3355_orb_info
+struct gc3355_info
 {
 	uint16_t freq;
 	unsigned chips;
@@ -44,20 +44,15 @@ struct gc3355_orb_info
 extern ssize_t gc3355_read(int fd, char *buf, size_t size);
 extern ssize_t gc3355_write(int fd, const void * const buf, const size_t size);
 
-extern void gc3355_init_usborb(int fd, int pll_freq, bool scrypt_only, bool detect_only);
-
-extern
-void gc3355_reset_dtr(int fd);
-
-extern void gc3355_init_usbstick(int fd, int pll_freq, bool scrypt_only, bool detect_only);
+extern void gc3355_init_miner(int fd, int pll_freq);
+extern void gc3355_init_dualminer(int fd, int pll_freq, bool scrypt_only, bool detect_only);
 
 extern void gc3355_scrypt_reset(int fd);
-
-extern
-void gc3355_scrypt_only_reset(int fd);
+extern void gc3355_scrypt_only_reset(int fd);
 
 extern void gc3355_scrypt_prepare_work(unsigned char cmd[156], struct work *);
 extern void gc3355_sha2_prepare_work(unsigned char cmd[52], struct work *);
+
 extern int64_t gc3355_get_firmware_version(int fd);
 extern void gc3355_set_pll_freq(int fd, int pll_freq);