ni_route_to_register(9)

πŸ“¦ version 7.3.1, in nixpkgs unstable

πŸ’… ni_route_to_register(9) β€” the "which register value is this route, bestie?" glow-up

Okay so this is a page from the Kernel API Manual, and it's genuinely one of the more niche little functions in the comedi ni_routes corner of the kernel. Sit down, grab a strawberry drink πŸ“, and let's get into it.


✨ NAME ✨

ni_route_to_register β€” validates and converts the specified signal route (src-->dest) to the value used at the appropriate register. That's it, that's the whole job. It checks the route is legit, then hands you back the magic number that goes in the register. πŸŽ€


✨ SYNOPSIS ✨

s8 ni_route_to_register (const int src , const int dest , const struct
ni_route_tables *tables );

Note the return type is s8 β€” a signed 8-bit value, which matters a lot later, so keep that in your pocket. 🫢


🌸 ARGUMENTS 🌸

  • src β€” the global-identifier for the route source. Like, where the signal is coming from, bestie.
  • dest β€” the global-identifier for the route destination. Where it's going. The main character of the route, honestly.
  • tables β€” pointer to the relevant set of routing tables. This is the lookup lore. πŸ“š

πŸ’œ DESCRIPTION πŸ’œ

Generally speaking β€” like, in the common case, no cap β€” most routes require the first six bits, and a few require 7 bits. Simple. Iconic. We love a straightforward bit layout.

But then. Then. Special handling is given for the return value when the route is to be handled by the RTSI sub-device. 😭 And this is the part where you have to pay attention, because in this case the returned register may not be sufficient to define the entire route path β€” it may only indicate the intermediate route. It's giving "here's a clue, not the whole answer."

For example: if the route must go through the RGOUT0 pin, the (src->RGOUT0) register value will be returned. Similarly, if the route must go through the NI_RTSI_BRD lines, BIT(6) will be set:

if route does not need RTSI_BRD lines: bits 0:7 : register value for a
route that must go through RGOUT0 pin, this will be equal to the
(src->RGOUT0) register value.  else: * route is (src->RTSI_BRD(x),
RTSI_BRD(x)->TRIGGER_LINE(i)) * bits 0:5 : zero bits 6   : set to 1 bits
7:7 : zero

Read that twice, babe. The bit fields are literally doing the group-chat callout for you: bits 0:5 zero, bit 6 set to 1, bit 7:7 zero in the else branch. πŸ”₯


πŸ‘‘ RETURN πŸ‘‘

  • register value to be used for source at destination β€” with the special cases given above, iykyk.
  • Otherwise, -1 if the specified route is not valid for this particular device. Like, invalid route, invalid vibes, no value for you. πŸ’€

🌈 SEE ALSO 🌈

Kernel file ./drivers/comedi/drivers/ni_routes.c β€” the whole friend group, honestly:


Alright bestie, that's the page. Quick sign-off moment πŸŽ€: this one lives in ./drivers/comedi/drivers, and it's dated October 2026, filed under ni_route_to_register(9). Slay, go validate your routes responsibly. πŸ’–

πŸ“¦ where this page comes from