Changeset 0687e1b in mainline


Ignore:
Timestamp:
2011-09-25T18:36:35Z (12 years ago)
Author:
Jan Vesely <jano.vesely@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
763444e
Parents:
7a0a0f5
Message:

sb16: Add mixer hw initialization and volume tables.

Location:
uspace/drv/audio/sb16
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • uspace/drv/audio/sb16/dsp.h

    r7a0a0f5 r0687e1b  
    3535#ifndef DRV_AUDIO_SB16_DSP_H
    3636#define DRV_AUDIO_SB16_DSP_H
     37
     38#include <libarch/ddi.h>
    3739
    3840#include "registers.h"
  • uspace/drv/audio/sb16/mixer.c

    r7a0a0f5 r0687e1b  
    2727 */
    2828
     29#include <bool.h>
    2930#include <errno.h>
     31#include <libarch/ddi.h>
    3032
    3133#include "mixer.h"
     34
     35#define CT_MIXER_RESET_ADDRESS 0x00
     36
     37typedef 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
     47static 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
     54static 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
     63static 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
     77static 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};
    3290
    3391const char * mixer_type_to_str(mixer_type_t type)
     
    44102int mixer_init(sb16_regs_t *regs, mixer_type_t type)
    45103{
     104        if (type == SB_MIXER_UNKNOWN)
     105                return ENOTSUP;
     106
     107        if (type != SB_MIXER_NONE) {
     108                pio_write_8(&regs->mixer_address, CT_MIXER_RESET_ADDRESS);
     109                pio_write_8(&regs->mixer_data, 1);
     110        }
    46111        return EOK;
    47112}
     
    49114void mixer_load_volume_levels(sb16_regs_t *regs, mixer_type_t type)
    50115{
     116        /* Default values are ok for now */
    51117}
    52118/*----------------------------------------------------------------------------*/
    53119void mixer_store_volume_levels(sb16_regs_t *regs, mixer_type_t type)
    54120{
     121        /* Default values are ok for now */
    55122}
    56123/*----------------------------------------------------------------------------*/
    57 int mixer_get_control_item_count(sb16_regs_t *regs, mixer_type_t type)
     124int mixer_get_control_item_count(mixer_type_t type)
    58125{
    59         return 1;
     126        return volume_table[type].count;
    60127}
    61128/*----------------------------------------------------------------------------*/
    62 int mixer_get_control_item_info(sb16_regs_t *regs, mixer_type_t type,
     129int mixer_get_control_item_info(mixer_type_t type, unsigned index,
    63130    const char** name, unsigned *channels)
    64131{
    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;
    66140}
    67141/*----------------------------------------------------------------------------*/
  • uspace/drv/audio/sb16/mixer.h

    r7a0a0f5 r0687e1b  
    4949void mixer_load_volume_levels(sb16_regs_t *regs, mixer_type_t type);
    5050void 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,
     51int mixer_get_control_item_count(mixer_type_t type);
     52int mixer_get_control_item_info(mixer_type_t type, unsigned index,
    5353    const char** name, unsigned *channels);
    5454int mixer_set_volume_level(sb16_regs_t *regs, mixer_type_t type,
  • uspace/drv/audio/sb16/sb16.c

    r7a0a0f5 r0687e1b  
    2929#include <errno.h>
    3030#include <str_error.h>
    31 #include <libarch/ddi.h>
    3231
    3332#include "ddf_log.h"
Note: See TracChangeset for help on using the changeset viewer.