cregit-Linux how code gets into the kernel

Release 4.8 sound/isa/es18xx.c

Directory: sound/isa
/*
 *  Driver for generic ESS AudioDrive ES18xx soundcards
 *  Copyright (c) by Christian Fischbach <fishbach@pool.informatik.rwth-aachen.de>
 *  Copyright (c) by Abramo Bagnara <abramo@alsa-project.org>
 *
 *
 *   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
 *
 */
/* GENERAL NOTES:
 *
 * BUGS:
 * - There are pops (we can't delay in trigger function, cause midlevel 
 *   often need to trigger down and then up very quickly).
 *   Any ideas?
 * - Support for 16 bit DMA seems to be broken. I've no hardware to tune it.
 */

/*
 * ES1868  NOTES:
 * - The chip has one half duplex pcm (with very limited full duplex support).
 *
 * - Duplex stereophonic sound is impossible.
 * - Record and playback must share the same frequency rate.
 *
 * - The driver use dma2 for playback and dma1 for capture.
 */

/*
 * ES1869 NOTES:
 *
 * - there are a first full duplex pcm and a second playback only pcm
 *   (incompatible with first pcm capture)
 * 
 * - there is support for the capture volume and ESS Spatializer 3D effect.
 *
 * - contrarily to some pages in DS_1869.PDF the rates can be set
 *   independently.
 *
 * - Zoom Video is implemented by sharing the FM DAC, thus the user can
 *   have either FM playback or Video playback but not both simultaneously.
 *   The Video Playback Switch mixer control toggles this choice.
 *
 * BUGS:
 *
 * - There is a major trouble I noted:
 *
 *   using both channel for playback stereo 16 bit samples at 44100 Hz
 *   the second pcm (Audio1) DMA slows down irregularly and sound is garbled.
 *   
 *   The same happens using Audio1 for captureing.
 *
 *   The Windows driver does not suffer of this (although it use Audio1
 *   only for captureing). I'm unable to discover why.
 *
 */

/*
 * ES1879 NOTES:
 * - When Zoom Video is enabled (reg 0x71 bit 6 toggled on) the PCM playback
 *   seems to be effected (speaker_test plays a lower frequency). Can't find
 *   anything in the datasheet to account for this, so a Video Playback Switch
 *   control has been included to allow ZV to be enabled only when necessary.
 *   Then again on at least one test system the 0x71 bit 6 enable bit is not 
 *   needed for ZV, so maybe the datasheet is entirely wrong here.
 */
 
#include <linux/init.h>
#include <linux/err.h>
#include <linux/isa.h>
#include <linux/pnp.h>
#include <linux/isapnp.h>
#include <linux/module.h>
#include <linux/delay.h>
#include <linux/io.h>

#include <asm/dma.h>
#include <sound/core.h>
#include <sound/control.h>
#include <sound/pcm.h>
#include <sound/pcm_params.h>
#include <sound/mpu401.h>
#include <sound/opl3.h>

#define SNDRV_LEGACY_FIND_FREE_IRQ

#define SNDRV_LEGACY_FIND_FREE_DMA
#include <sound/initval.h>


#define PFX "es18xx: "


struct snd_es18xx {
	
unsigned long port;		/* port of ESS chip */
	
unsigned long ctrl_port;	/* Control port of ESS chip */
	
struct resource *res_port;
	
struct resource *res_mpu_port;
	
struct resource *res_ctrl_port;
	
int irq;			/* IRQ number of ESS chip */
	
int dma1;			/* DMA1 */
	
int dma2;			/* DMA2 */
	
unsigned short version;		/* version of ESS chip */
	
int caps;			/* Chip capabilities */
	
unsigned short audio2_vol;	/* volume level of audio2 */

	
unsigned short active;		/* active channel mask */
	
unsigned int dma1_shift;
	
unsigned int dma2_shift;

	
struct snd_pcm *pcm;
	
struct snd_pcm_substream *playback_a_substream;
	
struct snd_pcm_substream *capture_a_substream;
	
struct snd_pcm_substream *playback_b_substream;

	
struct snd_rawmidi *rmidi;

	
struct snd_kcontrol *hw_volume;
	
struct snd_kcontrol *hw_switch;
	
struct snd_kcontrol *master_volume;
	
struct snd_kcontrol *master_switch;

	
spinlock_t reg_lock;
	
spinlock_t mixer_lock;
#ifdef CONFIG_PM
	
unsigned char pm_reg;
#endif
#ifdef CONFIG_PNP
	
struct pnp_dev *dev;
	
struct pnp_dev *devc;
#endif
};


