sst-mfld-platform.h 4.6 KB
Newer Older
1
/*
2
 *  sst_mfld_platform.h - Intel MID Platform driver header file
3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23
 *
 *  Copyright (C) 2010 Intel Corp
 *  Author: Vinod Koul <vinod.koul@intel.com>
 *  Author: Harsha Priya <priya.harsha@intel.com>
 *  ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
 *
 *  This program is free software; you can redistribute it and/or modify
 *  it under the terms of the GNU General Public License as published by
 *  the Free Software Foundation; version 2 of the License.
 *
 *  This program is distributed in the hope that it will be useful, but
 *  WITHOUT ANY WARRANTY; without even the implied warranty of
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 *  General Public License for more details.
 *
 * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
 */

#ifndef __SST_PLATFORMDRV_H__
#define __SST_PLATFORMDRV_H__

24
#include "sst-mfld-dsp.h"
25

26 27
extern struct sst_device *sst;

28 29 30 31 32 33 34 35 36 37 38 39
#define SST_MONO		1
#define SST_STEREO		2
#define SST_MAX_CAP		5

#define SST_MAX_BUFFER		(800*1024)
#define SST_MIN_BUFFER		(800*1024)
#define SST_MIN_PERIOD_BYTES	32
#define SST_MAX_PERIOD_BYTES	SST_MAX_BUFFER
#define SST_MIN_PERIODS		2
#define SST_MAX_PERIODS		(1024*2)
#define SST_FIFO_SIZE		0

40 41
struct pcm_stream_info {
	int str_id;
42 43
	void *arg;
	void (*period_elapsed) (void *arg);
44
	unsigned long long buffer_ptr;
45
	unsigned long long pcm_delay;
46
	int sfreq;
47 48 49 50 51 52 53 54 55 56
};

enum sst_drv_status {
	SST_PLATFORM_INIT = 1,
	SST_PLATFORM_STARTED,
	SST_PLATFORM_RUNNING,
	SST_PLATFORM_PAUSED,
	SST_PLATFORM_DROPPED,
};

57 58 59 60 61 62 63 64 65 66 67
enum sst_stream_ops {
	STREAM_OPS_PLAYBACK = 0,
	STREAM_OPS_CAPTURE,
};

enum sst_audio_device_type {
	SND_SST_DEVICE_HEADSET = 1,
	SND_SST_DEVICE_IHF,
	SND_SST_DEVICE_VIBRA,
	SND_SST_DEVICE_HAPTIC,
	SND_SST_DEVICE_CAPTURE,
68
	SND_SST_DEVICE_COMPRESS,
69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92
};

/* PCM Parameters */
struct sst_pcm_params {
	u16 codec;	/* codec type */
	u8 num_chan;	/* 1=Mono, 2=Stereo */
	u8 pcm_wd_sz;	/* 16/24 - bit*/
	u32 reserved;	/* Bitrate in bits per second */
	u32 sfreq;	/* Sampling rate in Hz */
	u32 ring_buffer_size;
	u32 period_count;	/* period elapsed in samples*/
	u32 ring_buffer_addr;
};

struct sst_stream_params {
	u32 result;
	u32 stream_id;
	u8 codec;
	u8 ops;
	u8 stream_type;
	u8 device_type;
	struct sst_pcm_params sparams;
};

93 94 95
struct sst_compress_cb {
	void *param;
	void (*compr_cb)(void *param);
96 97
	void *drain_cb_param;
	void (*drain_notify)(void *param);
98 99 100 101 102 103 104 105 106 107 108 109
};

struct compress_sst_ops {
	const char *name;
	int (*open) (struct snd_sst_params *str_params,
			struct sst_compress_cb *cb);
	int (*control) (unsigned int cmd, unsigned int str_id);
	int (*tstamp) (unsigned int str_id, struct snd_compr_tstamp *tstamp);
	int (*ack) (unsigned int str_id, unsigned long bytes);
	int (*close) (unsigned int str_id);
	int (*get_caps) (struct snd_compr_caps *caps);
	int (*get_codec_caps) (struct snd_compr_codec_caps *codec);
110 111
	int (*set_metadata) (unsigned int str_id,
			struct snd_compr_metadata *mdata);
112 113 114

};

115
struct sst_ops {
116 117 118 119 120 121 122 123 124
	int (*open) (struct device *dev, struct snd_sst_params *str_param);
	int (*stream_init) (struct device *dev, struct pcm_stream_info *str_info);
	int (*stream_start) (struct device *dev, int str_id);
	int (*stream_drop) (struct device *dev, int str_id);
	int (*stream_pause) (struct device *dev, int str_id);
	int (*stream_pause_release) (struct device *dev, int str_id);
	int (*stream_read_tstamp) (struct device *dev, struct pcm_stream_info *str_info);
	int (*send_byte_stream)(struct device *dev, struct snd_sst_bytes_v2 *bytes);
	int (*close) (struct device *dev, unsigned int str_id);
125 126 127 128
};

struct sst_runtime_stream {
	int     stream_status;
129 130
	unsigned int id;
	size_t bytes_written;
131 132
	struct pcm_stream_info stream_info;
	struct sst_ops *ops;
133
	struct compress_sst_ops *compr_ops;
134 135 136 137 138 139 140
	spinlock_t	status_lock;
};

struct sst_device {
	char *name;
	struct device *dev;
	struct sst_ops *ops;
V
Vinod Koul 已提交
141
	struct platform_device *pdev;
142
	struct compress_sst_ops *compr_ops;
143 144
};

V
Vinod Koul 已提交
145
struct sst_data;
V
Vinod Koul 已提交
146 147

int sst_dsp_init_v2_dpcm(struct snd_soc_platform *platform);
148
void sst_set_stream_status(struct sst_runtime_stream *stream, int state);
149 150 151
int sst_fill_stream_params(void *substream, const struct sst_data *ctx,
			   struct snd_sst_params *str_params, bool is_compress);

V
Vinod Koul 已提交
152 153 154 155 156 157 158 159 160 161
struct sst_algo_int_control_v2 {
	struct soc_mixer_control mc;
	u16 module_id; /* module identifieer */
	u16 pipe_id; /* location info: pipe_id + instance_id */
	u16 instance_id;
	unsigned int value; /* Value received is stored here */
};
struct sst_data {
	struct platform_device *pdev;
	struct sst_platform_data *pdata;
V
Vinod Koul 已提交
162
	char *byte_stream;
V
Vinod Koul 已提交
163 164
	struct mutex lock;
};
165 166
int sst_register_dsp(struct sst_device *sst);
int sst_unregister_dsp(struct sst_device *sst);
167
#endif