Path: blob/master/sound/soc/intel/atom/sst-mfld-platform.h
26493 views
/* SPDX-License-Identifier: GPL-2.0-only */1/*2* sst_mfld_platform.h - Intel MID Platform driver header file3*4* Copyright (C) 2010 Intel Corp5* Author: Vinod Koul <[email protected]>6* Author: Harsha Priya <[email protected]>7* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~8*9* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~10*/1112#ifndef __SST_PLATFORMDRV_H__13#define __SST_PLATFORMDRV_H__1415#include "sst-mfld-dsp.h"16#include "sst-atom-controls.h"1718extern struct sst_device *sst;19extern const struct snd_compress_ops sst_platform_compress_ops;2021#define DRV_NAME "sst"2223#define SST_MONO 124#define SST_STEREO 225#define SST_MAX_CAP 52627#define SST_MAX_BUFFER (800*1024)28#define SST_MIN_BUFFER (800*1024)29#define SST_MIN_PERIOD_BYTES 3230#define SST_MAX_PERIOD_BYTES SST_MAX_BUFFER31#define SST_MIN_PERIODS 232#define SST_MAX_PERIODS (1024*2)33#define SST_FIFO_SIZE 03435struct pcm_stream_info {36int str_id;37void *arg;38void (*period_elapsed) (void *arg);39unsigned long long buffer_ptr;40unsigned long long pcm_delay;41int sfreq;42};4344enum sst_drv_status {45SST_PLATFORM_INIT = 1,46SST_PLATFORM_STARTED,47SST_PLATFORM_RUNNING,48SST_PLATFORM_PAUSED,49SST_PLATFORM_DROPPED,50};5152enum sst_stream_ops {53STREAM_OPS_PLAYBACK = 0,54STREAM_OPS_CAPTURE,55};5657enum sst_audio_device_type {58SND_SST_DEVICE_HEADSET = 1,59SND_SST_DEVICE_IHF,60SND_SST_DEVICE_VIBRA,61SND_SST_DEVICE_HAPTIC,62SND_SST_DEVICE_CAPTURE,63SND_SST_DEVICE_COMPRESS,64};6566/* PCM Parameters */67struct sst_pcm_params {68u16 codec; /* codec type */69u8 num_chan; /* 1=Mono, 2=Stereo */70u8 pcm_wd_sz; /* 16/24 - bit*/71u32 reserved; /* Bitrate in bits per second */72u32 sfreq; /* Sampling rate in Hz */73u32 ring_buffer_size;74u32 period_count; /* period elapsed in samples*/75u32 ring_buffer_addr;76};7778struct sst_stream_params {79u32 result;80u32 stream_id;81u8 codec;82u8 ops;83u8 stream_type;84u8 device_type;85struct sst_pcm_params sparams;86};8788struct sst_compress_cb {89void *param;90void (*compr_cb)(void *param);91void *drain_cb_param;92void (*drain_notify)(void *param);93};9495struct compress_sst_ops {96const char *name;97int (*open)(struct device *dev,98struct snd_sst_params *str_params, struct sst_compress_cb *cb);99int (*stream_start)(struct device *dev, unsigned int str_id);100int (*stream_drop)(struct device *dev, unsigned int str_id);101int (*stream_drain)(struct device *dev, unsigned int str_id);102int (*stream_partial_drain)(struct device *dev, unsigned int str_id);103int (*stream_pause)(struct device *dev, unsigned int str_id);104int (*stream_pause_release)(struct device *dev, unsigned int str_id);105106int (*tstamp)(struct device *dev, unsigned int str_id,107struct snd_compr_tstamp *tstamp);108int (*ack)(struct device *dev, unsigned int str_id,109unsigned long bytes);110int (*close)(struct device *dev, unsigned int str_id);111int (*get_caps)(struct snd_compr_caps *caps);112int (*get_codec_caps)(struct snd_compr_codec_caps *codec);113int (*set_metadata)(struct device *dev, unsigned int str_id,114struct snd_compr_metadata *mdata);115int (*power)(struct device *dev, bool state);116};117118struct sst_ops {119int (*open)(struct device *dev, struct snd_sst_params *str_param);120int (*stream_init)(struct device *dev, struct pcm_stream_info *str_info);121int (*stream_start)(struct device *dev, int str_id);122int (*stream_drop)(struct device *dev, int str_id);123int (*stream_pause)(struct device *dev, int str_id);124int (*stream_pause_release)(struct device *dev, int str_id);125int (*stream_read_tstamp)(struct device *dev, struct pcm_stream_info *str_info);126int (*send_byte_stream)(struct device *dev, struct snd_sst_bytes_v2 *bytes);127int (*close)(struct device *dev, unsigned int str_id);128int (*power)(struct device *dev, bool state);129};130131struct sst_runtime_stream {132int stream_status;133unsigned int id;134size_t bytes_written;135struct pcm_stream_info stream_info;136struct sst_ops *ops;137struct compress_sst_ops *compr_ops;138spinlock_t status_lock;139};140141struct sst_device {142char *name;143struct device *dev;144struct sst_ops *ops;145struct platform_device *pdev;146struct compress_sst_ops *compr_ops;147};148149struct sst_data;150151int sst_dsp_init_v2_dpcm(struct snd_soc_component *component);152int sst_send_pipe_gains(struct snd_soc_dai *dai, int stream, int mute);153int send_ssp_cmd(struct snd_soc_dai *dai, const char *id, bool enable);154int sst_handle_vb_timer(struct snd_soc_dai *dai, bool enable);155156void sst_set_stream_status(struct sst_runtime_stream *stream, int state);157int sst_fill_stream_params(void *substream, const struct sst_data *ctx,158struct snd_sst_params *str_params, bool is_compress);159160struct sst_algo_int_control_v2 {161struct soc_mixer_control mc;162u16 module_id; /* module identifieer */163u16 pipe_id; /* location info: pipe_id + instance_id */164u16 instance_id;165unsigned int value; /* Value received is stored here */166};167struct sst_data {168struct platform_device *pdev;169struct sst_platform_data *pdata;170struct snd_sst_bytes_v2 *byte_stream;171struct mutex lock;172struct snd_soc_card *soc_card;173struct sst_cmd_sba_hw_set_ssp ssp_cmd;174};175int sst_register_dsp(struct sst_device *dev);176int sst_unregister_dsp(struct sst_device *dev);177#endif178179180