linux/drivers/iio/adc/envelope-detector.c

// SPDX-License-Identifier: GPL-2.0
/*
 * Driver for an envelope detector using a DAC and a comparator
 *
 * Copyright (C) 2016 Axentia Technologies AB
 *
 * Author: Peter Rosin <[email protected]>
 */

/*
 * The DAC is used to find the peak level of an alternating voltage input
 * signal by a binary search using the output of a comparator wired to
 * an interrupt pin. Like so:
 *                           _
 *                          | \
 *     input +------>-------|+ \
 *                          |   \
 *            .-------.     |    }---.
 *            |       |     |   /    |
 *            |    dac|-->--|- /     |
 *            |       |     |_/      |
 *            |       |              |
 *            |       |              |
 *            |    irq|------<-------'
 *            |       |
 *            '-------'
 */

#include <linux/completion.h>
#include <linux/device.h>
#include <linux/err.h>
#include <linux/kernel.h>
#include <linux/module.h>
#include <linux/mod_devicetable.h>
#include <linux/mutex.h>
#include <linux/iio/consumer.h>
#include <linux/iio/iio.h>
#include <linux/iio/sysfs.h>
#include <linux/interrupt.h>
#include <linux/irq.h>
#include <linux/platform_device.h>
#include <linux/spinlock.h>
#include <linux/workqueue.h>

struct envelope {};

/*
 * The envelope_detector_comp_latch function works together with the compare
 * interrupt service routine below (envelope_detector_comp_isr) as a latch
 * (one-bit memory) for if the interrupt has triggered since last calling
 * this function.
 * The ..._comp_isr function disables the interrupt so that the cpu does not
 * need to service a possible interrupt flood from the comparator when no-one
 * cares anyway, and this ..._comp_latch function reenables them again if
 * needed.
 */
static int envelope_detector_comp_latch(struct envelope *env)
{}

static irqreturn_t envelope_detector_comp_isr(int irq, void *ctx)
{}

static void envelope_detector_setup_compare(struct envelope *env)
{}

static void envelope_detector_timeout(struct work_struct *work)
{}

static int envelope_detector_read_raw(struct iio_dev *indio_dev,
				      struct iio_chan_spec const *chan,
				      int *val, int *val2, long mask)
{}

static ssize_t envelope_show_invert(struct iio_dev *indio_dev,
				    uintptr_t private,
				    struct iio_chan_spec const *ch, char *buf)
{}

static ssize_t envelope_store_invert(struct iio_dev *indio_dev,
				     uintptr_t private,
				     struct iio_chan_spec const *ch,
				     const char *buf, size_t len)
{}

static ssize_t envelope_show_comp_interval(struct iio_dev *indio_dev,
					   uintptr_t private,
					   struct iio_chan_spec const *ch,
					   char *buf)
{}

static ssize_t envelope_store_comp_interval(struct iio_dev *indio_dev,
					    uintptr_t private,
					    struct iio_chan_spec const *ch,
					    const char *buf, size_t len)
{}

static const struct iio_chan_spec_ext_info envelope_detector_ext_info[] =;

static const struct iio_chan_spec envelope_detector_iio_channel =;

static const struct iio_info envelope_detector_info =;

static int envelope_detector_probe(struct platform_device *pdev)
{}

static const struct of_device_id envelope_detector_match[] =;
MODULE_DEVICE_TABLE(of, envelope_detector_match);

static struct platform_driver envelope_detector_driver =;
module_platform_driver();

MODULE_DESCRIPTION();
MODULE_AUTHOR();
MODULE_LICENSE();