Lines Matching refs:chip
44 int snd_sbdsp_command(struct snd_sb *chip, unsigned char val) in snd_sbdsp_command() argument
51 if ((inb(SBP(chip, STATUS)) & 0x80) == 0) { in snd_sbdsp_command()
52 outb(val, SBP(chip, COMMAND)); in snd_sbdsp_command()
55 snd_printd("%s [0x%lx]: timeout (0x%x)\n", __func__, chip->port, val); in snd_sbdsp_command()
59 int snd_sbdsp_get_byte(struct snd_sb *chip) in snd_sbdsp_get_byte() argument
64 if (inb(SBP(chip, DATA_AVAIL)) & 0x80) { in snd_sbdsp_get_byte()
65 val = inb(SBP(chip, READ)); in snd_sbdsp_get_byte()
72 snd_printd("%s [0x%lx]: timeout\n", __func__, chip->port); in snd_sbdsp_get_byte()
76 int snd_sbdsp_reset(struct snd_sb *chip) in snd_sbdsp_reset() argument
80 outb(1, SBP(chip, RESET)); in snd_sbdsp_reset()
82 outb(0, SBP(chip, RESET)); in snd_sbdsp_reset()
85 if (inb(SBP(chip, DATA_AVAIL)) & 0x80) { in snd_sbdsp_reset()
86 if (inb(SBP(chip, READ)) == 0xaa) in snd_sbdsp_reset()
91 snd_printdd("%s [0x%lx] failed...\n", __func__, chip->port); in snd_sbdsp_reset()
95 static int snd_sbdsp_version(struct snd_sb * chip) in snd_sbdsp_version() argument
99 snd_sbdsp_command(chip, SB_DSP_GET_VERSION); in snd_sbdsp_version()
100 result = (short) snd_sbdsp_get_byte(chip) << 8; in snd_sbdsp_version()
101 result |= (short) snd_sbdsp_get_byte(chip); in snd_sbdsp_version()
105 static int snd_sbdsp_probe(struct snd_sb * chip) in snd_sbdsp_probe() argument
116 spin_lock_irqsave(&chip->reg_lock, flags); in snd_sbdsp_probe()
117 if (snd_sbdsp_reset(chip) < 0) { in snd_sbdsp_probe()
118 spin_unlock_irqrestore(&chip->reg_lock, flags); in snd_sbdsp_probe()
121 version = snd_sbdsp_version(chip); in snd_sbdsp_probe()
123 spin_unlock_irqrestore(&chip->reg_lock, flags); in snd_sbdsp_probe()
126 spin_unlock_irqrestore(&chip->reg_lock, flags); in snd_sbdsp_probe()
130 chip->port, major, minor); in snd_sbdsp_probe()
132 switch (chip->hardware) { in snd_sbdsp_probe()
136 chip->hardware = SB_HW_10; in snd_sbdsp_probe()
141 chip->hardware = SB_HW_201; in snd_sbdsp_probe()
144 chip->hardware = SB_HW_20; in snd_sbdsp_probe()
149 chip->hardware = SB_HW_PRO; in snd_sbdsp_probe()
153 chip->hardware = SB_HW_16; in snd_sbdsp_probe()
158 chip->port, major, minor); in snd_sbdsp_probe()
180 sprintf(chip->name, "Sound Blaster %s", str); in snd_sbdsp_probe()
181 chip->version = (major << 8) | minor; in snd_sbdsp_probe()
185 static int snd_sbdsp_free(struct snd_sb *chip) in snd_sbdsp_free() argument
187 release_and_free_resource(chip->res_port); in snd_sbdsp_free()
188 if (chip->irq >= 0) in snd_sbdsp_free()
189 free_irq(chip->irq, (void *) chip); in snd_sbdsp_free()
191 if (chip->dma8 >= 0) { in snd_sbdsp_free()
192 disable_dma(chip->dma8); in snd_sbdsp_free()
193 free_dma(chip->dma8); in snd_sbdsp_free()
195 if (chip->dma16 >= 0 && chip->dma16 != chip->dma8) { in snd_sbdsp_free()
196 disable_dma(chip->dma16); in snd_sbdsp_free()
197 free_dma(chip->dma16); in snd_sbdsp_free()
200 kfree(chip); in snd_sbdsp_free()
206 struct snd_sb *chip = device->device_data; in snd_sbdsp_dev_free() local
207 return snd_sbdsp_free(chip); in snd_sbdsp_dev_free()
219 struct snd_sb *chip; in snd_sbdsp_create() local
228 chip = kzalloc(sizeof(*chip), GFP_KERNEL); in snd_sbdsp_create()
229 if (chip == NULL) in snd_sbdsp_create()
231 spin_lock_init(&chip->reg_lock); in snd_sbdsp_create()
232 spin_lock_init(&chip->open_lock); in snd_sbdsp_create()
233 spin_lock_init(&chip->midi_input_lock); in snd_sbdsp_create()
234 spin_lock_init(&chip->mixer_lock); in snd_sbdsp_create()
235 chip->irq = -1; in snd_sbdsp_create()
236 chip->dma8 = -1; in snd_sbdsp_create()
237 chip->dma16 = -1; in snd_sbdsp_create()
238 chip->port = port; in snd_sbdsp_create()
244 "SoundBlaster", (void *) chip)) { in snd_sbdsp_create()
246 snd_sbdsp_free(chip); in snd_sbdsp_create()
249 chip->irq = irq; in snd_sbdsp_create()
254 if ((chip->res_port = request_region(port, 16, "SoundBlaster")) == NULL) { in snd_sbdsp_create()
256 snd_sbdsp_free(chip); in snd_sbdsp_create()
263 snd_sbdsp_free(chip); in snd_sbdsp_create()
266 chip->dma8 = dma8; in snd_sbdsp_create()
273 snd_sbdsp_free(chip); in snd_sbdsp_create()
277 chip->dma16 = dma16; in snd_sbdsp_create()
281 chip->card = card; in snd_sbdsp_create()
282 chip->hardware = hardware; in snd_sbdsp_create()
283 if ((err = snd_sbdsp_probe(chip)) < 0) { in snd_sbdsp_create()
284 snd_sbdsp_free(chip); in snd_sbdsp_create()
287 if ((err = snd_device_new(card, SNDRV_DEV_LOWLEVEL, chip, &ops)) < 0) { in snd_sbdsp_create()
288 snd_sbdsp_free(chip); in snd_sbdsp_create()
291 *r_chip = chip; in snd_sbdsp_create()