linux/sound/soc/sprd/sprd-pcm-compress.c

// SPDX-License-Identifier: GPL-2.0
// Copyright (C) 2019 Spreadtrum Communications Inc.

#include <linux/dma-mapping.h>
#include <linux/dmaengine.h>
#include <linux/dma/sprd-dma.h>
#include <linux/kernel.h>
#include <linux/module.h>
#include <sound/pcm.h>
#include <sound/pcm_params.h>
#include <sound/soc.h>
#include <sound/compress_driver.h>

#include "sprd-pcm-dma.h"

#define SPRD_COMPR_DMA_CHANS

/* Default values if userspace does not set */
#define SPRD_COMPR_MIN_FRAGMENT_SIZE
#define SPRD_COMPR_MAX_FRAGMENT_SIZE
#define SPRD_COMPR_MIN_NUM_FRAGMENTS
#define SPRD_COMPR_MAX_NUM_FRAGMENTS

/* DSP FIFO size */
#define SPRD_COMPR_MCDT_EMPTY_WMK
#define SPRD_COMPR_MCDT_FIFO_SIZE

/* Stage 0 IRAM buffer size definition */
#define SPRD_COMPR_IRAM_BUF_SIZE
#define SPRD_COMPR_IRAM_INFO_SIZE
#define SPRD_COMPR_IRAM_LINKLIST_SIZE
#define SPRD_COMPR_IRAM_SIZE

/* Stage 1 DDR buffer size definition */
#define SPRD_COMPR_AREA_BUF_SIZE
#define SPRD_COMPR_AREA_LINKLIST_SIZE
#define SPRD_COMPR_AREA_SIZE

struct sprd_compr_dma {};

/*
 * The Spreadtrum Audio compress offload mode will use 2-stage DMA transfer to
 * save power. That means we can request 2 dma channels, one for source channel,
 * and another one for destination channel. Once the source channel's transaction
 * is done, it will trigger the destination channel's transaction automatically
 * by hardware signal.
 *
 * For 2-stage DMA transfer, we can allocate 2 buffers: IRAM buffer (always
 * power-on) and DDR buffer. The source channel will transfer data from IRAM
 * buffer to the DSP fifo to decoding/encoding, once IRAM buffer is empty by
 * transferring done, the destination channel will start to transfer data from
 * DDR buffer to IRAM buffer.
 *
 * Since the DSP fifo is only 512B, IRAM buffer is allocated by 32K, and DDR
 * buffer is larger to 2M. That means only the IRAM 32k data is transferred
 * done, we can wake up the AP system to transfer data from DDR to IRAM, and
 * other time the AP system can be suspended to save power.
 */
struct sprd_compr_stream {};

static int sprd_platform_compr_trigger(struct snd_soc_component *component,
				       struct snd_compr_stream *cstream,
				       int cmd);

static void sprd_platform_compr_drain_notify(void *arg)
{}

static void sprd_platform_compr_dma_complete(void *data)
{}

static int sprd_platform_compr_dma_config(struct snd_soc_component *component,
					  struct snd_compr_stream *cstream,
					  struct snd_compr_params *params,
					  int channel)
{}

static int sprd_platform_compr_set_params(struct snd_soc_component *component,
					  struct snd_compr_stream *cstream,
					  struct snd_compr_params *params)
{}

static int sprd_platform_compr_open(struct snd_soc_component *component,
				    struct snd_compr_stream *cstream)
{}

static int sprd_platform_compr_free(struct snd_soc_component *component,
				    struct snd_compr_stream *cstream)
{}

static int sprd_platform_compr_trigger(struct snd_soc_component *component,
				       struct snd_compr_stream *cstream,
				       int cmd)
{}

static int sprd_platform_compr_pointer(struct snd_soc_component *component,
				       struct snd_compr_stream *cstream,
				       struct snd_compr_tstamp *tstamp)
{}

static int sprd_platform_compr_copy(struct snd_soc_component *component,
				    struct snd_compr_stream *cstream,
				    char __user *buf, size_t count)
{}

static int sprd_platform_compr_get_caps(struct snd_soc_component *component,
					struct snd_compr_stream *cstream,
					struct snd_compr_caps *caps)
{}

static int
sprd_platform_compr_get_codec_caps(struct snd_soc_component *component,
				   struct snd_compr_stream *cstream,
				   struct snd_compr_codec_caps *codec)
{}

const struct snd_compress_ops sprd_platform_compress_ops =;

MODULE_DESCRIPTION();
MODULE_LICENSE();
MODULE_ALIAS();