blob: 5e1fcd8ab0790b21f24074c6db995f09429a3818 [file] [log] [blame]
Niranjan Yadla88a93e42017-08-29 15:22:40 -07001/*
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
17#define LOG_TAG "debug-hifi"
18#include <errno.h>
19#include <fcntl.h>
20#include <unistd.h>
21#include <poll.h>
22#include <pthread.h>
23#include <sys/ioctl.h>
24#include <sys/prctl.h>
25#include <stdio.h>
26#include <cutils/log.h>
27#include <cutils/uevent.h>
28#include <stdlib.h>
29#include <linux/audio_hifi.h>
30
31int main(int argc, char *argv[])
32{
33 char *buffer;
34 int hifi_dsp_fd;
35 int ret = -1;
36 int i = 0;
37 unsigned int memsize = DRV_DSP_UART_TO_MEM_SIZE;
38 unsigned int clear = 0;
39 struct misc_io_dump_buf_param dump_buf;
40
41 ALOGI("Enter hifi-dsp Audio Framework - sample application\n");
42 if (argc > 1)
43 memsize = strtoul(argv[1], NULL, 0);
44 if (argc > 2)
45 clear = 1;
46 hifi_dsp_fd = open(HIFI_DSP_MISC_DRIVER, O_RDWR, 0);
47 if (hifi_dsp_fd < 0) {
48 ALOGE("Error %d opening hifi dsp device", errno);
49 return ret;
50 }
51 buffer = malloc(memsize);
52 if (!buffer) {
53 ALOGE("Error allocating buffer");
54 goto out0;
55 }
56 dump_buf.user_buf = (uint64_t)buffer;
57 dump_buf.buf_size = memsize;
58 dump_buf.clear = clear;
59 ret = ioctl(hifi_dsp_fd, HIFI_MISC_IOCTL_DISPLAY_MSG, &dump_buf);
60 if (ret) {
61 ALOGE("Error %d accessing message buffer", errno);
62 } else {
63 printf("%s\n", buffer);
64 }
65 free(buffer);
66out0:
67 close(hifi_dsp_fd);
68 ALOGI("Exit hifi-dsp Audio Framework - sample application\n");
69 return ret;
70}