"Fossies" - the Fresh Open Source Software Archive

Member "pulseaudio-13.0/src/modules/alsa/alsa-ucm.h" (13 Sep 2019, 7046 Bytes) of package /linux/misc/pulseaudio-13.0.tar.xz:


As a special service "Fossies" has tried to format the requested source page into HTML format using (guessed) C and C++ source code syntax highlighting (style: standard) with prefixed line numbers and code folding option. Alternatively you can here view or download the uninterpreted source code file. For more information about "alsa-ucm.h" see the Fossies "Dox" file reference documentation and the latest Fossies "Diffs" side-by-side code changes report: 12.2_vs_13.0.

    1 #ifndef fooalsaucmhfoo
    2 #define fooalsaucmhfoo
    3 
    4 /***
    5   This file is part of PulseAudio.
    6 
    7   Copyright 2011 Wolfson Microelectronics PLC
    8   Author Margarita Olaya <magi@slimlogic.co.uk>
    9   Copyright 2012 Feng Wei <wei.feng@freescale.com>, Freescale Ltd.
   10 
   11   PulseAudio is free software; you can redistribute it and/or modify
   12   it under the terms of the GNU Lesser General Public License as published
   13   by the Free Software Foundation; either version 2.1 of the License,
   14   or (at your option) any later version.
   15 
   16   PulseAudio is distributed in the hope that it will be useful, but
   17   WITHOUT ANY WARRANTY; without even the implied warranty of
   18   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
   19   General Public License for more details.
   20 
   21   You should have received a copy of the GNU Lesser General Public License
   22   along with PulseAudio; if not, see <http://www.gnu.org/licenses/>.
   23 ***/
   24 
   25 #ifdef HAVE_ALSA_UCM
   26 #include <alsa/use-case.h>
   27 #else
   28 typedef void snd_use_case_mgr_t;
   29 #endif
   30 
   31 #include "alsa-mixer.h"
   32 
   33 /** For devices: List of verbs, devices or modifiers available */
   34 #define PA_ALSA_PROP_UCM_NAME                       "alsa.ucm.name"
   35 
   36 /** For devices: List of supported devices per verb*/
   37 #define PA_ALSA_PROP_UCM_DESCRIPTION                "alsa.ucm.description"
   38 
   39 /** For devices: Playback device name e.g PlaybackPCM */
   40 #define PA_ALSA_PROP_UCM_SINK                       "alsa.ucm.sink"
   41 
   42 /** For devices: Capture device name e.g CapturePCM*/
   43 #define PA_ALSA_PROP_UCM_SOURCE                     "alsa.ucm.source"
   44 
   45 /** For devices: Playback roles */
   46 #define PA_ALSA_PROP_UCM_PLAYBACK_ROLES             "alsa.ucm.playback.roles"
   47 
   48 /** For devices: Playback control volume ID string. e.g PlaybackVolume */
   49 #define PA_ALSA_PROP_UCM_PLAYBACK_VOLUME            "alsa.ucm.playback.volume"
   50 
   51 /** For devices: Playback switch e.g PlaybackSwitch */
   52 #define PA_ALSA_PROP_UCM_PLAYBACK_SWITCH            "alsa.ucm.playback.switch"
   53 
   54 /** For devices: Playback priority */
   55 #define PA_ALSA_PROP_UCM_PLAYBACK_PRIORITY          "alsa.ucm.playback.priority"
   56 
   57 /** For devices: Playback rate */
   58 #define PA_ALSA_PROP_UCM_PLAYBACK_RATE              "alsa.ucm.playback.rate"
   59 
   60 /** For devices: Playback channels */
   61 #define PA_ALSA_PROP_UCM_PLAYBACK_CHANNELS          "alsa.ucm.playback.channels"
   62 
   63 /** For devices: Capture roles */
   64 #define PA_ALSA_PROP_UCM_CAPTURE_ROLES              "alsa.ucm.capture.roles"
   65 
   66 /** For devices: Capture controls volume ID string. e.g CaptureVolume */
   67 #define PA_ALSA_PROP_UCM_CAPTURE_VOLUME             "alsa.ucm.capture.volume"
   68 
   69 /** For devices: Capture switch e.g CaptureSwitch */
   70 #define PA_ALSA_PROP_UCM_CAPTURE_SWITCH             "alsa.ucm.capture.switch"
   71 
   72 /** For devices: Capture priority */
   73 #define PA_ALSA_PROP_UCM_CAPTURE_PRIORITY           "alsa.ucm.capture.priority"
   74 
   75 /** For devices: Capture rate */
   76 #define PA_ALSA_PROP_UCM_CAPTURE_RATE               "alsa.ucm.capture.rate"
   77 
   78 /** For devices: Capture channels */
   79 #define PA_ALSA_PROP_UCM_CAPTURE_CHANNELS           "alsa.ucm.capture.channels"
   80 
   81 /** For devices: Quality of Service */
   82 #define PA_ALSA_PROP_UCM_QOS                        "alsa.ucm.qos"
   83 
   84 /** For devices: The modifier (if any) that this device corresponds to */
   85 #define PA_ALSA_PROP_UCM_MODIFIER "alsa.ucm.modifier"
   86 
   87 /* Corresponds to the "JackControl" UCM value. */
   88 #define PA_ALSA_PROP_UCM_JACK_CONTROL               "alsa.ucm.jack_control"
   89 
   90 /* Corresponds to the "JackHWMute" UCM value. */
   91 #define PA_ALSA_PROP_UCM_JACK_HW_MUTE               "alsa.ucm.jack_hw_mute"
   92 
   93 typedef struct pa_alsa_ucm_verb pa_alsa_ucm_verb;
   94 typedef struct pa_alsa_ucm_modifier pa_alsa_ucm_modifier;
   95 typedef struct pa_alsa_ucm_device pa_alsa_ucm_device;
   96 typedef struct pa_alsa_ucm_config pa_alsa_ucm_config;
   97 typedef struct pa_alsa_ucm_mapping_context pa_alsa_ucm_mapping_context;
   98 
   99 int pa_alsa_ucm_query_profiles(pa_alsa_ucm_config *ucm, int card_index);
  100 pa_alsa_profile_set* pa_alsa_ucm_add_profile_set(pa_alsa_ucm_config *ucm, pa_channel_map *default_channel_map);
  101 int pa_alsa_ucm_set_profile(pa_alsa_ucm_config *ucm, const char *new_profile, const char *old_profile);
  102 
  103 int pa_alsa_ucm_get_verb(snd_use_case_mgr_t *uc_mgr, const char *verb_name, const char *verb_desc, pa_alsa_ucm_verb **p_verb);
  104 
  105 void pa_alsa_ucm_add_ports(
  106         pa_hashmap **hash,
  107         pa_proplist *proplist,
  108         pa_alsa_ucm_mapping_context *context,
  109         bool is_sink,
  110         pa_card *card);
  111 void pa_alsa_ucm_add_ports_combination(
  112         pa_hashmap *hash,
  113         pa_alsa_ucm_mapping_context *context,
  114         bool is_sink,
  115         pa_hashmap *ports,
  116         pa_card_profile *cp,
  117         pa_core *core);
  118 int pa_alsa_ucm_set_port(pa_alsa_ucm_mapping_context *context, pa_device_port *port, bool is_sink);
  119 
  120 void pa_alsa_ucm_free(pa_alsa_ucm_config *ucm);
  121 void pa_alsa_ucm_mapping_context_free(pa_alsa_ucm_mapping_context *context);
  122 
  123 void pa_alsa_ucm_roled_stream_begin(pa_alsa_ucm_config *ucm, const char *role, pa_direction_t dir);
  124 void pa_alsa_ucm_roled_stream_end(pa_alsa_ucm_config *ucm, const char *role, pa_direction_t dir);
  125 
  126 /* UCM - Use Case Manager is available on some audio cards */
  127 
  128 struct pa_alsa_ucm_device {
  129     PA_LLIST_FIELDS(pa_alsa_ucm_device);
  130 
  131     pa_proplist *proplist;
  132 
  133     unsigned playback_priority;
  134     unsigned capture_priority;
  135 
  136     unsigned playback_rate;
  137     unsigned capture_rate;
  138 
  139     unsigned playback_channels;
  140     unsigned capture_channels;
  141 
  142     pa_alsa_mapping *playback_mapping;
  143     pa_alsa_mapping *capture_mapping;
  144 
  145     pa_idxset *conflicting_devices;
  146     pa_idxset *supported_devices;
  147 
  148     /* One device may be part of multiple ports, since each device has
  149      * a dedicated port, and in addition to that we sometimes generate ports
  150      * that represent combinations of devices. */
  151     pa_dynarray *ucm_ports; /* struct ucm_port */
  152 
  153     pa_alsa_jack *jack;
  154     pa_dynarray *hw_mute_jacks; /* pa_alsa_jack */
  155     pa_available_t available;
  156 };
  157 
  158 void pa_alsa_ucm_device_update_available(pa_alsa_ucm_device *device);
  159 
  160 struct pa_alsa_ucm_modifier {
  161     PA_LLIST_FIELDS(pa_alsa_ucm_modifier);
  162 
  163     pa_proplist *proplist;
  164 
  165     int n_confdev;
  166     int n_suppdev;
  167 
  168     const char **conflicting_devices;
  169     const char **supported_devices;
  170 
  171     pa_direction_t action_direction;
  172 
  173     char *media_role;
  174 
  175     /* Non-NULL if the modifier has its own PlaybackPCM/CapturePCM */
  176     pa_alsa_mapping *playback_mapping;
  177     pa_alsa_mapping *capture_mapping;
  178 
  179     /* Count how many role matched streams are running */
  180     int enabled_counter;
  181 };
  182 
  183 struct pa_alsa_ucm_verb {
  184     PA_LLIST_FIELDS(pa_alsa_ucm_verb);
  185 
  186     pa_proplist *proplist;
  187 
  188     PA_LLIST_HEAD(pa_alsa_ucm_device, devices);
  189     PA_LLIST_HEAD(pa_alsa_ucm_modifier, modifiers);
  190 };
  191 
  192 struct pa_alsa_ucm_config {
  193     pa_core *core;
  194     snd_use_case_mgr_t *ucm_mgr;
  195     pa_alsa_ucm_verb *active_verb;
  196 
  197     PA_LLIST_HEAD(pa_alsa_ucm_verb, verbs);
  198     PA_LLIST_HEAD(pa_alsa_jack, jacks);
  199 };
  200 
  201 struct pa_alsa_ucm_mapping_context {
  202     pa_alsa_ucm_config *ucm;
  203     pa_direction_t direction;
  204 
  205     pa_idxset *ucm_devices;
  206     pa_idxset *ucm_modifiers;
  207 };
  208 
  209 #endif