audiocmi.c revision af145792def4317aeeb9d20f7772b32a35a0161f
5205N/A * The contents of this file are subject to the terms of the 5205N/A * Common Development and Distribution License (the "License"). 5205N/A * You may not use this file except in compliance with the License. 5205N/A * See the License for the specific language governing permissions 5205N/A * and limitations under the License. 5205N/A * When distributing Covered Code, include this CDDL HEADER in each 5205N/A * If applicable, add the following below this CDDL HEADER, with the 5205N/A * fields enclosed by brackets "[]" replaced with your own identifying 5205N/A * information: Portions Copyright [yyyy] [name of copyright owner] 5205N/A * Copyright 2009 Sun Microsystems, Inc. All rights reserved. 5205N/A * Use is subject to license terms. 6226N/A * Purpose: Driver for CMEDIA CM8738 PCI audio controller. 5205N/A * This file is part of Open Sound System 5205N/A * Copyright (C) 4Front Technologies 1996-2008. 5221N/A * Note: The original 4Front driver had support SPDIF and dual dac 5205N/A * options. Dual dac support is probably not terribly useful. SPDIF 6678N/A * on the other hand might be quite useful, we just don't have a card 6678N/A * that supports it at present. Some variants of the chip are also 6678N/A * capable of jack retasking, but we're electing to punt on supporting 6678N/A * that as well, for now (we don't have any cards that would benefit 5205N/A * Note that surround support requires the use of the second DMA 5205N/A * engine, and that the same second DMA engine is the only way one can 5205N/A * capture from SPDIF. Rather than support a lot more complexity in 5205N/A * the driver, we we will probably just punt on ever supporting 5205N/A * capture of SPDIF. (SPDIF playback should be doable, however.) 5205N/A * Adding back support for the advanced features would be an 5205N/A * interesting project for someone with access to suitable hardware. 5205N/A * Note that each variant (CMI 8338, 8738-033, -037, -055, and 8768) 5205N/A * seems to have significant differences in some of the registers. 5205N/A * While programming these parts for basic stereo is pretty much the 5205N/A * same on all parts, doing anything more than that can be 5205N/A * sigificantly different for each part. 5205N/A 0x0,
/* dma_attr_addr_lo */ 5205N/A 0xffffffffU,
/* dma_attr_addr_hi */ 5753N/A 0x3ffff,
/* dma_attr_count_max */ 5754N/A 0x7f,
/* dma_attr_burstsizes */ 5754N/A 0x1,
/* dma_attr_minxfer */ 5754N/A 0x3ffff,
/* dma_attr_maxxfer */ 5754N/A 0x3ffff,
/* dma_attr_seg */ 6415N/A 0x1,
/* dma_attr_granular */ 5205N/A /* toggle the bits that we are going to handle */ 6415N/A /* Set 48k 16-bit stereo -- these are just with all bits set. */ 5205N/A /* this gives us the offset in dwords */ 5205N/A /* check for wrap - note that the count is given in dwords */ 6678N/A /* the count is in dwords */ 5205N/A * convert dwords to frames - unfortunately this requires a 6415N/A /* left and right are the same */ 5205N/A /* speaker volume - mute in extension register, but we don't use */ 6418N/A /* aux - trickier because it doesn't use regular sbpro mixer */ 5205N/A /* maybe enable recording */ 5205N/A /* maybe enable monitoring */ 6678N/A * We don't bother to check for valid values - a bogus value 6418N/A * will give incorrect volumes, but is otherwise harmless. 5205N/A /* disable interrupts and such */ 5205N/A /* disable uart, joystick in Function Control Reg1 */ 5205N/A * Set DAC and ADC rates to 48 kHz - note that both rates have 5205N/A * all bits set in them, so we can do this with a simple "set". 6678N/A /* Set 16-bit stereo -- also these are just with all bits set. */ 5205N/A "Invalid channels property (%d), resetting to %d",
5205N/A * Channel 0 is recording channel, unless we are in 5205N/A * dual DAC mode. The reason for this is simple -- 5205N/A * only channel "B" (which I presume to mean channel 5205N/A * 1) supports multichannel configuration. 5205N/A * However, if we're going to use SPDIF recording, 5205N/A * then recording *must* occur on channel 1. Yes, the 5754N/A * Calculate fragfr, nfrags, buf. 5754N/A * 48 as minimum is chosen to ensure that we will have 5754N/A * at least 4 fragments. 512 is just an arbitrary 5754N/A * limit, and at the smallest frame size will result 5754N/A * in no more than 176 fragments. 5754N/A * Two fragments are enough to get ping-pong buffers. 5754N/A * The hardware could support considerably more than 5754N/A * this, but it just wastes memory. 5754N/A * For efficiency, we'd like to have the fragments 5754N/A * evenly divisble by 64 bytes. Since frames are 5205N/A * already evenly divisble by 4 (16-bit stereo), this 5205N/A * is adequate. For a typical configuration (175 Hz * requested) this will translate to 166 Hz. /* free up ports, including DMA resources for ports */ /* enable IO and Master accesses */ /* setup some initial values */ * Crazy 8738 detection scheme. Reviewing multiple * different open sources gives multiple different * answers here. Its unclear how accurate this is. * The approach taken here is a bit conservative in * assigning multiple channel support, but for users * with newer 8768 cards should offer the best /* wait one millisecond, to give reset a chance to get up */ "C-Media PCI Audio",
/* linkinfo */