From 3c4c1f4945b309b3eba11ca67c010469c7ff9256 Mon Sep 17 00:00:00 2001 From: Lennart Poettering Date: Mon, 8 Jun 2009 16:59:47 +0200 Subject: udev: reshuffle the properties we read from udev a bit --- src/modules/udev-util.c | 23 ++++++++++++++++++----- 1 file changed, 18 insertions(+), 5 deletions(-) (limited to 'src/modules/udev-util.c') diff --git a/src/modules/udev-util.c b/src/modules/udev-util.c index 144ad797..de8f5f2f 100644 --- a/src/modules/udev-util.c +++ b/src/modules/udev-util.c @@ -84,6 +84,19 @@ int pa_udev_get_info(pa_core *core, pa_proplist *p, int card_idx) { goto finish; } + if (!pa_proplist_contains(p, PA_PROP_DEVICE_BUS_PATH)) + if (((v = udev_device_get_property_value(card, "ID_PATH")) && *v) || + (v = udev_device_get_devpath(card))) + pa_proplist_sets(p, PA_PROP_DEVICE_BUS_PATH, v); + + if (!pa_proplist_contains(p, "sysfs.path")) + if ((v = udev_device_get_devpath(card))) + pa_proplist_sets(p, "sysfs.path", v); + + if (!pa_proplist_contains(p, "udev.id")) + if ((v = udev_device_get_property_value(card, "ID_ID")) && *v) + pa_proplist_sets(p, "udev.id", v); + if (!pa_proplist_contains(p, PA_PROP_DEVICE_BUS)) if ((v = udev_device_get_property_value(card, "ID_BUS")) && *v) pa_proplist_sets(p, PA_PROP_DEVICE_BUS, v); @@ -114,15 +127,15 @@ int pa_udev_get_info(pa_core *core, pa_proplist *p, int card_idx) { if ((v = udev_device_get_property_value(card, "ID_SERIAL")) && *v) pa_proplist_sets(p, PA_PROP_DEVICE_SERIAL, v); + if (!pa_proplist_contains(p, PA_PROP_DEVICE_CLASS)) + if ((v = udev_device_get_property_value(card, "SOUND_CLASS")) && *v) + pa_proplist_sets(p, PA_PROP_DEVICE_CLASS, v); + if (!pa_proplist_contains(p, PA_PROP_DEVICE_FORM_FACTOR)) if ((v = udev_device_get_property_value(card, "SOUND_FORM_FACTOR")) && *v) pa_proplist_sets(p, PA_PROP_DEVICE_FORM_FACTOR, v); - if (!pa_proplist_contains(p, PA_PROP_DEVICE_BUS_PATH)) - if ((v = udev_device_get_devpath(card))) - pa_proplist_sets(p, PA_PROP_DEVICE_BUS_PATH, v); - - /* This is normaly not set by th udev rules but may be useful to + /* This is normaly not set by the udev rules but may be useful to * allow administrators to overwrite the device description.*/ if (!pa_proplist_contains(p, PA_PROP_DEVICE_DESCRIPTION)) if ((v = udev_device_get_property_value(card, "SOUND_DESCRIPTION")) && *v) -- cgit From 31575f7766d6ff39665b64a3a04412eff1c39957 Mon Sep 17 00:00:00 2001 From: Lennart Poettering Date: Wed, 17 Jun 2009 03:45:14 +0200 Subject: alsa: rework mixer logic Completely rework mixer logic. This now allows controlling a full set of elements from a single sink's volume slider/mute button. This also introduces sink and source "ports" that can be used to choose different input or output ports with the UI. (i.e. "mic"/"line-in" or "speaker"/"headphones". The mixer paths and device maps are now configered in external configuration files and can be tweaked as necessary. --- src/modules/udev-util.c | 40 ++++++++++++++++++++++++++++++++++++++-- 1 file changed, 38 insertions(+), 2 deletions(-) (limited to 'src/modules/udev-util.c') diff --git a/src/modules/udev-util.c b/src/modules/udev-util.c index de8f5f2f..cc824465 100644 --- a/src/modules/udev-util.c +++ b/src/modules/udev-util.c @@ -58,7 +58,7 @@ static int read_id(struct udev_device *d, const char *n) { return u; } -int pa_udev_get_info(pa_core *core, pa_proplist *p, int card_idx) { +int pa_udev_get_info(int card_idx, pa_proplist *p) { int r = -1; struct udev *udev; struct udev_device *card = NULL; @@ -66,7 +66,6 @@ int pa_udev_get_info(pa_core *core, pa_proplist *p, int card_idx) { const char *v; int id; - pa_assert(core); pa_assert(p); pa_assert(card_idx >= 0); @@ -153,3 +152,40 @@ finish: return r; } + +char* pa_udev_get_property(int card_idx, const char *name) { + struct udev *udev; + struct udev_device *card = NULL; + char *t, *r = NULL; + const char *v; + + pa_assert(card_idx >= 0); + pa_assert(name); + + if (!(udev = udev_new())) { + pa_log_error("Failed to allocate udev context."); + goto finish; + } + + t = pa_sprintf_malloc("%s/class/sound/card%i", udev_get_sys_path(udev), card_idx); + card = udev_device_new_from_syspath(udev, t); + pa_xfree(t); + + if (!card) { + pa_log_error("Failed to get card object."); + goto finish; + } + + if ((v = udev_device_get_property_value(card, name)) && *v) + r = pa_xstrdup(v); + +finish: + + if (card) + udev_device_unref(card); + + if (udev) + udev_unref(udev); + + return r; +} -- cgit