/*
 * ALSA SoC dummy cpu & platform dai driver
 *
 *  This driver provides one dummy dai.
 *
 * Copyright (c) 2014 Samsung Electronics
 * http://www.samsungsemi.com/
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License version 2 as
 * published by the Free Software Foundation.
 */

#include <linux/module.h>
#include <linux/moduleparam.h>
#include <linux/slab.h>
#include <linux/of.h>
#include <linux/dma/dma-pl330.h>
#include <linux/dma-mapping.h>
#include <linux/kthread.h>
#include <sound/soc.h>
#include <sound/pcm.h>
#include <sound/initval.h>
#include <sound/pcm_params.h>

#define PERIOD_MIN		4

static DECLARE_WAIT_QUEUE_HEAD(compr_cap_wq);
extern ssize_t esa_copy(unsigned long hwbuf, ssize_t size);
extern int esa_compr_running(void);
extern void esa_compr_ctrl_fxintr(bool fxon);

static const struct snd_pcm_hardware dma_hardware = {
	.info			= SNDRV_PCM_INFO_INTERLEAVED |
				  SNDRV_PCM_INFO_BLOCK_TRANSFER |
				  SNDRV_PCM_INFO_MMAP |
				  SNDRV_PCM_INFO_MMAP_VALID,
	.formats		= SNDRV_PCM_FMTBIT_S16_LE |
				  SNDRV_PCM_FMTBIT_U16_LE |
				  SNDRV_PCM_FMTBIT_U8 |
				  SNDRV_PCM_FMTBIT_S8,
	.channels_min		= 1,
	.channels_max		= 8,
	.buffer_bytes_max	= 256*1024,
	.period_bytes_min	= 128,
	.period_bytes_max	= 32*1024,
	.periods_min		= 2,
	.periods_max		= 128,
	.fifo_size		= 32,
};

struct runtime_data {
	spinlock_t lock;
	int state;
	unsigned int dma_loaded;
	unsigned int dma_period;
	unsigned long buf_start;
	unsigned long buf_pos;
	unsigned long buf_end;
	unsigned long period_bytes;
	struct snd_pcm_hardware hw;
	struct snd_pcm_substream *substream;
	struct task_struct *compr_cap_kthread;
	bool running;
	bool opened;
	bool dram_used;
} rd;

static int dummy_dma_hw_params(struct snd_pcm_substream *substream,
	struct snd_pcm_hw_params *params)
{
	struct snd_pcm_runtime *runtime = substream->runtime;
	struct runtime_data *prtd = runtime->private_data;
	unsigned long totbytes = params_buffer_bytes(params);

	pr_debug("Entered %s\n", __func__);

	snd_pcm_set_runtime_buffer(substream, &substream->dma_buffer);

	runtime->dma_bytes = totbytes;

	spin_lock_irq(&prtd->lock);
	prtd->dma_loaded = 0;
	prtd->dma_period = params_period_bytes(params);
	prtd->buf_start = (unsigned long)runtime->dma_area;
	prtd->buf_pos = prtd->buf_start;
	prtd->buf_end = prtd->buf_start + totbytes;
	while ((totbytes / prtd->dma_period) < PERIOD_MIN)
		prtd->dma_period >>= 1;
	spin_unlock_irq(&prtd->lock);

	pr_info("Dummy DMA:%s:Addr=@0x%lx Total=%d PrdSz=%d(%d) #Prds=%d \n",
		(substream->stream == SNDRV_PCM_STREAM_PLAYBACK) ? "P" : "C",
		prtd->buf_start, (u32)runtime->dma_bytes,
		params_period_bytes(params),(u32) prtd->dma_period,
		params_periods(params));

	return 0;
}

static int dummy_dma_hw_free(struct snd_pcm_substream *substream)
{
	snd_pcm_set_runtime_buffer(substream, NULL);

	return 0;
}

static int dummy_dma_prepare(struct snd_pcm_substream *substream)
{
	struct runtime_data *prtd = substream->runtime->private_data;
	int ret = 0;

	pr_debug("Entered %s +\n", __func__);

	prtd->dma_loaded = 0;
	prtd->buf_pos = prtd->buf_start;

	pr_debug("Entered %s -\n", __func__);

	return ret;
}

static snd_pcm_uframes_t dummy_dma_pointer(struct snd_pcm_substream *substream)
{
	struct snd_pcm_runtime *runtime = substream->runtime;
	struct runtime_data *prtd = runtime->private_data;
	unsigned long res;

	pr_debug("Entered %s\n", __func__);
	res = prtd->buf_pos - prtd->buf_start;

	pr_debug("%s res = %lx\n", __func__, res);

	return bytes_to_frames(substream->runtime, res);
}

