2 * This file is part of the libsigrok project.
4 * Copyright (C) 2010-2012 Bert Vermeulen <bert@biot.com>
6 * This program is free software: you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation, either version 3 of the License, or
9 * (at your option) any later version.
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
16 * You should have received a copy of the GNU General Public License
17 * along with this program. If not, see <http://www.gnu.org/licenses/>.
22 SR_PRIV unsigned int get_memory_size(int type)
24 if (type == MEMORY_SIZE_8K)
26 else if (type == MEMORY_SIZE_64K)
28 else if (type == MEMORY_SIZE_128K)
30 else if (type == MEMORY_SIZE_512K)
36 SR_PRIV int set_limit_samples(struct dev_context *devc, uint64_t samples)
38 devc->limit_samples = samples;
40 if (samples <= 2 * 1024)
41 devc->memory_size = MEMORY_SIZE_8K;
42 else if (samples <= 16 * 1024)
43 devc->memory_size = MEMORY_SIZE_64K;
44 else if (samples <= 32 * 1024 || devc->max_memory_size <= 32 * 1024)
45 devc->memory_size = MEMORY_SIZE_128K;
47 devc->memory_size = MEMORY_SIZE_512K;
49 sr_info("Setting memory size to %dK.",
50 get_memory_size(devc->memory_size) / 1024);
52 analyzer_set_memory_size(devc->memory_size);
57 SR_PRIV int set_capture_ratio(struct dev_context *devc, uint64_t ratio)
60 sr_err("Invalid capture ratio: %" PRIu64 ".", ratio);
64 devc->capture_ratio = ratio;
66 sr_info("Setting capture ratio to %d%%.", devc->capture_ratio);
71 SR_PRIV void set_triggerbar(struct dev_context *devc)
73 unsigned int ramsize, n, triggerbar;
75 ramsize = get_memory_size(devc->memory_size) / 4;
78 if (devc->max_memory_size < n)
79 n = devc->max_memory_size;
80 if (devc->limit_samples < n)
81 n = devc->limit_samples;
82 n = n * devc->capture_ratio / 100;
84 triggerbar = ramsize - 8;
90 analyzer_set_triggerbar_address(triggerbar);
91 analyzer_set_ramsize_trigger_address(ramsize - triggerbar);
93 sr_dbg("triggerbar_address = %d(0x%x)", triggerbar, triggerbar);
94 sr_dbg("ramsize_triggerbar_address = %d(0x%x)",
95 ramsize - triggerbar, ramsize - triggerbar);