/* * 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 #include #include #include #include #include #include #include #include #include #include #include #include #include "ssp.h" #include //#include "../../staging/iio/iio.h" #include //#include "../../staging/iio/kfifo_buf.h" #include //#include "../../staging/iio/trigger_consumer.h" #include //#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) { return 0; } static int ssp_preenable(struct iio_dev *indio_dev) { int 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; return 0; }