
/*  A Bison parser, made from alsactl_parser.y
 by  GNU Bison version 1.25
  */

#define YYBISON 1  /* Identify Bison output.  */

#define	L_TRUE	258
#define	L_FALSE	259
#define	L_INTEGER	260
#define	L_STRING	261
#define	L_BYTEARRAY	262
#define	L_DOUBLE1	263
#define	L_SOUNDCARD	264
#define	L_MIXER	265
#define	L_ELEMENT	266
#define	L_SWITCH	267
#define	L_RAWDATA	268
#define	L_CONTROL	269
#define	L_PCM	270
#define	L_RAWMIDI	271
#define	L_PLAYBACK	272
#define	L_CAPTURE	273
#define	L_INPUT	274
#define	L_OUTPUT	275
#define	L_SWITCH1	276
#define	L_SWITCH2	277
#define	L_SWITCH3	278
#define	L_VOLUME1	279
#define	L_3D_EFFECT1	280
#define	L_ACCU3	281
#define	L_MUX1	282
#define	L_MUX2	283
#define	L_TONE_CONTROL1	284
#define	L_IEC958OCS	285
#define	L_3D	286
#define	L_RESET	287
#define	L_USER	288
#define	L_VALID	289
#define	L_DATA	290
#define	L_PROTECT	291
#define	L_PRE2	292
#define	L_FSUNLOCK	293
#define	L_TYPE	294
#define	L_GSTATUS	295
#define	L_ENABLE	296
#define	L_DISABLE	297
#define	L_SW	298
#define	L_MONO_SW	299
#define	L_WIDE	300
#define	L_VOLUME	301
#define	L_CENTER	302
#define	L_SPACE	303
#define	L_DEPTH	304
#define	L_DELAY	305
#define	L_DEPTH_REAR	306
#define	L_FEEDBACK	307
#define	L_BASS	308
#define	L_TREBLE	309

#line 1 "alsactl_parser.y"


/*
 *  Advanced Linux Sound Architecture Control Program
 *  Copyright (c) 1998 by Perex, APS, University of South Bohemia
 *
 *
 *   This program is free software; you can redistribute it and/or modify
 *   it under the terms of the GNU General Public License as published by
 *   the Free Software Foundation; either version 2 of the License, or
 *   (at your option) any later version.
 *
 *   This program is distributed in the hope that it will be useful,
 *   but WITHOUT ANY WARRANTY; without even the implied warranty of
 *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *   GNU General Public License for more details.
 *
 *   You should have received a copy of the GNU General Public License
 *   along with this program; if not, write to the Free Software
 *   Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
 *
 */

#include "alsactl.h"
#include <stdarg.h>

	/* insgus_lexer.c */

int yylex( void );

extern char cfgfile[];
extern int linecount;
extern FILE *yyin;

	/* structure for byte arrays */ 

struct bytearray {
  unsigned char *data;
  size_t datalen;
};

	/* local functions */

static void yyerror(char *, ...);

static void build_soundcard(char *name);
static void build_mixer(char *name);
static void build_pcm(char *name);
static void build_rawmidi(char *name);

static void build_mixer_element(char *name, int index, int etype);

static void build_control_switch(char *name);
static void build_mixer_switch(char *name);
static void build_pcm_playback_switch(char *name);
static void build_pcm_capture_switch(char *name);
static void build_rawmidi_output_switch(char *name);
static void build_rawmidi_input_switch(char *name);

static void mixer_switch1(int end);
static void mixer_switch1_value(int val);
static void mixer_switch2(int end);
static void mixer_switch2_value(int val);
static void mixer_switch3(int end);
static void mixer_switch3_value(int val);
static void mixer_volume1(int end);
static void mixer_volume1_value(int val);
static void mixer_3d_effect1(int end);
static void mixer_3d_effect1_value(unsigned int effect, int val);
static void mixer_accu3(int end);
static void mixer_accu3_value(int val);
static void mixer_mux1(int end);
static void mixer_mux1_value(char *str, int index, int type);
static void mixer_mux2(int end);
static void mixer_mux2_value(char *str, int index, int type);
static void mixer_tone_control1(int end);
static void mixer_tone_control1_value(unsigned int effect, int val);

static void set_switch_boolean(int val);
static void set_switch_integer(int val);
static void set_switch_bytearray(struct bytearray val);
static void set_switch_iec958ocs_begin(int end);
static void set_switch_iec958ocs(int idx, unsigned short val, unsigned short mask);

	/* local variables */

static struct soundcard *Xsoundcard = NULL;
static struct mixer *Xmixer = NULL;
static struct pcm *Xpcm = NULL;
static struct rawmidi *Xrawmidi = NULL;
static struct mixer_element *Xelement  = NULL;
static struct ctl_switch *Xswitch = NULL;
static unsigned int Xswitchiec958ocs = 0;
static unsigned short Xswitchiec958ocs1[16];


#line 100 "alsactl_parser.y"
typedef union {
    int b_value;
    int i_value;
    char *s_value;
    struct bytearray a_value;
  } YYSTYPE;
#include <stdio.h>

#ifndef __cplusplus
#ifndef __STDC__
#define const
#endif
#endif



#define	YYFINAL		308
#define	YYFLAG		-32768
#define	YYNTBASE	61

#define YYTRANSLATE(x) ((unsigned)(x) <= 309 ? yytranslate[x] : 128)

static const char yytranslate[] = {     0,
     2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
     2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
     2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
     2,     2,     2,     2,     2,     2,     2,     2,     2,    55,
    59,     2,     2,    58,     2,     2,     2,     2,     2,     2,
     2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
    60,     2,     2,     2,     2,     2,     2,     2,     2,     2,
     2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
     2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
     2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
     2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
     2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
     2,     2,    57,     2,    56,     2,     2,     2,     2,     2,
     2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
     2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
     2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
     2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
     2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
     2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
     2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
     2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
     2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
     2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
     2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
     2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
     2,     2,     2,     2,     2,     1,     2,     3,     4,     5,
     6,     7,     8,     9,    10,    11,    12,    13,    14,    15,
    16,    17,    18,    19,    20,    21,    22,    23,    24,    25,
    26,    27,    28,    29,    30,    31,    32,    33,    34,    35,
    36,    37,    38,    39,    40,    41,    42,    43,    44,    45,
    46,    47,    48,    49,    50,    51,    52,    53,    54
};

#if YYDEBUG != 0
static const short yyprhs[] = {     0,
     0,     2,     5,     6,    14,    16,    17,    20,    25,    26,
    34,    35,    43,    44,    52,    54,    56,    59,    60,    68,
    70,    71,    74,    75,    87,    88,    96,    98,    99,   105,
   106,   112,   113,   119,   120,   126,   127,   133,   134,   140,
   141,   147,   148,   149,   163,   164,   170,   172,   174,   178,
   180,   182,   184,   188,   190,   192,   194,   198,   200,   202,
   204,   208,   210,   212,   214,   218,   222,   226,   230,   234,
   238,   242,   246,   250,   254,   258,   260,   262,   266,   268,
   270,   272,   276,   285,   287,   289,   293,   297,   301,   305,
   307,   309,   312,   317,   322,   324,   326,   329,   330,   338,
   340,   342,   345,   346,   354,   356,   358,   361,   366,   371,
   373,   376,   377,   385,   387,   389,   392,   393,   401,   403,
   405,   408,   410,   412,   413,   419,   421,   423,   425,   429,
   431,   433,   435,   437,   439,   441,   443,   445,   447,   449,
   454,   456,   458,   460,   462,   464,   466,   471
};

static const short yyrhs[] = {    62,
     0,    61,    62,     0,     0,     9,    55,   126,    63,     8,
    64,    56,     0,     1,     0,     0,    64,    65,     0,    14,
    57,    69,    56,     0,     0,    10,    55,   126,    66,     8,
    72,    56,     0,     0,    15,    55,   126,    67,     8,   103,
    56,     0,     0,    16,    55,   126,    68,     8,   111,    56,
     0,     1,     0,    70,     0,    69,    70,     0,     0,    12,
    55,   126,    71,    58,   119,    59,     0,     1,     0,     0,
    72,    73,     0,     0,    11,    55,   126,    58,   125,    58,
   125,    74,    58,    76,    59,     0,     0,    12,    55,   126,
    75,    58,   119,    59,     0,     1,     0,     0,    21,    55,
    77,    87,    59,     0,     0,    22,    55,    78,    89,    59,
     0,     0,    23,    55,    79,    91,    59,     0,     0,    24,
    55,    80,    93,    59,     0,     0,    25,    55,    81,    95,
    59,     0,     0,    26,    55,    82,    97,    59,     0,     0,
    27,    55,    83,    99,    59,     0,     0,     0,    28,    55,
    84,    11,    55,   126,    58,   125,    58,   125,    59,    85,
    59,     0,     0,    29,    55,    86,   101,    59,     0,     1,
     0,    88,     0,    87,    58,    88,     0,   124,     0,     1,
     0,    90,     0,    89,    58,    90,     0,   124,     0,     1,
     0,    92,     0,    91,    58,    92,     0,   124,     0,     1,
     0,    94,     0,    93,    58,    94,     0,   125,     0,     1,
     0,    96,     0,    95,    58,    96,     0,    43,    60,   124,
     0,    44,    60,   124,     0,    45,    60,   125,     0,    46,
    60,   125,     0,    47,    60,   125,     0,    48,    60,   125,
     0,    49,    60,   125,     0,    50,    60,   125,     0,    52,
    60,   125,     0,    51,    60,   125,     0,     1,     0,    98,
     0,    97,    58,    98,     0,   125,     0,     1,     0,   100,
     0,    99,    58,   100,     0,    11,    55,   126,    58,   125,
    58,   125,    59,     0,     1,     0,   102,     0,   101,    58,
   102,     0,    43,    60,   124,     0,    53,    60,   125,     0,
    54,    60,   125,     0,     1,     0,   104,     0,   103,   104,
     0,    17,    57,   105,    56,     0,    18,    57,   108,    56,
     0,     1,     0,   106,     0,   105,   106,     0,     0,    12,
    55,   126,   107,    58,   119,    59,     0,     1,     0,   109,
     0,   108,   109,     0,     0,    12,    55,   126,   110,    58,
   119,    59,     0,     1,     0,   112,     0,   111,   112,     0,
    19,    57,   113,    56,     0,    20,    57,   116,    56,     0,
   114,     0,   113,   114,     0,     0,    12,    55,   126,   115,
    58,   119,    59,     0,     1,     0,   117,     0,   116,   117,
     0,     0,    12,    55,   126,   118,    58,   119,    59,     0,
     1,     0,   120,     0,   119,   120,     0,   124,     0,   125,
     0,     0,    30,    55,   121,   122,    59,     0,   127,     0,
     1,     0,   123,     0,   122,    58,   123,     0,    41,     0,
    42,     0,    31,     0,    32,     0,    33,     0,    34,     0,
    35,     0,    36,     0,    37,     0,    38,     0,    39,    55,
   125,    59,     0,    40,     0,     1,     0,     3,     0,     4,
     0,     5,     0,     6,     0,    13,    55,     7,    59,     0,
    13,     1,     0
};

