]>
Commit | Line | Data |
---|---|---|
1 | /* | |
2 | * This file is part of the libsigrok project. | |
3 | * | |
4 | * Copyright (C) 2013 Bert Vermeulen <bert@biot.com> | |
5 | * Copyright (C) 2012 Joel Holdsworth <joel@airwebreathe.org.uk> | |
6 | * | |
7 | * This program is free software: you can redistribute it and/or modify | |
8 | * it under the terms of the GNU General Public License as published by | |
9 | * the Free Software Foundation, either version 3 of the License, or | |
10 | * (at your option) any later version. | |
11 | * | |
12 | * This program is distributed in the hope that it will be useful, | |
13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | |
14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
15 | * GNU General Public License for more details. | |
16 | * | |
17 | * You should have received a copy of the GNU General Public License | |
18 | * along with this program. If not, see <http://www.gnu.org/licenses/>. | |
19 | */ | |
20 | ||
21 | #include <config.h> | |
22 | #include <glib.h> | |
23 | #include <glib/gstdio.h> | |
24 | #include "protocol.h" | |
25 | #include "dslogic.h" | |
26 | ||
27 | #pragma pack(push, 1) | |
28 | ||
29 | struct version_info { | |
30 | uint8_t major; | |
31 | uint8_t minor; | |
32 | }; | |
33 | ||
34 | struct cmd_start_acquisition { | |
35 | uint8_t flags; | |
36 | uint8_t sample_delay_h; | |
37 | uint8_t sample_delay_l; | |
38 | }; | |
39 | ||
40 | #pragma pack(pop) | |
41 | ||
42 | #define USB_TIMEOUT 100 | |
43 | ||
44 | static int command_get_fw_version(libusb_device_handle *devhdl, | |
45 | struct version_info *vi) | |
46 | { | |
47 | int ret; | |
48 | ||
49 | ret = libusb_control_transfer(devhdl, LIBUSB_REQUEST_TYPE_VENDOR | | |
50 | LIBUSB_ENDPOINT_IN, CMD_GET_FW_VERSION, 0x0000, 0x0000, | |
51 | (unsigned char *)vi, sizeof(struct version_info), USB_TIMEOUT); | |
52 | ||
53 | if (ret < 0) { | |
54 | sr_err("Unable to get version info: %s.", | |
55 | libusb_error_name(ret)); | |
56 | return SR_ERR; | |
57 | } | |
58 | ||
59 | return SR_OK; | |
60 | } | |
61 | ||
62 | static int command_get_revid_version(struct sr_dev_inst *sdi, uint8_t *revid) | |
63 | { | |
64 | struct dev_context *devc = sdi->priv; | |
65 | struct sr_usb_dev_inst *usb = sdi->conn; | |
66 | libusb_device_handle *devhdl = usb->devhdl; | |
67 | int cmd, ret; | |
68 | ||
69 | cmd = devc->dslogic ? DS_CMD_GET_REVID_VERSION : CMD_GET_REVID_VERSION; | |
70 | ret = libusb_control_transfer(devhdl, LIBUSB_REQUEST_TYPE_VENDOR | | |
71 | LIBUSB_ENDPOINT_IN, cmd, 0x0000, 0x0000, revid, 1, USB_TIMEOUT); | |
72 | ||
73 | if (ret < 0) { | |
74 | sr_err("Unable to get REVID: %s.", libusb_error_name(ret)); | |
75 | return SR_ERR; | |
76 | } | |
77 | ||
78 | return SR_OK; | |
79 | } | |
80 | ||
81 | SR_PRIV int fx2lafw_command_start_acquisition(const struct sr_dev_inst *sdi) | |
82 | { | |
83 | struct dev_context *devc; | |
84 | struct sr_usb_dev_inst *usb; | |
85 | uint64_t samplerate; | |
86 | struct cmd_start_acquisition cmd; | |
87 | int delay, ret; | |
88 | ||
89 | devc = sdi->priv; | |
90 | usb = sdi->conn; | |
91 | samplerate = devc->cur_samplerate; | |
92 | ||
93 | /* Compute the sample rate. */ | |
94 | if (devc->sample_wide && samplerate > MAX_16BIT_SAMPLE_RATE) { | |
95 | sr_err("Unable to sample at %" PRIu64 "Hz " | |
96 | "when collecting 16-bit samples.", samplerate); | |
97 | return SR_ERR; | |
98 | } | |
99 | ||
100 | delay = 0; | |
101 | cmd.flags = cmd.sample_delay_h = cmd.sample_delay_l = 0; | |
102 | if ((SR_MHZ(48) % samplerate) == 0) { | |
103 | cmd.flags = CMD_START_FLAGS_CLK_48MHZ; | |
104 | delay = SR_MHZ(48) / samplerate - 1; | |
105 | if (delay > MAX_SAMPLE_DELAY) | |
106 | delay = 0; | |
107 | } | |
108 | ||
109 | if (delay == 0 && (SR_MHZ(30) % samplerate) == 0) { | |
110 | cmd.flags = CMD_START_FLAGS_CLK_30MHZ; | |
111 | delay = SR_MHZ(30) / samplerate - 1; | |
112 | } | |
113 | ||
114 | sr_dbg("GPIF delay = %d, clocksource = %sMHz.", delay, | |
115 | (cmd.flags & CMD_START_FLAGS_CLK_48MHZ) ? "48" : "30"); | |
116 | ||
117 | if (delay <= 0 || delay > MAX_SAMPLE_DELAY) { | |
118 | sr_err("Unable to sample at %" PRIu64 "Hz.", samplerate); | |
119 | return SR_ERR; | |
120 | } | |
121 | ||
122 | cmd.sample_delay_h = (delay >> 8) & 0xff; | |
123 | cmd.sample_delay_l = delay & 0xff; | |
124 | ||
125 | /* Select the sampling width. */ | |
126 | cmd.flags |= devc->sample_wide ? CMD_START_FLAGS_SAMPLE_16BIT : | |
127 | CMD_START_FLAGS_SAMPLE_8BIT; | |
128 | /* Enable CTL2 clock. */ | |
129 | cmd.flags |= (g_slist_length(devc->enabled_analog_channels) > 0) ? CMD_START_FLAGS_CLK_CTL2 : 0; | |
130 | ||
131 | /* Send the control message. */ | |
132 | ret = libusb_control_transfer(usb->devhdl, LIBUSB_REQUEST_TYPE_VENDOR | | |
133 | LIBUSB_ENDPOINT_OUT, CMD_START, 0x0000, 0x0000, | |
134 | (unsigned char *)&cmd, sizeof(cmd), USB_TIMEOUT); | |
135 | if (ret < 0) { | |
136 | sr_err("Unable to send start command: %s.", | |
137 | libusb_error_name(ret)); | |
138 | return SR_ERR; | |
139 | } | |
140 | ||
141 | return SR_OK; | |
142 | } | |
143 | ||
144 | SR_PRIV int fx2lafw_dev_open(struct sr_dev_inst *sdi, struct sr_dev_driver *di) | |
145 | { | |
146 | libusb_device **devlist; | |
147 | struct sr_usb_dev_inst *usb; | |
148 | struct libusb_device_descriptor des; | |
149 | struct dev_context *devc; | |
150 | struct drv_context *drvc; | |
151 | struct version_info vi; | |
152 | int ret, i, device_count; | |
153 | uint8_t revid; | |
154 | char connection_id[64]; | |
155 | ||
156 | drvc = di->context; | |
157 | devc = sdi->priv; | |
158 | usb = sdi->conn; | |
159 | ||
160 | if (sdi->status == SR_ST_ACTIVE) | |
161 | /* Device is already in use. */ | |
162 | return SR_ERR; | |
163 | ||
164 | device_count = libusb_get_device_list(drvc->sr_ctx->libusb_ctx, &devlist); | |
165 | if (device_count < 0) { | |
166 | sr_err("Failed to get device list: %s.", | |
167 | libusb_error_name(device_count)); | |
168 | return SR_ERR; | |
169 | } | |
170 | ||
171 | for (i = 0; i < device_count; i++) { | |
172 | libusb_get_device_descriptor(devlist[i], &des); | |
173 | ||
174 | if (des.idVendor != devc->profile->vid | |
175 | || des.idProduct != devc->profile->pid) | |
176 | continue; | |
177 | ||
178 | if ((sdi->status == SR_ST_INITIALIZING) || | |
179 | (sdi->status == SR_ST_INACTIVE)) { | |
180 | /* | |
181 | * Check device by its physical USB bus/port address. | |
182 | */ | |
183 | usb_get_port_path(devlist[i], connection_id, sizeof(connection_id)); | |
184 | if (strcmp(sdi->connection_id, connection_id)) | |
185 | /* This is not the one. */ | |
186 | continue; | |
187 | } | |
188 | ||
189 | if (!(ret = libusb_open(devlist[i], &usb->devhdl))) { | |
190 | if (usb->address == 0xff) | |
191 | /* | |
192 | * First time we touch this device after FW | |
193 | * upload, so we don't know the address yet. | |
194 | */ | |
195 | usb->address = libusb_get_device_address(devlist[i]); | |
196 | } else { | |
197 | sr_err("Failed to open device: %s.", | |
198 | libusb_error_name(ret)); | |
199 | break; | |
200 | } | |
201 | ||
202 | if (libusb_has_capability(LIBUSB_CAP_SUPPORTS_DETACH_KERNEL_DRIVER)) { | |
203 | if (libusb_kernel_driver_active(usb->devhdl, USB_INTERFACE) == 1) { | |
204 | if ((ret = libusb_detach_kernel_driver(usb->devhdl, USB_INTERFACE)) < 0) { | |
205 | sr_err("Failed to detach kernel driver: %s.", | |
206 | libusb_error_name(ret)); | |
207 | return SR_ERR; | |
208 | } | |
209 | } | |
210 | } | |
211 | ||
212 | ret = command_get_fw_version(usb->devhdl, &vi); | |
213 | if (ret != SR_OK) { | |
214 | sr_err("Failed to get firmware version."); | |
215 | break; | |
216 | } | |
217 | ||
218 | ret = command_get_revid_version(sdi, &revid); | |
219 | if (ret != SR_OK) { | |
220 | sr_err("Failed to get REVID."); | |
221 | break; | |
222 | } | |
223 | ||
224 | /* | |
225 | * Changes in major version mean incompatible/API changes, so | |
226 | * bail out if we encounter an incompatible version. | |
227 | * Different minor versions are OK, they should be compatible. | |
228 | */ | |
229 | if (vi.major != FX2LAFW_REQUIRED_VERSION_MAJOR) { | |
230 | sr_err("Expected firmware version %d.x, " | |
231 | "got %d.%d.", FX2LAFW_REQUIRED_VERSION_MAJOR, | |
232 | vi.major, vi.minor); | |
233 | break; | |
234 | } | |
235 | ||
236 | sdi->status = SR_ST_ACTIVE; | |
237 | sr_info("Opened device on %d.%d (logical) / %s (physical), " | |
238 | "interface %d, firmware %d.%d.", | |
239 | usb->bus, usb->address, connection_id, | |
240 | USB_INTERFACE, vi.major, vi.minor); | |
241 | ||
242 | sr_info("Detected REVID=%d, it's a Cypress CY7C68013%s.", | |
243 | revid, (revid != 1) ? " (FX2)" : "A (FX2LP)"); | |
244 | ||
245 | break; | |
246 | } | |
247 | libusb_free_device_list(devlist, 1); | |
248 | ||
249 | if (sdi->status != SR_ST_ACTIVE) | |
250 | return SR_ERR; | |
251 | ||
252 | return SR_OK; | |
253 | } | |
254 | ||
255 | SR_PRIV struct dev_context *fx2lafw_dev_new(void) | |
256 | { | |
257 | struct dev_context *devc; | |
258 | ||
259 | devc = g_malloc0(sizeof(struct dev_context)); | |
260 | devc->profile = NULL; | |
261 | devc->fw_updated = 0; | |
262 | devc->cur_samplerate = 0; | |
263 | devc->limit_samples = 0; | |
264 | devc->capture_ratio = 0; | |
265 | devc->sample_wide = FALSE; | |
266 | devc->dslogic_continuous_mode = FALSE; | |
267 | devc->dslogic_clock_edge = DS_EDGE_RISING; | |
268 | devc->stl = NULL; | |
269 | ||
270 | return devc; | |
271 | } | |
272 | ||
273 | SR_PRIV void fx2lafw_abort_acquisition(struct dev_context *devc) | |
274 | { | |
275 | int i; | |
276 | ||
277 | devc->acq_aborted = TRUE; | |
278 | ||
279 | for (i = devc->num_transfers - 1; i >= 0; i--) { | |
280 | if (devc->transfers[i]) | |
281 | libusb_cancel_transfer(devc->transfers[i]); | |
282 | } | |
283 | } | |
284 | ||
285 | static void finish_acquisition(struct sr_dev_inst *sdi) | |
286 | { | |
287 | struct dev_context *devc; | |
288 | ||
289 | devc = sdi->priv; | |
290 | ||
291 | std_session_send_df_end(sdi); | |
292 | ||
293 | usb_source_remove(sdi->session, devc->ctx); | |
294 | ||
295 | devc->num_transfers = 0; | |
296 | g_free(devc->transfers); | |
297 | ||
298 | /* Free the deinterlace buffers if we had them. */ | |
299 | if (g_slist_length(devc->enabled_analog_channels) > 0) { | |
300 | g_free(devc->logic_buffer); | |
301 | g_free(devc->analog_buffer); | |
302 | } | |
303 | ||
304 | if (devc->stl) { | |
305 | soft_trigger_logic_free(devc->stl); | |
306 | devc->stl = NULL; | |
307 | } | |
308 | } | |
309 | ||
310 | static void free_transfer(struct libusb_transfer *transfer) | |
311 | { | |
312 | struct sr_dev_inst *sdi; | |
313 | struct dev_context *devc; | |
314 | unsigned int i; | |
315 | ||
316 | sdi = transfer->user_data; | |
317 | devc = sdi->priv; | |
318 | ||
319 | g_free(transfer->buffer); | |
320 | transfer->buffer = NULL; | |
321 | libusb_free_transfer(transfer); | |
322 | ||
323 | for (i = 0; i < devc->num_transfers; i++) { | |
324 | if (devc->transfers[i] == transfer) { | |
325 | devc->transfers[i] = NULL; | |
326 | break; | |
327 | } | |
328 | } | |
329 | ||
330 | devc->submitted_transfers--; | |
331 | if (devc->submitted_transfers == 0) | |
332 | finish_acquisition(sdi); | |
333 | } | |
334 | ||
335 | static void resubmit_transfer(struct libusb_transfer *transfer) | |
336 | { | |
337 | int ret; | |
338 | ||
339 | if ((ret = libusb_submit_transfer(transfer)) == LIBUSB_SUCCESS) | |
340 | return; | |
341 | ||
342 | sr_err("%s: %s", __func__, libusb_error_name(ret)); | |
343 | free_transfer(transfer); | |
344 | ||
345 | } | |
346 | ||
347 | SR_PRIV void mso_send_data_proc(struct sr_dev_inst *sdi, | |
348 | uint8_t *data, size_t length, size_t sample_width) | |
349 | { | |
350 | size_t i; | |
351 | struct dev_context *devc; | |
352 | struct sr_datafeed_analog analog; | |
353 | struct sr_analog_encoding encoding; | |
354 | struct sr_analog_meaning meaning; | |
355 | struct sr_analog_spec spec; | |
356 | ||
357 | (void)sample_width; | |
358 | ||
359 | devc = sdi->priv; | |
360 | ||
361 | length /= 2; | |
362 | ||
363 | /* Send the logic */ | |
364 | for (i = 0; i < length; i++) { | |
365 | devc->logic_buffer[i] = data[i * 2]; | |
366 | /* Rescale to -10V - +10V from 0-255. */ | |
367 | devc->analog_buffer[i] = (data[i * 2 + 1] - 128.0f) / 12.8f; | |
368 | }; | |
369 | ||
370 | const struct sr_datafeed_logic logic = { | |
371 | .length = length, | |
372 | .unitsize = 1, | |
373 | .data = devc->logic_buffer | |
374 | }; | |
375 | ||
376 | const struct sr_datafeed_packet logic_packet = { | |
377 | .type = SR_DF_LOGIC, | |
378 | .payload = &logic | |
379 | }; | |
380 | ||
381 | sr_session_send(sdi, &logic_packet); | |
382 | ||
383 | sr_analog_init(&analog, &encoding, &meaning, &spec, 2); | |
384 | analog.meaning->channels = devc->enabled_analog_channels; | |
385 | analog.meaning->mq = SR_MQ_VOLTAGE; | |
386 | analog.meaning->unit = SR_UNIT_VOLT; | |
387 | analog.meaning->mqflags = 0 /* SR_MQFLAG_DC */; | |
388 | analog.num_samples = length; | |
389 | analog.data = devc->analog_buffer; | |
390 | ||
391 | const struct sr_datafeed_packet analog_packet = { | |
392 | .type = SR_DF_ANALOG, | |
393 | .payload = &analog | |
394 | }; | |
395 | ||
396 | sr_session_send(sdi, &analog_packet); | |
397 | } | |
398 | ||
399 | SR_PRIV void la_send_data_proc(struct sr_dev_inst *sdi, | |
400 | uint8_t *data, size_t length, size_t sample_width) | |
401 | { | |
402 | const struct sr_datafeed_logic logic = { | |
403 | .length = length, | |
404 | .unitsize = sample_width, | |
405 | .data = data | |
406 | }; | |
407 | ||
408 | const struct sr_datafeed_packet packet = { | |
409 | .type = SR_DF_LOGIC, | |
410 | .payload = &logic | |
411 | }; | |
412 | ||
413 | sr_session_send(sdi, &packet); | |
414 | } | |
415 | ||
416 | SR_PRIV void LIBUSB_CALL fx2lafw_receive_transfer(struct libusb_transfer *transfer) | |
417 | { | |
418 | struct sr_dev_inst *sdi; | |
419 | struct dev_context *devc; | |
420 | gboolean packet_has_error = FALSE; | |
421 | struct sr_datafeed_packet packet; | |
422 | unsigned int num_samples; | |
423 | int trigger_offset, cur_sample_count, unitsize; | |
424 | int pre_trigger_samples; | |
425 | ||
426 | sdi = transfer->user_data; | |
427 | devc = sdi->priv; | |
428 | ||
429 | /* | |
430 | * If acquisition has already ended, just free any queued up | |
431 | * transfer that come in. | |
432 | */ | |
433 | if (devc->acq_aborted) { | |
434 | free_transfer(transfer); | |
435 | return; | |
436 | } | |
437 | ||
438 | sr_dbg("receive_transfer(): status %s received %d bytes.", | |
439 | libusb_error_name(transfer->status), transfer->actual_length); | |
440 | ||
441 | /* Save incoming transfer before reusing the transfer struct. */ | |
442 | unitsize = devc->sample_wide ? 2 : 1; | |
443 | cur_sample_count = transfer->actual_length / unitsize; | |
444 | ||
445 | switch (transfer->status) { | |
446 | case LIBUSB_TRANSFER_NO_DEVICE: | |
447 | fx2lafw_abort_acquisition(devc); | |
448 | free_transfer(transfer); | |
449 | return; | |
450 | case LIBUSB_TRANSFER_COMPLETED: | |
451 | case LIBUSB_TRANSFER_TIMED_OUT: /* We may have received some data though. */ | |
452 | break; | |
453 | default: | |
454 | packet_has_error = TRUE; | |
455 | break; | |
456 | } | |
457 | ||
458 | if (transfer->actual_length == 0 || packet_has_error) { | |
459 | devc->empty_transfer_count++; | |
460 | if (devc->empty_transfer_count > MAX_EMPTY_TRANSFERS) { | |
461 | /* | |
462 | * The FX2 gave up. End the acquisition, the frontend | |
463 | * will work out that the samplecount is short. | |
464 | */ | |
465 | fx2lafw_abort_acquisition(devc); | |
466 | free_transfer(transfer); | |
467 | } else { | |
468 | resubmit_transfer(transfer); | |
469 | } | |
470 | return; | |
471 | } else { | |
472 | devc->empty_transfer_count = 0; | |
473 | } | |
474 | if (devc->trigger_fired) { | |
475 | if (!devc->limit_samples || devc->sent_samples < devc->limit_samples) { | |
476 | /* Send the incoming transfer to the session bus. */ | |
477 | if (devc->limit_samples && devc->sent_samples + cur_sample_count > devc->limit_samples) | |
478 | num_samples = devc->limit_samples - devc->sent_samples; | |
479 | else | |
480 | num_samples = cur_sample_count; | |
481 | ||
482 | if (devc->dslogic && devc->trigger_pos > devc->sent_samples | |
483 | && devc->trigger_pos <= devc->sent_samples + num_samples) { | |
484 | /* DSLogic trigger in this block. Send trigger position. */ | |
485 | trigger_offset = devc->trigger_pos - devc->sent_samples; | |
486 | /* Pre-trigger samples. */ | |
487 | devc->send_data_proc(sdi, (uint8_t *)transfer->buffer, | |
488 | trigger_offset * unitsize, unitsize); | |
489 | devc->sent_samples += trigger_offset; | |
490 | /* Trigger position. */ | |
491 | devc->trigger_pos = 0; | |
492 | packet.type = SR_DF_TRIGGER; | |
493 | packet.payload = NULL; | |
494 | sr_session_send(sdi, &packet); | |
495 | /* Post trigger samples. */ | |
496 | num_samples -= trigger_offset; | |
497 | devc->send_data_proc(sdi, (uint8_t *)transfer->buffer | |
498 | + trigger_offset * unitsize, num_samples * unitsize, unitsize); | |
499 | devc->sent_samples += num_samples; | |
500 | } else { | |
501 | devc->send_data_proc(sdi, (uint8_t *)transfer->buffer, | |
502 | num_samples * unitsize, unitsize); | |
503 | devc->sent_samples += num_samples; | |
504 | } | |
505 | } | |
506 | } else { | |
507 | trigger_offset = soft_trigger_logic_check(devc->stl, | |
508 | transfer->buffer, transfer->actual_length, &pre_trigger_samples); | |
509 | if (trigger_offset > -1) { | |
510 | devc->sent_samples += pre_trigger_samples; | |
511 | num_samples = cur_sample_count - trigger_offset; | |
512 | if (devc->limit_samples && | |
513 | num_samples > devc->limit_samples - devc->sent_samples) | |
514 | num_samples = devc->limit_samples - devc->sent_samples; | |
515 | ||
516 | devc->send_data_proc(sdi, (uint8_t *)transfer->buffer | |
517 | + trigger_offset * unitsize, | |
518 | num_samples * unitsize, unitsize); | |
519 | devc->sent_samples += num_samples; | |
520 | ||
521 | devc->trigger_fired = TRUE; | |
522 | } | |
523 | } | |
524 | ||
525 | if (devc->limit_samples && devc->sent_samples >= devc->limit_samples) { | |
526 | fx2lafw_abort_acquisition(devc); | |
527 | free_transfer(transfer); | |
528 | } else | |
529 | resubmit_transfer(transfer); | |
530 | } | |
531 | ||
532 | static unsigned int to_bytes_per_ms(unsigned int samplerate) | |
533 | { | |
534 | return samplerate / 1000; | |
535 | } | |
536 | ||
537 | SR_PRIV size_t fx2lafw_get_buffer_size(struct dev_context *devc) | |
538 | { | |
539 | size_t s; | |
540 | ||
541 | /* | |
542 | * The buffer should be large enough to hold 10ms of data and | |
543 | * a multiple of 512. | |
544 | */ | |
545 | s = 10 * to_bytes_per_ms(devc->cur_samplerate); | |
546 | return (s + 511) & ~511; | |
547 | } | |
548 | ||
549 | SR_PRIV unsigned int fx2lafw_get_number_of_transfers(struct dev_context *devc) | |
550 | { | |
551 | unsigned int n; | |
552 | ||
553 | if (devc->dslogic) | |
554 | return dslogic_get_number_of_transfers(devc); | |
555 | ||
556 | /* Total buffer size should be able to hold about 500ms of data. */ | |
557 | n = (500 * to_bytes_per_ms(devc->cur_samplerate) / | |
558 | fx2lafw_get_buffer_size(devc)); | |
559 | ||
560 | if (n > NUM_SIMUL_TRANSFERS) | |
561 | return NUM_SIMUL_TRANSFERS; | |
562 | ||
563 | return n; | |
564 | } | |
565 | ||
566 | SR_PRIV unsigned int fx2lafw_get_timeout(struct dev_context *devc) | |
567 | { | |
568 | size_t total_size; | |
569 | unsigned int timeout; | |
570 | ||
571 | total_size = fx2lafw_get_buffer_size(devc) * | |
572 | fx2lafw_get_number_of_transfers(devc); | |
573 | timeout = total_size / to_bytes_per_ms(devc->cur_samplerate); | |
574 | return timeout + timeout / 4; /* Leave a headroom of 25% percent. */ | |
575 | } |