Changeset 650

Show
Ignore:
Timestamp:
10/14/07 14:40:59 (15 years ago)
Author:
ppalmers
Message:

Implement the focusrite saffire pro internal mixers as two connected matrix mixers.
One for the input mix and one for the output mix.

Note: does not check for out-of-boundary yet

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/libffado/src/bebob/focusrite/focusrite_cmd.h

    r624 r650  
    4747#define FOCUSRITE_CMD_SAMPLERATE_176K4  5 
    4848#define FOCUSRITE_CMD_SAMPLERATE_192K   6 
     49 
     50#define FOCUSRITE_CMD_ID_AN1_TO_IMIXL        0 
     51#define FOCUSRITE_CMD_ID_AN1_TO_IMIXR        1 
     52#define FOCUSRITE_CMD_ID_AN2_TO_IMIXL        2 
     53#define FOCUSRITE_CMD_ID_AN2_TO_IMIXR        3 
     54#define FOCUSRITE_CMD_ID_AN3_TO_IMIXL        4 
     55#define FOCUSRITE_CMD_ID_AN3_TO_IMIXR        5 
     56#define FOCUSRITE_CMD_ID_AN4_TO_IMIXL        6 
     57#define FOCUSRITE_CMD_ID_AN4_TO_IMIXR        7 
     58#define FOCUSRITE_CMD_ID_AN5_TO_IMIXL        8 
     59#define FOCUSRITE_CMD_ID_AN5_TO_IMIXR        9 
     60#define FOCUSRITE_CMD_ID_AN6_TO_IMIXL       10 
     61#define FOCUSRITE_CMD_ID_AN6_TO_IMIXR       11 
     62#define FOCUSRITE_CMD_ID_AN7_TO_IMIXL       12 
     63#define FOCUSRITE_CMD_ID_AN7_TO_IMIXR       13 
     64#define FOCUSRITE_CMD_ID_AN8_TO_IMIXL       14 
     65#define FOCUSRITE_CMD_ID_AN8_TO_IMIXR       15 
     66#define FOCUSRITE_CMD_ID_SPDIFL_TO_IMIXL    16 
     67#define FOCUSRITE_CMD_ID_SPDIFL_TO_IMIXR    17 
     68#define FOCUSRITE_CMD_ID_SPDIFR_TO_IMIXL    18 
     69#define FOCUSRITE_CMD_ID_SPDIFR_TO_IMIXR    19 
     70 
     71#define FOCUSRITE_CMD_ID_ADAT11_TO_IMIXL    20 
     72#define FOCUSRITE_CMD_ID_ADAT11_TO_IMIXR    21 
     73#define FOCUSRITE_CMD_ID_ADAT12_TO_IMIXL    22 
     74#define FOCUSRITE_CMD_ID_ADAT12_TO_IMIXR    23 
     75#define FOCUSRITE_CMD_ID_ADAT13_TO_IMIXL    24 
     76#define FOCUSRITE_CMD_ID_ADAT13_TO_IMIXR    25 
     77#define FOCUSRITE_CMD_ID_ADAT14_TO_IMIXL    26 
     78#define FOCUSRITE_CMD_ID_ADAT14_TO_IMIXR    27 
     79#define FOCUSRITE_CMD_ID_ADAT15_TO_IMIXL    28 
     80#define FOCUSRITE_CMD_ID_ADAT15_TO_IMIXR    29 
     81#define FOCUSRITE_CMD_ID_ADAT16_TO_IMIXL    30 
     82#define FOCUSRITE_CMD_ID_ADAT16_TO_IMIXR    31 
     83#define FOCUSRITE_CMD_ID_ADAT17_TO_IMIXL    32 
     84#define FOCUSRITE_CMD_ID_ADAT17_TO_IMIXR    33 
     85#define FOCUSRITE_CMD_ID_ADAT18_TO_IMIXL    34 
     86#define FOCUSRITE_CMD_ID_ADAT18_TO_IMIXR    35 
     87 
     88#define FOCUSRITE_CMD_ID_ADAT21_TO_IMIXL    36 
     89#define FOCUSRITE_CMD_ID_ADAT21_TO_IMIXR    37 
     90#define FOCUSRITE_CMD_ID_ADAT22_TO_IMIXL    38 
     91#define FOCUSRITE_CMD_ID_ADAT22_TO_IMIXR    39 
     92#define FOCUSRITE_CMD_ID_ADAT23_TO_IMIXL    40 
     93#define FOCUSRITE_CMD_ID_ADAT23_TO_IMIXR    41 
     94#define FOCUSRITE_CMD_ID_ADAT24_TO_IMIXL    42 
     95#define FOCUSRITE_CMD_ID_ADAT24_TO_IMIXR    43 
     96#define FOCUSRITE_CMD_ID_ADAT25_TO_IMIXL    44 
     97#define FOCUSRITE_CMD_ID_ADAT25_TO_IMIXR    45 
     98#define FOCUSRITE_CMD_ID_ADAT26_TO_IMIXL    46 
     99#define FOCUSRITE_CMD_ID_ADAT26_TO_IMIXR    47 
     100#define FOCUSRITE_CMD_ID_ADAT27_TO_IMIXL    48 
     101#define FOCUSRITE_CMD_ID_ADAT27_TO_IMIXR    49 
     102#define FOCUSRITE_CMD_ID_ADAT28_TO_IMIXL    50 
     103#define FOCUSRITE_CMD_ID_ADAT28_TO_IMIXR    51 
    49104 
    50105#define FOCUSRITE_CMD_ID_PC1_TO_OUT1    52 
  • trunk/libffado/src/bebob/focusrite/focusrite_saffirepro.cpp

    r649 r650  
    6565    if (m_MidiTru) addElement(m_MidiTru); 
    6666 
    67     // output mix controls 
    68     //  OUT12 
    69     m_Output12[0] = new VolumeControl(*this, FOCUSRITE_CMD_ID_PC1_TO_OUT1, 
    70                 "PC1_OUT1", "PC1_OUT1", "Volume from PC Channel 1 to Output Channel 1"); 
    71     if (m_Output12[0]) addElement(m_Output12[0]); 
    72     m_Output12[1] = new VolumeControl(*this, FOCUSRITE_CMD_ID_PC2_TO_OUT2, 
    73                 "PC2_OUT2", "PC2_OUT2", "Volume from PC Channel 2 to Output Channel 2"); 
    74     if (m_Output12[1]) addElement(m_Output12[1]); 
    75     m_Output12[2] = new VolumeControl(*this, FOCUSRITE_CMD_ID_MIX1_TO_OUT1, 
    76                 "MIX_OUT1", "MIX_OUT1", "Volume from Input Mix Left to Output Channel 1"); 
    77     if (m_Output12[2]) addElement(m_Output12[2]); 
    78     m_Output12[3] = new VolumeControl(*this, FOCUSRITE_CMD_ID_MIX2_TO_OUT2, 
    79                 "MIX_OUT2", "MIX_OUT2", "Volume from Input Mix Right to Output Channel 2"); 
    80     if (m_Output12[3]) addElement(m_Output12[3]); 
    81  
    82     //  OUT34 
    83     m_Output34[0] = new VolumeControl(*this, FOCUSRITE_CMD_ID_PC1_TO_OUT3, 
    84                 "PC1_OUT3", "PC1_OUT3", "Volume from PC Channel 1 to Output Channel 3"); 
    85     if (m_Output34[0]) addElement(m_Output34[0]); 
    86     m_Output34[1] = new VolumeControl(*this, FOCUSRITE_CMD_ID_PC2_TO_OUT4, 
    87                 "PC2_OUT4", "PC2_OUT4", "Volume from PC Channel 2 to Output Channel 4"); 
    88     if (m_Output34[1]) addElement(m_Output34[1]); 
    89     m_Output34[2] = new VolumeControl(*this, FOCUSRITE_CMD_ID_PC3_TO_OUT3, 
    90                 "PC3_OUT3", "PC3_OUT3", "Volume from PC Channel 3 to Output Channel 3"); 
    91     if (m_Output34[2]) addElement(m_Output34[2]); 
    92     m_Output34[3] = new VolumeControl(*this, FOCUSRITE_CMD_ID_PC4_TO_OUT4, 
    93                 "PC4_OUT4", "PC4_OUT4", "Volume from PC Channel 4 to Output Channel 4"); 
    94     if (m_Output34[3]) addElement(m_Output34[3]); 
    95     m_Output34[4] = new VolumeControl(*this, FOCUSRITE_CMD_ID_MIX1_TO_OUT3, 
    96                 "MIX_OUT3", "MIX_OUT3", "Volume from Input Mix Left to Output Channel 3"); 
    97     if (m_Output34[4]) addElement(m_Output34[4]); 
    98     m_Output34[5] = new VolumeControl(*this, FOCUSRITE_CMD_ID_MIX2_TO_OUT4, 
    99                 "MIX_OUT4", "MIX_OUT4", "Volume from Input Mix Right to Output Channel 4"); 
    100     if (m_Output34[5]) addElement(m_Output34[5]); 
    101      
    102     //  OUT56 
    103     m_Output56[0] = new VolumeControl(*this, FOCUSRITE_CMD_ID_PC1_TO_OUT5, 
    104                 "PC1_OUT5", "PC1_OUT5", "Volume from PC Channel 1 to Output Channel 5"); 
    105     if (m_Output56[0]) addElement(m_Output56[0]); 
    106     m_Output56[1] = new VolumeControl(*this, FOCUSRITE_CMD_ID_PC2_TO_OUT6, 
    107                 "PC2_OUT6", "PC2_OUT6", "Volume from PC Channel 2 to Output Channel 6"); 
    108     if (m_Output56[1]) addElement(m_Output56[1]); 
    109     m_Output56[2] = new VolumeControl(*this, FOCUSRITE_CMD_ID_PC5_TO_OUT5, 
    110                 "PC5_OUT5", "PC5_OUT5", "Volume from PC Channel 5 to Output Channel 5"); 
    111     if (m_Output56[2]) addElement(m_Output56[2]); 
    112     m_Output56[3] = new VolumeControl(*this, FOCUSRITE_CMD_ID_PC6_TO_OUT6, 
    113                 "PC6_OUT6", "PC6_OUT6", "Volume from PC Channel 6 to Output Channel 6"); 
    114     if (m_Output56[3]) addElement(m_Output56[3]); 
    115     m_Output56[4] = new VolumeControl(*this, FOCUSRITE_CMD_ID_MIX1_TO_OUT5, 
    116                 "MIX_OUT5", "MIX_OUT5", "Volume from Input Mix Left to Output Channel 5"); 
    117     if (m_Output56[4]) addElement(m_Output56[4]); 
    118     m_Output56[5] = new VolumeControl(*this, FOCUSRITE_CMD_ID_MIX2_TO_OUT6, 
    119                 "MIX_OUT6", "MIX_OUT6", "Volume from Input Mix Right to Output Channel 6"); 
    120     if (m_Output56[5]) addElement(m_Output56[5]); 
    121  
    122     //  OUT78 
    123     m_Output78[0] = new VolumeControl(*this, FOCUSRITE_CMD_ID_PC1_TO_OUT7, 
    124                 "PC1_OUT7", "PC1_OUT7", "Volume from PC Channel 1 to Output Channel 7"); 
    125     if (m_Output78[0]) addElement(m_Output78[0]); 
    126     m_Output78[1] = new VolumeControl(*this, FOCUSRITE_CMD_ID_PC2_TO_OUT8, 
    127                 "PC2_OUT8", "PC2_OUT8", "Volume from PC Channel 2 to Output Channel 8"); 
    128     if (m_Output78[1]) addElement(m_Output78[1]); 
    129     m_Output78[2] = new VolumeControl(*this, FOCUSRITE_CMD_ID_PC7_TO_OUT7, 
    130                 "PC7_OUT7", "PC7_OUT7", "Volume from PC Channel 7 to Output Channel 7"); 
    131     if (m_Output78[2]) addElement(m_Output78[2]); 
    132     m_Output78[3] = new VolumeControl(*this, FOCUSRITE_CMD_ID_PC8_TO_OUT8, 
    133                 "PC8_OUT8", "PC8_OUT8", "Volume from PC Channel 8 to Output Channel 8"); 
    134     if (m_Output78[3]) addElement(m_Output78[3]); 
    135     m_Output78[4] = new VolumeControl(*this, FOCUSRITE_CMD_ID_MIX1_TO_OUT7, 
    136                 "MIX_OUT7", "MIX_OUT7", "Volume from Input Mix Left to Output Channel 7"); 
    137     if (m_Output78[4]) addElement(m_Output78[4]); 
    138     m_Output78[5] = new VolumeControl(*this, FOCUSRITE_CMD_ID_MIX2_TO_OUT8, 
    139                 "MIX_OUT8", "MIX_OUT8", "Volume from Input Mix Right to Output Channel 8"); 
    140     if (m_Output78[5]) addElement(m_Output78[5]); 
    141  
    142     //  OUT910 
    143     m_Output910[0] = new VolumeControl(*this, FOCUSRITE_CMD_ID_PC1_TO_OUT9, 
    144                 "PC1_OUT9", "PC1_OUT9", "Volume from PC Channel 1 to Output Channel 9"); 
    145     if (m_Output910[0]) addElement(m_Output910[0]); 
    146     m_Output910[1] = new VolumeControl(*this, FOCUSRITE_CMD_ID_PC2_TO_OUT10, 
    147                 "PC2_OUT10", "PC2_OUT10", "Volume from PC Channel 2 to Output Channel 10"); 
    148     if (m_Output910[1]) addElement(m_Output910[1]); 
    149     m_Output910[2] = new VolumeControl(*this, FOCUSRITE_CMD_ID_PC9_TO_OUT9, 
    150                 "PC9_OUT9", "PC9_OUT9", "Volume from PC Channel 9 to Output Channel 9"); 
    151     if (m_Output910[2]) addElement(m_Output910[2]); 
    152     m_Output910[3] = new VolumeControl(*this, FOCUSRITE_CMD_ID_PC10_TO_OUT10, 
    153                 "PC10_OUT10", "PC10_OUT10", "Volume from PC Channel 10 to Output Channel 10"); 
    154     if (m_Output910[3]) addElement(m_Output910[3]); 
    155     m_Output910[4] = new VolumeControl(*this, FOCUSRITE_CMD_ID_MIX1_TO_OUT9, 
    156                 "MIX_OUT9", "MIX_OUT9", "Volume from Input Mix Left to Output Channel 9"); 
    157     if (m_Output910[4]) addElement(m_Output910[4]); 
    158     m_Output910[5] = new VolumeControl(*this, FOCUSRITE_CMD_ID_MIX2_TO_OUT10, 
    159                 "MIX_OUT10", "MIX_OUT10", "Volume from Input Mix Right to Output Channel 10"); 
    160     if (m_Output910[5]) addElement(m_Output910[5]); 
    161  
     67    // matrix mix controls 
     68    m_InputMixer=new SaffireProMatrixMixer(*this, SaffireProMatrixMixer::eMMT_InputMix, "InputMix"); 
     69    if (m_InputMixer) addElement(m_InputMixer); 
     70     
     71    m_OutputMixer=new SaffireProMatrixMixer(*this, SaffireProMatrixMixer::eMMT_OutputMix, "OutputMix"); 
     72    if (m_OutputMixer) addElement(m_OutputMixer); 
    16273} 
    16374 
     
    18394    if (m_MidiTru) delete m_MidiTru; 
    18495     
    185     int i=0; 
    186     for (i=0;i<4;i++) { 
    187         deleteElement(m_Output12[i]); 
    188         if (m_Output12[i]) delete m_Output12[i]; 
    189     } 
    190     for (i=0;i<6;i++) { 
    191         deleteElement(m_Output34[i]); 
    192         if (m_Output34[i]) delete m_Output34[i]; 
    193     } 
    194     for (i=0;i<6;i++) { 
    195         deleteElement(m_Output56[i]); 
    196         if (m_Output56[i]) delete m_Output56[i]; 
    197     } 
    198     for (i=0;i<6;i++) { 
    199         deleteElement(m_Output78[i]); 
    200         if (m_Output78[i]) delete m_Output78[i]; 
    201     } 
    202     for (i=0;i<6;i++) { 
    203         deleteElement(m_Output910[i]); 
    204         if (m_Output910[i]) delete m_Output910[i]; 
    205     } 
     96    deleteElement(m_InputMixer); 
     97    if (m_InputMixer) delete m_InputMixer; 
     98     
     99    deleteElement(m_OutputMixer); 
     100    if (m_OutputMixer) delete m_OutputMixer; 
    206101} 
    207102 
     
    326221} 
    327222 
     223 
     224// Saffire pro matrix mixer element 
     225 
     226SaffireProMatrixMixer::SaffireProMatrixMixer(SaffireProDevice& p,  
     227                                             enum eMatrixMixerType type) 
     228: Control::MatrixMixer("MatrixMixer") 
     229, m_Parent(p) 
     230, m_type(type) 
     231{ 
     232    init(type); 
     233} 
     234 
     235SaffireProMatrixMixer::SaffireProMatrixMixer(SaffireProDevice& p,  
     236                                             enum eMatrixMixerType type, std::string n) 
     237: Control::MatrixMixer(n) 
     238, m_Parent(p) 
     239, m_type(type) 
     240{ 
     241    init(type); 
     242} 
     243 
     244void SaffireProMatrixMixer::addSignalInfo(std::vector<struct sSignalInfo> &target, 
     245    std::string name, std::string label, std::string descr) 
     246{ 
     247    struct sSignalInfo s; 
     248    s.name=name; 
     249    s.label=label; 
     250    s.description=descr; 
     251 
     252    target.push_back(s); 
     253} 
     254 
     255void SaffireProMatrixMixer::setCellInfo(int row, int col, int addr, bool valid) 
     256{ 
     257    struct sCellInfo c; 
     258    c.row=row; 
     259    c.col=col; 
     260    c.valid=valid; 
     261    c.address=addr; 
     262 
     263    m_CellInfo[row][col]=c; 
     264} 
     265 
     266void SaffireProMatrixMixer::init(enum eMatrixMixerType type) 
     267{ 
     268    if (type==eMMT_OutputMix) { 
     269        addSignalInfo(m_RowInfo, "PC1", "PC 1", "PC Channel 1"); 
     270        addSignalInfo(m_RowInfo, "PC2", "PC 2", "PC Channel 2"); 
     271        addSignalInfo(m_RowInfo, "PC3", "PC 3", "PC Channel 3"); 
     272        addSignalInfo(m_RowInfo, "PC4", "PC 4", "PC Channel 4"); 
     273        addSignalInfo(m_RowInfo, "PC5", "PC 5", "PC Channel 5"); 
     274        addSignalInfo(m_RowInfo, "PC6", "PC 6", "PC Channel 6"); 
     275        addSignalInfo(m_RowInfo, "PC7", "PC 7", "PC Channel 7"); 
     276        addSignalInfo(m_RowInfo, "PC8", "PC 8", "PC Channel 8"); 
     277        addSignalInfo(m_RowInfo, "PC9", "PC 9", "PC Channel 9"); 
     278        addSignalInfo(m_RowInfo, "PC10", "PC 10", "PC Channel 10"); 
     279        addSignalInfo(m_RowInfo, "IMIXL", "IMix L", "Input Mix Left"); 
     280        addSignalInfo(m_RowInfo, "IMIXR", "IMix R", "Input Mix Right"); 
     281         
     282        addSignalInfo(m_ColInfo, "OUT1", "OUT 1", "Output Channel 1"); 
     283        addSignalInfo(m_ColInfo, "OUT2", "OUT 2", "Output Channel 2"); 
     284        addSignalInfo(m_ColInfo, "OUT3", "OUT 3", "Output Channel 3"); 
     285        addSignalInfo(m_ColInfo, "OUT4", "OUT 4", "Output Channel 4"); 
     286        addSignalInfo(m_ColInfo, "OUT5", "OUT 5", "Output Channel 5"); 
     287        addSignalInfo(m_ColInfo, "OUT6", "OUT 6", "Output Channel 6"); 
     288        addSignalInfo(m_ColInfo, "OUT7", "OUT 7", "Output Channel 7"); 
     289        addSignalInfo(m_ColInfo, "OUT8", "OUT 8", "Output Channel 8"); 
     290        addSignalInfo(m_ColInfo, "OUT9", "OUT 9", "Output Channel 9"); 
     291        addSignalInfo(m_ColInfo, "OUT10", "OUT 10", "Output Channel 10"); 
     292         
     293        // init the cell matrix 
     294        #define FOCUSRITE_SAFFIRE_PRO_OUTMIX_NB_COLS 10 
     295        #define FOCUSRITE_SAFFIRE_PRO_OUTMIX_NB_ROWS 12 
     296         
     297        std::vector<struct sCellInfo> tmp_cols( FOCUSRITE_SAFFIRE_PRO_OUTMIX_NB_COLS ); 
     298        std::vector< std::vector<struct sCellInfo> > tmp_all(FOCUSRITE_SAFFIRE_PRO_OUTMIX_NB_ROWS, tmp_cols); 
     299        m_CellInfo = tmp_all; 
     300     
     301        struct sCellInfo c; 
     302        c.row=-1; 
     303        c.col=-1; 
     304        c.valid=false; 
     305        c.address=0; 
     306         
     307        for (int i=0;i<FOCUSRITE_SAFFIRE_PRO_OUTMIX_NB_ROWS;i++) { 
     308            for (int j=0;j<FOCUSRITE_SAFFIRE_PRO_OUTMIX_NB_COLS;j++) { 
     309                m_CellInfo[i][j]=c; 
     310            } 
     311        } 
     312     
     313        // now set the cells that are valid 
     314        setCellInfo(0,0,FOCUSRITE_CMD_ID_PC1_TO_OUT1, true); 
     315        setCellInfo(1,1,FOCUSRITE_CMD_ID_PC2_TO_OUT2, true); 
     316        setCellInfo(10,0,FOCUSRITE_CMD_ID_MIX1_TO_OUT1, true); 
     317        setCellInfo(11,1,FOCUSRITE_CMD_ID_MIX2_TO_OUT2, true); 
     318        setCellInfo(0,2,FOCUSRITE_CMD_ID_PC1_TO_OUT3, true); 
     319        setCellInfo(1,3,FOCUSRITE_CMD_ID_PC2_TO_OUT4, true); 
     320        setCellInfo(2,2,FOCUSRITE_CMD_ID_PC3_TO_OUT3, true); 
     321        setCellInfo(3,3,FOCUSRITE_CMD_ID_PC4_TO_OUT4, true); 
     322        setCellInfo(10,2,FOCUSRITE_CMD_ID_MIX1_TO_OUT3, true); 
     323        setCellInfo(11,3,FOCUSRITE_CMD_ID_MIX2_TO_OUT4, true); 
     324        setCellInfo(0,4,FOCUSRITE_CMD_ID_PC1_TO_OUT5, true); 
     325        setCellInfo(1,5,FOCUSRITE_CMD_ID_PC2_TO_OUT6, true); 
     326        setCellInfo(4,4,FOCUSRITE_CMD_ID_PC5_TO_OUT5, true); 
     327        setCellInfo(5,5,FOCUSRITE_CMD_ID_PC6_TO_OUT6, true); 
     328        setCellInfo(10,4,FOCUSRITE_CMD_ID_MIX1_TO_OUT5, true); 
     329        setCellInfo(11,5,FOCUSRITE_CMD_ID_MIX2_TO_OUT6, true); 
     330        setCellInfo(0,6,FOCUSRITE_CMD_ID_PC1_TO_OUT7, true); 
     331        setCellInfo(1,7,FOCUSRITE_CMD_ID_PC2_TO_OUT8, true); 
     332        setCellInfo(6,6,FOCUSRITE_CMD_ID_PC7_TO_OUT7, true); 
     333        setCellInfo(7,7,FOCUSRITE_CMD_ID_PC8_TO_OUT8, true); 
     334        setCellInfo(10,6,FOCUSRITE_CMD_ID_MIX1_TO_OUT7, true); 
     335        setCellInfo(11,7,FOCUSRITE_CMD_ID_MIX2_TO_OUT8, true); 
     336        setCellInfo(0,8,FOCUSRITE_CMD_ID_PC1_TO_OUT9, true); 
     337        setCellInfo(1,9,FOCUSRITE_CMD_ID_PC2_TO_OUT10, true); 
     338        setCellInfo(8,8,FOCUSRITE_CMD_ID_PC9_TO_OUT9, true); 
     339        setCellInfo(9,9,FOCUSRITE_CMD_ID_PC10_TO_OUT10, true); 
     340        setCellInfo(10,8,FOCUSRITE_CMD_ID_MIX1_TO_OUT9, true); 
     341        setCellInfo(11,9,FOCUSRITE_CMD_ID_MIX2_TO_OUT10, true); 
     342 
     343    } else if (type==eMMT_InputMix) { 
     344        addSignalInfo(m_RowInfo, "AN1", "Analog 1", "Analog Input 1"); 
     345        addSignalInfo(m_RowInfo, "AN2", "Analog 2", "Analog Input 2"); 
     346        addSignalInfo(m_RowInfo, "AN3", "Analog 3", "Analog Input 3"); 
     347        addSignalInfo(m_RowInfo, "AN4", "Analog 4", "Analog Input 4"); 
     348        addSignalInfo(m_RowInfo, "AN5", "Analog 5", "Analog Input 5"); 
     349        addSignalInfo(m_RowInfo, "AN6", "Analog 6", "Analog Input 6"); 
     350        addSignalInfo(m_RowInfo, "AN7", "Analog 7", "Analog Input 7"); 
     351        addSignalInfo(m_RowInfo, "AN8", "Analog 8", "Analog Input 8"); 
     352        addSignalInfo(m_RowInfo, "SPDIFL", "SPDIF L", "SPDIF Left Input"); 
     353        addSignalInfo(m_RowInfo, "SPDIFR", "SPDIF R", "SPDIF Right Input"); 
     354         
     355        addSignalInfo(m_RowInfo, "ADAT11", "ADAT1 1", "ADAT1 Channel 1"); 
     356        addSignalInfo(m_RowInfo, "ADAT12", "ADAT1 2", "ADAT1 Channel 2"); 
     357        addSignalInfo(m_RowInfo, "ADAT13", "ADAT1 3", "ADAT1 Channel 3"); 
     358        addSignalInfo(m_RowInfo, "ADAT14", "ADAT1 4", "ADAT1 Channel 4"); 
     359        addSignalInfo(m_RowInfo, "ADAT15", "ADAT1 5", "ADAT1 Channel 5"); 
     360        addSignalInfo(m_RowInfo, "ADAT16", "ADAT1 6", "ADAT1 Channel 6"); 
     361        addSignalInfo(m_RowInfo, "ADAT17", "ADAT1 7", "ADAT1 Channel 7"); 
     362        addSignalInfo(m_RowInfo, "ADAT18", "ADAT1 8", "ADAT1 Channel 8"); 
     363         
     364        addSignalInfo(m_RowInfo, "ADAT21", "ADAT2 1", "ADAT2 Channel 1"); 
     365        addSignalInfo(m_RowInfo, "ADAT22", "ADAT2 2", "ADAT2 Channel 2"); 
     366        addSignalInfo(m_RowInfo, "ADAT23", "ADAT2 3", "ADAT2 Channel 3"); 
     367        addSignalInfo(m_RowInfo, "ADAT24", "ADAT2 4", "ADAT2 Channel 4"); 
     368        addSignalInfo(m_RowInfo, "ADAT25", "ADAT2 5", "ADAT2 Channel 5"); 
     369        addSignalInfo(m_RowInfo, "ADAT26", "ADAT2 6", "ADAT2 Channel 6"); 
     370        addSignalInfo(m_RowInfo, "ADAT27", "ADAT2 7", "ADAT2 Channel 7"); 
     371        addSignalInfo(m_RowInfo, "ADAT28", "ADAT2 8", "ADAT2 Channel 8"); 
     372         
     373        addSignalInfo(m_ColInfo, "IMIXL", "IMix L", "Input Mix Left"); 
     374        addSignalInfo(m_ColInfo, "IMIXR", "IMix R", "Input Mix Right"); 
     375         
     376        // init the cell matrix 
     377        #define FOCUSRITE_SAFFIRE_PRO_INMIX_NB_COLS 2 
     378        #define FOCUSRITE_SAFFIRE_PRO_INMIX_NB_ROWS 26 
     379         
     380        std::vector<struct sCellInfo> tmp_cols( FOCUSRITE_SAFFIRE_PRO_INMIX_NB_COLS ); 
     381        std::vector< std::vector<struct sCellInfo> > tmp_all(FOCUSRITE_SAFFIRE_PRO_INMIX_NB_ROWS,tmp_cols); 
     382        m_CellInfo = tmp_all; 
     383     
     384        struct sCellInfo c; 
     385        c.row=-1; 
     386        c.col=-1; 
     387        c.valid=false; 
     388        c.address=0; 
     389         
     390        for (int i=0;i<FOCUSRITE_SAFFIRE_PRO_INMIX_NB_ROWS;i++) { 
     391            for (int j=0;j<FOCUSRITE_SAFFIRE_PRO_INMIX_NB_COLS;j++) { 
     392                m_CellInfo[i][j]=c; 
     393            } 
     394        } 
     395     
     396        // now set the cells that are valid 
     397        setCellInfo(0,0,FOCUSRITE_CMD_ID_AN1_TO_IMIXL, true); 
     398        setCellInfo(0,1,FOCUSRITE_CMD_ID_AN1_TO_IMIXR, true); 
     399        setCellInfo(1,0,FOCUSRITE_CMD_ID_AN2_TO_IMIXL, true); 
     400        setCellInfo(1,1,FOCUSRITE_CMD_ID_AN2_TO_IMIXR, true); 
     401        setCellInfo(2,0,FOCUSRITE_CMD_ID_AN3_TO_IMIXL, true); 
     402        setCellInfo(2,1,FOCUSRITE_CMD_ID_AN3_TO_IMIXR, true); 
     403        setCellInfo(3,0,FOCUSRITE_CMD_ID_AN4_TO_IMIXL, true); 
     404        setCellInfo(3,1,FOCUSRITE_CMD_ID_AN4_TO_IMIXR, true); 
     405        setCellInfo(4,0,FOCUSRITE_CMD_ID_AN5_TO_IMIXL, true); 
     406        setCellInfo(4,1,FOCUSRITE_CMD_ID_AN5_TO_IMIXR, true); 
     407        setCellInfo(5,0,FOCUSRITE_CMD_ID_AN6_TO_IMIXL, true); 
     408        setCellInfo(5,1,FOCUSRITE_CMD_ID_AN6_TO_IMIXR, true); 
     409        setCellInfo(6,0,FOCUSRITE_CMD_ID_AN7_TO_IMIXL, true); 
     410        setCellInfo(6,1,FOCUSRITE_CMD_ID_AN7_TO_IMIXR, true); 
     411        setCellInfo(7,0,FOCUSRITE_CMD_ID_AN8_TO_IMIXL, true); 
     412        setCellInfo(7,1,FOCUSRITE_CMD_ID_AN8_TO_IMIXR, true); 
     413        setCellInfo(8,0,FOCUSRITE_CMD_ID_SPDIFL_TO_IMIXL, true); 
     414        setCellInfo(8,1,FOCUSRITE_CMD_ID_SPDIFL_TO_IMIXR, true); 
     415        setCellInfo(9,0,FOCUSRITE_CMD_ID_SPDIFR_TO_IMIXL, true); 
     416        setCellInfo(9,1,FOCUSRITE_CMD_ID_SPDIFR_TO_IMIXR, true); 
     417 
     418        setCellInfo(10,0,FOCUSRITE_CMD_ID_ADAT11_TO_IMIXL, true); 
     419        setCellInfo(10,1,FOCUSRITE_CMD_ID_ADAT11_TO_IMIXR, true); 
     420        setCellInfo(11,0,FOCUSRITE_CMD_ID_ADAT12_TO_IMIXL, true); 
     421        setCellInfo(11,1,FOCUSRITE_CMD_ID_ADAT12_TO_IMIXR, true); 
     422        setCellInfo(12,0,FOCUSRITE_CMD_ID_ADAT13_TO_IMIXL, true); 
     423        setCellInfo(12,1,FOCUSRITE_CMD_ID_ADAT13_TO_IMIXR, true); 
     424        setCellInfo(13,0,FOCUSRITE_CMD_ID_ADAT14_TO_IMIXL, true); 
     425        setCellInfo(13,1,FOCUSRITE_CMD_ID_ADAT14_TO_IMIXR, true); 
     426        setCellInfo(14,0,FOCUSRITE_CMD_ID_ADAT15_TO_IMIXL, true); 
     427        setCellInfo(14,1,FOCUSRITE_CMD_ID_ADAT15_TO_IMIXR, true); 
     428        setCellInfo(15,0,FOCUSRITE_CMD_ID_ADAT16_TO_IMIXL, true); 
     429        setCellInfo(15,1,FOCUSRITE_CMD_ID_ADAT16_TO_IMIXR, true); 
     430        setCellInfo(16,0,FOCUSRITE_CMD_ID_ADAT17_TO_IMIXL, true); 
     431        setCellInfo(16,1,FOCUSRITE_CMD_ID_ADAT17_TO_IMIXR, true); 
     432        setCellInfo(17,0,FOCUSRITE_CMD_ID_ADAT18_TO_IMIXL, true); 
     433        setCellInfo(17,1,FOCUSRITE_CMD_ID_ADAT18_TO_IMIXR, true); 
     434 
     435        setCellInfo(18,0,FOCUSRITE_CMD_ID_ADAT21_TO_IMIXL, true); 
     436        setCellInfo(18,1,FOCUSRITE_CMD_ID_ADAT21_TO_IMIXR, true); 
     437        setCellInfo(19,0,FOCUSRITE_CMD_ID_ADAT22_TO_IMIXL, true); 
     438        setCellInfo(19,1,FOCUSRITE_CMD_ID_ADAT22_TO_IMIXR, true); 
     439        setCellInfo(20,0,FOCUSRITE_CMD_ID_ADAT23_TO_IMIXL, true); 
     440        setCellInfo(20,1,FOCUSRITE_CMD_ID_ADAT23_TO_IMIXR, true); 
     441        setCellInfo(21,0,FOCUSRITE_CMD_ID_ADAT24_TO_IMIXL, true); 
     442        setCellInfo(21,1,FOCUSRITE_CMD_ID_ADAT24_TO_IMIXR, true); 
     443        setCellInfo(22,0,FOCUSRITE_CMD_ID_ADAT25_TO_IMIXL, true); 
     444        setCellInfo(22,1,FOCUSRITE_CMD_ID_ADAT25_TO_IMIXR, true); 
     445        setCellInfo(23,0,FOCUSRITE_CMD_ID_ADAT26_TO_IMIXL, true); 
     446        setCellInfo(23,1,FOCUSRITE_CMD_ID_ADAT26_TO_IMIXR, true); 
     447        setCellInfo(24,0,FOCUSRITE_CMD_ID_ADAT27_TO_IMIXL, true); 
     448        setCellInfo(24,1,FOCUSRITE_CMD_ID_ADAT27_TO_IMIXR, true); 
     449        setCellInfo(25,0,FOCUSRITE_CMD_ID_ADAT28_TO_IMIXL, true); 
     450        setCellInfo(25,1,FOCUSRITE_CMD_ID_ADAT28_TO_IMIXR, true); 
     451 
     452    } else { 
     453        debugError("Invalid mixer type\n"); 
     454    } 
     455} 
     456 
     457void SaffireProMatrixMixer::show() 
     458{ 
     459    debugOutput(DEBUG_LEVEL_NORMAL, "Saffire Pro Matrix mixer type %d\n"); 
     460} 
     461 
     462std::string SaffireProMatrixMixer::getRowName( const int row ) 
     463{ 
     464    return m_RowInfo.at(row).name; 
     465} 
     466 
     467std::string SaffireProMatrixMixer::getColName( const int col ) 
     468{ 
     469    return m_ColInfo.at(col).name; 
     470} 
     471 
     472int SaffireProMatrixMixer::canWrite( const int row, const int col ) 
     473{ 
     474    return m_CellInfo.at(row).at(col).valid; 
     475} 
     476 
     477double SaffireProMatrixMixer::setValue( const int row, const int col, const double val ) 
     478{ 
     479    uint32_t v=val; 
     480    struct sCellInfo c=m_CellInfo.at(row).at(col); 
     481     
     482    if (v>0x07FFF) v=0x07FFF; 
     483    else if (v<0) v=0; 
     484 
     485    if ( !m_Parent.setSpecificValue(c.address, v) ) { 
     486        debugError( "setSpecificValue failed\n" ); 
     487        return false; 
     488    } else return true; 
     489} 
     490 
     491double SaffireProMatrixMixer::getValue( const int row, const int col ) 
     492{ 
     493    struct sCellInfo c=m_CellInfo.at(row).at(col); 
     494    uint32_t val=0; 
     495 
     496    if ( !m_Parent.getSpecificValue(c.address, &val) ) { 
     497        debugError( "getSpecificValue failed\n" ); 
     498        return 0; 
     499    } else return val; 
     500} 
     501 
     502int SaffireProMatrixMixer::getRowCount( ) 
     503{ 
     504    return m_RowInfo.size(); 
     505} 
     506 
     507int SaffireProMatrixMixer::getColCount( ) 
     508{ 
     509    return m_ColInfo.size(); 
     510} 
     511 
    328512} // Focusrite 
    329513} // BeBoB 
  • trunk/libffado/src/bebob/focusrite/focusrite_saffirepro.h

    r649 r650  
    2929#include "focusrite_generic.h" 
    3030 
     31#include "libcontrol/MatrixMixer.h" 
     32 
     33#include <vector> 
     34#include <string> 
     35 
    3136namespace BeBoB { 
    3237namespace Focusrite { 
    3338 
    34 class SaffireProDevice : public FocusriteDevice { 
     39class SaffireProDevice; 
     40 
     41class SaffireProMatrixMixer : public Control::MatrixMixer 
     42
     43public: 
     44    enum eMatrixMixerType { 
     45        eMMT_InputMix, 
     46        eMMT_OutputMix 
     47    }; 
     48     
     49public: 
     50    SaffireProMatrixMixer(SaffireProDevice& parent, enum eMatrixMixerType type); 
     51    SaffireProMatrixMixer(SaffireProDevice& parent, enum eMatrixMixerType type, std::string n); 
     52    virtual ~SaffireProMatrixMixer() {}; 
     53 
     54    virtual void show(); 
     55 
     56    virtual std::string getRowName( const int ); 
     57    virtual std::string getColName( const int ); 
     58    virtual int canWrite( const int, const int ); 
     59    virtual double setValue( const int, const int, const double ); 
     60    virtual double getValue( const int, const int ); 
     61    virtual int getRowCount( ); 
     62    virtual int getColCount( ); 
     63 
     64private: 
     65    struct sSignalInfo { 
     66        std::string name; 
     67        std::string label; 
     68        std::string description; 
     69    }; 
     70    struct sCellInfo { 
     71        int row; 
     72        int col; 
     73        // indicates whether a cell can be valid, this 
     74        // doesn't mean that it is writable. Just that it can be. 
     75        bool valid; 
     76        // the address to use when manipulating this cell 
     77        int address; 
     78    }; 
     79     
     80    void init(enum eMatrixMixerType type); 
     81    void addSignalInfo(std::vector<struct sSignalInfo> &target, 
     82                       std::string name, std::string label, std::string descr); 
     83    void setCellInfo(int row, int col, int addr, bool valid); 
     84 
     85    std::vector<struct sSignalInfo> m_RowInfo; 
     86    std::vector<struct sSignalInfo> m_ColInfo; 
     87    std::vector< std::vector<struct sCellInfo> > m_CellInfo; 
     88     
     89    SaffireProDevice&       m_Parent; 
     90    enum eMatrixMixerType   m_type; 
     91}; 
     92 
     93 
     94class SaffireProDevice : public FocusriteDevice 
     95
    3596public: 
    3697    SaffireProDevice( Ieee1394Service& ieee1394Service, 
     
    62123    VolumeControl * m_Output910[6]; 
    63124     
     125    SaffireProMatrixMixer * m_InputMixer; 
     126    SaffireProMatrixMixer * m_OutputMixer; 
    64127}; 
    65128