#endif

#if YYDEBUG != 0
static const short yyrline[] = { 0,
   137,   138,   141,   142,   143,   146,   147,   150,   151,   152,
   153,   154,   155,   156,   157,   160,   161,   164,   165,   166,
   170,   171,   174,   176,   177,   178,   179,   183,   184,   185,
   186,   187,   188,   189,   190,   191,   192,   193,   194,   195,
   196,   197,   198,   202,   203,   204,   205,   208,   209,   212,
   213,   216,   217,   220,   221,   224,   225,   228,   229,   232,
   233,   236,   237,   240,   241,   244,   245,   246,   247,   248,
   249,   250,   251,   252,   253,   254,   257,   258,   261,   262,
   265,   266,   269,   272,   275,   276,   279,   280,   281,   282,
   286,   287,   290,   291,   292,   295,   296,   299,   300,   301,
   304,   305,   308,   309,   310,   313,   314,   317,   318,   321,
   322,   325,   326,   327,   330,   331,   334,   335,   336,   339,
   340,   343,   344,   345,   346,   347,   348,   351,   352,   355,
   356,   357,   358,   359,   360,   361,   362,   363,   364,   365,
   366,   367,   370,   371,   374,   377,   380,   381
};
#endif


#if YYDEBUG != 0 || defined (YYERROR_VERBOSE)

static const char * const yytname[] = {   "$","error","$undefined.","L_TRUE",
"L_FALSE","L_INTEGER","L_STRING","L_BYTEARRAY","L_DOUBLE1","L_SOUNDCARD","L_MIXER",
"L_ELEMENT","L_SWITCH","L_RAWDATA","L_CONTROL","L_PCM","L_RAWMIDI","L_PLAYBACK",
"L_CAPTURE","L_INPUT","L_OUTPUT","L_SWITCH1","L_SWITCH2","L_SWITCH3","L_VOLUME1",
"L_3D_EFFECT1","L_ACCU3","L_MUX1","L_MUX2","L_TONE_CONTROL1","L_IEC958OCS","L_3D",
"L_RESET","L_USER","L_VALID","L_DATA","L_PROTECT","L_PRE2","L_FSUNLOCK","L_TYPE",
"L_GSTATUS","L_ENABLE","L_DISABLE","L_SW","L_MONO_SW","L_WIDE","L_VOLUME","L_CENTER",
"L_SPACE","L_DEPTH","L_DELAY","L_DEPTH_REAR","L_FEEDBACK","L_BASS","L_TREBLE",
"'('","'}'","'{'","','","')'","'='","lines","line","@1","soundcards","soundcard",
"@2","@3","@4","controls","control","@5","mixers","mixer","@6","@7","etype",
"@8","@9","@10","@11","@12","@13","@14","@15","@16","@17","m_switch1","m_switch1_0",
"m_switch2","m_switch2_0","m_switch3","m_switch3_0","m_volume1","m_volume1_0",
"m_3d_effect1","m_3d_effect1_0","m_accu3","m_accu3_0","m_mux1","m_mux1_0","m_tone_control1",
"m_tone_control1_0","pcms","pcm","playbacks","playback","@18","captures","capture",
"@19","rawmidis","rawmidi","inputs","input","@20","outputs","output","@21","switches",
"switch","@22","iec958ocs","iec958ocs1","boolean","integer","string","rawdata", NULL
};
#endif

static const short yyr1[] = {     0,
    61,    61,    63,    62,    62,    64,    64,    65,    66,    65,
    67,    65,    68,    65,    65,    69,    69,    71,    70,    70,
    72,    72,    74,    73,    75,    73,    73,    77,    76,    78,
    76,    79,    76,    80,    76,    81,    76,    82,    76,    83,
    76,    84,    85,    76,    86,    76,    76,    87,    87,    88,
    88,    89,    89,    90,    90,    91,    91,    92,    92,    93,
    93,    94,    94,    95,    95,    96,    96,    96,    96,    96,
    96,    96,    96,    96,    96,    96,    97,    97,    98,    98,
    99,    99,   100,   100,   101,   101,   102,   102,   102,   102,
   103,   103,   104,   104,   104,   105,   105,   107,   106,   106,
   108,   108,   110,   109,   109,   111,   111,   112,   112,   113,
   113,   115,   114,   114,   116,   116,   118,   117,   117,   119,
   119,   120,   120,   121,   120,   120,   120,   122,   122,   123,
   123,   123,   123,   123,   123,   123,   123,   123,   123,   123,
   123,   123,   124,   124,   125,   126,   127,   127
};

static const short yyr2[] = {     0,
     1,     2,     0,     7,     1,     0,     2,     4,     0,     7,
     0,     7,     0,     7,     1,     1,     2,     0,     7,     1,
     0,     2,     0,    11,     0,     7,     1,     0,     5,     0,
     5,     0,     5,     0,     5,     0,     5,     0,     5,     0,
     5,     0,     0,    13,     0,     5,     1,     1,     3,     1,
     1,     1,     3,     1,     1,     1,     3,     1,     1,     1,
     3,     1,     1,     1,     3,     3,     3,     3,     3,     3,
     3,     3,     3,     3,     3,     1,     1,     3,     1,     1,
     1,     3,     8,     1,     1,     3,     3,     3,     3,     1,
     1,     2,     4,     4,     1,     1,     2,     0,     7,     1,
     1,     2,     0,     7,     1,     1,     2,     4,     4,     1,
     2,     0,     7,     1,     1,     2,     0,     7,     1,     1,
     2,     1,     1,     0,     5,     1,     1,     1,     3,     1,
     1,     1,     1,     1,     1,     1,     1,     1,     1,     4,
     1,     1,     1,     1,     1,     1,     4,     2
};

static const short yydefact[] = {     0,
     5,     0,     0,     1,     0,     2,   146,     3,     0,     6,
     0,    15,     0,     0,     0,     0,     4,     7,     0,     0,
     0,     0,     9,    20,     0,     0,    16,    11,    13,     0,
     0,     8,    17,     0,     0,    21,    18,     0,     0,     0,
     0,    95,     0,     0,     0,    91,     0,     0,     0,   106,
    27,     0,     0,    10,    22,     0,     0,     0,    12,    92,
     0,     0,    14,   107,     0,     0,   127,   143,   144,   145,
     0,     0,     0,   120,   122,   123,   126,   100,     0,     0,
    96,   105,     0,     0,   101,   114,     0,     0,   110,   119,
     0,     0,   115,     0,    25,   148,     0,   124,    19,   121,
     0,    93,    97,     0,    94,   102,     0,   108,   111,     0,
   109,   116,     0,     0,     0,     0,    98,   103,   112,   117,
     0,     0,   147,   142,   132,   133,   134,   135,   136,   137,
   138,   139,     0,   141,   130,   131,     0,   128,     0,     0,
     0,     0,     0,     0,     0,     0,   125,     0,     0,     0,
     0,    23,    26,     0,   129,     0,     0,     0,     0,     0,
   140,    99,   104,   113,   118,     0,    47,     0,     0,     0,
     0,     0,     0,     0,     0,     0,     0,    28,    30,    32,
    34,    36,    38,    40,    42,    45,    24,     0,     0,     0,
     0,     0,     0,     0,     0,     0,    51,     0,    48,    50,
    55,     0,    52,    54,    59,     0,    56,    58,    63,     0,
    60,    62,    76,     0,     0,     0,     0,     0,     0,     0,
     0,     0,     0,     0,    64,    80,     0,    77,    79,    84,
     0,     0,    81,     0,    90,     0,     0,     0,     0,    85,
     0,    29,     0,    31,     0,    33,     0,    35,     0,     0,
     0,     0,     0,     0,     0,     0,     0,     0,     0,    37,
     0,    39,     0,     0,    41,     0,     0,     0,     0,     0,
    46,    49,    53,    57,    61,    66,    67,    68,    69,    70,
    71,    72,    73,    75,    74,    65,    78,     0,    82,     0,
    87,    88,    89,    86,     0,     0,     0,     0,     0,     0,
     0,     0,    83,    43,     0,    44,     0,     0
};

static const short yydefgoto[] = {     3,
     4,     9,    11,    18,    30,    34,    35,    26,    27,    41,
    40,    55,   160,   114,   177,   188,   189,   190,   191,   192,
   193,   194,   195,   305,   196,   198,   199,   202,   203,   206,
   207,   210,   211,   224,   225,   227,   228,   232,   233,   239,
   240,    45,    46,    80,    81,   139,    84,    85,   140,    49,
    50,    88,    89,   141,    92,    93,   142,    73,    74,   116,
   137,   138,    75,    76,     8,    77
};

