Browse Source

Merge commit '44659ca' into littlefury

Conflicts:
	libbitfury.c
	libbitfury.h
Luke Dashjr 12 years ago
parent
commit
7ba10d20d6
3 changed files with 13 additions and 6 deletions
  1. 1 0
      driver-littlefury.c
  2. 10 6
      libbitfury.c
  3. 2 0
      libbitfury.h

+ 1 - 0
driver-littlefury.c

@@ -385,6 +385,7 @@ bool littlefury_job_prepare(struct thr_info *thr, struct work *work, __maybe_unu
 {
 	struct bitfury_device * const bitfury = thr->cgpu->device_data;
 	work_to_payload(&bitfury->payload, thr->next_work);
+	payload_to_atrvec(bitfury->atrvec, &bitfury->payload);
 	return true;
 }
 

+ 10 - 6
libbitfury.c

@@ -381,6 +381,13 @@ void work_to_payload(struct bitfury_payload *p, struct work *w) {
 	p->nbits = bswap_32(*(unsigned *)(flipped_data + 72));
 }
 
+void payload_to_atrvec(uint32_t *atrvec, struct bitfury_payload *p)
+{
+	/* Programming next value */
+	memcpy(atrvec, p, 20*4);
+	ms3_compute(atrvec);
+}
+
 void libbitfury_sendHashData1(int chip_id, struct bitfury_device *d, bool second_run)
 {
 	struct spi_port *port = d->spi;
@@ -389,15 +396,11 @@ void libbitfury_sendHashData1(int chip_id, struct bitfury_device *d, bool second
 	struct bitfury_payload *p = &(d->payload);
 	struct bitfury_payload *op = &(d->opayload);
 	struct bitfury_payload *o2p = &(d->o2payload);
-	unsigned atrvec[20];
 	struct timespec d_time;
 	struct timespec time;
 	int smart = 0;
 	int chip = d->fasync;
 
-	memcpy(atrvec, p, 20*4);
-	ms3_compute(atrvec);
-
 	clock_gettime(CLOCK_REALTIME, &(time));
 
 	if (!second_run) {
@@ -414,7 +417,7 @@ void libbitfury_sendHashData1(int chip_id, struct bitfury_device *d, bool second
 		spi_clear_buf(port);
 		spi_emit_break(port);
 		spi_emit_fasync(port, chip);
-		spi_emit_data(port, 0x3000, &atrvec[0], 19*4);
+		spi_emit_data(port, 0x3000, &d->atrvec[0], 19*4);
 		if (smart) {
 			config_reg(port, 3, 0);
 		}
@@ -584,7 +587,7 @@ void libbitfury_sendHashData1(int chip_id, struct bitfury_device *d, bool second
 			spi_clear_buf(port);
 			spi_emit_break(port);
 			spi_emit_fasync(port, chip);
-			spi_emit_data(port, 0x3000, &atrvec[0], 19*4);
+			spi_emit_data(port, 0x3000, &d->atrvec[0], 19*4);
 			if (smart) {
 				config_reg(port, 3, 1);
 			}
@@ -605,6 +608,7 @@ void libbitfury_sendHashData(struct bitfury_device *bf, int chip_n) {
 
 	for (chip_id = 0; chip_id < chip_n; chip_id++) {
 		struct bitfury_device *d = bf + chip_id;
+		payload_to_atrvec(d->atrvec, &d->payload);
 		libbitfury_sendHashData1(chip_id, d, second_run);
 	}
 	second_run = true;

+ 2 - 0
libbitfury.h

@@ -24,6 +24,7 @@ struct bitfury_device {
 	struct work * owork;
 	struct work * o2work;
 	int job_switched;
+	uint32_t atrvec[20];
 	struct bitfury_payload payload;
 	struct bitfury_payload opayload;
 	struct bitfury_payload o2payload;
@@ -55,6 +56,7 @@ int libbitfury_readHashData(unsigned int *res);
 extern void libbitfury_sendHashData1(int chip_id, struct bitfury_device *d, bool second_run);
 void libbitfury_sendHashData(struct bitfury_device *bf, int chip_n);
 void work_to_payload(struct bitfury_payload *p, struct work *w);
+extern void payload_to_atrvec(uint32_t *atrvec, struct bitfury_payload *);
 struct timespec t_diff(struct timespec start, struct timespec end);
 extern void send_reinit(struct spi_port *, int slot, int chip_n, int n);
 extern void send_shutdown(struct spi_port *, int slot, int chip_n);