• 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_alsa_profile_set *ps,
71         pa_alsa_mapping **mapping);       /* modified at return */
72 
73 /* Uses the specified mapping */
74 snd_pcm_t *pa_alsa_open_by_device_id_mapping(
75         const char *dev_id,
76         char **dev,                       /* modified at return */
77         pa_sample_spec *ss,               /* modified at return */
78         pa_channel_map* map,              /* modified at return */
79         int mode,
80         snd_pcm_uframes_t *period_size,   /* modified at return */
81         snd_pcm_uframes_t *buffer_size,   /* modified at return */
82         snd_pcm_uframes_t tsched_size,
83         bool *use_mmap,                   /* modified at return */
84         bool *use_tsched,                 /* modified at return */
85         pa_alsa_mapping *mapping);
86 
87 /* Opens the explicit ALSA device */
88 snd_pcm_t *pa_alsa_open_by_device_string(
89         const char *dir,
90         char **dev,                       /* modified at return */
91         pa_sample_spec *ss,               /* modified at return */
92         pa_channel_map* map,              /* modified at return */
93         int mode,
94         snd_pcm_uframes_t *period_size,   /* modified at return */
95         snd_pcm_uframes_t *buffer_size,   /* modified at return */
96         snd_pcm_uframes_t tsched_size,
97         bool *use_mmap,                   /* modified at return */
98         bool *use_tsched,                 /* modified at return */
99         bool require_exact_channel_number);
100 
101 /* Opens the explicit ALSA device with a fallback list */
102 snd_pcm_t *pa_alsa_open_by_template(
103         char **template,
104         const char *dev_id,
105         char **dev,                       /* modified at return */
106         pa_sample_spec *ss,               /* modified at return */
107         pa_channel_map* map,              /* modified at return */
108         int mode,
109         snd_pcm_uframes_t *period_size,   /* modified at return */
110         snd_pcm_uframes_t *buffer_size,   /* modified at return */
111         snd_pcm_uframes_t tsched_size,
112         bool *use_mmap,                   /* modified at return */
113         bool *use_tsched,                 /* modified at return */
114         bool require_exact_channel_number);
115 
116 void pa_alsa_dump(pa_log_level_t level, snd_pcm_t *pcm);
117 void pa_alsa_dump_status(snd_pcm_t *pcm);
118 
119 void pa_alsa_refcnt_inc(void);
120 void pa_alsa_refcnt_dec(void);
121 
122 void pa_alsa_init_proplist_pcm_info(pa_core *c, pa_proplist *p, snd_pcm_info_t *pcm_info);
123 void pa_alsa_init_proplist_card(pa_core *c, pa_proplist *p, int card);
124 void pa_alsa_init_proplist_pcm(pa_core *c, pa_proplist *p, snd_pcm_t *pcm);
125 void pa_alsa_init_proplist_ctl(pa_proplist *p, const char *name);
126 bool pa_alsa_init_description(pa_proplist *p, pa_card *card);
127 
128 int pa_alsa_recover_from_poll(snd_pcm_t *pcm, int revents);
129 
130 pa_rtpoll_item* pa_alsa_build_pollfd(snd_pcm_t *pcm, pa_rtpoll *rtpoll);
131 
132 snd_pcm_sframes_t pa_alsa_safe_avail(snd_pcm_t *pcm, size_t hwbuf_size, const pa_sample_spec *ss);
133 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);
134 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);
135 
136 char *pa_alsa_get_driver_name(int card);
137 char *pa_alsa_get_driver_name_by_pcm(snd_pcm_t *pcm);
138 
139 char *pa_alsa_get_reserve_name(const char *device);
140 
141 unsigned int *pa_alsa_get_supported_rates(snd_pcm_t *pcm, unsigned int fallback_rate);
142 pa_sample_format_t *pa_alsa_get_supported_formats(snd_pcm_t *pcm, pa_sample_format_t fallback_format);
143 
144 bool pa_alsa_pcm_is_hw(snd_pcm_t *pcm);
145 bool pa_alsa_pcm_is_modem(snd_pcm_t *pcm);
146 
147 const char* pa_alsa_strerror(int errnum);
148 
149 bool pa_alsa_may_tsched(bool want);
150 
151 snd_mixer_elem_t *pa_alsa_mixer_find_card(snd_mixer_t *mixer, struct pa_alsa_mixer_id *alsa_id, unsigned int device);
152 snd_mixer_elem_t *pa_alsa_mixer_find_pcm(snd_mixer_t *mixer, const char *name, unsigned int device);
153 
154 snd_mixer_t *pa_alsa_open_mixer(pa_hashmap *mixers, int alsa_card_index, bool probe);
155 snd_mixer_t *pa_alsa_open_mixer_by_name(pa_hashmap *mixers, const char *dev, bool probe);
156 snd_mixer_t *pa_alsa_open_mixer_for_pcm(pa_hashmap *mixers, snd_pcm_t *pcm, bool probe);
157 void pa_alsa_mixer_set_fdlist(pa_hashmap *mixers, snd_mixer_t *mixer, pa_mainloop_api *ml);
158 void pa_alsa_mixer_free(pa_alsa_mixer *mixer);
159 
160 typedef struct pa_hdmi_eld pa_hdmi_eld;
161 struct pa_hdmi_eld {
162     char monitor_name[17];
163 };
164 
165 int pa_alsa_get_hdmi_eld(snd_hctl_elem_t *elem, pa_hdmi_eld *eld);
166 
167 #endif
168