static const short yypact[] = {    28,
-32768,   -45,   207,-32768,    44,-32768,-32768,-32768,    48,-32768,
    20,-32768,     3,    13,    35,    47,-32768,-32768,    44,    26,
    44,    44,-32768,-32768,    64,    72,-32768,-32768,-32768,   145,
    44,-32768,-32768,   158,   162,-32768,-32768,   114,   131,    66,
    97,-32768,   132,   146,    31,-32768,   154,   156,   -12,-32768,
-32768,   188,   190,-32768,-32768,   201,    74,   125,-32768,-32768,
   126,   135,-32768,-32768,    44,    44,-32768,-32768,-32768,-32768,
    16,   191,    10,-32768,-32768,-32768,-32768,-32768,   193,   105,
-32768,-32768,   194,   108,-32768,-32768,   195,   109,-32768,-32768,
   196,   111,-32768,   197,-32768,-32768,   213,-32768,-32768,-32768,
    44,-32768,-32768,    44,-32768,-32768,    44,-32768,-32768,    44,
-32768,-32768,   247,   198,   199,   159,-32768,-32768,-32768,-32768,
   202,   201,-32768,-32768,-32768,-32768,-32768,-32768,-32768,-32768,
-32768,-32768,   204,-32768,-32768,-32768,    75,-32768,   203,   205,
   206,   208,   247,    15,   247,   159,-32768,   201,   201,   201,
   201,-32768,-32768,   209,-32768,    38,    59,    95,   100,   212,
-32768,-32768,-32768,-32768,-32768,   211,-32768,   210,   216,   217,
   219,   220,   221,   222,   223,   224,   225,-32768,-32768,-32768,
-32768,-32768,-32768,-32768,-32768,-32768,-32768,    21,   214,   218,
   106,   128,   147,   113,   242,   115,-32768,   104,-32768,-32768,
-32768,   123,-32768,-32768,-32768,   127,-32768,-32768,-32768,   151,
-32768,-32768,-32768,   226,   227,   228,   229,   230,   231,   232,
   233,   234,   235,   165,-32768,-32768,   167,-32768,-32768,-32768,
   241,   169,-32768,   243,-32768,   237,   239,   240,   171,-32768,
    21,-32768,   214,-32768,   218,-32768,   106,-32768,   238,   238,
   247,   247,   247,   247,   247,   247,   247,   247,   128,-32768,
   147,-32768,    44,   113,-32768,    44,   238,   247,   247,   115,
-32768,-32768,-32768,-32768,-32768,-32768,-32768,-32768,-32768,-32768,
-32768,-32768,-32768,-32768,-32768,-32768,-32768,   215,-32768,   244,
-32768,-32768,-32768,-32768,   247,   247,   245,   246,   247,   247,
   248,   249,-32768,-32768,   250,-32768,   254,-32768
};

static const short yypgoto[] = {-32768,
   259,-32768,-32768,-32768,-32768,-32768,-32768,-32768,   255,-32768,
-32768,-32768,-32768,-32768,-32768,-32768,-32768,-32768,-32768,-32768,
-32768,-32768,-32768,-32768,-32768,-32768,    39,-32768,    14,-32768,
    22,-32768,    36,-32768,    23,-32768,     8,-32768,    37,-32768,
    40,-32768,   260,-32768,   236,-32768,-32768,   251,-32768,-32768,
   257,-32768,   252,-32768,-32768,   253,-32768,   -96,   -64,-32768,
-32768,   139,  -184,  -112,   -19,-32768
};


#define	YYLAST		345


static const short yytable[] = {    23,
   121,    28,    29,   200,   204,   208,    47,    48,   100,     5,
    67,    37,    68,    69,    70,    67,    96,    68,    69,    70,
    12,   197,    71,    68,    69,   144,    24,    71,     1,    13,
   152,    42,   154,    14,    15,    16,     2,    25,    67,    72,
    68,    69,    70,    63,    72,    94,    95,    43,    44,     7,
    71,   156,   157,   158,   159,    10,   200,    19,   204,    67,
   208,    68,    69,    70,   276,   277,    51,    72,    99,    20,
    97,    71,    24,   153,    78,    17,    52,    53,   212,   100,
   229,   117,   291,    25,   118,    79,    59,   119,    72,    21,
   120,   100,   100,   100,   100,    67,   162,    68,    69,    70,
    67,    22,    68,    69,    70,    78,   209,    71,    82,    86,
    70,    90,    71,   230,    42,   235,    79,   163,    31,    83,
    87,    54,    91,   231,    72,    82,    86,    32,   213,    72,
    43,    44,   146,   147,   212,    90,    83,    87,   278,   279,
   280,   281,   282,   283,   284,   285,    91,   226,   229,    47,
    48,    70,    36,   164,    56,   292,   293,   236,   165,   124,
   102,   241,   242,   105,   108,    38,   111,   237,   238,    39,
   214,   215,   216,   217,   218,   219,   220,   221,   222,   223,
   243,   244,   297,   298,   245,   246,   301,   302,    57,   125,
   126,   127,   128,   129,   130,   131,   132,   133,   134,   135,
   136,    67,    58,    68,    69,    70,   307,     1,   247,   248,
    61,   167,    62,    71,   201,     2,    68,    69,   205,   115,
    68,    69,   259,   260,   261,   262,   264,   265,   270,   271,
    72,   168,   169,   170,   171,   172,   173,   174,   175,   176,
    68,    69,    65,   288,    66,    98,   290,   101,   104,   107,
   110,    70,   234,   308,   113,   122,   273,   123,   145,   143,
   148,     6,   149,   150,   178,   151,   274,   161,   287,   166,
   179,   180,   295,   181,   182,   183,   184,   185,   186,   272,
    33,   286,   275,   187,   155,   249,   250,   251,   252,   253,
   254,   255,   256,   257,   258,   263,   267,   266,   268,   269,
   289,   296,   299,   300,    60,    64,   303,   304,   306,   294,
     0,     0,     0,     0,     0,   103,     0,     0,     0,     0,
     0,     0,     0,     0,     0,     0,     0,     0,     0,     0,
     0,     0,     0,     0,   106,     0,     0,     0,     0,   109,
     0,     0,     0,     0,   112
};

static const short yycheck[] = {    19,
   113,    21,    22,   188,   189,   190,    19,    20,    73,    55,
     1,    31,     3,     4,     5,     1,     1,     3,     4,     5,
     1,     1,    13,     3,     4,   122,     1,    13,     1,    10,
   143,     1,   145,    14,    15,    16,     9,    12,     1,    30,
     3,     4,     5,    56,    30,    65,    66,    17,    18,     6,
    13,   148,   149,   150,   151,     8,   241,    55,   243,     1,
   245,     3,     4,     5,   249,   250,     1,    30,    59,    57,
    55,    13,     1,    59,     1,    56,    11,    12,   191,   144,
   193,   101,   267,    12,   104,    12,    56,   107,    30,    55,
   110,   156,   157,   158,   159,     1,    59,     3,     4,     5,
     1,    55,     3,     4,     5,     1,     1,    13,     1,     1,
     5,     1,    13,     1,     1,     1,    12,    59,    55,    12,
    12,    56,    12,    11,    30,     1,     1,    56,     1,    30,
    17,    18,    58,    59,   247,     1,    12,    12,   251,   252,
   253,   254,   255,   256,   257,   258,    12,     1,   261,    19,
    20,     5,     8,    59,    58,   268,   269,    43,    59,     1,
    56,    58,    59,    56,    56,     8,    56,    53,    54,     8,
    43,    44,    45,    46,    47,    48,    49,    50,    51,    52,
    58,    59,   295,   296,    58,    59,   299,   300,    57,    31,
    32,    33,    34,    35,    36,    37,    38,    39,    40,    41,
    42,     1,    57,     3,     4,     5,     0,     1,    58,    59,
    57,     1,    57,    13,     1,     9,     3,     4,     1,     7,
     3,     4,    58,    59,    58,    59,    58,    59,    58,    59,
    30,    21,    22,    23,    24,    25,    26,    27,    28,    29,
     3,     4,    55,   263,    55,    55,   266,    55,    55,    55,
    55,     5,    11,     0,    58,    58,   243,    59,    55,    58,
    58,     3,    58,    58,    55,    58,   245,    59,   261,    58,
    55,    55,    58,    55,    55,    55,    55,    55,    55,   241,
    26,   259,   247,    59,   146,    60,    60,    60,    60,    60,
    60,    60,    60,    60,    60,    55,    60,    55,    60,    60,
   264,    58,    58,    58,    45,    49,    59,    59,    59,   270,
    -1,    -1,    -1,    -1,    -1,    80,    -1,    -1,    -1,    -1,
    -1,    -1,    -1,    -1,    -1,    -1,    -1,    -1,    -1,    -1,
    -1,    -1,    -1,    -1,    84,    -1,    -1,    -1,    -1,    88,
    -1,    -1,    -1,    -1,    92
};
/* -*-C-*-  Note some compilers choke on comments on `#line' lines.  */
#line 3 "/usr/share/bison.simple"

/* Skeleton output parser for bison,
   Copyright (C) 1984, 1989, 1990 Free Software Foundation, Inc.

   This program is free software; you can redistribute it and/or modify
   it under the terms of the GNU General Public License as published by
   the Free Software Foundation; either version 2, or (at your option)
   any later version.

   This program is distributed in the hope that it will be useful,
   but WITHOUT ANY WARRANTY; without even the implied warranty of
   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
   GNU General Public License for more details.

   You should have received a copy of the GNU General Public License
   along with this program; if not, write to the Free Software
   Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.  */

