blob: 103c931a5935ef49db007b751ce39ec14cea99c9 [file] [log] [blame]
wei.wang1e45cfd32023-07-10 08:33:46 +00001/*
2 * Copyright (C) 2023 Amlogic Corporation.
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
17#include <string.h>
18#include <stdio.h>
19#include <stdlib.h>
20#include <stdbool.h>
21
22#include <AML_Audio_Setting.h>
23
24static void usage()
25{
26 printf("Usage:\n");
27 printf(" set volume : test_audiosetting volume x (x is vol value, 0~100)\n");
28 printf(" get volume : test_audiosetting volume\n");
29 printf(" set mute : test_audiosetting mute port x (port:hdmi or hp, x is mute:1 or unmute:0)\n");
30 printf(" get mute : test_audiosetting mute port (port:hdmi or hp)\n");
haiyang.renfdc144e2023-09-01 02:55:50 +000031 printf(" set mode : test_audiosetting mode \"AML_HAL_xxx\"\n");
32 printf(" get mode : test_audiosetting mode\n");
haiyang.ren936bfc52023-09-18 05:46:24 +000033 printf(" set drc : test_audiosetting drc \"RF/LINE/OFF\"\n");
34 printf(" get drc : test_audiosetting drc\n");
wei.wang1e45cfd32023-07-10 08:33:46 +000035}
36
37int main(int argc, char **argv)
38{
39 float vol;
40 int ret;
41 if (argc < 2) {
42 usage();
43 return -1;
44 }
45 if (!strncmp("volume", argv[1], sizeof("volume")) && argv[2] != NULL) {
46 ret = aml_audio_set_volume(atoi(argv[2]));
47 printf("aml_audio_set_volume(%d): ret = %d\n", atoi(argv[2]), ret);
48 } else if (!strncmp("volume", argv[1], sizeof("volume"))) {
49 ret = aml_audio_get_volume();
50 printf("aml_audio_get_volume: %d\n", ret);
51 } else if (!strncmp("mute", argv[1], sizeof("mute")) && argv[2] != NULL && argv[3] != NULL) {
52 if (!strncmp("hdmi", argv[2], sizeof("hdmi")))
53 ret = aml_audio_set_mute(AUDIO_PORT_HDMI, atoi(argv[3]));
54 else if (!strncmp("hp", argv[2], sizeof("hp")))
55 ret = aml_audio_set_mute(AUDIO_PORT_HEADPHONE, atoi(argv[3]));
56 printf("aml_audio_set_mute(%s: %d): ret = %d\n", argv[2], atoi(argv[3]), ret);
57 } else if (!strncmp("mute", argv[1], sizeof("mute")) && argv[2] != NULL) {
58 if (!strncmp("hdmi", argv[2], sizeof("hdmi")))
59 ret = aml_audio_get_mute(AUDIO_PORT_HDMI);
60 else if (!strncmp("hp", argv[2], sizeof("hp")))
61 ret = aml_audio_get_mute(AUDIO_PORT_HEADPHONE);
62 printf("aml_audio_get_mute(%s): %smute\n", argv[2], ret ? "" : "un");
haiyang.renfdc144e2023-09-01 02:55:50 +000063 } else if (!strncmp("mode", argv[1], sizeof("mode")) && argv[2] != NULL) {
64 if (!strncmp("AML_HAL_PCM", argv[2], sizeof("AML_HAL_PCM")))
65 ret = aml_audio_set_digital_mode(AML_HAL_PCM);
66 else if (!strncmp("AML_HAL_DD", argv[2], sizeof("AML_HAL_DD")))
67 ret = aml_audio_set_digital_mode(AML_HAL_DD);
68 else if (!strncmp("AML_HAL_AUTO", argv[2], sizeof("AML_HAL_AUTO")))
69 ret = aml_audio_set_digital_mode(AML_HAL_AUTO);
70 else if (!strncmp("AML_HAL_BYPASS", argv[2], sizeof("AML_HAL_BYPASS")))
71 ret = aml_audio_set_digital_mode(AML_HAL_BYPASS);
72 else if (!strncmp("AML_HAL_DDP", argv[2], sizeof("AML_HAL_DDP")))
73 ret = aml_audio_set_digital_mode(AML_HAL_DDP);
74 } else if (!strncmp("mode", argv[1], sizeof("mode"))) {
75 ret = aml_audio_get_digital_mode();
76 printf("aml_audio_get_digital_mode: %d\n", ret);
haiyang.ren936bfc52023-09-18 05:46:24 +000077 } else if (!strncmp("drc", argv[1], sizeof("drc")) && argv[2] != NULL) {
78 if (!strncmp("RF", argv[2], sizeof("RF")))
79 ret = aml_audio_set_drc_mode(DRC_RF);
80 else if (!strncmp("LINE", argv[2], sizeof("LINE")))
81 ret = aml_audio_set_drc_mode(DRC_LINE);
82 else if (!strncmp("OFF", argv[2], sizeof("OFF")))
83 ret = aml_audio_set_drc_mode(DRC_OFF);
84 } else if (!strncmp("drc", argv[1], sizeof("drc"))) {
85 ret = aml_audio_get_drc_mode();
86 printf("aml_audio_get_drc_mode: %d\n", ret);
wei.wang1e45cfd32023-07-10 08:33:46 +000087 }
88 return 0;
89}
90