blob: d70b4e6d3c1c6c7a2e4377f45046158c81149e56 [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");
wei.wang1e45cfd32023-07-10 08:33:46 +000033}
34
35int main(int argc, char **argv)
36{
37 float vol;
38 int ret;
39 if (argc < 2) {
40 usage();
41 return -1;
42 }
43 if (!strncmp("volume", argv[1], sizeof("volume")) && argv[2] != NULL) {
44 ret = aml_audio_set_volume(atoi(argv[2]));
45 printf("aml_audio_set_volume(%d): ret = %d\n", atoi(argv[2]), ret);
46 } else if (!strncmp("volume", argv[1], sizeof("volume"))) {
47 ret = aml_audio_get_volume();
48 printf("aml_audio_get_volume: %d\n", ret);
49 } else if (!strncmp("mute", argv[1], sizeof("mute")) && argv[2] != NULL && argv[3] != NULL) {
50 if (!strncmp("hdmi", argv[2], sizeof("hdmi")))
51 ret = aml_audio_set_mute(AUDIO_PORT_HDMI, atoi(argv[3]));
52 else if (!strncmp("hp", argv[2], sizeof("hp")))
53 ret = aml_audio_set_mute(AUDIO_PORT_HEADPHONE, atoi(argv[3]));
54 printf("aml_audio_set_mute(%s: %d): ret = %d\n", argv[2], atoi(argv[3]), ret);
55 } else if (!strncmp("mute", argv[1], sizeof("mute")) && argv[2] != NULL) {
56 if (!strncmp("hdmi", argv[2], sizeof("hdmi")))
57 ret = aml_audio_get_mute(AUDIO_PORT_HDMI);
58 else if (!strncmp("hp", argv[2], sizeof("hp")))
59 ret = aml_audio_get_mute(AUDIO_PORT_HEADPHONE);
60 printf("aml_audio_get_mute(%s): %smute\n", argv[2], ret ? "" : "un");
haiyang.renfdc144e2023-09-01 02:55:50 +000061 } else if (!strncmp("mode", argv[1], sizeof("mode")) && argv[2] != NULL) {
62 if (!strncmp("AML_HAL_PCM", argv[2], sizeof("AML_HAL_PCM")))
63 ret = aml_audio_set_digital_mode(AML_HAL_PCM);
64 else if (!strncmp("AML_HAL_DD", argv[2], sizeof("AML_HAL_DD")))
65 ret = aml_audio_set_digital_mode(AML_HAL_DD);
66 else if (!strncmp("AML_HAL_AUTO", argv[2], sizeof("AML_HAL_AUTO")))
67 ret = aml_audio_set_digital_mode(AML_HAL_AUTO);
68 else if (!strncmp("AML_HAL_BYPASS", argv[2], sizeof("AML_HAL_BYPASS")))
69 ret = aml_audio_set_digital_mode(AML_HAL_BYPASS);
70 else if (!strncmp("AML_HAL_DDP", argv[2], sizeof("AML_HAL_DDP")))
71 ret = aml_audio_set_digital_mode(AML_HAL_DDP);
72 } else if (!strncmp("mode", argv[1], sizeof("mode"))) {
73 ret = aml_audio_get_digital_mode();
74 printf("aml_audio_get_digital_mode: %d\n", ret);
wei.wang1e45cfd32023-07-10 08:33:46 +000075 }
76 return 0;
77}
78