/* As a special exception, when this file is copied by Bison into a
   Bison output file, you may use that output file without restriction.
   This special exception was added by the Free Software Foundation
   in version 1.24 of Bison.  */

#ifndef alloca
#ifdef __GNUC__
#define alloca __builtin_alloca
#else /* not GNU C.  */
#if (!defined (__STDC__) && defined (sparc)) || defined (__sparc__) || defined (__sparc) || defined (__sgi)
#include <alloca.h>
#else /* not sparc */
#if defined (MSDOS) && !defined (__TURBOC__)
#include <malloc.h>
#else /* not MSDOS, or __TURBOC__ */
#if defined(_AIX)
#include <malloc.h>
 #pragma alloca
#else /* not MSDOS, __TURBOC__, or _AIX */
#ifdef __hpux
#ifdef __cplusplus
extern "C" {
void *alloca (unsigned int);
};
#else /* not __cplusplus */
void *alloca ();
#endif /* not __cplusplus */
#endif /* __hpux */
#endif /* not _AIX */
#endif /* not MSDOS, or __TURBOC__ */
#endif /* not sparc.  */
#endif /* not GNU C.  */
#endif /* alloca not defined.  */

/* This is the parser code that is written into each bison parser
  when the %semantic_parser declaration is not specified in the grammar.
  It was written by Richard Stallman by simplifying the hairy parser
  used when %semantic_parser is specified.  */

/* Note: there must be only one dollar sign in this file.
   It is replaced by the list of actions, each action
   as one case of the switch.  */

#define yyerrok		(yyerrstatus = 0)
#define yyclearin	(yychar = YYEMPTY)
#define YYEMPTY		-2
#define YYEOF		0
#define YYACCEPT	return(0)
#define YYABORT 	return(1)
#define YYERROR		goto yyerrlab1
/* Like YYERROR except do call yyerror.
   This remains here temporarily to ease the
   transition to the new meaning of YYERROR, for GCC.
   Once GCC version 2 has supplanted version 1, this can go.  */
#define YYFAIL		goto yyerrlab
#define YYRECOVERING()  (!!yyerrstatus)
#define YYBACKUP(token, value) \
do								\
  if (yychar == YYEMPTY && yylen == 1)				\
    { yychar = (token), yylval = (value);			\
      yychar1 = YYTRANSLATE (yychar);				\
      YYPOPSTACK;						\
      goto yybackup;						\
    }								\
  else								\
    { yyerror ("syntax error: cannot back up"); YYERROR; }	\
while (0)

#define YYTERROR	1
#define YYERRCODE	256

#ifndef YYPURE
#define YYLEX		yylex()
#endif

#ifdef YYPURE
#ifdef YYLSP_NEEDED
#ifdef YYLEX_PARAM
#define YYLEX		yylex(&yylval, &yylloc, YYLEX_PARAM)
#else
#define YYLEX		yylex(&yylval, &yylloc)
#endif
#else /* not YYLSP_NEEDED */
#ifdef YYLEX_PARAM
#define YYLEX		yylex(&yylval, YYLEX_PARAM)
#else
#define YYLEX		yylex(&yylval)
#endif
#endif /* not YYLSP_NEEDED */
#endif

/* If nonreentrant, generate the variables here */

#ifndef YYPURE

int	yychar;			/*  the lookahead symbol		*/
YYSTYPE	yylval;			/*  the semantic value of the		*/
				/*  lookahead symbol			*/

#ifdef YYLSP_NEEDED
YYLTYPE yylloc;			/*  location data for the lookahead	*/
				/*  symbol				*/
#endif

int yynerrs;			/*  number of parse errors so far       */
#endif  /* not YYPURE */

#if YYDEBUG != 0
int yydebug;			/*  nonzero means print parse trace	*/
/* Since this is uninitialized, it does not stop multiple parsers
   from coexisting.  */
#endif

/*  YYINITDEPTH indicates the initial size of the parser's stacks	*/

#ifndef	YYINITDEPTH
#define YYINITDEPTH 200
#endif

/*  YYMAXDEPTH is the maximum size the stacks can grow to
    (effective only if the built-in stack extension method is used).  */

#if YYMAXDEPTH == 0
#undef YYMAXDEPTH
#endif

#ifndef YYMAXDEPTH
#define YYMAXDEPTH 10000
#endif

#ifndef YYPARSE_RETURN_TYPE
#define YYPARSE_RETURN_TYPE int
#endif

/* Prevent warning if -Wstrict-prototypes.  */
#ifdef __GNUC__
YYPARSE_RETURN_TYPE yyparse (void);
#endif

#if __GNUC__ > 1		/* GNU C and GNU C++ define this.  */
#define __yy_memcpy(TO,FROM,COUNT)	__builtin_memcpy(TO,FROM,COUNT)
#else				/* not GNU C or C++ */
#ifndef __cplusplus

/* This is the most reliable way to avoid incompatibilities
   in available built-in functions on various systems.  */
static void
__yy_memcpy (to, from, count)
     char *to;
     char *from;
     int count;
{
  register char *f = from;
  register char *t = to;
  register int i = count;

  while (i-- > 0)
    *t++ = *f++;
}

#else /* __cplusplus */

/* This is the most reliable way to avoid incompatibilities
   in available built-in functions on various systems.  */
static void
__yy_memcpy (char *to, char *from, int count)
{
  register char *f = from;
  register char *t = to;
  register int i = count;

  while (i-- > 0)
    *t++ = *f++;
}

#endif
#endif

#line 196 "/usr/share/bison.simple"

/* The user can define YYPARSE_PARAM as the name of an argument to be passed
   into yyparse.  The argument should have type void *.
   It should actually point to an object.
   Grammar actions can access the variable by casting it
   to the proper pointer type.  */

#ifdef YYPARSE_PARAM
#ifdef __cplusplus
#define YYPARSE_PARAM_ARG void *YYPARSE_PARAM
#define YYPARSE_PARAM_DECL
#else /* not __cplusplus */
#define YYPARSE_PARAM_ARG YYPARSE_PARAM
#define YYPARSE_PARAM_DECL void *YYPARSE_PARAM;
#endif /* not __cplusplus */
#else /* not YYPARSE_PARAM */
#define YYPARSE_PARAM_ARG
#define YYPARSE_PARAM_DECL
#endif /* not YYPARSE_PARAM */

