• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2023 Huawei Device Co., Ltd.
3  * Licensed under the Apache License, Version 2.0 (the "License");
4  * you may not use this file except in compliance with the License.
5  * You may obtain a copy of the License at
6  *
7  *     http://www.apache.org/licenses/LICENSE-2.0
8  *
9  * Unless required by applicable law or agreed to in writing, software
10  * distributed under the License is distributed on an "AS IS" BASIS,
11  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12  * See the License for the specific language governing permissions and
13  * limitations under the License.
14  */
15 
16 #ifndef AUDIO_INTERFACE_LIB_MIXER_H
17 #define AUDIO_INTERFACE_LIB_MIXER_H
18 
19 #include <sys/types.h>
20 
21 #define MIXER_CMD_ID_BASE 200
22 
23 #define AUDIO_BASE_LEN          32
24 #define AUDIO_ELEMENT_NUM       64
25 #define AUDIO_INTEGER_NUM       128
26 #define AUDIO_ELEM_NAME_LEN     (2 * (AUDIO_BASE_LEN))
27 #define AUDIO_CARD_SRV_NAME_LEN (2 * (AUDIO_BASE_LEN))
28 #define RESERVED_BUF_LEN        (8 * (AUDIO_BASE_LEN))
29 
30 typedef enum {
31     PCM_RENDER = 1,
32     PCM_CAPTURE = 2,
33     PCM_BOTTOM = PCM_RENDER,
34 } AudioPcmType;
35 
36 typedef enum {
37     /** Card level */
38     AUDIO_CTL_ELEM_IFACE_CARD,
39     AUDIO_CTL_ELEM_IFACE_PCM,
40     AUDIO_CTL_ELEM_IFACE_MIXER = 2, /* virtual mixer control */
41     AUDIO_CTL_ELEM_IFACE_LAST = AUDIO_CTL_ELEM_IFACE_MIXER,
42 } AudioCtlElemIfaceType;
43 
44 typedef enum {
45     AUDIO_CTL_ELEM_TYPE_NONE = 0, /* Invalid type */
46     AUDIO_CTL_ELEM_TYPE_BOOLEAN,
47     AUDIO_CTL_ELEM_TYPE_INTEGER,
48     AUDIO_CTL_ELEM_TYPE_ENUMERATED,
49     AUDIO_CTL_ELEM_TYPE_BYTES,
50     AUDIO_CTL_ELEM_TYPE_LAST = AUDIO_CTL_ELEM_TYPE_BYTES,
51 } AudioCtlElemType;
52 
53 enum AudioControlType {
54     AUDIO_CONTROL_MIXER = 1,
55     AUDIO_CONTROL_MUX,
56     AUDIO_CONTROL_ENUM,
57 };
58 
59 typedef enum AudioMixerCtrlCmdList {
60     MIXER_CTL_IOCTL_PVERSION = -1,
61     MIXER_CTL_IOCTL_ELEM_INFO = MIXER_CMD_ID_BASE,
62     MIXER_CTL_IOCTL_ELEM_READ,
63     MIXER_CTL_IOCTL_ELEM_WRITE,
64     MIXER_CTL_IOCTL_ELEM_LIST,
65     MIXER_CTL_IOCTL_ELEM_GET_PROP,
66     MIXER_CTL_IOCTL_ELEM_SET_PROP,
67     MIXER_CTL_IOCTL_GET_CARDS,
68     MIXER_CTL_IOCTL_GET_CHMAP,
69     MIXER_CTL_IOCTL_SET_CHMAP,
70     MIXER_CTL_IOCTL_BUTT = MIXER_CTL_IOCTL_PVERSION,
71 } OpCode;
72 
73 struct HdfIoService;
74 typedef int32_t (*AudioMixer)(AudioPcmType pcm, OpCode cmd, const struct HdfIoService *service, void *data);
75 
76 struct AudioMixerOps {
77     int32_t cmdId;
78     AudioMixer func;
79 };
80 
81 struct AudioCardId {
82     int32_t index;
83     char cardName[AUDIO_CARD_SRV_NAME_LEN];
84 };
85 
86 struct SndCardsList {
87     uint32_t cardNums;
88     void *cardsList; /* AudioCardId Indicates the first link address of the structure type */
89 };
90 
91 struct AudioHwCtlElemId {
92     char name[AUDIO_ELEM_NAME_LEN]; /* ASCII name of item */
93     AudioCtlElemIfaceType iface;
94 };
95 
96 struct AudioHwCtlElemIndex {
97     struct AudioHwCtlElemId eId;
98     uint32_t index; /* index of item */
99 };
100 
101 struct AudioCtlElemList {
102     const char *cardSrvName;
103     uint32_t count;                           /* R: count of all elements */
104     uint32_t space;                           /* W: count of element IDs to get */
105     struct AudioHwCtlElemId *ctlElemListAddr; /* R: IDs (AudioHwCtlElemId list addr) */
106 };
107 
108 struct AudioMixerCtlElemInfo {
109     char cardSrvName[AUDIO_CARD_SRV_NAME_LEN];
110     struct AudioHwCtlElemIndex eIndexId; /* W: element IDx */
111     AudioCtlElemType type;               /* R: value type - AudioCtlElemType */
112     uint32_t count;                      /* count of values */
113     union {
114         struct {
115             int32_t min;                  /* R: minimum value */
116             int32_t max;                  /* R: maximum value */
117             int32_t step;                 /* R: step (0 variable) */
118             long vals[AUDIO_INTEGER_NUM]; /* RW: values */
119         } intVal;
120         struct {
121             uint32_t items;                 /* R: number of items */
122             uint32_t item;                  /* W: item number */
123             long val[AUDIO_ELEMENT_NUM];    /* RW: value */
124             char name[AUDIO_ELEM_NAME_LEN]; /* R: value name */
125             uint64_t names_ptr;             /* W: names list (ELEM_ADD only) */
126             uint32_t names_length;
127         } enumVal;
128         unsigned char reserved[RESERVED_BUF_LEN];
129     } value;
130 };
131 
132 /* External structure */
133 struct AudioMixerContents {
134     char cardServiceName[AUDIO_CARD_SRV_NAME_LEN];
135     uint32_t elemNum;
136     void *data; /* AudioHwCtlElemId Indicates the first link address of the structure type */
137 };
138 
139 #endif /* AUDIO_INTERFACE_LIB_MIXER_H */
140