blob: 3ea4fee0ba0d385c7b499f38e9964c554db6e486 [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;
42 void *mad_substream;
43 void (*period_elapsed) (void *mad_substream);
44 unsigned long long buffer_ptr;
45 int sfreq;
Vinod Kould927fda2011-01-04 20:16:32 +053046};
47
48enum sst_drv_status {
49 SST_PLATFORM_INIT = 1,
50 SST_PLATFORM_STARTED,
51 SST_PLATFORM_RUNNING,
52 SST_PLATFORM_PAUSED,
53 SST_PLATFORM_DROPPED,
54};
55
Vinod Koul03c33042011-12-05 19:13:41 +053056enum sst_controls {
57 SST_SND_ALLOC = 0x00,
58 SST_SND_PAUSE = 0x01,
59 SST_SND_RESUME = 0x02,
60 SST_SND_DROP = 0x03,
61 SST_SND_FREE = 0x04,
62 SST_SND_BUFFER_POINTER = 0x05,
63 SST_SND_STREAM_INIT = 0x06,
64 SST_SND_START = 0x07,
65 SST_MAX_CONTROLS = 0x07,
66};
67
68enum sst_stream_ops {
69 STREAM_OPS_PLAYBACK = 0,
70 STREAM_OPS_CAPTURE,
71};
72
73enum sst_audio_device_type {
74 SND_SST_DEVICE_HEADSET = 1,
75 SND_SST_DEVICE_IHF,
76 SND_SST_DEVICE_VIBRA,
77 SND_SST_DEVICE_HAPTIC,
78 SND_SST_DEVICE_CAPTURE,
Vinod Koulc514a912012-08-16 17:10:42 +053079 SND_SST_DEVICE_COMPRESS,
Vinod Koul03c33042011-12-05 19:13:41 +053080};
81
82/* PCM Parameters */
83struct sst_pcm_params {
84 u16 codec; /* codec type */
85 u8 num_chan; /* 1=Mono, 2=Stereo */
86 u8 pcm_wd_sz; /* 16/24 - bit*/
87 u32 reserved; /* Bitrate in bits per second */
88 u32 sfreq; /* Sampling rate in Hz */
89 u32 ring_buffer_size;
90 u32 period_count; /* period elapsed in samples*/
91 u32 ring_buffer_addr;
92};
93
94struct sst_stream_params {
95 u32 result;
96 u32 stream_id;
97 u8 codec;
98 u8 ops;
99 u8 stream_type;
100 u8 device_type;
101 struct sst_pcm_params sparams;
102};
103
Vinod Koulc514a912012-08-16 17:10:42 +0530104struct sst_compress_cb {
105 void *param;
106 void (*compr_cb)(void *param);
107};
108
109struct compress_sst_ops {
110 const char *name;
111 int (*open) (struct snd_sst_params *str_params,
112 struct sst_compress_cb *cb);
113 int (*control) (unsigned int cmd, unsigned int str_id);
114 int (*tstamp) (unsigned int str_id, struct snd_compr_tstamp *tstamp);
115 int (*ack) (unsigned int str_id, unsigned long bytes);
116 int (*close) (unsigned int str_id);
117 int (*get_caps) (struct snd_compr_caps *caps);
118 int (*get_codec_caps) (struct snd_compr_codec_caps *codec);
Vinod Koul0cd57512013-03-29 23:41:42 +0530119 int (*set_metadata) (unsigned int str_id,
120 struct snd_compr_metadata *mdata);
Vinod Koulc514a912012-08-16 17:10:42 +0530121
122};
123
Vinod Koul03c33042011-12-05 19:13:41 +0530124struct sst_ops {
125 int (*open) (struct sst_stream_params *str_param);
126 int (*device_control) (int cmd, void *arg);
127 int (*close) (unsigned int str_id);
128};
129
130struct sst_runtime_stream {
131 int stream_status;
Vinod Koulc514a912012-08-16 17:10:42 +0530132 unsigned int id;
133 size_t bytes_written;
Vinod Koul03c33042011-12-05 19:13:41 +0530134 struct pcm_stream_info stream_info;
135 struct sst_ops *ops;
Vinod Koulc514a912012-08-16 17:10:42 +0530136 struct compress_sst_ops *compr_ops;
Vinod Koul03c33042011-12-05 19:13:41 +0530137 spinlock_t status_lock;
138};
139
140struct sst_device {
141 char *name;
142 struct device *dev;
143 struct sst_ops *ops;
Vinod Koulc514a912012-08-16 17:10:42 +0530144 struct compress_sst_ops *compr_ops;
Vinod Koul03c33042011-12-05 19:13:41 +0530145};
146
Vinod Koul4496ffa2014-05-05 14:27:49 +0530147void sst_set_stream_status(struct sst_runtime_stream *stream, int state);
Vinod Koul03c33042011-12-05 19:13:41 +0530148int sst_register_dsp(struct sst_device *sst);
149int sst_unregister_dsp(struct sst_device *sst);
Vinod Kould927fda2011-01-04 20:16:32 +0530150#endif