Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

missing iio_channel_get_label(const struct iio_channel *chn) function #1222

Open
rgetz opened this issue Dec 30, 2024 · 5 comments
Open

missing iio_channel_get_label(const struct iio_channel *chn) function #1222

rgetz opened this issue Dec 30, 2024 · 5 comments
Assignees

Comments

@rgetz
Copy link
Contributor

rgetz commented Dec 30, 2024

While libiio supports reading device labels for the last three years.

Some devices (ion hwmon) have channel labels - which seems to be a good idea for userspace:

        hwmon18: max15301 (label: VCCPSINT)
                5 channels found:
                        curr1:  (input)
                        4 channel-specific attributes found:
                                attr  0: crit (curr1_crit) value: 11015
                                attr  1: crit_alarm (curr1_crit_alarm) value: 0
                                attr  2: input (curr1_input) value: 1560
                                attr  3: label (curr1_label) value: iout1
                        temp2:  (input)
                        3 channel-specific attributes found:
                                attr  0: crit (temp2_crit) value: 115000
                                attr  1: crit_alarm (temp2_crit_alarm) value: 0
                                attr  2: input (temp2_input) value: 44375
                        in1:  (input)
                        3 channel-specific attributes found:
                                attr  0: alarm (in1_alarm) value: 0
                                attr  1: input (in1_input) value: 12000
                                attr  2: label (in1_label) value: vin
                        temp1:  (input)
                        3 channel-specific attributes found:
                                attr  0: crit (temp1_crit) value: 115000
                                attr  1: crit_alarm (temp1_crit_alarm) value: 0
                                attr  2: input (temp1_input) value: 41375
                        in2:  (input)
                        3 channel-specific attributes found:
                                attr  0: alarm (in2_alarm) value: 0
                                attr  1: input (in2_input) value: 849
                                attr  2: label (in2_label) value: vout1
                No trigger on this device

vin and vout1 is much more user intuitive than in1 and in2.

Supporting this with a function like:

   iio_channel_get_label(const struct iio_channel *chn)

seems like a no brainer...

See hwmon sysfs Doc:

in[0-*]_label	Suggested voltage channel label.
		Text string
		Should only be created if the driver has hints about what
		this voltage channel is being used for, and user-space
		doesn't. In all other cases, the label is provided by
		user-space.
		RO

fan[1-*]_label	Suggested fan channel label.
		Text string
		Should only be created if the driver has hints about what
		this fan channel is being used for, and user-space doesn't.
		In all other cases, the label is provided by user-space.
		RO

temp[1-*]_label	Suggested temperature channel label.
		Text string
		Should only be created if the driver has hints about what
		this temperature channel is being used for, and user-space
		doesn't. In all other cases, the label is provided by
		user-space.
		RO

IIO seems to support it as well:

What:		/sys/bus/iio/devices/iio:deviceX/in_voltageY_label
What:		/sys/bus/iio/devices/iio:deviceX/out_voltageY_label
KernelVersion:	5.8
Contact:	[email protected]
Description:
		Optional symbolic label to a device channel.
		If a label is defined for this channel add that to the channel
		specific attributes. This is useful for userspace to be able to
		better identify an individual channel.

What:		/sys/bus/iio/devices/iio:deviceX/in_anglY_label
KernelVersion:	5.12
Contact:	[email protected]
Description:
		Optional symbolic label for channel Y.
		For Intel hid hinge sensor, the label values are:
		hinge, keyboard, screen. It means the three channels
		each correspond respectively to hinge angle, keyboard angle,
		and screen angle.

What:		/sys/bus/iio/devices/iio:deviceX/events/in_altvoltageY_mag_either_label
What:		/sys/bus/iio/devices/iio:deviceX/events/in_altvoltageY_mag_rising_label
What:		/sys/bus/iio/devices/iio:deviceX/events/in_altvoltageY_thresh_falling_label
What:		/sys/bus/iio/devices/iio:deviceX/events/in_altvoltageY_thresh_rising_label
What:		/sys/bus/iio/devices/iio:deviceX/events/in_anglvelY_mag_rising_label
What:		/sys/bus/iio/devices/iio:deviceX/events/in_anglY_thresh_rising_label
What:		/sys/bus/iio/devices/iio:deviceX/events/in_phaseY_mag_rising_label
KernelVersion:	6.7
Contact:	[email protected]
Description:
		Optional symbolic label to a device channel event.
		If a label is defined for this event add that to the event
		specific attributes. This is useful for userspace to be able to
		better identify an individual event.

its just libiio that does not.

@rgetz
Copy link
Contributor Author

rgetz commented Dec 30, 2024

Here are the sequnce of commits that @pcercuei did for adding device labels - channel labels should be similar:

and then bindings:

and then utils:

and then (as a best practice) make sure that new kernel device drivers have labels if the channels will be mostly constant.

@nunojsa
Copy link
Contributor

nunojsa commented Jan 3, 2025

Agreed, makes sense to support this...

@rgetz
Copy link
Contributor Author

rgetz commented Jan 8, 2025

would be nice to support this before 1.0 is released ...

??

@mhennerich
Copy link
Contributor

Dan can you please have a look?

@dNechita
Copy link
Contributor

dNechita commented Jan 9, 2025

Yes, I will make this a priority.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants