/*
    Part of this file comes from envy24control alsa tool

    Copyright (c) 2007  Valentin RUSU kenvy24@rusu.info

    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) version 3 or, at the discretion of KDE e.V. (which shall
    act as a proxy as in section 14 of the GPLv3), 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, see <http://www.gnu.org/licenses/>.
*/
#ifndef _ENVVY24CONTROL_H_INCLUDED_
#define _ENVVY24CONTROL_H_INCLUDED_

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <signal.h>
#include <errno.h>
#include <assert.h>
#include <alsa/asoundlib.h>

/* Profiles */
#ifdef PACKAGE
#define PROGRAM_NAME PACKAGE
#else
#define PROGRAM_NAME "envy24control"
#endif
#define MAX_PROFILES 8
#define MAX_PROFILE_NAME_LENGTH 20
#define DEFAULT_PROFILERC "~/envy24control/profiles.conf"
#define SYS_PROFILERC "/etc/envy24control/profiles.conf"
#ifndef MKDIR
#define MKDIR "/bin/mkdir"
#endif
#ifndef ALSACTL
#define ALSACTL "/usr/sbin/alsactl"
#endif

#include "profiles.h"

/* MidiMan */
#define ICE1712_SUBDEVICE_DELTA1010	0x121430d6
#define ICE1712_SUBDEVICE_DELTADIO2496	0x121431d6
#define ICE1712_SUBDEVICE_DELTA66	0x121432d6
#define ICE1712_SUBDEVICE_DELTA44	0x121433d6
#define ICE1712_SUBDEVICE_AUDIOPHILE    0x121434d6
#define ICE1712_SUBDEVICE_DELTA410      0x121438d6
#define ICE1712_SUBDEVICE_DELTA1010LT   0x12143bd6

/* Terratec */
#define ICE1712_SUBDEVICE_EWX2496       0x3b153011
#define ICE1712_SUBDEVICE_EWS88MT       0x3b151511
#define ICE1712_SUBDEVICE_EWS88D        0x3b152b11
#define ICE1712_SUBDEVICE_DMX6FIRE      0x3b153811

/* Hoontech */
#define ICE1712_SUBDEVICE_STDSP24       0x12141217      /* Hoontech SoundTrack Audio DSP 24 */

/* max number of cards for alsa */
#define MAX_CARD_NUMBERS	8
/* max number of HW input/output channels (analog lines)
 * the number of available HW input/output channels is defined
 * at 'adcs/dacs' in the driver
 */
/* max number of HW input channels (analog lines) */
#define MAX_INPUT_CHANNELS	8
/* max number of HW output channels (analog lines) */
#define MAX_OUTPUT_CHANNELS	8
/* max number of spdif input/output channels */
#define MAX_SPDIF_CHANNELS	2
/* max number of PCM output channels */
#define MAX_PCM_OUTPUT_CHANNELS	8

typedef struct {
	unsigned int subvendor;	/* PCI[2c-2f] */
	unsigned char size;	/* size of EEPROM image in bytes */
	unsigned char version;	/* must be 1 */
	unsigned char codec;	/* codec configuration PCI[60] */
	unsigned char aclink;	/* ACLink configuration PCI[61] */
	unsigned char i2sID;	/* PCI[62] */
	unsigned char spdif;	/* S/PDIF configuration PCI[63] */
	unsigned char gpiomask;	/* GPIO initial mask, 0 = write, 1 = don't */
	unsigned char gpiostate; /* GPIO initial state */
	unsigned char gpiodir;	/* GPIO direction state */
	unsigned short ac97main;
	unsigned short ac97pcm;
	unsigned short ac97rec;
	unsigned char ac97recsrc;
	unsigned char dacID[4];	/* I2S IDs for DACs */
	unsigned char adcID[4];	/* I2S IDs for ADCs */
	unsigned char extra[4];
} ice1712_eeprom_t;

extern snd_ctl_t *ctl;
extern ice1712_eeprom_t card_eeprom;

#endif // _ENVVY24CONTROL_H_INCLUDED_
