1/* 2 * Mixer Interface - AC97 simple abstact module 3 * Copyright (c) 2005 by Jaroslav Kysela <perex@perex.cz> 4 * 5 * 6 * This library is free software; you can redistribute it and/or modify 7 * it under the terms of the GNU Lesser General Public License as 8 * published by the Free Software Foundation; either version 2.1 of 9 * the License, or (at your option) any later version. 10 * 11 * This program is distributed in the hope that it will be useful, 12 * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 * GNU Lesser General Public License for more details. 15 * 16 * You should have received a copy of the GNU Lesser General Public 17 * License along with this library; if not, write to the Free Software 18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 19 * 20 */ 21 22#include <stdio.h> 23#include <stdlib.h> 24#include <unistd.h> 25#include <string.h> 26#include <fcntl.h> 27#include <sys/ioctl.h> 28#include <math.h> 29#include "asoundlib.h" 30#include "mixer_abst.h" 31#include "sbase.h" 32 33static struct sm_elem_ops simple_ac97_ops; 34 35struct melem_sids sids[] = { 36 { 37 .sid = SID_MASTER, 38 .sname = "Master", 39 .sindex = 0, 40 .weight = 1, 41 .chanmap = { 3, 0 }, 42 .sops = &simple_ac97_ops, 43 } 44}; 45 46#define SELECTORS (sizeof(selectors)/sizeof(selectors[0])) 47 48struct helem_selector selectors[] = { 49 { 50 .iface = SND_CTL_ELEM_IFACE_MIXER, 51 .name = "Master Playback Volume", 52 .index = 0, 53 .sid = SID_MASTER, 54 .purpose = PURPOSE_VOLUME, 55 .caps = SM_CAP_PVOLUME, 56 }, 57 { 58 .iface = SND_CTL_ELEM_IFACE_MIXER, 59 .name = "Master Playback Switch", 60 .index = 0, 61 .sid = SID_MASTER, 62 .purpose = PURPOSE_SWITCH, 63 .caps = SM_CAP_PSWITCH, 64 } 65}; 66 67int alsa_mixer_simple_event(snd_mixer_class_t *class, unsigned int mask, 68 snd_hctl_elem_t *helem, snd_mixer_elem_t *melem) 69{ 70 struct bclass_private *priv = snd_mixer_sbasic_get_private(class); 71 return priv->ops.event(class, mask, helem, melem); 72} 73 74int alsa_mixer_simple_init(snd_mixer_class_t *class) 75{ 76 struct bclass_base_ops *ops; 77 int err; 78 79 err = mixer_simple_basic_dlopen(class, &ops); 80 if (err < 0) 81 return 0; 82 err = ops->selreg(class, selectors, SELECTORS); 83 if (err < 0) 84 return err; 85 err = ops->sidreg(class, sids, SELECTORS); 86 if (err < 0) 87 return err; 88 return 0; 89} 90