Blame view
sound/pci/via82xx.c
77.2 KB
1da177e4c Linux-2.6.12-rc2 |
1 2 3 4 5 |
/* * ALSA driver for VIA VT82xx (South Bridge) * * VT82C686A/B/C, VT8233A/C, VT8235 * |
c1017a4cd [ALSA] Changed Ja... |
6 |
* Copyright (c) 2000 Jaroslav Kysela <perex@perex.cz> |
1da177e4c Linux-2.6.12-rc2 |
7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 |
* Tjeerd.Mulder <Tjeerd.Mulder@fujitsu-siemens.com> * 2002 Takashi Iwai <tiwai@suse.de> * * 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 * */ /* * Changes: * * Dec. 19, 2002 Takashi Iwai <tiwai@suse.de> * - use the DSX channels for the first pcm playback. * (on VIA8233, 8233C and 8235 only) * this will allow you play simultaneously up to 4 streams. * multi-channel playback is assigned to the second device * on these chips. * - support the secondary capture (on VIA8233/C,8235) * - SPDIF support * the DSX3 channel can be used for SPDIF output. * on VIA8233A, this channel is assigned to the second pcm * playback. * the card config of alsa-lib will assign the correct * device for applications. * - clean up the code, separate low-level initialization * routines for each chipset. |
4f550df58 [ALSA] Reduce int... |
44 45 46 |
* * Sep. 26, 2005 Karsten Wiese <annabellesgarden@yahoo.de> * - Optimize position calculation for the 823x chips. |
1da177e4c Linux-2.6.12-rc2 |
47 |
*/ |
1da177e4c Linux-2.6.12-rc2 |
48 49 50 51 52 53 54 |
#include <asm/io.h> #include <linux/delay.h> #include <linux/interrupt.h> #include <linux/init.h> #include <linux/pci.h> #include <linux/slab.h> #include <linux/gameport.h> |
65a772172 sound: fix driver... |
55 |
#include <linux/module.h> |
1da177e4c Linux-2.6.12-rc2 |
56 57 58 59 |
#include <sound/core.h> #include <sound/pcm.h> #include <sound/pcm_params.h> #include <sound/info.h> |
7058c0420 [ALSA] Added TLV ... |
60 |
#include <sound/tlv.h> |
1da177e4c Linux-2.6.12-rc2 |
61 62 63 64 65 66 67 |
#include <sound/ac97_codec.h> #include <sound/mpu401.h> #include <sound/initval.h> #if 0 #define POINTER_DEBUG #endif |
c1017a4cd [ALSA] Changed Ja... |
68 |
MODULE_AUTHOR("Jaroslav Kysela <perex@perex.cz>"); |
1da177e4c Linux-2.6.12-rc2 |
69 70 71 72 73 74 75 |
MODULE_DESCRIPTION("VIA VT82xx audio"); MODULE_LICENSE("GPL"); MODULE_SUPPORTED_DEVICE("{{VIA,VT82C686A/B/C,pci},{VIA,VT8233A/C,8235}}"); #if defined(CONFIG_GAMEPORT) || (defined(MODULE) && defined(CONFIG_GAMEPORT_MODULE)) #define SUPPORT_JOYSTICK 1 #endif |
b7fe46220 [ALSA] highlander... |
76 77 78 |
static int index = SNDRV_DEFAULT_IDX1; /* Index 0-MAX */ static char *id = SNDRV_DEFAULT_STR1; /* ID for this card */ static long mpu_port; |
1da177e4c Linux-2.6.12-rc2 |
79 |
#ifdef SUPPORT_JOYSTICK |
a67ff6a54 ALSA: module_para... |
80 |
static bool joystick; |
1da177e4c Linux-2.6.12-rc2 |
81 |
#endif |
b7fe46220 [ALSA] highlander... |
82 83 84 |
static int ac97_clock = 48000; static char *ac97_quirk; static int dxs_support; |
395c61d19 ALSA: via82xx: al... |
85 |
static int dxs_init_volume = 31; |
115551d98 ALSA: via82xx: ad... |
86 |
static int nodelay; |
1da177e4c Linux-2.6.12-rc2 |
87 |
|
b7fe46220 [ALSA] highlander... |
88 |
module_param(index, int, 0444); |
1da177e4c Linux-2.6.12-rc2 |
89 |
MODULE_PARM_DESC(index, "Index value for VIA 82xx bridge."); |
b7fe46220 [ALSA] highlander... |
90 |
module_param(id, charp, 0444); |
1da177e4c Linux-2.6.12-rc2 |
91 |
MODULE_PARM_DESC(id, "ID string for VIA 82xx bridge."); |
b7fe46220 [ALSA] highlander... |
92 |
module_param(mpu_port, long, 0444); |
1da177e4c Linux-2.6.12-rc2 |
93 94 |
MODULE_PARM_DESC(mpu_port, "MPU-401 port. (VT82C686x only)"); #ifdef SUPPORT_JOYSTICK |
b7fe46220 [ALSA] highlander... |
95 |
module_param(joystick, bool, 0444); |
1da177e4c Linux-2.6.12-rc2 |
96 97 |
MODULE_PARM_DESC(joystick, "Enable joystick. (VT82C686x only)"); #endif |
b7fe46220 [ALSA] highlander... |
98 |
module_param(ac97_clock, int, 0444); |
1da177e4c Linux-2.6.12-rc2 |
99 |
MODULE_PARM_DESC(ac97_clock, "AC'97 codec clock (default 48000Hz)."); |
b7fe46220 [ALSA] highlander... |
100 |
module_param(ac97_quirk, charp, 0444); |
1da177e4c Linux-2.6.12-rc2 |
101 |
MODULE_PARM_DESC(ac97_quirk, "AC'97 workaround for strange hardware."); |
b7fe46220 [ALSA] highlander... |
102 |
module_param(dxs_support, int, 0444); |
2d7eb7cb2 [ALSA] Support al... |
103 |
MODULE_PARM_DESC(dxs_support, "Support for DXS channels (0 = auto, 1 = enable, 2 = disable, 3 = 48k only, 4 = no VRA, 5 = enable any sample rate)"); |
395c61d19 ALSA: via82xx: al... |
104 105 |
module_param(dxs_init_volume, int, 0644); MODULE_PARM_DESC(dxs_init_volume, "initial DXS volume (0-31)"); |
115551d98 ALSA: via82xx: ad... |
106 107 |
module_param(nodelay, int, 0444); MODULE_PARM_DESC(nodelay, "Disable 500ms init delay"); |
1da177e4c Linux-2.6.12-rc2 |
108 |
|
2b3e584b9 [ALSA] Add dummy ... |
109 |
/* just for backward compatibility */ |
a67ff6a54 ALSA: module_para... |
110 |
static bool enable; |
698444f31 [ALSA] Fix the ty... |
111 |
module_param(enable, bool, 0444); |
2b3e584b9 [ALSA] Add dummy ... |
112 |
|
1da177e4c Linux-2.6.12-rc2 |
113 |
|
1da177e4c Linux-2.6.12-rc2 |
114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 |
/* revision numbers for via686 */ #define VIA_REV_686_A 0x10 #define VIA_REV_686_B 0x11 #define VIA_REV_686_C 0x12 #define VIA_REV_686_D 0x13 #define VIA_REV_686_E 0x14 #define VIA_REV_686_H 0x20 /* revision numbers for via8233 */ #define VIA_REV_PRE_8233 0x10 /* not in market */ #define VIA_REV_8233C 0x20 /* 2 rec, 4 pb, 1 multi-pb */ #define VIA_REV_8233 0x30 /* 2 rec, 4 pb, 1 multi-pb, spdif */ #define VIA_REV_8233A 0x40 /* 1 rec, 1 multi-pb, spdf */ #define VIA_REV_8235 0x50 /* 2 rec, 4 pb, 1 multi-pb, spdif */ #define VIA_REV_8237 0x60 |
8263c65fb [ALSA] via82xx: a... |
129 |
#define VIA_REV_8251 0x70 |
1da177e4c Linux-2.6.12-rc2 |
130 131 132 133 134 135 136 137 138 139 140 |
/* * Direct registers */ #define VIAREG(via, x) ((via)->port + VIA_REG_##x) #define VIADEV_REG(viadev, x) ((viadev)->port + VIA_REG_##x) /* common offsets */ #define VIA_REG_OFFSET_STATUS 0x00 /* byte - channel status */ #define VIA_REG_STAT_ACTIVE 0x80 /* RO */ |
4f550df58 [ALSA] Reduce int... |
141 |
#define VIA8233_SHADOW_STAT_ACTIVE 0x08 /* RO */ |
1da177e4c Linux-2.6.12-rc2 |
142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 |
#define VIA_REG_STAT_PAUSED 0x40 /* RO */ #define VIA_REG_STAT_TRIGGER_QUEUED 0x08 /* RO */ #define VIA_REG_STAT_STOPPED 0x04 /* RWC */ #define VIA_REG_STAT_EOL 0x02 /* RWC */ #define VIA_REG_STAT_FLAG 0x01 /* RWC */ #define VIA_REG_OFFSET_CONTROL 0x01 /* byte - channel control */ #define VIA_REG_CTRL_START 0x80 /* WO */ #define VIA_REG_CTRL_TERMINATE 0x40 /* WO */ #define VIA_REG_CTRL_AUTOSTART 0x20 #define VIA_REG_CTRL_PAUSE 0x08 /* RW */ #define VIA_REG_CTRL_INT_STOP 0x04 #define VIA_REG_CTRL_INT_EOL 0x02 #define VIA_REG_CTRL_INT_FLAG 0x01 #define VIA_REG_CTRL_RESET 0x01 /* RW - probably reset? undocumented */ #define VIA_REG_CTRL_INT (VIA_REG_CTRL_INT_FLAG | VIA_REG_CTRL_INT_EOL | VIA_REG_CTRL_AUTOSTART) #define VIA_REG_OFFSET_TYPE 0x02 /* byte - channel type (686 only) */ #define VIA_REG_TYPE_AUTOSTART 0x80 /* RW - autostart at EOL */ #define VIA_REG_TYPE_16BIT 0x20 /* RW */ #define VIA_REG_TYPE_STEREO 0x10 /* RW */ #define VIA_REG_TYPE_INT_LLINE 0x00 #define VIA_REG_TYPE_INT_LSAMPLE 0x04 #define VIA_REG_TYPE_INT_LESSONE 0x08 #define VIA_REG_TYPE_INT_MASK 0x0c #define VIA_REG_TYPE_INT_EOL 0x02 #define VIA_REG_TYPE_INT_FLAG 0x01 #define VIA_REG_OFFSET_TABLE_PTR 0x04 /* dword - channel table pointer */ #define VIA_REG_OFFSET_CURR_PTR 0x04 /* dword - channel current pointer */ #define VIA_REG_OFFSET_STOP_IDX 0x08 /* dword - stop index, channel type, sample rate */ #define VIA8233_REG_TYPE_16BIT 0x00200000 /* RW */ #define VIA8233_REG_TYPE_STEREO 0x00100000 /* RW */ #define VIA_REG_OFFSET_CURR_COUNT 0x0c /* dword - channel current count (24 bit) */ #define VIA_REG_OFFSET_CURR_INDEX 0x0f /* byte - channel current index (for via8233 only) */ #define DEFINE_VIA_REGSET(name,val) \ enum {\ VIA_REG_##name##_STATUS = (val),\ VIA_REG_##name##_CONTROL = (val) + 0x01,\ VIA_REG_##name##_TYPE = (val) + 0x02,\ VIA_REG_##name##_TABLE_PTR = (val) + 0x04,\ VIA_REG_##name##_CURR_PTR = (val) + 0x04,\ VIA_REG_##name##_STOP_IDX = (val) + 0x08,\ VIA_REG_##name##_CURR_COUNT = (val) + 0x0c,\ } /* playback block */ DEFINE_VIA_REGSET(PLAYBACK, 0x00); DEFINE_VIA_REGSET(CAPTURE, 0x10); DEFINE_VIA_REGSET(FM, 0x20); /* AC'97 */ #define VIA_REG_AC97 0x80 /* dword */ #define VIA_REG_AC97_CODEC_ID_MASK (3<<30) #define VIA_REG_AC97_CODEC_ID_SHIFT 30 #define VIA_REG_AC97_CODEC_ID_PRIMARY 0x00 #define VIA_REG_AC97_CODEC_ID_SECONDARY 0x01 #define VIA_REG_AC97_SECONDARY_VALID (1<<27) #define VIA_REG_AC97_PRIMARY_VALID (1<<25) #define VIA_REG_AC97_BUSY (1<<24) #define VIA_REG_AC97_READ (1<<23) #define VIA_REG_AC97_CMD_SHIFT 16 #define VIA_REG_AC97_CMD_MASK 0x7e #define VIA_REG_AC97_DATA_SHIFT 0 #define VIA_REG_AC97_DATA_MASK 0xffff #define VIA_REG_SGD_SHADOW 0x84 /* dword */ /* via686 */ #define VIA_REG_SGD_STAT_PB_FLAG (1<<0) #define VIA_REG_SGD_STAT_CP_FLAG (1<<1) #define VIA_REG_SGD_STAT_FM_FLAG (1<<2) #define VIA_REG_SGD_STAT_PB_EOL (1<<4) #define VIA_REG_SGD_STAT_CP_EOL (1<<5) #define VIA_REG_SGD_STAT_FM_EOL (1<<6) #define VIA_REG_SGD_STAT_PB_STOP (1<<8) #define VIA_REG_SGD_STAT_CP_STOP (1<<9) #define VIA_REG_SGD_STAT_FM_STOP (1<<10) #define VIA_REG_SGD_STAT_PB_ACTIVE (1<<12) #define VIA_REG_SGD_STAT_CP_ACTIVE (1<<13) #define VIA_REG_SGD_STAT_FM_ACTIVE (1<<14) /* via8233 */ #define VIA8233_REG_SGD_STAT_FLAG (1<<0) #define VIA8233_REG_SGD_STAT_EOL (1<<1) #define VIA8233_REG_SGD_STAT_STOP (1<<2) #define VIA8233_REG_SGD_STAT_ACTIVE (1<<3) #define VIA8233_INTR_MASK(chan) ((VIA8233_REG_SGD_STAT_FLAG|VIA8233_REG_SGD_STAT_EOL) << ((chan) * 4)) #define VIA8233_REG_SGD_CHAN_SDX 0 #define VIA8233_REG_SGD_CHAN_MULTI 4 #define VIA8233_REG_SGD_CHAN_REC 6 #define VIA8233_REG_SGD_CHAN_REC1 7 #define VIA_REG_GPI_STATUS 0x88 #define VIA_REG_GPI_INTR 0x8c /* multi-channel and capture registers for via8233 */ DEFINE_VIA_REGSET(MULTPLAY, 0x40); DEFINE_VIA_REGSET(CAPTURE_8233, 0x60); /* via8233-specific registers */ #define VIA_REG_OFS_PLAYBACK_VOLUME_L 0x02 /* byte */ #define VIA_REG_OFS_PLAYBACK_VOLUME_R 0x03 /* byte */ #define VIA_REG_OFS_MULTPLAY_FORMAT 0x02 /* byte - format and channels */ #define VIA_REG_MULTPLAY_FMT_8BIT 0x00 #define VIA_REG_MULTPLAY_FMT_16BIT 0x80 #define VIA_REG_MULTPLAY_FMT_CH_MASK 0x70 /* # channels << 4 (valid = 1,2,4,6) */ #define VIA_REG_OFS_CAPTURE_FIFO 0x02 /* byte - bit 6 = fifo enable */ #define VIA_REG_CAPTURE_FIFO_ENABLE 0x40 #define VIA_DXS_MAX_VOLUME 31 /* max. volume (attenuation) of reg 0x32/33 */ #define VIA_REG_CAPTURE_CHANNEL 0x63 /* byte - input select */ #define VIA_REG_CAPTURE_CHANNEL_MIC 0x4 #define VIA_REG_CAPTURE_CHANNEL_LINE 0 #define VIA_REG_CAPTURE_SELECT_CODEC 0x03 /* recording source codec (0 = primary) */ #define VIA_TBL_BIT_FLAG 0x40000000 #define VIA_TBL_BIT_EOL 0x80000000 /* pci space */ #define VIA_ACLINK_STAT 0x40 #define VIA_ACLINK_C11_READY 0x20 #define VIA_ACLINK_C10_READY 0x10 #define VIA_ACLINK_C01_READY 0x04 /* secondary codec ready */ #define VIA_ACLINK_LOWPOWER 0x02 /* low-power state */ #define VIA_ACLINK_C00_READY 0x01 /* primary codec ready */ #define VIA_ACLINK_CTRL 0x41 #define VIA_ACLINK_CTRL_ENABLE 0x80 /* 0: disable, 1: enable */ #define VIA_ACLINK_CTRL_RESET 0x40 /* 0: assert, 1: de-assert */ #define VIA_ACLINK_CTRL_SYNC 0x20 /* 0: release SYNC, 1: force SYNC hi */ #define VIA_ACLINK_CTRL_SDO 0x10 /* 0: release SDO, 1: force SDO hi */ #define VIA_ACLINK_CTRL_VRA 0x08 /* 0: disable VRA, 1: enable VRA */ #define VIA_ACLINK_CTRL_PCM 0x04 /* 0: disable PCM, 1: enable PCM */ #define VIA_ACLINK_CTRL_FM 0x02 /* via686 only */ #define VIA_ACLINK_CTRL_SB 0x01 /* via686 only */ #define VIA_ACLINK_CTRL_INIT (VIA_ACLINK_CTRL_ENABLE|\ VIA_ACLINK_CTRL_RESET|\ VIA_ACLINK_CTRL_PCM|\ VIA_ACLINK_CTRL_VRA) #define VIA_FUNC_ENABLE 0x42 #define VIA_FUNC_MIDI_PNP 0x80 /* FIXME: it's 0x40 in the datasheet! */ #define VIA_FUNC_MIDI_IRQMASK 0x40 /* FIXME: not documented! */ #define VIA_FUNC_RX2C_WRITE 0x20 #define VIA_FUNC_SB_FIFO_EMPTY 0x10 #define VIA_FUNC_ENABLE_GAME 0x08 #define VIA_FUNC_ENABLE_FM 0x04 #define VIA_FUNC_ENABLE_MIDI 0x02 #define VIA_FUNC_ENABLE_SB 0x01 #define VIA_PNP_CONTROL 0x43 #define VIA_FM_NMI_CTRL 0x48 #define VIA8233_VOLCHG_CTRL 0x48 #define VIA8233_SPDIF_CTRL 0x49 #define VIA8233_SPDIF_DX3 0x08 #define VIA8233_SPDIF_SLOT_MASK 0x03 #define VIA8233_SPDIF_SLOT_1011 0x00 #define VIA8233_SPDIF_SLOT_34 0x01 #define VIA8233_SPDIF_SLOT_78 0x02 #define VIA8233_SPDIF_SLOT_69 0x03 /* */ #define VIA_DXS_AUTO 0 #define VIA_DXS_ENABLE 1 #define VIA_DXS_DISABLE 2 #define VIA_DXS_48K 3 #define VIA_DXS_NO_VRA 4 |
2d7eb7cb2 [ALSA] Support al... |
306 |
#define VIA_DXS_SRC 5 |
1da177e4c Linux-2.6.12-rc2 |
307 308 309 |
/* |
1da177e4c Linux-2.6.12-rc2 |
310 311 312 313 314 315 316 317 318 |
* pcm stream */ struct snd_via_sg_table { unsigned int offset; unsigned int size; } ; #define VIA_TABLE_SIZE 255 |
5503600a1 ALSA: via82xx - c... |
319 |
#define VIA_MAX_BUFSIZE (1<<24) |
1da177e4c Linux-2.6.12-rc2 |
320 |
|
e437e3d7c [ALSA] Remove xxx... |
321 |
struct viadev { |
1da177e4c Linux-2.6.12-rc2 |
322 323 324 |
unsigned int reg_offset; unsigned long port; int direction; /* playback = 0, capture = 1 */ |
e437e3d7c [ALSA] Remove xxx... |
325 |
struct snd_pcm_substream *substream; |
1da177e4c Linux-2.6.12-rc2 |
326 327 328 329 330 331 332 333 334 |
int running; unsigned int tbl_entries; /* # descriptors */ struct snd_dma_buffer table; struct snd_via_sg_table *idx_table; /* for recovery from the unexpected pointer */ unsigned int lastpos; unsigned int fragsize; unsigned int bufsize; unsigned int bufsize2; |
4f550df58 [ALSA] Reduce int... |
335 336 337 |
int hwptr_done; /* processed frame position in the buffer */ int in_interrupt; int shadow_shift; |
1da177e4c Linux-2.6.12-rc2 |
338 339 340 341 342 343 344 345 346 347 348 349 350 |
}; enum { TYPE_CARD_VIA686 = 1, TYPE_CARD_VIA8233 }; enum { TYPE_VIA686, TYPE_VIA8233, TYPE_VIA8233A }; #define VIA_MAX_DEVS 7 /* 4 playback, 1 multi, 2 capture */ struct via_rate_lock { spinlock_t lock; int rate; int used; }; |
e437e3d7c [ALSA] Remove xxx... |
351 |
struct via82xx { |
1da177e4c Linux-2.6.12-rc2 |
352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 |
int irq; unsigned long port; struct resource *mpu_res; int chip_type; unsigned char revision; unsigned char old_legacy; unsigned char old_legacy_cfg; #ifdef CONFIG_PM unsigned char legacy_saved; unsigned char legacy_cfg_saved; unsigned char spdif_ctrl_saved; unsigned char capture_src_saved[2]; unsigned int mpu_port_saved; #endif |
00f226d40 [ALSA] Enable DXS... |
368 369 |
unsigned char playback_volume[4][2]; /* for VIA8233/C/8235; default = 0 */ unsigned char playback_volume_c[2]; /* for VIA8233/C/8235; default = 0 */ |
1da177e4c Linux-2.6.12-rc2 |
370 371 372 373 |
unsigned int intr_mask; /* SGD_SHADOW mask to check interrupts */ struct pci_dev *pci; |
e437e3d7c [ALSA] Remove xxx... |
374 |
struct snd_card *card; |
1da177e4c Linux-2.6.12-rc2 |
375 376 377 |
unsigned int num_devs; unsigned int playback_devno, multi_devno, capture_devno; |
e437e3d7c [ALSA] Remove xxx... |
378 |
struct viadev devs[VIA_MAX_DEVS]; |
1da177e4c Linux-2.6.12-rc2 |
379 380 381 |
struct via_rate_lock rates[2]; /* playback and capture */ unsigned int dxs_fixed: 1; /* DXS channel accepts only 48kHz */ unsigned int no_vra: 1; /* no need to set VRA on DXS channels */ |
2d7eb7cb2 [ALSA] Support al... |
382 |
unsigned int dxs_src: 1; /* use full SRC capabilities of DXS */ |
1da177e4c Linux-2.6.12-rc2 |
383 |
unsigned int spdif_on: 1; /* only spdif rates work to external DACs */ |
e437e3d7c [ALSA] Remove xxx... |
384 385 |
struct snd_pcm *pcms[2]; struct snd_rawmidi *rmidi; |
3d0094137 sound: via82xx: d... |
386 |
struct snd_kcontrol *dxs_controls[4]; |
1da177e4c Linux-2.6.12-rc2 |
387 |
|
e437e3d7c [ALSA] Remove xxx... |
388 389 |
struct snd_ac97_bus *ac97_bus; struct snd_ac97 *ac97; |
1da177e4c Linux-2.6.12-rc2 |
390 391 392 393 |
unsigned int ac97_clock; unsigned int ac97_secondary; /* secondary AC'97 codec is present */ spinlock_t reg_lock; |
e437e3d7c [ALSA] Remove xxx... |
394 |
struct snd_info_entry *proc_entry; |
1da177e4c Linux-2.6.12-rc2 |
395 396 397 398 399 |
#ifdef SUPPORT_JOYSTICK struct gameport *gameport; #endif }; |
cebe41d4b sound: use DEFINE... |
400 |
static DEFINE_PCI_DEVICE_TABLE(snd_via82xx_ids) = { |
4f550df58 [ALSA] Reduce int... |
401 |
/* 0x1106, 0x3058 */ |
28d27aae9 sound: Use PCI_VD... |
402 |
{ PCI_VDEVICE(VIA, PCI_DEVICE_ID_VIA_82C686_5), TYPE_CARD_VIA686, }, /* 686A */ |
4f550df58 [ALSA] Reduce int... |
403 |
/* 0x1106, 0x3059 */ |
28d27aae9 sound: Use PCI_VD... |
404 |
{ PCI_VDEVICE(VIA, PCI_DEVICE_ID_VIA_8233_5), TYPE_CARD_VIA8233, }, /* VT8233 */ |
1da177e4c Linux-2.6.12-rc2 |
405 406 407 408 409 410 411 412 413 414 415 416 417 |
{ 0, } }; MODULE_DEVICE_TABLE(pci, snd_via82xx_ids); /* */ /* * allocate and initialize the descriptor buffers * periods = number of periods * fragsize = period size in bytes */ |
e437e3d7c [ALSA] Remove xxx... |
418 |
static int build_via_table(struct viadev *dev, struct snd_pcm_substream *substream, |
1da177e4c Linux-2.6.12-rc2 |
419 420 421 422 |
struct pci_dev *pci, unsigned int periods, unsigned int fragsize) { unsigned int i, idx, ofs, rest; |
e437e3d7c [ALSA] Remove xxx... |
423 |
struct via82xx *chip = snd_pcm_substream_chip(substream); |
1da177e4c Linux-2.6.12-rc2 |
424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 |
if (dev->table.area == NULL) { /* the start of each lists must be aligned to 8 bytes, * but the kernel pages are much bigger, so we don't care */ if (snd_dma_alloc_pages(SNDRV_DMA_TYPE_DEV, snd_dma_pci_data(chip->pci), PAGE_ALIGN(VIA_TABLE_SIZE * 2 * 8), &dev->table) < 0) return -ENOMEM; } if (! dev->idx_table) { dev->idx_table = kmalloc(sizeof(*dev->idx_table) * VIA_TABLE_SIZE, GFP_KERNEL); if (! dev->idx_table) return -ENOMEM; } /* fill the entries */ idx = 0; ofs = 0; for (i = 0; i < periods; i++) { rest = fragsize; /* fill descriptors for a period. * a period can be split to several descriptors if it's * over page boundary. */ do { unsigned int r; unsigned int flag; |
77a23f269 ALSA: Clean up SG... |
452 |
unsigned int addr; |
1da177e4c Linux-2.6.12-rc2 |
453 454 455 456 457 458 |
if (idx >= VIA_TABLE_SIZE) { snd_printk(KERN_ERR "via82xx: too much table size! "); return -EINVAL; } |
77a23f269 ALSA: Clean up SG... |
459 460 |
addr = snd_pcm_sgbuf_get_addr(substream, ofs); ((u32 *)dev->table.area)[idx << 1] = cpu_to_le32(addr); |
5503600a1 ALSA: via82xx - c... |
461 |
r = snd_pcm_sgbuf_get_chunk_size(substream, ofs, rest); |
1da177e4c Linux-2.6.12-rc2 |
462 463 464 465 466 467 468 469 |
rest -= r; if (! rest) { if (i == periods - 1) flag = VIA_TBL_BIT_EOL; /* buffer boundary */ else flag = VIA_TBL_BIT_FLAG; /* period boundary */ } else flag = 0; /* period continues to the next */ |
ee419653a ALSA: Fix missing... |
470 471 472 473 474 |
/* printk(KERN_DEBUG "via: tbl %d: at %d size %d " "(rest %d) ", idx, ofs, r, rest); */ |
1da177e4c Linux-2.6.12-rc2 |
475 476 477 478 479 480 481 482 483 484 485 486 487 |
((u32 *)dev->table.area)[(idx<<1) + 1] = cpu_to_le32(r | flag); dev->idx_table[idx].offset = ofs; dev->idx_table[idx].size = r; ofs += r; idx++; } while (rest > 0); } dev->tbl_entries = idx; dev->bufsize = periods * fragsize; dev->bufsize2 = dev->bufsize / 2; dev->fragsize = fragsize; return 0; } |
e437e3d7c [ALSA] Remove xxx... |
488 |
static int clean_via_table(struct viadev *dev, struct snd_pcm_substream *substream, |
1da177e4c Linux-2.6.12-rc2 |
489 490 491 492 493 494 |
struct pci_dev *pci) { if (dev->table.area) { snd_dma_free_pages(&dev->table); dev->table.area = NULL; } |
4d572776d [ALSA] Remove red... |
495 496 |
kfree(dev->idx_table); dev->idx_table = NULL; |
1da177e4c Linux-2.6.12-rc2 |
497 498 499 500 501 502 |
return 0; } /* * Basic I/O */ |
e437e3d7c [ALSA] Remove xxx... |
503 |
static inline unsigned int snd_via82xx_codec_xread(struct via82xx *chip) |
1da177e4c Linux-2.6.12-rc2 |
504 505 506 507 |
{ return inl(VIAREG(chip, AC97)); } |
e437e3d7c [ALSA] Remove xxx... |
508 |
static inline void snd_via82xx_codec_xwrite(struct via82xx *chip, unsigned int val) |
1da177e4c Linux-2.6.12-rc2 |
509 510 511 512 |
{ outl(val, VIAREG(chip, AC97)); } |
e437e3d7c [ALSA] Remove xxx... |
513 |
static int snd_via82xx_codec_ready(struct via82xx *chip, int secondary) |
1da177e4c Linux-2.6.12-rc2 |
514 515 516 517 518 519 520 521 522 |
{ unsigned int timeout = 1000; /* 1ms */ unsigned int val; while (timeout-- > 0) { udelay(1); if (!((val = snd_via82xx_codec_xread(chip)) & VIA_REG_AC97_BUSY)) return val & 0xffff; } |
e437e3d7c [ALSA] Remove xxx... |
523 524 525 |
snd_printk(KERN_ERR "codec_ready: codec %i is not ready [0x%x] ", secondary, snd_via82xx_codec_xread(chip)); |
1da177e4c Linux-2.6.12-rc2 |
526 527 528 |
return -EIO; } |
e437e3d7c [ALSA] Remove xxx... |
529 |
static int snd_via82xx_codec_valid(struct via82xx *chip, int secondary) |
1da177e4c Linux-2.6.12-rc2 |
530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 |
{ unsigned int timeout = 1000; /* 1ms */ unsigned int val, val1; unsigned int stat = !secondary ? VIA_REG_AC97_PRIMARY_VALID : VIA_REG_AC97_SECONDARY_VALID; while (timeout-- > 0) { val = snd_via82xx_codec_xread(chip); val1 = val & (VIA_REG_AC97_BUSY | stat); if (val1 == stat) return val & 0xffff; udelay(1); } return -EIO; } |
e437e3d7c [ALSA] Remove xxx... |
546 |
static void snd_via82xx_codec_wait(struct snd_ac97 *ac97) |
1da177e4c Linux-2.6.12-rc2 |
547 |
{ |
e437e3d7c [ALSA] Remove xxx... |
548 |
struct via82xx *chip = ac97->private_data; |
1da177e4c Linux-2.6.12-rc2 |
549 550 551 |
int err; err = snd_via82xx_codec_ready(chip, ac97->num); /* here we need to wait fairly for long time.. */ |
115551d98 ALSA: via82xx: ad... |
552 553 |
if (!nodelay) msleep(500); |
1da177e4c Linux-2.6.12-rc2 |
554 |
} |
e437e3d7c [ALSA] Remove xxx... |
555 |
static void snd_via82xx_codec_write(struct snd_ac97 *ac97, |
1da177e4c Linux-2.6.12-rc2 |
556 557 558 |
unsigned short reg, unsigned short val) { |
e437e3d7c [ALSA] Remove xxx... |
559 |
struct via82xx *chip = ac97->private_data; |
1da177e4c Linux-2.6.12-rc2 |
560 |
unsigned int xval; |
4f550df58 [ALSA] Reduce int... |
561 |
|
1da177e4c Linux-2.6.12-rc2 |
562 563 564 565 566 567 568 |
xval = !ac97->num ? VIA_REG_AC97_CODEC_ID_PRIMARY : VIA_REG_AC97_CODEC_ID_SECONDARY; xval <<= VIA_REG_AC97_CODEC_ID_SHIFT; xval |= reg << VIA_REG_AC97_CMD_SHIFT; xval |= val << VIA_REG_AC97_DATA_SHIFT; snd_via82xx_codec_xwrite(chip, xval); snd_via82xx_codec_ready(chip, ac97->num); } |
e437e3d7c [ALSA] Remove xxx... |
569 |
static unsigned short snd_via82xx_codec_read(struct snd_ac97 *ac97, unsigned short reg) |
1da177e4c Linux-2.6.12-rc2 |
570 |
{ |
e437e3d7c [ALSA] Remove xxx... |
571 |
struct via82xx *chip = ac97->private_data; |
1da177e4c Linux-2.6.12-rc2 |
572 573 574 575 576 577 578 579 580 |
unsigned int xval, val = 0xffff; int again = 0; xval = ac97->num << VIA_REG_AC97_CODEC_ID_SHIFT; xval |= ac97->num ? VIA_REG_AC97_SECONDARY_VALID : VIA_REG_AC97_PRIMARY_VALID; xval |= VIA_REG_AC97_READ; xval |= (reg & 0x7f) << VIA_REG_AC97_CMD_SHIFT; while (1) { if (again++ > 3) { |
e437e3d7c [ALSA] Remove xxx... |
581 582 583 |
snd_printk(KERN_ERR "codec_read: codec %i is not valid [0x%x] ", ac97->num, snd_via82xx_codec_xread(chip)); |
1da177e4c Linux-2.6.12-rc2 |
584 585 586 587 588 589 590 591 592 593 594 595 |
return 0xffff; } snd_via82xx_codec_xwrite(chip, xval); udelay (20); if (snd_via82xx_codec_valid(chip, ac97->num) >= 0) { udelay(25); val = snd_via82xx_codec_xread(chip); break; } } return val & 0xffff; } |
e437e3d7c [ALSA] Remove xxx... |
596 |
static void snd_via82xx_channel_reset(struct via82xx *chip, struct viadev *viadev) |
1da177e4c Linux-2.6.12-rc2 |
597 598 599 600 601 602 603 604 605 606 607 608 |
{ outb(VIA_REG_CTRL_PAUSE | VIA_REG_CTRL_TERMINATE | VIA_REG_CTRL_RESET, VIADEV_REG(viadev, OFFSET_CONTROL)); inb(VIADEV_REG(viadev, OFFSET_CONTROL)); udelay(50); /* disable interrupts */ outb(0x00, VIADEV_REG(viadev, OFFSET_CONTROL)); /* clear interrupts */ outb(0x03, VIADEV_REG(viadev, OFFSET_STATUS)); outb(0x00, VIADEV_REG(viadev, OFFSET_TYPE)); /* for via686 */ // outl(0, VIADEV_REG(viadev, OFFSET_CURR_PTR)); viadev->lastpos = 0; |
4f550df58 [ALSA] Reduce int... |
609 |
viadev->hwptr_done = 0; |
1da177e4c Linux-2.6.12-rc2 |
610 611 612 613 614 |
} /* * Interrupt handler |
4f550df58 [ALSA] Reduce int... |
615 |
* Used for 686 and 8233A |
1da177e4c Linux-2.6.12-rc2 |
616 |
*/ |
7d12e780e IRQ: Maintain reg... |
617 |
static irqreturn_t snd_via686_interrupt(int irq, void *dev_id) |
1da177e4c Linux-2.6.12-rc2 |
618 |
{ |
e437e3d7c [ALSA] Remove xxx... |
619 |
struct via82xx *chip = dev_id; |
1da177e4c Linux-2.6.12-rc2 |
620 621 622 623 624 625 626 |
unsigned int status; unsigned int i; status = inl(VIAREG(chip, SGD_SHADOW)); if (! (status & chip->intr_mask)) { if (chip->rmidi) /* check mpu401 interrupt */ |
7d12e780e IRQ: Maintain reg... |
627 |
return snd_mpu401_uart_interrupt(irq, chip->rmidi->private_data); |
1da177e4c Linux-2.6.12-rc2 |
628 629 630 631 632 633 |
return IRQ_NONE; } /* check status for each stream */ spin_lock(&chip->reg_lock); for (i = 0; i < chip->num_devs; i++) { |
e437e3d7c [ALSA] Remove xxx... |
634 |
struct viadev *viadev = &chip->devs[i]; |
1da177e4c Linux-2.6.12-rc2 |
635 |
unsigned char c_status = inb(VIADEV_REG(viadev, OFFSET_STATUS)); |
4f550df58 [ALSA] Reduce int... |
636 |
if (! (c_status & (VIA_REG_STAT_EOL|VIA_REG_STAT_FLAG|VIA_REG_STAT_STOPPED))) |
1da177e4c Linux-2.6.12-rc2 |
637 638 |
continue; if (viadev->substream && viadev->running) { |
4f550df58 [ALSA] Reduce int... |
639 640 641 642 643 644 645 646 647 648 |
/* * Update hwptr_done based on 'period elapsed' * interrupts. We'll use it, when the chip returns 0 * for OFFSET_CURR_COUNT. */ if (c_status & VIA_REG_STAT_EOL) viadev->hwptr_done = 0; else viadev->hwptr_done += viadev->fragsize; viadev->in_interrupt = c_status; |
1da177e4c Linux-2.6.12-rc2 |
649 650 651 |
spin_unlock(&chip->reg_lock); snd_pcm_period_elapsed(viadev->substream); spin_lock(&chip->reg_lock); |
4f550df58 [ALSA] Reduce int... |
652 |
viadev->in_interrupt = 0; |
1da177e4c Linux-2.6.12-rc2 |
653 654 655 656 657 658 659 660 |
} outb(c_status, VIADEV_REG(viadev, OFFSET_STATUS)); /* ack */ } spin_unlock(&chip->reg_lock); return IRQ_HANDLED; } /* |
4f550df58 [ALSA] Reduce int... |
661 662 |
* Interrupt handler */ |
7d12e780e IRQ: Maintain reg... |
663 |
static irqreturn_t snd_via8233_interrupt(int irq, void *dev_id) |
4f550df58 [ALSA] Reduce int... |
664 |
{ |
e437e3d7c [ALSA] Remove xxx... |
665 |
struct via82xx *chip = dev_id; |
4f550df58 [ALSA] Reduce int... |
666 667 668 669 670 671 672 673 674 |
unsigned int status; unsigned int i; int irqreturn = 0; /* check status for each stream */ spin_lock(&chip->reg_lock); status = inl(VIAREG(chip, SGD_SHADOW)); for (i = 0; i < chip->num_devs; i++) { |
e437e3d7c [ALSA] Remove xxx... |
675 676 |
struct viadev *viadev = &chip->devs[i]; struct snd_pcm_substream *substream; |
4f550df58 [ALSA] Reduce int... |
677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 |
unsigned char c_status, shadow_status; shadow_status = (status >> viadev->shadow_shift) & (VIA8233_SHADOW_STAT_ACTIVE|VIA_REG_STAT_EOL| VIA_REG_STAT_FLAG); c_status = shadow_status & (VIA_REG_STAT_EOL|VIA_REG_STAT_FLAG); if (!c_status) continue; substream = viadev->substream; if (substream && viadev->running) { /* * Update hwptr_done based on 'period elapsed' * interrupts. We'll use it, when the chip returns 0 * for OFFSET_CURR_COUNT. */ if (c_status & VIA_REG_STAT_EOL) viadev->hwptr_done = 0; else viadev->hwptr_done += viadev->fragsize; viadev->in_interrupt = c_status; if (shadow_status & VIA8233_SHADOW_STAT_ACTIVE) viadev->in_interrupt |= VIA_REG_STAT_ACTIVE; spin_unlock(&chip->reg_lock); snd_pcm_period_elapsed(substream); spin_lock(&chip->reg_lock); viadev->in_interrupt = 0; } outb(c_status, VIADEV_REG(viadev, OFFSET_STATUS)); /* ack */ irqreturn = 1; } spin_unlock(&chip->reg_lock); return IRQ_RETVAL(irqreturn); } /* |
1da177e4c Linux-2.6.12-rc2 |
715 716 717 718 719 720 |
* PCM callbacks */ /* * trigger callback */ |
e437e3d7c [ALSA] Remove xxx... |
721 |
static int snd_via82xx_pcm_trigger(struct snd_pcm_substream *substream, int cmd) |
1da177e4c Linux-2.6.12-rc2 |
722 |
{ |
e437e3d7c [ALSA] Remove xxx... |
723 724 |
struct via82xx *chip = snd_pcm_substream_chip(substream); struct viadev *viadev = substream->runtime->private_data; |
1da177e4c Linux-2.6.12-rc2 |
725 726 727 728 729 730 731 732 |
unsigned char val; if (chip->chip_type != TYPE_VIA686) val = VIA_REG_CTRL_INT; else val = 0; switch (cmd) { case SNDRV_PCM_TRIGGER_START: |
41e4845c4 [ALSA] PCM resume... |
733 |
case SNDRV_PCM_TRIGGER_RESUME: |
1da177e4c Linux-2.6.12-rc2 |
734 735 736 737 |
val |= VIA_REG_CTRL_START; viadev->running = 1; break; case SNDRV_PCM_TRIGGER_STOP: |
41e4845c4 [ALSA] PCM resume... |
738 |
case SNDRV_PCM_TRIGGER_SUSPEND: |
1da177e4c Linux-2.6.12-rc2 |
739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 |
val = VIA_REG_CTRL_TERMINATE; viadev->running = 0; break; case SNDRV_PCM_TRIGGER_PAUSE_PUSH: val |= VIA_REG_CTRL_PAUSE; viadev->running = 0; break; case SNDRV_PCM_TRIGGER_PAUSE_RELEASE: viadev->running = 1; break; default: return -EINVAL; } outb(val, VIADEV_REG(viadev, OFFSET_CONTROL)); if (cmd == SNDRV_PCM_TRIGGER_STOP) snd_via82xx_channel_reset(chip, viadev); return 0; } /* * pointer callbacks */ /* * calculate the linear position at the given sg-buffer index and the rest count */ #define check_invalid_pos(viadev,pos) \ |
e437e3d7c [ALSA] Remove xxx... |
768 769 |
((pos) < viadev->lastpos && ((pos) >= viadev->bufsize2 ||\ viadev->lastpos < viadev->bufsize2)) |
1da177e4c Linux-2.6.12-rc2 |
770 |
|
e437e3d7c [ALSA] Remove xxx... |
771 772 |
static inline unsigned int calc_linear_pos(struct viadev *viadev, unsigned int idx, unsigned int count) |
1da177e4c Linux-2.6.12-rc2 |
773 774 775 776 777 778 |
{ unsigned int size, base, res; size = viadev->idx_table[idx].size; base = viadev->idx_table[idx].offset; res = base + size - count; |
4f550df58 [ALSA] Reduce int... |
779 780 |
if (res >= viadev->bufsize) res -= viadev->bufsize; |
1da177e4c Linux-2.6.12-rc2 |
781 782 783 |
/* check the validity of the calculated position */ if (size < count) { |
e437e3d7c [ALSA] Remove xxx... |
784 785 786 |
snd_printd(KERN_ERR "invalid via82xx_cur_ptr (size = %d, count = %d) ", (int)size, (int)count); |
1da177e4c Linux-2.6.12-rc2 |
787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 |
res = viadev->lastpos; } else { if (! count) { /* Some mobos report count = 0 on the DMA boundary, * i.e. count = size indeed. * Let's check whether this step is above the expected size. */ int delta = res - viadev->lastpos; if (delta < 0) delta += viadev->bufsize; if ((unsigned int)delta > viadev->fragsize) res = base; } if (check_invalid_pos(viadev, res)) { #ifdef POINTER_DEBUG |
e437e3d7c [ALSA] Remove xxx... |
802 803 804 805 806 807 808 |
printk(KERN_DEBUG "fail: idx = %i/%i, lastpos = 0x%x, " "bufsize2 = 0x%x, offsize = 0x%x, size = 0x%x, " "count = 0x%x ", idx, viadev->tbl_entries, viadev->lastpos, viadev->bufsize2, viadev->idx_table[idx].offset, viadev->idx_table[idx].size, count); |
1da177e4c Linux-2.6.12-rc2 |
809 810 811 812 |
#endif /* count register returns full size when end of buffer is reached */ res = base + size; if (check_invalid_pos(viadev, res)) { |
e437e3d7c [ALSA] Remove xxx... |
813 814 815 |
snd_printd(KERN_ERR "invalid via82xx_cur_ptr (2), " "using last valid pointer "); |
1da177e4c Linux-2.6.12-rc2 |
816 817 818 819 |
res = viadev->lastpos; } } } |
1da177e4c Linux-2.6.12-rc2 |
820 821 822 823 824 825 |
return res; } /* * get the current pointer on via686 */ |
e437e3d7c [ALSA] Remove xxx... |
826 |
static snd_pcm_uframes_t snd_via686_pcm_pointer(struct snd_pcm_substream *substream) |
1da177e4c Linux-2.6.12-rc2 |
827 |
{ |
e437e3d7c [ALSA] Remove xxx... |
828 829 |
struct via82xx *chip = snd_pcm_substream_chip(substream); struct viadev *viadev = substream->runtime->private_data; |
1da177e4c Linux-2.6.12-rc2 |
830 |
unsigned int idx, ptr, count, res; |
da3cec35d ALSA: Kill snd_as... |
831 832 |
if (snd_BUG_ON(!viadev->tbl_entries)) return 0; |
1da177e4c Linux-2.6.12-rc2 |
833 834 835 836 837 838 839 840 841 842 843 844 845 846 |
if (!(inb(VIADEV_REG(viadev, OFFSET_STATUS)) & VIA_REG_STAT_ACTIVE)) return 0; spin_lock(&chip->reg_lock); count = inl(VIADEV_REG(viadev, OFFSET_CURR_COUNT)) & 0xffffff; /* The via686a does not have the current index register, * so we need to calculate the index from CURR_PTR. */ ptr = inl(VIADEV_REG(viadev, OFFSET_CURR_PTR)); if (ptr <= (unsigned int)viadev->table.addr) idx = 0; else /* CURR_PTR holds the address + 8 */ idx = ((ptr - (unsigned int)viadev->table.addr) / 8 - 1) % viadev->tbl_entries; res = calc_linear_pos(viadev, idx, count); |
4f550df58 [ALSA] Reduce int... |
847 |
viadev->lastpos = res; /* remember the last position */ |
1da177e4c Linux-2.6.12-rc2 |
848 849 850 851 852 853 854 855 |
spin_unlock(&chip->reg_lock); return bytes_to_frames(substream->runtime, res); } /* * get the current pointer on via823x */ |
e437e3d7c [ALSA] Remove xxx... |
856 |
static snd_pcm_uframes_t snd_via8233_pcm_pointer(struct snd_pcm_substream *substream) |
1da177e4c Linux-2.6.12-rc2 |
857 |
{ |
e437e3d7c [ALSA] Remove xxx... |
858 859 |
struct via82xx *chip = snd_pcm_substream_chip(substream); struct viadev *viadev = substream->runtime->private_data; |
1da177e4c Linux-2.6.12-rc2 |
860 |
unsigned int idx, count, res; |
4f550df58 [ALSA] Reduce int... |
861 |
int status; |
1da177e4c Linux-2.6.12-rc2 |
862 |
|
da3cec35d ALSA: Kill snd_as... |
863 864 |
if (snd_BUG_ON(!viadev->tbl_entries)) return 0; |
4f550df58 [ALSA] Reduce int... |
865 |
|
1da177e4c Linux-2.6.12-rc2 |
866 |
spin_lock(&chip->reg_lock); |
4f550df58 [ALSA] Reduce int... |
867 868 869 870 |
count = inl(VIADEV_REG(viadev, OFFSET_CURR_COUNT)); status = viadev->in_interrupt; if (!status) status = inb(VIADEV_REG(viadev, OFFSET_STATUS)); |
c6cc0e3b0 [ALSA] via82xx: t... |
871 872 873 874 |
/* An apparent bug in the 8251 is worked around by sending a * REG_CTRL_START. */ if (chip->revision == VIA_REV_8251 && (status & VIA_REG_STAT_EOL)) snd_via82xx_pcm_trigger(substream, SNDRV_PCM_TRIGGER_START); |
4f550df58 [ALSA] Reduce int... |
875 |
if (!(status & VIA_REG_STAT_ACTIVE)) { |
c6cc0e3b0 [ALSA] via82xx: t... |
876 877 |
res = 0; goto unlock; |
4f550df58 [ALSA] Reduce int... |
878 879 880 881 |
} if (count & 0xffffff) { idx = count >> 24; if (idx >= viadev->tbl_entries) { |
1da177e4c Linux-2.6.12-rc2 |
882 |
#ifdef POINTER_DEBUG |
e437e3d7c [ALSA] Remove xxx... |
883 884 885 |
printk(KERN_DEBUG "fail: invalid idx = %i/%i ", idx, viadev->tbl_entries); |
1da177e4c Linux-2.6.12-rc2 |
886 |
#endif |
4f550df58 [ALSA] Reduce int... |
887 888 889 890 891 |
res = viadev->lastpos; } else { count &= 0xffffff; res = calc_linear_pos(viadev, idx, count); } |
1da177e4c Linux-2.6.12-rc2 |
892 |
} else { |
4f550df58 [ALSA] Reduce int... |
893 894 895 896 897 898 899 900 901 902 903 904 |
res = viadev->hwptr_done; if (!viadev->in_interrupt) { if (status & VIA_REG_STAT_EOL) { res = 0; } else if (status & VIA_REG_STAT_FLAG) { res += viadev->fragsize; } } } unlock: viadev->lastpos = res; |
1da177e4c Linux-2.6.12-rc2 |
905 906 907 908 909 910 911 912 913 914 |
spin_unlock(&chip->reg_lock); return bytes_to_frames(substream->runtime, res); } /* * hw_params callback: * allocate the buffer and build up the buffer description table */ |
e437e3d7c [ALSA] Remove xxx... |
915 916 |
static int snd_via82xx_hw_params(struct snd_pcm_substream *substream, struct snd_pcm_hw_params *hw_params) |
1da177e4c Linux-2.6.12-rc2 |
917 |
{ |
e437e3d7c [ALSA] Remove xxx... |
918 919 |
struct via82xx *chip = snd_pcm_substream_chip(substream); struct viadev *viadev = substream->runtime->private_data; |
1da177e4c Linux-2.6.12-rc2 |
920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 |
int err; err = snd_pcm_lib_malloc_pages(substream, params_buffer_bytes(hw_params)); if (err < 0) return err; err = build_via_table(viadev, substream, chip->pci, params_periods(hw_params), params_period_bytes(hw_params)); if (err < 0) return err; return 0; } /* * hw_free callback: * clean up the buffer description table and release the buffer */ |
e437e3d7c [ALSA] Remove xxx... |
938 |
static int snd_via82xx_hw_free(struct snd_pcm_substream *substream) |
1da177e4c Linux-2.6.12-rc2 |
939 |
{ |
e437e3d7c [ALSA] Remove xxx... |
940 941 |
struct via82xx *chip = snd_pcm_substream_chip(substream); struct viadev *viadev = substream->runtime->private_data; |
1da177e4c Linux-2.6.12-rc2 |
942 943 944 945 946 947 948 949 950 951 |
clean_via_table(viadev, substream, chip->pci); snd_pcm_lib_free_pages(substream); return 0; } /* * set up the table pointer */ |
e437e3d7c [ALSA] Remove xxx... |
952 |
static void snd_via82xx_set_table_ptr(struct via82xx *chip, struct viadev *viadev) |
1da177e4c Linux-2.6.12-rc2 |
953 954 955 956 957 958 959 960 961 962 |
{ snd_via82xx_codec_ready(chip, 0); outl((u32)viadev->table.addr, VIADEV_REG(viadev, OFFSET_TABLE_PTR)); udelay(20); snd_via82xx_codec_ready(chip, 0); } /* * prepare callback for playback and capture on via686 */ |
e437e3d7c [ALSA] Remove xxx... |
963 964 |
static void via686_setup_format(struct via82xx *chip, struct viadev *viadev, struct snd_pcm_runtime *runtime) |
1da177e4c Linux-2.6.12-rc2 |
965 966 967 968 969 970 971 972 973 974 975 |
{ snd_via82xx_channel_reset(chip, viadev); /* this must be set after channel_reset */ snd_via82xx_set_table_ptr(chip, viadev); outb(VIA_REG_TYPE_AUTOSTART | (runtime->format == SNDRV_PCM_FORMAT_S16_LE ? VIA_REG_TYPE_16BIT : 0) | (runtime->channels > 1 ? VIA_REG_TYPE_STEREO : 0) | ((viadev->reg_offset & 0x10) == 0 ? VIA_REG_TYPE_INT_LSAMPLE : 0) | VIA_REG_TYPE_INT_EOL | VIA_REG_TYPE_INT_FLAG, VIADEV_REG(viadev, OFFSET_TYPE)); } |
e437e3d7c [ALSA] Remove xxx... |
976 |
static int snd_via686_playback_prepare(struct snd_pcm_substream *substream) |
1da177e4c Linux-2.6.12-rc2 |
977 |
{ |
e437e3d7c [ALSA] Remove xxx... |
978 979 980 |
struct via82xx *chip = snd_pcm_substream_chip(substream); struct viadev *viadev = substream->runtime->private_data; struct snd_pcm_runtime *runtime = substream->runtime; |
1da177e4c Linux-2.6.12-rc2 |
981 982 983 984 985 986 |
snd_ac97_set_rate(chip->ac97, AC97_PCM_FRONT_DAC_RATE, runtime->rate); snd_ac97_set_rate(chip->ac97, AC97_SPDIF, runtime->rate); via686_setup_format(chip, viadev, runtime); return 0; } |
e437e3d7c [ALSA] Remove xxx... |
987 |
static int snd_via686_capture_prepare(struct snd_pcm_substream *substream) |
1da177e4c Linux-2.6.12-rc2 |
988 |
{ |
e437e3d7c [ALSA] Remove xxx... |
989 990 991 |
struct via82xx *chip = snd_pcm_substream_chip(substream); struct viadev *viadev = substream->runtime->private_data; struct snd_pcm_runtime *runtime = substream->runtime; |
1da177e4c Linux-2.6.12-rc2 |
992 993 994 995 996 997 998 999 1000 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 |
snd_ac97_set_rate(chip->ac97, AC97_PCM_LR_ADC_RATE, runtime->rate); via686_setup_format(chip, viadev, runtime); return 0; } /* * lock the current rate */ static int via_lock_rate(struct via_rate_lock *rec, int rate) { int changed = 0; spin_lock_irq(&rec->lock); if (rec->rate != rate) { if (rec->rate && rec->used > 1) /* already set */ changed = -EINVAL; else { rec->rate = rate; changed = 1; } } spin_unlock_irq(&rec->lock); return changed; } /* * prepare callback for DSX playback on via823x */ |
e437e3d7c [ALSA] Remove xxx... |
1021 |
static int snd_via8233_playback_prepare(struct snd_pcm_substream *substream) |
1da177e4c Linux-2.6.12-rc2 |
1022 |
{ |
e437e3d7c [ALSA] Remove xxx... |
1023 1024 1025 |
struct via82xx *chip = snd_pcm_substream_chip(substream); struct viadev *viadev = substream->runtime->private_data; struct snd_pcm_runtime *runtime = substream->runtime; |
2d7eb7cb2 [ALSA] Support al... |
1026 |
int ac97_rate = chip->dxs_src ? 48000 : runtime->rate; |
1da177e4c Linux-2.6.12-rc2 |
1027 1028 |
int rate_changed; u32 rbits; |
2d7eb7cb2 [ALSA] Support al... |
1029 |
if ((rate_changed = via_lock_rate(&chip->rates[0], ac97_rate)) < 0) |
1da177e4c Linux-2.6.12-rc2 |
1030 |
return rate_changed; |
16d3f140f [ALSA] via82xx - ... |
1031 |
if (rate_changed) |
1da177e4c Linux-2.6.12-rc2 |
1032 1033 |
snd_ac97_set_rate(chip->ac97, AC97_PCM_FRONT_DAC_RATE, chip->no_vra ? 48000 : runtime->rate); |
16d3f140f [ALSA] via82xx - ... |
1034 1035 |
if (chip->spdif_on && viadev->reg_offset == 0x30) snd_ac97_set_rate(chip->ac97, AC97_SPDIF, runtime->rate); |
1da177e4c Linux-2.6.12-rc2 |
1036 1037 1038 |
if (runtime->rate == 48000) rbits = 0xfffff; else |
e437e3d7c [ALSA] Remove xxx... |
1039 1040 |
rbits = (0x100000 / 48000) * runtime->rate + ((0x100000 % 48000) * runtime->rate) / 48000; |
da3cec35d ALSA: Kill snd_as... |
1041 |
snd_BUG_ON(rbits & ~0xfffff); |
1da177e4c Linux-2.6.12-rc2 |
1042 1043 |
snd_via82xx_channel_reset(chip, viadev); snd_via82xx_set_table_ptr(chip, viadev); |
e437e3d7c [ALSA] Remove xxx... |
1044 1045 1046 1047 |
outb(chip->playback_volume[viadev->reg_offset / 0x10][0], VIADEV_REG(viadev, OFS_PLAYBACK_VOLUME_L)); outb(chip->playback_volume[viadev->reg_offset / 0x10][1], VIADEV_REG(viadev, OFS_PLAYBACK_VOLUME_R)); |
1da177e4c Linux-2.6.12-rc2 |
1048 1049 1050 1051 1052 1053 1054 1055 1056 1057 1058 1059 1060 |
outl((runtime->format == SNDRV_PCM_FORMAT_S16_LE ? VIA8233_REG_TYPE_16BIT : 0) | /* format */ (runtime->channels > 1 ? VIA8233_REG_TYPE_STEREO : 0) | /* stereo */ rbits | /* rate */ 0xff000000, /* STOP index is never reached */ VIADEV_REG(viadev, OFFSET_STOP_IDX)); udelay(20); snd_via82xx_codec_ready(chip, 0); return 0; } /* * prepare callback for multi-channel playback on via823x */ |
e437e3d7c [ALSA] Remove xxx... |
1061 |
static int snd_via8233_multi_prepare(struct snd_pcm_substream *substream) |
1da177e4c Linux-2.6.12-rc2 |
1062 |
{ |
e437e3d7c [ALSA] Remove xxx... |
1063 1064 1065 |
struct via82xx *chip = snd_pcm_substream_chip(substream); struct viadev *viadev = substream->runtime->private_data; struct snd_pcm_runtime *runtime = substream->runtime; |
1da177e4c Linux-2.6.12-rc2 |
1066 1067 1068 1069 1070 1071 1072 1073 1074 1075 1076 |
unsigned int slots; int fmt; if (via_lock_rate(&chip->rates[0], runtime->rate) < 0) return -EINVAL; snd_ac97_set_rate(chip->ac97, AC97_PCM_FRONT_DAC_RATE, runtime->rate); snd_ac97_set_rate(chip->ac97, AC97_PCM_SURR_DAC_RATE, runtime->rate); snd_ac97_set_rate(chip->ac97, AC97_PCM_LFE_DAC_RATE, runtime->rate); snd_ac97_set_rate(chip->ac97, AC97_SPDIF, runtime->rate); snd_via82xx_channel_reset(chip, viadev); snd_via82xx_set_table_ptr(chip, viadev); |
e437e3d7c [ALSA] Remove xxx... |
1077 1078 |
fmt = (runtime->format == SNDRV_PCM_FORMAT_S16_LE) ? VIA_REG_MULTPLAY_FMT_16BIT : VIA_REG_MULTPLAY_FMT_8BIT; |
1da177e4c Linux-2.6.12-rc2 |
1079 1080 1081 1082 1083 1084 1085 1086 1087 1088 1089 1090 1091 1092 1093 1094 1095 1096 1097 1098 1099 1100 1101 1102 1103 1104 1105 1106 1107 1108 |
fmt |= runtime->channels << 4; outb(fmt, VIADEV_REG(viadev, OFS_MULTPLAY_FORMAT)); #if 0 if (chip->revision == VIA_REV_8233A) slots = 0; else #endif { /* set sample number to slot 3, 4, 7, 8, 6, 9 (for VIA8233/C,8235) */ /* corresponding to FL, FR, RL, RR, C, LFE ?? */ switch (runtime->channels) { case 1: slots = (1<<0) | (1<<4); break; case 2: slots = (1<<0) | (2<<4); break; case 3: slots = (1<<0) | (2<<4) | (5<<8); break; case 4: slots = (1<<0) | (2<<4) | (3<<8) | (4<<12); break; case 5: slots = (1<<0) | (2<<4) | (3<<8) | (4<<12) | (5<<16); break; case 6: slots = (1<<0) | (2<<4) | (3<<8) | (4<<12) | (5<<16) | (6<<20); break; default: slots = 0; break; } } /* STOP index is never reached */ outl(0xff000000 | slots, VIADEV_REG(viadev, OFFSET_STOP_IDX)); udelay(20); snd_via82xx_codec_ready(chip, 0); return 0; } /* * prepare callback for capture on via823x */ |
e437e3d7c [ALSA] Remove xxx... |
1109 |
static int snd_via8233_capture_prepare(struct snd_pcm_substream *substream) |
1da177e4c Linux-2.6.12-rc2 |
1110 |
{ |
e437e3d7c [ALSA] Remove xxx... |
1111 1112 1113 |
struct via82xx *chip = snd_pcm_substream_chip(substream); struct viadev *viadev = substream->runtime->private_data; struct snd_pcm_runtime *runtime = substream->runtime; |
1da177e4c Linux-2.6.12-rc2 |
1114 1115 1116 1117 1118 1119 1120 1121 1122 1123 1124 1125 1126 1127 1128 1129 1130 1131 1132 1133 |
if (via_lock_rate(&chip->rates[1], runtime->rate) < 0) return -EINVAL; snd_ac97_set_rate(chip->ac97, AC97_PCM_LR_ADC_RATE, runtime->rate); snd_via82xx_channel_reset(chip, viadev); snd_via82xx_set_table_ptr(chip, viadev); outb(VIA_REG_CAPTURE_FIFO_ENABLE, VIADEV_REG(viadev, OFS_CAPTURE_FIFO)); outl((runtime->format == SNDRV_PCM_FORMAT_S16_LE ? VIA8233_REG_TYPE_16BIT : 0) | (runtime->channels > 1 ? VIA8233_REG_TYPE_STEREO : 0) | 0xff000000, /* STOP index is never reached */ VIADEV_REG(viadev, OFFSET_STOP_IDX)); udelay(20); snd_via82xx_codec_ready(chip, 0); return 0; } /* * pcm hardware definition, identical for both playback and capture */ |
e437e3d7c [ALSA] Remove xxx... |
1134 |
static struct snd_pcm_hardware snd_via82xx_hw = |
1da177e4c Linux-2.6.12-rc2 |
1135 1136 1137 1138 |
{ .info = (SNDRV_PCM_INFO_MMAP | SNDRV_PCM_INFO_INTERLEAVED | SNDRV_PCM_INFO_BLOCK_TRANSFER | SNDRV_PCM_INFO_MMAP_VALID | |
41e4845c4 [ALSA] PCM resume... |
1139 |
/* SNDRV_PCM_INFO_RESUME | */ |
1da177e4c Linux-2.6.12-rc2 |
1140 1141 1142 1143 1144 1145 1146 |
SNDRV_PCM_INFO_PAUSE), .formats = SNDRV_PCM_FMTBIT_U8 | SNDRV_PCM_FMTBIT_S16_LE, .rates = SNDRV_PCM_RATE_48000, .rate_min = 48000, .rate_max = 48000, .channels_min = 1, .channels_max = 2, |
5503600a1 ALSA: via82xx - c... |
1147 |
.buffer_bytes_max = VIA_MAX_BUFSIZE, |
1da177e4c Linux-2.6.12-rc2 |
1148 |
.period_bytes_min = 32, |
5503600a1 ALSA: via82xx - c... |
1149 |
.period_bytes_max = VIA_MAX_BUFSIZE / 2, |
1da177e4c Linux-2.6.12-rc2 |
1150 1151 1152 1153 1154 1155 1156 1157 1158 |
.periods_min = 2, .periods_max = VIA_TABLE_SIZE / 2, .fifo_size = 0, }; /* * open callback skeleton */ |
e437e3d7c [ALSA] Remove xxx... |
1159 1160 |
static int snd_via82xx_pcm_open(struct via82xx *chip, struct viadev *viadev, struct snd_pcm_substream *substream) |
1da177e4c Linux-2.6.12-rc2 |
1161 |
{ |
e437e3d7c [ALSA] Remove xxx... |
1162 |
struct snd_pcm_runtime *runtime = substream->runtime; |
1da177e4c Linux-2.6.12-rc2 |
1163 1164 |
int err; struct via_rate_lock *ratep; |
5495ffbd7 ALSA: via82xx: al... |
1165 |
bool use_src = false; |
1da177e4c Linux-2.6.12-rc2 |
1166 1167 1168 1169 1170 1171 1172 1173 1174 1175 1176 1177 1178 1179 1180 |
runtime->hw = snd_via82xx_hw; /* set the hw rate condition */ ratep = &chip->rates[viadev->direction]; spin_lock_irq(&ratep->lock); ratep->used++; if (chip->spdif_on && viadev->reg_offset == 0x30) { /* DXS#3 and spdif is on */ runtime->hw.rates = chip->ac97->rates[AC97_RATES_SPDIF]; snd_pcm_limit_hw_rates(runtime); } else if (chip->dxs_fixed && viadev->reg_offset < 0x40) { /* fixed DXS playback rate */ runtime->hw.rates = SNDRV_PCM_RATE_48000; runtime->hw.rate_min = runtime->hw.rate_max = 48000; |
2d7eb7cb2 [ALSA] Support al... |
1181 1182 1183 1184 1185 1186 |
} else if (chip->dxs_src && viadev->reg_offset < 0x40) { /* use full SRC capabilities of DXS */ runtime->hw.rates = (SNDRV_PCM_RATE_CONTINUOUS | SNDRV_PCM_RATE_8000_48000); runtime->hw.rate_min = 8000; runtime->hw.rate_max = 48000; |
5495ffbd7 ALSA: via82xx: al... |
1187 |
use_src = true; |
1da177e4c Linux-2.6.12-rc2 |
1188 1189 1190 1191 1192 1193 1194 1195 1196 1197 1198 1199 1200 1201 1202 |
} else if (! ratep->rate) { int idx = viadev->direction ? AC97_RATES_ADC : AC97_RATES_FRONT_DAC; runtime->hw.rates = chip->ac97->rates[idx]; snd_pcm_limit_hw_rates(runtime); } else { /* a fixed rate */ runtime->hw.rates = SNDRV_PCM_RATE_KNOT; runtime->hw.rate_max = runtime->hw.rate_min = ratep->rate; } spin_unlock_irq(&ratep->lock); /* we may remove following constaint when we modify table entries in interrupt */ if ((err = snd_pcm_hw_constraint_integer(runtime, SNDRV_PCM_HW_PARAM_PERIODS)) < 0) return err; |
5495ffbd7 ALSA: via82xx: al... |
1203 1204 1205 1206 1207 |
if (use_src) { err = snd_pcm_hw_rule_noresample(runtime, 48000); if (err < 0) return err; } |
1da177e4c Linux-2.6.12-rc2 |
1208 1209 1210 1211 1212 1213 1214 1215 |
runtime->private_data = viadev; viadev->substream = substream; return 0; } /* |
3d0094137 sound: via82xx: d... |
1216 |
* open callback for playback on via686 |
1da177e4c Linux-2.6.12-rc2 |
1217 |
*/ |
3d0094137 sound: via82xx: d... |
1218 |
static int snd_via686_playback_open(struct snd_pcm_substream *substream) |
1da177e4c Linux-2.6.12-rc2 |
1219 |
{ |
e437e3d7c [ALSA] Remove xxx... |
1220 1221 |
struct via82xx *chip = snd_pcm_substream_chip(substream); struct viadev *viadev = &chip->devs[chip->playback_devno + substream->number]; |
1da177e4c Linux-2.6.12-rc2 |
1222 1223 1224 1225 1226 1227 1228 1229 |
int err; if ((err = snd_via82xx_pcm_open(chip, viadev, substream)) < 0) return err; return 0; } /* |
3d0094137 sound: via82xx: d... |
1230 1231 1232 1233 1234 1235 1236 1237 1238 1239 1240 1241 1242 1243 |
* open callback for playback on via823x DXS */ static int snd_via8233_playback_open(struct snd_pcm_substream *substream) { struct via82xx *chip = snd_pcm_substream_chip(substream); struct viadev *viadev; unsigned int stream; int err; viadev = &chip->devs[chip->playback_devno + substream->number]; if ((err = snd_via82xx_pcm_open(chip, viadev, substream)) < 0) return err; stream = viadev->reg_offset / 0x10; if (chip->dxs_controls[stream]) { |
395c61d19 ALSA: via82xx: al... |
1244 1245 1246 1247 |
chip->playback_volume[stream][0] = VIA_DXS_MAX_VOLUME - (dxs_init_volume & 31); chip->playback_volume[stream][1] = VIA_DXS_MAX_VOLUME - (dxs_init_volume & 31); |
3d0094137 sound: via82xx: d... |
1248 1249 1250 1251 1252 1253 1254 1255 1256 1257 |
chip->dxs_controls[stream]->vd[0].access &= ~SNDRV_CTL_ELEM_ACCESS_INACTIVE; snd_ctl_notify(chip->card, SNDRV_CTL_EVENT_MASK_VALUE | SNDRV_CTL_EVENT_MASK_INFO, &chip->dxs_controls[stream]->id); } return 0; } /* |
1da177e4c Linux-2.6.12-rc2 |
1258 1259 |
* open callback for playback on via823x multi-channel */ |
e437e3d7c [ALSA] Remove xxx... |
1260 |
static int snd_via8233_multi_open(struct snd_pcm_substream *substream) |
1da177e4c Linux-2.6.12-rc2 |
1261 |
{ |
e437e3d7c [ALSA] Remove xxx... |
1262 1263 |
struct via82xx *chip = snd_pcm_substream_chip(substream); struct viadev *viadev = &chip->devs[chip->multi_devno]; |
1da177e4c Linux-2.6.12-rc2 |
1264 1265 1266 1267 1268 1269 1270 |
int err; /* channels constraint for VIA8233A * 3 and 5 channels are not supported */ static unsigned int channels[] = { 1, 2, 4, 6 }; |
e437e3d7c [ALSA] Remove xxx... |
1271 |
static struct snd_pcm_hw_constraint_list hw_constraints_channels = { |
1da177e4c Linux-2.6.12-rc2 |
1272 1273 1274 1275 1276 1277 1278 1279 1280 |
.count = ARRAY_SIZE(channels), .list = channels, .mask = 0, }; if ((err = snd_via82xx_pcm_open(chip, viadev, substream)) < 0) return err; substream->runtime->hw.channels_max = 6; if (chip->revision == VIA_REV_8233A) |
e437e3d7c [ALSA] Remove xxx... |
1281 1282 1283 |
snd_pcm_hw_constraint_list(substream->runtime, 0, SNDRV_PCM_HW_PARAM_CHANNELS, &hw_constraints_channels); |
1da177e4c Linux-2.6.12-rc2 |
1284 1285 1286 1287 1288 1289 |
return 0; } /* * open callback for capture on via686 and via823x */ |
e437e3d7c [ALSA] Remove xxx... |
1290 |
static int snd_via82xx_capture_open(struct snd_pcm_substream *substream) |
1da177e4c Linux-2.6.12-rc2 |
1291 |
{ |
e437e3d7c [ALSA] Remove xxx... |
1292 1293 |
struct via82xx *chip = snd_pcm_substream_chip(substream); struct viadev *viadev = &chip->devs[chip->capture_devno + substream->pcm->device]; |
1da177e4c Linux-2.6.12-rc2 |
1294 1295 1296 1297 1298 1299 1300 |
return snd_via82xx_pcm_open(chip, viadev, substream); } /* * close callback */ |
e437e3d7c [ALSA] Remove xxx... |
1301 |
static int snd_via82xx_pcm_close(struct snd_pcm_substream *substream) |
1da177e4c Linux-2.6.12-rc2 |
1302 |
{ |
e437e3d7c [ALSA] Remove xxx... |
1303 1304 |
struct via82xx *chip = snd_pcm_substream_chip(substream); struct viadev *viadev = substream->runtime->private_data; |
1da177e4c Linux-2.6.12-rc2 |
1305 1306 1307 1308 1309 1310 1311 1312 1313 |
struct via_rate_lock *ratep; /* release the rate lock */ ratep = &chip->rates[viadev->direction]; spin_lock_irq(&ratep->lock); ratep->used--; if (! ratep->used) ratep->rate = 0; spin_unlock_irq(&ratep->lock); |
6dbe66287 [ALSA] Add experi... |
1314 1315 1316 1317 1318 1319 1320 1321 1322 1323 1324 1325 |
if (! ratep->rate) { if (! viadev->direction) { snd_ac97_update_power(chip->ac97, AC97_PCM_FRONT_DAC_RATE, 0); snd_ac97_update_power(chip->ac97, AC97_PCM_SURR_DAC_RATE, 0); snd_ac97_update_power(chip->ac97, AC97_PCM_LFE_DAC_RATE, 0); } else snd_ac97_update_power(chip->ac97, AC97_PCM_LR_ADC_RATE, 0); } |
1da177e4c Linux-2.6.12-rc2 |
1326 1327 1328 |
viadev->substream = NULL; return 0; } |
3d0094137 sound: via82xx: d... |
1329 1330 1331 1332 1333 1334 1335 1336 1337 1338 1339 1340 1341 1342 1343 |
static int snd_via8233_playback_close(struct snd_pcm_substream *substream) { struct via82xx *chip = snd_pcm_substream_chip(substream); struct viadev *viadev = substream->runtime->private_data; unsigned int stream; stream = viadev->reg_offset / 0x10; if (chip->dxs_controls[stream]) { chip->dxs_controls[stream]->vd[0].access |= SNDRV_CTL_ELEM_ACCESS_INACTIVE; snd_ctl_notify(chip->card, SNDRV_CTL_EVENT_MASK_INFO, &chip->dxs_controls[stream]->id); } return snd_via82xx_pcm_close(substream); } |
1da177e4c Linux-2.6.12-rc2 |
1344 1345 |
/* via686 playback callbacks */ |
e437e3d7c [ALSA] Remove xxx... |
1346 |
static struct snd_pcm_ops snd_via686_playback_ops = { |
3d0094137 sound: via82xx: d... |
1347 |
.open = snd_via686_playback_open, |
1da177e4c Linux-2.6.12-rc2 |
1348 1349 1350 1351 1352 1353 1354 1355 1356 1357 1358 |
.close = snd_via82xx_pcm_close, .ioctl = snd_pcm_lib_ioctl, .hw_params = snd_via82xx_hw_params, .hw_free = snd_via82xx_hw_free, .prepare = snd_via686_playback_prepare, .trigger = snd_via82xx_pcm_trigger, .pointer = snd_via686_pcm_pointer, .page = snd_pcm_sgbuf_ops_page, }; /* via686 capture callbacks */ |
e437e3d7c [ALSA] Remove xxx... |
1359 |
static struct snd_pcm_ops snd_via686_capture_ops = { |
1da177e4c Linux-2.6.12-rc2 |
1360 1361 1362 1363 1364 1365 1366 1367 1368 1369 1370 1371 |
.open = snd_via82xx_capture_open, .close = snd_via82xx_pcm_close, .ioctl = snd_pcm_lib_ioctl, .hw_params = snd_via82xx_hw_params, .hw_free = snd_via82xx_hw_free, .prepare = snd_via686_capture_prepare, .trigger = snd_via82xx_pcm_trigger, .pointer = snd_via686_pcm_pointer, .page = snd_pcm_sgbuf_ops_page, }; /* via823x DSX playback callbacks */ |
e437e3d7c [ALSA] Remove xxx... |
1372 |
static struct snd_pcm_ops snd_via8233_playback_ops = { |
3d0094137 sound: via82xx: d... |
1373 1374 |
.open = snd_via8233_playback_open, .close = snd_via8233_playback_close, |
1da177e4c Linux-2.6.12-rc2 |
1375 1376 1377 1378 1379 1380 1381 1382 1383 1384 |
.ioctl = snd_pcm_lib_ioctl, .hw_params = snd_via82xx_hw_params, .hw_free = snd_via82xx_hw_free, .prepare = snd_via8233_playback_prepare, .trigger = snd_via82xx_pcm_trigger, .pointer = snd_via8233_pcm_pointer, .page = snd_pcm_sgbuf_ops_page, }; /* via823x multi-channel playback callbacks */ |
e437e3d7c [ALSA] Remove xxx... |
1385 |
static struct snd_pcm_ops snd_via8233_multi_ops = { |
1da177e4c Linux-2.6.12-rc2 |
1386 1387 1388 1389 1390 1391 1392 1393 1394 1395 1396 1397 |
.open = snd_via8233_multi_open, .close = snd_via82xx_pcm_close, .ioctl = snd_pcm_lib_ioctl, .hw_params = snd_via82xx_hw_params, .hw_free = snd_via82xx_hw_free, .prepare = snd_via8233_multi_prepare, .trigger = snd_via82xx_pcm_trigger, .pointer = snd_via8233_pcm_pointer, .page = snd_pcm_sgbuf_ops_page, }; /* via823x capture callbacks */ |
e437e3d7c [ALSA] Remove xxx... |
1398 |
static struct snd_pcm_ops snd_via8233_capture_ops = { |
1da177e4c Linux-2.6.12-rc2 |
1399 1400 1401 1402 1403 1404 1405 1406 1407 1408 |
.open = snd_via82xx_capture_open, .close = snd_via82xx_pcm_close, .ioctl = snd_pcm_lib_ioctl, .hw_params = snd_via82xx_hw_params, .hw_free = snd_via82xx_hw_free, .prepare = snd_via8233_capture_prepare, .trigger = snd_via82xx_pcm_trigger, .pointer = snd_via8233_pcm_pointer, .page = snd_pcm_sgbuf_ops_page, }; |
e437e3d7c [ALSA] Remove xxx... |
1409 1410 |
static void init_viadev(struct via82xx *chip, int idx, unsigned int reg_offset, int shadow_pos, int direction) |
1da177e4c Linux-2.6.12-rc2 |
1411 1412 |
{ chip->devs[idx].reg_offset = reg_offset; |
4f550df58 [ALSA] Reduce int... |
1413 |
chip->devs[idx].shadow_shift = shadow_pos * 4; |
1da177e4c Linux-2.6.12-rc2 |
1414 1415 1416 1417 1418 1419 1420 |
chip->devs[idx].direction = direction; chip->devs[idx].port = chip->port + reg_offset; } /* * create pcm instances for VIA8233, 8233C and 8235 (not 8233A) */ |
e437e3d7c [ALSA] Remove xxx... |
1421 |
static int __devinit snd_via8233_pcm_new(struct via82xx *chip) |
1da177e4c Linux-2.6.12-rc2 |
1422 |
{ |
e437e3d7c [ALSA] Remove xxx... |
1423 |
struct snd_pcm *pcm; |
1da177e4c Linux-2.6.12-rc2 |
1424 1425 1426 1427 1428 1429 1430 1431 1432 1433 1434 1435 1436 1437 1438 1439 1440 1441 1442 |
int i, err; chip->playback_devno = 0; /* x 4 */ chip->multi_devno = 4; /* x 1 */ chip->capture_devno = 5; /* x 2 */ chip->num_devs = 7; chip->intr_mask = 0x33033333; /* FLAG|EOL for rec0-1, mc, sdx0-3 */ /* PCM #0: 4 DSX playbacks and 1 capture */ err = snd_pcm_new(chip->card, chip->card->shortname, 0, 4, 1, &pcm); if (err < 0) return err; snd_pcm_set_ops(pcm, SNDRV_PCM_STREAM_PLAYBACK, &snd_via8233_playback_ops); snd_pcm_set_ops(pcm, SNDRV_PCM_STREAM_CAPTURE, &snd_via8233_capture_ops); pcm->private_data = chip; strcpy(pcm->name, chip->card->shortname); chip->pcms[0] = pcm; /* set up playbacks */ for (i = 0; i < 4; i++) |
4f550df58 [ALSA] Reduce int... |
1443 |
init_viadev(chip, i, 0x10 * i, i, 0); |
1da177e4c Linux-2.6.12-rc2 |
1444 |
/* capture */ |
4f550df58 [ALSA] Reduce int... |
1445 |
init_viadev(chip, chip->capture_devno, VIA_REG_CAPTURE_8233_STATUS, 6, 1); |
1da177e4c Linux-2.6.12-rc2 |
1446 |
|
a2e3961d0 ALSA: via82xx - i... |
1447 1448 |
snd_pcm_lib_preallocate_pages_for_all(pcm, SNDRV_DMA_TYPE_DEV_SG, snd_dma_pci_data(chip->pci), |
5503600a1 ALSA: via82xx - c... |
1449 |
64*1024, VIA_MAX_BUFSIZE); |
1da177e4c Linux-2.6.12-rc2 |
1450 1451 1452 1453 1454 1455 1456 1457 1458 1459 1460 |
/* PCM #1: multi-channel playback and 2nd capture */ err = snd_pcm_new(chip->card, chip->card->shortname, 1, 1, 1, &pcm); if (err < 0) return err; snd_pcm_set_ops(pcm, SNDRV_PCM_STREAM_PLAYBACK, &snd_via8233_multi_ops); snd_pcm_set_ops(pcm, SNDRV_PCM_STREAM_CAPTURE, &snd_via8233_capture_ops); pcm->private_data = chip; strcpy(pcm->name, chip->card->shortname); chip->pcms[1] = pcm; /* set up playback */ |
4f550df58 [ALSA] Reduce int... |
1461 |
init_viadev(chip, chip->multi_devno, VIA_REG_MULTPLAY_STATUS, 4, 0); |
1da177e4c Linux-2.6.12-rc2 |
1462 |
/* set up capture */ |
4f550df58 [ALSA] Reduce int... |
1463 |
init_viadev(chip, chip->capture_devno + 1, VIA_REG_CAPTURE_8233_STATUS + 0x10, 7, 1); |
1da177e4c Linux-2.6.12-rc2 |
1464 |
|
a2e3961d0 ALSA: via82xx - i... |
1465 1466 |
snd_pcm_lib_preallocate_pages_for_all(pcm, SNDRV_DMA_TYPE_DEV_SG, snd_dma_pci_data(chip->pci), |
5503600a1 ALSA: via82xx - c... |
1467 |
64*1024, VIA_MAX_BUFSIZE); |
1da177e4c Linux-2.6.12-rc2 |
1468 1469 1470 1471 1472 1473 |
return 0; } /* * create pcm instances for VIA8233A */ |
e437e3d7c [ALSA] Remove xxx... |
1474 |
static int __devinit snd_via8233a_pcm_new(struct via82xx *chip) |
1da177e4c Linux-2.6.12-rc2 |
1475 |
{ |
e437e3d7c [ALSA] Remove xxx... |
1476 |
struct snd_pcm *pcm; |
1da177e4c Linux-2.6.12-rc2 |
1477 1478 1479 1480 1481 1482 1483 1484 1485 1486 1487 1488 1489 1490 1491 1492 1493 1494 |
int err; chip->multi_devno = 0; chip->playback_devno = 1; chip->capture_devno = 2; chip->num_devs = 3; chip->intr_mask = 0x03033000; /* FLAG|EOL for rec0, mc, sdx3 */ /* PCM #0: multi-channel playback and capture */ err = snd_pcm_new(chip->card, chip->card->shortname, 0, 1, 1, &pcm); if (err < 0) return err; snd_pcm_set_ops(pcm, SNDRV_PCM_STREAM_PLAYBACK, &snd_via8233_multi_ops); snd_pcm_set_ops(pcm, SNDRV_PCM_STREAM_CAPTURE, &snd_via8233_capture_ops); pcm->private_data = chip; strcpy(pcm->name, chip->card->shortname); chip->pcms[0] = pcm; /* set up playback */ |
4f550df58 [ALSA] Reduce int... |
1495 |
init_viadev(chip, chip->multi_devno, VIA_REG_MULTPLAY_STATUS, 4, 0); |
1da177e4c Linux-2.6.12-rc2 |
1496 |
/* capture */ |
4f550df58 [ALSA] Reduce int... |
1497 |
init_viadev(chip, chip->capture_devno, VIA_REG_CAPTURE_8233_STATUS, 6, 1); |
1da177e4c Linux-2.6.12-rc2 |
1498 |
|
a2e3961d0 ALSA: via82xx - i... |
1499 1500 |
snd_pcm_lib_preallocate_pages_for_all(pcm, SNDRV_DMA_TYPE_DEV_SG, snd_dma_pci_data(chip->pci), |
5503600a1 ALSA: via82xx - c... |
1501 |
64*1024, VIA_MAX_BUFSIZE); |
1da177e4c Linux-2.6.12-rc2 |
1502 1503 1504 1505 1506 1507 1508 1509 1510 1511 1512 1513 1514 1515 |
/* SPDIF supported? */ if (! ac97_can_spdif(chip->ac97)) return 0; /* PCM #1: DXS3 playback (for spdif) */ err = snd_pcm_new(chip->card, chip->card->shortname, 1, 1, 0, &pcm); if (err < 0) return err; snd_pcm_set_ops(pcm, SNDRV_PCM_STREAM_PLAYBACK, &snd_via8233_playback_ops); pcm->private_data = chip; strcpy(pcm->name, chip->card->shortname); chip->pcms[1] = pcm; /* set up playback */ |
4f550df58 [ALSA] Reduce int... |
1516 |
init_viadev(chip, chip->playback_devno, 0x30, 3, 0); |
1da177e4c Linux-2.6.12-rc2 |
1517 |
|
a2e3961d0 ALSA: via82xx - i... |
1518 1519 |
snd_pcm_lib_preallocate_pages_for_all(pcm, SNDRV_DMA_TYPE_DEV_SG, snd_dma_pci_data(chip->pci), |
5503600a1 ALSA: via82xx - c... |
1520 |
64*1024, VIA_MAX_BUFSIZE); |
1da177e4c Linux-2.6.12-rc2 |
1521 1522 1523 1524 1525 1526 |
return 0; } /* * create a pcm instance for via686a/b */ |
e437e3d7c [ALSA] Remove xxx... |
1527 |
static int __devinit snd_via686_pcm_new(struct via82xx *chip) |
1da177e4c Linux-2.6.12-rc2 |
1528 |
{ |
e437e3d7c [ALSA] Remove xxx... |
1529 |
struct snd_pcm *pcm; |
1da177e4c Linux-2.6.12-rc2 |
1530 1531 1532 1533 1534 1535 1536 1537 1538 1539 1540 1541 1542 1543 1544 |
int err; chip->playback_devno = 0; chip->capture_devno = 1; chip->num_devs = 2; chip->intr_mask = 0x77; /* FLAG | EOL for PB, CP, FM */ err = snd_pcm_new(chip->card, chip->card->shortname, 0, 1, 1, &pcm); if (err < 0) return err; snd_pcm_set_ops(pcm, SNDRV_PCM_STREAM_PLAYBACK, &snd_via686_playback_ops); snd_pcm_set_ops(pcm, SNDRV_PCM_STREAM_CAPTURE, &snd_via686_capture_ops); pcm->private_data = chip; strcpy(pcm->name, chip->card->shortname); chip->pcms[0] = pcm; |
4f550df58 [ALSA] Reduce int... |
1545 1546 |
init_viadev(chip, 0, VIA_REG_PLAYBACK_STATUS, 0, 0); init_viadev(chip, 1, VIA_REG_CAPTURE_STATUS, 0, 1); |
1da177e4c Linux-2.6.12-rc2 |
1547 |
|
a2e3961d0 ALSA: via82xx - i... |
1548 1549 |
snd_pcm_lib_preallocate_pages_for_all(pcm, SNDRV_DMA_TYPE_DEV_SG, snd_dma_pci_data(chip->pci), |
5503600a1 ALSA: via82xx - c... |
1550 |
64*1024, VIA_MAX_BUFSIZE); |
1da177e4c Linux-2.6.12-rc2 |
1551 1552 1553 1554 1555 1556 1557 |
return 0; } /* * Mixer part */ |
e437e3d7c [ALSA] Remove xxx... |
1558 1559 |
static int snd_via8233_capture_source_info(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_info *uinfo) |
1da177e4c Linux-2.6.12-rc2 |
1560 1561 1562 1563 1564 1565 1566 1567 1568 1569 1570 1571 1572 1573 1574 |
{ /* formerly they were "Line" and "Mic", but it looks like that they * have nothing to do with the actual physical connections... */ static char *texts[2] = { "Input1", "Input2" }; uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED; uinfo->count = 1; uinfo->value.enumerated.items = 2; if (uinfo->value.enumerated.item >= 2) uinfo->value.enumerated.item = 1; strcpy(uinfo->value.enumerated.name, texts[uinfo->value.enumerated.item]); return 0; } |
e437e3d7c [ALSA] Remove xxx... |
1575 1576 |
static int snd_via8233_capture_source_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) |
1da177e4c Linux-2.6.12-rc2 |
1577 |
{ |
e437e3d7c [ALSA] Remove xxx... |
1578 |
struct via82xx *chip = snd_kcontrol_chip(kcontrol); |
1da177e4c Linux-2.6.12-rc2 |
1579 1580 1581 1582 |
unsigned long port = chip->port + (kcontrol->id.index ? (VIA_REG_CAPTURE_CHANNEL + 0x10) : VIA_REG_CAPTURE_CHANNEL); ucontrol->value.enumerated.item[0] = inb(port) & VIA_REG_CAPTURE_CHANNEL_MIC ? 1 : 0; return 0; } |
e437e3d7c [ALSA] Remove xxx... |
1583 1584 |
static int snd_via8233_capture_source_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) |
1da177e4c Linux-2.6.12-rc2 |
1585 |
{ |
e437e3d7c [ALSA] Remove xxx... |
1586 |
struct via82xx *chip = snd_kcontrol_chip(kcontrol); |
1da177e4c Linux-2.6.12-rc2 |
1587 1588 1589 1590 1591 1592 1593 1594 1595 1596 1597 1598 1599 |
unsigned long port = chip->port + (kcontrol->id.index ? (VIA_REG_CAPTURE_CHANNEL + 0x10) : VIA_REG_CAPTURE_CHANNEL); u8 val, oval; spin_lock_irq(&chip->reg_lock); oval = inb(port); val = oval & ~VIA_REG_CAPTURE_CHANNEL_MIC; if (ucontrol->value.enumerated.item[0]) val |= VIA_REG_CAPTURE_CHANNEL_MIC; if (val != oval) outb(val, port); spin_unlock_irq(&chip->reg_lock); return val != oval; } |
e437e3d7c [ALSA] Remove xxx... |
1600 |
static struct snd_kcontrol_new snd_via8233_capture_source __devinitdata = { |
1da177e4c Linux-2.6.12-rc2 |
1601 1602 1603 1604 1605 1606 |
.name = "Input Source Select", .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .info = snd_via8233_capture_source_info, .get = snd_via8233_capture_source_get, .put = snd_via8233_capture_source_put, }; |
a5ce88909 [ALSA] Clean up w... |
1607 |
#define snd_via8233_dxs3_spdif_info snd_ctl_boolean_mono_info |
1da177e4c Linux-2.6.12-rc2 |
1608 |
|
e437e3d7c [ALSA] Remove xxx... |
1609 1610 |
static int snd_via8233_dxs3_spdif_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) |
1da177e4c Linux-2.6.12-rc2 |
1611 |
{ |
e437e3d7c [ALSA] Remove xxx... |
1612 |
struct via82xx *chip = snd_kcontrol_chip(kcontrol); |
1da177e4c Linux-2.6.12-rc2 |
1613 1614 1615 1616 1617 1618 |
u8 val; pci_read_config_byte(chip->pci, VIA8233_SPDIF_CTRL, &val); ucontrol->value.integer.value[0] = (val & VIA8233_SPDIF_DX3) ? 1 : 0; return 0; } |
e437e3d7c [ALSA] Remove xxx... |
1619 1620 |
static int snd_via8233_dxs3_spdif_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) |
1da177e4c Linux-2.6.12-rc2 |
1621 |
{ |
e437e3d7c [ALSA] Remove xxx... |
1622 |
struct via82xx *chip = snd_kcontrol_chip(kcontrol); |
1da177e4c Linux-2.6.12-rc2 |
1623 1624 1625 1626 1627 1628 1629 1630 1631 1632 1633 1634 1635 1636 |
u8 val, oval; pci_read_config_byte(chip->pci, VIA8233_SPDIF_CTRL, &oval); val = oval & ~VIA8233_SPDIF_DX3; if (ucontrol->value.integer.value[0]) val |= VIA8233_SPDIF_DX3; /* save the spdif flag for rate filtering */ chip->spdif_on = ucontrol->value.integer.value[0] ? 1 : 0; if (val != oval) { pci_write_config_byte(chip->pci, VIA8233_SPDIF_CTRL, val); return 1; } return 0; } |
e437e3d7c [ALSA] Remove xxx... |
1637 |
static struct snd_kcontrol_new snd_via8233_dxs3_spdif_control __devinitdata = { |
10e8d78a9 [ALSA] use SNDRV_... |
1638 |
.name = SNDRV_CTL_NAME_IEC958("Output ",NONE,SWITCH), |
1da177e4c Linux-2.6.12-rc2 |
1639 1640 1641 1642 1643 |
.iface = SNDRV_CTL_ELEM_IFACE_MIXER, .info = snd_via8233_dxs3_spdif_info, .get = snd_via8233_dxs3_spdif_get, .put = snd_via8233_dxs3_spdif_put, }; |
e437e3d7c [ALSA] Remove xxx... |
1644 1645 |
static int snd_via8233_dxs_volume_info(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_info *uinfo) |
1da177e4c Linux-2.6.12-rc2 |
1646 1647 1648 1649 1650 1651 1652 |
{ uinfo->type = SNDRV_CTL_ELEM_TYPE_INTEGER; uinfo->count = 2; uinfo->value.integer.min = 0; uinfo->value.integer.max = VIA_DXS_MAX_VOLUME; return 0; } |
e437e3d7c [ALSA] Remove xxx... |
1653 1654 |
static int snd_via8233_dxs_volume_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) |
1da177e4c Linux-2.6.12-rc2 |
1655 |
{ |
e437e3d7c [ALSA] Remove xxx... |
1656 |
struct via82xx *chip = snd_kcontrol_chip(kcontrol); |
2fb930b53 sound: via82xx: m... |
1657 |
unsigned int idx = kcontrol->id.subdevice; |
00f226d40 [ALSA] Enable DXS... |
1658 1659 1660 1661 1662 |
ucontrol->value.integer.value[0] = VIA_DXS_MAX_VOLUME - chip->playback_volume[idx][0]; ucontrol->value.integer.value[1] = VIA_DXS_MAX_VOLUME - chip->playback_volume[idx][1]; return 0; } |
e437e3d7c [ALSA] Remove xxx... |
1663 1664 |
static int snd_via8233_pcmdxs_volume_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) |
00f226d40 [ALSA] Enable DXS... |
1665 |
{ |
e437e3d7c [ALSA] Remove xxx... |
1666 |
struct via82xx *chip = snd_kcontrol_chip(kcontrol); |
00f226d40 [ALSA] Enable DXS... |
1667 1668 |
ucontrol->value.integer.value[0] = VIA_DXS_MAX_VOLUME - chip->playback_volume_c[0]; ucontrol->value.integer.value[1] = VIA_DXS_MAX_VOLUME - chip->playback_volume_c[1]; |
1da177e4c Linux-2.6.12-rc2 |
1669 1670 |
return 0; } |
e437e3d7c [ALSA] Remove xxx... |
1671 1672 |
static int snd_via8233_dxs_volume_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) |
1da177e4c Linux-2.6.12-rc2 |
1673 |
{ |
e437e3d7c [ALSA] Remove xxx... |
1674 |
struct via82xx *chip = snd_kcontrol_chip(kcontrol); |
2fb930b53 sound: via82xx: m... |
1675 |
unsigned int idx = kcontrol->id.subdevice; |
00f226d40 [ALSA] Enable DXS... |
1676 1677 1678 1679 1680 1681 1682 1683 1684 1685 1686 1687 1688 1689 1690 1691 1692 |
unsigned long port = chip->port + 0x10 * idx; unsigned char val; int i, change = 0; for (i = 0; i < 2; i++) { val = ucontrol->value.integer.value[i]; if (val > VIA_DXS_MAX_VOLUME) val = VIA_DXS_MAX_VOLUME; val = VIA_DXS_MAX_VOLUME - val; change |= val != chip->playback_volume[idx][i]; if (change) { chip->playback_volume[idx][i] = val; outb(val, port + VIA_REG_OFS_PLAYBACK_VOLUME_L + i); } } return change; } |
e437e3d7c [ALSA] Remove xxx... |
1693 1694 |
static int snd_via8233_pcmdxs_volume_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) |
00f226d40 [ALSA] Enable DXS... |
1695 |
{ |
e437e3d7c [ALSA] Remove xxx... |
1696 |
struct via82xx *chip = snd_kcontrol_chip(kcontrol); |
1da177e4c Linux-2.6.12-rc2 |
1697 1698 1699 1700 1701 1702 1703 1704 1705 |
unsigned int idx; unsigned char val; int i, change = 0; for (i = 0; i < 2; i++) { val = ucontrol->value.integer.value[i]; if (val > VIA_DXS_MAX_VOLUME) val = VIA_DXS_MAX_VOLUME; val = VIA_DXS_MAX_VOLUME - val; |
00f226d40 [ALSA] Enable DXS... |
1706 |
if (val != chip->playback_volume_c[i]) { |
1da177e4c Linux-2.6.12-rc2 |
1707 |
change = 1; |
00f226d40 [ALSA] Enable DXS... |
1708 |
chip->playback_volume_c[i] = val; |
1da177e4c Linux-2.6.12-rc2 |
1709 1710 |
for (idx = 0; idx < 4; idx++) { unsigned long port = chip->port + 0x10 * idx; |
00f226d40 [ALSA] Enable DXS... |
1711 |
chip->playback_volume[idx][i] = val; |
1da177e4c Linux-2.6.12-rc2 |
1712 1713 1714 1715 1716 1717 |
outb(val, port + VIA_REG_OFS_PLAYBACK_VOLUME_L + i); } } } return change; } |
b452e08e7 sound: via82xx: f... |
1718 |
static const DECLARE_TLV_DB_SCALE(db_scale_dxs, -4650, 150, 1); |
7058c0420 [ALSA] Added TLV ... |
1719 |
|
e437e3d7c [ALSA] Remove xxx... |
1720 |
static struct snd_kcontrol_new snd_via8233_pcmdxs_volume_control __devinitdata = { |
1da177e4c Linux-2.6.12-rc2 |
1721 1722 |
.name = "PCM Playback Volume", .iface = SNDRV_CTL_ELEM_IFACE_MIXER, |
7058c0420 [ALSA] Added TLV ... |
1723 1724 |
.access = (SNDRV_CTL_ELEM_ACCESS_READWRITE | SNDRV_CTL_ELEM_ACCESS_TLV_READ), |
1da177e4c Linux-2.6.12-rc2 |
1725 |
.info = snd_via8233_dxs_volume_info, |
00f226d40 [ALSA] Enable DXS... |
1726 1727 |
.get = snd_via8233_pcmdxs_volume_get, .put = snd_via8233_pcmdxs_volume_put, |
7058c0420 [ALSA] Added TLV ... |
1728 |
.tlv = { .p = db_scale_dxs } |
00f226d40 [ALSA] Enable DXS... |
1729 |
}; |
e437e3d7c [ALSA] Remove xxx... |
1730 |
static struct snd_kcontrol_new snd_via8233_dxs_volume_control __devinitdata = { |
2fb930b53 sound: via82xx: m... |
1731 1732 1733 1734 |
.iface = SNDRV_CTL_ELEM_IFACE_PCM, .device = 0, /* .subdevice set later */ .name = "PCM Playback Volume", |
3d0094137 sound: via82xx: d... |
1735 1736 1737 |
.access = SNDRV_CTL_ELEM_ACCESS_READWRITE | SNDRV_CTL_ELEM_ACCESS_TLV_READ | SNDRV_CTL_ELEM_ACCESS_INACTIVE, |
00f226d40 [ALSA] Enable DXS... |
1738 |
.info = snd_via8233_dxs_volume_info, |
1da177e4c Linux-2.6.12-rc2 |
1739 1740 |
.get = snd_via8233_dxs_volume_get, .put = snd_via8233_dxs_volume_put, |
7058c0420 [ALSA] Added TLV ... |
1741 |
.tlv = { .p = db_scale_dxs } |
1da177e4c Linux-2.6.12-rc2 |
1742 1743 1744 1745 |
}; /* */ |
e437e3d7c [ALSA] Remove xxx... |
1746 |
static void snd_via82xx_mixer_free_ac97_bus(struct snd_ac97_bus *bus) |
1da177e4c Linux-2.6.12-rc2 |
1747 |
{ |
e437e3d7c [ALSA] Remove xxx... |
1748 |
struct via82xx *chip = bus->private_data; |
1da177e4c Linux-2.6.12-rc2 |
1749 1750 |
chip->ac97_bus = NULL; } |
e437e3d7c [ALSA] Remove xxx... |
1751 |
static void snd_via82xx_mixer_free_ac97(struct snd_ac97 *ac97) |
1da177e4c Linux-2.6.12-rc2 |
1752 |
{ |
e437e3d7c [ALSA] Remove xxx... |
1753 |
struct via82xx *chip = ac97->private_data; |
1da177e4c Linux-2.6.12-rc2 |
1754 1755 1756 1757 1758 |
chip->ac97 = NULL; } static struct ac97_quirk ac97_quirks[] = { { |
69ad07cf9 [ALSA] AC97 - ren... |
1759 1760 |
.subvendor = 0x1106, .subdevice = 0x4161, |
1da177e4c Linux-2.6.12-rc2 |
1761 1762 1763 1764 1765 |
.codec_id = 0x56494161, /* VT1612A */ .name = "Soltek SL-75DRV5", .type = AC97_TUNE_NONE }, { /* FIXME: which codec? */ |
69ad07cf9 [ALSA] AC97 - ren... |
1766 1767 |
.subvendor = 0x1106, .subdevice = 0x4161, |
1da177e4c Linux-2.6.12-rc2 |
1768 1769 1770 1771 |
.name = "ASRock K7VT2", .type = AC97_TUNE_HP_ONLY }, { |
bf30a4309 ALSA: via82xx: ad... |
1772 1773 1774 1775 1776 1777 |
.subvendor = 0x110a, .subdevice = 0x0079, .name = "Fujitsu Siemens D1289", .type = AC97_TUNE_HP_ONLY }, { |
69ad07cf9 [ALSA] AC97 - ren... |
1778 1779 |
.subvendor = 0x1019, .subdevice = 0x0a81, |
1da177e4c Linux-2.6.12-rc2 |
1780 1781 1782 1783 |
.name = "ECS K7VTA3", .type = AC97_TUNE_HP_ONLY }, { |
69ad07cf9 [ALSA] AC97 - ren... |
1784 1785 |
.subvendor = 0x1019, .subdevice = 0x0a85, |
1da177e4c Linux-2.6.12-rc2 |
1786 1787 1788 1789 |
.name = "ECS L7VMM2", .type = AC97_TUNE_HP_ONLY }, { |
942fd1ebf ALSA: via82xx - A... |
1790 1791 1792 1793 1794 1795 |
.subvendor = 0x1019, .subdevice = 0x1841, .name = "ECS K7VTA3", .type = AC97_TUNE_HP_ONLY }, { |
69ad07cf9 [ALSA] AC97 - ren... |
1796 1797 |
.subvendor = 0x1849, .subdevice = 0x3059, |
1da177e4c Linux-2.6.12-rc2 |
1798 1799 1800 1801 |
.name = "ASRock K7VM2", .type = AC97_TUNE_HP_ONLY /* VT1616 */ }, { |
69ad07cf9 [ALSA] AC97 - ren... |
1802 1803 |
.subvendor = 0x14cd, .subdevice = 0x7002, |
1da177e4c Linux-2.6.12-rc2 |
1804 1805 1806 1807 |
.name = "Unknown", .type = AC97_TUNE_ALC_JACK }, { |
69ad07cf9 [ALSA] AC97 - ren... |
1808 1809 |
.subvendor = 0x1071, .subdevice = 0x8590, |
1da177e4c Linux-2.6.12-rc2 |
1810 1811 1812 1813 |
.name = "Mitac Mobo", .type = AC97_TUNE_ALC_JACK }, { |
69ad07cf9 [ALSA] AC97 - ren... |
1814 1815 |
.subvendor = 0x161f, .subdevice = 0x202b, |
1da177e4c Linux-2.6.12-rc2 |
1816 1817 1818 |
.name = "Arima Notebook", .type = AC97_TUNE_HP_ONLY, }, |
dac8dddd8 [ALSA] via82xx - ... |
1819 1820 1821 1822 1823 1824 |
{ .subvendor = 0x161f, .subdevice = 0x2032, .name = "Targa Traveller 811", .type = AC97_TUNE_HP_ONLY, }, |
d4199f017 [ALSA] Add hp_onl... |
1825 1826 1827 1828 1829 1830 |
{ .subvendor = 0x161f, .subdevice = 0x2032, .name = "m680x", .type = AC97_TUNE_HP_ONLY, /* http://launchpad.net/bugs/38546 */ }, |
9674513d6 [ALSA] via82xx - ... |
1831 1832 1833 1834 1835 1836 |
{ .subvendor = 0x1297, .subdevice = 0xa232, .name = "Shuttle AK32VN", .type = AC97_TUNE_HP_ONLY }, |
1da177e4c Linux-2.6.12-rc2 |
1837 1838 |
{ } /* terminator */ }; |
e437e3d7c [ALSA] Remove xxx... |
1839 |
static int __devinit snd_via82xx_mixer_new(struct via82xx *chip, const char *quirk_override) |
1da177e4c Linux-2.6.12-rc2 |
1840 |
{ |
e437e3d7c [ALSA] Remove xxx... |
1841 |
struct snd_ac97_template ac97; |
1da177e4c Linux-2.6.12-rc2 |
1842 |
int err; |
e437e3d7c [ALSA] Remove xxx... |
1843 |
static struct snd_ac97_bus_ops ops = { |
1da177e4c Linux-2.6.12-rc2 |
1844 1845 1846 1847 1848 1849 1850 1851 1852 |
.write = snd_via82xx_codec_write, .read = snd_via82xx_codec_read, .wait = snd_via82xx_codec_wait, }; if ((err = snd_ac97_bus(chip->card, 0, &ops, chip, &chip->ac97_bus)) < 0) return err; chip->ac97_bus->private_free = snd_via82xx_mixer_free_ac97_bus; chip->ac97_bus->clock = chip->ac97_clock; |
1da177e4c Linux-2.6.12-rc2 |
1853 1854 1855 1856 1857 |
memset(&ac97, 0, sizeof(ac97)); ac97.private_data = chip; ac97.private_free = snd_via82xx_mixer_free_ac97; ac97.pci = chip->pci; |
f1a63a38d [ALSA] ac97 - Sup... |
1858 |
ac97.scaps = AC97_SCAP_SKIP_MODEM | AC97_SCAP_POWER_SAVE; |
1da177e4c Linux-2.6.12-rc2 |
1859 1860 1861 1862 1863 1864 1865 1866 1867 1868 1869 1870 1871 1872 1873 |
if ((err = snd_ac97_mixer(chip->ac97_bus, &ac97, &chip->ac97)) < 0) return err; snd_ac97_tune_hardware(chip->ac97, ac97_quirks, quirk_override); if (chip->chip_type != TYPE_VIA686) { /* use slot 10/11 */ snd_ac97_update_bits(chip->ac97, AC97_EXTENDED_STATUS, 0x03 << 4, 0x03 << 4); } return 0; } #ifdef SUPPORT_JOYSTICK #define JOYSTICK_ADDR 0x200 |
e437e3d7c [ALSA] Remove xxx... |
1874 |
static int __devinit snd_via686_create_gameport(struct via82xx *chip, unsigned char *legacy) |
1da177e4c Linux-2.6.12-rc2 |
1875 1876 1877 |
{ struct gameport *gp; struct resource *r; |
b7fe46220 [ALSA] highlander... |
1878 |
if (!joystick) |
1da177e4c Linux-2.6.12-rc2 |
1879 1880 1881 1882 |
return -ENODEV; r = request_region(JOYSTICK_ADDR, 8, "VIA686 gameport"); if (!r) { |
e437e3d7c [ALSA] Remove xxx... |
1883 1884 1885 |
printk(KERN_WARNING "via82xx: cannot reserve joystick port 0x%#x ", JOYSTICK_ADDR); |
1da177e4c Linux-2.6.12-rc2 |
1886 1887 1888 1889 1890 1891 1892 |
return -EBUSY; } chip->gameport = gp = gameport_allocate_port(); if (!gp) { printk(KERN_ERR "via82xx: cannot allocate memory for gameport "); |
b1d5776d8 [ALSA] Remove vma... |
1893 |
release_and_free_resource(r); |
1da177e4c Linux-2.6.12-rc2 |
1894 1895 1896 1897 1898 1899 1900 1901 1902 1903 1904 1905 1906 1907 1908 1909 1910 |
return -ENOMEM; } gameport_set_name(gp, "VIA686 Gameport"); gameport_set_phys(gp, "pci%s/gameport0", pci_name(chip->pci)); gameport_set_dev_parent(gp, &chip->pci->dev); gp->io = JOYSTICK_ADDR; gameport_set_port_data(gp, r); /* Enable legacy joystick port */ *legacy |= VIA_FUNC_ENABLE_GAME; pci_write_config_byte(chip->pci, VIA_FUNC_ENABLE, *legacy); gameport_register_port(chip->gameport); return 0; } |
e437e3d7c [ALSA] Remove xxx... |
1911 |
static void snd_via686_free_gameport(struct via82xx *chip) |
1da177e4c Linux-2.6.12-rc2 |
1912 1913 1914 1915 1916 1917 |
{ if (chip->gameport) { struct resource *r = gameport_get_port_data(chip->gameport); gameport_unregister_port(chip->gameport); chip->gameport = NULL; |
b1d5776d8 [ALSA] Remove vma... |
1918 |
release_and_free_resource(r); |
1da177e4c Linux-2.6.12-rc2 |
1919 1920 1921 |
} } #else |
e437e3d7c [ALSA] Remove xxx... |
1922 |
static inline int snd_via686_create_gameport(struct via82xx *chip, unsigned char *legacy) |
1da177e4c Linux-2.6.12-rc2 |
1923 1924 1925 |
{ return -ENOSYS; } |
e437e3d7c [ALSA] Remove xxx... |
1926 |
static inline void snd_via686_free_gameport(struct via82xx *chip) { } |
1da177e4c Linux-2.6.12-rc2 |
1927 1928 1929 1930 1931 1932 |
#endif /* * */ |
e437e3d7c [ALSA] Remove xxx... |
1933 |
static int __devinit snd_via8233_init_misc(struct via82xx *chip) |
1da177e4c Linux-2.6.12-rc2 |
1934 1935 1936 1937 1938 1939 1940 1941 1942 1943 1944 1945 1946 1947 1948 1949 1950 1951 1952 1953 |
{ int i, err, caps; unsigned char val; caps = chip->chip_type == TYPE_VIA8233A ? 1 : 2; for (i = 0; i < caps; i++) { snd_via8233_capture_source.index = i; err = snd_ctl_add(chip->card, snd_ctl_new1(&snd_via8233_capture_source, chip)); if (err < 0) return err; } if (ac97_can_spdif(chip->ac97)) { err = snd_ctl_add(chip->card, snd_ctl_new1(&snd_via8233_dxs3_spdif_control, chip)); if (err < 0) return err; } if (chip->chip_type != TYPE_VIA8233A) { /* when no h/w PCM volume control is found, use DXS volume control * as the PCM vol control */ |
e437e3d7c [ALSA] Remove xxx... |
1954 |
struct snd_ctl_elem_id sid; |
1da177e4c Linux-2.6.12-rc2 |
1955 1956 1957 1958 |
memset(&sid, 0, sizeof(sid)); strcpy(sid.name, "PCM Playback Volume"); sid.iface = SNDRV_CTL_ELEM_IFACE_MIXER; if (! snd_ctl_find_id(chip->card, &sid)) { |
00f226d40 [ALSA] Enable DXS... |
1959 1960 1961 1962 1963 1964 1965 1966 |
snd_printd(KERN_INFO "Using DXS as PCM Playback "); err = snd_ctl_add(chip->card, snd_ctl_new1(&snd_via8233_pcmdxs_volume_control, chip)); if (err < 0) return err; } else /* Using DXS when PCM emulation is enabled is really weird */ { |
2fb930b53 sound: via82xx: m... |
1967 1968 1969 1970 1971 1972 1973 1974 1975 1976 1977 |
for (i = 0; i < 4; ++i) { struct snd_kcontrol *kctl; kctl = snd_ctl_new1( &snd_via8233_dxs_volume_control, chip); if (!kctl) return -ENOMEM; kctl->id.subdevice = i; err = snd_ctl_add(chip->card, kctl); if (err < 0) return err; |
3d0094137 sound: via82xx: d... |
1978 |
chip->dxs_controls[i] = kctl; |
2fb930b53 sound: via82xx: m... |
1979 |
} |
1da177e4c Linux-2.6.12-rc2 |
1980 1981 |
} } |
1da177e4c Linux-2.6.12-rc2 |
1982 1983 1984 1985 1986 1987 1988 1989 |
/* select spdif data slot 10/11 */ pci_read_config_byte(chip->pci, VIA8233_SPDIF_CTRL, &val); val = (val & ~VIA8233_SPDIF_SLOT_MASK) | VIA8233_SPDIF_SLOT_1011; val &= ~VIA8233_SPDIF_DX3; /* SPDIF off as default */ pci_write_config_byte(chip->pci, VIA8233_SPDIF_CTRL, val); return 0; } |
e437e3d7c [ALSA] Remove xxx... |
1990 |
static int __devinit snd_via686_init_misc(struct via82xx *chip) |
1da177e4c Linux-2.6.12-rc2 |
1991 1992 1993 1994 1995 1996 1997 1998 1999 2000 |
{ unsigned char legacy, legacy_cfg; int rev_h = 0; legacy = chip->old_legacy; legacy_cfg = chip->old_legacy_cfg; legacy |= VIA_FUNC_MIDI_IRQMASK; /* FIXME: correct? (disable MIDI) */ legacy &= ~VIA_FUNC_ENABLE_GAME; /* disable joystick */ if (chip->revision >= VIA_REV_686_H) { rev_h = 1; |
b7fe46220 [ALSA] highlander... |
2001 2002 2003 |
if (mpu_port >= 0x200) { /* force MIDI */ mpu_port &= 0xfffc; pci_write_config_dword(chip->pci, 0x18, mpu_port | 0x01); |
1da177e4c Linux-2.6.12-rc2 |
2004 |
#ifdef CONFIG_PM |
b7fe46220 [ALSA] highlander... |
2005 |
chip->mpu_port_saved = mpu_port; |
1da177e4c Linux-2.6.12-rc2 |
2006 2007 |
#endif } else { |
b7fe46220 [ALSA] highlander... |
2008 |
mpu_port = pci_resource_start(chip->pci, 2); |
1da177e4c Linux-2.6.12-rc2 |
2009 2010 |
} } else { |
b7fe46220 [ALSA] highlander... |
2011 |
switch (mpu_port) { /* force MIDI */ |
1da177e4c Linux-2.6.12-rc2 |
2012 2013 2014 2015 2016 |
case 0x300: case 0x310: case 0x320: case 0x330: legacy_cfg &= ~(3 << 2); |
b7fe46220 [ALSA] highlander... |
2017 |
legacy_cfg |= (mpu_port & 0x0030) >> 2; |
1da177e4c Linux-2.6.12-rc2 |
2018 2019 2020 |
break; default: /* no, use BIOS settings */ if (legacy & VIA_FUNC_ENABLE_MIDI) |
b7fe46220 [ALSA] highlander... |
2021 |
mpu_port = 0x300 + ((legacy_cfg & 0x000c) << 2); |
1da177e4c Linux-2.6.12-rc2 |
2022 2023 2024 |
break; } } |
b7fe46220 [ALSA] highlander... |
2025 2026 2027 |
if (mpu_port >= 0x200 && (chip->mpu_res = request_region(mpu_port, 2, "VIA82xx MPU401")) != NULL) { |
1da177e4c Linux-2.6.12-rc2 |
2028 2029 2030 2031 2032 2033 2034 |
if (rev_h) legacy |= VIA_FUNC_MIDI_PNP; /* enable PCI I/O 2 */ legacy |= VIA_FUNC_ENABLE_MIDI; } else { if (rev_h) legacy &= ~VIA_FUNC_MIDI_PNP; /* disable PCI I/O 2 */ legacy &= ~VIA_FUNC_ENABLE_MIDI; |
b7fe46220 [ALSA] highlander... |
2035 |
mpu_port = 0; |
1da177e4c Linux-2.6.12-rc2 |
2036 2037 2038 2039 2040 2041 |
} pci_write_config_byte(chip->pci, VIA_FUNC_ENABLE, legacy); pci_write_config_byte(chip->pci, VIA_PNP_CONTROL, legacy_cfg); if (chip->mpu_res) { if (snd_mpu401_uart_new(chip->card, 0, MPU401_HW_VIA686A, |
dba8b4699 ALSA: mpu401: cle... |
2042 2043 2044 |
mpu_port, MPU401_INFO_INTEGRATED | MPU401_INFO_IRQ_HOOK, -1, &chip->rmidi) < 0) { |
b7fe46220 [ALSA] highlander... |
2045 2046 2047 |
printk(KERN_WARNING "unable to initialize MPU-401" " at 0x%lx, skipping ", mpu_port); |
1da177e4c Linux-2.6.12-rc2 |
2048 2049 2050 2051 2052 2053 |
legacy &= ~VIA_FUNC_ENABLE_MIDI; } else { legacy &= ~VIA_FUNC_MIDI_IRQMASK; /* enable MIDI interrupt */ } pci_write_config_byte(chip->pci, VIA_FUNC_ENABLE, legacy); } |
b7fe46220 [ALSA] highlander... |
2054 |
snd_via686_create_gameport(chip, &legacy); |
1da177e4c Linux-2.6.12-rc2 |
2055 2056 2057 2058 2059 2060 2061 2062 2063 2064 2065 2066 2067 |
#ifdef CONFIG_PM chip->legacy_saved = legacy; chip->legacy_cfg_saved = legacy_cfg; #endif return 0; } /* * proc interface */ |
e437e3d7c [ALSA] Remove xxx... |
2068 2069 |
static void snd_via82xx_proc_read(struct snd_info_entry *entry, struct snd_info_buffer *buffer) |
1da177e4c Linux-2.6.12-rc2 |
2070 |
{ |
e437e3d7c [ALSA] Remove xxx... |
2071 |
struct via82xx *chip = entry->private_data; |
1da177e4c Linux-2.6.12-rc2 |
2072 2073 2074 2075 2076 2077 2078 2079 2080 2081 |
int i; snd_iprintf(buffer, "%s ", chip->card->longname); for (i = 0; i < 0xa0; i += 4) { snd_iprintf(buffer, "%02x: %08x ", i, inl(chip->port + i)); } } |
e437e3d7c [ALSA] Remove xxx... |
2082 |
static void __devinit snd_via82xx_proc_init(struct via82xx *chip) |
1da177e4c Linux-2.6.12-rc2 |
2083 |
{ |
e437e3d7c [ALSA] Remove xxx... |
2084 |
struct snd_info_entry *entry; |
1da177e4c Linux-2.6.12-rc2 |
2085 2086 |
if (! snd_card_proc_new(chip->card, "via82xx", &entry)) |
bf850204a [ALSA] Remove unn... |
2087 |
snd_info_set_text_ops(entry, chip, snd_via82xx_proc_read); |
1da177e4c Linux-2.6.12-rc2 |
2088 2089 2090 2091 2092 |
} /* * */ |
e437e3d7c [ALSA] Remove xxx... |
2093 |
static int snd_via82xx_chip_init(struct via82xx *chip) |
1da177e4c Linux-2.6.12-rc2 |
2094 2095 |
{ unsigned int val; |
ef21ca24f [ALSA] sound/pci:... |
2096 |
unsigned long end_time; |
1da177e4c Linux-2.6.12-rc2 |
2097 2098 2099 2100 2101 2102 2103 2104 2105 2106 2107 2108 2109 2110 2111 2112 2113 2114 2115 2116 2117 2118 2119 2120 2121 2122 2123 2124 2125 2126 2127 2128 2129 2130 2131 2132 2133 2134 2135 2136 2137 |
unsigned char pval; #if 0 /* broken on K7M? */ if (chip->chip_type == TYPE_VIA686) /* disable all legacy ports */ pci_write_config_byte(chip->pci, VIA_FUNC_ENABLE, 0); #endif pci_read_config_byte(chip->pci, VIA_ACLINK_STAT, &pval); if (! (pval & VIA_ACLINK_C00_READY)) { /* codec not ready? */ /* deassert ACLink reset, force SYNC */ pci_write_config_byte(chip->pci, VIA_ACLINK_CTRL, VIA_ACLINK_CTRL_ENABLE | VIA_ACLINK_CTRL_RESET | VIA_ACLINK_CTRL_SYNC); udelay(100); #if 1 /* FIXME: should we do full reset here for all chip models? */ pci_write_config_byte(chip->pci, VIA_ACLINK_CTRL, 0x00); udelay(100); #else /* deassert ACLink reset, force SYNC (warm AC'97 reset) */ pci_write_config_byte(chip->pci, VIA_ACLINK_CTRL, VIA_ACLINK_CTRL_RESET|VIA_ACLINK_CTRL_SYNC); udelay(2); #endif /* ACLink on, deassert ACLink reset, VSR, SGD data out */ /* note - FM data out has trouble with non VRA codecs !! */ pci_write_config_byte(chip->pci, VIA_ACLINK_CTRL, VIA_ACLINK_CTRL_INIT); udelay(100); } /* Make sure VRA is enabled, in case we didn't do a * complete codec reset, above */ pci_read_config_byte(chip->pci, VIA_ACLINK_CTRL, &pval); if ((pval & VIA_ACLINK_CTRL_INIT) != VIA_ACLINK_CTRL_INIT) { /* ACLink on, deassert ACLink reset, VSR, SGD data out */ /* note - FM data out has trouble with non VRA codecs !! */ pci_write_config_byte(chip->pci, VIA_ACLINK_CTRL, VIA_ACLINK_CTRL_INIT); udelay(100); } /* wait until codec ready */ |
ef21ca24f [ALSA] sound/pci:... |
2138 |
end_time = jiffies + msecs_to_jiffies(750); |
1da177e4c Linux-2.6.12-rc2 |
2139 2140 2141 2142 |
do { pci_read_config_byte(chip->pci, VIA_ACLINK_STAT, &pval); if (pval & VIA_ACLINK_C00_READY) /* primary codec ready */ break; |
d86d01935 [ALSA] alsa-kerne... |
2143 |
schedule_timeout_uninterruptible(1); |
ef21ca24f [ALSA] sound/pci:... |
2144 |
} while (time_before(jiffies, end_time)); |
1da177e4c Linux-2.6.12-rc2 |
2145 2146 |
if ((val = snd_via82xx_codec_xread(chip)) & VIA_REG_AC97_BUSY) |
99b359ba1 [ALSA] Add missin... |
2147 2148 |
snd_printk(KERN_ERR "AC'97 codec is not ready [0x%x] ", val); |
1da177e4c Linux-2.6.12-rc2 |
2149 2150 2151 2152 2153 |
#if 0 /* FIXME: we don't support the second codec yet so skip the detection now.. */ snd_via82xx_codec_xwrite(chip, VIA_REG_AC97_READ | VIA_REG_AC97_SECONDARY_VALID | (VIA_REG_AC97_CODEC_ID_SECONDARY << VIA_REG_AC97_CODEC_ID_SHIFT)); |
ef21ca24f [ALSA] sound/pci:... |
2154 |
end_time = jiffies + msecs_to_jiffies(750); |
1da177e4c Linux-2.6.12-rc2 |
2155 2156 2157 2158 2159 2160 2161 2162 |
snd_via82xx_codec_xwrite(chip, VIA_REG_AC97_READ | VIA_REG_AC97_SECONDARY_VALID | (VIA_REG_AC97_CODEC_ID_SECONDARY << VIA_REG_AC97_CODEC_ID_SHIFT)); do { if ((val = snd_via82xx_codec_xread(chip)) & VIA_REG_AC97_SECONDARY_VALID) { chip->ac97_secondary = 1; goto __ac97_ok2; } |
d86d01935 [ALSA] alsa-kerne... |
2163 |
schedule_timeout_uninterruptible(1); |
ef21ca24f [ALSA] sound/pci:... |
2164 |
} while (time_before(jiffies, end_time)); |
1da177e4c Linux-2.6.12-rc2 |
2165 2166 2167 2168 2169 2170 2171 2172 2173 2174 2175 2176 2177 2178 2179 2180 2181 |
/* This is ok, the most of motherboards have only one codec */ __ac97_ok2: #endif if (chip->chip_type == TYPE_VIA686) { /* route FM trap to IRQ, disable FM trap */ pci_write_config_byte(chip->pci, VIA_FM_NMI_CTRL, 0); /* disable all GPI interrupts */ outl(0, VIAREG(chip, GPI_INTR)); } if (chip->chip_type != TYPE_VIA686) { /* Workaround for Award BIOS bug: * DXS channels don't work properly with VRA if MC97 is disabled. */ struct pci_dev *pci; |
0dd119f70 [ALSA] pci_find_d... |
2182 |
pci = pci_get_device(0x1106, 0x3068, NULL); /* MC97 */ |
1da177e4c Linux-2.6.12-rc2 |
2183 2184 2185 2186 |
if (pci) { unsigned char data; pci_read_config_byte(pci, 0x44, &data); pci_write_config_byte(pci, 0x44, data | 0x40); |
0dd119f70 [ALSA] pci_find_d... |
2187 |
pci_dev_put(pci); |
1da177e4c Linux-2.6.12-rc2 |
2188 2189 2190 2191 2192 2193 2194 |
} } if (chip->chip_type != TYPE_VIA8233A) { int i, idx; for (idx = 0; idx < 4; idx++) { unsigned long port = chip->port + 0x10 * idx; |
00f226d40 [ALSA] Enable DXS... |
2195 2196 |
for (i = 0; i < 2; i++) { chip->playback_volume[idx][i]=chip->playback_volume_c[i]; |
e437e3d7c [ALSA] Remove xxx... |
2197 2198 |
outb(chip->playback_volume_c[i], port + VIA_REG_OFS_PLAYBACK_VOLUME_L + i); |
00f226d40 [ALSA] Enable DXS... |
2199 |
} |
1da177e4c Linux-2.6.12-rc2 |
2200 2201 2202 2203 2204 2205 2206 2207 2208 2209 |
} } return 0; } #ifdef CONFIG_PM /* * power management */ |
57feb8350 [ALSA] via82xx - ... |
2210 |
static int snd_via82xx_suspend(struct pci_dev *pci, pm_message_t state) |
1da177e4c Linux-2.6.12-rc2 |
2211 |
{ |
57feb8350 [ALSA] via82xx - ... |
2212 2213 |
struct snd_card *card = pci_get_drvdata(pci); struct via82xx *chip = card->private_data; |
1da177e4c Linux-2.6.12-rc2 |
2214 |
int i; |
57feb8350 [ALSA] via82xx - ... |
2215 |
snd_power_change_state(card, SNDRV_CTL_POWER_D3hot); |
1da177e4c Linux-2.6.12-rc2 |
2216 |
for (i = 0; i < 2; i++) |
57feb8350 [ALSA] via82xx - ... |
2217 |
snd_pcm_suspend_all(chip->pcms[i]); |
1da177e4c Linux-2.6.12-rc2 |
2218 2219 2220 2221 2222 2223 2224 2225 2226 2227 2228 |
for (i = 0; i < chip->num_devs; i++) snd_via82xx_channel_reset(chip, &chip->devs[i]); synchronize_irq(chip->irq); snd_ac97_suspend(chip->ac97); /* save misc values */ if (chip->chip_type != TYPE_VIA686) { pci_read_config_byte(chip->pci, VIA8233_SPDIF_CTRL, &chip->spdif_ctrl_saved); chip->capture_src_saved[0] = inb(chip->port + VIA_REG_CAPTURE_CHANNEL); chip->capture_src_saved[1] = inb(chip->port + VIA_REG_CAPTURE_CHANNEL + 0x10); } |
57feb8350 [ALSA] via82xx - ... |
2229 2230 |
pci_disable_device(pci); pci_save_state(pci); |
30b35399c [ALSA] Various fi... |
2231 |
pci_set_power_state(pci, pci_choose_state(pci, state)); |
1da177e4c Linux-2.6.12-rc2 |
2232 2233 |
return 0; } |
57feb8350 [ALSA] via82xx - ... |
2234 |
static int snd_via82xx_resume(struct pci_dev *pci) |
1da177e4c Linux-2.6.12-rc2 |
2235 |
{ |
57feb8350 [ALSA] via82xx - ... |
2236 2237 |
struct snd_card *card = pci_get_drvdata(pci); struct via82xx *chip = card->private_data; |
1da177e4c Linux-2.6.12-rc2 |
2238 |
int i; |
57feb8350 [ALSA] via82xx - ... |
2239 |
pci_set_power_state(pci, PCI_D0); |
30b35399c [ALSA] Various fi... |
2240 2241 2242 2243 2244 2245 2246 2247 2248 |
pci_restore_state(pci); if (pci_enable_device(pci) < 0) { printk(KERN_ERR "via82xx: pci_enable_device failed, " "disabling device "); snd_card_disconnect(card); return -EIO; } pci_set_master(pci); |
1da177e4c Linux-2.6.12-rc2 |
2249 2250 2251 2252 2253 2254 2255 2256 2257 2258 2259 2260 2261 2262 2263 2264 2265 2266 |
snd_via82xx_chip_init(chip); if (chip->chip_type == TYPE_VIA686) { if (chip->mpu_port_saved) pci_write_config_dword(chip->pci, 0x18, chip->mpu_port_saved | 0x01); pci_write_config_byte(chip->pci, VIA_FUNC_ENABLE, chip->legacy_saved); pci_write_config_byte(chip->pci, VIA_PNP_CONTROL, chip->legacy_cfg_saved); } else { pci_write_config_byte(chip->pci, VIA8233_SPDIF_CTRL, chip->spdif_ctrl_saved); outb(chip->capture_src_saved[0], chip->port + VIA_REG_CAPTURE_CHANNEL); outb(chip->capture_src_saved[1], chip->port + VIA_REG_CAPTURE_CHANNEL + 0x10); } snd_ac97_resume(chip->ac97); for (i = 0; i < chip->num_devs; i++) snd_via82xx_channel_reset(chip, &chip->devs[i]); |
57feb8350 [ALSA] via82xx - ... |
2267 |
snd_power_change_state(card, SNDRV_CTL_POWER_D0); |
1da177e4c Linux-2.6.12-rc2 |
2268 2269 2270 |
return 0; } #endif /* CONFIG_PM */ |
e437e3d7c [ALSA] Remove xxx... |
2271 |
static int snd_via82xx_free(struct via82xx *chip) |
1da177e4c Linux-2.6.12-rc2 |
2272 2273 2274 2275 2276 2277 2278 2279 |
{ unsigned int i; if (chip->irq < 0) goto __end_hw; /* disable interrupts */ for (i = 0; i < chip->num_devs; i++) snd_via82xx_channel_reset(chip, &chip->devs[i]); |
f000fd809 [ALSA] Fix synchr... |
2280 |
|
1da177e4c Linux-2.6.12-rc2 |
2281 |
if (chip->irq >= 0) |
e437e3d7c [ALSA] Remove xxx... |
2282 |
free_irq(chip->irq, chip); |
757d5a756 [ALSA] via82xx: m... |
2283 |
__end_hw: |
b1d5776d8 [ALSA] Remove vma... |
2284 |
release_and_free_resource(chip->mpu_res); |
1da177e4c Linux-2.6.12-rc2 |
2285 2286 2287 2288 2289 2290 2291 2292 2293 2294 2295 |
pci_release_regions(chip->pci); if (chip->chip_type == TYPE_VIA686) { snd_via686_free_gameport(chip); pci_write_config_byte(chip->pci, VIA_FUNC_ENABLE, chip->old_legacy); pci_write_config_byte(chip->pci, VIA_PNP_CONTROL, chip->old_legacy_cfg); } pci_disable_device(chip->pci); kfree(chip); return 0; } |
e437e3d7c [ALSA] Remove xxx... |
2296 |
static int snd_via82xx_dev_free(struct snd_device *device) |
1da177e4c Linux-2.6.12-rc2 |
2297 |
{ |
e437e3d7c [ALSA] Remove xxx... |
2298 |
struct via82xx *chip = device->device_data; |
1da177e4c Linux-2.6.12-rc2 |
2299 2300 |
return snd_via82xx_free(chip); } |
e437e3d7c [ALSA] Remove xxx... |
2301 |
static int __devinit snd_via82xx_create(struct snd_card *card, |
1da177e4c Linux-2.6.12-rc2 |
2302 2303 2304 2305 |
struct pci_dev *pci, int chip_type, int revision, unsigned int ac97_clock, |
e437e3d7c [ALSA] Remove xxx... |
2306 |
struct via82xx ** r_via) |
1da177e4c Linux-2.6.12-rc2 |
2307 |
{ |
e437e3d7c [ALSA] Remove xxx... |
2308 |
struct via82xx *chip; |
1da177e4c Linux-2.6.12-rc2 |
2309 |
int err; |
e437e3d7c [ALSA] Remove xxx... |
2310 |
static struct snd_device_ops ops = { |
1da177e4c Linux-2.6.12-rc2 |
2311 2312 2313 2314 2315 |
.dev_free = snd_via82xx_dev_free, }; if ((err = pci_enable_device(pci)) < 0) return err; |
e560d8d83 [ALSA] Replace wi... |
2316 |
if ((chip = kzalloc(sizeof(*chip), GFP_KERNEL)) == NULL) { |
1da177e4c Linux-2.6.12-rc2 |
2317 2318 2319 2320 2321 2322 2323 2324 2325 2326 2327 2328 2329 2330 2331 2332 2333 2334 2335 2336 2337 2338 2339 2340 2341 |
pci_disable_device(pci); return -ENOMEM; } chip->chip_type = chip_type; chip->revision = revision; spin_lock_init(&chip->reg_lock); spin_lock_init(&chip->rates[0].lock); spin_lock_init(&chip->rates[1].lock); chip->card = card; chip->pci = pci; chip->irq = -1; pci_read_config_byte(pci, VIA_FUNC_ENABLE, &chip->old_legacy); pci_read_config_byte(pci, VIA_PNP_CONTROL, &chip->old_legacy_cfg); pci_write_config_byte(chip->pci, VIA_FUNC_ENABLE, chip->old_legacy & ~(VIA_FUNC_ENABLE_SB|VIA_FUNC_ENABLE_FM)); if ((err = pci_request_regions(pci, card->driver)) < 0) { kfree(chip); pci_disable_device(pci); return err; } chip->port = pci_resource_start(pci, 0); |
4f550df58 [ALSA] Reduce int... |
2342 2343 2344 |
if (request_irq(pci->irq, chip_type == TYPE_VIA8233 ? snd_via8233_interrupt : snd_via686_interrupt, |
437a5a460 [ALSA] Remove IRQ... |
2345 |
IRQF_SHARED, |
934c2b6d0 ALSA: use KBUILD_... |
2346 |
KBUILD_MODNAME, chip)) { |
99b359ba1 [ALSA] Add missin... |
2347 2348 |
snd_printk(KERN_ERR "unable to grab IRQ %d ", pci->irq); |
1da177e4c Linux-2.6.12-rc2 |
2349 2350 2351 2352 2353 2354 2355 2356 2357 2358 2359 2360 2361 2362 2363 2364 2365 2366 2367 2368 2369 2370 2371 2372 2373 2374 2375 2376 2377 2378 2379 2380 2381 2382 2383 2384 2385 2386 2387 2388 2389 |
snd_via82xx_free(chip); return -EBUSY; } chip->irq = pci->irq; if (ac97_clock >= 8000 && ac97_clock <= 48000) chip->ac97_clock = ac97_clock; synchronize_irq(chip->irq); if ((err = snd_via82xx_chip_init(chip)) < 0) { snd_via82xx_free(chip); return err; } if ((err = snd_device_new(card, SNDRV_DEV_LOWLEVEL, chip, &ops)) < 0) { snd_via82xx_free(chip); return err; } /* The 8233 ac97 controller does not implement the master bit * in the pci command register. IMHO this is a violation of the PCI spec. * We call pci_set_master here because it does not hurt. */ pci_set_master(pci); snd_card_set_dev(card, &pci->dev); *r_via = chip; return 0; } struct via823x_info { int revision; char *name; int type; }; static struct via823x_info via823x_cards[] __devinitdata = { { VIA_REV_PRE_8233, "VIA 8233-Pre", TYPE_VIA8233 }, { VIA_REV_8233C, "VIA 8233C", TYPE_VIA8233 }, { VIA_REV_8233, "VIA 8233", TYPE_VIA8233 }, { VIA_REV_8233A, "VIA 8233A", TYPE_VIA8233A }, { VIA_REV_8235, "VIA 8235", TYPE_VIA8233 }, { VIA_REV_8237, "VIA 8237", TYPE_VIA8233 }, |
8263c65fb [ALSA] via82xx: a... |
2390 |
{ VIA_REV_8251, "VIA 8251", TYPE_VIA8233 }, |
1da177e4c Linux-2.6.12-rc2 |
2391 2392 2393 2394 2395 |
}; /* * auto detection of DXS channel supports. */ |
9d74958a8 [ALSA] via82xx - ... |
2396 2397 2398 2399 2400 2401 |
static struct snd_pci_quirk dxs_whitelist[] __devinitdata = { SND_PCI_QUIRK(0x1005, 0x4710, "Avance Logic Mobo", VIA_DXS_ENABLE), SND_PCI_QUIRK(0x1019, 0x0996, "ESC Mobo", VIA_DXS_48K), SND_PCI_QUIRK(0x1019, 0x0a81, "ECS K7VTA3 v8.0", VIA_DXS_NO_VRA), SND_PCI_QUIRK(0x1019, 0x0a85, "ECS L7VMM2", VIA_DXS_NO_VRA), |
a85165c66 ALSA: via82xx - C... |
2402 |
SND_PCI_QUIRK_VENDOR(0x1019, "ESC K8", VIA_DXS_SRC), |
9d74958a8 [ALSA] via82xx - ... |
2403 2404 2405 |
SND_PCI_QUIRK(0x1019, 0xaa01, "ESC K8T890-A", VIA_DXS_SRC), SND_PCI_QUIRK(0x1025, 0x0033, "Acer Inspire 1353LM", VIA_DXS_NO_VRA), SND_PCI_QUIRK(0x1025, 0x0046, "Acer Aspire 1524 WLMi", VIA_DXS_SRC), |
a85165c66 ALSA: via82xx - C... |
2406 2407 |
SND_PCI_QUIRK_VENDOR(0x1043, "ASUS A7/A8", VIA_DXS_NO_VRA), SND_PCI_QUIRK_VENDOR(0x1071, "Diverse Notebook", VIA_DXS_NO_VRA), |
9d74958a8 [ALSA] via82xx - ... |
2408 |
SND_PCI_QUIRK(0x10cf, 0x118e, "FSC Laptop", VIA_DXS_ENABLE), |
a85165c66 ALSA: via82xx - C... |
2409 |
SND_PCI_QUIRK_VENDOR(0x1106, "ASRock", VIA_DXS_SRC), |
11be265f7 [ALSA] via82xx - ... |
2410 |
SND_PCI_QUIRK(0x1297, 0xa231, "Shuttle AK31v2", VIA_DXS_SRC), |
9674513d6 [ALSA] via82xx - ... |
2411 2412 |
SND_PCI_QUIRK(0x1297, 0xa232, "Shuttle", VIA_DXS_SRC), SND_PCI_QUIRK(0x1297, 0xc160, "Shuttle Sk41G", VIA_DXS_SRC), |
9d74958a8 [ALSA] via82xx - ... |
2413 2414 2415 2416 |
SND_PCI_QUIRK(0x1458, 0xa002, "Gigabyte GA-7VAXP", VIA_DXS_ENABLE), SND_PCI_QUIRK(0x1462, 0x3800, "MSI KT266", VIA_DXS_ENABLE), SND_PCI_QUIRK(0x1462, 0x7120, "MSI KT4V", VIA_DXS_ENABLE), SND_PCI_QUIRK(0x1462, 0x7142, "MSI K8MM-V", VIA_DXS_ENABLE), |
a85165c66 ALSA: via82xx - C... |
2417 |
SND_PCI_QUIRK_VENDOR(0x1462, "MSI Mobo", VIA_DXS_SRC), |
9d74958a8 [ALSA] via82xx - ... |
2418 2419 2420 2421 2422 2423 2424 2425 2426 2427 2428 2429 2430 |
SND_PCI_QUIRK(0x147b, 0x1401, "ABIT KD7(-RAID)", VIA_DXS_ENABLE), SND_PCI_QUIRK(0x147b, 0x1411, "ABIT VA-20", VIA_DXS_ENABLE), SND_PCI_QUIRK(0x147b, 0x1413, "ABIT KV8 Pro", VIA_DXS_ENABLE), SND_PCI_QUIRK(0x147b, 0x1415, "ABIT AV8", VIA_DXS_NO_VRA), SND_PCI_QUIRK(0x14ff, 0x0403, "Twinhead mobo", VIA_DXS_ENABLE), SND_PCI_QUIRK(0x14ff, 0x0408, "Twinhead laptop", VIA_DXS_SRC), SND_PCI_QUIRK(0x1558, 0x4701, "Clevo D470", VIA_DXS_SRC), SND_PCI_QUIRK(0x1584, 0x8120, "Diverse Laptop", VIA_DXS_ENABLE), SND_PCI_QUIRK(0x1584, 0x8123, "Targa/Uniwill", VIA_DXS_NO_VRA), SND_PCI_QUIRK(0x161f, 0x202b, "Amira Notebook", VIA_DXS_NO_VRA), SND_PCI_QUIRK(0x161f, 0x2032, "m680x machines", VIA_DXS_48K), SND_PCI_QUIRK(0x1631, 0xe004, "PB EasyNote 3174", VIA_DXS_ENABLE), SND_PCI_QUIRK(0x1695, 0x3005, "EPoX EP-8K9A", VIA_DXS_ENABLE), |
a85165c66 ALSA: via82xx - C... |
2431 2432 2433 |
SND_PCI_QUIRK_VENDOR(0x1695, "EPoX mobo", VIA_DXS_SRC), SND_PCI_QUIRK_VENDOR(0x16f3, "Jetway K8", VIA_DXS_SRC), SND_PCI_QUIRK_VENDOR(0x1734, "FSC Laptop", VIA_DXS_SRC), |
9d74958a8 [ALSA] via82xx - ... |
2434 |
SND_PCI_QUIRK(0x1849, 0x3059, "ASRock K7VM2", VIA_DXS_NO_VRA), |
a85165c66 ALSA: via82xx - C... |
2435 |
SND_PCI_QUIRK_VENDOR(0x1849, "ASRock mobo", VIA_DXS_SRC), |
9d74958a8 [ALSA] via82xx - ... |
2436 2437 2438 |
SND_PCI_QUIRK(0x1919, 0x200a, "Soltek SL-K8", VIA_DXS_NO_VRA), SND_PCI_QUIRK(0x4005, 0x4710, "MSI K7T266", VIA_DXS_SRC), { } /* terminator */ |
1da177e4c Linux-2.6.12-rc2 |
2439 |
}; |
a769577b3 [ALSA] via82xx - ... |
2440 |
static int __devinit check_dxs_list(struct pci_dev *pci, int revision) |
1da177e4c Linux-2.6.12-rc2 |
2441 |
{ |
9d74958a8 [ALSA] via82xx - ... |
2442 |
const struct snd_pci_quirk *w; |
1da177e4c Linux-2.6.12-rc2 |
2443 |
|
9d74958a8 [ALSA] via82xx - ... |
2444 2445 2446 2447 2448 2449 |
w = snd_pci_quirk_lookup(pci, dxs_whitelist); if (w) { snd_printdd(KERN_INFO "via82xx: DXS white list for %s found ", w->name); return w->value; |
1da177e4c Linux-2.6.12-rc2 |
2450 |
} |
a769577b3 [ALSA] via82xx - ... |
2451 2452 2453 |
/* for newer revision, default to DXS_SRC */ if (revision >= VIA_REV_8235) return VIA_DXS_SRC; |
1da177e4c Linux-2.6.12-rc2 |
2454 2455 2456 2457 2458 |
/* * not detected, try 48k rate only to be sure. */ printk(KERN_INFO "via82xx: Assuming DXS channels with 48k fixed sample rate. "); |
ee3b4c60f [ALSA] via82xx - ... |
2459 2460 |
printk(KERN_INFO " Please try dxs_support=5 option "); |
1da177e4c Linux-2.6.12-rc2 |
2461 2462 |
printk(KERN_INFO " and report if it works on your machine. "); |
ee3b4c60f [ALSA] via82xx - ... |
2463 2464 |
printk(KERN_INFO " For more details, read ALSA-Configuration.txt. "); |
1da177e4c Linux-2.6.12-rc2 |
2465 2466 2467 2468 2469 2470 |
return VIA_DXS_48K; }; static int __devinit snd_via82xx_probe(struct pci_dev *pci, const struct pci_device_id *pci_id) { |
e437e3d7c [ALSA] Remove xxx... |
2471 2472 |
struct snd_card *card; struct via82xx *chip; |
1da177e4c Linux-2.6.12-rc2 |
2473 2474 2475 |
int chip_type = 0, card_type; unsigned int i; int err; |
e58de7baf ALSA: Convert to ... |
2476 2477 2478 |
err = snd_card_create(index, id, THIS_MODULE, 0, &card); if (err < 0) return err; |
1da177e4c Linux-2.6.12-rc2 |
2479 2480 |
card_type = pci_id->driver_data; |
1da177e4c Linux-2.6.12-rc2 |
2481 2482 2483 |
switch (card_type) { case TYPE_CARD_VIA686: strcpy(card->driver, "VIA686A"); |
44c10138f PCI: Change all d... |
2484 |
sprintf(card->shortname, "VIA 82C686A/B rev%x", pci->revision); |
1da177e4c Linux-2.6.12-rc2 |
2485 2486 2487 2488 |
chip_type = TYPE_VIA686; break; case TYPE_CARD_VIA8233: chip_type = TYPE_VIA8233; |
44c10138f PCI: Change all d... |
2489 |
sprintf(card->shortname, "VIA 823x rev%x", pci->revision); |
1da177e4c Linux-2.6.12-rc2 |
2490 |
for (i = 0; i < ARRAY_SIZE(via823x_cards); i++) { |
44c10138f PCI: Change all d... |
2491 |
if (pci->revision == via823x_cards[i].revision) { |
1da177e4c Linux-2.6.12-rc2 |
2492 2493 2494 2495 2496 2497 |
chip_type = via823x_cards[i].type; strcpy(card->shortname, via823x_cards[i].name); break; } } if (chip_type != TYPE_VIA8233A) { |
b7fe46220 [ALSA] highlander... |
2498 |
if (dxs_support == VIA_DXS_AUTO) |
44c10138f PCI: Change all d... |
2499 |
dxs_support = check_dxs_list(pci, pci->revision); |
1da177e4c Linux-2.6.12-rc2 |
2500 2501 2502 |
/* force to use VIA8233 or 8233A model according to * dxs_support module option */ |
b7fe46220 [ALSA] highlander... |
2503 |
if (dxs_support == VIA_DXS_DISABLE) |
1da177e4c Linux-2.6.12-rc2 |
2504 2505 2506 2507 2508 2509 |
chip_type = TYPE_VIA8233A; else chip_type = TYPE_VIA8233; } if (chip_type == TYPE_VIA8233A) strcpy(card->driver, "VIA8233A"); |
44c10138f PCI: Change all d... |
2510 |
else if (pci->revision >= VIA_REV_8237) |
1da177e4c Linux-2.6.12-rc2 |
2511 2512 2513 2514 2515 2516 2517 2518 2519 2520 2521 |
strcpy(card->driver, "VIA8237"); /* no slog assignment */ else strcpy(card->driver, "VIA8233"); break; default: snd_printk(KERN_ERR "invalid card type %d ", card_type); err = -EINVAL; goto __error; } |
44c10138f PCI: Change all d... |
2522 |
if ((err = snd_via82xx_create(card, pci, chip_type, pci->revision, |
b7fe46220 [ALSA] highlander... |
2523 |
ac97_clock, &chip)) < 0) |
1da177e4c Linux-2.6.12-rc2 |
2524 |
goto __error; |
57feb8350 [ALSA] via82xx - ... |
2525 |
card->private_data = chip; |
b7fe46220 [ALSA] highlander... |
2526 |
if ((err = snd_via82xx_mixer_new(chip, ac97_quirk)) < 0) |
1da177e4c Linux-2.6.12-rc2 |
2527 2528 2529 2530 |
goto __error; if (chip_type == TYPE_VIA686) { if ((err = snd_via686_pcm_new(chip)) < 0 || |
b7fe46220 [ALSA] highlander... |
2531 |
(err = snd_via686_init_misc(chip)) < 0) |
1da177e4c Linux-2.6.12-rc2 |
2532 2533 2534 2535 2536 2537 2538 2539 2540 |
goto __error; } else { if (chip_type == TYPE_VIA8233A) { if ((err = snd_via8233a_pcm_new(chip)) < 0) goto __error; // chip->dxs_fixed = 1; /* FIXME: use 48k for DXS #3? */ } else { if ((err = snd_via8233_pcm_new(chip)) < 0) goto __error; |
b7fe46220 [ALSA] highlander... |
2541 |
if (dxs_support == VIA_DXS_48K) |
1da177e4c Linux-2.6.12-rc2 |
2542 |
chip->dxs_fixed = 1; |
b7fe46220 [ALSA] highlander... |
2543 |
else if (dxs_support == VIA_DXS_NO_VRA) |
1da177e4c Linux-2.6.12-rc2 |
2544 |
chip->no_vra = 1; |
b7fe46220 [ALSA] highlander... |
2545 |
else if (dxs_support == VIA_DXS_SRC) { |
2d7eb7cb2 [ALSA] Support al... |
2546 2547 2548 |
chip->no_vra = 1; chip->dxs_src = 1; } |
1da177e4c Linux-2.6.12-rc2 |
2549 |
} |
b7fe46220 [ALSA] highlander... |
2550 |
if ((err = snd_via8233_init_misc(chip)) < 0) |
1da177e4c Linux-2.6.12-rc2 |
2551 2552 |
goto __error; } |
1da177e4c Linux-2.6.12-rc2 |
2553 2554 2555 2556 2557 2558 2559 2560 2561 2562 2563 2564 2565 2566 2567 |
/* disable interrupts */ for (i = 0; i < chip->num_devs; i++) snd_via82xx_channel_reset(chip, &chip->devs[i]); snprintf(card->longname, sizeof(card->longname), "%s with %s at %#lx, irq %d", card->shortname, snd_ac97_get_short_name(chip->ac97), chip->port, chip->irq); snd_via82xx_proc_init(chip); if ((err = snd_card_register(card)) < 0) { snd_card_free(card); return err; } pci_set_drvdata(pci, card); |
1da177e4c Linux-2.6.12-rc2 |
2568 2569 2570 2571 2572 2573 2574 2575 2576 2577 2578 2579 2580 2581 |
return 0; __error: snd_card_free(card); return err; } static void __devexit snd_via82xx_remove(struct pci_dev *pci) { snd_card_free(pci_get_drvdata(pci)); pci_set_drvdata(pci, NULL); } static struct pci_driver driver = { |
3733e424c ALSA: Use KBUILD_... |
2582 |
.name = KBUILD_MODNAME, |
1da177e4c Linux-2.6.12-rc2 |
2583 2584 2585 |
.id_table = snd_via82xx_ids, .probe = snd_via82xx_probe, .remove = __devexit_p(snd_via82xx_remove), |
57feb8350 [ALSA] via82xx - ... |
2586 2587 2588 2589 |
#ifdef CONFIG_PM .suspend = snd_via82xx_suspend, .resume = snd_via82xx_resume, #endif |
1da177e4c Linux-2.6.12-rc2 |
2590 2591 2592 2593 |
}; static int __init alsa_card_via82xx_init(void) { |
01d25d460 [ALSA] Replace pc... |
2594 |
return pci_register_driver(&driver); |
1da177e4c Linux-2.6.12-rc2 |
2595 2596 2597 2598 2599 2600 2601 2602 2603 |
} static void __exit alsa_card_via82xx_exit(void) { pci_unregister_driver(&driver); } module_init(alsa_card_via82xx_init) module_exit(alsa_card_via82xx_exit) |