#define AUDIO1_IRQ	0x01

#define AUDIO2_IRQ	0x02

#define HWV_IRQ		0x04

#define MPU_IRQ		0x08


#define ES18XX_PCM2	0x0001	
/* Has two useable PCM */

#define ES18XX_SPATIALIZER 0x0002	
/* Has 3D Spatializer */

#define ES18XX_RECMIX	0x0004	
/* Has record mixer */

#define ES18XX_DUPLEX_MONO 0x0008	
/* Has mono duplex only */

#define ES18XX_DUPLEX_SAME 0x0010	
/* Playback and record must share the same rate */

#define ES18XX_NEW_RATE	0x0020	
/* More precise rate setting */

#define ES18XX_AUXB	0x0040	
/* AuxB mixer control */

#define ES18XX_HWV	0x0080	
/* Has separate hardware volume mixer controls*/

#define ES18XX_MONO	0x0100	
/* Mono_in mixer control */

#define ES18XX_I2S	0x0200	
/* I2S mixer control */

#define ES18XX_MUTEREC	0x0400	
/* Record source can be muted */

#define ES18XX_CONTROL	0x0800	
/* Has control ports */

#define ES18XX_GPO_2BIT	0x1000	
/* GPO0,1 controlled by PM port */

/* Power Management */

#define ES18XX_PM	0x07

#define ES18XX_PM_GPO0	0x01

#define ES18XX_PM_GPO1	0x02

#define ES18XX_PM_PDR	0x04

#define ES18XX_PM_ANA	0x08

#define ES18XX_PM_FM	0x020

#define ES18XX_PM_SUS	0x080

/* Lowlevel */


#define DAC1 0x01

#define ADC1 0x02

#define DAC2 0x04

#define MILLISECOND 10000


static int snd_es18xx_dsp_command(struct snd_es18xx *chip, unsigned char val) { int i; for(i = MILLISECOND; i; i--) if ((inb(chip->port + 0x0C) & 0x80) == 0) { outb(val, chip->port + 0x0C); return 0; } snd_printk(KERN_ERR "dsp_command: timeout (0x%x)\n", val); return -EINVAL; }

Contributors

PersonTokensPropCommitsCommitProp
jaroslav kyselajaroslav kysela7195.95%133.33%
takashi iwaitakashi iwai34.05%266.67%
Total74100.00%3100.00%


static int snd_es18xx_dsp_get_byte(struct snd_es18xx *chip) { int i; for(i = MILLISECOND/10; i; i--) if (inb(chip->port + 0x0C) & 0x40) return inb(chip->port + 0x0A); snd_printk(KERN_ERR "dsp_get_byte failed: 0x%lx = 0x%x!!!\n", chip->port + 0x0A, inb(chip->port + 0x0A)); return -ENODEV; }

Contributors

PersonTokensPropCommitsCommitProp
jaroslav kyselajaroslav kysela7296.00%133.33%
takashi iwaitakashi iwai34.00%266.67%
Total75100.00%3100.00%

