]> sigrok.org Git - libsigrok.git/blame - hardware/alsa/protocol.h
alsa: Do not use snd_pcm_hw_params_set_rate_near()
[libsigrok.git] / hardware / alsa / protocol.h
CommitLineData
9cd9f6b7
AG
1/*
2 * This file is part of the libsigrok project.
3 *
4 * Copyright (C) 2011 Daniel Ribeiro <drwyrm@gmail.com>
5 * Copyright (C) 2012 Uwe Hermann <uwe@hermann-uwe.de>
6 * Copyright (C) 2012 Alexandru Gagniuc <mr.nuke.me@gmail.com>
7 *
8 * This program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License as published by
10 * the Free Software Foundation; either version 2 of the License, or
11 * (at your option) any later version.
12 *
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
17 *
18 * You should have received a copy of the GNU General Public License
19 * along with this program; if not, write to the Free Software
20 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
21 */
22
23#ifndef LIBSIGROK_HARDWARE_ALSA_PROTOCOL_H
24#define LIBSIGROK_HARDWARE_ALSA_PROTOCOL_H
25
26#include "libsigrok.h"
27#include "libsigrok-internal.h"
28
29#include <alsa/asoundlib.h>
30#include <stdint.h>
31
32/* Message logging helpers with driver-specific prefix string. */
33#define DRIVER_LOG_DOMAIN "alsa: "
34#define sr_log(l, s, args...) sr_log(l, DRIVER_LOG_DOMAIN s, ## args)
35#define sr_spew(s, args...) sr_spew(DRIVER_LOG_DOMAIN s, ## args)
36#define sr_dbg(s, args...) sr_dbg(DRIVER_LOG_DOMAIN s, ## args)
37#define sr_info(s, args...) sr_info(DRIVER_LOG_DOMAIN s, ## args)
38#define sr_warn(s, args...) sr_warn(DRIVER_LOG_DOMAIN s, ## args)
39#define sr_err(s, args...) sr_err(DRIVER_LOG_DOMAIN s, ## args)
40
41/** Private, per-device-instance driver context. */
42struct dev_context {
43 uint64_t cur_samplerate;
44 uint64_t limit_samples;
45 uint64_t num_samples;
46 uint8_t num_probes;
47 snd_pcm_t *capture_handle;
48 snd_pcm_hw_params_t *hw_params;
49 struct pollfd *ufds;
50 void *cb_data;
51};
52
53SR_PRIV int alsa_receive_data(int fd, int revents, void *cb_data);
54
55#endif /* LIBSIGROK_HARDWARE_ALSA_PROTOCOL_H */