forked from thesofproject/sof
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathfile.h
More file actions
88 lines (72 loc) · 2.02 KB
/
file.h
File metadata and controls
88 lines (72 loc) · 2.02 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
/* SPDX-License-Identifier: BSD-3-Clause
*
* Copyright(c) 2018 Intel Corporation. All rights reserved.
*
* Author: Seppo Ingalsuo <seppo.ingalsuo@linux.intel.com>
* Liam Girdwood <liam.r.girdwood@linux.intel.com>
* Keyon Jie <yang.jie@linux.intel.com>
* Ranjani Sridharan <ranjani.sridharan@linux.intel.com>
*/
#ifndef _TESTBENCH_FILE_H
#define _TESTBENCH_FILE_H
#include <stdint.h>
#define FILE_MAX_COPIES_TIMEOUT 3
/**< Convert with right shift a bytes count to samples count */
#define FILE_BYTES_TO_S16_SAMPLES(s) ((s) >> 1)
#define FILE_BYTES_TO_S32_SAMPLES(s) ((s) >> 2)
/* bfc7488c-75aa-4ce8-9dbed8da08a698c2 */
static const struct sof_uuid tb_file_uuid = {
0xbfc7488c, 0x75aa, 0x4ce8, {0x9d, 0xbe, 0xd8, 0xda, 0x08, 0xa6, 0x98, 0xc2}
};
/* file component modes */
enum file_mode {
FILE_READ = 0,
FILE_WRITE,
FILE_DUPLEX,
};
enum file_format {
FILE_TEXT = 0,
FILE_RAW,
};
/* file component state */
struct file_state {
uint64_t cycles_count;
FILE *rfh, *wfh; /* read/write file handle */
char *fn;
int copy_count;
int channels;
int rate;
int n;
enum file_mode mode;
enum file_format f_format;
bool reached_eof;
bool write_failed;
bool copy_timeout;
};
struct file_comp_data;
/* file comp data */
struct file_comp_data {
struct file_state fs;
enum sof_ipc_frame frame_fmt;
int sample_container_bytes;
int (*file_func)(struct file_comp_data *cd, struct audio_stream *sink,
struct audio_stream *source, uint32_t frames);
/* maximum limits */
int max_samples;
int max_copies;
int max_frames;
int copies_timeout_count;
};
void sys_comp_module_file_interface_init(void);
/* Get file comp data from copier data */
static inline struct file_comp_data *get_file_comp_data(struct copier_data *ccd)
{
struct file_comp_data *cd = (struct file_comp_data *)ccd->ipcgtw_data;
return cd;
}
/* Set file comp data to copier data */
static inline void file_set_comp_data(struct copier_data *ccd, struct file_comp_data *cd)
{
ccd->ipcgtw_data = (struct ipcgtw_data *)cd;
}
#endif /* _TESTBENCH_FILE */