#undef REG_DEBUG
static int snd_es18xx_write(struct snd_es18xx *chip, unsigned char reg, unsigned char data) { unsigned long flags; int ret; spin_lock_irqsave(&chip->reg_lock, flags); ret = snd_es18xx_dsp_command(chip, reg); if (ret < 0) goto end; ret = snd_es18xx_dsp_command(chip, data); end: spin_unlock_irqrestore(&chip->reg_lock, flags); #ifdef REG_DEBUG snd_printk(KERN_DEBUG "Reg %02x set to %02x\n", reg, data); #endif return ret; }

Contributors

PersonTokensPropCommitsCommitProp
jaroslav kyselajaroslav kysela9096.77%133.33%
takashi iwaitakashi iwai33.23%266.67%
Total93100.00%3100.00%


static int snd_es18xx_read(struct snd_es18xx *chip, unsigned char reg) { unsigned long flags; int ret, data; spin_lock_irqsave(&chip->reg_lock, flags); ret = snd_es18xx_dsp_command(chip, 0xC0); if (ret < 0) goto end; ret = snd_es18xx_dsp_command(chip, reg); if (ret < 0) goto end; data = snd_es18xx_dsp_get_byte(chip); ret = data; #ifdef REG_DEBUG snd_printk(KERN_DEBUG "Reg %02x now is %02x (%d)\n", reg, data, ret); #endif end: spin_unlock_irqrestore(&chip->reg_lock, flags); return ret; }

Contributors

PersonTokensPropCommitsCommitProp
jaroslav kyselajaroslav kysela11097.35%133.33%
takashi iwaitakashi iwai32.65%266.67%
Total113100.00%3100.00%

/* Return old value */
static int snd_es18xx_bits(struct snd_es18xx *chip, unsigned char reg, unsigned char mask, unsigned char val) { int ret; unsigned char old, new, oval; unsigned long flags; spin_lock_irqsave(&chip->reg_lock, flags); ret = snd_es18xx_dsp_command(chip, 0xC0); if (ret < 0) goto end; ret = snd_es18xx_dsp_command(chip, reg); if (ret < 0) goto end; ret = snd_es18xx_dsp_get_byte(chip); if (ret < 0) { goto end; } old = ret; oval = old & mask; if (val != oval) { ret = snd_es18xx_dsp_command(chip, reg); if (ret < 0) goto end; new = (old & ~mask) | (val & mask); ret = snd_es18xx_dsp_command(chip, new); if (ret < 0) goto end; #ifdef REG_DEBUG snd_printk(KERN_DEBUG "Reg %02x was %02x, set to %02x (%d)\n", reg, old, new, ret); #endif } ret = oval; end: spin_unlock_irqrestore(&chip->reg_lock, flags); return ret; }

Contributors

PersonTokensPropCommitsCommitProp
jaroslav kyselajaroslav kysela20698.56%133.33%
takashi iwaitakashi iwai31.44%266.67%
Total209100.00%3100.00%


static inline void snd_es18xx_mixer_write(struct snd_es18xx *chip, unsigned char reg, unsigned char data) { unsigned long flags; spin_lock_irqsave(&chip->mixer_lock, flags); outb(reg, chip->port + 0x04); outb(data, chip->port + 0x05); spin_unlock_irqrestore(&chip->mixer_lock, flags); #ifdef REG_DEBUG snd_printk(KERN_DEBUG "Mixer reg %02x set to %02x\n", reg, data); #endif }

Contributors

PersonTokensPropCommitsCommitProp
jaroslav kyselajaroslav kysela7896.30%250.00%
takashi iwaitakashi iwai33.70%250.00%
Total81100.00%4100.00%


static inline int snd_es18xx_mixer_read(struct snd_es18xx *chip, unsigned char reg) { unsigned long flags; int data; spin_lock_irqsave(&chip->mixer_lock, flags); outb(reg, chip->port + 0x04); data = inb(chip->port + 0x05); spin_unlock_irqrestore(&chip->mixer_lock, flags); #ifdef REG_DEBUG snd_printk(KERN_DEBUG "Mixer reg %02x now is %02x\n", reg, data); #endif return data; }

Contributors

PersonTokensPropCommitsCommitProp
jaroslav kyselajaroslav kysela8096.39%250.00%
takashi iwaitakashi iwai33.61%250.00%
Total83100.00%4100.00%

/* Return old value */
static inline int snd_es18xx_mixer_bits(struct snd_es18xx *chip, unsigned char reg, unsigned char mask, unsigned char val) { unsigned char old, new, oval; unsigned long flags; spin_lock_irqsave(&chip->mixer_lock, flags); outb(reg, chip->port + 0x04); old = inb(chip->port + 0x05); oval = old & mask; if (val != oval) { new = (old & ~mask) | (val & mask); outb(new, chip->port + 0x05); #ifdef REG_DEBUG snd_printk(KERN_DEBUG "Mixer reg %02x was %02x, set to %02x\n", reg, old, new); #endif } spin_unlock_irqrestore(&chip->mixer_lock, flags); return oval; }

Contributors

PersonTokensPropCommitsCommitProp
jaroslav kyselajaroslav kysela13597.83%133.33%
takashi iwaitakashi iwai32.17%266.67%
Total138100.00%3100.00%


static inline int snd_es18xx_mixer_writable(struct snd_es18xx *chip, unsigned char reg, unsigned char mask) { int old, expected, new; unsigned long flags; spin_lock_irqsave(&chip->mixer_lock, flags); outb(reg, chip->port + 0x04); old = inb(chip->port + 0x05); expected = old ^ mask; outb(expected, chip->port + 0x05); new = inb(chip->port + 0x05); spin_unlock_irqrestore(&chip->mixer_lock, flags); #ifdef REG_DEBUG snd_printk(KERN_DEBUG "Mixer reg %02x was %02x, set to %02x, now is %02x\n", reg, old, expected, new); #endif return expected == new; }

Contributors

PersonTokensPropCommitsCommitProp
jaroslav kyselajaroslav kysela12297.60%133.33%
takashi iwaitakashi iwai32.40%266.67%
Total125100.00%3100.00%


static int snd_es18xx_reset(struct snd_es18xx *chip) { int i; outb(0x03, chip->port + 0x06); inb(chip->port + 0x06); outb(0x00, chip->port + 0x06); for(i = 0; i < MILLISECOND && !(inb(chip->port + 0x0E) & 0x80); i++); if (inb(chip->port + 0x0A) != 0xAA) return -1; return 0; }

Contributors

PersonTokensPropCommitsCommitProp
jaroslav kyselajaroslav kysela9197.85%150.00%
takashi iwaitakashi iwai22.15%150.00%
Total93100.00%2100.00%


static int snd_es18xx_reset_fifo(struct snd_es18xx *chip) { outb(0x02, chip->port + 0x06); inb(chip->port + 0x06); outb(0x00, chip->port + 0x06); return 0; }

Contributors

PersonTokensPropCommitsCommitProp
jaroslav kyselajaroslav kysela4395.56%150.00%
takashi iwaitakashi iwai24.44%150.00%
Total45100.00%2100.00%

static struct snd_ratnum new_clocks[2] = { { .num = 793800, .den_min = 1, .den_max = 128, .den_step = 1, }, { .num = 768000, .den_min = 1, .den_max = 128, .den_step = 1, } }; static struct snd_pcm_hw_constraint_ratnums new_hw_constraints_clocks = { .nrats = 2, .rats = new_clocks, }; static struct snd_ratnum old_clocks[2] = { { .num = 795444, .den_min = 1, .den_max = 128, .den_step = 1, }, { .num = 397722, .den_min = 1, .den_max = 128, .den_step = 1, } }; static struct snd_pcm_hw_constraint_ratnums old_hw_constraints_clocks = { .nrats = 2, .rats = old_clocks, };
static void snd_es18xx_rate_set(struct snd_es18xx *chip, struct snd_pcm_substream *substream, int mode) { unsigned int bits, div0; struct snd_pcm_runtime *runtime = substream->runtime; if (chip->caps & ES18XX_NEW_RATE) { if (runtime->rate_num == new_clocks[0].num) bits = 128 - runtime->rate_den; else bits = 256 - runtime->rate_den; } else { if (runtime->rate_num == old_clocks[0].num) bits = 256 - runtime->rate_den; else bits = 128 - runtime->rate_den; } /* set filter register */ div0 = 256 - 7160000*20/(8*82*runtime->rate); if ((chip->caps & ES18XX_PCM2) && mode == DAC2) { snd_es18xx_mixer_write(chip, 0x70, bits); /* * Comment from kernel oss driver: * FKS: fascinating: 0x72 doesn't seem to work. */ snd_es18xx_write(chip, 0xA2, div0); snd_es18xx_mixer_write(chip, 0x72, div0); } else { snd_es18xx_write(chip, 0xA1, bits); snd_es18xx_write(chip, 0xA2, div0); } }

Contributors

PersonTokensPropCommitsCommitProp
jaroslav kyselajaroslav kysela18596.86%266.67%
takashi iwaitakashi iwai63.14%133.33%
Total191100.00%3100.00%


static int snd_es18xx_playback_hw_params(struct snd_pcm_substream *substream, struct snd_pcm_hw_params *hw_params) { struct snd_es18xx *chip = snd_pcm_substream_chip(substream); int shift, err; shift = 0; if (params_channels(hw_params) == 2) shift++; if (snd_pcm_format_width(params_format(hw_params)) == 16) shift++; if (substream->number == 0 && (chip->caps & ES18XX_PCM2)) { if ((chip->caps & ES18XX_DUPLEX_MONO) && (chip->capture_a_substream) && params_channels(hw_params) != 1) { _snd_pcm_hw_param_setempty(hw_params, SNDRV_PCM_HW_PARAM_CHANNELS); return -EBUSY; } chip->dma2_shift = shift; } else { chip->dma1_shift = shift; } if ((err = snd_pcm_lib_malloc_pages(substream, params_buffer_bytes(hw_params))) < 0) return err; return 0; }

Contributors

PersonTokensPropCommitsCommitProp
jaroslav kyselajaroslav kysela14996.13%266.67%
takashi iwaitakashi iwai63.87%133.33%
Total155100.00%3100.00%


static int snd_es18xx_pcm_hw_free(struct snd_pcm_substream *substream) { return snd_pcm_lib_free_pages(substream); }

Contributors

PersonTokensPropCommitsCommitProp
jaroslav kyselajaroslav kysela1588.24%150.00%
takashi iwaitakashi iwai211.76%150.00%
Total17100.00%2100.00%


static int snd_es18xx_playback1_prepare(struct snd_es18xx *chip, struct snd_pcm_substream *substream) { struct snd_pcm_runtime *runtime = substream->runtime; unsigned int size = snd_pcm_lib_buffer_bytes(substream); unsigned int count = snd_pcm_lib_period_bytes(substream); snd_es18xx_rate_set(chip, substream, DAC2); /* Transfer Count Reload */ count = 0x10000 - count; snd_es18xx_mixer_write(chip, 0x74, count & 0xff); snd_es18xx_mixer_write(chip, 0x76, count >> 8); /* Set format */ snd_es18xx_mixer_bits(chip, 0x7A, 0x07, ((runtime->channels == 1) ? 0x00 : 0x02) | (snd_pcm_format_width(runtime->format) == 16 ? 0x01 : 0x00) | (snd_pcm_format_unsigned(runtime->format) ? 0x00 : 0x04)); /* Set DMA controller */ snd_dma_program(chip->dma2, runtime->dma_addr, size, DMA_MODE_WRITE | DMA_AUTOINIT); return 0; }

Contributors

PersonTokensPropCommitsCommitProp
jaroslav kyselajaroslav kysela14896.10%266.67%
takashi iwaitakashi iwai63.90%133.33%
Total154100.00%3100.00%


static int snd_es18xx_playback1_trigger(struct snd_es18xx *chip, struct snd_pcm_substream *substream, int cmd) { switch (cmd) { case SNDRV_PCM_TRIGGER_START: case SNDRV_PCM_TRIGGER_RESUME: if (chip->active & DAC2) return 0; chip->active |= DAC2; /* Start DMA */ if (chip->dma2 >= 4) snd_es18xx_mixer_write(chip, 0x78, 0xb3); else snd_es18xx_mixer_write(chip, 0x78, 0x93); #ifdef AVOID_POPS /* Avoid pops */ mdelay(100); if (chip->caps & ES18XX_PCM2) /* Restore Audio 2 volume */ snd_es18xx_mixer_write(chip, 0x7C, chip->audio2_vol); else /* Enable PCM output */ snd_es18xx_dsp_command(chip, 0xD1); #endif break; case SNDRV_PCM_TRIGGER_STOP: case SNDRV_PCM_TRIGGER_SUSPEND: if (!(chip->active & DAC2)) return 0; chip->active &= ~DAC2; /* Stop DMA */ snd_es18xx_mixer_write(chip, 0x78, 0x00); #ifdef AVOID_POPS mdelay(25); if (chip->caps & ES18XX_PCM2) /* Set Audio 2 volume to 0 */ snd_es18xx_mixer_write(chip, 0x7C, 0); else /* Disable PCM output */ snd_es18xx_dsp_command(chip, 0xD3); #endif break; default: return -EINVAL; } return 0; }

Contributors

PersonTokensPropCommitsCommitProp
jaroslav kyselajaroslav kysela19296.00%250.00%
zhen-hua lizhen-hua li42.00%125.00%
takashi iwaitakashi iwai42.00%125.00%
Total200100.00%4100.00%


static int snd_es18xx_capture_hw_params(struct snd_pcm_substream *substream, struct snd_pcm_hw_params *hw_params) { struct snd_es18xx *chip = snd_pcm_substream_chip(substream); int shift, err; shift = 0; if ((chip->caps & ES18XX_DUPLEX_MONO) && chip->playback_a_substream && params_channels(hw_params) != 1) { _snd_pcm_hw_param_setempty(hw_params, SNDRV_PCM_HW_PARAM_CHANNELS); return -EBUSY; } if (params_channels(hw_params) == 2) shift++; if (snd_pcm_format_width(params_format(hw_params)) == 16) shift++; chip->dma1_shift = shift; if ((err = snd_pcm_lib_malloc_pages(substream, params_buffer_bytes(hw_params))) < 0) return err; return 0; }

Contributors

PersonTokensPropCommitsCommitProp
jaroslav kyselajaroslav kysela12095.24%150.00%
takashi iwaitakashi iwai64.76%150.00%
Total126100.00%2100.00%


static int snd_es18xx_capture_prepare(struct snd_pcm_substream *substream) { struct snd_es18xx *chip = snd_pcm_substream_chip(substream); struct snd_pcm_runtime *runtime = substream->runtime; unsigned int size = snd_pcm_lib_buffer_bytes(substream); unsigned int count = snd_pcm_lib_period_bytes(substream); snd_es18xx_reset_fifo(chip); /* Set stereo/mono */ snd_es18xx_bits(chip, 0xA8, 0x03, runtime->channels == 1 ? 0x02 : 0x01); snd_es18xx_rate_set(chip, substream, ADC1); /* Transfer Count Reload */ count = 0x10000 - count; snd_es18xx_write(chip, 0xA4, count & 0xff); snd_es18xx_write(chip, 0xA5, count >> 8); #ifdef AVOID_POPS mdelay(100); #endif /* Set format */ snd_es18xx_write(chip, 0xB7, snd_pcm_format_unsigned(runtime->format) ? 0x51 : 0x71); snd_es18xx_write(chip, 0xB7, 0x90 | ((runtime->channels == 1) ? 0x40 : 0x08) | (snd_pcm_format_width(runtime->format) == 16 ? 0x04 : 0x00) | (snd_pcm_format_unsigned(runtime->format) ? 0x00 : 0x20)); /* Set DMA controller */ snd_dma_program(chip->dma1, runtime->dma_addr, size, DMA_MODE_READ | DMA_AUTOINIT); return 0; }

Contributors

PersonTokensPropCommitsCommitProp
jaroslav kyselajaroslav kysela20395.75%240.00%
takashi iwaitakashi iwai62.83%120.00%
zhen-hua lizhen-hua li20.94%120.00%
robert p. j. dayrobert p. j. day10.47%120.00%
Total212100.00%5100.00%


static int snd_es18xx_capture_trigger(struct snd_pcm_substream *substream, int cmd) { struct snd_es18xx *chip = snd_pcm_substream_chip(substream); switch (cmd) { case SNDRV_PCM_TRIGGER_START: case SNDRV_PCM_TRIGGER_RESUME: if (chip->active & ADC1) return 0; chip->active |= ADC1; /* Start DMA */ snd_es18xx_write(chip, 0xB8, 0x0f); break; case SNDRV_PCM_TRIGGER_STOP: case SNDRV_PCM_TRIGGER_SUSPEND: if (!(chip->active & ADC1)) return 0; chip->active &= ~ADC1; /* Stop DMA */ snd_es18xx_write(chip, 0xB8, 0x00); break; default: return -EINVAL; } return 0; }

Contributors

PersonTokensPropCommitsCommitProp
jaroslav kyselajaroslav kysela10696.36%266.67%
takashi iwaitakashi iwai43.64%133.33%
Total110100.00%3100.00%


static int snd_es18xx_playback2_prepare(struct snd_es18xx *chip, struct snd_pcm_substream *substream) { struct snd_pcm_runtime *runtime = substream->runtime; unsigned int size = snd_pcm_lib_buffer_bytes(substream); unsigned int count = snd_pcm_lib_period_bytes(substream); snd_es18xx_reset_fifo(chip); /* Set stereo/mono */ snd_es18xx_bits(chip, 0xA8, 0x03, runtime->channels == 1 ? 0x02 : 0x01); snd_es18xx_rate_set(chip, substream, DAC1); /* Transfer Count Reload */ count = 0x10000 - count; snd_es18xx_write(chip, 0xA4, count & 0xff); snd_es18xx_write(chip, 0xA5, count >> 8); /* Set format */ snd_es18xx_write(chip, 0xB6, snd_pcm_format_unsigned(runtime->format) ? 0x80 : 0x00); snd_es18xx_write(chip, 0xB7, snd_pcm_format_unsigned(runtime->format) ? 0x51 : 0x71); snd_es18xx_write(chip, 0xB7, 0x90 | (runtime->channels == 1 ? 0x40 : 0x08) | (snd_pcm_format_width(runtime->format) == 16 ? 0x04 : 0x00) | (snd_pcm_format_unsigned(runtime->format) ? 0x00 : 0x20)); /* Set DMA controller */ snd_dma_program(chip->dma1, runtime->dma_addr,