123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102 |
- /*
- * Copyright (C) 2011, Samsung Electronics Co. Ltd. All Rights Reserved.
- *
- * 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; either version 2 of the License, or
- * (at your option) any later version.
- *
- * 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.
- *
- */
- #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
- #include <linux/module.h>
- #include <linux/init.h>
- #include <linux/slab.h>
- #include <linux/i2c.h>
- #include <linux/err.h>
- #include <linux/delay.h>
- #include <linux/sysfs.h>
- #include <linux/jiffies.h>
- #include <linux/irq.h>
- #include <linux/interrupt.h>
- #include <linux/kfifo.h>
- #include <linux/poll.h>
- #include <linux/miscdevice.h>
- #include "ssp.h"
- #include "../../staging/iio/iio.h"
- #include "../../staging/iio/kfifo_buf.h"
- #include "../../staging/iio/trigger_consumer.h"
- #include "../../staging/iio/sysfs.h"
- void ssp_iio_unconfigure_ring(struct iio_dev *indio_dev)
- {
- iio_kfifo_free(indio_dev->buffer);
- };
- static int ssp_predisable(struct iio_dev *indio_dev)
- {
- /* sch0317 need to implement
- struct inv_mpu_state *st = iio_priv(indio_dev);
- int result;
- if (st->chip_config.enable) {
- result = set_inv_enable(indio_dev, false);
- if (result)
- return result;
- result = st->set_power_state(st, false);
- if (result)
- return result;
- }
- */
- return 0;
- }
- static int ssp_preenable(struct iio_dev *indio_dev)
- {
- int result;
- //result = inv_check_conflict_sysfs(indio_dev);
- //if (result)
- // return result;
- result = iio_sw_buffer_preenable(indio_dev);
- return result;
- }
- static const struct iio_buffer_setup_ops ssp_iio_ring_setup_ops = {
- .preenable = &ssp_preenable,
- .predisable = &ssp_predisable,
- };
- int ssp_iio_configure_ring(struct iio_dev *indio_dev)
- {
- struct iio_buffer *ring;
- ring = iio_kfifo_allocate(indio_dev);
- if (!ring)
- return -ENOMEM;
- ring->bytes_per_datum = 8;
- indio_dev->buffer = ring;
- /* setup ring buffer */
- ring->scan_timestamp = true;
- indio_dev->setup_ops = &ssp_iio_ring_setup_ops;
- /*scan count double count timestamp. should subtract 1. but
- number of channels still includes timestamp*/
- indio_dev->modes |= INDIO_BUFFER_HARDWARE; // INDIO_BUFFER_TRIGGERED
- return 0;
- }
|