lola_proc.c 2.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586
  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. #include <linux/kernel.h>
  21. #include <linux/init.h>
  22. #include <linux/io.h>
  23. #include <sound/core.h>
  24. #include <sound/info.h>
  25. #include <sound/pcm.h>
  26. #include "lola.h"
  27. /* direct codec access for debugging */
  28. static void lola_proc_codec_write(struct snd_info_entry *entry,
  29. struct snd_info_buffer *buffer)
  30. {
  31. struct lola *chip = entry->private_data;
  32. char line[64];
  33. unsigned int id, verb, data, extdata;
  34. while (!snd_info_get_line(buffer, line, sizeof(line))) {
  35. if (sscanf(line, "%i %i %i %i", &id, &verb, &data, &extdata) != 4)
  36. continue;
  37. lola_codec_read(chip, id, verb, data, extdata,
  38. &chip->debug_res,
  39. &chip->debug_res_ex);
  40. }
  41. }
  42. static void lola_proc_codec_read(struct snd_info_entry *entry,
  43. struct snd_info_buffer *buffer)
  44. {
  45. struct lola *chip = entry->private_data;
  46. snd_iprintf(buffer, "0x%x 0x%x\n", chip->debug_res, chip->debug_res_ex);
  47. }
  48. /*
  49. * dump some registers
  50. */
  51. static void lola_proc_regs_read(struct snd_info_entry *entry,
  52. struct snd_info_buffer *buffer)
  53. {
  54. struct lola *chip = entry->private_data;
  55. int i;
  56. for (i = 0; i < 0x40; i += 4) {
  57. snd_iprintf(buffer, "BAR0 %02x: %08x\n", i,
  58. readl(chip->bar[BAR0].remap_addr + i));
  59. }
  60. for (i = 0; i < 0x30; i += 4) {
  61. snd_iprintf(buffer, "BAR1 %02x: %08x\n", i,
  62. readl(chip->bar[BAR1].remap_addr + i));
  63. }
  64. for (i = 0x80; i < 0xa0; i += 4) {
  65. snd_iprintf(buffer, "BAR1 %02x: %08x\n", i,
  66. readl(chip->bar[BAR1].remap_addr + i));
  67. }
  68. }
  69. void __devinit lola_proc_debug_new(struct lola *chip)
  70. {
  71. struct snd_info_entry *entry;
  72. if (!snd_card_proc_new(chip->card, "codec", &entry)) {
  73. snd_info_set_text_ops(entry, chip, lola_proc_codec_read);
  74. entry->mode |= S_IWUSR;
  75. entry->c.text.write = lola_proc_codec_write;
  76. }
  77. if (!snd_card_proc_new(chip->card, "regs", &entry))
  78. snd_info_set_text_ops(entry, chip, lola_proc_regs_read);
  79. }