Remove pa_bool_t and replace it with bool
[platform/upstream/pulseaudio.git] / src / modules / alsa / alsa-util.h
1 #ifndef fooalsautilhfoo
2 #define fooalsautilhfoo
3
4 /***
5   This file is part of PulseAudio.
6
7   Copyright 2004-2006 Lennart Poettering
8   Copyright 2006 Pierre Ossman <ossman@cendio.se> for Cendio AB
9
10   PulseAudio is free software; you can redistribute it and/or modify
11   it under the terms of the GNU Lesser General Public License as published
12   by the Free Software Foundation; either version 2.1 of the License,
13   or (at your option) any later version.
14
15   PulseAudio is distributed in the hope that it will be useful, but
16   WITHOUT ANY WARRANTY; without even the implied warranty of
17   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
18   General Public License for more details.
19
20   You should have received a copy of the GNU Lesser General Public License
21   along with PulseAudio; if not, write to the Free Software
22   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
23   USA.
24 ***/
25
26 #include <asoundlib.h>
27
28 #include <pulse/sample.h>
29 #include <pulse/channelmap.h>
30 #include <pulse/proplist.h>
31
32 #include <pulsecore/rtpoll.h>
33 #include <pulsecore/core.h>
34 #include <pulsecore/log.h>
35
36 #include "alsa-mixer.h"
37
38 int pa_alsa_set_hw_params(
39         snd_pcm_t *pcm_handle,
40         pa_sample_spec *ss,                /* modified at return */
41         snd_pcm_uframes_t *period_size,    /* modified at return */
42         snd_pcm_uframes_t *buffer_size,    /* modified at return */
43         snd_pcm_uframes_t tsched_size,
44         bool *use_mmap,                    /* modified at return */
45         bool *use_tsched,                  /* modified at return */
46         bool require_exact_channel_number);
47
48 #ifdef __TIZEN__
49 int pa_alsa_set_sw_params(
50         snd_pcm_t *pcm,
51         snd_pcm_uframes_t avail_min,
52         bool period_event,
53         int start_threshold,
54         int sampling_rate );
55 #else
56 int pa_alsa_set_sw_params(
57         snd_pcm_t *pcm,
58         snd_pcm_uframes_t avail_min,
59         bool period_event);
60 #endif
61
62 /* Picks a working mapping from the profile set based on the specified ss/map */
63 snd_pcm_t *pa_alsa_open_by_device_id_auto(
64 #ifdef __TIZEN__
65         pa_core *c,
66 #endif
67         const char *dev_id,
68         char **dev,                       /* modified at return */
69         pa_sample_spec *ss,               /* modified at return */
70         pa_channel_map* map,              /* modified at return */
71         int mode,
72         snd_pcm_uframes_t *period_size,   /* modified at return */
73         snd_pcm_uframes_t *buffer_size,   /* modified at return */
74         snd_pcm_uframes_t tsched_size,
75         bool *use_mmap,                   /* modified at return */
76         bool *use_tsched,                 /* modified at return */
77         pa_alsa_profile_set *ps,
78         pa_alsa_mapping **mapping);       /* modified at return */
79
80 /* Uses the specified mapping */
81 snd_pcm_t *pa_alsa_open_by_device_id_mapping(
82 #ifdef __TIZEN__
83         pa_core *c,
84 #endif
85         const char *dev_id,
86         char **dev,                       /* modified at return */
87         pa_sample_spec *ss,               /* modified at return */
88         pa_channel_map* map,              /* modified at return */
89         int mode,
90         snd_pcm_uframes_t *period_size,   /* modified at return */
91         snd_pcm_uframes_t *buffer_size,   /* modified at return */
92         snd_pcm_uframes_t tsched_size,
93         bool *use_mmap,                   /* modified at return */
94         bool *use_tsched,                 /* modified at return */
95         pa_alsa_mapping *mapping);
96
97 /* Opens the explicit ALSA device */
98 snd_pcm_t *pa_alsa_open_by_device_string(
99 #ifdef __TIZEN__
100         pa_core *c,
101 #endif
102         const char *dir,
103         char **dev,                       /* modified at return */
104         pa_sample_spec *ss,               /* modified at return */
105         pa_channel_map* map,              /* modified at return */
106         int mode,
107         snd_pcm_uframes_t *period_size,   /* modified at return */
108         snd_pcm_uframes_t *buffer_size,   /* modified at return */
109         snd_pcm_uframes_t tsched_size,
110         bool *use_mmap,                   /* modified at return */
111         bool *use_tsched,                 /* modified at return */
112         bool require_exact_channel_number);
113
114 /* Opens the explicit ALSA device with a fallback list */
115 snd_pcm_t *pa_alsa_open_by_template(
116 #ifdef __TIZEN__
117         pa_core *c,
118 #endif
119         char **template,
120         const char *dev_id,
121         char **dev,                       /* modified at return */
122         pa_sample_spec *ss,               /* modified at return */
123         pa_channel_map* map,              /* modified at return */
124         int mode,
125         snd_pcm_uframes_t *period_size,   /* modified at return */
126         snd_pcm_uframes_t *buffer_size,   /* modified at return */
127         snd_pcm_uframes_t tsched_size,
128         bool *use_mmap,                   /* modified at return */
129         bool *use_tsched,                 /* modified at return */
130         bool require_exact_channel_number);
131
132 void pa_alsa_dump(pa_log_level_t level, snd_pcm_t *pcm);
133 void pa_alsa_dump_status(snd_pcm_t *pcm);
134
135 void pa_alsa_refcnt_inc(void);
136 void pa_alsa_refcnt_dec(void);
137
138 void pa_alsa_init_proplist_pcm_info(pa_core *c, pa_proplist *p, snd_pcm_info_t *pcm_info);
139 void pa_alsa_init_proplist_card(pa_core *c, pa_proplist *p, int card);
140 void pa_alsa_init_proplist_pcm(pa_core *c, pa_proplist *p, snd_pcm_t *pcm);
141 void pa_alsa_init_proplist_ctl(pa_proplist *p, const char *name);
142 bool pa_alsa_init_description(pa_proplist *p);
143
144 int pa_alsa_recover_from_poll(snd_pcm_t *pcm, int revents);
145
146 pa_rtpoll_item* pa_alsa_build_pollfd(snd_pcm_t *pcm, pa_rtpoll *rtpoll);
147
148 snd_pcm_sframes_t pa_alsa_safe_avail(snd_pcm_t *pcm, size_t hwbuf_size, const pa_sample_spec *ss);
149 int pa_alsa_safe_delay(snd_pcm_t *pcm, snd_pcm_status_t *status, snd_pcm_sframes_t *delay, size_t hwbuf_size, const pa_sample_spec *ss, bool capture);
150 int pa_alsa_safe_mmap_begin(snd_pcm_t *pcm, const snd_pcm_channel_area_t **areas, snd_pcm_uframes_t *offset, snd_pcm_uframes_t *frames, size_t hwbuf_size, const pa_sample_spec *ss);
151
152 char *pa_alsa_get_driver_name(int card);
153 char *pa_alsa_get_driver_name_by_pcm(snd_pcm_t *pcm);
154
155 char *pa_alsa_get_reserve_name(const char *device);
156
157 unsigned int *pa_alsa_get_supported_rates(snd_pcm_t *pcm, unsigned int fallback_rate);
158
159 bool pa_alsa_pcm_is_hw(snd_pcm_t *pcm);
160 bool pa_alsa_pcm_is_modem(snd_pcm_t *pcm);
161 #ifdef __TIZEN__
162 bool pa_alsa_pcm_is_voip(snd_pcm_t *pcm);
163 #endif
164
165 const char* pa_alsa_strerror(int errnum);
166
167 bool pa_alsa_may_tsched(bool want);
168
169 snd_hctl_elem_t* pa_alsa_find_jack(snd_hctl_t *hctl, const char* jack_name);
170 snd_hctl_elem_t* pa_alsa_find_eld_ctl(snd_hctl_t *hctl, int device);
171
172 snd_mixer_t *pa_alsa_open_mixer(int alsa_card_index, char **ctl_device, snd_hctl_t **hctl);
173
174 typedef struct pa_hdmi_eld pa_hdmi_eld;
175 struct pa_hdmi_eld {
176     char monitor_name[17];
177 };
178
179 int pa_alsa_get_hdmi_eld(snd_hctl_t *hctl, int device, pa_hdmi_eld *eld);
180
181 #ifdef __TIZEN__
182 int pa_alsa_set_mixer_control(const char *ctl_name, int val);
183 #endif
184
185 #endif