YYPARSE_RETURN_TYPE
yyparse(YYPARSE_PARAM_ARG)
     YYPARSE_PARAM_DECL
{
  register int yystate;
  register int yyn;
  register short *yyssp;
  register YYSTYPE *yyvsp;
  int yyerrstatus;	/*  number of tokens to shift before error messages enabled */
  int yychar1 = 0;		/*  lookahead token as an internal (translated) token number */

  short	yyssa[YYINITDEPTH];	/*  the state stack			*/
  YYSTYPE yyvsa[YYINITDEPTH];	/*  the semantic value stack		*/

  short *yyss = yyssa;		/*  refer to the stacks thru separate pointers */
  YYSTYPE *yyvs = yyvsa;	/*  to allow yyoverflow to reallocate them elsewhere */

#ifdef YYLSP_NEEDED
  YYLTYPE yylsa[YYINITDEPTH];	/*  the location stack			*/
  YYLTYPE *yyls = yylsa;
  YYLTYPE *yylsp;

#define YYPOPSTACK   (yyvsp--, yyssp--, yylsp--)
#else
#define YYPOPSTACK   (yyvsp--, yyssp--)
#endif

  int yystacksize = YYINITDEPTH;

#ifdef YYPURE
  int yychar;
  YYSTYPE yylval;
  int yynerrs;
#ifdef YYLSP_NEEDED
  YYLTYPE yylloc;
#endif
#endif

  YYSTYPE yyval;		/*  the variable used to return		*/
				/*  semantic values from the action	*/
				/*  routines				*/

  int yylen;

#if YYDEBUG != 0
  if (yydebug)
    fprintf(stderr, "Starting parse\n");
#endif

  yystate = 0;
  yyerrstatus = 0;
  yynerrs = 0;
  yychar = YYEMPTY;		/* Cause a token to be read.  */

  /* Initialize stack pointers.
     Waste one element of value and location stack
     so that they stay on the same level as the state stack.
     The wasted elements are never initialized.  */

  yyssp = yyss - 1;
  yyvsp = yyvs;
#ifdef YYLSP_NEEDED
  yylsp = yyls;
#endif

/* Push a new state, which is found in  yystate  .  */
/* In all cases, when you get here, the value and location stacks
   have just been pushed. so pushing a state here evens the stacks.  */
yynewstate:

  *++yyssp = yystate;

  if (yyssp >= yyss + yystacksize - 1)
    {
      /* Give user a chance to reallocate the stack */
      /* Use copies of these so that the &'s don't force the real ones into memory. */
      YYSTYPE *yyvs1 = yyvs;
      short *yyss1 = yyss;
#ifdef YYLSP_NEEDED
      YYLTYPE *yyls1 = yyls;
#endif

      /* Get the current used size of the three stacks, in elements.  */
      int size = yyssp - yyss + 1;

#ifdef yyoverflow
      /* Each stack pointer address is followed by the size of
	 the data in use in that stack, in bytes.  */
#ifdef YYLSP_NEEDED
      /* This used to be a conditional around just the two extra args,
	 but that might be undefined if yyoverflow is a macro.  */
      yyoverflow("parser stack overflow",
		 &yyss1, size * sizeof (*yyssp),
		 &yyvs1, size * sizeof (*yyvsp),
		 &yyls1, size * sizeof (*yylsp),
		 &yystacksize);
#else
      yyoverflow("parser stack overflow",
		 &yyss1, size * sizeof (*yyssp),
		 &yyvs1, size * sizeof (*yyvsp),
		 &yystacksize);
#endif

      yyss = yyss1; yyvs = yyvs1;
#ifdef YYLSP_NEEDED
      yyls = yyls1;
#endif
#else /* no yyoverflow */
      /* Extend the stack our own way.  */
      if (yystacksize >= YYMAXDEPTH)
	{
	  yyerror("parser stack overflow");
	  return 2;
	}
      yystacksize *= 2;
      if (yystacksize > YYMAXDEPTH)
	yystacksize = YYMAXDEPTH;
      yyss = (short *) alloca (yystacksize * sizeof (*yyssp));
      __yy_memcpy ((char *)yyss, (char *)yyss1, size * sizeof (*yyssp));
      yyvs = (YYSTYPE *) alloca (yystacksize * sizeof (*yyvsp));
      __yy_memcpy ((char *)yyvs, (char *)yyvs1, size * sizeof (*yyvsp));
#ifdef YYLSP_NEEDED
      yyls = (YYLTYPE *) alloca (yystacksize * sizeof (*yylsp));
      __yy_memcpy ((char *)yyls, (char *)yyls1, size * sizeof (*yylsp));
#endif
#endif /* no yyoverflow */

      yyssp = yyss + size - 1;
      yyvsp = yyvs + size - 1;
#ifdef YYLSP_NEEDED
      yylsp = yyls + size - 1;
#endif

#if YYDEBUG != 0
      if (yydebug)
	fprintf(stderr, "Stack size increased to %d\n", yystacksize);
#endif

      if (yyssp >= yyss + yystacksize - 1)
	YYABORT;
    }

#if YYDEBUG != 0
  if (yydebug)
    fprintf(stderr, "Entering state %d\n", yystate);
#endif

  goto yybackup;
 yybackup:

/* Do appropriate processing given the current state.  */
/* Read a lookahead token if we need one and don't already have one.  */
/* yyresume: */

  /* First try to decide what to do without reference to lookahead token.  */

  yyn = yypact[yystate];
  if (yyn == YYFLAG)
    goto yydefault;

  /* Not known => get a lookahead token if don't already have one.  */

  /* yychar is either YYEMPTY or YYEOF
     or a valid token in external form.  */

  if (yychar == YYEMPTY)
    {
#if YYDEBUG != 0
      if (yydebug)
	fprintf(stderr, "Reading a token: ");
#endif
      yychar = YYLEX;
    }

  /* Convert token to internal form (in yychar1) for indexing tables with */

  if (yychar <= 0)		/* This means end of input. */
    {
      yychar1 = 0;
      yychar = YYEOF;		/* Don't call YYLEX any more */

#if YYDEBUG != 0
      if (yydebug)
	fprintf(stderr, "Now at end of input.\n");
#endif
    }
  else
    {
      yychar1 = YYTRANSLATE(yychar);

#if YYDEBUG != 0
      if (yydebug)
	{
	  fprintf (stderr, "Next token is %d (%s", yychar, yytname[yychar1]);
	  /* Give the individual parser a way to print the precise meaning
	     of a token, for further debugging info.  */
#ifdef YYPRINT
	  YYPRINT (stderr, yychar, yylval);
#endif
	  fprintf (stderr, ")\n");
	}
#endif
    }

  yyn += yychar1;
  if (yyn < 0 || yyn > YYLAST || yycheck[yyn] != yychar1)
    goto yydefault;

  yyn = yytable[yyn];

  /* yyn is what to do for this token type in this state.
     Negative => reduce, -yyn is rule number.
     Positive => shift, yyn is new state.
       New state is final state => don't bother to shift,
       just return success.
     0, or most negative number => error.  */

  if (yyn < 0)
    {
      if (yyn == YYFLAG)
	goto yyerrlab;
      yyn = -yyn;
      goto yyreduce;
    }
  else if (yyn == 0)
    goto yyerrlab;

  if (yyn == YYFINAL)
    YYACCEPT;

  /* Shift the lookahead token.  */

#if YYDEBUG != 0
  if (yydebug)
    fprintf(stderr, "Shifting token %d (%s), ", yychar, yytname[yychar1]);
#endif

  /* Discard the token being shifted unless it is eof.  */
  if (yychar != YYEOF)
    yychar = YYEMPTY;

  *++yyvsp = yylval;
#ifdef YYLSP_NEEDED
  *++yylsp = yylloc;
#endif

  /* count tokens shifted since error; after three, turn off error status.  */
  if (yyerrstatus) yyerrstatus--;

  yystate = yyn;
  goto yynewstate;

/* Do the default action for the current state.  */
yydefault:

  yyn = yydefact[yystate];
  if (yyn == 0)
    goto yyerrlab;

/* Do a reduction.  yyn is the number of a rule to reduce with.  */
yyreduce:
  yylen = yyr2[yyn];
  if (yylen > 0)
    yyval = yyvsp[1-yylen]; /* implement default value of the action */

#if YYDEBUG != 0
  if (yydebug)
    {
      int i;

      fprintf (stderr, "Reducing via rule %d (line %d), ",
	       yyn, yyrline[yyn]);

      /* Print the symbols being reduced, and their result.  */
      for (i = yyprhs[yyn]; yyrhs[i] > 0; i++)
	fprintf (stderr, "%s ", yytname[yyrhs[i]]);
      fprintf (stderr, " -> %s\n", yytname[yyr1[yyn]]);
    }
#endif


  switch (yyn) {

case 3:
#line 141 "alsactl_parser.y"
{ build_soundcard(yyvsp[0].s_value); ;
    break;}
case 4:
#line 142 "alsactl_parser.y"
{ build_soundcard(NULL); ;
    break;}
case 5:
#line 143 "alsactl_parser.y"
{ yyerror("unknown keyword in top level"); ;
    break;}
case 9:
#line 151 "alsactl_parser.y"
{ build_mixer(yyvsp[0].s_value); ;
    break;}
case 10:
#line 152 "alsactl_parser.y"
{ build_mixer(NULL); ;
    break;}
case 11:
#line 153 "alsactl_parser.y"
{ build_pcm(yyvsp[0].s_value); ;
    break;}
case 12:
#line 154 "alsactl_parser.y"
{ build_pcm(NULL); ;
    break;}
case 13:
#line 155 "alsactl_parser.y"
{ build_rawmidi(yyvsp[0].s_value); ;
    break;}
case 14:
#line 156 "alsactl_parser.y"
{ build_rawmidi(NULL); ;
    break;}
case 15:
#line 157 "alsactl_parser.y"
{ yyerror( "an unknown keyword in the soundcard{} level"); ;
    break;}
case 18:
#line 164 "alsactl_parser.y"
{ build_control_switch(yyvsp[0].s_value); ;
    break;}
case 19:
#line 165 "alsactl_parser.y"
{ build_control_switch(NULL); ;
    break;}
case 20:
#line 166 "alsactl_parser.y"
{ yyerror("an unknown keyword in the control{} level"); ;
    break;}
case 23:
#line 175 "alsactl_parser.y"
{ build_mixer_element(yyvsp[-4].s_value, yyvsp[-2].i_value, yyvsp[0].i_value); ;
    break;}
case 24:
#line 176 "alsactl_parser.y"
{ build_mixer_element(NULL, -1, -1); ;
    break;}
case 25:
#line 177 "alsactl_parser.y"
{ build_mixer_switch(yyvsp[0].s_value); ;
    break;}
case 26:
#line 178 "alsactl_parser.y"
{ build_mixer_switch(NULL); ;
    break;}
case 27:
#line 179 "alsactl_parser.y"
{ yyerror("an unknown keyword in the mixer level"); ;
    break;}
case 28:
#line 183 "alsactl_parser.y"
{ mixer_switch1(0); ;
    break;}
case 29:
#line 184 "alsactl_parser.y"
{ mixer_switch1(1); ;
    break;}
case 30:
#line 185 "alsactl_parser.y"
{ mixer_switch2(0); ;
    break;}
case 31:
#line 186 "alsactl_parser.y"
{ mixer_switch2(1); ;
    break;}
case 32:
#line 187 "alsactl_parser.y"
{ mixer_switch3(0); ;
    break;}
case 33:
#line 188 "alsactl_parser.y"
{ mixer_switch3(1); ;
    break;}
case 34:
#line 189 "alsactl_parser.y"
{ mixer_volume1(0); ;
    break;}
case 35:
#line 190 "alsactl_parser.y"
{ mixer_volume1(1); ;
    break;}
case 36:
#line 191 "alsactl_parser.y"
{ mixer_3d_effect1(0); ;
    break;}
case 37:
#line 192 "alsactl_parser.y"
{ mixer_3d_effect1(1); ;
    break;}
case 38:
#line 193 "alsactl_parser.y"
{ mixer_accu3(0); ;
    break;}
case 39:
#line 194 "alsactl_parser.y"
{ mixer_accu3(1); ;
    break;}
case 40:
#line 195 "alsactl_parser.y"
{ mixer_mux1(0); ;
    break;}
case 41:
#line 196 "alsactl_parser.y"
{ mixer_mux1(1); ;
    break;}
case 42:
#line 197 "alsactl_parser.y"
{ mixer_mux2(0); ;
    break;}
case 43:
#line 201 "alsactl_parser.y"
{ mixer_mux2_value(yyvsp[-5].s_value, yyvsp[-3].i_value, yyvsp[-1].i_value); ;
    break;}
case 44:
#line 202 "alsactl_parser.y"
{ mixer_mux2(1); ;
    break;}
case 45:
#line 203 "alsactl_parser.y"
{ mixer_tone_control1(0); ;
    break;}
case 46:
#line 204 "alsactl_parser.y"
{ mixer_tone_control1(1); ;
    break;}
case 47:
#line 205 "alsactl_parser.y"
{ yyerror("an unknown keyword in the mixer element level"); ;
    break;}
case 50:
#line 212 "alsactl_parser.y"
{ mixer_switch1_value(yyvsp[0].b_value); ;
    break;}
case 51:
#line 213 "alsactl_parser.y"
{ yyerror("an unknown keyword in the Switch1 element level"); ;
    break;}
case 54:
#line 220 "alsactl_parser.y"
{ mixer_switch2_value(yyvsp[0].b_value); ;
    break;}
case 55:
#line 221 "alsactl_parser.y"
{ yyerror("an unknown keyword in the Switch2 element level"); ;
    break;}
case 58:
#line 228 "alsactl_parser.y"
{ mixer_switch3_value(yyvsp[0].b_value); ;
    break;}
case 59:
#line 229 "alsactl_parser.y"
{ yyerror("an unknown keyword in the Switch3 element level"); ;
    break;}
case 62:
#line 236 "alsactl_parser.y"
{ mixer_volume1_value(yyvsp[0].i_value); ;
    break;}
case 63:
#line 237 "alsactl_parser.y"
{ yyerror("an unknown keyword in the Volume1 element level"); ;
    break;}
case 66:
#line 244 "alsactl_parser.y"
{ mixer_3d_effect1_value(SND_MIXER_EFF1_SW, yyvsp[0].b_value); ;
    break;}
case 67:
#line 245 "alsactl_parser.y"
{ mixer_3d_effect1_value(SND_MIXER_EFF1_MONO_SW, yyvsp[0].b_value); ;
    break;}
case 68:
#line 246 "alsactl_parser.y"
{ mixer_3d_effect1_value(SND_MIXER_EFF1_WIDE, yyvsp[0].i_value); ;
    break;}
case 69:
#line 247 "alsactl_parser.y"
{ mixer_3d_effect1_value(SND_MIXER_EFF1_VOLUME, yyvsp[0].i_value); ;
    break;}
case 70:
#line 248 "alsactl_parser.y"
{ mixer_3d_effect1_value(SND_MIXER_EFF1_CENTER, yyvsp[0].i_value); ;
    break;}
case 71:
#line 249 "alsactl_parser.y"
{ mixer_3d_effect1_value(SND_MIXER_EFF1_SPACE, yyvsp[0].i_value); ;
    break;}
case 72:
#line 250 "alsactl_parser.y"
{ mixer_3d_effect1_value(SND_MIXER_EFF1_DEPTH, yyvsp[0].i_value); ;
    break;}
case 73:
#line 251 "alsactl_parser.y"
{ mixer_3d_effect1_value(SND_MIXER_EFF1_DELAY, yyvsp[0].i_value); ;
    break;}
case 74:
#line 252 "alsactl_parser.y"
{ mixer_3d_effect1_value(SND_MIXER_EFF1_FEEDBACK, yyvsp[0].i_value); ;
    break;}
case 75:
#line 253 "alsactl_parser.y"
{ mixer_3d_effect1_value(SND_MIXER_EFF1_DEPTH_REAR, yyvsp[0].i_value); ;
    break;}
case 76:
#line 254 "alsactl_parser.y"
{ yyerror("an unknown keyword in the 3D Effect1 element level"); ;
    break;}
case 79:
#line 261 "alsactl_parser.y"
{ mixer_accu3_value(yyvsp[0].i_value); ;
    break;}
case 80:
#line 262 "alsactl_parser.y"
{ yyerror("an unknown keyword in the Accu3 element level"); ;
    break;}
case 83:
#line 271 "alsactl_parser.y"
{ mixer_mux1_value(yyvsp[-5].s_value, yyvsp[-3].i_value, yyvsp[-1].i_value); ;
    break;}
case 84:
#line 272 "alsactl_parser.y"
{ yyerror("an unknown keyword in the Mux1 element level"); ;
    break;}
case 87:
#line 279 "alsactl_parser.y"
{ mixer_tone_control1_value(SND_MIXER_TC1_SW, yyvsp[0].b_value); ;
    break;}
case 88:
#line 280 "alsactl_parser.y"
{ mixer_tone_control1_value(SND_MIXER_TC1_BASS, yyvsp[0].i_value); ;
    break;}
case 89:
#line 281 "alsactl_parser.y"
{ mixer_tone_control1_value(SND_MIXER_TC1_TREBLE, yyvsp[0].i_value); ;
    break;}
case 90:
#line 282 "alsactl_parser.y"
{ yyerror("an unknown keyword in the ToneControl1 element level"); ;
    break;}
case 95:
#line 292 "alsactl_parser.y"
{ yyerror("an unknown keyword in the pcm{} section"); ;
    break;}
case 98:
#line 299 "alsactl_parser.y"
{ build_pcm_playback_switch(yyvsp[0].s_value); ;
    break;}
case 99:
#line 300 "alsactl_parser.y"
{ build_pcm_playback_switch(NULL); ;
    break;}
case 100:
#line 301 "alsactl_parser.y"
{ yyerror("an unknown keyword in the playback{} section"); ;
    break;}
case 103:
#line 308 "alsactl_parser.y"
{ build_pcm_capture_switch(yyvsp[0].s_value); ;
    break;}
case 104:
#line 309 "alsactl_parser.y"
{ build_pcm_capture_switch(NULL); ;
    break;}
case 105:
#line 310 "alsactl_parser.y"
{ yyerror("an unknown keyword in the capture{} section"); ;
    break;}
case 112:
#line 325 "alsactl_parser.y"
{ build_rawmidi_input_switch(yyvsp[0].s_value); ;
    break;}
case 113:
#line 326 "alsactl_parser.y"
{ build_rawmidi_input_switch(NULL); ;
    break;}
case 114:
#line 327 "alsactl_parser.y"
{ yyerror( "an unknown keyword in the input{} section" ); ;
    break;}
case 117:
#line 334 "alsactl_parser.y"
{ build_rawmidi_output_switch(yyvsp[0].s_value); ;
    break;}
case 118:
#line 335 "alsactl_parser.y"
{ build_rawmidi_output_switch(NULL); ;
    break;}
case 119:
#line 336 "alsactl_parser.y"
{ yyerror( "an unknown keyword in the output{} section" ); ;
    break;}
case 122:
#line 343 "alsactl_parser.y"
{ set_switch_boolean(yyvsp[0].b_value); ;
    break;}
case 123:
#line 344 "alsactl_parser.y"
{ set_switch_integer(yyvsp[0].i_value); ;
    break;}
case 124:
#line 345 "alsactl_parser.y"
{ set_switch_iec958ocs_begin(0); ;
    break;}
case 125:
#line 346 "alsactl_parser.y"
{ set_switch_iec958ocs_begin(1); ;
    break;}
case 126:
#line 347 "alsactl_parser.y"
{ set_switch_bytearray(yyvsp[0].a_value); ;
    break;}
case 127:
#line 348 "alsactl_parser.y"
{ yyerror( "an unknown keyword in the switch() data parameter" ); ;
    break;}
case 130:
#line 355 "alsactl_parser.y"
{ set_switch_iec958ocs( 0, 1, 0 ); ;
    break;}
case 131:
#line 356 "alsactl_parser.y"
{ set_switch_iec958ocs( 0, 0, 0 ); ;
    break;}
case 132:
#line 357 "alsactl_parser.y"
{ set_switch_iec958ocs( 4, 0x2000, ~0x2000 ); ;
    break;}
case 133:
#line 358 "alsactl_parser.y"
{ set_switch_iec958ocs( 4, 0x0040, ~0x0040 ); ;
    break;}
case 134:
#line 359 "alsactl_parser.y"
{ set_switch_iec958ocs( 4, 0x0020, ~0x0020 ); ;
    break;}
case 135:
#line 360 "alsactl_parser.y"
{ set_switch_iec958ocs( 4, 0x0010, ~0x0010 ); ;
    break;}
case 136:
#line 361 "alsactl_parser.y"
{ set_switch_iec958ocs( 5, 0x0002, ~0x0002 ); ;
    break;}
case 137:
#line 362 "alsactl_parser.y"
{ set_switch_iec958ocs( 5, 0, ~0x0004 ); ;
    break;}
case 138:
#line 363 "alsactl_parser.y"
{ set_switch_iec958ocs( 5, 0x0008, ~0x0018 ); ;
    break;}
case 139:
#line 364 "alsactl_parser.y"
{ set_switch_iec958ocs( 5, 0x0020, ~0x0020 ); ;
    break;}
case 140:
#line 365 "alsactl_parser.y"
{ set_switch_iec958ocs( 5, (yyvsp[-1].i_value & 0x7f) << 6, ~(0x7f<<6) ); ;
    break;}
case 141:
#line 366 "alsactl_parser.y"
{ set_switch_iec958ocs( 5, 0x2000, ~0x2000 ); ;
    break;}
case 142:
#line 367 "alsactl_parser.y"
{ yyerror( "an unknown keyword in the iec958ocs1() arguments" ); ;
    break;}
case 143:
#line 370 "alsactl_parser.y"
{ yyval.b_value = 1; ;
    break;}
case 144:
#line 371 "alsactl_parser.y"
{ yyval.b_value = 0; ;
    break;}
case 145:
#line 374 "alsactl_parser.y"
{ yyval.i_value = yyvsp[0].i_value; ;
    break;}
case 146:
#line 377 "alsactl_parser.y"
{ yyval.s_value = yyvsp[0].s_value; ;
    break;}
case 147:
#line 380 "alsactl_parser.y"
{ yyval.a_value = yyvsp[-1].a_value; ;
    break;}
case 148:
#line 381 "alsactl_parser.y"
{ yyerror( "malformed rawdata value" ); ;
    break;}
}
   /* the action file gets copied in in place of this dollarsign */
#line 498 "/usr/share/bison.simple"

  yyvsp -= yylen;
  yyssp -= yylen;
#ifdef YYLSP_NEEDED
  yylsp -= yylen;
#endif

#if YYDEBUG != 0
  if (yydebug)
    {
      short *ssp1 = yyss - 1;
      fprintf (stderr, "state stack now");
      while (ssp1 != yyssp)
	fprintf (stderr, " %d", *++ssp1);
      fprintf (stderr, "\n");
    }
#endif

  *++yyvsp = yyval;

#ifdef YYLSP_NEEDED
  yylsp++;
  if (yylen == 0)
    {
      yylsp->first_line = yylloc.first_line;
      yylsp->first_column = yylloc.first_column;
      yylsp->last_line = (yylsp-1)->last_line;
      yylsp->last_column = (yylsp-1)->last_column;
      yylsp->text = 0;
    }
  else
    {
      yylsp->last_line = (yylsp+yylen-1)->last_line;
      yylsp->last_column = (yylsp+yylen-1)->last_column;
    }
#endif

  /* Now "shift" the result of the reduction.
     Determine what state that goes to,
     based on the state we popped back to
     and the rule number reduced by.  */

  yyn = yyr1[yyn];

  yystate = yypgoto[yyn - YYNTBASE] + *yyssp;
  if (yystate >= 0 && yystate <= YYLAST && yycheck[yystate] == *yyssp)
    yystate = yytable[yystate];
  else
    yystate = yydefgoto[yyn - YYNTBASE];

  goto yynewstate;

yyerrlab:   /* here on detecting error */

  if (! yyerrstatus)
    /* If not already recovering from an error, report this error.  */
    {
      ++yynerrs;

#ifdef YYERROR_VERBOSE
      yyn = yypact[yystate];

      if (yyn > YYFLAG && yyn < YYLAST)
	{
	  int size = 0;
	  char *msg;
	  int x, count;

	  count = 0;
	  /* Start X at -yyn if nec to avoid negative indexes in yycheck.  */
	  for (x = (yyn < 0 ? -yyn : 0);
	       x < (sizeof(yytname) / sizeof(char *)); x++)
	    if (yycheck[x + yyn] == x)
	      size += strlen(yytname[x]) + 15, count++;
	  msg = (char *) malloc(size + 15);
	  if (msg != 0)
	    {
	      strcpy(msg, "parse error");

	      if (count < 5)
		{
		  count = 0;
		  for (x = (yyn < 0 ? -yyn : 0);
		       x < (sizeof(yytname) / sizeof(char *)); x++)
		    if (yycheck[x + yyn] == x)
		      {
			strcat(msg, count == 0 ? ", expecting `" : " or `");
			strcat(msg, yytname[x]);
			strcat(msg, "'");
			count++;
		      }
		}
	      yyerror(msg);
	      free(msg);
	    }
	  else
	    yyerror ("parse error; also virtual memory exceeded");
	}
      else
#endif /* YYERROR_VERBOSE */
	yyerror("parse error");
    }

  goto yyerrlab1;
yyerrlab1:   /* here on error raised explicitly by an action */

  if (yyerrstatus == 3)
    {
      /* if just tried and failed to reuse lookahead token after an error, discard it.  */

      /* return failure if at end of input */
      if (yychar == YYEOF)
	YYABORT;

#if YYDEBUG != 0
      if (yydebug)
	fprintf(stderr, "Discarding token %d (%s).\n", yychar, yytname[yychar1]);
#endif

      yychar = YYEMPTY;
    }

  /* Else will try to reuse lookahead token
     after shifting the error token.  */

  yyerrstatus = 3;		/* Each real token shifted decrements this */

  goto yyerrhandle;

yyerrdefault:  /* current state does not do anything special for the error token. */

#if 0
  /* This is wrong; only states that explicitly want error tokens
     should shift them.  */
  yyn = yydefact[yystate];  /* If its default is to accept any token, ok.  Otherwise pop it.*/
  if (yyn) goto yydefault;
#endif

yyerrpop:   /* pop the current state because it cannot handle the error token */

  if (yyssp == yyss) YYABORT;
  yyvsp--;
  yystate = *--yyssp;
#ifdef YYLSP_NEEDED
  yylsp--;
#endif

#if YYDEBUG != 0
  if (yydebug)
    {
      short *ssp1 = yyss - 1;
      fprintf (stderr, "Error: state stack now");
      while (ssp1 != yyssp)
	fprintf (stderr, " %d", *++ssp1);
      fprintf (stderr, "\n");
    }
#endif

yyerrhandle:

  yyn = yypact[yystate];
  if (yyn == YYFLAG)
    goto yyerrdefault;

  yyn += YYTERROR;
  if (yyn < 0 || yyn > YYLAST || yycheck[yyn] != YYTERROR)
    goto yyerrdefault;

  yyn = yytable[yyn];
  if (yyn < 0)
    {
      if (yyn == YYFLAG)
	goto yyerrpop;
      yyn = -yyn;
      goto yyreduce;
    }
  else if (yyn == 0)
    goto yyerrpop;

  if (yyn == YYFINAL)
    YYACCEPT;

#if YYDEBUG != 0
  if (yydebug)
    fprintf(stderr, "Shifting error token, ");
#endif

  *++yyvsp = yylval;
#ifdef YYLSP_NEEDED
  *++yylsp = yylloc;
#endif

  yystate = yyn;
  goto yynewstate;
}
#line 384 "alsactl_parser.y"


