element_create_settings(p->elements, NULL);
}
-int pa_alsa_path_probe(pa_alsa_path *p, snd_mixer_t *m, snd_hctl_t *hctl, bool ignore_dB) {
+int pa_alsa_path_probe(pa_alsa_path *p, snd_mixer_t *m, bool ignore_dB) {
pa_alsa_element *e;
pa_alsa_jack *j;
double min_dB[PA_CHANNEL_POSITION_MAX], max_dB[PA_CHANNEL_POSITION_MAX];
snd_pcm_t *pcm_handle;
pa_alsa_path_set *ps;
snd_mixer_t *mixer_handle;
- snd_hctl_t *hctl_handle;
if (direction == PA_ALSA_DIRECTION_OUTPUT) {
if (m->output_path_set)
pa_assert(pcm_handle);
- mixer_handle = pa_alsa_open_mixer_for_pcm(pcm_handle, NULL, &hctl_handle);
+ mixer_handle = pa_alsa_open_mixer_for_pcm(pcm_handle, NULL);
if (!mixer_handle) {
/* Cannot open mixer, remove all entries */
pa_hashmap_remove_all(ps->paths);
}
PA_HASHMAP_FOREACH(p, ps->paths, state) {
- if (pa_alsa_path_probe(p, mixer_handle, hctl_handle, m->profile_set->ignore_dB) < 0) {
+ if (pa_alsa_path_probe(p, mixer_handle, m->profile_set->ignore_dB) < 0) {
pa_hashmap_remove(ps->paths, p);
}
}
pa_alsa_path *pa_alsa_path_new(const char *paths_dir, const char *fname, pa_alsa_direction_t direction);
pa_alsa_path *pa_alsa_path_synthesize(const char *element, pa_alsa_direction_t direction);
-int pa_alsa_path_probe(pa_alsa_path *p, snd_mixer_t *m, snd_hctl_t *hctl, bool ignore_dB);
+int pa_alsa_path_probe(pa_alsa_path *p, snd_mixer_t *m, bool ignore_dB);
void pa_alsa_path_dump(pa_alsa_path *p);
int pa_alsa_path_get_volume(pa_alsa_path *p, snd_mixer_t *m, const pa_channel_map *cm, pa_cvolume *v);
int pa_alsa_path_get_mute(pa_alsa_path *path, snd_mixer_t *m, bool *muted);
void pa_alsa_profile_set_dump(pa_alsa_profile_set *s);
void pa_alsa_profile_set_drop_unsupported(pa_alsa_profile_set *s);
-snd_mixer_t *pa_alsa_open_mixer_for_pcm(snd_pcm_t *pcm, char **ctl_device, snd_hctl_t **hctl);
+snd_mixer_t *pa_alsa_open_mixer_for_pcm(snd_pcm_t *pcm, char **ctl_device);
pa_alsa_fdlist *pa_alsa_fdlist_new(void);
void pa_alsa_fdlist_free(pa_alsa_fdlist *fdl);
}
static void find_mixer(struct userdata *u, pa_alsa_mapping *mapping, const char *element, bool ignore_dB) {
- snd_hctl_t *hctl;
-
if (!mapping && !element)
return;
- if (!(u->mixer_handle = pa_alsa_open_mixer_for_pcm(u->pcm_handle, &u->control_device, &hctl))) {
+ if (!(u->mixer_handle = pa_alsa_open_mixer_for_pcm(u->pcm_handle, &u->control_device))) {
pa_log_info("Failed to find a working mixer device.");
return;
}
if (!(u->mixer_path = pa_alsa_path_synthesize(element, PA_ALSA_DIRECTION_OUTPUT)))
goto fail;
- if (pa_alsa_path_probe(u->mixer_path, u->mixer_handle, hctl, ignore_dB) < 0)
+ if (pa_alsa_path_probe(u->mixer_path, u->mixer_handle, ignore_dB) < 0)
goto fail;
pa_log_debug("Probed mixer path %s:", u->mixer_path->name);
}
static void find_mixer(struct userdata *u, pa_alsa_mapping *mapping, const char *element, bool ignore_dB) {
- snd_hctl_t *hctl;
-
if (!mapping && !element)
return;
- if (!(u->mixer_handle = pa_alsa_open_mixer_for_pcm(u->pcm_handle, &u->control_device, &hctl))) {
+ if (!(u->mixer_handle = pa_alsa_open_mixer_for_pcm(u->pcm_handle, &u->control_device))) {
pa_log_info("Failed to find a working mixer device.");
return;
}
if (!(u->mixer_path = pa_alsa_path_synthesize(element, PA_ALSA_DIRECTION_INPUT)))
goto fail;
- if (pa_alsa_path_probe(u->mixer_path, u->mixer_handle, hctl, ignore_dB) < 0)
+ if (pa_alsa_path_probe(u->mixer_path, u->mixer_handle, ignore_dB) < 0)
goto fail;
pa_log_debug("Probed mixer path %s:", u->mixer_path->name);
static void ucm_mapping_jack_probe(pa_alsa_mapping *m) {
snd_pcm_t *pcm_handle;
snd_mixer_t *mixer_handle;
- snd_hctl_t *hctl_handle;
pa_alsa_ucm_mapping_context *context = &m->ucm_context;
pa_alsa_ucm_device *dev;
uint32_t idx;
pcm_handle = m->direction == PA_ALSA_DIRECTION_OUTPUT ? m->output_pcm : m->input_pcm;
- mixer_handle = pa_alsa_open_mixer_for_pcm(pcm_handle, NULL, &hctl_handle);
- if (!mixer_handle || !hctl_handle)
+ mixer_handle = pa_alsa_open_mixer_for_pcm(pcm_handle, NULL);
+ if (!mixer_handle)
return;
PA_IDXSET_FOREACH(dev, context->ucm_devices, idx) {
pa_alsa_jack *jack;
jack = m->direction == PA_ALSA_DIRECTION_OUTPUT ? dev->output_jack : dev->input_jack;
pa_assert (jack);
- jack->has_control = pa_alsa_find_jack(hctl_handle, jack->alsa_name) != NULL;
+ jack->has_control = pa_alsa_mixer_find(mixer_handle, jack->alsa_name, 0) != NULL;
pa_log_info("UCM jack %s has_control=%d", jack->name, jack->has_control);
}
return NULL;
}
-snd_hctl_elem_t* pa_alsa_find_jack(snd_hctl_t *hctl, const char* jack_name) {
- snd_ctl_elem_id_t *id;
-
- snd_ctl_elem_id_alloca(&id);
- snd_ctl_elem_id_clear(id);
- snd_ctl_elem_id_set_interface(id, SND_CTL_ELEM_IFACE_CARD);
- snd_ctl_elem_id_set_name(id, jack_name);
-
- return snd_hctl_find_elem(hctl, id);
-}
-
-snd_hctl_elem_t* pa_alsa_find_eld_ctl(snd_hctl_t *hctl, int device) {
- snd_ctl_elem_id_t *id;
-
- /* See if we can find the ELD control */
- snd_ctl_elem_id_alloca(&id);
- snd_ctl_elem_id_clear(id);
- snd_ctl_elem_id_set_interface(id, SND_CTL_ELEM_IFACE_PCM);
- snd_ctl_elem_id_set_name(id, "ELD");
- snd_ctl_elem_id_set_device(id, device);
-
- return snd_hctl_find_elem(hctl, id);
-}
-
static int mixer_class_compare(const snd_mixer_elem_t *c1, const snd_mixer_elem_t *c2)
{
/* Dummy compare function */
return 0;
}
-static int prepare_mixer(snd_mixer_t *mixer, const char *dev, snd_hctl_t **hctl) {
+static int prepare_mixer(snd_mixer_t *mixer, const char *dev) {
int err;
snd_mixer_class_t *class;
return -1;
}
- /* Note: The hctl handle returned should not be freed.
- It is closed/freed by alsa-lib on snd_mixer_close/free */
- if (hctl && (err = snd_mixer_get_hctl(mixer, dev, hctl)) < 0) {
- pa_log_info("Unable to get hctl of mixer %s: %s", dev, pa_alsa_strerror(err));
- return -1;
- }
-
if (snd_mixer_class_malloc(&class)) {
pa_log_info("Failed to allocate mixer class for %s", dev);
return -1;
return 0;
}
-snd_mixer_t *pa_alsa_open_mixer(int alsa_card_index, char **ctl_device, snd_hctl_t **hctl) {
+snd_mixer_t *pa_alsa_open_mixer(int alsa_card_index, char **ctl_device) {
int err;
snd_mixer_t *m;
char *md;
/* Then, try by card index */
md = pa_sprintf_malloc("hw:%i", alsa_card_index);
- if (prepare_mixer(m, md, hctl) >= 0) {
+ if (prepare_mixer(m, md) >= 0) {
if (ctl_device)
*ctl_device = md;
return NULL;
}
-snd_mixer_t *pa_alsa_open_mixer_for_pcm(snd_pcm_t *pcm, char **ctl_device, snd_hctl_t **hctl) {
+snd_mixer_t *pa_alsa_open_mixer_for_pcm(snd_pcm_t *pcm, char **ctl_device) {
int err;
snd_mixer_t *m;
const char *dev;
/* First, try by name */
if ((dev = snd_pcm_name(pcm)))
- if (prepare_mixer(m, dev, hctl) >= 0) {
+ if (prepare_mixer(m, dev) >= 0) {
if (ctl_device)
*ctl_device = pa_xstrdup(dev);
md = pa_sprintf_malloc("hw:%i", card_idx);
if (!dev || !pa_streq(dev, md))
- if (prepare_mixer(m, md, hctl) >= 0) {
+ if (prepare_mixer(m, md) >= 0) {
if (ctl_device)
*ctl_device = md;
return NULL;
}
-int pa_alsa_get_hdmi_eld(snd_hctl_t *hctl, int device, pa_hdmi_eld *eld) {
+int pa_alsa_get_hdmi_eld(snd_hctl_elem_t *elem, pa_hdmi_eld *eld) {
/* The ELD format is specific to HDA Intel sound cards and defined in the
HDA specification: http://www.intel.com/content/www/us/en/standards/high-definition-audio-specification.html */
int err;
- snd_hctl_elem_t *elem;
snd_ctl_elem_info_t *info;
snd_ctl_elem_value_t *value;
uint8_t *elddata;
unsigned int eldsize, mnl;
+ unsigned int device;
pa_assert(eld != NULL);
-
- /* See if we can find the ELD control */
- elem = pa_alsa_find_eld_ctl(hctl, device);
- if (elem == NULL) {
- pa_log_debug("No ELD info control found (for device=%d)", device);
- return -1;
- }
+ pa_assert(elem != NULL);
/* Does it have any contents? */
snd_ctl_elem_info_alloca(&info);
return -1;
}
+ device = snd_hctl_elem_get_device(elem);
eldsize = snd_ctl_elem_info_get_count(info);
elddata = (unsigned char *) snd_ctl_elem_value_get_bytes(value);
if (elddata == NULL || eldsize == 0) {
bool pa_alsa_may_tsched(bool want);
-snd_hctl_elem_t* pa_alsa_find_jack(snd_hctl_t *hctl, const char* jack_name);
-snd_hctl_elem_t* pa_alsa_find_eld_ctl(snd_hctl_t *hctl, int device);
-
snd_mixer_elem_t *pa_alsa_mixer_find(snd_mixer_t *mixer, const char *name, unsigned int device);
-snd_mixer_t *pa_alsa_open_mixer(int alsa_card_index, char **ctl_device, snd_hctl_t **hctl);
+snd_mixer_t *pa_alsa_open_mixer(int alsa_card_index, char **ctl_device);
typedef struct pa_hdmi_eld pa_hdmi_eld;
struct pa_hdmi_eld {
char monitor_name[17];
};
-int pa_alsa_get_hdmi_eld(snd_hctl_t *hctl, int device, pa_hdmi_eld *eld);
+int pa_alsa_get_hdmi_eld(snd_hctl_elem_t *elem, pa_hdmi_eld *eld);
#endif
int alsa_card_index;
snd_mixer_t *mixer_handle;
- snd_hctl_t *hctl_handle;
pa_hashmap *jacks;
pa_alsa_fdlist *mixer_fdl;
return 0;
}
- if (pa_alsa_get_hdmi_eld(u->hctl_handle, device, &eld) < 0)
+ if (pa_alsa_get_hdmi_eld(elem, &eld) < 0)
memset(&eld, 0, sizeof(eld));
old_monitor_name = pa_proplist_gets(p->proplist, PA_PROP_DEVICE_PRODUCT_NAME);
void *state;
pa_device_port *port;
- if (!u->hctl_handle)
+ if (!u->mixer_handle)
return;
PA_HASHMAP_FOREACH(port, u->card->ports, state) {
u->mixer_fdl = pa_alsa_fdlist_new();
- u->mixer_handle = pa_alsa_open_mixer(u->alsa_card_index, NULL, &u->hctl_handle);
+ u->mixer_handle = pa_alsa_open_mixer(u->alsa_card_index, NULL);
if (u->mixer_handle && pa_alsa_fdlist_set_handle(u->mixer_fdl, u->mixer_handle, NULL, u->core->mainloop) >= 0) {
PA_HASHMAP_FOREACH(jack, u->jacks, state) {
jack->melem = pa_alsa_mixer_find(u->mixer_handle, jack->alsa_name, 0);
}
} else
- pa_log("Failed to open hctl/mixer for jack detection");
+ pa_log("Failed to open mixer for jack detection");
}