Vinod Koul | d927fda | 2011-01-04 20:16:32 +0530 | [diff] [blame] | 1 | /* |
| 2 | * sst_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 | * You should have received a copy of the GNU General Public License along |
| 19 | * with this program; if not, write to the Free Software Foundation, Inc., |
| 20 | * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. |
| 21 | * |
| 22 | * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ |
| 23 | * |
| 24 | * |
| 25 | */ |
| 26 | |
| 27 | #ifndef __SST_PLATFORMDRV_H__ |
| 28 | #define __SST_PLATFORMDRV_H__ |
| 29 | |
Vinod Koul | c514a91 | 2012-08-16 17:10:42 +0530 | [diff] [blame] | 30 | #include "sst_dsp.h" |
| 31 | |
Vinod Koul | d927fda | 2011-01-04 20:16:32 +0530 | [diff] [blame] | 32 | #define SST_MONO 1 |
| 33 | #define SST_STEREO 2 |
| 34 | #define SST_MAX_CAP 5 |
| 35 | |
| 36 | #define SST_MIN_RATE 8000 |
| 37 | #define SST_MAX_RATE 48000 |
| 38 | #define SST_MIN_CHANNEL 1 |
| 39 | #define SST_MAX_CHANNEL 5 |
| 40 | #define SST_MAX_BUFFER (800*1024) |
| 41 | #define SST_MIN_BUFFER (800*1024) |
| 42 | #define SST_MIN_PERIOD_BYTES 32 |
| 43 | #define SST_MAX_PERIOD_BYTES SST_MAX_BUFFER |
| 44 | #define SST_MIN_PERIODS 2 |
| 45 | #define SST_MAX_PERIODS (1024*2) |
| 46 | #define SST_FIFO_SIZE 0 |
Vinod Koul | d927fda | 2011-01-04 20:16:32 +0530 | [diff] [blame] | 47 | |
Vinod Koul | 03c3304 | 2011-12-05 19:13:41 +0530 | [diff] [blame] | 48 | struct pcm_stream_info { |
| 49 | int str_id; |
| 50 | void *mad_substream; |
| 51 | void (*period_elapsed) (void *mad_substream); |
| 52 | unsigned long long buffer_ptr; |
| 53 | int sfreq; |
Vinod Koul | d927fda | 2011-01-04 20:16:32 +0530 | [diff] [blame] | 54 | }; |
| 55 | |
| 56 | enum sst_drv_status { |
| 57 | SST_PLATFORM_INIT = 1, |
| 58 | SST_PLATFORM_STARTED, |
| 59 | SST_PLATFORM_RUNNING, |
| 60 | SST_PLATFORM_PAUSED, |
| 61 | SST_PLATFORM_DROPPED, |
| 62 | }; |
| 63 | |
Vinod Koul | 03c3304 | 2011-12-05 19:13:41 +0530 | [diff] [blame] | 64 | enum sst_controls { |
| 65 | SST_SND_ALLOC = 0x00, |
| 66 | SST_SND_PAUSE = 0x01, |
| 67 | SST_SND_RESUME = 0x02, |
| 68 | SST_SND_DROP = 0x03, |
| 69 | SST_SND_FREE = 0x04, |
| 70 | SST_SND_BUFFER_POINTER = 0x05, |
| 71 | SST_SND_STREAM_INIT = 0x06, |
| 72 | SST_SND_START = 0x07, |
| 73 | SST_MAX_CONTROLS = 0x07, |
| 74 | }; |
| 75 | |
| 76 | enum sst_stream_ops { |
| 77 | STREAM_OPS_PLAYBACK = 0, |
| 78 | STREAM_OPS_CAPTURE, |
| 79 | }; |
| 80 | |
| 81 | enum sst_audio_device_type { |
| 82 | SND_SST_DEVICE_HEADSET = 1, |
| 83 | SND_SST_DEVICE_IHF, |
| 84 | SND_SST_DEVICE_VIBRA, |
| 85 | SND_SST_DEVICE_HAPTIC, |
| 86 | SND_SST_DEVICE_CAPTURE, |
Vinod Koul | c514a91 | 2012-08-16 17:10:42 +0530 | [diff] [blame] | 87 | SND_SST_DEVICE_COMPRESS, |
Vinod Koul | 03c3304 | 2011-12-05 19:13:41 +0530 | [diff] [blame] | 88 | }; |
| 89 | |
| 90 | /* PCM Parameters */ |
| 91 | struct sst_pcm_params { |
| 92 | u16 codec; /* codec type */ |
| 93 | u8 num_chan; /* 1=Mono, 2=Stereo */ |
| 94 | u8 pcm_wd_sz; /* 16/24 - bit*/ |
| 95 | u32 reserved; /* Bitrate in bits per second */ |
| 96 | u32 sfreq; /* Sampling rate in Hz */ |
| 97 | u32 ring_buffer_size; |
| 98 | u32 period_count; /* period elapsed in samples*/ |
| 99 | u32 ring_buffer_addr; |
| 100 | }; |
| 101 | |
| 102 | struct sst_stream_params { |
| 103 | u32 result; |
| 104 | u32 stream_id; |
| 105 | u8 codec; |
| 106 | u8 ops; |
| 107 | u8 stream_type; |
| 108 | u8 device_type; |
| 109 | struct sst_pcm_params sparams; |
| 110 | }; |
| 111 | |
Vinod Koul | c514a91 | 2012-08-16 17:10:42 +0530 | [diff] [blame] | 112 | struct sst_compress_cb { |
| 113 | void *param; |
| 114 | void (*compr_cb)(void *param); |
| 115 | }; |
| 116 | |
| 117 | struct compress_sst_ops { |
| 118 | const char *name; |
| 119 | int (*open) (struct snd_sst_params *str_params, |
| 120 | struct sst_compress_cb *cb); |
| 121 | int (*control) (unsigned int cmd, unsigned int str_id); |
| 122 | int (*tstamp) (unsigned int str_id, struct snd_compr_tstamp *tstamp); |
| 123 | int (*ack) (unsigned int str_id, unsigned long bytes); |
| 124 | int (*close) (unsigned int str_id); |
| 125 | int (*get_caps) (struct snd_compr_caps *caps); |
| 126 | int (*get_codec_caps) (struct snd_compr_codec_caps *codec); |
| 127 | |
| 128 | }; |
| 129 | |
Vinod Koul | 03c3304 | 2011-12-05 19:13:41 +0530 | [diff] [blame] | 130 | struct sst_ops { |
| 131 | int (*open) (struct sst_stream_params *str_param); |
| 132 | int (*device_control) (int cmd, void *arg); |
| 133 | int (*close) (unsigned int str_id); |
| 134 | }; |
| 135 | |
| 136 | struct sst_runtime_stream { |
| 137 | int stream_status; |
Vinod Koul | c514a91 | 2012-08-16 17:10:42 +0530 | [diff] [blame] | 138 | unsigned int id; |
| 139 | size_t bytes_written; |
Vinod Koul | 03c3304 | 2011-12-05 19:13:41 +0530 | [diff] [blame] | 140 | struct pcm_stream_info stream_info; |
| 141 | struct sst_ops *ops; |
Vinod Koul | c514a91 | 2012-08-16 17:10:42 +0530 | [diff] [blame] | 142 | struct compress_sst_ops *compr_ops; |
Vinod Koul | 03c3304 | 2011-12-05 19:13:41 +0530 | [diff] [blame] | 143 | spinlock_t status_lock; |
| 144 | }; |
| 145 | |
| 146 | struct sst_device { |
| 147 | char *name; |
| 148 | struct device *dev; |
| 149 | struct sst_ops *ops; |
Vinod Koul | c514a91 | 2012-08-16 17:10:42 +0530 | [diff] [blame] | 150 | struct compress_sst_ops *compr_ops; |
Vinod Koul | 03c3304 | 2011-12-05 19:13:41 +0530 | [diff] [blame] | 151 | }; |
| 152 | |
| 153 | int sst_register_dsp(struct sst_device *sst); |
| 154 | int sst_unregister_dsp(struct sst_device *sst); |
Vinod Koul | d927fda | 2011-01-04 20:16:32 +0530 | [diff] [blame] | 155 | #endif |