u_char	ess_dsp_write_ready __P((struct ess_softc *sc));
u_char	ess_dsp_write_ready __P((struct ess_softc *));
int	ess_audio1_trigger_output __P((void *, void *, void *, int,	    void (*)(void *), void *, struct audio_params *));int	ess_audio2_trigger_output __P((void *, void *, void *, int,	    void (*)(void *), void *, struct audio_params *));int	ess_audio1_trigger_input __P((void *, void *, void *, int,	    void (*)(void *), void *, struct audio_params *));int	ess_audio1_halt __P((void *));int	ess_audio2_halt __P((void *));int	ess_audio1_intr __P((void *));int	ess_audio2_intr __P((void *));void	ess_audio1_poll __P((void *));void	ess_audio2_poll __P((void *));int	ess_speaker_ctl __P((void *, int));int	ess_getdev __P((void *, struct audio_device *));	int	ess_set_port __P((void *, mixer_ctrl_t *));int	ess_get_port __P((void *, mixer_ctrl_t *));void   *ess_malloc __P((void *, unsigned long, int, int));void	ess_free __P((void *, void *, int));unsigned long ess_round_buffersize __P((void *, unsigned long));int	ess_mappage __P((void *, void *, int, int));int	ess_query_devinfo __P((void *, mixer_devinfo_t *));int	ess_1788_get_props __P((void *));int	ess_1888_get_props __P((void *));void	ess_speaker_on __P((struct ess_softc *));void	ess_speaker_off __P((struct ess_softc *));int	ess_config_addr __P((struct ess_softc *));void	ess_config_irq __P((struct ess_softc *));void	ess_config_drq __P((struct ess_softc *));void	ess_setup __P((struct ess_softc *));int	ess_identify __P((struct ess_softc *));int	ess_reset __P((struct ess_softc *));void	ess_set_gain __P((struct ess_softc *, int, int));int	ess_set_in_port __P((struct ess_softc *, int));int	ess_set_in_ports __P((struct ess_softc *, int));u_int	ess_srtotc __P((u_int));u_int	ess_srtofc __P((u_int));u_char	ess_get_dsp_status __P((struct ess_softc *));u_char	ess_dsp_read_ready __P((struct ess_softc *));u_char	ess_dsp_write_ready __P((struct ess_softc *sc));int	ess_rdsp __P((struct ess_softc *));int	ess_wdsp __P((struct ess_softc *, u_char));u_char	ess_read_x_reg __P((struct ess_softc *, u_char));int	ess_write_x_reg __P((struct ess_softc *, u_char, u_char));void	ess_clear_xreg_bits __P((struct ess_softc *, u_char, u_char));void	ess_set_xreg_bits __P((struct ess_softc *, u_char, u_char));u_char	ess_read_mix_reg __P((struct ess_softc *, u_char));void	ess_write_mix_reg __P((struct ess_softc *, u_char, u_char));void	ess_clear_mreg_bits __P((struct ess_softc *, u_char, u_char));void	ess_set_mreg_bits __P((struct ess_softc *, u_char, u_char));static char *essmodel[] = {	"unsupported",	"1888",	"1887",	"888",	"1788"};struct audio_device ess_device = {	"ESS Technology",	"x",	"ess"};/* * Define our interface to the higher level audio driver. */struct audio_hw_if ess_1788_hw_if = {	ess_open,	ess_1788_close,	ess_drain,	ess_query_encoding,	ess_set_params,	ess_round_blocksize,	NULL,	NULL,	NULL,	NULL,	NULL,	ess_audio1_halt,	ess_audio1_halt,	ess_speaker_ctl,	ess_getdev,	NULL,	ess_set_port,	ess_get_port,	ess_query_devinfo,	ess_malloc,	ess_free,	ess_round_buffersize,	ess_mappage,	ess_1788_get_props,	ess_audio1_trigger_output,	ess_audio1_trigger_input,};struct audio_hw_if ess_1888_hw_if = {	ess_open,	ess_1888_close,	ess_drain,	ess_query_encoding,	ess_set_params,	ess_round_blocksize,	NULL,	NULL,	NULL,	NULL,	NULL,	ess_audio2_halt,	ess_audio1_halt,	ess_speaker_ctl,	ess_getdev,	NULL,	ess_set_port,	ess_get_port,	ess_query_devinfo,	ess_malloc,	ess_free,	ess_round_buffersize,	ess_mappage,	ess_1888_get_props,	ess_audio2_trigger_output,	ess_audio1_trigger_input,};#ifdef AUDIO_DEBUGvoid ess_printsc __P((struct ess_softc *));void ess_dump_mixer __P((struct ess_softc *));voidess_printsc(sc)	struct ess_softc *sc;{	int i;    	printf("open %d iobase 0x%x outport %u inport %u speaker %s\n",	       (int)sc->sc_open, sc->sc_iobase, sc->out_port,	       sc->in_port, sc->spkr_state ? "on" : "off");	printf("audio1: dmachan %d irq %d nintr %lu intr %p arg %p\n",	       sc->sc_audio1.drq, sc->sc_audio1.irq, sc->sc_audio1.nintr,	       sc->sc_audio1.intr, sc->sc_audio1.arg);	if (sc->sc_model != ESS_1788) {		printf("audio2: dmachan %d irq %d nintr %lu intr %p arg %p\n",		       sc->sc_audio2.drq, sc->sc_audio2.irq, sc->sc_audio2.nintr,		       sc->sc_audio2.intr, sc->sc_audio2.arg);	}	printf("gain:");	for (i = 0; i < sc->ndevs; i++)		printf(" %u,%u", sc->gain[i][ESS_LEFT], sc->gain[i][ESS_RIGHT]);	printf("\n");}voidess_dump_mixer(sc)	struct ess_softc *sc;{	printf("ESS_DAC_PLAY_VOL: mix reg 0x%02x=0x%02x\n",	       0x7C, ess_read_mix_reg(sc, 0x7C));	printf("ESS_MIC_PLAY_VOL: mix reg 0x%02x=0x%02x\n",	       0x1A, ess_read_mix_reg(sc, 0x1A));	printf("ESS_LINE_PLAY_VOL: mix reg 0x%02x=0x%02x\n",	       0x3E, ess_read_mix_reg(sc, 0x3E));	printf("ESS_SYNTH_PLAY_VOL: mix reg 0x%02x=0x%02x\n",	       0x36, ess_read_mix_reg(sc, 0x36));	printf("ESS_CD_PLAY_VOL: mix reg 0x%02x=0x%02x\n",	       0x38, ess_read_mix_reg(sc, 0x38));	printf("ESS_AUXB_PLAY_VOL: mix reg 0x%02x=0x%02x\n",	       0x3A, ess_read_mix_reg(sc, 0x3A));	printf("ESS_MASTER_VOL: mix reg 0x%02x=0x%02x\n",	       0x32, ess_read_mix_reg(sc, 0x32));	printf("ESS_PCSPEAKER_VOL: mix reg 0x%02x=0x%02x\n",	       0x3C, ess_read_mix_reg(sc, 0x3C));	printf("ESS_DAC_REC_VOL: mix reg 0x%02x=0x%02x\n",	       0x69, ess_read_mix_reg(sc, 0x69));	printf("ESS_MIC_REC_VOL: mix reg 0x%02x=0x%02x\n",	       0x68, ess_read_mix_reg(sc, 0x68));	printf("ESS_LINE_REC_VOL: mix reg 0x%02x=0x%02x\n",	       0x6E, ess_read_mix_reg(sc, 0x6E));	printf("ESS_SYNTH_REC_VOL: mix reg 0x%02x=0x%02x\n",	       0x6B, ess_read_mix_reg(sc, 0x6B));	printf("ESS_CD_REC_VOL: mix reg 0x%02x=0x%02x\n",	       0x6A, ess_read_mix_reg(sc, 0x6A));	printf("ESS_AUXB_REC_VOL: mix reg 0x%02x=0x%02x\n",	       0x6C, ess_read_mix_reg(sc, 0x6C));	printf("ESS_RECORD_VOL: x reg 0x%02x=0x%02x\n",	       0xB4, ess_read_x_reg(sc, 0xB4));	printf("Audio 1 play vol (unused): mix reg 0x%02x=0x%02x\n",	       0x14, ess_read_mix_reg(sc, 0x14));	printf("ESS_MIC_PREAMP: x reg 0x%02x=0x%02x\n",	       ESS_XCMD_PREAMP_CTRL, ess_read_x_reg(sc, ESS_XCMD_PREAMP_CTRL));	printf("ESS_RECORD_MONITOR: x reg 0x%02x=0x%02x\n",	       ESS_XCMD_AUDIO_CTRL, ess_read_x_reg(sc, ESS_XCMD_AUDIO_CTRL));	printf("Record source: mix reg 0x%02x=0x%02x, 0x%02x=0x%02x\n",	       ESS_MREG_ADC_SOURCE, ess_read_mix_reg(sc, ESS_MREG_ADC_SOURCE),	       ESS_MREG_AUDIO2_CTRL2, ess_read_mix_reg(sc, ESS_MREG_AUDIO2_CTRL2));}#endif/* * Configure the ESS chip for the desired audio base address. */intess_config_addr(sc)	struct ess_softc *sc;{	int iobase = sc->sc_iobase;	bus_space_tag_t iot = sc->sc_iot;	/*	 * Configure using the System Control Register method.  This	 * method is used when the AMODE line is tied high, which is	 * the case for the Shark, but not for the evaluation board.	 */	bus_space_handle_t scr_access_ioh;	bus_space_handle_t scr_ioh;	u_short scr_value;	/*	 * Set the SCR bit to enable audio.	 */	scr_value = ESS_SCR_AUDIO_ENABLE;	/*	 * Set the SCR bits necessary to select the specified audio	 * base address.	 */	switch(iobase) {	case 0x220:		scr_value |= ESS_SCR_AUDIO_220;		break;	case 0x230:		scr_value |= ESS_SCR_AUDIO_230;		break;	case 0x240:		scr_value |= ESS_SCR_AUDIO_240;		break;	case 0x250:		scr_value |= ESS_SCR_AUDIO_250;		break;	default:		printf("ess: configured iobase 0x%x invalid\n", iobase);		return (1);		break;	}	/*	 * Get a mapping for the System Control Register (SCR) access	 * registers and the SCR data registers.	 */	if (bus_space_map(iot, ESS_SCR_ACCESS_BASE, ESS_SCR_ACCESS_PORTS,			  0, &scr_access_ioh)) {		printf("ess: can't map SCR access registers\n");		return (1);	}	if (bus_space_map(iot, ESS_SCR_BASE, ESS_SCR_PORTS,			  0, &scr_ioh)) {		printf("ess: can't map SCR registers\n");		bus_space_unmap(iot, scr_access_ioh, ESS_SCR_ACCESS_PORTS);		return (1);	}	/* Unlock the SCR. */	EWRITE1(iot, scr_access_ioh, ESS_SCR_UNLOCK, 0);	/* Write the base address information into SCR[0]. */	EWRITE1(iot, scr_ioh, ESS_SCR_INDEX, 0);	EWRITE1(iot, scr_ioh, ESS_SCR_DATA, scr_value);		/* Lock the SCR. */	EWRITE1(iot, scr_access_ioh, ESS_SCR_LOCK, 0);	/* Unmap the SCR access ports and the SCR data ports. */	bus_space_unmap(iot, scr_access_ioh, ESS_SCR_ACCESS_PORTS);	bus_space_unmap(iot, scr_ioh, ESS_SCR_PORTS);	return 0;}