static int dummy_dma_open(struct snd_pcm_substream *substream)
{
	struct snd_pcm_runtime *runtime = substream->runtime;

	pr_info("Entered %s\n", __func__);

	if (rd.opened)
		return -EBUSY;

	if (!esa_compr_running())
		return -ENODEV;

	spin_lock_init(&rd.lock);

	memcpy(&rd.hw, &dma_hardware, sizeof(struct snd_pcm_hardware));

	snd_pcm_hw_constraint_integer(runtime, SNDRV_PCM_HW_PARAM_PERIODS);
	runtime->private_data = &rd;
	snd_soc_set_runtime_hwparams(substream, &rd.hw);

	rd.opened = true;

	pr_info("%s: prtd = %p\n", __func__, &rd);

	return 0;
}

static int dummy_dma_close(struct snd_pcm_substream *substream)
{
	pr_info("Entered %s\n", __func__);

	rd.opened = false;

	return 0;
}

static int dummy_dma_copy(struct snd_pcm_substream *substream, int channel,
		snd_pcm_uframes_t pos, void __user *buf, snd_pcm_uframes_t count)
{
	struct snd_pcm_runtime *runtime = substream->runtime;
	char *hwbuf = runtime->dma_area + frames_to_bytes(runtime, pos);

	if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) {
		if (copy_from_user(hwbuf, buf, frames_to_bytes(runtime, count)))
			return -EFAULT;
	} else {
		if (copy_to_user(buf, hwbuf, frames_to_bytes(runtime, count)))
			return -EFAULT;
	}

	return 0;
}

static int dummy_dma_trigger(struct snd_pcm_substream *substream, int cmd)
{
	struct runtime_data *prtd = substream->runtime->private_data;
	int ret = 0;

	pr_info("Entered %s\n", __func__);

	spin_lock(&prtd->lock);

	switch (cmd) {
	case SNDRV_PCM_TRIGGER_START:
		/* Enable seiren firmware effect Fx external interrupt
		   to capture offload's PCM data from firmware */
		esa_compr_ctrl_fxintr(true);
		rd.running = true;
		if (waitqueue_active(&compr_cap_wq))
			wake_up_interruptible(&compr_cap_wq);
		break;

	case SNDRV_PCM_TRIGGER_STOP:
		rd.running = false;
		/* Disable seiren firmware effect Fx externalinterrupt */
		esa_compr_ctrl_fxintr(false);
		break;

	default:
		ret = -EINVAL;
		break;
	}

	spin_unlock(&prtd->lock);

	return ret;
}

static struct snd_pcm_ops visualizercap_dummy_dma_ops = {
	.open		= dummy_dma_open,
	.close		= dummy_dma_close,
	.ioctl		= snd_pcm_lib_ioctl,
	.hw_params	= dummy_dma_hw_params,
	.hw_free	= dummy_dma_hw_free,
	.prepare	= dummy_dma_prepare,
	.trigger	= dummy_dma_trigger,
	.pointer	= dummy_dma_pointer,
	.copy		= dummy_dma_copy,
};

static int compr_cap_kthr(void *p)
{
	struct runtime_data *prtd = (struct runtime_data *)p;
	int ret = 0;


	while (!kthread_should_stop()) {
		wait_event_interruptible(compr_cap_wq, rd.running);

		ret = esa_copy(prtd->buf_pos, prtd->dma_period);
		if (ret < 0) {
			pr_err("Failed to get f/w decoded pcm data\n");
			rd.running = false;
			continue;
		}

		prtd->buf_pos = prtd->buf_pos + prtd->dma_period;
		if (prtd->buf_pos >= prtd->buf_end)
			prtd->buf_pos = prtd->buf_start;
		snd_pcm_period_elapsed(rd.substream);
	}

	return 0;
}

static int preallocate_dma_buffer_of(struct snd_pcm *pcm, int stream,
					struct device_node *np)
{
	struct snd_pcm_substream *substream = pcm->streams[stream].substream;
	struct snd_dma_buffer *buf = &substream->dma_buffer;
	dma_addr_t dma_addr;
	size_t size = dma_hardware.buffer_bytes_max;

	pr_debug("Entered %s\n", __func__);

	buf->dev.type = SNDRV_DMA_TYPE_DEV;
	buf->dev.dev = pcm->card->dev;
	buf->private_data = NULL;

	buf->area = dma_alloc_coherent(pcm->card->dev, size, &dma_addr, GFP_KERNEL);
	if (!buf->area)
		return -ENOMEM;

