Changeset 0687e1b in mainline
- Timestamp:
- 2011-09-25T18:36:35Z (13 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- 763444e
- Parents:
- 7a0a0f5
- Location:
- uspace/drv/audio/sb16
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/drv/audio/sb16/dsp.h
r7a0a0f5 r0687e1b 35 35 #ifndef DRV_AUDIO_SB16_DSP_H 36 36 #define DRV_AUDIO_SB16_DSP_H 37 38 #include <libarch/ddi.h> 37 39 38 40 #include "registers.h" -
uspace/drv/audio/sb16/mixer.c
r7a0a0f5 r0687e1b 27 27 */ 28 28 29 #include <bool.h> 29 30 #include <errno.h> 31 #include <libarch/ddi.h> 30 32 31 33 #include "mixer.h" 34 35 #define CT_MIXER_RESET_ADDRESS 0x00 36 37 typedef struct volume_item { 38 uint8_t address; 39 uint8_t channels; 40 const char *description; 41 unsigned min_value; 42 unsigned max_value; 43 unsigned shift; 44 bool same_reg; 45 } volume_item_t; 46 47 static const volume_item_t volume_ct1335[] = { 48 { 0x02, 1, "Master", 0, 7, 1, true }, 49 { 0x06, 1, "MIDI", 0, 7, 1, true }, 50 { 0x08, 1, "CD", 0, 7, 1, true }, 51 { 0x0a, 1, "Voice", 0, 3, 1, true }, 52 }; 53 54 static const volume_item_t volume_ct1345[] = { 55 { 0x04, 2, "Voice", 0, 7, 1, true }, 56 { 0x0a, 1, "Mic", 0, 3, 1, true }, 57 { 0x22, 2, "Master", 0, 7, 1, true }, 58 { 0x26, 2, "MIDI", 0, 7, 1, true }, 59 { 0x28, 2, "CD", 0, 7, 1, true }, 60 { 0x2e, 2, "Line", 0, 7, 1, true }, 61 }; 62 63 static const volume_item_t volume_ct1745[] = { 64 { 0x30, 2, "Master", 0, 31, 3, false }, 65 { 0x32, 2, "Voice", 0, 31, 3, false }, 66 { 0x34, 2, "MIDI", 0, 31, 3, false }, 67 { 0x36, 2, "CD", 0, 31, 3, false }, 68 { 0x38, 2, "Line", 0, 31, 3, false }, 69 { 0x3a, 1, "Mic", 0, 31, 3, false }, 70 { 0x3b, 1, "PC Speaker", 0, 3, 6, false }, 71 { 0x3f, 2, "Input Gain", 0, 3, 6, false }, 72 { 0x41, 2, "Output Gain", 0, 3, 6, false }, 73 { 0x44, 2, "Treble", 0, 15, 4, false }, 74 { 0x46, 2, "Bass", 0, 15, 4, false }, 75 }; 76 77 static const struct { 78 size_t count; 79 const volume_item_t *table; 80 } volume_table[] = { 81 [SB_MIXER_NONE] = { 0, NULL }, 82 [SB_MIXER_UNKNOWN] = { 0, NULL }, 83 [SB_MIXER_CT1335] = { 84 sizeof(volume_ct1335) / sizeof(volume_item_t), volume_ct1335 }, 85 [SB_MIXER_CT1345] = { 86 sizeof(volume_ct1345) / sizeof(volume_item_t), volume_ct1345 }, 87 [SB_MIXER_CT1745] = { 88 sizeof(volume_ct1745) / sizeof(volume_item_t), volume_ct1745 }, 89 }; 32 90 33 91 const char * mixer_type_to_str(mixer_type_t type) … … 44 102 int mixer_init(sb16_regs_t *regs, mixer_type_t type) 45 103 { 104 if (type == SB_MIXER_UNKNOWN) 105 return ENOTSUP; 106 107 if (type != SB_MIXER_NONE) { 108 pio_write_8(®s->mixer_address, CT_MIXER_RESET_ADDRESS); 109 pio_write_8(®s->mixer_data, 1); 110 } 46 111 return EOK; 47 112 } … … 49 114 void mixer_load_volume_levels(sb16_regs_t *regs, mixer_type_t type) 50 115 { 116 /* Default values are ok for now */ 51 117 } 52 118 /*----------------------------------------------------------------------------*/ 53 119 void mixer_store_volume_levels(sb16_regs_t *regs, mixer_type_t type) 54 120 { 121 /* Default values are ok for now */ 55 122 } 56 123 /*----------------------------------------------------------------------------*/ 57 int mixer_get_control_item_count( sb16_regs_t *regs,mixer_type_t type)124 int mixer_get_control_item_count(mixer_type_t type) 58 125 { 59 return 1;126 return volume_table[type].count; 60 127 } 61 128 /*----------------------------------------------------------------------------*/ 62 int mixer_get_control_item_info( sb16_regs_t *regs, mixer_type_t type,129 int mixer_get_control_item_info(mixer_type_t type, unsigned index, 63 130 const char** name, unsigned *channels) 64 131 { 65 return ENOTSUP; 132 if (index > volume_table[type].count) 133 return ENOENT; 134 135 if (name) 136 *name = volume_table[type].table[index].description; 137 if (channels) 138 *channels = volume_table[type].table[index].channels; 139 return EOK; 66 140 } 67 141 /*----------------------------------------------------------------------------*/ -
uspace/drv/audio/sb16/mixer.h
r7a0a0f5 r0687e1b 49 49 void mixer_load_volume_levels(sb16_regs_t *regs, mixer_type_t type); 50 50 void mixer_store_volume_levels(sb16_regs_t *regs, mixer_type_t type); 51 int mixer_get_control_item_count( sb16_regs_t *regs,mixer_type_t type);52 int mixer_get_control_item_info( sb16_regs_t *regs, mixer_type_t type,51 int mixer_get_control_item_count(mixer_type_t type); 52 int mixer_get_control_item_info(mixer_type_t type, unsigned index, 53 53 const char** name, unsigned *channels); 54 54 int mixer_set_volume_level(sb16_regs_t *regs, mixer_type_t type, -
uspace/drv/audio/sb16/sb16.c
r7a0a0f5 r0687e1b 29 29 #include <errno.h> 30 30 #include <str_error.h> 31 #include <libarch/ddi.h>32 31 33 32 #include "ddf_log.h"
Note:
See TracChangeset
for help on using the changeset viewer.