1/*
2 *  Mixer Interface - HDA 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
14 *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15 *   GNU Lesser General Public License for more details.
16 *
17 *   You should have received a copy of the GNU Lesser General Public
18 *   License along with this library; if not, write to the Free Software
19 *   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
20 *
21 */
22
23#include <stdio.h>
24#include <stdlib.h>
25#include <unistd.h>
26#include <string.h>
27#include <fcntl.h>
28#include <sys/ioctl.h>
29#include <math.h>
30#include "asoundlib.h"
31#include "mixer_abst.h"
32#include "sbase.h"
33
34static struct sm_elem_ops simple_hda_ops;
35
36struct melem_sids sids[] = {
37	{
38		.sid	= SID_FRONT,
39		.sname	= "Front",
40		.sindex	= 0,
41		.weight = 1,
42		.chanmap = { 3, 0 },
43		.sops = &simple_hda_ops,
44	}
45};
46
47#define SELECTORS (sizeof(selectors)/sizeof(selectors[0]))
48
49struct helem_selector selectors[] = {
50	{
51		.iface =	SND_CTL_ELEM_IFACE_MIXER,
52		.name =		"Front Playback Volume",
53		.index = 	0,
54		.sid =		SID_FRONT,
55		.purpose =	PURPOSE_VOLUME,
56		.caps = 	SM_CAP_PVOLUME,
57	},
58	{
59		.iface =	SND_CTL_ELEM_IFACE_MIXER,
60		.name =		"Front Playback Switch",
61		.index = 	0,
62		.sid =		SID_FRONT,
63		.purpose =	PURPOSE_SWITCH,
64		.caps = 	SM_CAP_PSWITCH,
65	}
66};
67
68int alsa_mixer_simple_event(snd_mixer_class_t *class, unsigned int mask,
69			    snd_hctl_elem_t *helem, snd_mixer_elem_t *melem)
70{
71	struct bclass_private *priv = snd_mixer_sbasic_get_private(class);
72	return priv->ops.event(class, mask, helem, melem);
73}
74
75int alsa_mixer_simple_init(snd_mixer_class_t *class)
76{
77	struct bclass_base_ops *ops;
78	int err;
79
80	err = mixer_simple_basic_dlopen(class, &ops);
81	if (err < 0)
82		return 0;
83	err = ops->selreg(class, selectors, SELECTORS);
84	if (err < 0)
85		return err;
86	err = ops->sidreg(class, sids, SELECTORS);
87	if (err < 0)
88		return err;
89	return 0;
90}
91