Changeset bde691c in mainline
- Timestamp:
- 2011-09-26T15:24:48Z (13 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- bf38143
- Parents:
- 050d4fa
- Location:
- uspace/drv/audio/sb16
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/drv/audio/sb16/mixer.c
r050d4fa rbde691c 89 89 }; 90 90 91 static void mixer_max_master_levels(sb_mixer_t *mixer)91 static void sb_mixer_max_master_levels(sb_mixer_t *mixer) 92 92 { 93 93 assert(mixer); 94 94 /* Set Master to maximum */ 95 if (! mixer_get_control_item_count(mixer))95 if (!sb_mixer_get_control_item_count(mixer)) 96 96 return; 97 97 unsigned levels = 0, channels = 0, current_level; 98 98 const char *name = NULL; 99 mixer_get_control_item_info(mixer, 0, &name, &channels, &levels);99 sb_mixer_get_control_item_info(mixer, 0, &name, &channels, &levels); 100 100 unsigned channel = 0; 101 101 for (;channel < channels; ++channel) { 102 102 current_level = 103 mixer_get_volume_level(mixer, 0, channel);103 sb_mixer_get_volume_level(mixer, 0, channel); 104 104 ddf_log_note("Setting %s channel %d to %d (%d).\n", 105 105 name, channel, levels - 1, current_level); 106 106 107 mixer_set_volume_level(mixer, 0, channel, levels - 1);107 sb_mixer_set_volume_level(mixer, 0, channel, levels - 1); 108 108 109 109 current_level = 110 mixer_get_volume_level(mixer, 0, channel);110 sb_mixer_get_volume_level(mixer, 0, channel); 111 111 ddf_log_note("%s channel %d set to %d.\n", 112 112 name, channel, current_level); … … 115 115 } 116 116 /*----------------------------------------------------------------------------*/ 117 const char * mixer_type_str(mixer_type_t type)117 const char * sb_mixer_type_str(sb_mixer_type_t type) 118 118 { 119 119 static const char * names[] = { … … 126 126 } 127 127 /*----------------------------------------------------------------------------*/ 128 int mixer_init(sb_mixer_t *mixer, sb16_regs_t *regs,mixer_type_t type)128 int sb_mixer_init(sb_mixer_t *mixer, sb16_regs_t *regs, sb_mixer_type_t type) 129 129 { 130 130 assert(mixer); … … 137 137 pio_write_8(®s->mixer_address, CT_MIXER_RESET_ADDRESS); 138 138 pio_write_8(®s->mixer_data, 1); 139 mixer_max_master_levels(mixer);139 sb_mixer_max_master_levels(mixer); 140 140 } 141 141 return EOK; 142 142 } 143 143 /*----------------------------------------------------------------------------*/ 144 int mixer_get_control_item_count(const sb_mixer_t *mixer)144 int sb_mixer_get_control_item_count(const sb_mixer_t *mixer) 145 145 { 146 146 assert(mixer); … … 148 148 } 149 149 /*----------------------------------------------------------------------------*/ 150 int mixer_get_control_item_info(const sb_mixer_t *mixer, unsigned index,150 int sb_mixer_get_control_item_info(const sb_mixer_t *mixer, unsigned index, 151 151 const char** name, unsigned *channels, unsigned *levels) 152 152 { … … 164 164 } 165 165 /*----------------------------------------------------------------------------*/ 166 int mixer_set_volume_level(const sb_mixer_t *mixer,166 int sb_mixer_set_volume_level(const sb_mixer_t *mixer, 167 167 unsigned index, unsigned channel, unsigned level) 168 168 { … … 194 194 } 195 195 /*----------------------------------------------------------------------------*/ 196 unsigned mixer_get_volume_level(const sb_mixer_t *mixer, unsigned index,196 unsigned sb_mixer_get_volume_level(const sb_mixer_t *mixer, unsigned index, 197 197 unsigned channel) 198 198 { -
uspace/drv/audio/sb16/mixer.h
r050d4fa rbde691c 43 43 SB_MIXER_CT1745, 44 44 SB_MIXER_UNKNOWN, 45 } mixer_type_t;45 } sb_mixer_type_t; 46 46 47 47 typedef struct sb_mixer { 48 48 sb16_regs_t *regs; 49 mixer_type_t type;49 sb_mixer_type_t type; 50 50 } sb_mixer_t; 51 51 52 const char * mixer_type_str(mixer_type_t type);53 int mixer_init(sb_mixer_t *mixer, sb16_regs_t *regs,mixer_type_t type);54 int mixer_get_control_item_count(const sb_mixer_t *mixer);55 int mixer_get_control_item_info(const sb_mixer_t *mixer, unsigned index,52 const char * sb_mixer_type_str(sb_mixer_type_t type); 53 int sb_mixer_init(sb_mixer_t *mixer, sb16_regs_t *regs, sb_mixer_type_t type); 54 int sb_mixer_get_control_item_count(const sb_mixer_t *mixer); 55 int sb_mixer_get_control_item_info(const sb_mixer_t *mixer, unsigned index, 56 56 const char** name, unsigned *channels, unsigned *levels); 57 int mixer_set_volume_level(const sb_mixer_t *mixer,57 int sb_mixer_set_volume_level(const sb_mixer_t *mixer, 58 58 unsigned item, unsigned channel, unsigned level); 59 unsigned mixer_get_volume_level(const sb_mixer_t *mixer,59 unsigned sb_mixer_get_volume_level(const sb_mixer_t *mixer, 60 60 unsigned item, unsigned channel); 61 61 #endif -
uspace/drv/audio/sb16/sb16.c
r050d4fa rbde691c 41 41 { .cmdcount = 1, .cmds = (irq_cmd_t*)irq_cmds }; 42 42 43 static mixer_type_t mixer_type_by_dsp_version(unsigned major, unsigned minor) 43 static inline sb_mixer_type_t sb_mixer_type_by_dsp_version( 44 unsigned major, unsigned minor) 44 45 { 45 46 switch (major) … … 91 92 92 93 /* Initialize mixer */ 93 const mixer_type_t mixer_type =mixer_type_by_dsp_version(94 const sb_mixer_type_t mixer_type = sb_mixer_type_by_dsp_version( 94 95 drv->dsp_version.major, drv->dsp_version.minor); 95 96 96 ret = mixer_init(&drv->mixer, drv->regs, mixer_type);97 ret = sb_mixer_init(&drv->mixer, drv->regs, mixer_type); 97 98 if (ret != EOK) { 98 99 ddf_log_error("Failed to initialize SB mixer: %s.\n", … … 101 102 } 102 103 ddf_log_note("Initialized mixer: %s.\n", 103 mixer_type_str(drv->mixer.type));104 sb_mixer_type_str(drv->mixer.type)); 104 105 105 106 return EOK;
Note:
See TracChangeset
for help on using the changeset viewer.