Commit | Line | Data |
---|---|---|
d927fdae | 1 | /* |
a4b12990 | 2 | * sst_mfld_platform.h - Intel MID Platform driver header file |
d927fdae VK |
3 | * |
4 | * Copyright (C) 2010 Intel Corp | |
5 | * Author: Vinod Koul <vinod.koul@intel.com> | |
6 | * Author: Harsha Priya <priya.harsha@intel.com> | |
7 | * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ | |
8 | * | |
9 | * This program is free software; you can redistribute it and/or modify | |
10 | * it under the terms of the GNU General Public License as published by | |
11 | * the Free Software Foundation; version 2 of the License. | |
12 | * | |
13 | * This program is distributed in the hope that it will be useful, but | |
14 | * WITHOUT ANY WARRANTY; without even the implied warranty of | |
15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | |
16 | * General Public License for more details. | |
17 | * | |
d927fdae | 18 | * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ |
d927fdae VK |
19 | */ |
20 | ||
21 | #ifndef __SST_PLATFORMDRV_H__ | |
22 | #define __SST_PLATFORMDRV_H__ | |
23 | ||
a4b12990 | 24 | #include "sst-mfld-dsp.h" |
5749d70e | 25 | #include "sst-atom-controls.h" |
c514a911 | 26 | |
4b68b4e1 | 27 | extern struct sst_device *sst; |
47a7bfc2 | 28 | extern struct snd_compr_ops sst_platform_compr_ops; |
4b68b4e1 | 29 | |
d927fdae VK |
30 | #define SST_MONO 1 |
31 | #define SST_STEREO 2 | |
32 | #define SST_MAX_CAP 5 | |
33 | ||
d927fdae VK |
34 | #define SST_MAX_BUFFER (800*1024) |
35 | #define SST_MIN_BUFFER (800*1024) | |
36 | #define SST_MIN_PERIOD_BYTES 32 | |
37 | #define SST_MAX_PERIOD_BYTES SST_MAX_BUFFER | |
38 | #define SST_MIN_PERIODS 2 | |
39 | #define SST_MAX_PERIODS (1024*2) | |
40 | #define SST_FIFO_SIZE 0 | |
d927fdae | 41 | |
03c33042 VK |
42 | struct pcm_stream_info { |
43 | int str_id; | |
9daa5bd3 VK |
44 | void *arg; |
45 | void (*period_elapsed) (void *arg); | |
03c33042 | 46 | unsigned long long buffer_ptr; |
2a635825 | 47 | unsigned long long pcm_delay; |
03c33042 | 48 | int sfreq; |
d927fdae VK |
49 | }; |
50 | ||
51 | enum sst_drv_status { | |
52 | SST_PLATFORM_INIT = 1, | |
53 | SST_PLATFORM_STARTED, | |
54 | SST_PLATFORM_RUNNING, | |
55 | SST_PLATFORM_PAUSED, | |
56 | SST_PLATFORM_DROPPED, | |
57 | }; | |
58 | ||
03c33042 VK |
59 | enum sst_stream_ops { |
60 | STREAM_OPS_PLAYBACK = 0, | |
61 | STREAM_OPS_CAPTURE, | |
62 | }; | |
63 | ||
64 | enum sst_audio_device_type { | |
65 | SND_SST_DEVICE_HEADSET = 1, | |
66 | SND_SST_DEVICE_IHF, | |
67 | SND_SST_DEVICE_VIBRA, | |
68 | SND_SST_DEVICE_HAPTIC, | |
69 | SND_SST_DEVICE_CAPTURE, | |
c514a911 | 70 | SND_SST_DEVICE_COMPRESS, |
03c33042 VK |
71 | }; |
72 | ||
73 | /* PCM Parameters */ | |
74 | struct sst_pcm_params { | |
75 | u16 codec; /* codec type */ | |
76 | u8 num_chan; /* 1=Mono, 2=Stereo */ | |
77 | u8 pcm_wd_sz; /* 16/24 - bit*/ | |
78 | u32 reserved; /* Bitrate in bits per second */ | |
79 | u32 sfreq; /* Sampling rate in Hz */ | |
80 | u32 ring_buffer_size; | |
81 | u32 period_count; /* period elapsed in samples*/ | |
82 | u32 ring_buffer_addr; | |
83 | }; | |
84 | ||
85 | struct sst_stream_params { | |
86 | u32 result; | |
87 | u32 stream_id; | |
88 | u8 codec; | |
89 | u8 ops; | |
90 | u8 stream_type; | |
91 | u8 device_type; | |
92 | struct sst_pcm_params sparams; | |
93 | }; | |
94 | ||
c514a911 VK |
95 | struct sst_compress_cb { |
96 | void *param; | |
97 | void (*compr_cb)(void *param); | |
bd17aa45 VK |
98 | void *drain_cb_param; |
99 | void (*drain_notify)(void *param); | |
c514a911 VK |
100 | }; |
101 | ||
102 | struct compress_sst_ops { | |
103 | const char *name; | |
06cb1eb3 SP |
104 | int (*open)(struct device *dev, |
105 | struct snd_sst_params *str_params, struct sst_compress_cb *cb); | |
106 | int (*stream_start)(struct device *dev, unsigned int str_id); | |
107 | int (*stream_drop)(struct device *dev, unsigned int str_id); | |
108 | int (*stream_drain)(struct device *dev, unsigned int str_id); | |
109 | int (*stream_partial_drain)(struct device *dev, unsigned int str_id); | |
110 | int (*stream_pause)(struct device *dev, unsigned int str_id); | |
111 | int (*stream_pause_release)(struct device *dev, unsigned int str_id); | |
112 | ||
113 | int (*tstamp)(struct device *dev, unsigned int str_id, | |
114 | struct snd_compr_tstamp *tstamp); | |
115 | int (*ack)(struct device *dev, unsigned int str_id, | |
116 | unsigned long bytes); | |
117 | int (*close)(struct device *dev, unsigned int str_id); | |
118 | int (*get_caps)(struct snd_compr_caps *caps); | |
119 | int (*get_codec_caps)(struct snd_compr_codec_caps *codec); | |
120 | int (*set_metadata)(struct device *dev, unsigned int str_id, | |
0cd5751a | 121 | struct snd_compr_metadata *mdata); |
fdcc4a03 | 122 | int (*power)(struct device *dev, bool state); |
c514a911 VK |
123 | }; |
124 | ||
03c33042 | 125 | struct sst_ops { |
0121327c VK |
126 | int (*open)(struct device *dev, struct snd_sst_params *str_param); |
127 | int (*stream_init)(struct device *dev, struct pcm_stream_info *str_info); | |
128 | int (*stream_start)(struct device *dev, int str_id); | |
129 | int (*stream_drop)(struct device *dev, int str_id); | |
130 | int (*stream_pause)(struct device *dev, int str_id); | |
131 | int (*stream_pause_release)(struct device *dev, int str_id); | |
132 | int (*stream_read_tstamp)(struct device *dev, struct pcm_stream_info *str_info); | |
b12b087c | 133 | int (*send_byte_stream)(struct device *dev, struct snd_sst_bytes_v2 *bytes); |
0121327c VK |
134 | int (*close)(struct device *dev, unsigned int str_id); |
135 | int (*power)(struct device *dev, bool state); | |
03c33042 VK |
136 | }; |
137 | ||
138 | struct sst_runtime_stream { | |
139 | int stream_status; | |
c514a911 VK |
140 | unsigned int id; |
141 | size_t bytes_written; | |
03c33042 VK |
142 | struct pcm_stream_info stream_info; |
143 | struct sst_ops *ops; | |
c514a911 | 144 | struct compress_sst_ops *compr_ops; |
03c33042 VK |
145 | spinlock_t status_lock; |
146 | }; | |
147 | ||
148 | struct sst_device { | |
149 | char *name; | |
150 | struct device *dev; | |
151 | struct sst_ops *ops; | |
61b165ca | 152 | struct platform_device *pdev; |
c514a911 | 153 | struct compress_sst_ops *compr_ops; |
03c33042 VK |
154 | }; |
155 | ||
61b165ca | 156 | struct sst_data; |
d8499c9b VK |
157 | |
158 | int sst_dsp_init_v2_dpcm(struct snd_soc_platform *platform); | |
e4f5ccd0 VK |
159 | int sst_send_pipe_gains(struct snd_soc_dai *dai, int stream, int mute); |
160 | int send_ssp_cmd(struct snd_soc_dai *dai, const char *id, bool enable); | |
161 | int sst_handle_vb_timer(struct snd_soc_dai *dai, bool enable); | |
162 | ||
4496ffab | 163 | void sst_set_stream_status(struct sst_runtime_stream *stream, int state); |
0ec66fed VK |
164 | int sst_fill_stream_params(void *substream, const struct sst_data *ctx, |
165 | struct snd_sst_params *str_params, bool is_compress); | |
166 | ||
61b165ca VK |
167 | struct sst_algo_int_control_v2 { |
168 | struct soc_mixer_control mc; | |
169 | u16 module_id; /* module identifieer */ | |
170 | u16 pipe_id; /* location info: pipe_id + instance_id */ | |
171 | u16 instance_id; | |
172 | unsigned int value; /* Value received is stored here */ | |
173 | }; | |
61b165ca VK |
174 | struct sst_data { |
175 | struct platform_device *pdev; | |
176 | struct sst_platform_data *pdata; | |
10615a5c | 177 | struct snd_sst_bytes_v2 *byte_stream; |
61b165ca | 178 | struct mutex lock; |
54e6becc | 179 | struct snd_soc_card *soc_card; |
5749d70e | 180 | struct sst_cmd_sba_hw_set_ssp ssp_cmd; |
61b165ca | 181 | }; |
03c33042 VK |
182 | int sst_register_dsp(struct sst_device *sst); |
183 | int sst_unregister_dsp(struct sst_device *sst); | |
d927fdae | 184 | #endif |