*/
SR_API gboolean sr_dev_has_hwcap(const struct sr_dev *dev, int hwcap)
{
- int *capabilities, i;
+ int *hwcaps, i;
if (!dev) {
sr_err("dev: %s: dev was NULL", __func__);
/* TODO: Sanity check on 'hwcap'. */
- if (!(capabilities = dev->plugin->get_capabilities())) {
+ if (!(hwcaps = dev->plugin->hwcap_get_all())) {
sr_err("dev: %s: dev has no capabilities", __func__);
return FALSE; /* TODO: SR_ERR*. */
}
- for (i = 0; capabilities[i]; i++) {
- if (capabilities[i] != hwcap)
+ for (i = 0; hwcaps[i]; i++) {
+ if (hwcaps[i] != hwcap)
continue;
sr_spew("dev: %s: found hwcap %d", __func__, hwcap);
return TRUE;
struct sr_analog_probe probes[];
};
-static int capabilities[] = {
+static int hwcaps[] = {
SR_HWCAP_SAMPLERATE,
SR_HWCAP_LIMIT_SAMPLES,
SR_HWCAP_CONTINUOUS,
dev_insts = g_slist_append(dev_insts, sdi);
return 1;
+
free_alsa:
g_free(alsa);
return 0;
return SR_ST_ACTIVE;
}
-static int *hw_get_capabilities(void)
+static int *hw_hwcap_get_all(void)
{
- return capabilities;
+ return hwcaps;
}
-static int hw_set_configuration(int dev_index, int capability, void *value)
+static int hw_set_configuration(int dev_index, int hwcap, void *value)
{
struct sr_dev_inst *sdi;
struct alsa *alsa;
return SR_ERR;
alsa = sdi->priv;
- switch (capability) {
+ switch (hwcap) {
case SR_HWCAP_PROBECONFIG:
return SR_OK;
case SR_HWCAP_SAMPLERATE:
.closedev = hw_closedev,
.get_dev_info = hw_get_dev_info,
.get_status = hw_get_status,
- .get_capabilities = hw_get_capabilities,
+ .hwcap_get_all = hw_hwcap_get_all,
.set_configuration = hw_set_configuration,
.start_acquisition = hw_start_acquisition,
.stop_acquisition = hw_stop_acquisition,
supported_samplerates,
};
-static int capabilities[] = {
+static int hwcaps[] = {
SR_HWCAP_LOGIC_ANALYZER,
SR_HWCAP_SAMPLERATE,
SR_HWCAP_CAPTURE_RATIO,
return SR_ST_NOT_FOUND;
}
-static int *hw_get_capabilities(void)
+static int *hw_hwcap_get_all(void)
{
- return capabilities;
+ return hwcaps;
}
-static int hw_set_configuration(int dev_index, int capability, void *value)
+static int hw_set_configuration(int dev_index, int hwcap, void *value)
{
struct sr_dev_inst *sdi;
struct sigma *sigma;
sigma = sdi->priv;
- if (capability == SR_HWCAP_SAMPLERATE) {
+ if (hwcap == SR_HWCAP_SAMPLERATE) {
ret = set_samplerate(sdi, *(uint64_t*) value);
- } else if (capability == SR_HWCAP_PROBECONFIG) {
+ } else if (hwcap == SR_HWCAP_PROBECONFIG) {
ret = configure_probes(sdi, value);
- } else if (capability == SR_HWCAP_LIMIT_MSEC) {
+ } else if (hwcap == SR_HWCAP_LIMIT_MSEC) {
sigma->limit_msec = *(uint64_t*) value;
if (sigma->limit_msec > 0)
ret = SR_OK;
else
ret = SR_ERR;
- } else if (capability == SR_HWCAP_CAPTURE_RATIO) {
+ } else if (hwcap == SR_HWCAP_CAPTURE_RATIO) {
sigma->capture_ratio = *(uint64_t*) value;
if (sigma->capture_ratio < 0 || sigma->capture_ratio > 100)
ret = SR_ERR;
.closedev = hw_closedev,
.get_dev_info = hw_get_dev_info,
.get_status = hw_get_status,
- .get_capabilities = hw_get_capabilities,
+ .hwcap_get_all = hw_hwcap_get_all,
.set_configuration = hw_set_configuration,
.start_acquisition = hw_start_acquisition,
.stop_acquisition = hw_stop_acquisition,
};
/* Note: Continuous sampling is not supported by the hardware. */
-static int capabilities[] = {
+static int hwcaps[] = {
SR_HWCAP_LOGIC_ANALYZER,
SR_HWCAP_SAMPLERATE,
SR_HWCAP_LIMIT_MSEC, /* TODO: Not yet implemented. */
return sdi->status;
}
-static int *hw_get_capabilities(void)
+static int *hw_hwcap_get_all(void)
{
sr_spew("la8: entering %s", __func__);
- return capabilities;
+ return hwcaps;
}
-static int hw_set_configuration(int dev_index, int capability, void *value)
+static int hw_set_configuration(int dev_index, int hwcap, void *value)
{
struct sr_dev_inst *sdi;
struct la8 *la8;
return SR_ERR; /* TODO: SR_ERR_ARG? */
}
- switch (capability) {
+ switch (hwcap) {
case SR_HWCAP_SAMPLERATE:
if (set_samplerate(sdi, *(uint64_t *)value) == SR_ERR)
return SR_ERR;
.closedev = hw_closedev,
.get_dev_info = hw_get_dev_info,
.get_status = hw_get_status,
- .get_capabilities = hw_get_capabilities,
+ .hwcap_get_all = hw_hwcap_get_all,
.set_configuration = hw_set_configuration,
.start_acquisition = hw_start_acquisition,
.stop_acquisition = hw_stop_acquisition,
GTimer *timer;
};
-static int capabilities[] = {
+static int hwcaps[] = {
SR_HWCAP_LOGIC_ANALYZER,
SR_HWCAP_DEMO_DEV,
SR_HWCAP_SAMPLERATE,
return SR_ST_ACTIVE;
}
-static int *hw_get_capabilities(void)
+static int *hw_hwcap_get_all(void)
{
- return capabilities;
+ return hwcaps;
}
-static int hw_set_configuration(int dev_index, int capability, void *value)
+static int hw_set_configuration(int dev_index, int hwcap, void *value)
{
int ret;
char *stropt;
/* Avoid compiler warnings. */
(void)dev_index;
- if (capability == SR_HWCAP_PROBECONFIG) {
+ if (hwcap == SR_HWCAP_PROBECONFIG) {
/* Nothing to do, but must be supported */
ret = SR_OK;
- } else if (capability == SR_HWCAP_SAMPLERATE) {
+ } else if (hwcap == SR_HWCAP_SAMPLERATE) {
cur_samplerate = *(uint64_t *)value;
sr_dbg("demo: %s: setting samplerate to %" PRIu64, __func__,
cur_samplerate);
ret = SR_OK;
- } else if (capability == SR_HWCAP_LIMIT_SAMPLES) {
+ } else if (hwcap == SR_HWCAP_LIMIT_SAMPLES) {
limit_samples = *(uint64_t *)value;
sr_dbg("demo: %s: setting limit_samples to %" PRIu64, __func__,
limit_samples);
ret = SR_OK;
- } else if (capability == SR_HWCAP_LIMIT_MSEC) {
+ } else if (hwcap == SR_HWCAP_LIMIT_MSEC) {
limit_msec = *(uint64_t *)value;
sr_dbg("demo: %s: setting limit_msec to %" PRIu64, __func__,
limit_msec);
ret = SR_OK;
- } else if (capability == SR_HWCAP_PATTERN_MODE) {
+ } else if (hwcap == SR_HWCAP_PATTERN_MODE) {
stropt = value;
ret = SR_OK;
if (!strcmp(stropt, "sigrok")) {
.closedev = hw_closedev,
.get_dev_info = hw_get_dev_info,
.get_status = hw_get_status,
- .get_capabilities = hw_get_capabilities,
+ .hwcap_get_all = hw_hwcap_get_all,
.set_configuration = hw_set_configuration,
.start_acquisition = hw_start_acquisition,
.stop_acquisition = hw_stop_acquisition,
#define NUM_PROBES 8
-static int capabilities[] = {
+static int hwcaps[] = {
SR_HWCAP_LOGIC_ANALYZER,
// SR_HWCAP_OSCILLOSCOPE,
// SR_HWCAP_PAT_GENERATOR,
return sdi->status;
}
-static int *hw_get_capabilities(void)
+static int *hw_hwcap_get_all(void)
{
- return capabilities;
+ return hwcaps;
}
-static int hw_set_configuration(int dev_index, int capability, void *value)
+static int hw_set_configuration(int dev_index, int hwcap, void *value)
{
struct sr_dev_inst *sdi;
if (!(sdi = sr_dev_inst_get(dev_insts, dev_index)))
return SR_ERR;
- switch (capability) {
+ switch (hwcap) {
case SR_HWCAP_SAMPLERATE:
return mso_configure_rate(sdi, *(uint64_t *) value);
case SR_HWCAP_PROBECONFIG:
.closedev = hw_closedev,
.get_dev_info = hw_get_dev_info,
.get_status = hw_get_status,
- .get_capabilities = hw_get_capabilities,
+ .hwcap_get_all = hw_hwcap_get_all,
.set_configuration = hw_set_configuration,
.start_acquisition = hw_start_acquisition,
.stop_acquisition = hw_stop_acquisition,
#define O_NONBLOCK FIONBIO
#endif
-static int capabilities[] = {
+static int hwcaps[] = {
SR_HWCAP_LOGIC_ANALYZER,
SR_HWCAP_SAMPLERATE,
SR_HWCAP_CAPTURE_RATIO,
return sdi->status;
}
-static int *hw_get_capabilities(void)
+static int *hw_hwcap_get_all(void)
{
- return capabilities;
+ return hwcaps;
}
static int set_configuration_samplerate(struct sr_dev_inst *sdi,
return SR_OK;
}
-static int hw_set_configuration(int dev_index, int capability, void *value)
+static int hw_set_configuration(int dev_index, int hwcap, void *value)
{
struct sr_dev_inst *sdi;
struct ols_dev *ols;
if (sdi->status != SR_ST_ACTIVE)
return SR_ERR;
- switch (capability) {
+ switch (hwcap) {
case SR_HWCAP_SAMPLERATE:
tmp_u64 = value;
ret = set_configuration_samplerate(sdi, *tmp_u64);
.closedev = hw_closedev,
.get_dev_info = hw_get_dev_info,
.get_status = hw_get_status,
- .get_capabilities = hw_get_capabilities,
+ .hwcap_get_all = hw_hwcap_get_all,
.set_configuration = hw_set_configuration,
.start_acquisition = hw_start_acquisition,
.stop_acquisition = hw_stop_acquisition,
{ 0, 0, 0, 0, 0, 0, 0, 0 }
};
-static int capabilities[] = {
+static int hwcaps[] = {
SR_HWCAP_LOGIC_ANALYZER,
SR_HWCAP_SAMPLERATE,
static int new_saleae_logic_firmware = 0;
-static int hw_set_configuration(int dev_index, int capability, void *value);
+static int hw_set_configuration(int dev_index, int hwcap, void *value);
static int hw_stop_acquisition(int dev_index, gpointer session_dev_id);
/**
return SR_ST_NOT_FOUND;
}
-static int *hw_get_capabilities(void)
+static int *hw_hwcap_get_all(void)
{
- return capabilities;
+ return hwcaps;
}
static uint8_t new_firmware_divider_value(uint64_t samplerate)
return SR_OK;
}
-static int hw_set_configuration(int dev_index, int capability, void *value)
+static int hw_set_configuration(int dev_index, int hwcap, void *value)
{
struct sr_dev_inst *sdi;
struct fx2_dev *fx2;
return SR_ERR;
fx2 = sdi->priv;
- if (capability == SR_HWCAP_SAMPLERATE) {
+ if (hwcap == SR_HWCAP_SAMPLERATE) {
tmp_u64 = value;
ret = set_configuration_samplerate(sdi, *tmp_u64);
- } else if (capability == SR_HWCAP_PROBECONFIG) {
+ } else if (hwcap == SR_HWCAP_PROBECONFIG) {
ret = configure_probes(fx2, (GSList *) value);
- } else if (capability == SR_HWCAP_LIMIT_SAMPLES) {
+ } else if (hwcap == SR_HWCAP_LIMIT_SAMPLES) {
tmp_u64 = value;
fx2->limit_samples = *tmp_u64;
ret = SR_OK;
.closedev = hw_closedev,
.get_dev_info = hw_get_dev_info,
.get_status = hw_get_status,
- .get_capabilities = hw_get_capabilities,
+ .hwcap_get_all = hw_hwcap_get_all,
.set_configuration = hw_set_configuration,
.start_acquisition = hw_start_acquisition,
.stop_acquisition = hw_stop_acquisition,
{0x7016, "LAP-C(162000)", 16, 2048, 200},
};
-static int capabilities[] = {
+static int hwcaps[] = {
SR_HWCAP_LOGIC_ANALYZER,
SR_HWCAP_SAMPLERATE,
SR_HWCAP_PROBECONFIG,
struct sr_usb_dev_inst *usb;
};
-static int hw_set_configuration(int dev_index, int capability, void *value);
+static int hw_set_configuration(int dev_index, int hwcap, void *value);
static unsigned int get_memory_size(int type)
{
return SR_ST_NOT_FOUND;
}
-static int *hw_get_capabilities(void)
+static int *hw_hwcap_get_all(void)
{
- return capabilities;
+ return hwcaps;
}
static int set_configuration_samplerate(struct sr_dev_inst *sdi,
return SR_OK;
}
-static int hw_set_configuration(int dev_index, int capability, void *value)
+static int hw_set_configuration(int dev_index, int hwcap, void *value)
{
struct sr_dev_inst *sdi;
uint64_t *tmp_u64;
return SR_ERR_ARG;
}
- switch (capability) {
+ switch (hwcap) {
case SR_HWCAP_SAMPLERATE:
tmp_u64 = value;
return set_configuration_samplerate(sdi, *tmp_u64);
.closedev = hw_closedev,
.get_dev_info = hw_get_dev_info,
.get_status = hw_get_status,
- .get_capabilities = hw_get_capabilities,
+ .hwcap_get_all = hw_hwcap_get_all,
.set_configuration = hw_set_configuration,
.start_acquisition = hw_start_acquisition,
.stop_acquisition = hw_stop_acquisition,
*/
SR_API gboolean sr_hw_has_hwcap(struct sr_dev_plugin *plugin, int hwcap)
{
- int *capabilities, i;
+ int *hwcaps, i;
- capabilities = plugin->get_capabilities();
- for (i = 0; capabilities[i]; i++) {
- if (capabilities[i] == hwcap)
+ hwcaps = plugin->hwcap_get_all();
+ for (i = 0; hwcaps[i]; i++) {
+ if (hwcaps[i] == hwcap)
return TRUE;
}
{
int i;
- for (i = 0; sr_hwcap_options[i].capability; i++) {
- if (sr_hwcap_options[i].capability == hwcap)
+ for (i = 0; sr_hwcap_options[i].hwcap; i++) {
+ if (sr_hwcap_options[i].hwcap == hwcap)
return &sr_hwcap_options[i];
}
static char *sessionfile = NULL;
static GSList *dev_insts = NULL;
-static int capabilities[] = {
+static int hwcaps[] = {
SR_HWCAP_CAPTUREFILE,
SR_HWCAP_CAPTURE_UNITSIZE,
0,
* @return A pointer to the (hardware) capabilities of this virtual session
* driver. This could be NULL, if no such capabilities exist.
*/
-static int *hw_get_capabilities(void)
+static int *hw_hwcap_get_all(void)
{
- return capabilities;
+ return hwcaps;
}
-static int hw_set_configuration(int dev_index, int capability, void *value)
+static int hw_set_configuration(int dev_index, int hwcap, void *value)
{
struct session_vdev *vdev;
uint64_t *tmp_u64;
if (!(vdev = get_vdev_by_index(dev_index)))
return SR_ERR;
- switch (capability) {
+ switch (hwcap) {
case SR_HWCAP_SAMPLERATE:
tmp_u64 = value;
vdev->samplerate = *tmp_u64;
break;
default:
sr_err("session driver: %s: unknown capability %d requested",
- __func__, capability);
+ __func__, hwcap);
return SR_ERR;
}
NULL,
hw_get_dev_info,
hw_get_status,
- hw_get_capabilities,
+ hw_hwcap_get_all,
hw_set_configuration,
hw_start_acquisition,
NULL,
};
struct sr_hwcap_option {
- int capability;
+ int hwcap;
int type;
char *description;
char *shortname;
int (*closedev) (int dev_index);
void *(*get_dev_info) (int dev_index, int dev_info_id);
int (*get_status) (int dev_index);
- int *(*get_capabilities) (void);
- int (*set_configuration) (int dev_index, int capability, void *value);
+ int *(*hwcap_get_all) (void);
+ int (*set_configuration) (int dev_index, int hwcap, void *value);
int (*start_acquisition) (int dev_index, gpointer session_dev_id);
int (*stop_acquisition) (int dev_index, gpointer session_dev_id);
};