/*
* Copyright (c) by Jaroslav Kysela <perex@suse.cz>
* Routines for control of AD1848/AD1847/CS4248
*
*
* 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
*/
#define SNDRV_MAIN_OBJECT_FILE
#include <sound/driver.h>
#include <linux/delay.h>
#include <linux/init.h>
#include <linux/interrupt.h>
#include <linux/slab.h>
#include <linux/ioport.h>
#include <sound/core.h>
#include <sound/ad1848.h>
#include <sound/control.h>
#include <sound/pcm_params.h>
#include <asm/io.h>
#include <asm/dma.h>
MODULE_AUTHOR("Jaroslav Kysela <perex@suse.cz>");
MODULE_DESCRIPTION("Routines for control of AD1848/AD1847/CS4248");
MODULE_LICENSE("GPL");
#if 0
#define SNDRV_DEBUG_MCE
#endif
/*
* Some variables
*/
static unsigned char freq_bits[14] = {
/* 5510 */ 0x00 | AD1848_XTAL2,
/* 6620 */ 0x0E | AD1848_XTAL2,
/* 8000 */ 0x00 | AD1848_XTAL1,
/* 9600 */ 0x0E | AD1848_XTAL1,
/* 11025 */ 0x02 | AD1848_XTAL2,
/* 16000 */ 0x02 | AD1848_XTAL1,
/* 18900 */ 0x04 | AD1848_XTAL2,
/* 22050 */ 0x06 | AD1848_XTAL2,
/* 27042 */ 0x04 | AD1848_XTAL1,
/* 32000 */ 0x06 | AD1848_XTAL1,
/* 33075 */ 0x0C | AD1848_XTAL2,
/* 37800 */ 0x08 | AD1848_XTAL2,
/* 44100 */ 0x0A | AD1848_XTAL2,
/* 48000 */ 0x0C | AD1848_XTAL1
};
static unsigned int rates[14] = {
5510, 6620, 8000, 9600, 11025, 16000, 18900, 22050,
27042, 32000, 33075, 37800, 44100, 48000
};
static struct snd_pcm_hw_constraint_list hw_constraints_rates = {
.count = 14,
.list = rates,
.mask = 0,
};
static unsigned char snd_ad1848_original_image[16] =
{
0x00, /* 00 - lic */
0x00, /* 01 - ric */
0x9f, /* 02 - la1ic */
0x9f, /* 03 - ra1ic */
0x9f, /* 04 - la2ic */
0x9f, /* 05 - ra2ic */
0xbf, /* 06 - loc */
0xbf, /* 07 - roc */
0x20, /* 08 - dfr */
AD1848_AUTOCALIB, /* 09 - ic */
0x00, /* 0a - pc */
0x00, /* 0b - ti */
0x00, /* 0c - mi */
0x00, /* 0d - lbc */
0x00, /* 0e - dru */
0x00, /* 0f - drl */
};
/*
* Basic I/O functions
*/
void snd_ad1848_out(struct snd_ad1848 *chip,
unsigned char reg,
unsigned char value)
{
int timeout;
for