Linux IIO development
 help / color / mirror / Atom feed
From: "Cercueil, Paul" <Paul.Cercueil@analog.com>
To: "preid@electromag.com.au" <preid@electromag.com.au>,
	"linux-iio@vger.kernel.org" <linux-iio@vger.kernel.org>
Subject: Re: Question on shared attributes
Date: Tue, 28 Jun 2016 10:38:09 +0000	[thread overview]
Message-ID: <1467110288.2364.11.camel@analog.com> (raw)
In-Reply-To: <e87b35bc-36e9-dc1a-a87e-4e1c20db8d2e@electromag.com.au>

[-- Attachment #1: Type: text/plain, Size: 8528 bytes --]

Hi Phil,

I think right now libiio doesn't handle shared-by-dir attributes yet,
only shared-by-type. Ideally, 'in_sampling_frequency' should appear as
a 'sampling_frequency' attribute on all input channels of your module0
device.

Regards,
Paul Cercueil

Le mardi 28 juin 2016 à 16:55 +0800, Phil Reid a écrit :
> G'day All,
> 
> Found something interesting.
> For a new iio driver I have a shared attribute on direction.
> 
> .info_mask_shared_by_dir = BIT(IIO_CHAN_INFO_SAMP_FREQ)
> 
> Which results in sysfs attribute name of:
> in_sampling_frequency
> 
> Which results in iio_info giving the following output:
> iio:device3: module0
>          7 channels found:
>                  voltage0:  (input)
>                  6 channel-specific attributes found:
>                          attr 0: scale value: 0.000149011
>                          attr 1: raw value: 0
>                          attr 2: hardwaregain value: 1
>                          attr 3: index value: 0
>                          attr 4: en value: 0
>                          attr 5: type value: le:s24/32>>0
>                  voltage1:  (input)
>                  6 channel-specific attributes found:
>                          attr 0: raw value: 0
>                          attr 1: scale value: 0.000149011
>                          attr 2: hardwaregain value: 1
>                          attr 3: en value: 0
>                          attr 4: index value: 1
>                          attr 5: type value: le:s24/32>>0
>                  voltage2:  (input)
>                  6 channel-specific attributes found:
>                          attr 0: raw value: 0
>                          attr 1: scale value: 0.000149011
>                          attr 2: hardwaregain value: 1
>                          attr 3: en value: 0
>                          attr 4: index value: 2
>                          attr 5: type value: le:s24/32>>0
>                  voltage3:  (input)
>                  6 channel-specific attributes found:
>                          attr 0: hardwaregain value: 1
>                          attr 1: raw value: 0
>                          attr 2: scale value: 0.000149011
>                          attr 3: en value: 0
>                          attr 4: type value: le:s24/32>>0
>                          attr 5: index value: 3
>                  voltage4:  (output)
>                  2 channel-specific attributes found:
>                          attr 0: raw value: 32768
>                          attr 1: scale value: 2500000.000000000
>                  voltage5:  (output)
>                  2 channel-specific attributes found:
>                          attr 0: raw value: 32768
>                          attr 1: scale value: 2500000.000000000
>                  sampling:  (input)
>                  1 channel-specific attributes found:
>                          attr 0: frequency value: 24000
>          2 device-specific attributes found:
>                          attr 0: freq value: 6144000
>                          attr 1: out_en value: 0
> 
> 
> Note that the sampling_frequency attr has been converted into an
> input channel.
> 
> Modify the definition in industrialio-core.c
> 	[IIO_CHAN_INFO_SAMP_FREQ] = "sampling_frequency",
> to
> 	[IIO_CHAN_INFO_SAMP_FREQ] = "samplingfrequency",
> 
> Results in the following output:
> iio:device4: module0
>          6 channels found:
>                  voltage0:  (input)
>                  6 channel-specific attributes found:
>                          attr 0: scale value: 0.000149011
>                          attr 1: raw value: 0
>                          attr 2: hardwaregain value: 1
>                          attr 3: index value: 0
>                          attr 4: en value: 0
>                          attr 5: type value: le:s24/32>>0
>                  voltage1:  (input)
>                  6 channel-specific attributes found:
>                          attr 0: raw value: 0
>                          attr 1: scale value: 0.000149011
>                          attr 2: hardwaregain value: 1
>                          attr 3: en value: 0
>                          attr 4: index value: 1
>                          attr 5: type value: le:s24/32>>0
>                  voltage2:  (input)
>                  6 channel-specific attributes found:
>                          attr 0: raw value: 0
>                          attr 1: scale value: 0.000149011
>                          attr 2: hardwaregain value: 1
>                          attr 3: en value: 0
>                          attr 4: index value: 2
>                          attr 5: type value: le:s24/32>>0
>                  voltage3:  (input)
>                  6 channel-specific attributes found:
>                          attr 0: hardwaregain value: 1
>                          attr 1: raw value: 0
>                          attr 2: scale value: 0.000149011
>                          attr 3: en value: 0
>                          attr 4: type value: le:s24/32>>0
>                          attr 5: index value: 3
>                  voltage4:  (output)
>                  2 channel-specific attributes found:
>                          attr 0: raw value: 32768
>                          attr 1: scale value: 2500000.000000000
>                  voltage5:  (output)
>                  2 channel-specific attributes found:
>                          attr 0: raw value: 32768
>                          attr 1: scale value: 2500000.000000000
>          3 device-specific attributes found:
>                          attr 0: freq value: 6144000
>                          attr 1: in_samplingfrequency value: 24000
>                          attr 2: out_en value: 0
> 
> Which makes more sense. So libiio is treating the name sampling as a
> channel name
> in 'in_sampling_frequency' assuming that attributes never have an
> underscore in there name.
> 
> I'm guessing the same would be the case for out attributes as well.
> 
> A quick search of the drivers in the kernel to date indicate that
> IIO_CHAN_INFO_SAMP_FREQ is generally
> shared by type or all. shared by dir occurs with the
> iio_simple_dummy, but can't see anything with a real device.
> I'm using libiio from git://github.com/analogdevicesinc/libiio.git
> 
> So is this intended, or does libiio need to be smarter on identifying
> channels and shared attributes?
> I'm guessing we cant change the kernel interface, which would be the
> easiest fix. :/
> 
> 

[-- Attachment #2: This is a digitally signed message part --]
[-- Type: application/pgp-signature, Size: 473 bytes --]

  reply	other threads:[~2016-06-28 11:11 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-06-28  8:55 Question on shared attributes Phil Reid
2016-06-28 10:38 ` Cercueil, Paul [this message]
2016-06-29  3:24   ` Phil Reid

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1467110288.2364.11.camel@analog.com \
    --to=paul.cercueil@analog.com \
    --cc=linux-iio@vger.kernel.org \
    --cc=preid@electromag.com.au \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox