110433SGarrett.Damore@Sun.COM /* 210433SGarrett.Damore@Sun.COM * CDDL HEADER START 310433SGarrett.Damore@Sun.COM * 410433SGarrett.Damore@Sun.COM * The contents of this file are subject to the terms of the 510433SGarrett.Damore@Sun.COM * Common Development and Distribution License (the "License"). 610433SGarrett.Damore@Sun.COM * You may not use this file except in compliance with the License. 710433SGarrett.Damore@Sun.COM * 810433SGarrett.Damore@Sun.COM * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 910433SGarrett.Damore@Sun.COM * or http://www.opensolaris.org/os/licensing. 1010433SGarrett.Damore@Sun.COM * See the License for the specific language governing permissions 1110433SGarrett.Damore@Sun.COM * and limitations under the License. 1210433SGarrett.Damore@Sun.COM * 1310433SGarrett.Damore@Sun.COM * When distributing Covered Code, include this CDDL HEADER in each 1410433SGarrett.Damore@Sun.COM * file and include the License file at usr/src/OPENSOLARIS.LICENSE. 1510433SGarrett.Damore@Sun.COM * If applicable, add the following below this CDDL HEADER, with the 1610433SGarrett.Damore@Sun.COM * fields enclosed by brackets "[]" replaced with your own identifying 1710433SGarrett.Damore@Sun.COM * information: Portions Copyright [yyyy] [name of copyright owner] 1810433SGarrett.Damore@Sun.COM * 1910433SGarrett.Damore@Sun.COM * CDDL HEADER END 2010433SGarrett.Damore@Sun.COM */ 2110433SGarrett.Damore@Sun.COM 2210433SGarrett.Damore@Sun.COM /* 23*11936Sgdamore@opensolaris.org * Copyright 2010 Sun Microsystems, Inc. All rights reserved. 2410433SGarrett.Damore@Sun.COM * Use is subject to license terms. 2510433SGarrett.Damore@Sun.COM */ 2610433SGarrett.Damore@Sun.COM 2710433SGarrett.Damore@Sun.COM /* 2810433SGarrett.Damore@Sun.COM * Purpose: Definitions for the Creative Audigy LS driver 2910433SGarrett.Damore@Sun.COM */ 3010433SGarrett.Damore@Sun.COM /* 3110433SGarrett.Damore@Sun.COM * This file is part of Open Sound System 3210433SGarrett.Damore@Sun.COM * 3310433SGarrett.Damore@Sun.COM * Copyright (C) 4Front Technologies 1996-2009. 3410433SGarrett.Damore@Sun.COM * 3510433SGarrett.Damore@Sun.COM * This software is released under CDDL 1.0 source license. 3610433SGarrett.Damore@Sun.COM * See the COPYING file included in the main directory of this source 3710433SGarrett.Damore@Sun.COM * distribution for the license terms and conditions. 3810433SGarrett.Damore@Sun.COM */ 3910433SGarrett.Damore@Sun.COM #ifndef AUDIGYLS_H 4010433SGarrett.Damore@Sun.COM #define AUDIGYLS_H 4110433SGarrett.Damore@Sun.COM 4210433SGarrett.Damore@Sun.COM #define AUDIGYLS_NAME "audiols" 4310433SGarrett.Damore@Sun.COM 4410433SGarrett.Damore@Sun.COM #define AUDIGYLS_NUM_PORT 2 4510433SGarrett.Damore@Sun.COM #define AUDIGYLS_PLAY_PORT 0 4610433SGarrett.Damore@Sun.COM #define AUDIGYLS_REC_PORT 1 4710433SGarrett.Damore@Sun.COM 4810433SGarrett.Damore@Sun.COM #define PCI_VENDOR_ID_CREATIVE 0x1102 4910433SGarrett.Damore@Sun.COM #define PCI_DEVICE_ID_CREATIVE_AUDIGYLS 0x0007 5010433SGarrett.Damore@Sun.COM 5110433SGarrett.Damore@Sun.COM /* 5210433SGarrett.Damore@Sun.COM * PCI registers 5310433SGarrett.Damore@Sun.COM */ 5410433SGarrett.Damore@Sun.COM 5510433SGarrett.Damore@Sun.COM #define PR 0x00 5610433SGarrett.Damore@Sun.COM #define DR 0x04 5710433SGarrett.Damore@Sun.COM #define IPR 0x08 5810433SGarrett.Damore@Sun.COM #define IER 0x0C 5910433SGarrett.Damore@Sun.COM #define INTR_PCI (1 << 0) 6010433SGarrett.Damore@Sun.COM #define INTR_TXA (1 << 1) /* midi-a tx */ 6110433SGarrett.Damore@Sun.COM #define INTR_RXA (1 << 2) /* midi-a rx */ 6210433SGarrett.Damore@Sun.COM #define INTR_IT2 (1 << 3) /* timer 2, 44.1 kHz */ 6310433SGarrett.Damore@Sun.COM #define INTR_IT1 (1 << 4) /* timer 1, 192 kHz */ 6410433SGarrett.Damore@Sun.COM #define INTR_SS_ (1 << 5) /* spdif status */ 6510433SGarrett.Damore@Sun.COM #define INTR_SRT (1 << 6) /* sample rate status */ 6610433SGarrett.Damore@Sun.COM #define INTR_GP (1 << 7) 6710433SGarrett.Damore@Sun.COM #define INTR_AI (1 << 8) /* audio pending interrupt */ 6810433SGarrett.Damore@Sun.COM #define INTR_I2CDAC (1 << 9) 6910433SGarrett.Damore@Sun.COM #define INTR_I2CEE (1 << 10) 7010433SGarrett.Damore@Sun.COM #define INTR_SPI (1 << 11) 7110433SGarrett.Damore@Sun.COM #define INTR_SPF (1 << 12) 7210433SGarrett.Damore@Sun.COM #define INTR_SUO (1 << 13) 7310433SGarrett.Damore@Sun.COM #define INTR_SUI (1 << 14) 7410433SGarrett.Damore@Sun.COM #define INTR_TXB (1 << 16) /* midi-b tx */ 7510433SGarrett.Damore@Sun.COM #define INTR_RXB (1 << 17) /* midi-b rx */ 7610433SGarrett.Damore@Sun.COM 7710433SGarrett.Damore@Sun.COM #define HC 0x14 7810433SGarrett.Damore@Sun.COM #define HC_PF (1 << 11) /* play fmt 1 = 32b, 0 = 16b */ 7910433SGarrett.Damore@Sun.COM #define HC_RF (1 << 10) /* rec fmt 1 = 32b, 0 = 16b */ 8010433SGarrett.Damore@Sun.COM #define HC_AC97 (1 << 3) 8110433SGarrett.Damore@Sun.COM #define HC_AEN (1 << 0) /* audio enable */ 8210433SGarrett.Damore@Sun.COM 8310433SGarrett.Damore@Sun.COM #define GPIO 0x18 8410433SGarrett.Damore@Sun.COM #define AC97D 0x1C 8510433SGarrett.Damore@Sun.COM #define AC97A 0x1E 8610433SGarrett.Damore@Sun.COM /* 8710433SGarrett.Damore@Sun.COM * Indirect registers 8810433SGarrett.Damore@Sun.COM */ 8910433SGarrett.Damore@Sun.COM 9010433SGarrett.Damore@Sun.COM #define PTBA 0x000 /* gather play table base address */ 9110433SGarrett.Damore@Sun.COM #define PTBS 0x001 /* gather play table buffer size */ 9210433SGarrett.Damore@Sun.COM #define PTCA 0x002 /* gather play table current addr ptr */ 9310433SGarrett.Damore@Sun.COM #define PFBA 0x004 /* play fifo base address */ 9410433SGarrett.Damore@Sun.COM #define PFBS 0x005 /* play fifo buffer size */ 9510433SGarrett.Damore@Sun.COM #define CPFA 0x006 /* current play fifo address */ 9610433SGarrett.Damore@Sun.COM #define PFEA 0x007 /* play fifo end address */ 9710433SGarrett.Damore@Sun.COM #define CPCAV 0x008 /* current play fifo offset/cache sz valid */ 9810433SGarrett.Damore@Sun.COM #define RFBA 0x010 /* record fifo base address */ 9910433SGarrett.Damore@Sun.COM #define RFBS 0x011 /* record fifo buffer size */ 10010433SGarrett.Damore@Sun.COM #define CRFA 0x012 /* current record fifo address */ 10110433SGarrett.Damore@Sun.COM #define CRCAV 0x013 /* current record fifo offset/cache sz valid */ 10210433SGarrett.Damore@Sun.COM #define CDL 0x020 /* play fifo cache data, 0x20-0x2f */ 10310433SGarrett.Damore@Sun.COM #define SA 0x040 /* start audio */ 10410433SGarrett.Damore@Sun.COM #define SCS3 0x041 10510433SGarrett.Damore@Sun.COM #define SCS0 0x042 10610433SGarrett.Damore@Sun.COM #define SCS1 0x043 10710433SGarrett.Damore@Sun.COM #define SCS2 0x044 10810433SGarrett.Damore@Sun.COM #define SPC 0x045 /* spdif output control */ 10910433SGarrett.Damore@Sun.COM #define WMARK 0x046 /* test purposes only */ 11010433SGarrett.Damore@Sun.COM #define SPSC 0x049 /* spdif input control */ 11110433SGarrett.Damore@Sun.COM #define RCD 0x050 /* record cache data, 0x50-0x5f */ 11210433SGarrett.Damore@Sun.COM #define P17RECSEL 0x060 /* record fifo map address */ 11310433SGarrett.Damore@Sun.COM #define P17RECVOLL 0x061 /* record fifo volume control (lo) */ 11410433SGarrett.Damore@Sun.COM #define P17RECVOLH 0x062 /* record fifo volume control (hi) */ 11510433SGarrett.Damore@Sun.COM 11610433SGarrett.Damore@Sun.COM #define HMIXMAP_SPDIF 0x063 /* spdif router map address */ 11710433SGarrett.Damore@Sun.COM #define SMIXMAP_SPDIF 0x064 /* spdif router map address */ 11810433SGarrett.Damore@Sun.COM #define MIXCTL_SPDIF 0x065 /* spdif mixer control */ 11910433SGarrett.Damore@Sun.COM #define MIXVOL_SPDIF 0x066 /* spdif mixer input volume control */ 12010433SGarrett.Damore@Sun.COM #define HMIXMAP_I2S 0x067 /* i2s router map address */ 12110433SGarrett.Damore@Sun.COM #define SMIXMAP_I2S 0x068 /* i2s router map address */ 12210433SGarrett.Damore@Sun.COM #define MIXCTL_I2S 0x069 /* i2s mixer control */ 12310433SGarrett.Damore@Sun.COM #define MIXVOL_I2S 0x06a /* i2s mixer input volume control */ 12410433SGarrett.Damore@Sun.COM 12510433SGarrett.Damore@Sun.COM /* MIDI UART */ 12610433SGarrett.Damore@Sun.COM #define MUDATA 0x06c /* midi uart a data */ 12710433SGarrett.Damore@Sun.COM #define MUCMDA 0x06d /* midi uart a command/status */ 12810433SGarrett.Damore@Sun.COM #define MUDATB 0x06e /* midi uart b data */ 12910433SGarrett.Damore@Sun.COM #define MUCMDB 0x06f /* midi uart b command/status */ 13010433SGarrett.Damore@Sun.COM 13110433SGarrett.Damore@Sun.COM #define SRT 0x070 /* sample rate tracker status */ 13210433SGarrett.Damore@Sun.COM #define SRCTL 0x071 /* sample rate control */ 13310433SGarrett.Damore@Sun.COM #define AUDCTL 0x072 /* audio output control */ 13410433SGarrett.Damore@Sun.COM #define CHIP_ID 0x074 /* chip id */ 13510433SGarrett.Damore@Sun.COM #define AIE 0x075 /* audio interrupt enable */ 13610433SGarrett.Damore@Sun.COM #define AIP 0x076 /* audio interrupt */ 13710433SGarrett.Damore@Sun.COM #define WALL192 0x077 /* wall clock @ 192 kHz */ 13810433SGarrett.Damore@Sun.COM #define WALL441 0x078 /* wall clock @ 44.1 kHz */ 13910433SGarrett.Damore@Sun.COM #define IT 0x079 /* interval timer */ 14010433SGarrett.Damore@Sun.COM #define SPI 0x07a /* spi interface */ 14110433SGarrett.Damore@Sun.COM #define I2C_A 0x07b /* i2c address */ 14210433SGarrett.Damore@Sun.COM #define I2C_0 0x07c /* i2c data */ 14310433SGarrett.Damore@Sun.COM #define I2C_1 0x07d /* i2c data */ 14410433SGarrett.Damore@Sun.COM 14510433SGarrett.Damore@Sun.COM /* 14610433SGarrett.Damore@Sun.COM * Audio interrupt bits 14710433SGarrett.Damore@Sun.COM */ 14810433SGarrett.Damore@Sun.COM 14910433SGarrett.Damore@Sun.COM #define AI_PFH 0x00000001 /* playback fifo half loop */ 15010433SGarrett.Damore@Sun.COM #define AI_PFF 0x00000010 /* playback fifo loop */ 15110433SGarrett.Damore@Sun.COM #define AI_TFH 0x00000100 /* playback table half loop */ 15210433SGarrett.Damore@Sun.COM #define AI_TFF 0x00001000 /* playback table loop */ 15310433SGarrett.Damore@Sun.COM #define AI_RFH 0x00010000 /* capture table half loop */ 15410433SGarrett.Damore@Sun.COM #define AI_RFF 0x00100000 /* capture fifo loop */ 15510433SGarrett.Damore@Sun.COM #define AI_EAI 0x01000000 /* enables audio end interrupt */ 15610433SGarrett.Damore@Sun.COM 15710433SGarrett.Damore@Sun.COM #define SA_48K 0 15810433SGarrett.Damore@Sun.COM #define SA_44K 1 15910433SGarrett.Damore@Sun.COM #define SA_96K 2 16010433SGarrett.Damore@Sun.COM #define SA_192K 3 16110433SGarrett.Damore@Sun.COM 16210433SGarrett.Damore@Sun.COM #define SA_MIX_OUT_EN(ch) (1 << ((ch) + 28)) 16310433SGarrett.Damore@Sun.COM #define SA_MIX_IN_EN(ch) (1 << ((ch) + 24)) 16410433SGarrett.Damore@Sun.COM #define SA_PLAY_RATE(ch, rate) ((rate) << (((ch) * 2) + 16)) 16510433SGarrett.Damore@Sun.COM #define SA_PLAY_START(ch) (1 << (ch)) 16610433SGarrett.Damore@Sun.COM #define SA_RECORD_START(ch) (1 << ((ch) + 8)) 16710433SGarrett.Damore@Sun.COM 16810433SGarrett.Damore@Sun.COM #define SA_SPA(ch) (1U << (ch)) 16910433SGarrett.Damore@Sun.COM #define SA_SRA(ch) (1U << ((ch) + 8)) 17010433SGarrett.Damore@Sun.COM 17110433SGarrett.Damore@Sun.COM #define RECSEL_SPDIFOUT 0 17210433SGarrett.Damore@Sun.COM #define RECSEL_I2SOUT 1 17310433SGarrett.Damore@Sun.COM #define RECSEL_SPDIFIN 2 17410433SGarrett.Damore@Sun.COM #define RECSEL_I2SIN 3 17510433SGarrett.Damore@Sun.COM #define RECSEL_AC97 4 17610433SGarrett.Damore@Sun.COM #define RECSEL_SRC 5 17710433SGarrett.Damore@Sun.COM 17810433SGarrett.Damore@Sun.COM typedef struct _audigyls_dev_t audigyls_dev_t; 17910433SGarrett.Damore@Sun.COM typedef struct _audigyls_port_t audigyls_port_t; 18010433SGarrett.Damore@Sun.COM 18110433SGarrett.Damore@Sun.COM typedef enum { 18210433SGarrett.Damore@Sun.COM CTL_FRONT = 0, 18310433SGarrett.Damore@Sun.COM CTL_SURROUND, 18410433SGarrett.Damore@Sun.COM CTL_CENTER, 18510433SGarrett.Damore@Sun.COM CTL_LFE, 18610433SGarrett.Damore@Sun.COM CTL_RECORDVOL, 18710433SGarrett.Damore@Sun.COM CTL_MONGAIN, 18810433SGarrett.Damore@Sun.COM CTL_RECSRC, 18910433SGarrett.Damore@Sun.COM CTL_SPREAD, 19010433SGarrett.Damore@Sun.COM CTL_LOOP, 19110433SGarrett.Damore@Sun.COM CTL_NUM /* must be last */ 19210433SGarrett.Damore@Sun.COM } audigyls_ctrl_num_t; 19310433SGarrett.Damore@Sun.COM 19410433SGarrett.Damore@Sun.COM typedef struct audigyls_ctrl 19510433SGarrett.Damore@Sun.COM { 19610433SGarrett.Damore@Sun.COM audigyls_dev_t *dev; 19710433SGarrett.Damore@Sun.COM audio_ctrl_t *ctrl; 19810433SGarrett.Damore@Sun.COM audigyls_ctrl_num_t num; 19910433SGarrett.Damore@Sun.COM uint64_t val; 20010433SGarrett.Damore@Sun.COM } audigyls_ctrl_t; 20110433SGarrett.Damore@Sun.COM 20210433SGarrett.Damore@Sun.COM struct _audigyls_port_t 20310433SGarrett.Damore@Sun.COM { 20410433SGarrett.Damore@Sun.COM audigyls_dev_t *dev; 20510433SGarrett.Damore@Sun.COM audio_engine_t *engine; 20610433SGarrett.Damore@Sun.COM 20710433SGarrett.Damore@Sun.COM int direction; 20810433SGarrett.Damore@Sun.COM 20910433SGarrett.Damore@Sun.COM unsigned nchan; 21010433SGarrett.Damore@Sun.COM 21110433SGarrett.Damore@Sun.COM ddi_dma_handle_t buf_dmah; /* dma for buffers */ 21210433SGarrett.Damore@Sun.COM ddi_acc_handle_t buf_acch; 21310433SGarrett.Damore@Sun.COM uint32_t buf_paddr; 21410433SGarrett.Damore@Sun.COM caddr_t buf_kaddr; 21510433SGarrett.Damore@Sun.COM uint32_t buf_size; 21610433SGarrett.Damore@Sun.COM uint32_t buf_frames; /* Buffer size in frames */ 21710433SGarrett.Damore@Sun.COM uint32_t offset; 21810433SGarrett.Damore@Sun.COM int syncdir; 21910433SGarrett.Damore@Sun.COM uint64_t count; 22010433SGarrett.Damore@Sun.COM }; 22110433SGarrett.Damore@Sun.COM 22210433SGarrett.Damore@Sun.COM struct _audigyls_dev_t 22310433SGarrett.Damore@Sun.COM { 22410433SGarrett.Damore@Sun.COM dev_info_t *dip; 22510433SGarrett.Damore@Sun.COM audio_dev_t *adev; 22610433SGarrett.Damore@Sun.COM ac97_t *ac97; 22710433SGarrett.Damore@Sun.COM 22810433SGarrett.Damore@Sun.COM int nactive; /* Num active ports */ 22910433SGarrett.Damore@Sun.COM char digital_enable; /* Orange combo-jack mode */ 23010433SGarrett.Damore@Sun.COM 23110433SGarrett.Damore@Sun.COM ddi_acc_handle_t pcih; 23210433SGarrett.Damore@Sun.COM ddi_acc_handle_t regsh; 23310433SGarrett.Damore@Sun.COM caddr_t base; 23410433SGarrett.Damore@Sun.COM kmutex_t mutex; /* For normal locking */ 23510433SGarrett.Damore@Sun.COM kmutex_t low_mutex; /* For low level routines */ 23610433SGarrett.Damore@Sun.COM 23710433SGarrett.Damore@Sun.COM audigyls_port_t *port[AUDIGYLS_NUM_PORT]; 23810433SGarrett.Damore@Sun.COM audigyls_ctrl_t controls[CTL_NUM]; 23910433SGarrett.Damore@Sun.COM 24010433SGarrett.Damore@Sun.COM ac97_ctrl_t *ac97_recgain; 24110433SGarrett.Damore@Sun.COM ac97_ctrl_t *ac97_recsrc; 24210433SGarrett.Damore@Sun.COM uint64_t recmask; 24310433SGarrett.Damore@Sun.COM }; 24410433SGarrett.Damore@Sun.COM 24510433SGarrett.Damore@Sun.COM #define INB(dev, reg) \ 24610433SGarrett.Damore@Sun.COM ddi_get8(dev->regsh, (void *)(dev->base + reg)) 24710433SGarrett.Damore@Sun.COM #define OUTB(dev, reg, val) \ 24810433SGarrett.Damore@Sun.COM ddi_put8(dev->regsh, (void *)(dev->base + reg), (val)) 24910433SGarrett.Damore@Sun.COM 25010433SGarrett.Damore@Sun.COM #define INW(dev, reg) \ 25110433SGarrett.Damore@Sun.COM ddi_get16(dev->regsh, (void *)(dev->base + reg)) 25210433SGarrett.Damore@Sun.COM #define OUTW(dev, reg, val) \ 25310433SGarrett.Damore@Sun.COM ddi_put16(dev->regsh, (void *)(dev->base + reg), (val)) 25410433SGarrett.Damore@Sun.COM 25510433SGarrett.Damore@Sun.COM #define INL(dev, reg) \ 25610433SGarrett.Damore@Sun.COM ddi_get32(dev->regsh, (void *)(dev->base + reg)) 25710433SGarrett.Damore@Sun.COM #define OUTL(dev, reg, val) \ 25810433SGarrett.Damore@Sun.COM ddi_put32(dev->regsh, (void *)(dev->base + reg), (val)) 25910433SGarrett.Damore@Sun.COM 26010433SGarrett.Damore@Sun.COM #endif /* AUDIGYLS_H */ 261