From: Bert Vermeulen Date: Sun, 8 Jul 2012 12:56:54 +0000 (+0200) Subject: sr: move SR_HWOPT into its own enum, and create struct sr_hwopt X-Git-Tag: dsupstream~845 X-Git-Url: http://sigrok.org/gitweb/?a=commitdiff_plain;h=b159add3d9e3804f7806e82b01374fa099610668;p=libsigrok.git sr: move SR_HWOPT into its own enum, and create struct sr_hwopt SR_HWOPT_* entries are driver options, not device instance parameters, so they will never be mixed together. Also, driver options are always passed in a GSList, where the data field is a struct sr_hwopt. --- diff --git a/hwdriver.c b/hwdriver.c index 7a9e7e66..42932b36 100644 --- a/hwdriver.c +++ b/hwdriver.c @@ -32,6 +32,11 @@ */ /* TODO: This shouldn't be a global. */ SR_API struct sr_hwcap_option sr_hwcap_options[] = { + /* Driver scanning options. */ + {SR_HWOPT_MODEL, SR_T_KEYVALUE, "Model", "model"}, + {SR_HWOPT_CONN, SR_T_CHAR, "Connection", "conn"}, + {SR_HWOPT_SERIALCOMM, SR_T_CHAR, "Serial communication", "serialcomm"}, + /* Device instance options. */ {SR_HWCAP_SAMPLERATE, SR_T_UINT64, "Sample rate", "samplerate"}, {SR_HWCAP_CAPTURE_RATIO, SR_T_UINT64, "Pre-trigger capture ratio", "captureratio"}, {SR_HWCAP_PATTERN_MODE, SR_T_CHAR, "Pattern generator mode", "pattern"}, @@ -45,9 +50,6 @@ SR_API struct sr_hwcap_option sr_hwcap_options[] = { {SR_HWCAP_FILTER, SR_T_CHAR, "Filter targets", "filter"}, {SR_HWCAP_VDIV, SR_T_RATIONAL_VOLT, "Volts/div", "vdiv"}, {SR_HWCAP_COUPLING, SR_T_CHAR, "Coupling", "coupling"}, - {SR_HWCAP_MODEL, SR_T_KEYVALUE, "Model", "model"}, - {SR_HWCAP_CONN, SR_T_CHAR, "Connection", "connect"}, - {SR_HWCAP_SERIALCOMM, SR_T_CHAR, "Serial communication", "serialcomm"}, {0, 0, NULL, NULL}, }; diff --git a/libsigrok.h b/libsigrok.h index ccad393c..0ba97bce 100644 --- a/libsigrok.h +++ b/libsigrok.h @@ -261,7 +261,24 @@ struct sr_probe { char *trigger; }; -/* Hardware driver capabilities */ +struct sr_hwopt { + int hwopt; + const void *value; +}; + +/* Hardware driver options */ +enum { + /** Some drivers cannot detect the exact model they're talking to. */ + SR_HWOPT_MODEL, + + /** Specification on how to connect to a device */ + SR_HWOPT_CONN, + + /** Serial communication spec: e.g. 8n1 */ + SR_HWOPT_SERIALCOMM, +}; + +/* Hardware device capabilities */ enum { SR_HWCAP_DUMMY = 0, /* Used to terminate lists. Must be 0! */ @@ -280,17 +297,6 @@ enum { SR_HWCAP_DEMO_DEV, - /*--- Device communication ------------------------------------------*/ - /** Some drivers cannot detect the exact model they're talking to. */ - SR_HWCAP_MODEL, - - /** Specification on how to connect to a device */ - SR_HWCAP_CONN, - - /** Serial communication spec: e.g. 8n1 */ - SR_HWCAP_SERIALCOMM, - - /*--- Device configuration ------------------------------------------*/ /** The device supports setting/changing its samplerate. */