static void yyerror(char *string,...)
{
	char errstr[1024];

	va_list vars;
	va_start(vars, string);
	vsprintf(errstr, string, vars);
	va_end(vars);
	error("Error in configuration file '%s' (line %i): %s", cfgfile, linecount + 1, errstr);

	exit(1);
}

static void error_nomem(void)
{
	yyerror("No enough memory...\n");
}

static void build_soundcard(char *name)
{
	struct soundcard *soundcard;

	if (!name) {
		Xsoundcard = NULL;
		return;
	}
	Xsoundcard = (struct soundcard *)malloc(sizeof(struct soundcard));
	if (!Xsoundcard) {
		free(name);
		error_nomem();
		return;
	}
	bzero(Xsoundcard, sizeof(*Xsoundcard));
	for (soundcard = rsoundcards; soundcard && soundcard->next; soundcard = soundcard->next);
	if (soundcard) {
		soundcard->next = Xsoundcard;
	} else {
		rsoundcards = Xsoundcard;
	}
	strncpy(Xsoundcard->control.hwinfo.id, name, sizeof(Xsoundcard->control.hwinfo.id));
	free(name);
}

static void build_mixer(char *name)
{
	struct mixer *mixer;

	if (!name) {
		Xmixer = NULL;
		return;
	}
	Xmixer = (struct mixer *)malloc(sizeof(struct pcm));
	if (!Xmixer) {
		free(name);
		error_nomem();
		return;
	}
	bzero(Xmixer, sizeof(*Xmixer));
	for (mixer = Xsoundcard->mixers; mixer && mixer->next; mixer = mixer->next);
	if (mixer) {
		mixer->next = Xmixer;
	} else {
		Xsoundcard->mixers = Xmixer;
	}
	strncpy(Xmixer->info.name, name, sizeof(Xmixer->info.name));
	free(name);
}

