1 /* 2 * Copyright (C) 2017 The Android Open Source Project 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 #define _GNU_SOURCE 17 18 #include <stdio.h> 19 #include <string.h> 20 #include <sys/types.h> 21 #include <sys/wait.h> 22 #include <sys/stat.h> 23 #include <sys/ioctl.h> 24 #include <fcntl.h> 25 #include <errno.h> 26 #include <sys/time.h> 27 #include <sys/mman.h> 28 29 typedef int __bitwise snd_ctl_elem_iface_t; 30 31 struct snd_ctl_elem_id { 32 unsigned int numid; 33 snd_ctl_elem_iface_t iface; 34 unsigned int device; 35 unsigned int subdevice; 36 unsigned char name[44]; 37 unsigned int index; 38 }; 39 40 struct snd_aes_iec958 { 41 unsigned char status[24]; 42 unsigned char subcode[147]; 43 unsigned char pad; 44 unsigned char dig_subframe[4]; 45 }; 46 47 struct snd_ctl_elem_value { 48 struct snd_ctl_elem_id id; 49 unsigned int indirect: 1; 50 union { 51 union { 52 long value[128]; 53 long *value_ptr; 54 } integer; 55 union { 56 long long value[64]; 57 long long *value_ptr; 58 } integer64; 59 union { 60 unsigned int item[128]; 61 unsigned int *item_ptr; 62 } enumerated; 63 union { 64 unsigned char data[512]; 65 unsigned char *data_ptr; 66 } bytes; 67 struct snd_aes_iec958 iec958; 68 } value; 69 struct timespec tstamp; 70 unsigned char reserved[128-sizeof(struct timespec)]; 71 }; 72 main()73int main() 74 { 75 int fd; 76 int ret; 77 void *map; 78 struct snd_ctl_elem_value arg; 79 80 fd = open("/dev/snd/controlC0", O_RDWR); 81 if(fd < 0){ 82 return -1; 83 } 84 85 arg.id.numid = 148; 86 arg.value.enumerated.item[0] = 528; 87 88 ret = ioctl(fd,0xc4c85513,&arg); 89 if(ret < 0){ 90 return -1; 91 } 92 93 return 0; 94 } 95