]>
Commit | Line | Data |
---|---|---|
8cc72361 WYC |
1 | /** |
2 | * Copyright (C) 2008, Creative Technology Ltd. All Rights Reserved. | |
3 | * | |
4 | * This source file is released under GPL v2 license (no other versions). | |
5 | * See the COPYING file included in the main directory of this source | |
6 | * distribution for the license terms and conditions. | |
7 | * | |
8 | * @File ctsrc.h | |
9 | * | |
10 | * @Brief | |
11 | * This file contains the definition of the Sample Rate Convertor | |
12 | * resource management object. | |
13 | * | |
14 | * @Author Liu Chun | |
15 | * @Date May 13 2008 | |
16 | * | |
17 | */ | |
18 | ||
19 | #ifndef CTSRC_H | |
20 | #define CTSRC_H | |
21 | ||
22 | #include "ctresource.h" | |
23 | #include "ctimap.h" | |
24 | #include <linux/spinlock.h> | |
25 | #include <linux/list.h> | |
26 | ||
27 | #define SRC_STATE_OFF 0x0 | |
28 | #define SRC_STATE_INIT 0x4 | |
29 | #define SRC_STATE_RUN 0x5 | |
30 | ||
31 | #define SRC_SF_U8 0x0 | |
32 | #define SRC_SF_S16 0x1 | |
33 | #define SRC_SF_S24 0x2 | |
34 | #define SRC_SF_S32 0x3 | |
35 | #define SRC_SF_F32 0x4 | |
36 | ||
37 | /* Define the descriptor of a src resource */ | |
38 | enum SRCMODE { | |
39 | MEMRD, /* Read data from host memory */ | |
40 | MEMWR, /* Write data to host memory */ | |
41 | ARCRW, /* Read from and write to audio ring channel */ | |
42 | NUM_SRCMODES | |
43 | }; | |
44 | ||
45 | struct src_rsc_ops; | |
46 | ||
47 | struct src { | |
48 | struct rsc rsc; /* Basic resource info */ | |
49 | struct src *intlv; /* Pointer to next interleaved SRC in a series */ | |
50 | struct src_rsc_ops *ops; /* SRC specific operations */ | |
51 | /* Number of contiguous srcs for interleaved usage */ | |
52 | unsigned char multi; | |
53 | unsigned char mode; /* Working mode of this SRC resource */ | |
54 | }; | |
55 | ||
56 | struct src_rsc_ops { | |
57 | int (*set_state)(struct src *src, unsigned int state); | |
58 | int (*set_bm)(struct src *src, unsigned int bm); | |
59 | int (*set_sf)(struct src *src, unsigned int sf); | |
60 | int (*set_pm)(struct src *src, unsigned int pm); | |
61 | int (*set_rom)(struct src *src, unsigned int rom); | |
62 | int (*set_vo)(struct src *src, unsigned int vo); | |
63 | int (*set_st)(struct src *src, unsigned int st); | |
64 | int (*set_bp)(struct src *src, unsigned int bp); | |
65 | int (*set_cisz)(struct src *src, unsigned int cisz); | |
66 | int (*set_ca)(struct src *src, unsigned int ca); | |
67 | int (*set_sa)(struct src *src, unsigned int sa); | |
68 | int (*set_la)(struct src *src, unsigned int la); | |
69 | int (*set_pitch)(struct src *src, unsigned int pitch); | |
70 | int (*set_clr_zbufs)(struct src *src); | |
71 | int (*commit_write)(struct src *src); | |
72 | int (*get_ca)(struct src *src); | |
73 | int (*init)(struct src *src); | |
74 | struct src* (*next_interleave)(struct src *src); | |
75 | }; | |
76 | ||
77 | /* Define src resource request description info */ | |
78 | struct src_desc { | |
79 | /* Number of contiguous master srcs for interleaved usage */ | |
80 | unsigned char multi; | |
81 | unsigned char msr; | |
82 | unsigned char mode; /* Working mode of the requested srcs */ | |
83 | }; | |
84 | ||
85 | /* Define src manager object */ | |
86 | struct src_mgr { | |
87 | struct rsc_mgr mgr; /* Basic resource manager info */ | |
88 | spinlock_t mgr_lock; | |
89 | ||
90 | /* request src resource */ | |
91 | int (*get_src)(struct src_mgr *mgr, | |
92 | const struct src_desc *desc, struct src **rsrc); | |
93 | /* return src resource */ | |
94 | int (*put_src)(struct src_mgr *mgr, struct src *src); | |
95 | int (*src_enable_s)(struct src_mgr *mgr, struct src *src); | |
96 | int (*src_enable)(struct src_mgr *mgr, struct src *src); | |
97 | int (*src_disable)(struct src_mgr *mgr, struct src *src); | |
98 | int (*commit_write)(struct src_mgr *mgr); | |
99 | }; | |
100 | ||
101 | /* Define the descriptor of a SRC Input Mapper resource */ | |
102 | struct srcimp_mgr; | |
103 | struct srcimp_rsc_ops; | |
104 | ||
105 | struct srcimp { | |
106 | struct rsc rsc; | |
107 | unsigned char idx[8]; | |
108 | struct imapper *imappers; | |
109 | unsigned int mapped; /* A bit-map indicating which conj rsc is mapped */ | |
110 | struct srcimp_mgr *mgr; | |
111 | struct srcimp_rsc_ops *ops; | |
112 | }; | |
113 | ||
114 | struct srcimp_rsc_ops { | |
115 | int (*map)(struct srcimp *srcimp, struct src *user, struct rsc *input); | |
116 | int (*unmap)(struct srcimp *srcimp); | |
117 | }; | |
118 | ||
119 | /* Define SRCIMP resource request description info */ | |
120 | struct srcimp_desc { | |
121 | unsigned int msr; | |
122 | }; | |
123 | ||
124 | struct srcimp_mgr { | |
125 | struct rsc_mgr mgr; /* Basic resource manager info */ | |
126 | spinlock_t mgr_lock; | |
127 | spinlock_t imap_lock; | |
128 | struct list_head imappers; | |
129 | struct imapper *init_imap; | |
130 | unsigned int init_imap_added; | |
131 | ||
132 | /* request srcimp resource */ | |
133 | int (*get_srcimp)(struct srcimp_mgr *mgr, | |
134 | const struct srcimp_desc *desc, | |
135 | struct srcimp **rsrcimp); | |
136 | /* return srcimp resource */ | |
137 | int (*put_srcimp)(struct srcimp_mgr *mgr, struct srcimp *srcimp); | |
138 | int (*imap_add)(struct srcimp_mgr *mgr, struct imapper *entry); | |
139 | int (*imap_delete)(struct srcimp_mgr *mgr, struct imapper *entry); | |
140 | }; | |
141 | ||
142 | /* Constructor and destructor of SRC resource manager */ | |
143 | int src_mgr_create(void *hw, struct src_mgr **rsrc_mgr); | |
144 | int src_mgr_destroy(struct src_mgr *src_mgr); | |
145 | /* Constructor and destructor of SRCIMP resource manager */ | |
146 | int srcimp_mgr_create(void *hw, struct srcimp_mgr **rsrc_mgr); | |
147 | int srcimp_mgr_destroy(struct srcimp_mgr *srcimp_mgr); | |
148 | ||
149 | #endif /* CTSRC_H */ |