static void build_pcm(char *name)
{
	struct pcm *pcm;

	if (!name) {
		Xpcm = NULL;
		return;
	}
	Xpcm = (struct pcm *)malloc(sizeof(struct pcm));
	if (!Xpcm) {
		free(name);
		error_nomem();
		return;
	}
	bzero(Xpcm, sizeof(*Xpcm));
	for (pcm = Xsoundcard->pcms; pcm && pcm->next; pcm = pcm->next);
	if (pcm) {
		pcm->next = Xpcm;
	} else {
		Xsoundcard->pcms = Xpcm;
	}
	strncpy(Xpcm->info.name, name, sizeof(Xpcm->info.name));
	free(name);
}

static void build_rawmidi(char *name)
{
	struct rawmidi *rawmidi;

	if (!name) {
		Xrawmidi = NULL;
		return;
	}
	Xrawmidi = (struct rawmidi *)malloc(sizeof(struct rawmidi));
	if (!Xrawmidi) {
		free(name);
		error_nomem();
		return;
	}
	bzero(Xrawmidi, sizeof(*Xrawmidi));
	for (rawmidi = Xsoundcard->rawmidis; rawmidi && rawmidi->next; rawmidi = rawmidi->next);
	if (rawmidi) {
		rawmidi->next = Xrawmidi;
	} else {
		Xsoundcard->rawmidis = Xrawmidi;
	}
	strncpy(Xrawmidi->info.name, name, sizeof(Xrawmidi->info.name));
	free(name);
}

static void build_mixer_element(char *name, int index, int etype)
{
	struct mixer_element *element;

	if (!name) {
		Xelement = NULL;
		return;
	}
	Xelement = (struct mixer_element *)malloc(sizeof(struct mixer_element));
	if (!Xelement) {
		free(name);
		error_nomem();
		return;
	}
	bzero(Xelement, sizeof(*Xelement));	
	for (element = Xmixer->elements; element && element->next; element = element->next);
	if (element) {
		element->next = Xelement;
	} else {
		Xmixer->elements = Xelement;
	}
	strncpy(Xelement->element.eid.name, name, sizeof(Xelement->element.eid.name));
	Xelement->element.eid.index = index;
	Xelement->element.eid.type = etype;
	Xelement->info.eid = Xelement->element.eid;
	free(name);
}

static void mixer_type_check(int type)
{
	if (Xelement->element.eid.type != type)
		yyerror("The element has got the unexpected data type.");
}

static void mixer_switch1(int end)
{
	mixer_type_check(SND_MIXER_ETYPE_SWITCH1);
}