	buf->addr = dma_addr;
	buf->bytes = size;

	rd.substream = substream;

	return 0;
}

static void dummy_dma_free_dma_buffers(struct snd_pcm *pcm)
{
	struct snd_pcm_substream *substream;
	struct snd_dma_buffer *buf;

	pr_debug("Entered %s\n", __func__);

	substream = pcm->streams[SNDRV_PCM_STREAM_CAPTURE].substream;
	if (!substream)
		return;

	buf = &substream->dma_buffer;
	if (!buf->area)
		return;

	dma_free_coherent(pcm->card->dev, buf->bytes, buf->area, buf->addr);
	buf->area = NULL;
}

static u64 dma_mask = DMA_BIT_MASK(32);

static int dummy_dma_new(struct snd_soc_pcm_runtime *rtd)
{
	struct snd_card *card = rtd->card->snd_card;
	struct snd_pcm *pcm = rtd->pcm;
	struct device_node *np = rtd->cpu_dai->dev->of_node;
	struct sched_param param = { .sched_priority = 0 };
	struct task_struct *ret_task;
	int ret = 0;

	pr_debug("Entered %s\n", __func__);

	if (!card->dev->dma_mask)
		card->dev->dma_mask = &dma_mask;
	if (!card->dev->coherent_dma_mask)
		card->dev->coherent_dma_mask = DMA_BIT_MASK(32);

	if (pcm->streams[SNDRV_PCM_STREAM_CAPTURE].substream) {
		ret = 0;
		if (np)
			ret = preallocate_dma_buffer_of(pcm,
				SNDRV_PCM_STREAM_CAPTURE, np);
		if (ret)
			goto out;
	}

	ret_task = kthread_run(compr_cap_kthr, &rd, "compr_cap_kthr");
	if (IS_ERR(ret_task)) {
		pr_info("%s: failed to create compr_cap thread(%ld)\n",
				__func__, PTR_ERR(ret_task));
		ret = PTR_ERR(ret_task);
	} else {
		sched_setscheduler(ret_task, SCHED_NORMAL, &param);
	}

out:
	return ret;
}

static struct snd_soc_platform_driver dummy_asoc_platform = {
	.ops		= &visualizercap_dummy_dma_ops,
	.pcm_new	= dummy_dma_new,
	.pcm_free	= dummy_dma_free_dma_buffers,
};

#define SAMSUNG_I2S_RATES	SNDRV_PCM_RATE_8000_192000

#define SAMSUNG_I2S_FMTS	(SNDRV_PCM_FMTBIT_S8 | \
					SNDRV_PCM_FMTBIT_S16_LE | \
					SNDRV_PCM_FMTBIT_S24_LE)

static struct snd_soc_dai_driver dummy_i2s_dai_drv = {
	.name		= "dummy-i2s-dai-driver",
};

static const struct snd_soc_component_driver dummy_i2s_component = {
	.name		= "dummy-i2s",
};

static int dummy_cpu_probe(struct platform_device *pdev)
{
	dummy_i2s_dai_drv.symmetric_rates = 1;
	dummy_i2s_dai_drv.capture.channels_min = 1;
	dummy_i2s_dai_drv.capture.channels_max = 2;
	dummy_i2s_dai_drv.capture.rates = SAMSUNG_I2S_RATES;
	dummy_i2s_dai_drv.capture.formats = SAMSUNG_I2S_FMTS;

	snd_soc_register_component(&pdev->dev, &dummy_i2s_component,
			&dummy_i2s_dai_drv, 1);

	snd_soc_register_platform(&pdev->dev, &dummy_asoc_platform);

	return 0;
}

static int dummy_cpu_remove(struct platform_device *pdev)
{
	snd_soc_unregister_component(&pdev->dev);
	snd_soc_unregister_platform(&pdev->dev);

	return 0;
}

static const struct of_device_id dummy_cpu_of_match[] = {
	{ .compatible = "samsung,dummy-i2s", },
	{},
};
MODULE_DEVICE_TABLE(of, dummy_cpu_of_match);

static struct platform_driver dummy_cpu_driver = {
	.probe		= dummy_cpu_probe,
	.remove		= dummy_cpu_remove,
	.driver		= {
		.name	= "dummy-i2s",
		.owner	= THIS_MODULE,
		.of_match_table = of_match_ptr(dummy_cpu_of_match),
	},
};

module_platform_driver(dummy_cpu_driver);

MODULE_AUTHOR("Hyunwoong Kim <khw0178.kim@samsung.com>");
MODULE_DESCRIPTION("Dummy dai driver");
MODULE_LICENSE("GPL");
