81 | | // Set amplifier gains |
---|
| 86 | // A default sampling rate. An explicit DDS frequency is not enabled |
---|
| 87 | // by default. |
---|
| 88 | dev_config->software_freq = 44100; |
---|
| 89 | dev_config->dds_freq = 0; |
---|
| 90 | |
---|
| 91 | // TODO: set input amplifier gains to a value other than 0? |
---|
| 92 | |
---|
| 93 | // TODO: store and set matrix mixer values |
---|
| 94 | // TODO: store and manipulate channel mute/rec flags |
---|
| 95 | |
---|
| 96 | // Configure the hardware to match the current software status. |
---|
| 97 | // This is only done if the settings valid flag is 0; if it is 1 it |
---|
| 98 | // indicates that something has already set the device up to match |
---|
| 99 | // the software settings so there's no need to do it again. |
---|
| 100 | |
---|
| 101 | if (set_hardware_params(settings) != 0) |
---|
| 102 | ret = -1; |
---|
| 103 | |
---|
| 104 | if (ret==0 && m_rme_model==RME_MODEL_FIREFACE400) { |
---|
| 105 | unsigned int node_id = getConfigRom().getNodeId(); |
---|
| 106 | unsigned int midi_hi_addr; |
---|
| 107 | // For now we'll fix this since that's what's done under other |
---|
| 108 | // systems. |
---|
| 109 | midi_hi_addr = 0x01; |
---|
| 110 | if (writeRegister(RME_FF400_MIDI_HIGH_ADDR, (node_id<<16) | midi_hi_addr) != 0) |
---|
| 111 | ret = -1; |
---|
| 112 | } |
---|
| 113 | |
---|
| 114 | if (ret==0) { |
---|
| 115 | signed freq = dev_config->software_freq; |
---|
| 116 | if (dev_config->dds_freq > 0) |
---|
| 117 | freq = dev_config->dds_freq; |
---|
| 118 | if (set_hardware_dds_freq(freq) != 0) |
---|
| 119 | ret = -1; |
---|
| 120 | } |
---|
| 121 | |
---|
| 129 | // Matrix mixer settings |
---|
| 130 | for (dest=0; dest<n_channels; dest++) { |
---|
| 131 | for (src=0; src<n_channels; src++) { |
---|
| 132 | set_hardware_mixergain(RME_FF_MM_INPUT, src, dest, 0); |
---|
| 133 | } |
---|
| 134 | for (src=0; src<n_channels; src++) { |
---|
| 135 | set_hardware_mixergain(RME_FF_MM_PLAYBACK, src, dest, 0); |
---|
| 136 | } |
---|
| 137 | } |
---|
| 138 | for (src=0; src<n_channels; src++) { |
---|
| 139 | set_hardware_mixergain(RME_FF_MM_OUTPUT, src, 0, 0); |
---|
| 140 | } |
---|
| 141 | |
---|
| 142 | set_hardware_output_rec(0); |
---|
| 143 | |
---|
108 | | } |
---|
109 | | |
---|
110 | | if (ret==0 && m_rme_model==RME_MODEL_FIREFACE400) { |
---|
111 | | unsigned int node_id = getConfigRom().getNodeId(); |
---|
112 | | unsigned int midi_hi_addr; |
---|
113 | | // For now we'll fix this since that's what's done under other |
---|
114 | | // systems. |
---|
115 | | midi_hi_addr = 0x01; |
---|
116 | | if (writeRegister(RME_FF400_MIDI_HIGH_ADDR, (node_id<<16) | midi_hi_addr) != 0) |
---|
117 | | ret = -1; |
---|
118 | | } |
---|
119 | | |
---|
120 | | if (ret==0) { |
---|
121 | | signed freq = dev_config->software_freq; |
---|
122 | | if (dev_config->dds_freq > 0) |
---|
123 | | freq = dev_config->dds_freq; |
---|
124 | | if (set_hardware_dds_freq(freq) != 0) |
---|
125 | | ret = -1; |
---|
792 | | } |
---|
| 839 | signed int |
---|
| 840 | Device::set_hardware_mixergain(unsigned int ctype, unsigned int src_channel, |
---|
| 841 | unsigned int dest_channel, signed int val) { |
---|
| 842 | // Set the value of a matrix mixer control. ctype is one of the RME_FF_MM_* |
---|
| 843 | // defines: |
---|
| 844 | // RME_FF_MM_INPUT: source is a physical input |
---|
| 845 | // RME_FF_MM_PLAYBACK: source is playback from PC |
---|
| 846 | // RME_FF_MM_OUTPUT: source is the physical output whose gain is to be |
---|
| 847 | // changed, destination is ignored |
---|
| 848 | // Val is the integer value sent to the device. The amount of gain (in dB) |
---|
| 849 | // applied can be calculated using |
---|
| 850 | // dB = 20.log10(val/32768) |
---|
| 851 | // The maximum value of val is 0x10000, corresponding to +6dB of gain. |
---|
| 852 | // The minimum is 0x00000 corresponding to mute. |
---|
| 853 | |
---|
| 854 | unsigned int n_channels; |
---|
| 855 | signed int ram_output_block_size; |
---|
| 856 | unsigned int ram_addr; |
---|
| 857 | |
---|
| 858 | n_channels = (m_rme_model==RME_MODEL_FIREFACE400)? |
---|
| 859 | RME_FF400_MAX_CHANNELS:RME_FF800_MAX_CHANNELS; |
---|
| 860 | if (src_channel>n_channels || dest_channel>n_channels) |
---|
| 861 | return -1; |
---|
| 862 | if (val<0 || val>0x10000) |
---|
| 863 | return -1; |
---|
| 864 | |
---|
| 865 | if (m_rme_model == RME_MODEL_FIREFACE400) { |
---|
| 866 | ram_output_block_size = 0x48; |
---|
| 867 | } else { |
---|
| 868 | ram_output_block_size = 0x80; |
---|
| 869 | } |
---|
| 870 | |
---|
| 871 | ram_addr = RME_FF_MIXER_RAM; |
---|
| 872 | switch (ctype) { |
---|
| 873 | case RME_FF_MM_INPUT: |
---|
| 874 | case RME_FF_MM_PLAYBACK: |
---|
| 875 | ram_addr += (dest_channel*2*ram_output_block_size) + 4*src_channel; |
---|
| 876 | if (ctype == RME_FF_MM_PLAYBACK) |
---|
| 877 | ram_addr += ram_output_block_size; |
---|
| 878 | break; |
---|
| 879 | case RME_FF_MM_OUTPUT: |
---|
| 880 | ram_addr += 0x0f80 + 4*src_channel; |
---|
| 881 | break; |
---|
| 882 | } |
---|
| 883 | writeRegister(ram_addr, val); |
---|
| 884 | |
---|
| 885 | // If setting the output volume and the device is the FF400, keep |
---|
| 886 | // the separate gain register in sync. |
---|
| 887 | if (ctype==RME_FF_MM_OUTPUT && m_rme_model==RME_MODEL_FIREFACE400) { |
---|
| 888 | signed int dB; |
---|
| 889 | if (val==0) |
---|
| 890 | dB = -90; |
---|
| 891 | else |
---|
| 892 | dB = roundl(20.0*log10(val/32768.0)); |
---|
| 893 | set_hardware_ampgain(FF400_AMPGAIN_OUTPUT1+src_channel, dB); |
---|
| 894 | } |
---|
| 895 | |
---|
| 896 | return 0; |
---|
| 897 | } |
---|
| 898 | |
---|
| 899 | signed int |
---|
| 900 | Device::set_hardware_channel_mute(signed int mute) { |
---|
| 901 | // Explicitly mute (mute!=0) or unmute (mute=0) all channels. |
---|
| 902 | // TODO: fill the details in to allow individual channels to be muted as |
---|
| 903 | // required. |
---|
| 904 | quadlet_t buf[28]; |
---|
| 905 | signed int i; |
---|
| 906 | |
---|
| 907 | for (i=0; i<28; i++) |
---|
| 908 | buf[i] = (mute!=0); |
---|
| 909 | |
---|
| 910 | // Write 28 quadlets even for FF400 |
---|
| 911 | return writeBlock(RME_FF_CHANNEL_MUTE_MASK, buf, 28); |
---|
| 912 | } |
---|
| 913 | |
---|
| 914 | signed int |
---|
| 915 | Device::set_hardware_output_rec(signed int rec) { |
---|
| 916 | // Explicitly record (mute!=1) outputs, or not. |
---|
| 917 | // TODO: fill the details in to allow individual outputs to be recorded as |
---|
| 918 | // required. |
---|
| 919 | quadlet_t buf[28]; |
---|
| 920 | signed int i; |
---|
| 921 | |
---|
| 922 | for (i=0; i<28; i++) |
---|
| 923 | buf[i] = (rec!=0); |
---|
| 924 | |
---|
| 925 | // Write 28 quadlets even for FF400 |
---|
| 926 | return writeBlock(RME_FF_OUTPUT_REC_MASK, buf, 28); |
---|
| 927 | } |
---|
| 928 | |
---|
| 929 | } |
---|