static void mixer_switch1_value(int val)
{
	unsigned int *ptr;

	if (Xelement->element.data.switch1.sw_size <= Xelement->element.data.switch1.sw) {
		Xelement->element.data.switch1.sw_size += 32;
		ptr = (unsigned int *)realloc(Xelement->element.data.switch1.psw, ((Xelement->element.data.switch1.sw_size + 31) / 32) * sizeof(unsigned int));
		if (ptr == NULL) {
			error_nomem();
			return;
		}
		Xelement->element.data.switch1.psw = ptr;
	}
	snd_mixer_set_bit(Xelement->element.data.switch1.psw, Xelement->element.data.switch1.sw++, val ? 1 : 0);
}

static void mixer_switch2(int end)
{
	mixer_type_check(SND_MIXER_ETYPE_SWITCH2);
}

static void mixer_switch2_value(int val)
{
	Xelement->element.data.switch2.sw = val ? 1 : 0;
}

static void mixer_switch3(int end)
{
	mixer_type_check(SND_MIXER_ETYPE_SWITCH3);
}

static void mixer_switch3_value(int val)
{
	unsigned int *ptr;

	if (Xelement->element.data.switch3.rsw_size <= Xelement->element.data.switch3.rsw) {
		Xelement->element.data.switch3.rsw_size += 32;
		ptr = (unsigned int *)realloc(Xelement->element.data.switch1.psw, ((Xelement->element.data.switch3.rsw_size + 31) / 32) * sizeof(unsigned int));
		if (ptr == NULL) {
			error_nomem();
			return;
		}
		Xelement->element.data.switch3.prsw = ptr;
	}
	snd_mixer_set_bit(Xelement->element.data.switch3.prsw, Xelement->element.data.switch3.rsw++, val ? 1 : 0);
}

static void mixer_volume1(int end)
{
	mixer_type_check(SND_MIXER_ETYPE_VOLUME1);
}

static void mixer_volume1_value(int val)
{
	int *ptr;

	if (Xelement->element.data.volume1.voices_size <= Xelement->element.data.volume1.voices) {
		Xelement->element.data.volume1.voices_size += 4;
		ptr = (int *)realloc(Xelement->element.data.volume1.pvoices, Xelement->element.data.volume1.voices_size * sizeof(int));
		if (ptr == NULL) {
			error_nomem();
			return;
		}
		Xelement->element.data.volume1.pvoices = ptr;
	}
	Xelement->element.data.volume1.pvoices[Xelement->element.data.volume1.voices++] = val;
} 

static void mixer_3d_effect1(int end)
{
	mixer_type_check(SND_MIXER_ETYPE_3D_EFFECT1);
}

static void mixer_3d_effect1_value(unsigned int effect, int val)
{
	switch (effect) {
	case SND_MIXER_EFF1_SW:
		Xelement->element.data.teffect1.sw = val ? 1 : 0;
		break;
	case SND_MIXER_EFF1_MONO_SW:
		Xelement->element.data.teffect1.mono_sw = val ? 1 : 0;
		break;
	case SND_MIXER_EFF1_WIDE:
		Xelement->element.data.teffect1.wide = val;
		break;
	case SND_MIXER_EFF1_VOLUME:
		Xelement->element.data.teffect1.volume = val;
		break;
	case SND_MIXER_EFF1_CENTER:
		Xelement->element.data.teffect1.center = val;
		break;
	case SND_MIXER_EFF1_SPACE:
		Xelement->element.data.teffect1.space = val;
		break;
	case SND_MIXER_EFF1_DEPTH:
		Xelement->element.data.teffect1.depth = val;
		break;
	case SND_MIXER_EFF1_DELAY:
		Xelement->element.data.teffect1.delay = val;
		break;
	case SND_MIXER_EFF1_FEEDBACK:
		Xelement->element.data.teffect1.feedback = val;
		break;
	case SND_MIXER_EFF1_DEPTH_REAR:
		Xelement->element.data.teffect1.depth_rear = val;
		break;
	default:
		yyerror("Unknown effect 0x%x\n", effect);
	}
} 

static void mixer_accu3(int end)
{
	mixer_type_check(SND_MIXER_ETYPE_ACCU3);
}

static void mixer_accu3_value(int val)
{
	int *ptr;

	if (Xelement->element.data.accu3.voices_size <= Xelement->element.data.accu3.voices) {
		Xelement->element.data.accu3.voices_size += 4;
		ptr = (int *)realloc(Xelement->element.data.accu3.pvoices, Xelement->element.data.accu3.voices_size * sizeof(int));
		if (ptr == NULL) {
			error_nomem();
			return;
		}
		Xelement->element.data.accu3.pvoices = ptr;
	}
	Xelement->element.data.accu3.pvoices[Xelement->element.data.accu3.voices++] = val;
} 

static void mixer_mux1(int end)
{
	mixer_type_check(SND_MIXER_ETYPE_MUX1);
}

static void mixer_mux1_value(char *name, int index, int type)
{
	snd_mixer_eid_t *ptr;
	snd_mixer_eid_t *eid;

	if (Xelement->element.data.mux1.output_size <= Xelement->element.data.mux1.output) {
		Xelement->element.data.mux1.output_size += 4;
		ptr = (snd_mixer_eid_t *)realloc(Xelement->element.data.mux1.poutput, Xelement->element.data.mux1.output_size * sizeof(snd_mixer_eid_t));
		if (ptr == NULL) {
			error_nomem();
			free(name);
			return;
		}
		Xelement->element.data.mux1.poutput = ptr;
	}
	eid = &Xelement->element.data.mux1.poutput[Xelement->element.data.mux1.output++];
	strncpy(eid->name, name, sizeof(eid->name));
	eid->index = index;
	eid->type = type;
	free(name);
} 

static void mixer_mux2(int end)
{
	mixer_type_check(SND_MIXER_ETYPE_MUX2);
}

static void mixer_mux2_value(char *name, int index, int type)
{
	snd_mixer_eid_t *eid;

	eid = &Xelement->element.data.mux2.output;
	strncpy(eid->name, name, sizeof(eid->name));
	eid->index = index;
	eid->type = type;
	free(name);
} 

static void mixer_tone_control1(int end)
{
	mixer_type_check(SND_MIXER_ETYPE_TONE_CONTROL1);
}

static void mixer_tone_control1_value(unsigned int effect, int val)
{
	Xelement->element.data.tc1.tc |= effect;
	switch (effect) {
	case SND_MIXER_TC1_SW:
		Xelement->element.data.tc1.sw = val ? 1 : 0;
		break;
	case SND_MIXER_TC1_BASS:
		Xelement->element.data.tc1.bass = val;
		break;
	case SND_MIXER_TC1_TREBLE:
		Xelement->element.data.tc1.treble = val;
		break;
	default:
		yyerror("Unknown effect 0x%x\n", effect);
	}
} 

static void build_switch(struct ctl_switch **first, char *name)
{
	struct ctl_switch *sw;

	if (!name) {
		Xswitch = NULL;
		return;
	}
	Xswitch = (struct ctl_switch *)malloc(sizeof(struct ctl_switch));
	if (!Xswitch) {
		free(name);
		error_nomem();
		return;
	}
	bzero(Xswitch, sizeof(*Xswitch));
	for (sw = *first; sw && sw->next; sw = sw->next);
	if (sw) {
		sw->next = Xswitch;
	} else {
		*first = Xswitch;
	}
	strncpy(Xswitch->s.name, name, sizeof(Xswitch->s.name));
	free(name);
}

static void build_control_switch(char *name)
{
	build_switch(&Xsoundcard->control.switches, name);
}

static void build_mixer_switch(char *name)
{
	build_switch(&Xmixer->switches, name);
}

static void build_pcm_playback_switch(char *name)
{
	build_switch(&Xpcm->pswitches, name);
}

static void build_pcm_capture_switch(char *name)
{ 
	build_switch(&Xpcm->rswitches, name);
}

static void build_rawmidi_output_switch(char *name)
{
	build_switch(&Xrawmidi->oswitches, name);
}

static void build_rawmidi_input_switch(char *name)
{
	build_switch(&Xrawmidi->iswitches, name);
}

static void set_switch_boolean(int val)
{
	Xswitch->s.type = SND_SW_TYPE_BOOLEAN;
	Xswitch->s.value.enable = val ? 1 : 0;
}

static void set_switch_integer(int val)
{
	unsigned int xx;

	Xswitch->s.type = SND_SW_TYPE_DWORD;
	xx = val;
	memcpy(&Xswitch->s.value, &xx, sizeof(xx));
}

static void set_switch_bytearray(struct bytearray val)
{
	Xswitch->s.type = SND_SW_TYPE_USER;

	if (val.datalen > 32)
		yyerror("Byte array too large for switch.");

	memcpy(Xswitch->s.value.data8, val.data, val.datalen);
}

static void set_switch_iec958ocs_begin(int end)
{
	if (end) {
		Xswitch->s.value.enable = Xswitchiec958ocs;
		Xswitch->s.value.data16[4] = Xswitchiec958ocs1[4];
		Xswitch->s.value.data16[5] = Xswitchiec958ocs1[5];
#if 0
		printf("IEC958: enable = %i, ocs1[4] = 0x%x, ocs1[5] = 0x%x\n",
		       sw->value.enable,
		       sw->value.data16[4],
		       sw->value.data16[5]);
#endif
		return;
	}
	Xswitch->s.type = SND_SW_TYPE_BOOLEAN;
	Xswitch->s.value.data32[1] = ('C' << 8) | 'S';
	Xswitchiec958ocs = 0;
	Xswitchiec958ocs1[4] = 0x0000;
	Xswitchiec958ocs1[5] = 0x0004;	/* copy permitted */
}

static void set_switch_iec958ocs(int idx, unsigned short val, unsigned short mask)
{
	if (idx == 0) {
		Xswitchiec958ocs = val ? 1 : 0;
		return;
	}
	Xswitchiec958ocs1[idx] &= mask;
	Xswitchiec958ocs1[idx] |= val;
}
