blob: 6c6a42c08e2410b90a898d2e9d77730a4bf7721f [file] [log] [blame]
Vinod Kould927fda2011-01-04 20:16:32 +05301/*
Mark Browna4b12992014-03-12 23:04:35 +00002 * sst_mfld_platform.h - Intel MID Platform driver header file
Vinod Kould927fda2011-01-04 20:16:32 +05303 *
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 *
Vinod Kould927fda2011-01-04 20:16:32 +053018 * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Vinod Kould927fda2011-01-04 20:16:32 +053019 */
20
21#ifndef __SST_PLATFORMDRV_H__
22#define __SST_PLATFORMDRV_H__
23
Mark Browna4b12992014-03-12 23:04:35 +000024#include "sst-mfld-dsp.h"
Vinod Koulc514a912012-08-16 17:10:42 +053025
Vinod Koul4b68b4e2014-05-05 14:27:50 +053026extern struct sst_device *sst;
27
Vinod Kould927fda2011-01-04 20:16:32 +053028#define SST_MONO 1
29#define SST_STEREO 2
30#define SST_MAX_CAP 5
31
Vinod Kould927fda2011-01-04 20:16:32 +053032#define SST_MAX_BUFFER (800*1024)
33#define SST_MIN_BUFFER (800*1024)
34#define SST_MIN_PERIOD_BYTES 32
35#define SST_MAX_PERIOD_BYTES SST_MAX_BUFFER
36#define SST_MIN_PERIODS 2
37#define SST_MAX_PERIODS (1024*2)
38#define SST_FIFO_SIZE 0
Vinod Kould927fda2011-01-04 20:16:32 +053039
Vinod Koul03c33042011-12-05 19:13:41 +053040struct pcm_stream_info {
41 int str_id;
Vinod Koul9daa5bd2014-06-13 18:03:52 +053042 void *arg;
43 void (*period_elapsed) (void *arg);
Vinod Koul03c33042011-12-05 19:13:41 +053044 unsigned long long buffer_ptr;
Vinod Koul2a635822014-06-13 18:03:53 +053045 unsigned long long pcm_delay;
Vinod Koul03c33042011-12-05 19:13:41 +053046 int sfreq;
Vinod Kould927fda2011-01-04 20:16:32 +053047};
48
49enum sst_drv_status {
50 SST_PLATFORM_INIT = 1,
51 SST_PLATFORM_STARTED,
52 SST_PLATFORM_RUNNING,
53 SST_PLATFORM_PAUSED,
54 SST_PLATFORM_DROPPED,
55};
56
Vinod Koul03c33042011-12-05 19:13:41 +053057enum sst_controls {
58 SST_SND_ALLOC = 0x00,
59 SST_SND_PAUSE = 0x01,
60 SST_SND_RESUME = 0x02,
61 SST_SND_DROP = 0x03,
62 SST_SND_FREE = 0x04,
63 SST_SND_BUFFER_POINTER = 0x05,
64 SST_SND_STREAM_INIT = 0x06,
65 SST_SND_START = 0x07,
Vinod Koule310fb92014-07-09 14:57:51 +053066 SST_SET_BYTE_STREAM = 0x100A,
67 SST_GET_BYTE_STREAM = 0x100B,
68 SST_MAX_CONTROLS = SST_GET_BYTE_STREAM,
Vinod Koul03c33042011-12-05 19:13:41 +053069};
70
71enum sst_stream_ops {
72 STREAM_OPS_PLAYBACK = 0,
73 STREAM_OPS_CAPTURE,
74};
75
76enum sst_audio_device_type {
77 SND_SST_DEVICE_HEADSET = 1,
78 SND_SST_DEVICE_IHF,
79 SND_SST_DEVICE_VIBRA,
80 SND_SST_DEVICE_HAPTIC,
81 SND_SST_DEVICE_CAPTURE,
Vinod Koulc514a912012-08-16 17:10:42 +053082 SND_SST_DEVICE_COMPRESS,
Vinod Koul03c33042011-12-05 19:13:41 +053083};
84
85/* PCM Parameters */
86struct sst_pcm_params {
87 u16 codec; /* codec type */
88 u8 num_chan; /* 1=Mono, 2=Stereo */
89 u8 pcm_wd_sz; /* 16/24 - bit*/
90 u32 reserved; /* Bitrate in bits per second */
91 u32 sfreq; /* Sampling rate in Hz */
92 u32 ring_buffer_size;
93 u32 period_count; /* period elapsed in samples*/
94 u32 ring_buffer_addr;
95};
96
97struct sst_stream_params {
98 u32 result;
99 u32 stream_id;
100 u8 codec;
101 u8 ops;
102 u8 stream_type;
103 u8 device_type;
104 struct sst_pcm_params sparams;
105};
106
Vinod Koulc514a912012-08-16 17:10:42 +0530107struct sst_compress_cb {
108 void *param;
109 void (*compr_cb)(void *param);
Vinod Koulbd17aa42014-05-15 21:38:16 +0530110 void *drain_cb_param;
111 void (*drain_notify)(void *param);
Vinod Koulc514a912012-08-16 17:10:42 +0530112};
113
114struct compress_sst_ops {
115 const char *name;
116 int (*open) (struct snd_sst_params *str_params,
117 struct sst_compress_cb *cb);
118 int (*control) (unsigned int cmd, unsigned int str_id);
119 int (*tstamp) (unsigned int str_id, struct snd_compr_tstamp *tstamp);
120 int (*ack) (unsigned int str_id, unsigned long bytes);
121 int (*close) (unsigned int str_id);
122 int (*get_caps) (struct snd_compr_caps *caps);
123 int (*get_codec_caps) (struct snd_compr_codec_caps *codec);
Vinod Koul0cd57512013-03-29 23:41:42 +0530124 int (*set_metadata) (unsigned int str_id,
125 struct snd_compr_metadata *mdata);
Vinod Koulc514a912012-08-16 17:10:42 +0530126
127};
128
Vinod Koul03c33042011-12-05 19:13:41 +0530129struct sst_ops {
Vinod Koula870cdc2014-06-13 18:03:55 +0530130 int (*open) (struct snd_sst_params *str_param);
Vinod Koul03c33042011-12-05 19:13:41 +0530131 int (*device_control) (int cmd, void *arg);
Vinod Koule310fb92014-07-09 14:57:51 +0530132 int (*set_generic_params)(enum sst_controls cmd, void *arg);
Vinod Koul03c33042011-12-05 19:13:41 +0530133 int (*close) (unsigned int str_id);
134};
135
136struct sst_runtime_stream {
137 int stream_status;
Vinod Koulc514a912012-08-16 17:10:42 +0530138 unsigned int id;
139 size_t bytes_written;
Vinod Koul03c33042011-12-05 19:13:41 +0530140 struct pcm_stream_info stream_info;
141 struct sst_ops *ops;
Vinod Koulc514a912012-08-16 17:10:42 +0530142 struct compress_sst_ops *compr_ops;
Vinod Koul03c33042011-12-05 19:13:41 +0530143 spinlock_t status_lock;
144};
145
146struct sst_device {
147 char *name;
148 struct device *dev;
149 struct sst_ops *ops;
Vinod Koul61b165c2014-06-13 18:03:56 +0530150 struct platform_device *pdev;
Vinod Koulc514a912012-08-16 17:10:42 +0530151 struct compress_sst_ops *compr_ops;
Vinod Koul03c33042011-12-05 19:13:41 +0530152};
153
Vinod Koul61b165c2014-06-13 18:03:56 +0530154struct sst_data;
Vinod Koul4496ffa2014-05-05 14:27:49 +0530155void sst_set_stream_status(struct sst_runtime_stream *stream, int state);
Vinod Koul0ec66fe2014-06-13 18:03:57 +0530156int sst_fill_stream_params(void *substream, const struct sst_data *ctx,
157 struct snd_sst_params *str_params, bool is_compress);
158
Vinod Koul61b165c2014-06-13 18:03:56 +0530159struct sst_algo_int_control_v2 {
160 struct soc_mixer_control mc;
161 u16 module_id; /* module identifieer */
162 u16 pipe_id; /* location info: pipe_id + instance_id */
163 u16 instance_id;
164 unsigned int value; /* Value received is stored here */
165};
Vinod Koul61b165c2014-06-13 18:03:56 +0530166struct sst_data {
167 struct platform_device *pdev;
168 struct sst_platform_data *pdata;
169 struct mutex lock;
170};
Vinod Koul03c33042011-12-05 19:13:41 +0530171int sst_register_dsp(struct sst_device *sst);
172int sst_unregister_dsp(struct sst_device *sst);
Vinod Kould927fda2011-01-04 20:16:32 +0530173#endif