From c5c12248c0a7b65b5801c8cdd78b2b441fe9b2d9 Mon Sep 17 00:00:00 2001 From: DreamSourceLab Date: Sun, 24 Nov 2019 00:17:48 -0800 Subject: [PATCH] Extend timebase range @ dso mode --- DSView/pv/mainwindow.cpp | 2 +- DSView/pv/storesession.cpp | 12 ++++++++++++ DSView/pv/toolbars/samplingbar.cpp | 21 +++++++++++++++++---- DSView/pv/toolbars/samplingbar.h | 6 +++--- libsigrok4DSL/hardware/DSL/dsl.c | 5 +++++ libsigrok4DSL/hardware/demo/demo.c | 5 +++++ libsigrok4DSL/libsigrok.h | 2 ++ libsigrok4DSL/session_driver.c | 25 +++++++++++++++++++++++-- libsigrok4DSL/session_file.c | 8 ++++++++ 9 files changed, 76 insertions(+), 10 deletions(-) diff --git a/DSView/pv/mainwindow.cpp b/DSView/pv/mainwindow.cpp index 048ae51..b306584 100755 --- a/DSView/pv/mainwindow.cpp +++ b/DSView/pv/mainwindow.cpp @@ -441,7 +441,7 @@ void MainWindow::update_device_list() // USB device speed check if (!selected_device->name().contains("virtual")) { - int usb_speed; + int usb_speed = LIBUSB_SPEED_HIGH; GVariant *gvar = selected_device->get_config(NULL, NULL, SR_CONF_USB_SPEED); if (gvar != NULL) { usb_speed = g_variant_get_int32(gvar); diff --git a/DSView/pv/storesession.cpp b/DSView/pv/storesession.cpp index f637e62..765f290 100755 --- a/DSView/pv/storesession.cpp +++ b/DSView/pv/storesession.cpp @@ -375,6 +375,18 @@ QString StoreSession::meta_gen(boost::shared_ptr snapshot) fprintf(meta, "hDiv = %" PRIu64 "\n", tmp_u64); g_variant_unref(gvar); } + gvar = _session.get_device()->get_config(NULL, NULL, SR_CONF_MAX_TIMEBASE); + if (gvar != NULL) { + uint64_t tmp_u64 = g_variant_get_uint64(gvar); + fprintf(meta, "hDiv max = %" PRIu64 "\n", tmp_u64); + g_variant_unref(gvar); + } + gvar = _session.get_device()->get_config(NULL, NULL, SR_CONF_MIN_TIMEBASE); + if (gvar != NULL) { + uint64_t tmp_u64 = g_variant_get_uint64(gvar); + fprintf(meta, "hDiv min = %" PRIu64 "\n", tmp_u64); + g_variant_unref(gvar); + } gvar = _session.get_device()->get_config(NULL, NULL, SR_CONF_UNIT_BITS); if (gvar != NULL) { uint8_t tmp_u8 = g_variant_get_byte(gvar); diff --git a/DSView/pv/toolbars/samplingbar.cpp b/DSView/pv/toolbars/samplingbar.cpp index 8a07995..908464c 100755 --- a/DSView/pv/toolbars/samplingbar.cpp +++ b/DSView/pv/toolbars/samplingbar.cpp @@ -19,6 +19,8 @@ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ +#include "samplingbar.h" + #include #include #include @@ -30,7 +32,6 @@ #include #include -#include "samplingbar.h" #include "../devicemanager.h" #include "../device/devinst.h" #include "../dialogs/deviceoptions.h" @@ -156,7 +157,7 @@ void SamplingBar::retranslateUi() else if (dev_inst->name().contains("virtual")) _device_type.setText(tr("File")); else { - int usb_speed; + int usb_speed = LIBUSB_SPEED_HIGH; GVariant *gvar = dev_inst->get_config(NULL, NULL, SR_CONF_USB_SPEED); if (gvar != NULL) { usb_speed = g_variant_get_int32(gvar); @@ -203,7 +204,7 @@ void SamplingBar::reStyle() else if (dev_inst->name().contains("virtual")) _device_type.setIcon(QIcon(":/icons/data.png")); else { - int usb_speed; + int usb_speed = LIBUSB_SPEED_HIGH; GVariant *gvar = dev_inst->get_config(NULL, NULL, SR_CONF_USB_SPEED); if (gvar != NULL) { usb_speed = g_variant_get_int32(gvar); @@ -521,6 +522,7 @@ void SamplingBar::update_sample_count_selector() uint64_t sw_depth; uint64_t rle_depth = 0; uint64_t max_timebase = 0; + uint64_t min_timebase = SR_NS(10); double pre_duration = SR_SEC(1); double duration; bool rle_support = false; @@ -574,6 +576,11 @@ void SamplingBar::update_sample_count_selector() max_timebase = g_variant_get_uint64(gvar); g_variant_unref(gvar); } + gvar = dev_inst->get_config(NULL, NULL, SR_CONF_MIN_TIMEBASE); + if (gvar != NULL) { + min_timebase = g_variant_get_uint64(gvar); + g_variant_unref(gvar); + } } if (0 != _sample_count.count()) @@ -626,7 +633,7 @@ void SamplingBar::update_sample_count_selector() unit == SR_MIN(1) ? SR_SEC(50) : duration * 0.5); if (dev_inst->dev_inst()->mode == DSO) - not_last = duration >= SR_NS(10); + not_last = duration >= min_timebase; else if (dev_inst->dev_inst()->mode == ANALOG) not_last = (duration >= SR_MS(100)) && (duration / SR_SEC(1) * samplerate >= SR_KB(1)); @@ -957,6 +964,11 @@ void SamplingBar::enable_toggle(bool enable) _sample_count.setDisabled(true); _sample_rate.setDisabled(true); } + + if (_session.get_device()->name() == "virtual-session") { + _sample_count.setDisabled(true); + _sample_rate.setDisabled(true); + } } void SamplingBar::enable_run_stop(bool enable) @@ -1005,6 +1017,7 @@ void SamplingBar::reload() _instant_action->setVisible(true); enable_toggle(true); } + retranslateUi(); reStyle(); update(); diff --git a/DSView/pv/toolbars/samplingbar.h b/DSView/pv/toolbars/samplingbar.h index c023d7b..567eff1 100755 --- a/DSView/pv/toolbars/samplingbar.h +++ b/DSView/pv/toolbars/samplingbar.h @@ -23,6 +23,8 @@ #ifndef DSVIEW_PV_TOOLBARS_SAMPLINGBAR_H #define DSVIEW_PV_TOOLBARS_SAMPLINGBAR_H +#include "../sigsession.h" + #include #include #include @@ -35,8 +37,6 @@ #include #include -#include "../sigsession.h" - struct st_dev_inst; class QAction; @@ -67,7 +67,7 @@ private: static const uint64_t AnalogMaxSWDepth = SR_Mn(100); static const QString RLEString; static const QString DIVString; - static const uint64_t ZeroTimeBase = SR_US(10); + static const uint64_t ZeroTimeBase = SR_US(2); public: SamplingBar(SigSession &session, QWidget *parent); diff --git a/libsigrok4DSL/hardware/DSL/dsl.c b/libsigrok4DSL/hardware/DSL/dsl.c index 059f030..4a31270 100755 --- a/libsigrok4DSL/hardware/DSL/dsl.c +++ b/libsigrok4DSL/hardware/DSL/dsl.c @@ -1248,6 +1248,11 @@ SR_PRIV int dsl_config_get(int id, GVariant **data, const struct sr_dev_inst *sd channel_modes[devc->ch_mode].min_samplerate / DS_CONF_DSO_HDIVS)); break; + case SR_CONF_MIN_TIMEBASE: + if (!sdi) + return SR_ERR; + *data = g_variant_new_uint64(SR_SEC(1) / channel_modes[devc->ch_mode].hw_max_samplerate); + break; case SR_CONF_PROBE_COUPLING: if (!ch) return SR_ERR; diff --git a/libsigrok4DSL/hardware/demo/demo.c b/libsigrok4DSL/hardware/demo/demo.c index a073269..ce1550d 100755 --- a/libsigrok4DSL/hardware/demo/demo.c +++ b/libsigrok4DSL/hardware/demo/demo.c @@ -347,6 +347,11 @@ static int config_get(int id, GVariant **data, const struct sr_dev_inst *sdi, return SR_ERR; *data = g_variant_new_uint64(MAX_TIMEBASE); break; + case SR_CONF_MIN_TIMEBASE: + if (!sdi) + return SR_ERR; + *data = g_variant_new_uint64(MIN_TIMEBASE); + break; case SR_CONF_PROBE_COUPLING: *data = g_variant_new_byte(ch->coupling); break; diff --git a/libsigrok4DSL/libsigrok.h b/libsigrok4DSL/libsigrok.h index 771ca83..6999fc6 100755 --- a/libsigrok4DSL/libsigrok.h +++ b/libsigrok4DSL/libsigrok.h @@ -129,6 +129,7 @@ enum { * Oscilloscope */ #define MAX_TIMEBASE SR_SEC(10) +#define MIN_TIMEBASE SR_NS(10) extern char DS_RES_PATH[256]; @@ -842,6 +843,7 @@ enum { /** Time base. */ SR_CONF_MAX_TIMEBASE, + SR_CONF_MIN_TIMEBASE, SR_CONF_TIMEBASE, /** Filter. */ diff --git a/libsigrok4DSL/session_driver.c b/libsigrok4DSL/session_driver.c index ce95ae8..ce4281e 100755 --- a/libsigrok4DSL/session_driver.c +++ b/libsigrok4DSL/session_driver.c @@ -85,6 +85,8 @@ struct session_vdev { int num_probes; int enabled_probes; uint64_t timebase; + uint64_t max_timebase; + uint64_t min_timebase; uint8_t unit_bits; uint32_t ref_min; uint32_t ref_max; @@ -364,6 +366,8 @@ static int dev_open(struct sr_dev_inst *sdi) vdev->unit_bits = 1; vdev->ref_min = 0; vdev->ref_max = 0; + vdev->max_timebase = MAX_TIMEBASE; + vdev->min_timebase = MIN_TIMEBASE; vdev->max_height = 0; vdev->mstatus.measure_valid = TRUE; @@ -431,9 +435,18 @@ static int config_get(int id, GVariant **data, const struct sr_dev_inst *sdi, return SR_ERR; break; case SR_CONF_MAX_TIMEBASE: - if (!sdi) + if (sdi) { + vdev = sdi->priv; + *data = g_variant_new_uint64(vdev->max_timebase); + } else + return SR_ERR; + break; + case SR_CONF_MIN_TIMEBASE: + if (sdi) { + vdev = sdi->priv; + *data = g_variant_new_uint64(vdev->min_timebase); + } else return SR_ERR; - *data = g_variant_new_uint64(MAX_TIMEBASE); break; case SR_CONF_UNIT_BITS: if (sdi) { @@ -593,6 +606,14 @@ static int config_set(int id, GVariant *data, struct sr_dev_inst *sdi, vdev->timebase = g_variant_get_uint64(data); sr_info("Setting timebase to %" PRIu64 ".", vdev->timebase); break; + case SR_CONF_MAX_TIMEBASE: + vdev->max_timebase = g_variant_get_uint64(data); + sr_info("Setting max timebase to %" PRIu64 ".", vdev->max_timebase); + break; + case SR_CONF_MIN_TIMEBASE: + vdev->min_timebase = g_variant_get_uint64(data); + sr_info("Setting min timebase to %" PRIu64 ".", vdev->min_timebase); + break; case SR_CONF_UNIT_BITS: vdev->unit_bits = g_variant_get_byte(data); sr_info("Setting unit bits to %d.", vdev->unit_bits); diff --git a/libsigrok4DSL/session_file.c b/libsigrok4DSL/session_file.c index 14c6a75..4ae027d 100755 --- a/libsigrok4DSL/session_file.c +++ b/libsigrok4DSL/session_file.c @@ -220,6 +220,14 @@ SR_API int sr_session_load(const char *filename) tmp_u64 = strtoull(val, NULL, 10); sdi->driver->config_set(SR_CONF_TIMEBASE, g_variant_new_uint64(tmp_u64), sdi, NULL, NULL); + } else if (!strcmp(keys[j], "hDiv min")) { + tmp_u64 = strtoull(val, NULL, 10); + sdi->driver->config_set(SR_CONF_MIN_TIMEBASE, + g_variant_new_uint64(tmp_u64), sdi, NULL, NULL); + } else if (!strcmp(keys[j], "hDiv max")) { + tmp_u64 = strtoull(val, NULL, 10); + sdi->driver->config_set(SR_CONF_MAX_TIMEBASE, + g_variant_new_uint64(tmp_u64), sdi, NULL, NULL); } else if (!strcmp(keys[j], "bits")) { tmp_u64 = strtoull(val, NULL, 10); sdi->driver->config_set(SR_CONF_UNIT_BITS, -- 2.30.2