• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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, see <http://www.gnu.org/licenses/>.
22 ***/
23 
24 #include <alsa/asoundlib.h>
25 
26 #include <pulse/sample.h>
27 #include <pulse/channelmap.h>
28 #include <pulse/proplist.h>
29 
30 #include <pulsecore/rtpoll.h>
31 #include <pulsecore/core.h>
32 #include <pulsecore/log.h>
33 
34 #include "alsa-mixer.h"
35 
36 enum {
37     PA_ALSA_ERR_UNSPECIFIED = 1,
38     PA_ALSA_ERR_UCM_OPEN = 1000,
39     PA_ALSA_ERR_UCM_NO_VERB = 1001,
40     PA_ALSA_ERR_UCM_LINKED = 1002
41 };
42 
43 int pa_alsa_set_hw_params(
44         snd_pcm_t *pcm_handle,
45         pa_sample_spec *ss,                /* modified at return */
46         snd_pcm_uframes_t *period_size,    /* modified at return */
47         snd_pcm_uframes_t *buffer_size,    /* modified at return */
48         snd_pcm_uframes_t tsched_size,
49         bool *use_mmap,                    /* modified at return */
50         bool *use_tsched,                  /* modified at return */
51         bool require_exact_channel_number);
52 
53 int pa_alsa_set_sw_params(
54         snd_pcm_t *pcm,
55         snd_pcm_uframes_t avail_min,
56         bool period_event);
57 
58 /* Picks a working mapping from the profile set based on the specified ss/map */
59 snd_pcm_t *pa_alsa_open_by_device_id_auto(
60         const char *dev_id,
61         char **dev,                       /* modified at return */
62         pa_sample_spec *ss,               /* modified at return */
63         pa_channel_map* map,              /* modified at return */
64         int mode,
65         snd_pcm_uframes_t *period_size,   /* modified at return */
66         snd_pcm_uframes_t *buffer_size,   /* modified at return */
67         snd_pcm_uframes_t tsched_size,
68         bool *use_mmap,                   /* modified at return */
69         bool *use_tsched,                 /* modified at return */
70         pa_sample_format_t **query_supported_formats, /* modified at return */
71         unsigned int **query_supported_rates,         /* modified at return */
72         pa_alsa_profile_set *ps,
73         pa_alsa_mapping **mapping);       /* modified at return */
74 
75 /* Uses the specified mapping */
76 snd_pcm_t *pa_alsa_open_by_device_id_mapping(
77         const char *dev_id,
78         char **dev,                       /* modified at return */
79         pa_sample_spec *ss,               /* modified at return */
80         pa_channel_map* map,              /* modified at return */
81         int mode,
82         snd_pcm_uframes_t *period_size,   /* modified at return */
83         snd_pcm_uframes_t *buffer_size,   /* modified at return */
84         snd_pcm_uframes_t tsched_size,
85         bool *use_mmap,                   /* modified at return */
86         bool *use_tsched,                 /* modified at return */
87         pa_sample_format_t **query_supported_formats, /* modified at return */
88         unsigned int **query_supported_rates,         /* modified at return */
89         pa_alsa_mapping *mapping);
90 
91 /* Opens the explicit ALSA device */
92 snd_pcm_t *pa_alsa_open_by_device_string(
93         const char *dir,
94         char **dev,                       /* modified at return */
95         pa_sample_spec *ss,               /* modified at return */
96         pa_channel_map* map,              /* modified at return */
97         int mode,
98         snd_pcm_uframes_t *period_size,   /* modified at return */
99         snd_pcm_uframes_t *buffer_size,   /* modified at return */
100         snd_pcm_uframes_t tsched_size,
101         bool *use_mmap,                   /* modified at return */
102         bool *use_tsched,                 /* modified at return */
103         pa_sample_format_t **query_supported_formats, /* modified at return */
104         unsigned int **query_supported_rates,         /* modified at return */
105         bool require_exact_channel_number);
106 
107 /* Opens the explicit ALSA device with a fallback list */
108 snd_pcm_t *pa_alsa_open_by_template(
109         char **template,
110         const char *dev_id,
111         char **dev,                       /* modified at return */
112         pa_sample_spec *ss,               /* modified at return */
113         pa_channel_map* map,              /* modified at return */
114         int mode,
115         snd_pcm_uframes_t *period_size,   /* modified at return */
116         snd_pcm_uframes_t *buffer_size,   /* modified at return */
117         snd_pcm_uframes_t tsched_size,
118         bool *use_mmap,                   /* modified at return */
119         bool *use_tsched,                 /* modified at return */
120         pa_sample_format_t **query_supported_formats, /* modified at return */
121         unsigned int **query_supported_rates,        /* modified at return */
122         bool require_exact_channel_number);
123 
124 void pa_alsa_dump(pa_log_level_t level, snd_pcm_t *pcm);
125 void pa_alsa_dump_status(snd_pcm_t *pcm);
126 
127 void pa_alsa_refcnt_inc(void);
128 void pa_alsa_refcnt_dec(void);
129 
130 void pa_alsa_init_proplist_pcm_info(pa_core *c, pa_proplist *p, snd_pcm_info_t *pcm_info);
131 void pa_alsa_init_proplist_card(pa_core *c, pa_proplist *p, int card);
132 void pa_alsa_init_proplist_pcm(pa_core *c, pa_proplist *p, snd_pcm_t *pcm);
133 void pa_alsa_init_proplist_ctl(pa_proplist *p, const char *name);
134 bool pa_alsa_init_description(pa_proplist *p, pa_card *card);
135 
136 int pa_alsa_recover_from_poll(snd_pcm_t *pcm, int revents);
137 
138 pa_rtpoll_item* pa_alsa_build_pollfd(snd_pcm_t *pcm, pa_rtpoll *rtpoll);
139 
140 snd_pcm_sframes_t pa_alsa_safe_avail(snd_pcm_t *pcm, size_t hwbuf_size, const pa_sample_spec *ss);
141 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);
142 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);
143 
144 char *pa_alsa_get_driver_name(int card);
145 char *pa_alsa_get_driver_name_by_pcm(snd_pcm_t *pcm);
146 
147 char *pa_alsa_get_reserve_name(const char *device);
148 
149 unsigned int *pa_alsa_get_supported_rates(snd_pcm_t *pcm, unsigned int fallback_rate);
150 pa_sample_format_t *pa_alsa_get_supported_formats(snd_pcm_t *pcm, pa_sample_format_t fallback_format);
151 
152 bool pa_alsa_pcm_is_hw(snd_pcm_t *pcm);
153 bool pa_alsa_pcm_is_modem(snd_pcm_t *pcm);
154 
155 const char* pa_alsa_strerror(int errnum);
156 
157 bool pa_alsa_may_tsched(bool want);
158 
159 snd_mixer_elem_t *pa_alsa_mixer_find_card(snd_mixer_t *mixer, struct pa_alsa_mixer_id *alsa_id, unsigned int device);
160 snd_mixer_elem_t *pa_alsa_mixer_find_pcm(snd_mixer_t *mixer, const char *name, unsigned int device);
161 
162 snd_mixer_t *pa_alsa_open_mixer(pa_hashmap *mixers, int alsa_card_index, bool probe);
163 snd_mixer_t *pa_alsa_open_mixer_by_name(pa_hashmap *mixers, const char *dev, bool probe);
164 snd_mixer_t *pa_alsa_open_mixer_for_pcm(pa_hashmap *mixers, snd_pcm_t *pcm, bool probe);
165 void pa_alsa_mixer_set_fdlist(pa_hashmap *mixers, snd_mixer_t *mixer, pa_mainloop_api *ml);
166 void pa_alsa_mixer_free(pa_alsa_mixer *mixer);
167 
168 typedef struct pa_hdmi_eld pa_hdmi_eld;
169 struct pa_hdmi_eld {
170     char monitor_name[17];
171 };
172 
173 int pa_alsa_get_hdmi_eld(snd_hctl_elem_t *elem, pa_hdmi_eld *eld);
174 
175 #endif
176