18ffdff6aSGreg Kroah-Hartman /* SPDX-License-Identifier: GPL-2.0+ */
28ffdff6aSGreg Kroah-Hartman /*
38ffdff6aSGreg Kroah-Hartman * comedi/drivers/ni_routes.h
48ffdff6aSGreg Kroah-Hartman * Route information for NI boards.
58ffdff6aSGreg Kroah-Hartman *
68ffdff6aSGreg Kroah-Hartman * COMEDI - Linux Control and Measurement Device Interface
78ffdff6aSGreg Kroah-Hartman * Copyright (C) 2016 Spencer E. Olson <olsonse@umich.edu>
88ffdff6aSGreg Kroah-Hartman *
98ffdff6aSGreg Kroah-Hartman * This program is free software; you can redistribute it and/or modify
108ffdff6aSGreg Kroah-Hartman * it under the terms of the GNU General Public License as published by
118ffdff6aSGreg Kroah-Hartman * the Free Software Foundation; either version 2 of the License, or
128ffdff6aSGreg Kroah-Hartman * (at your option) any later version.
138ffdff6aSGreg Kroah-Hartman *
148ffdff6aSGreg Kroah-Hartman * This program is distributed in the hope that it will be useful,
158ffdff6aSGreg Kroah-Hartman * but WITHOUT ANY WARRANTY; without even the implied warranty of
168ffdff6aSGreg Kroah-Hartman * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
178ffdff6aSGreg Kroah-Hartman * GNU General Public License for more details.
188ffdff6aSGreg Kroah-Hartman */
198ffdff6aSGreg Kroah-Hartman
208ffdff6aSGreg Kroah-Hartman #ifndef _COMEDI_DRIVERS_NI_ROUTES_H
218ffdff6aSGreg Kroah-Hartman #define _COMEDI_DRIVERS_NI_ROUTES_H
228ffdff6aSGreg Kroah-Hartman
238ffdff6aSGreg Kroah-Hartman #include <linux/types.h>
248ffdff6aSGreg Kroah-Hartman #include <linux/errno.h>
258ffdff6aSGreg Kroah-Hartman
268ffdff6aSGreg Kroah-Hartman #ifndef NI_ROUTE_VALUE_EXTERNAL_CONVERSION
278ffdff6aSGreg Kroah-Hartman #include <linux/bitops.h>
288ffdff6aSGreg Kroah-Hartman #endif
298ffdff6aSGreg Kroah-Hartman
30*df0e68c1SIan Abbott #include <linux/comedi.h>
318ffdff6aSGreg Kroah-Hartman
328ffdff6aSGreg Kroah-Hartman /**
338ffdff6aSGreg Kroah-Hartman * struct ni_route_set - Set of destinations with a common source.
348ffdff6aSGreg Kroah-Hartman * @dest: Destination of all sources in this route set.
358ffdff6aSGreg Kroah-Hartman * @n_src: Number of sources for this route set.
368ffdff6aSGreg Kroah-Hartman * @src: List of sources that all map to the same destination.
378ffdff6aSGreg Kroah-Hartman */
388ffdff6aSGreg Kroah-Hartman struct ni_route_set {
398ffdff6aSGreg Kroah-Hartman int dest;
408ffdff6aSGreg Kroah-Hartman int n_src;
418ffdff6aSGreg Kroah-Hartman int *src;
428ffdff6aSGreg Kroah-Hartman };
438ffdff6aSGreg Kroah-Hartman
448ffdff6aSGreg Kroah-Hartman /**
458ffdff6aSGreg Kroah-Hartman * struct ni_device_routes - List of all src->dest sets for a particular device.
468ffdff6aSGreg Kroah-Hartman * @device: Name of board/device (e.g. pxi-6733).
478ffdff6aSGreg Kroah-Hartman * @n_route_sets: Number of route sets that are valid for this device.
488ffdff6aSGreg Kroah-Hartman * @routes: List of route sets that are valid for this device.
498ffdff6aSGreg Kroah-Hartman */
508ffdff6aSGreg Kroah-Hartman struct ni_device_routes {
518ffdff6aSGreg Kroah-Hartman const char *device;
528ffdff6aSGreg Kroah-Hartman int n_route_sets;
538ffdff6aSGreg Kroah-Hartman struct ni_route_set *routes;
548ffdff6aSGreg Kroah-Hartman };
558ffdff6aSGreg Kroah-Hartman
568ffdff6aSGreg Kroah-Hartman /**
578ffdff6aSGreg Kroah-Hartman * struct ni_route_tables - Register values and valid routes for a device.
588ffdff6aSGreg Kroah-Hartman * @valid_routes: Pointer to a all valid route sets for a single device.
598ffdff6aSGreg Kroah-Hartman * @route_values: Pointer to register values for all routes for the family to
608ffdff6aSGreg Kroah-Hartman * which the device belongs.
618ffdff6aSGreg Kroah-Hartman *
628ffdff6aSGreg Kroah-Hartman * Link to the valid src->dest routes and the register values used to assign
638ffdff6aSGreg Kroah-Hartman * such routes for that particular device.
648ffdff6aSGreg Kroah-Hartman */
658ffdff6aSGreg Kroah-Hartman struct ni_route_tables {
668ffdff6aSGreg Kroah-Hartman const struct ni_device_routes *valid_routes;
678ffdff6aSGreg Kroah-Hartman const u8 *route_values;
688ffdff6aSGreg Kroah-Hartman };
698ffdff6aSGreg Kroah-Hartman
708ffdff6aSGreg Kroah-Hartman /*
718ffdff6aSGreg Kroah-Hartman * ni_assign_device_routes() - Assign the proper lookup table for NI signal
728ffdff6aSGreg Kroah-Hartman * routing to the specified NI device.
738ffdff6aSGreg Kroah-Hartman *
748ffdff6aSGreg Kroah-Hartman * Return: -ENODATA if assignment was not successful; 0 if successful.
758ffdff6aSGreg Kroah-Hartman */
768ffdff6aSGreg Kroah-Hartman int ni_assign_device_routes(const char *device_family,
778ffdff6aSGreg Kroah-Hartman const char *board_name,
788ffdff6aSGreg Kroah-Hartman const char *alt_board_name,
798ffdff6aSGreg Kroah-Hartman struct ni_route_tables *tables);
808ffdff6aSGreg Kroah-Hartman
818ffdff6aSGreg Kroah-Hartman /*
828ffdff6aSGreg Kroah-Hartman * ni_find_route_set() - Finds the proper route set with the specified
838ffdff6aSGreg Kroah-Hartman * destination.
848ffdff6aSGreg Kroah-Hartman * @destination: Destination of which to search for the route set.
858ffdff6aSGreg Kroah-Hartman * @valid_routes: Pointer to device routes within which to search.
868ffdff6aSGreg Kroah-Hartman *
878ffdff6aSGreg Kroah-Hartman * Return: NULL if no route_set is found with the specified @destination;
888ffdff6aSGreg Kroah-Hartman * otherwise, a pointer to the route_set if found.
898ffdff6aSGreg Kroah-Hartman */
908ffdff6aSGreg Kroah-Hartman const struct ni_route_set *
918ffdff6aSGreg Kroah-Hartman ni_find_route_set(const int destination,
928ffdff6aSGreg Kroah-Hartman const struct ni_device_routes *valid_routes);
938ffdff6aSGreg Kroah-Hartman
948ffdff6aSGreg Kroah-Hartman /*
958ffdff6aSGreg Kroah-Hartman * ni_route_set_has_source() - Determines whether the given source is in
968ffdff6aSGreg Kroah-Hartman * included given route_set.
978ffdff6aSGreg Kroah-Hartman *
988ffdff6aSGreg Kroah-Hartman * Return: true if found; false otherwise.
998ffdff6aSGreg Kroah-Hartman */
1008ffdff6aSGreg Kroah-Hartman bool ni_route_set_has_source(const struct ni_route_set *routes, const int src);
1018ffdff6aSGreg Kroah-Hartman
1028ffdff6aSGreg Kroah-Hartman /*
1038ffdff6aSGreg Kroah-Hartman * ni_route_to_register() - Validates and converts the specified signal route
1048ffdff6aSGreg Kroah-Hartman * (src-->dest) to the value used at the appropriate
1058ffdff6aSGreg Kroah-Hartman * register.
1068ffdff6aSGreg Kroah-Hartman * @src: global-identifier for route source
1078ffdff6aSGreg Kroah-Hartman * @dest: global-identifier for route destination
1088ffdff6aSGreg Kroah-Hartman * @tables: pointer to relevant set of routing tables.
1098ffdff6aSGreg Kroah-Hartman *
1108ffdff6aSGreg Kroah-Hartman * Generally speaking, most routes require the first six bits and a few require
1118ffdff6aSGreg Kroah-Hartman * 7 bits. Special handling is given for the return value when the route is to
1128ffdff6aSGreg Kroah-Hartman * be handled by the RTSI sub-device. In this case, the returned register may
1138ffdff6aSGreg Kroah-Hartman * not be sufficient to define the entire route path, but rather may only
1148ffdff6aSGreg Kroah-Hartman * indicate the intermediate route. For example, if the route must go through
1158ffdff6aSGreg Kroah-Hartman * the RGOUT0 pin, the (src->RGOUT0) register value will be returned.
1168ffdff6aSGreg Kroah-Hartman * Similarly, if the route must go through the NI_RTSI_BRD lines, the BIT(6)
1178ffdff6aSGreg Kroah-Hartman * will be set:
1188ffdff6aSGreg Kroah-Hartman *
1198ffdff6aSGreg Kroah-Hartman * if route does not need RTSI_BRD lines:
1208ffdff6aSGreg Kroah-Hartman * bits 0:7 : register value
1218ffdff6aSGreg Kroah-Hartman * for a route that must go through RGOUT0 pin, this will be equal
1228ffdff6aSGreg Kroah-Hartman * to the (src->RGOUT0) register value.
1238ffdff6aSGreg Kroah-Hartman * else: * route is (src->RTSI_BRD(x), RTSI_BRD(x)->TRIGGER_LINE(i)) *
1248ffdff6aSGreg Kroah-Hartman * bits 0:5 : zero
1258ffdff6aSGreg Kroah-Hartman * bits 6 : set to 1
1268ffdff6aSGreg Kroah-Hartman * bits 7:7 : zero
1278ffdff6aSGreg Kroah-Hartman *
1288ffdff6aSGreg Kroah-Hartman * Return: register value to be used for source at destination with special
1298ffdff6aSGreg Kroah-Hartman * cases given above; Otherwise, -1 if the specified route is not valid for
1308ffdff6aSGreg Kroah-Hartman * this particular device.
1318ffdff6aSGreg Kroah-Hartman */
1328ffdff6aSGreg Kroah-Hartman s8 ni_route_to_register(const int src, const int dest,
1338ffdff6aSGreg Kroah-Hartman const struct ni_route_tables *tables);
1348ffdff6aSGreg Kroah-Hartman
ni_rtsi_route_requires_mux(s8 value)1358ffdff6aSGreg Kroah-Hartman static inline bool ni_rtsi_route_requires_mux(s8 value)
1368ffdff6aSGreg Kroah-Hartman {
1378ffdff6aSGreg Kroah-Hartman return value & BIT(6);
1388ffdff6aSGreg Kroah-Hartman }
1398ffdff6aSGreg Kroah-Hartman
1408ffdff6aSGreg Kroah-Hartman /*
1418ffdff6aSGreg Kroah-Hartman * ni_lookup_route_register() - Look up a register value for a particular route
1428ffdff6aSGreg Kroah-Hartman * without checking whether the route is valid for
1438ffdff6aSGreg Kroah-Hartman * the particular device.
1448ffdff6aSGreg Kroah-Hartman * @src: global-identifier for route source
1458ffdff6aSGreg Kroah-Hartman * @dest: global-identifier for route destination
1468ffdff6aSGreg Kroah-Hartman * @tables: pointer to relevant set of routing tables.
1478ffdff6aSGreg Kroah-Hartman *
1488ffdff6aSGreg Kroah-Hartman * Return: -EINVAL if the specified route is not valid for this device family.
1498ffdff6aSGreg Kroah-Hartman */
1508ffdff6aSGreg Kroah-Hartman s8 ni_lookup_route_register(int src, int dest,
1518ffdff6aSGreg Kroah-Hartman const struct ni_route_tables *tables);
1528ffdff6aSGreg Kroah-Hartman
1538ffdff6aSGreg Kroah-Hartman /**
1548ffdff6aSGreg Kroah-Hartman * route_is_valid() - Determines whether the specified signal route (src-->dest)
1558ffdff6aSGreg Kroah-Hartman * is valid for the given NI comedi_device.
1568ffdff6aSGreg Kroah-Hartman * @src: global-identifier for route source
1578ffdff6aSGreg Kroah-Hartman * @dest: global-identifier for route destination
1588ffdff6aSGreg Kroah-Hartman * @tables: pointer to relevant set of routing tables.
1598ffdff6aSGreg Kroah-Hartman *
1608ffdff6aSGreg Kroah-Hartman * Return: True if the route is valid, otherwise false.
1618ffdff6aSGreg Kroah-Hartman */
route_is_valid(const int src,const int dest,const struct ni_route_tables * tables)1628ffdff6aSGreg Kroah-Hartman static inline bool route_is_valid(const int src, const int dest,
1638ffdff6aSGreg Kroah-Hartman const struct ni_route_tables *tables)
1648ffdff6aSGreg Kroah-Hartman {
1658ffdff6aSGreg Kroah-Hartman return ni_route_to_register(src, dest, tables) >= 0;
1668ffdff6aSGreg Kroah-Hartman }
1678ffdff6aSGreg Kroah-Hartman
1688ffdff6aSGreg Kroah-Hartman /*
1698ffdff6aSGreg Kroah-Hartman * ni_is_cmd_dest() - Determine whether the given destination is only
1708ffdff6aSGreg Kroah-Hartman * configurable via a comedi_cmd struct.
1718ffdff6aSGreg Kroah-Hartman * @dest: Destination to test.
1728ffdff6aSGreg Kroah-Hartman */
1738ffdff6aSGreg Kroah-Hartman bool ni_is_cmd_dest(int dest);
1748ffdff6aSGreg Kroah-Hartman
channel_is_pfi(int channel)1758ffdff6aSGreg Kroah-Hartman static inline bool channel_is_pfi(int channel)
1768ffdff6aSGreg Kroah-Hartman {
1778ffdff6aSGreg Kroah-Hartman return NI_PFI(0) <= channel && channel <= NI_PFI(-1);
1788ffdff6aSGreg Kroah-Hartman }
1798ffdff6aSGreg Kroah-Hartman
channel_is_rtsi(int channel)1808ffdff6aSGreg Kroah-Hartman static inline bool channel_is_rtsi(int channel)
1818ffdff6aSGreg Kroah-Hartman {
1828ffdff6aSGreg Kroah-Hartman return TRIGGER_LINE(0) <= channel && channel <= TRIGGER_LINE(-1);
1838ffdff6aSGreg Kroah-Hartman }
1848ffdff6aSGreg Kroah-Hartman
channel_is_ctr(int channel)1858ffdff6aSGreg Kroah-Hartman static inline bool channel_is_ctr(int channel)
1868ffdff6aSGreg Kroah-Hartman {
1878ffdff6aSGreg Kroah-Hartman return channel >= NI_COUNTER_NAMES_BASE &&
1888ffdff6aSGreg Kroah-Hartman channel <= NI_COUNTER_NAMES_MAX;
1898ffdff6aSGreg Kroah-Hartman }
1908ffdff6aSGreg Kroah-Hartman
1918ffdff6aSGreg Kroah-Hartman /*
1928ffdff6aSGreg Kroah-Hartman * ni_count_valid_routes() - Count the number of valid routes.
1938ffdff6aSGreg Kroah-Hartman * @tables: Routing tables for which to count all valid routes.
1948ffdff6aSGreg Kroah-Hartman */
1958ffdff6aSGreg Kroah-Hartman unsigned int ni_count_valid_routes(const struct ni_route_tables *tables);
1968ffdff6aSGreg Kroah-Hartman
1978ffdff6aSGreg Kroah-Hartman /*
1988ffdff6aSGreg Kroah-Hartman * ni_get_valid_routes() - Implements INSN_DEVICE_CONFIG_GET_ROUTES.
1998ffdff6aSGreg Kroah-Hartman * @tables: pointer to relevant set of routing tables.
2008ffdff6aSGreg Kroah-Hartman * @n_pairs: Number of pairs for which memory is allocated by the user. If
2018ffdff6aSGreg Kroah-Hartman * the user specifies '0', only the number of available pairs is
2028ffdff6aSGreg Kroah-Hartman * returned.
2038ffdff6aSGreg Kroah-Hartman * @pair_data: Pointer to memory allocated to return pairs back to user. Each
2048ffdff6aSGreg Kroah-Hartman * even, odd indexed member of this array will hold source,
2058ffdff6aSGreg Kroah-Hartman * destination of a route pair respectively.
2068ffdff6aSGreg Kroah-Hartman *
2078ffdff6aSGreg Kroah-Hartman * Return: the number of valid routes if n_pairs == 0; otherwise, the number of
2088ffdff6aSGreg Kroah-Hartman * valid routes copied.
2098ffdff6aSGreg Kroah-Hartman */
2108ffdff6aSGreg Kroah-Hartman unsigned int ni_get_valid_routes(const struct ni_route_tables *tables,
2118ffdff6aSGreg Kroah-Hartman unsigned int n_pairs,
2128ffdff6aSGreg Kroah-Hartman unsigned int *pair_data);
2138ffdff6aSGreg Kroah-Hartman
2148ffdff6aSGreg Kroah-Hartman /*
2158ffdff6aSGreg Kroah-Hartman * ni_sort_device_routes() - Sort the list of valid device signal routes in
2168ffdff6aSGreg Kroah-Hartman * preparation for use.
2178ffdff6aSGreg Kroah-Hartman * @valid_routes: pointer to ni_device_routes struct to sort.
2188ffdff6aSGreg Kroah-Hartman */
2198ffdff6aSGreg Kroah-Hartman void ni_sort_device_routes(struct ni_device_routes *valid_routes);
2208ffdff6aSGreg Kroah-Hartman
2218ffdff6aSGreg Kroah-Hartman /*
2228ffdff6aSGreg Kroah-Hartman * ni_find_route_source() - Finds the signal source corresponding to a signal
2238ffdff6aSGreg Kroah-Hartman * route (src-->dest) of the specified routing register
2248ffdff6aSGreg Kroah-Hartman * value and the specified route destination on the
2258ffdff6aSGreg Kroah-Hartman * specified device.
2268ffdff6aSGreg Kroah-Hartman *
2278ffdff6aSGreg Kroah-Hartman * Note that this function does _not_ validate the source based on device
2288ffdff6aSGreg Kroah-Hartman * routes.
2298ffdff6aSGreg Kroah-Hartman *
2308ffdff6aSGreg Kroah-Hartman * Return: The NI signal value (e.g. NI_PFI(0) or PXI_Clk10) if found.
2318ffdff6aSGreg Kroah-Hartman * If the source was not found (i.e. the register value is not
2328ffdff6aSGreg Kroah-Hartman * valid for any routes to the destination), -EINVAL is returned.
2338ffdff6aSGreg Kroah-Hartman */
2348ffdff6aSGreg Kroah-Hartman int ni_find_route_source(const u8 src_sel_reg_value, const int dest,
2358ffdff6aSGreg Kroah-Hartman const struct ni_route_tables *tables);
2368ffdff6aSGreg Kroah-Hartman
2378ffdff6aSGreg Kroah-Hartman /**
2388ffdff6aSGreg Kroah-Hartman * route_register_is_valid() - Determines whether the register value for the
2398ffdff6aSGreg Kroah-Hartman * specified route destination on the specified
2408ffdff6aSGreg Kroah-Hartman * device is valid.
2418ffdff6aSGreg Kroah-Hartman */
route_register_is_valid(const u8 src_sel_reg_value,const int dest,const struct ni_route_tables * tables)2428ffdff6aSGreg Kroah-Hartman static inline bool route_register_is_valid(const u8 src_sel_reg_value,
2438ffdff6aSGreg Kroah-Hartman const int dest,
2448ffdff6aSGreg Kroah-Hartman const struct ni_route_tables *tables)
2458ffdff6aSGreg Kroah-Hartman {
2468ffdff6aSGreg Kroah-Hartman return ni_find_route_source(src_sel_reg_value, dest, tables) >= 0;
2478ffdff6aSGreg Kroah-Hartman }
2488ffdff6aSGreg Kroah-Hartman
2498ffdff6aSGreg Kroah-Hartman /**
2508ffdff6aSGreg Kroah-Hartman * ni_get_reg_value_roffs() - Determines the proper register value for a
2518ffdff6aSGreg Kroah-Hartman * particular valid NI signal/terminal route.
2528ffdff6aSGreg Kroah-Hartman * @src: Either a direct register value or one of NI_* signal names.
2538ffdff6aSGreg Kroah-Hartman * @dest: global-identifier for route destination
2548ffdff6aSGreg Kroah-Hartman * @tables: pointer to relevant set of routing tables.
2558ffdff6aSGreg Kroah-Hartman * @direct_reg_offset:
2568ffdff6aSGreg Kroah-Hartman * Compatibility compensation argument. This argument allows us to
2578ffdff6aSGreg Kroah-Hartman * arbitrarily apply an offset to src if src is a direct register
2588ffdff6aSGreg Kroah-Hartman * value reference. This is necessary to be compatible with
2598ffdff6aSGreg Kroah-Hartman * definitions of register values as previously exported directly
2608ffdff6aSGreg Kroah-Hartman * to user space.
2618ffdff6aSGreg Kroah-Hartman *
2628ffdff6aSGreg Kroah-Hartman * Return: the register value (>0) to be used at the destination if the src is
2638ffdff6aSGreg Kroah-Hartman * valid for the given destination; -1 otherwise.
2648ffdff6aSGreg Kroah-Hartman */
ni_get_reg_value_roffs(int src,const int dest,const struct ni_route_tables * tables,const int direct_reg_offset)2658ffdff6aSGreg Kroah-Hartman static inline s8 ni_get_reg_value_roffs(int src, const int dest,
2668ffdff6aSGreg Kroah-Hartman const struct ni_route_tables *tables,
2678ffdff6aSGreg Kroah-Hartman const int direct_reg_offset)
2688ffdff6aSGreg Kroah-Hartman {
2698ffdff6aSGreg Kroah-Hartman if (src < NI_NAMES_BASE) {
2708ffdff6aSGreg Kroah-Hartman src += direct_reg_offset;
2718ffdff6aSGreg Kroah-Hartman /*
2728ffdff6aSGreg Kroah-Hartman * In this case, the src is expected to actually be a register
2738ffdff6aSGreg Kroah-Hartman * value.
2748ffdff6aSGreg Kroah-Hartman */
2758ffdff6aSGreg Kroah-Hartman if (route_register_is_valid(src, dest, tables))
2768ffdff6aSGreg Kroah-Hartman return src;
2778ffdff6aSGreg Kroah-Hartman return -1;
2788ffdff6aSGreg Kroah-Hartman }
2798ffdff6aSGreg Kroah-Hartman
2808ffdff6aSGreg Kroah-Hartman /*
2818ffdff6aSGreg Kroah-Hartman * Otherwise, the src is expected to be one of the abstracted NI
2828ffdff6aSGreg Kroah-Hartman * signal/terminal names.
2838ffdff6aSGreg Kroah-Hartman */
2848ffdff6aSGreg Kroah-Hartman return ni_route_to_register(src, dest, tables);
2858ffdff6aSGreg Kroah-Hartman }
2868ffdff6aSGreg Kroah-Hartman
ni_get_reg_value(const int src,const int dest,const struct ni_route_tables * tables)2878ffdff6aSGreg Kroah-Hartman static inline int ni_get_reg_value(const int src, const int dest,
2888ffdff6aSGreg Kroah-Hartman const struct ni_route_tables *tables)
2898ffdff6aSGreg Kroah-Hartman {
2908ffdff6aSGreg Kroah-Hartman return ni_get_reg_value_roffs(src, dest, tables, 0);
2918ffdff6aSGreg Kroah-Hartman }
2928ffdff6aSGreg Kroah-Hartman
2938ffdff6aSGreg Kroah-Hartman /**
2948ffdff6aSGreg Kroah-Hartman * ni_check_trigger_arg_roffs() - Checks the trigger argument (*_arg) of an NI
2958ffdff6aSGreg Kroah-Hartman * device to ensure that the *_arg value
2968ffdff6aSGreg Kroah-Hartman * corresponds to _either_ a valid register value
2978ffdff6aSGreg Kroah-Hartman * to define a trigger source, _or_ a valid NI
2988ffdff6aSGreg Kroah-Hartman * signal/terminal name that has a valid route to
2998ffdff6aSGreg Kroah-Hartman * the destination on the particular device.
3008ffdff6aSGreg Kroah-Hartman * @src: Either a direct register value or one of NI_* signal names.
3018ffdff6aSGreg Kroah-Hartman * @dest: global-identifier for route destination
3028ffdff6aSGreg Kroah-Hartman * @tables: pointer to relevant set of routing tables.
3038ffdff6aSGreg Kroah-Hartman * @direct_reg_offset:
3048ffdff6aSGreg Kroah-Hartman * Compatibility compensation argument. This argument allows us to
3058ffdff6aSGreg Kroah-Hartman * arbitrarily apply an offset to src if src is a direct register
3068ffdff6aSGreg Kroah-Hartman * value reference. This is necessary to be compatible with
3078ffdff6aSGreg Kroah-Hartman * definitions of register values as previously exported directly
3088ffdff6aSGreg Kroah-Hartman * to user space.
3098ffdff6aSGreg Kroah-Hartman *
3108ffdff6aSGreg Kroah-Hartman * Return: 0 if the src (either register value or NI signal/terminal name) is
3118ffdff6aSGreg Kroah-Hartman * valid for the destination; -EINVAL otherwise.
3128ffdff6aSGreg Kroah-Hartman */
3138ffdff6aSGreg Kroah-Hartman static inline
ni_check_trigger_arg_roffs(int src,const int dest,const struct ni_route_tables * tables,const int direct_reg_offset)3148ffdff6aSGreg Kroah-Hartman int ni_check_trigger_arg_roffs(int src, const int dest,
3158ffdff6aSGreg Kroah-Hartman const struct ni_route_tables *tables,
3168ffdff6aSGreg Kroah-Hartman const int direct_reg_offset)
3178ffdff6aSGreg Kroah-Hartman {
3188ffdff6aSGreg Kroah-Hartman if (ni_get_reg_value_roffs(src, dest, tables, direct_reg_offset) < 0)
3198ffdff6aSGreg Kroah-Hartman return -EINVAL;
3208ffdff6aSGreg Kroah-Hartman return 0;
3218ffdff6aSGreg Kroah-Hartman }
3228ffdff6aSGreg Kroah-Hartman
ni_check_trigger_arg(const int src,const int dest,const struct ni_route_tables * tables)3238ffdff6aSGreg Kroah-Hartman static inline int ni_check_trigger_arg(const int src, const int dest,
3248ffdff6aSGreg Kroah-Hartman const struct ni_route_tables *tables)
3258ffdff6aSGreg Kroah-Hartman {
3268ffdff6aSGreg Kroah-Hartman return ni_check_trigger_arg_roffs(src, dest, tables, 0);
3278ffdff6aSGreg Kroah-Hartman }
3288ffdff6aSGreg Kroah-Hartman
3298ffdff6aSGreg Kroah-Hartman #endif /* _COMEDI_DRIVERS_NI_ROUTES_H */
330