]> git.karo-electronics.de Git - linux-beck.git/blob - sound/soc/intel/atom/sst-mfld-platform.h
Merge tag 'edac/v4.2-1' of git://git.kernel.org/pub/scm/linux/kernel/git/mchehab...
[linux-beck.git] / sound / soc / intel / atom / sst-mfld-platform.h
1 /*
2  *  sst_mfld_platform.h - Intel MID Platform driver header file
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  *
18  * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
19  */
20
21 #ifndef __SST_PLATFORMDRV_H__
22 #define __SST_PLATFORMDRV_H__
23
24 #include "sst-mfld-dsp.h"
25 #include "sst-atom-controls.h"
26
27 extern struct sst_device *sst;
28
29 #define SST_MONO                1
30 #define SST_STEREO              2
31 #define SST_MAX_CAP             5
32
33 #define SST_MAX_BUFFER          (800*1024)
34 #define SST_MIN_BUFFER          (800*1024)
35 #define SST_MIN_PERIOD_BYTES    32
36 #define SST_MAX_PERIOD_BYTES    SST_MAX_BUFFER
37 #define SST_MIN_PERIODS         2
38 #define SST_MAX_PERIODS         (1024*2)
39 #define SST_FIFO_SIZE           0
40
41 struct pcm_stream_info {
42         int str_id;
43         void *arg;
44         void (*period_elapsed) (void *arg);
45         unsigned long long buffer_ptr;
46         unsigned long long pcm_delay;
47         int sfreq;
48 };
49
50 enum sst_drv_status {
51         SST_PLATFORM_INIT = 1,
52         SST_PLATFORM_STARTED,
53         SST_PLATFORM_RUNNING,
54         SST_PLATFORM_PAUSED,
55         SST_PLATFORM_DROPPED,
56 };
57
58 enum sst_stream_ops {
59         STREAM_OPS_PLAYBACK = 0,
60         STREAM_OPS_CAPTURE,
61 };
62
63 enum sst_audio_device_type {
64         SND_SST_DEVICE_HEADSET = 1,
65         SND_SST_DEVICE_IHF,
66         SND_SST_DEVICE_VIBRA,
67         SND_SST_DEVICE_HAPTIC,
68         SND_SST_DEVICE_CAPTURE,
69         SND_SST_DEVICE_COMPRESS,
70 };
71
72 /* PCM Parameters */
73 struct sst_pcm_params {
74         u16 codec;      /* codec type */
75         u8 num_chan;    /* 1=Mono, 2=Stereo */
76         u8 pcm_wd_sz;   /* 16/24 - bit*/
77         u32 reserved;   /* Bitrate in bits per second */
78         u32 sfreq;      /* Sampling rate in Hz */
79         u32 ring_buffer_size;
80         u32 period_count;       /* period elapsed in samples*/
81         u32 ring_buffer_addr;
82 };
83
84 struct sst_stream_params {
85         u32 result;
86         u32 stream_id;
87         u8 codec;
88         u8 ops;
89         u8 stream_type;
90         u8 device_type;
91         struct sst_pcm_params sparams;
92 };
93
94 struct sst_compress_cb {
95         void *param;
96         void (*compr_cb)(void *param);
97         void *drain_cb_param;
98         void (*drain_notify)(void *param);
99 };
100
101 struct compress_sst_ops {
102         const char *name;
103         int (*open)(struct device *dev,
104                 struct snd_sst_params *str_params, struct sst_compress_cb *cb);
105         int (*stream_start)(struct device *dev, unsigned int str_id);
106         int (*stream_drop)(struct device *dev, unsigned int str_id);
107         int (*stream_drain)(struct device *dev, unsigned int str_id);
108         int (*stream_partial_drain)(struct device *dev, unsigned int str_id);
109         int (*stream_pause)(struct device *dev, unsigned int str_id);
110         int (*stream_pause_release)(struct device *dev, unsigned int str_id);
111
112         int (*tstamp)(struct device *dev, unsigned int str_id,
113                         struct snd_compr_tstamp *tstamp);
114         int (*ack)(struct device *dev, unsigned int str_id,
115                         unsigned long bytes);
116         int (*close)(struct device *dev, unsigned int str_id);
117         int (*get_caps)(struct snd_compr_caps *caps);
118         int (*get_codec_caps)(struct snd_compr_codec_caps *codec);
119         int (*set_metadata)(struct device *dev, unsigned int str_id,
120                         struct snd_compr_metadata *mdata);
121         int (*power)(struct device *dev, bool state);
122 };
123
124 struct sst_ops {
125         int (*open)(struct device *dev, struct snd_sst_params *str_param);
126         int (*stream_init)(struct device *dev, struct pcm_stream_info *str_info);
127         int (*stream_start)(struct device *dev, int str_id);
128         int (*stream_drop)(struct device *dev, int str_id);
129         int (*stream_pause)(struct device *dev, int str_id);
130         int (*stream_pause_release)(struct device *dev, int str_id);
131         int (*stream_read_tstamp)(struct device *dev, struct pcm_stream_info *str_info);
132         int (*send_byte_stream)(struct device *dev, struct snd_sst_bytes_v2 *bytes);
133         int (*close)(struct device *dev, unsigned int str_id);
134         int (*power)(struct device *dev, bool state);
135 };
136
137 struct sst_runtime_stream {
138         int     stream_status;
139         unsigned int id;
140         size_t bytes_written;
141         struct pcm_stream_info stream_info;
142         struct sst_ops *ops;
143         struct compress_sst_ops *compr_ops;
144         spinlock_t      status_lock;
145 };
146
147 struct sst_device {
148         char *name;
149         struct device *dev;
150         struct sst_ops *ops;
151         struct platform_device *pdev;
152         struct compress_sst_ops *compr_ops;
153 };
154
155 struct sst_data;
156
157 int sst_dsp_init_v2_dpcm(struct snd_soc_platform *platform);
158 int sst_send_pipe_gains(struct snd_soc_dai *dai, int stream, int mute);
159 int send_ssp_cmd(struct snd_soc_dai *dai, const char *id, bool enable);
160 int sst_handle_vb_timer(struct snd_soc_dai *dai, bool enable);
161
162 void sst_set_stream_status(struct sst_runtime_stream *stream, int state);
163 int sst_fill_stream_params(void *substream, const struct sst_data *ctx,
164                            struct snd_sst_params *str_params, bool is_compress);
165
166 struct sst_algo_int_control_v2 {
167         struct soc_mixer_control mc;
168         u16 module_id; /* module identifieer */
169         u16 pipe_id; /* location info: pipe_id + instance_id */
170         u16 instance_id;
171         unsigned int value; /* Value received is stored here */
172 };
173 struct sst_data {
174         struct platform_device *pdev;
175         struct sst_platform_data *pdata;
176         struct snd_sst_bytes_v2 *byte_stream;
177         struct mutex lock;
178         struct snd_soc_card *soc_card;
179         struct sst_cmd_sba_hw_set_ssp ssp_cmd;
180 };
181 int sst_register_dsp(struct sst_device *sst);
182 int sst_unregister_dsp(struct sst_device *sst);
183 #endif