| #include "mbtk_audio.h" |
| #include <stdlib.h> |
| |
| static void help(int tag) |
| { |
| printf("TAG : %d\n", tag); |
| printf("./mbtk_gain_set tx_codec/tx_dsp [gain]\n"); |
| printf("./mbtk_gain_set rx_codec/rx_dsp [gain0] [value1] [gain2] [value3] [gain4] [value5] [gain6] [value7] [gain8] [value9] [value10]\n"); |
| printf("./mbtk_gain_set reg [addr] [value]\n"); |
| } |
| |
| int main(int argc,char *argv[]) |
| { |
| int handler = 0; |
| |
| if(argc < 3) |
| { |
| help(0); |
| return -1; |
| } |
| |
| if(strcmp(argv[1], "reg") && strcmp(argv[1], "tx_codec") |
| && strcmp(argv[1], "tx_dsp") && strcmp(argv[1], "rx_codec") |
| && strcmp(argv[1], "rx_dsp")) { |
| help(1); |
| return -1; |
| } |
| |
| if(strcmp(argv[1], "reg") == 0 && argc != 4) { |
| help(2); |
| return -1; |
| } |
| |
| if(strcmp(argv[1], "tx_codec") == 0 && argc != 3) { |
| help(3); |
| return -1; |
| } |
| |
| if(strcmp(argv[1], "tx_dsp") == 0 && argc != 3) { |
| help(4); |
| return -1; |
| } |
| |
| if(strcmp(argv[1], "rx_codec") == 0 && argc != 13) { |
| help(5); |
| return -1; |
| } |
| |
| if(strcmp(argv[1], "rx_dsp") == 0 && argc != 13) { |
| help(6); |
| return -1; |
| } |
| |
| if(mbtk_audio_ubus_client_init(&handler, NULL)) { |
| printf("mbtk_audio_ubus_client_init fail.\n"); |
| return -1; |
| } |
| |
| if(strcmp(argv[1], "tx_codec") == 0 || strcmp(argv[1], "tx_dsp") == 0) { |
| unsigned short gain[1]; |
| |
| gain[0] = (unsigned short)strtoul(argv[2], 0, 0); |
| |
| printf("Type:%s, gain:%d(0x%04x)\n", argv[1], gain[0], gain[0]); |
| |
| if(strcmp(argv[1], "tx_codec") == 0) { |
| mbtk_audio_ubus_gain_set(AUDIO_GAIN_TYPE_TX_CODECGAIN, gain, 1); |
| } else { |
| mbtk_audio_ubus_gain_set(AUDIO_GAIN_TYPE_TX_DSPGAIN, gain, 1); |
| } |
| } else if(strcmp(argv[1], "rx_codec") == 0 || strcmp(argv[1], "rx_dsp") == 0) { |
| unsigned short gain[11]; |
| |
| printf("Type:%s\n", argv[1]); |
| |
| int i = 0; |
| for(;i < 11; i++) { |
| gain[i] = (unsigned short)strtoul(argv[2 + i], 0, 0); |
| printf("Gain[%d%%]:%d(0x%04x)\n", i * 10, gain[i], gain[i]); |
| } |
| |
| if(strcmp(argv[1], "rx_codec") == 0) { |
| mbtk_audio_ubus_gain_set(AUDIO_GAIN_TYPE_RX_CODECGAIN, gain, 11); |
| } else { |
| mbtk_audio_ubus_gain_set(AUDIO_GAIN_TYPE_RX_DSPGAIN, gain, 11); |
| } |
| } else if(strcmp(argv[1], "reg") == 0) { |
| int value[2]; |
| value[0] = (unsigned int)strtoul(argv[2], 0, 0); |
| value[1] = (unsigned int)strtoul(argv[3], 0, 0); |
| mbtk_audio_ubus_reg_set(value[0], value[1]); |
| } |
| |
| if(mbtk_audio_ubus_client_deinit(handler)) { |
| printf("mbtk_audio_ubus_client_init fail.\n"); |
| return -1; |
| } |
| |
| return 0; |
| } |
| |