X-Git-Url: https://sigrok.org/gitweb/?a=blobdiff_plain;f=hardware%2Falsa%2Falsa.c;h=3ddadcb937f6838919d439bae547eadd5916db52;hb=3bbd9849e9dc5fdc9fe18a4394abe4d4b43ac9d4;hp=2ff25f2b5a1eba08d6959428f6637ca4b35d0eb9;hpb=e46b8fb154ba90ffec9c1f805399dfa819e736f9;p=libsigrok.git diff --git a/hardware/alsa/alsa.c b/hardware/alsa/alsa.c index 2ff25f2b..3ddadcb9 100644 --- a/hardware/alsa/alsa.c +++ b/hardware/alsa/alsa.c @@ -30,9 +30,9 @@ #define AUDIO_DEV "plughw:0,0" static int capabilities[] = { - HWCAP_SAMPLERATE, - HWCAP_LIMIT_SAMPLES, - HWCAP_CONTINUOUS, + SR_HWCAP_SAMPLERATE, + SR_HWCAP_LIMIT_SAMPLES, + SR_HWCAP_CONTINUOUS, }; static GSList *device_instances = NULL; @@ -47,7 +47,7 @@ struct alsa { static int hw_init(char *deviceinfo) { - struct sigrok_device_instance *sdi; + struct sr_device_instance *sdi; struct alsa *alsa; /* Avoid compiler warnings. */ @@ -58,7 +58,7 @@ static int hw_init(char *deviceinfo) return 0; memset(alsa, 0, sizeof(struct alsa)); - sdi = sigrok_device_instance_new(0, ST_ACTIVE, "alsa", NULL, NULL); + sdi = sr_device_instance_new(0, SR_ST_ACTIVE, "alsa", NULL, NULL); if (!sdi) goto free_alsa; @@ -74,11 +74,11 @@ free_alsa: static int hw_opendev(int device_index) { - struct sigrok_device_instance *sdi; + struct sr_device_instance *sdi; struct alsa *alsa; int err; - if (!(sdi = get_sigrok_device_instance(device_instances, device_index))) + if (!(sdi = sr_get_device_instance(device_instances, device_index))) return SR_ERR; alsa = sdi->priv; @@ -109,10 +109,10 @@ static int hw_opendev(int device_index) static void hw_closedev(int device_index) { - struct sigrok_device_instance *sdi; + struct sr_device_instance *sdi; struct alsa *alsa; - if (!(sdi = get_sigrok_device_instance(device_instances, device_index))) + if (!(sdi = sr_get_device_instance(device_instances, device_index))) return; alsa = sdi->priv; if (!alsa) @@ -126,37 +126,37 @@ static void hw_closedev(int device_index) static void hw_cleanup(void) { - struct sigrok_device_instance *sdi; + struct sr_device_instance *sdi; - if (!(sdi = get_sigrok_device_instance(device_instances, 0))) + if (!(sdi = sr_get_device_instance(device_instances, 0))) return; free(sdi->priv); - sigrok_device_instance_free(sdi); + sr_device_instance_free(sdi); } static void *hw_get_device_info(int device_index, int device_info_id) { - struct sigrok_device_instance *sdi; + struct sr_device_instance *sdi; struct alsa *alsa; void *info = NULL; - if (!(sdi = get_sigrok_device_instance(device_instances, device_index))) + if (!(sdi = sr_get_device_instance(device_instances, device_index))) return NULL; alsa = sdi->priv; switch (device_info_id) { - case DI_INSTANCE: + case SR_DI_INSTANCE: info = sdi; break; - case DI_NUM_PROBES: + case SR_DI_NUM_PROBES: info = GINT_TO_POINTER(NUM_PROBES); break; - case DI_CUR_SAMPLERATE: + case SR_DI_CUR_SAMPLERATE: info = &alsa->cur_rate; break; - // case DI_PROBE_TYPE: - // info = GINT_TO_POINTER(PROBE_TYPE_ANALOG); + // case SR_DI_PROBE_TYPE: + // info = GINT_TO_POINTER(SR_PROBE_TYPE_ANALOG); // break; } @@ -168,7 +168,7 @@ static int hw_get_status(int device_index) /* Avoid compiler warnings. */ device_index = device_index; - return ST_ACTIVE; + return SR_ST_ACTIVE; } static int *hw_get_capabilities(void) @@ -178,20 +178,20 @@ static int *hw_get_capabilities(void) static int hw_set_configuration(int device_index, int capability, void *value) { - struct sigrok_device_instance *sdi; + struct sr_device_instance *sdi; struct alsa *alsa; - if (!(sdi = get_sigrok_device_instance(device_instances, device_index))) + if (!(sdi = sr_get_device_instance(device_instances, device_index))) return SR_ERR; alsa = sdi->priv; switch (capability) { - case HWCAP_PROBECONFIG: + case SR_HWCAP_PROBECONFIG: return SR_OK; - case HWCAP_SAMPLERATE: + case SR_HWCAP_SAMPLERATE: alsa->cur_rate = *(uint64_t *) value; return SR_OK; - case HWCAP_LIMIT_SAMPLES: + case SR_HWCAP_LIMIT_SAMPLES: alsa->limit_samples = *(uint64_t *) value; return SR_OK; default: @@ -201,9 +201,9 @@ static int hw_set_configuration(int device_index, int capability, void *value) static int receive_data(int fd, int revents, void *user_data) { - struct sigrok_device_instance *sdi = user_data; + struct sr_device_instance *sdi = user_data; struct alsa *alsa = sdi->priv; - struct datafeed_packet packet; + struct sr_datafeed_packet packet; struct analog_sample *sample; unsigned int sample_size = sizeof(struct analog_sample) + (NUM_PROBES * sizeof(struct analog_probe)); @@ -240,7 +240,7 @@ static int receive_data(int fd, int revents, void *user_data) } } - packet.type = DF_ANALOG; + packet.type = SR_DF_ANALOG; packet.length = count * sample_size; packet.unitsize = sample_size; packet.payload = outb; @@ -250,7 +250,7 @@ static int receive_data(int fd, int revents, void *user_data) } while (alsa->limit_samples > 0); - packet.type = DF_END; + packet.type = SR_DF_END; session_bus(user_data, &packet); return TRUE; @@ -258,15 +258,15 @@ static int receive_data(int fd, int revents, void *user_data) static int hw_start_acquisition(int device_index, gpointer session_device_id) { - struct sigrok_device_instance *sdi; + struct sr_device_instance *sdi; struct alsa *alsa; - struct datafeed_packet packet; - struct datafeed_header header; + struct sr_datafeed_packet packet; + struct sr_datafeed_header header; struct pollfd *ufds; int count; int err; - if (!(sdi = get_sigrok_device_instance(device_instances, device_index))) + if (!(sdi = sr_get_device_instance(device_instances, device_index))) return SR_ERR; alsa = sdi->priv; @@ -333,15 +333,15 @@ static int hw_start_acquisition(int device_index, gpointer session_device_id) alsa->session_id = session_device_id; source_add(ufds[0].fd, ufds[0].events, 10, receive_data, sdi); - packet.type = DF_HEADER; - packet.length = sizeof(struct datafeed_header); + packet.type = SR_DF_HEADER; + packet.length = sizeof(struct sr_datafeed_header); packet.payload = (unsigned char *) &header; header.feed_version = 1; gettimeofday(&header.starttime, NULL); header.samplerate = alsa->cur_rate; header.num_analog_probes = NUM_PROBES; header.num_logic_probes = 0; - header.protocol_id = PROTO_RAW; + header.protocol_id = SR_PROTO_RAW; session_bus(session_device_id, &packet); free(ufds); @@ -355,8 +355,9 @@ static void hw_stop_acquisition(int device_index, gpointer session_device_id) session_device_id = session_device_id; } -struct device_plugin alsa_plugin_info = { +struct sr_device_plugin alsa_plugin_info = { "alsa", + "ALSA driver", 1, hw_init, hw_cleanup,