Add sr_ prefix for device related API functions.

This commit is contained in:
Uwe Hermann 2011-02-08 18:19:38 +01:00
parent 60679b18e6
commit 2bf4aca64a
10 changed files with 46 additions and 46 deletions

View File

@ -28,5 +28,5 @@ int sr_init(void)
/* TODO: Should return int to be able to report back error codes. */ /* TODO: Should return int to be able to report back error codes. */
void sr_exit(void) void sr_exit(void)
{ {
device_close_all(); sr_device_close_all();
} }

View File

@ -25,7 +25,7 @@ extern struct sr_global *global;
GSList *devices = NULL; GSList *devices = NULL;
void device_scan(void) void sr_device_scan(void)
{ {
GSList *plugins, *l; GSList *plugins, *l;
struct sr_device_plugin *plugin; struct sr_device_plugin *plugin;
@ -39,12 +39,12 @@ void device_scan(void)
*/ */
for (l = plugins; l; l = l->next) { for (l = plugins; l; l = l->next) {
plugin = l->data; plugin = l->data;
device_plugin_init(plugin); sr_device_plugin_init(plugin);
} }
} }
int device_plugin_init(struct sr_device_plugin *plugin) int sr_device_plugin_init(struct sr_device_plugin *plugin)
{ {
int num_devices, num_probes, i; int num_devices, num_probes, i;
@ -52,13 +52,13 @@ int device_plugin_init(struct sr_device_plugin *plugin)
num_devices = plugin->init(NULL); num_devices = plugin->init(NULL);
for (i = 0; i < num_devices; i++) { for (i = 0; i < num_devices; i++) {
num_probes = (int)plugin->get_device_info(i, SR_DI_NUM_PROBES); num_probes = (int)plugin->get_device_info(i, SR_DI_NUM_PROBES);
device_new(plugin, i, num_probes); sr_device_new(plugin, i, num_probes);
} }
return num_devices; return num_devices;
} }
void device_close_all(void) void sr_device_close_all(void)
{ {
struct sr_device *device; struct sr_device *device;
@ -66,20 +66,20 @@ void device_close_all(void)
device = devices->data; device = devices->data;
if (device->plugin && device->plugin->close) if (device->plugin && device->plugin->close)
device->plugin->close(device->plugin_index); device->plugin->close(device->plugin_index);
device_destroy(device); sr_device_destroy(device);
} }
} }
GSList *device_list(void) GSList *sr_device_list(void)
{ {
if (!devices) if (!devices)
device_scan(); sr_device_scan();
return devices; return devices;
} }
struct sr_device *device_new(struct sr_device_plugin *plugin, int plugin_index, struct sr_device *sr_device_new(struct sr_device_plugin *plugin, int plugin_index,
int num_probes) int num_probes)
{ {
struct sr_device *device; struct sr_device *device;
@ -91,12 +91,12 @@ struct sr_device *device_new(struct sr_device_plugin *plugin, int plugin_index,
devices = g_slist_append(devices, device); devices = g_slist_append(devices, device);
for (i = 0; i < num_probes; i++) for (i = 0; i < num_probes; i++)
device_probe_add(device, NULL); sr_device_probe_add(device, NULL);
return device; return device;
} }
void device_clear(struct sr_device *device) void sr_device_clear(struct sr_device *device)
{ {
unsigned int pnum; unsigned int pnum;
@ -106,10 +106,10 @@ void device_clear(struct sr_device *device)
return; return;
for (pnum = 1; pnum <= g_slist_length(device->probes); pnum++) for (pnum = 1; pnum <= g_slist_length(device->probes); pnum++)
device_probe_clear(device, pnum); sr_device_probe_clear(device, pnum);
} }
void device_destroy(struct sr_device *device) void sr_device_destroy(struct sr_device *device)
{ {
unsigned int pnum; unsigned int pnum;
@ -121,13 +121,13 @@ void device_destroy(struct sr_device *device)
devices = g_slist_remove(devices, device); devices = g_slist_remove(devices, device);
if (device->probes) { if (device->probes) {
for (pnum = 1; pnum <= g_slist_length(device->probes); pnum++) for (pnum = 1; pnum <= g_slist_length(device->probes); pnum++)
device_probe_clear(device, pnum); sr_device_probe_clear(device, pnum);
g_slist_free(device->probes); g_slist_free(device->probes);
} }
g_free(device); g_free(device);
} }
void device_probe_clear(struct sr_device *device, int probenum) void sr_device_probe_clear(struct sr_device *device, int probenum)
{ {
struct sr_probe *p; struct sr_probe *p;
@ -146,7 +146,7 @@ void device_probe_clear(struct sr_device *device, int probenum)
} }
} }
void device_probe_add(struct sr_device *device, char *name) void sr_device_probe_add(struct sr_device *device, char *name)
{ {
struct sr_probe *p; struct sr_probe *p;
char probename[16]; char probename[16];
@ -184,7 +184,7 @@ struct sr_probe *probe_find(struct sr_device *device, int probenum)
} }
/* TODO: return SIGROK_ERR if probenum not found */ /* TODO: return SIGROK_ERR if probenum not found */
void device_probe_name(struct sr_device *device, int probenum, char *name) void sr_device_probe_name(struct sr_device *device, int probenum, char *name)
{ {
struct sr_probe *p; struct sr_probe *p;
@ -198,7 +198,7 @@ void device_probe_name(struct sr_device *device, int probenum, char *name)
} }
/* TODO: return SIGROK_ERR if probenum not found */ /* TODO: return SIGROK_ERR if probenum not found */
void device_trigger_clear(struct sr_device *device) void sr_device_trigger_clear(struct sr_device *device)
{ {
struct sr_probe *p; struct sr_probe *p;
unsigned int pnum; unsigned int pnum;
@ -216,7 +216,7 @@ void device_trigger_clear(struct sr_device *device)
} }
/* TODO: return SIGROK_ERR if probenum not found */ /* TODO: return SIGROK_ERR if probenum not found */
void device_trigger_set(struct sr_device *device, int probenum, char *trigger) void sr_device_trigger_set(struct sr_device *device, int probenum, char *trigger)
{ {
struct sr_probe *p; struct sr_probe *p;
@ -231,7 +231,7 @@ void device_trigger_set(struct sr_device *device, int probenum, char *trigger)
} }
gboolean device_has_hwcap(struct sr_device *device, int hwcap) gboolean sr_device_has_hwcap(struct sr_device *device, int hwcap)
{ {
int *capabilities, i; int *capabilities, i;

View File

@ -51,7 +51,7 @@ static int init(struct sr_input *in)
num_probes = DEFAULT_NUM_PROBES; num_probes = DEFAULT_NUM_PROBES;
/* create a virtual device */ /* create a virtual device */
in->vdevice = device_new(NULL, 0, num_probes); in->vdevice = sr_device_new(NULL, 0, num_probes);
return SR_OK; return SR_OK;
} }

