mirror of
https://github.com/torvalds/linux.git
synced 2024-11-10 06:01:57 +00:00
iio: test: gts: test available times and gains sorting
The iio_gts helpers build available times and scales tables based on the times and gains arrays given from the driver. The driver should be able to list all valid register values so that conversion from register valu to correct gain/time works for all supported register values. It might be more convenient for drivers to list these times and gains in the order where they're listed in the data-sheet than ascending order. However, for user who requests the supported scales / times it is more convenient to get the results in asscending order. Also, listing duplicated values is not meaning for the user. Hence the GTS heler should do sorting and deduplication of the scales and times when it builds the tables listing the available times/scales. Note, currently duplicated gain values aren't handled by GTS-helpers. Unsort the gain and time arrays in the test code, and add duplicates to time array in order to test the sorting and deduplicating works. Signed-off-by: Matti Vaittinen <mazziesaccount@gmail.com> Link: https://lore.kernel.org/r/365cc6de3c17a457db738f5fdf8dd3bd6f50d5f2.1714480171.git.mazziesaccount@gmail.com Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
This commit is contained in:
parent
5acc3f971a
commit
6de2f3a1f4
@ -70,6 +70,7 @@
|
||||
*/
|
||||
static struct iio_gts gts;
|
||||
|
||||
/* Keep the gain and time tables unsorted to test the sorting */
|
||||
static const struct iio_gain_sel_pair gts_test_gains[] = {
|
||||
GAIN_SCALE_GAIN(1, TEST_GSEL_1),
|
||||
GAIN_SCALE_GAIN(4, TEST_GSEL_4),
|
||||
@ -79,16 +80,17 @@ static const struct iio_gain_sel_pair gts_test_gains[] = {
|
||||
GAIN_SCALE_GAIN(256, TEST_GSEL_256),
|
||||
GAIN_SCALE_GAIN(512, TEST_GSEL_512),
|
||||
GAIN_SCALE_GAIN(1024, TEST_GSEL_1024),
|
||||
GAIN_SCALE_GAIN(2048, TEST_GSEL_2048),
|
||||
GAIN_SCALE_GAIN(4096, TEST_GSEL_4096),
|
||||
GAIN_SCALE_GAIN(2048, TEST_GSEL_2048),
|
||||
#define HWGAIN_MAX 4096
|
||||
};
|
||||
|
||||
static const struct iio_itime_sel_mul gts_test_itimes[] = {
|
||||
GAIN_SCALE_ITIME_US(400 * 1000, TEST_TSEL_400, 8),
|
||||
GAIN_SCALE_ITIME_US(200 * 1000, TEST_TSEL_200, 4),
|
||||
GAIN_SCALE_ITIME_US(100 * 1000, TEST_TSEL_100, 2),
|
||||
GAIN_SCALE_ITIME_US(400 * 1000, TEST_TSEL_400, 8),
|
||||
GAIN_SCALE_ITIME_US(400 * 1000, TEST_TSEL_400, 8),
|
||||
GAIN_SCALE_ITIME_US(50 * 1000, TEST_TSEL_50, 1),
|
||||
GAIN_SCALE_ITIME_US(200 * 1000, TEST_TSEL_200, 4),
|
||||
#define TIMEGAIN_MAX 8
|
||||
};
|
||||
#define TOTAL_GAIN_MAX (HWGAIN_MAX * TIMEGAIN_MAX)
|
||||
|
Loading…
Reference in New Issue
Block a user