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