Changeset 84 for GPL/trunk/alsa-kernel/pci/emu10k1/io.c
- Timestamp:
- Oct 23, 2006, 11:07:11 PM (19 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
GPL/trunk/alsa-kernel/pci/emu10k1/io.c
r34 r84 26 26 */ 27 27 28 #define __NO_VERSION__29 28 #include <sound/driver.h> 30 29 #include <linux/time.h> … … 62 61 } 63 62 } 63 64 EXPORT_SYMBOL(snd_emu10k1_ptr_read); 64 65 65 66 void snd_emu10k1_ptr_write(struct snd_emu10k1 *emu, unsigned int reg, unsigned int chn, unsigned int data) … … 93 94 } 94 95 96 EXPORT_SYMBOL(snd_emu10k1_ptr_write); 97 95 98 unsigned int snd_emu10k1_ptr20_read(struct snd_emu10k1 * emu, 96 99 unsigned int reg, … … 123 126 outl(data, emu->port + 0x20 + DATA); 124 127 spin_unlock_irqrestore(&emu->emu_lock, flags); 128 } 129 130 int snd_emu10k1_spi_write(struct snd_emu10k1 * emu, 131 unsigned int data) 132 { 133 unsigned int reset, set; 134 unsigned int reg, tmp; 135 int n, result; 136 if (emu->card_capabilities->ca0108_chip) 137 reg = 0x3c; /* PTR20, reg 0x3c */ 138 else { 139 /* For other chip types the SPI register 140 * is currently unknown. */ 141 return 1; 142 } 143 if (data > 0xffff) /* Only 16bit values allowed */ 144 return 1; 145 146 tmp = snd_emu10k1_ptr20_read(emu, reg, 0); 147 reset = (tmp & ~0x3ffff) | 0x20000; /* Set xxx20000 */ 148 set = reset | 0x10000; /* Set xxx1xxxx */ 149 snd_emu10k1_ptr20_write(emu, reg, 0, reset | data); 150 tmp = snd_emu10k1_ptr20_read(emu, reg, 0); /* write post */ 151 snd_emu10k1_ptr20_write(emu, reg, 0, set | data); 152 result = 1; 153 /* Wait for status bit to return to 0 */ 154 for (n = 0; n < 100; n++) { 155 udelay(10); 156 tmp = snd_emu10k1_ptr20_read(emu, reg, 0); 157 if (!(tmp & 0x10000)) { 158 result = 0; 159 break; 160 } 161 } 162 if (result) /* Timed out */ 163 return 1; 164 snd_emu10k1_ptr20_write(emu, reg, 0, reset | data); 165 tmp = snd_emu10k1_ptr20_read(emu, reg, 0); /* Write post */ 166 return 0; 167 } 168 169 int snd_emu1010_fpga_write(struct snd_emu10k1 * emu, int reg, int value) 170 { 171 if (reg < 0 || reg > 0x3f) 172 return 1; 173 reg += 0x40; /* 0x40 upwards are registers. */ 174 if (value < 0 || value > 0x3f) /* 0 to 0x3f are values */ 175 return 1; 176 outl(reg, emu->port + A_IOCFG); 177 udelay(10); 178 outl(reg | 0x80, emu->port + A_IOCFG); /* High bit clocks the value into the fpga. */ 179 udelay(10); 180 outl(value, emu->port + A_IOCFG); 181 udelay(10); 182 outl(value | 0x80 , emu->port + A_IOCFG); /* High bit clocks the value into the fpga. */ 183 184 return 0; 185 } 186 187 int snd_emu1010_fpga_read(struct snd_emu10k1 * emu, int reg, int *value) 188 { 189 if (reg < 0 || reg > 0x3f) 190 return 1; 191 reg += 0x40; /* 0x40 upwards are registers. */ 192 outl(reg, emu->port + A_IOCFG); 193 udelay(10); 194 outl(reg | 0x80, emu->port + A_IOCFG); /* High bit clocks the value into the fpga. */ 195 udelay(10); 196 *value = ((inl(emu->port + A_IOCFG) >> 8) & 0x7f); 197 198 return 0; 199 } 200 201 /* Each Destination has one and only one Source, 202 * but one Source can feed any number of Destinations simultaneously. 203 */ 204 int snd_emu1010_fpga_link_dst_src_write(struct snd_emu10k1 * emu, int dst, int src) 205 { 206 snd_emu1010_fpga_write(emu, 0x00, ((dst >> 8) & 0x3f) ); 207 snd_emu1010_fpga_write(emu, 0x01, (dst & 0x3f) ); 208 snd_emu1010_fpga_write(emu, 0x02, ((src >> 8) & 0x3f) ); 209 snd_emu1010_fpga_write(emu, 0x03, (src & 0x3f) ); 210 211 return 0; 125 212 } 126 213 … … 320 407 } 321 408 322 unsigned short snd_emu10k1_ac97_read( ac97_t*ac97, unsigned short reg)409 unsigned short snd_emu10k1_ac97_read(struct snd_ac97 *ac97, unsigned short reg) 323 410 { 324 411 struct snd_emu10k1 *emu = ac97->private_data; … … 333 420 } 334 421 335 void snd_emu10k1_ac97_write( ac97_t*ac97, unsigned short reg, unsigned short data)422 void snd_emu10k1_ac97_write(struct snd_ac97 *ac97, unsigned short reg, unsigned short data) 336 423 { 337 424 struct snd_emu10k1 *emu = ac97->private_data; … … 403 490 return 0; /* Should never reach this point */ 404 491 } 405 406 /*407 * Returns an attenuation based upon a cumulative volume value408 * Algorithm calculates 0x200 - 0x10 log2 (input)409 */410 411 unsigned char snd_emu10k1_sum_vol_attn(unsigned int value)412 {413 unsigned short count = 16, ans;414 415 if (value == 0)416 return 0xFF;417 418 /* Find first SET bit. This is the integer part of the value */419 while ((value & 0x10000) == 0) {420 value <<= 1;421 count--;422 }423 424 /* The REST of the data is the fractional part. */425 ans = (unsigned short) (0x110 - ((count << 4) + ((value & 0x0FFFFL) >> 12)));426 if (ans > 0xFF)427 ans = 0xFF;428 429 return (unsigned char) ans;430 }
Note:
See TracChangeset
for help on using the changeset viewer.