Blame modules/mixer/simple/hda.c

Packit 4a16fb
/*
Packit 4a16fb
 *  Mixer Interface - HDA simple abstact module
Packit 4a16fb
 *  Copyright (c) 2005 by Jaroslav Kysela <perex@perex.cz>
Packit 4a16fb
 *
Packit 4a16fb
 *
Packit 4a16fb
 *   This library is free software; you can redistribute it and/or modify
Packit 4a16fb
 *   it under the terms of the GNU Lesser General Public License as
Packit 4a16fb
 *   published by the Free Software Foundation; either version 2.1 of
Packit 4a16fb
 *   the License, or (at your option) any later version.
Packit 4a16fb
 *
Packit 4a16fb
 *   This program is distributed in the hope that it will be useful,
Packit 4a16fb
 *   but WITHOUT ANY WARRANTY; without even the implied warranty of
Packit 4a16fb
Packit 4a16fb
 *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
Packit 4a16fb
 *   GNU Lesser General Public License for more details.
Packit 4a16fb
 *
Packit 4a16fb
 *   You should have received a copy of the GNU Lesser General Public
Packit 4a16fb
 *   License along with this library; if not, write to the Free Software
Packit 4a16fb
 *   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
Packit 4a16fb
 *
Packit 4a16fb
 */
Packit 4a16fb
Packit 4a16fb
#include <stdio.h>
Packit 4a16fb
#include <stdlib.h>
Packit 4a16fb
#include <unistd.h>
Packit 4a16fb
#include <string.h>
Packit 4a16fb
#include <fcntl.h>
Packit 4a16fb
#include <sys/ioctl.h>
Packit 4a16fb
#include <math.h>
Packit 4a16fb
#include "asoundlib.h"
Packit 4a16fb
#include "mixer_abst.h"
Packit 4a16fb
#include "sbase.h"
Packit 4a16fb
Packit 4a16fb
static struct sm_elem_ops simple_hda_ops;
Packit 4a16fb
Packit 4a16fb
struct melem_sids sids[] = {
Packit 4a16fb
	{
Packit 4a16fb
		.sid	= SID_FRONT,
Packit 4a16fb
		.sname	= "Front",
Packit 4a16fb
		.sindex	= 0,
Packit 4a16fb
		.weight = 1,
Packit 4a16fb
		.chanmap = { 3, 0 },
Packit 4a16fb
		.sops = &simple_hda_ops,
Packit 4a16fb
	}
Packit 4a16fb
};
Packit 4a16fb
Packit 4a16fb
#define SELECTORS (sizeof(selectors)/sizeof(selectors[0]))
Packit 4a16fb
Packit 4a16fb
struct helem_selector selectors[] = {
Packit 4a16fb
	{
Packit 4a16fb
		.iface =	SND_CTL_ELEM_IFACE_MIXER,
Packit 4a16fb
		.name =		"Front Playback Volume",
Packit 4a16fb
		.index = 	0,
Packit 4a16fb
		.sid =		SID_FRONT,
Packit 4a16fb
		.purpose =	PURPOSE_VOLUME,
Packit 4a16fb
		.caps = 	SM_CAP_PVOLUME,
Packit 4a16fb
	},
Packit 4a16fb
	{
Packit 4a16fb
		.iface =	SND_CTL_ELEM_IFACE_MIXER,
Packit 4a16fb
		.name =		"Front Playback Switch",
Packit 4a16fb
		.index = 	0,
Packit 4a16fb
		.sid =		SID_FRONT,
Packit 4a16fb
		.purpose =	PURPOSE_SWITCH,
Packit 4a16fb
		.caps = 	SM_CAP_PSWITCH,
Packit 4a16fb
	}
Packit 4a16fb
};
Packit 4a16fb
Packit 4a16fb
int alsa_mixer_simple_event(snd_mixer_class_t *class, unsigned int mask,
Packit 4a16fb
			    snd_hctl_elem_t *helem, snd_mixer_elem_t *melem)
Packit 4a16fb
{
Packit 4a16fb
	struct bclass_private *priv = snd_mixer_sbasic_get_private(class);
Packit 4a16fb
	return priv->ops.event(class, mask, helem, melem);
Packit 4a16fb
}
Packit 4a16fb
Packit 4a16fb
int alsa_mixer_simple_init(snd_mixer_class_t *class)
Packit 4a16fb
{
Packit 4a16fb
	struct bclass_base_ops *ops;
Packit 4a16fb
	int err;
Packit 4a16fb
	
Packit 4a16fb
	err = mixer_simple_basic_dlopen(class, &ops;;
Packit 4a16fb
	if (err < 0)
Packit 4a16fb
		return 0;
Packit 4a16fb
	err = ops->selreg(class, selectors, SELECTORS);
Packit 4a16fb
	if (err < 0)
Packit 4a16fb
		return err;
Packit 4a16fb
	err = ops->sidreg(class, sids, SELECTORS);
Packit 4a16fb
	if (err < 0)
Packit 4a16fb
		return err;
Packit 4a16fb
	return 0;
Packit 4a16fb
}