View File

@ -133,7 +133,7 @@ static int init(struct sr_output *o, int default_spl, enum outputmode mode)
snprintf(ctx->header, 511, "%s\n", PACKAGE_STRING); snprintf(ctx->header, 511, "%s\n", PACKAGE_STRING);
num_probes = g_slist_length(o->device->probes); num_probes = g_slist_length(o->device->probes);
if (o->device->plugin && device_has_hwcap(o->device, SR_HWCAP_SAMPLERATE)) { if (o->device->plugin && sr_device_has_hwcap(o->device, SR_HWCAP_SAMPLERATE)) {
samplerate = *((uint64_t *) o->device->plugin->get_device_info( samplerate = *((uint64_t *) o->device->plugin->get_device_info(
o->device->plugin_index, SR_DI_CUR_SAMPLERATE)); o->device->plugin_index, SR_DI_CUR_SAMPLERATE));
if (!(samplerate_s = sr_samplerate_string(samplerate))) { if (!(samplerate_s = sr_samplerate_string(samplerate))) {

View File

@ -79,7 +79,7 @@ static int init(struct sr_output *o)
num_probes = g_slist_length(o->device->probes); num_probes = g_slist_length(o->device->probes);
comment[0] = '\0'; comment[0] = '\0';
if (o->device->plugin && device_has_hwcap(o->device, SR_HWCAP_SAMPLERATE)) { if (o->device->plugin && sr_device_has_hwcap(o->device, SR_HWCAP_SAMPLERATE)) {
samplerate = *((uint64_t *) o->device->plugin->get_device_info( samplerate = *((uint64_t *) o->device->plugin->get_device_info(
o->device->plugin_index, SR_DI_CUR_SAMPLERATE)); o->device->plugin_index, SR_DI_CUR_SAMPLERATE));
if (!(frequency_s = sr_samplerate_string(samplerate))) { if (!(frequency_s = sr_samplerate_string(samplerate))) {
@ -226,7 +226,7 @@ static int analog_init(struct sr_output *o)
num_probes = g_slist_length(o->device->probes); num_probes = g_slist_length(o->device->probes);
comment[0] = '\0'; comment[0] = '\0';
if (o->device->plugin && device_has_hwcap(o->device, SR_HWCAP_SAMPLERATE)) { if (o->device->plugin && sr_device_has_hwcap(o->device, SR_HWCAP_SAMPLERATE)) {
samplerate = *((uint64_t *) o->device->plugin->get_device_info( samplerate = *((uint64_t *) o->device->plugin->get_device_info(
o->device->plugin_index, SR_DI_CUR_SAMPLERATE)); o->device->plugin_index, SR_DI_CUR_SAMPLERATE));
if (!(frequency_s = sr_samplerate_string(samplerate))) { if (!(frequency_s = sr_samplerate_string(samplerate))) {

View File

@ -48,7 +48,7 @@ static void make_header(struct sr_output *o)
ctx = o->internal; ctx = o->internal;
if (o->device->plugin && device_has_hwcap(o->device, SR_HWCAP_SAMPLERATE)) if (o->device->plugin && sr_device_has_hwcap(o->device, SR_HWCAP_SAMPLERATE))
samplerate = *((uint64_t *) o->device->plugin->get_device_info( samplerate = *((uint64_t *) o->device->plugin->get_device_info(
o->device->plugin_index, SR_DI_CUR_SAMPLERATE)); o->device->plugin_index, SR_DI_CUR_SAMPLERATE));
else else

View File

@ -91,7 +91,7 @@ static int init(struct sr_output *o)
g_string_append_printf(ctx->header, "$version %s %s $end\n", g_string_append_printf(ctx->header, "$version %s %s $end\n",
PACKAGE, PACKAGE_VERSION); PACKAGE, PACKAGE_VERSION);
if (o->device->plugin && device_has_hwcap(o->device, SR_HWCAP_SAMPLERATE)) { if (o->device->plugin && sr_device_has_hwcap(o->device, SR_HWCAP_SAMPLERATE)) {
ctx->samplerate = *((uint64_t *) o->device->plugin->get_device_info( ctx->samplerate = *((uint64_t *) o->device->plugin->get_device_info(
o->device->plugin_index, SR_DI_CUR_SAMPLERATE)); o->device->plugin_index, SR_DI_CUR_SAMPLERATE));
if (!((samplerate_s = sr_samplerate_string(ctx->samplerate)))) { if (!((samplerate_s = sr_samplerate_string(ctx->samplerate)))) {

View File

@ -107,7 +107,7 @@ int init(struct sr_output *o, int default_spl, enum outputmode mode)
snprintf(ctx->header, 511, "%s\n", PACKAGE_STRING); snprintf(ctx->header, 511, "%s\n", PACKAGE_STRING);
num_probes = g_slist_length(o->device->probes); num_probes = g_slist_length(o->device->probes);
if (o->device->plugin || device_has_hwcap(o->device, SR_HWCAP_SAMPLERATE)) { if (o->device->plugin || sr_device_has_hwcap(o->device, SR_HWCAP_SAMPLERATE)) {
samplerate = *((uint64_t *) o->device->plugin->get_device_info( samplerate = *((uint64_t *) o->device->plugin->get_device_info(
o->device->plugin_index, SR_DI_CUR_SAMPLERATE)); o->device->plugin_index, SR_DI_CUR_SAMPLERATE));
if (!(samplerate_s = sr_samplerate_string(samplerate))) { if (!(samplerate_s = sr_samplerate_string(samplerate))) {

View File

@ -94,7 +94,7 @@ int sr_session_load(const char *filename)
for (j = 0; keys[j]; j++) { for (j = 0; keys[j]; j++) {
val = g_key_file_get_string(kf, sections[i], keys[j], NULL); val = g_key_file_get_string(kf, sections[i], keys[j], NULL);
if (!strcmp(keys[j], "capturefile")) { if (!strcmp(keys[j], "capturefile")) {
device = device_new(&session_driver, devcnt, 0); device = sr_device_new(&session_driver, devcnt, 0);
if (devcnt == 0) if (devcnt == 0)
/* first device, init the plugin */ /* first device, init the plugin */
device->plugin->init((char *)filename); device->plugin->init((char *)filename);
@ -111,16 +111,16 @@ int sr_session_load(const char *filename)
total_probes = strtoull(val, NULL, 10); total_probes = strtoull(val, NULL, 10);
device->plugin->set_configuration(devcnt, SR_HWCAP_CAPTURE_NUM_PROBES, &total_probes); device->plugin->set_configuration(devcnt, SR_HWCAP_CAPTURE_NUM_PROBES, &total_probes);
for (p = 1; p <= total_probes; p++) for (p = 1; p <= total_probes; p++)
device_probe_add(device, NULL); sr_device_probe_add(device, NULL);
} else if (!strncmp(keys[j], "probe", 5)) { } else if (!strncmp(keys[j], "probe", 5)) {
if (!device) if (!device)
continue; continue;
enabled_probes++; enabled_probes++;
tmp_u64 = strtoul(keys[j]+5, NULL, 10); tmp_u64 = strtoul(keys[j]+5, NULL, 10);
device_probe_name(device, tmp_u64, val); sr_device_probe_name(device, tmp_u64, val);
} else if (!strncmp(keys[j], "trigger", 7)) { } else if (!strncmp(keys[j], "trigger", 7)) {
probenum = strtoul(keys[j]+7, NULL, 10); probenum = strtoul(keys[j]+7, NULL, 10);
device_trigger_set(device, probenum, val); sr_device_trigger_set(device, probenum, val);
} }
} }
g_strfreev(keys); g_strfreev(keys);
@ -189,7 +189,7 @@ int sr_session_save(char *filename)
fprintf(meta, "capturefile = logic-%d\n", devcnt); fprintf(meta, "capturefile = logic-%d\n", devcnt);
fprintf(meta, "unitsize = %d\n", ds->ds_unitsize); fprintf(meta, "unitsize = %d\n", ds->ds_unitsize);
fprintf(meta, "total probes = %d\n", g_slist_length(device->probes)); fprintf(meta, "total probes = %d\n", g_slist_length(device->probes));
if (device_has_hwcap(device, SR_HWCAP_SAMPLERATE)) { if (sr_device_has_hwcap(device, SR_HWCAP_SAMPLERATE)) {
samplerate = *((uint64_t *) device->plugin->get_device_info( samplerate = *((uint64_t *) device->plugin->get_device_info(
device->plugin_index, SR_DI_CUR_SAMPLERATE)); device->plugin_index, SR_DI_CUR_SAMPLERATE));
s = sr_samplerate_string(samplerate); s = sr_samplerate_string(samplerate);

View File

@ -34,23 +34,23 @@ void datastore_put(struct datastore *ds, void *data, unsigned int length,
/*--- device.c --------------------------------------------------------------*/ /*--- device.c --------------------------------------------------------------*/
void device_scan(void); void sr_device_scan(void);
int device_plugin_init(struct sr_device_plugin *plugin); int sr_device_plugin_init(struct sr_device_plugin *plugin);
void device_close_all(void); void sr_device_close_all(void);
GSList *device_list(void); GSList *sr_device_list(void);
struct sr_device *device_new(struct sr_device_plugin *plugin, int plugin_index, struct sr_device *sr_device_new(struct sr_device_plugin *plugin, int plugin_index,
int num_probes); int num_probes);
void device_clear(struct sr_device *device); void sr_device_clear(struct sr_device *device);
void device_destroy(struct sr_device *dev); void sr_device_destroy(struct sr_device *dev);
void device_probe_clear(struct sr_device *device, int probenum); void sr_device_probe_clear(struct sr_device *device, int probenum);
void device_probe_add(struct sr_device *device, char *name); void sr_device_probe_add(struct sr_device *device, char *name);
struct sr_probe *probe_find(struct sr_device *device, int probenum); struct sr_probe *probe_find(struct sr_device *device, int probenum);
void device_probe_name(struct sr_device *device, int probenum, char *name); void sr_device_probe_name(struct sr_device *device, int probenum, char *name);
void device_trigger_clear(struct sr_device *device); void sr_device_trigger_clear(struct sr_device *device);
void device_trigger_set(struct sr_device *device, int probenum, char *trigger); void sr_device_trigger_set(struct sr_device *device, int probenum, char *trigger);
gboolean device_has_hwcap(struct sr_device *device, int hwcap); gboolean sr_device_has_hwcap(struct sr_device *device, int hwcap);
/*--- filter.c --------------------------------------------------------------*/ /*--- filter.c --------------------------------------------------------------*/