Takashi Iwai | d43f3010 | 2011-05-03 16:14:46 +0200 | [diff] [blame^] | 1 | /* |
| 2 | * Support for Digigram Lola PCI-e boards |
| 3 | * |
| 4 | * Copyright (c) 2011 Takashi Iwai <tiwai@suse.de> |
| 5 | * |
| 6 | * This program is free software; you can redistribute it and/or modify it |
| 7 | * under the terms of the GNU General Public License as published by the Free |
| 8 | * Software Foundation; either version 2 of the License, or (at your option) |
| 9 | * any later version. |
| 10 | * |
| 11 | * This program is distributed in the hope that it will be useful, but WITHOUT |
| 12 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
| 13 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for |
| 14 | * more details. |
| 15 | * |
| 16 | * You should have received a copy of the GNU General Public License along with |
| 17 | * this program; if not, write to the Free Software Foundation, Inc., 59 |
| 18 | * Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
| 19 | */ |
| 20 | |
| 21 | #include <linux/kernel.h> |
| 22 | #include <linux/init.h> |
| 23 | #include <linux/io.h> |
| 24 | #include <sound/core.h> |
| 25 | #include <sound/info.h> |
| 26 | #include <sound/pcm.h> |
| 27 | #include "lola.h" |
| 28 | |
| 29 | /* direct codec access for debugging */ |
| 30 | static void lola_proc_codec_write(struct snd_info_entry *entry, |
| 31 | struct snd_info_buffer *buffer) |
| 32 | { |
| 33 | struct lola *chip = entry->private_data; |
| 34 | char line[64]; |
| 35 | unsigned int id, verb, data, extdata; |
| 36 | while (!snd_info_get_line(buffer, line, sizeof(line))) { |
| 37 | if (sscanf(line, "%i %i %i %i", &id, &verb, &data, &extdata) != 4) |
| 38 | continue; |
| 39 | lola_codec_read(chip, id, verb, data, extdata, |
| 40 | &chip->debug_res, |
| 41 | &chip->debug_res_ex); |
| 42 | } |
| 43 | } |
| 44 | |
| 45 | static void lola_proc_codec_read(struct snd_info_entry *entry, |
| 46 | struct snd_info_buffer *buffer) |
| 47 | { |
| 48 | struct lola *chip = entry->private_data; |
| 49 | snd_iprintf(buffer, "0x%x 0x%x\n", chip->debug_res, chip->debug_res_ex); |
| 50 | } |
| 51 | |
| 52 | /* |
| 53 | * dump some registers |
| 54 | */ |
| 55 | static void lola_proc_regs_read(struct snd_info_entry *entry, |
| 56 | struct snd_info_buffer *buffer) |
| 57 | { |
| 58 | struct lola *chip = entry->private_data; |
| 59 | int i; |
| 60 | |
| 61 | for (i = 0; i < 0x40; i += 4) { |
| 62 | snd_iprintf(buffer, "BAR0 %02x: %08x\n", i, |
| 63 | readl(chip->bar[BAR0].remap_addr + i)); |
| 64 | } |
| 65 | for (i = 0; i < 0x30; i += 4) { |
| 66 | snd_iprintf(buffer, "BAR1 %02x: %08x\n", i, |
| 67 | readl(chip->bar[BAR1].remap_addr + i)); |
| 68 | } |
| 69 | for (i = 0x80; i < 0xa0; i += 4) { |
| 70 | snd_iprintf(buffer, "BAR1 %02x: %08x\n", i, |
| 71 | readl(chip->bar[BAR1].remap_addr + i)); |
| 72 | } |
| 73 | } |
| 74 | |
| 75 | void __devinit lola_proc_debug_new(struct lola *chip) |
| 76 | { |
| 77 | struct snd_info_entry *entry; |
| 78 | |
| 79 | if (!snd_card_proc_new(chip->card, "codec", &entry)) { |
| 80 | snd_info_set_text_ops(entry, chip, lola_proc_codec_read); |
| 81 | entry->mode |= S_IWUSR; |
| 82 | entry->c.text.write = lola_proc_codec_write; |
| 83 | } |
| 84 | if (!snd_card_proc_new(chip->card, "regs", &entry)) |
| 85 | snd_info_set_text_ops(entry, chip, lola_proc_regs_read); |
| 86 | } |