Re: [PATCH v5 3/3] iio: light: Add support for APDS9306 Light Sensor

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Sun, 4 Feb 2024 21:53:55 +1030
Subhajit Ghosh <subhajit.ghosh@xxxxxxxxxxxxxx> wrote:

> Hi Jonathan,
> >>  
> >>> +
> >>> +static struct iio_event_spec apds9306_event_spec_als[] = {
> >>> +    {
> >>> +        .type = IIO_EV_TYPE_THRESH,
> >>> +        .dir = IIO_EV_DIR_RISING,
> >>> +        .mask_shared_by_all = BIT(IIO_EV_INFO_VALUE),
> >>> +    }, {
> >>> +        .type = IIO_EV_TYPE_THRESH,
> >>> +        .dir = IIO_EV_DIR_FALLING,
> >>> +        .mask_shared_by_all = BIT(IIO_EV_INFO_VALUE),
> >>> +    }, {
> >>> +        .type = IIO_EV_TYPE_THRESH,
> >>> +        .mask_shared_by_all = BIT(IIO_EV_INFO_PERIOD),
> >>> +    }, {
> >>> +        .type = IIO_EV_TYPE_THRESH_ADAPTIVE,
> >>> +        .mask_shared_by_all = BIT(IIO_EV_INFO_VALUE) |
> >>> +            BIT(IIO_EV_INFO_ENABLE),
> >>> +    }, {
> >>> +        .mask_separate = BIT(IIO_EV_INFO_ENABLE),  
> >>
> >> What's the intent of this final entry?
> >> The type will default to IIO_EV_TYPE_THRESH anyway but if that
> >> the intent you should specify it.   There isn't an 'obvious'
> >> default for type in the same way there sort of is for dir
> >> (as it's either direction).  
> > Understood, let me experiment and see the ABI difference, if any and get back to you.
> >   
> This device has two channels - ALS and CLEAR. One interrupt enable option and
> one Channel selection option (Clear or ALS). According to our previous discussions:
> https://lore.kernel.org/all/20230415183543.6d5e3392@jic23-huawei/
> the event_spec was updated to have two interrupt enable attributes - one for CLEAR and
> one for ALS. (Intensity channel and Illuminance channel)
> 
> If I remove the final entry I am getting only one enable option (intensity channel):
> /sys/bus/iio/devices/iio:device0/
> |-- events
> |   |-- in_intensity_clear_thresh_either_en
> |   |-- thresh_adaptive_either_en
> |   |-- thresh_adaptive_either_value
> |   |-- thresh_adaptive_either_values_available
> |   |-- thresh_either_period
> |   |-- thresh_either_period_available
> |   |-- thresh_falling_value
> |   `-- thresh_rising_value
> 
> The last entry gives be the following event attributes, enable attributes for both
> intensity and illuminance channels:
> /sys/bus/iio/devices/iio:device0/
> |-- events
> |   |-- in_illuminance_thresh_either_en
> |   |-- in_intensity_clear_thresh_either_en
> |   |-- thresh_adaptive_either_en
> |   |-- thresh_adaptive_either_value
> |   |-- thresh_adaptive_either_values_available
> |   |-- thresh_either_period
> |   |-- thresh_either_period_available
> |   |-- thresh_falling_value
> |   `-- thresh_rising_value
> 
> Please let me know if this sounds ok to you.
Looks like coincidence of enum values being 0.
It's really
{
	.type = IIO_EV_TYPE_THRESH, /* Value 0 */
	.dir = IIO_EV_DIR_EITHER, /* value 0 */
	.mask_separate = BIT(IIO_EV_INFO_ENABLE),

Dropping 'defaults' for these things is fine if they are the obvious default
or other parameters mean they aren't used, but that isn't the case here so
please be explicit for all the values that are used.

You can put this final mask a few lines earlier as the other fields match
anyway.
	{
        	.type = IIO_EV_TYPE_THRESH,
		.dir = IIO_EV_DIR_EITHER,
        	.mask_shared_by_all = BIT(IIO_EV_INFO_PERIOD),
		.mask_separate = BIT(IIO_EV_INFO_ENABLE),
	},..

> 
> Regards,
> Subhajit Ghosh






[Index of Archives]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Yosemite News]     [Linux Input]     [Linux Kernel]     [Linux SCSI]     [X.org]

  Powered by Linux