* Getting error "failed to setup attributes" on Adding Custom Fields in accelerometer HID driver
@ 2015-02-27 13:15 s.rawat
[not found] ` <CALwa49uj+e-=fqkppQPd+NfXwG03+joHqBHGYyjvOWgrmvD-4Q@mail.gmail.com>
0 siblings, 1 reply; 8+ messages in thread
From: s.rawat @ 2015-02-27 13:15 UTC (permalink / raw)
To: kernelnewbies
Do I need to define the all the Usage Tags in the input report of a sensor
to retrieve minimum any one field or Only a Usage Tag which I wanted to
retrieve is enough.
e.g for an input report of an accelerometer which has the below
fields(added new one in Bold),
HID_USAGE_SENSOR_ACCEL_X_AXIS
HID_USAGE_SENSOR_ACCEL_Y_AXIS
HID_USAGE_SENSOR_ACCEL_Z_AXIS
*HID_USAGE_SENSOR_DATA_MOTION_STATE,*
*HID_USAGE_SENSOR_DATA_CUSTOM_VALUE_2*
*HID_USAGE_SENSOR_DATA_CUSTOM_VALUE_3*
*HID_USAGE_SENSOR_DATA_CUSTOM_VALUE_4*
I want to retrieve Custom_Value_4 do I also need to define parameters for
Data_Motion_state, Custom_Value2,Custom_Value3 as well apart
from Custom_Value4 in the below structure.
enum accel_3d_channel {.. }
struct accel_3d_state {.. }
static const struct iio_chan_spec accel_3d_channels[] = { ..}
I did so but was getting error - "failed to setup attributes" but after I
modified the code in the function : accel_3d_parse_report() like below to
accommodate all the non Contigous Usage Tags and associated them with their
channels - *_SCAN_INDEX_* . I did not get this error but some other error
(listed at the end of the mail)
//First Three channel X,Y and Z whose Usage Tags are contionus
- 0x200453/54/55
for (i = 0; i <= CHANNEL_SCAN_INDEX_Z; ++i) {
ret = sensor_hub_input_get_attribute_info(hsdev,
HID_INPUT_REPORT,
usage_id,
HID_USAGE_SENSOR_ACCEL_X_AXIS + i,
&st->accel[CHANNEL_SCAN_INDEX_X + i]);
accel_3d_adjust_channel_bit_mask(channels,
CHANNEL_SCAN_INDEX_X + i,
st->accel[CHANNEL_SCAN_INDEX_X + i].size);
}
//Fourth channel For Data Motion - 0x200451
ret = sensor_hub_input_get_attribute_info(hsdev,
HID_INPUT_REPORT,
usage_id,
HID_USAGE_SENSOR_DATA_MOTION_STATE, // For CHANNEL_SCAN_DATA_MOTION
&st->accel[CHANNEL_SCAN_INDEX_X + i]);
accel_3d_adjust_channel_bit_mask(channels,
CHANNEL_SCAN_INDEX_X + i,
st->accel[CHANNEL_SCAN_INDEX_X + i].size);
//Last Three Channel for Custom Value 2,3,4 - 0x200545/46/47
for (i = 0; i <= 2; ++i) {
ret = sensor_hub_input_get_attribute_info(hsdev,
HID_INPUT_REPORT,
usage_id,
HID_USAGE_SENSOR_DATA_CUSTOM_VALUE_2 + i,
&st->accel[CHANNEL_SCAN_INDEX_X + i + 4]); //start after
CHANNEL_SCAN_DATA_MOTION Channel
accel_3d_adjust_channel_bit_mask(channels,
CHANNEL_SCAN_INDEX_X + i + 4,
st->accel[CHANNEL_SCAN_INDEX_X + i].size);
}
But now I am getting a different error :
[13778.127716] iio iio:device4: tried to double register : in_accel_x_index
[13778.127899] hid_sensor_accel_3d HID-SENSOR-200073.3.auto: failed to
initialize trigger buffer
[13778.143676] hid_sensor_accel_3d: probe of HID-SENSOR-200073.3.auto
failed with error -16
I am still figuring out where else Do I have to modify the code in order to
receive the above custom values ..
Thanks,
S
On Thu, Feb 26, 2015 at 6:54 PM, Daniel Baluta <daniel.baluta@gmail.com>
wrote:
> + linux-iio list.
>
> On Thu, Feb 26, 2015 at 8:04 AM, s.rawat <imsaurabhrawat@gmail.com> wrote:
> > I have modified the hid-sensor-accel_3d.c driver to add the custom
> fields -
> > CHANNEL_SCAN_DATA_MOTION and HID_USAGE_SENSOR_DATA_CUSTOM_VALUEX ( X =
> > 2,3,4).
> > Below are my modifications :
> >
> > enum accel_3d_channel {
> > CHANNEL_SCAN_INDEX_X,
> > CHANNEL_SCAN_INDEX_Y,
> > CHANNEL_SCAN_INDEX_Z,
> > CHANNEL_SCAN_DATA_MOTION,
> > CHANNEL_CUSTOM_VALUE_2,
> > CHANNEL_CUSTOM_VALUE_3,
> > CHANNEL_CUSTOM_VALUE_4,
> > ACCEL_3D_CHANNEL_MAX,
> >
> > static const u32 accel_3d_addresses[ACCEL_3D_CHANNEL_MAX] = {
> > HID_USAGE_SENSOR_ACCEL_X_AXIS,
> > HID_USAGE_SENSOR_ACCEL_Y_AXIS,
> > HID_USAGE_SENSOR_ACCEL_Z_AXIS,
> > HID_USAGE_SENSOR_DATA_MOTION_STATE,
> > HID_USAGE_SENSOR_DATA_CUSTOM_VALUE2,
> > HID_USAGE_SENSOR_DATA_CUSTOM_VALUE3,
> > HID_USAGE_SENSOR_DATA_CUSTOM_VALUE4
> > };
> >
> >
> >
> > /* Channel definitions */
> > static const struct iio_chan_spec accel_3d_channels[] = {
> > {
> > ..
> > ..
> > ..
> > {
> > .type = IIO_ACCEL,
> > .modified = 1,
> > .channel2 = IIO_MOD_X,
> > .info_mask_separate = BIT(IIO_CHAN_INFO_RAW),
> > .info_mask_shared_by_type = BIT(IIO_CHAN_INFO_OFFSET) |
> > BIT(IIO_CHAN_INFO_SCALE) |
> > BIT(IIO_CHAN_INFO_SAMP_FREQ) |
> > BIT(IIO_CHAN_INFO_HYSTERESIS),
> > .scan_index = CHANNEL_SCAN_DATA_MOTION,
> > },
> > {
> > .type = IIO_ACCEL,
> > .modified = 1,
> > .channel2 = IIO_MOD_X,
> > .info_mask_separate = BIT(IIO_CHAN_INFO_RAW),
> > .info_mask_shared_by_type = BIT(IIO_CHAN_INFO_OFFSET) |
> > BIT(IIO_CHAN_INFO_SCALE) |
> > BIT(IIO_CHAN_INFO_SAMP_FREQ) |
> > BIT(IIO_CHAN_INFO_HYSTERESIS),
> > .scan_index = CHANNEL_CUSTOM_VALUE_2,
> > },
> > {
> > .type = IIO_ACCEL,
> > .modified = 1,
> > .channel2 = IIO_MOD_X,
> > .info_mask_separate = BIT(IIO_CHAN_INFO_RAW),
> > .info_mask_shared_by_type = BIT(IIO_CHAN_INFO_OFFSET) |
> > BIT(IIO_CHAN_INFO_SCALE) |
> > BIT(IIO_CHAN_INFO_SAMP_FREQ) |
> > BIT(IIO_CHAN_INFO_HYSTERESIS),
> > .scan_index = CHANNEL_CUSTOM_VALUE_3,
> > },
> > {
> > .type = IIO_ACCEL,
> > .modified = 1,
> > .channel2 = IIO_MOD_X,
> > .info_mask_separate = BIT(IIO_CHAN_INFO_RAW),
> > .info_mask_shared_by_type = BIT(IIO_CHAN_INFO_OFFSET) |
> > BIT(IIO_CHAN_INFO_SCALE) |
> > BIT(IIO_CHAN_INFO_SAMP_FREQ) |
> > BIT(IIO_CHAN_INFO_HYSTERESIS),
> > .scan_index = CHANNEL_CUSTOM_VALUE_4,
> > }
> >
> >
> >
> > /* Capture samples in local storage */
> > static int accel_3d_capture_sample(struct hid_sensor_hub_device *hsdev,
> > unsigned usage_id,
> > size_t raw_len, char *raw_data,
> > void *priv)
> > {
> > struct iio_dev *indio_dev = platform_get_drvdata(priv);
> > struct accel_3d_state *accel_state = iio_priv(indio_dev);
> > int offset;
> > int ret = -EINVAL;
> >
> > switch (usage_id) {
> > case HID_USAGE_SENSOR_ACCEL_X_AXIS:
> > case HID_USAGE_SENSOR_ACCEL_Y_AXIS:
> > case HID_USAGE_SENSOR_ACCEL_Z_AXIS:
> > case HID_USAGE_SENSOR_DATA_MOTION_STATE:
> > case HID_USAGE_SENSOR_DATA_CUSTOM_VALUE2:
> > case HID_USAGE_SENSOR_DATA_CUSTOM_VALUE3:
> > case HID_USAGE_SENSOR_DATA_CUSTOM_VALUE4:
> > offset = usage_id - HID_USAGE_SENSOR_ACCEL_X_AXIS;
> >
> >
> >
> > /* Parse report which is specific to an usage id*/
> > static int accel_3d_parse_report(struct platform_device *pdev,
> > struct hid_sensor_hub_device *hsdev,
> > struct iio_chan_spec *channels,
> > unsigned usage_id,
> > struct accel_3d_state *st)
> > {
> > int ret;
> > int i;
> >
> > for (i = 0; i <= CHANNEL_CUSTOM_VALUE_4; ++i) { //previously <
> > CHANNEL_SCAN_INDEX_Z
> > ret = sensor_hub_input_get_attribute_info(hsdev,
> >
> >
> >
> > After build /insmod i get the following dmesg :
> >
> > hid_sensor_accel_3d:HID-SENSOR-200073.3 auto : failed to setup attributes
> > hid_sensor_accel_3d:HID-SENSOR-200073.3 auto.failed with error -1
> >
> >
> > I am not getting what else I have to modify to avoid this error .If i
> remove
> > the portion in bold(and use this original code
> > :
> http://lxr.free-electrons.com/source/drivers/iio/accel/hid-sensor-accel-3d.c
> )
> > I can happily insert the module without any error and can interact with
> the
> > driver using my application.
> >
> >
> > _______________________________________________
> > Kernelnewbies mailing list
> > Kernelnewbies at kernelnewbies.org
> > http://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies
> >
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.kernelnewbies.org/pipermail/kernelnewbies/attachments/20150227/698e6634/attachment.html
^ permalink raw reply [flat|nested] 8+ messages in thread[parent not found: <CALwa49uj+e-=fqkppQPd+NfXwG03+joHqBHGYyjvOWgrmvD-4Q@mail.gmail.com>]
* Re: Getting error "failed to setup attributes" on Adding Custom Fields in accelerometer HID driver [not found] ` <CALwa49uj+e-=fqkppQPd+NfXwG03+joHqBHGYyjvOWgrmvD-4Q@mail.gmail.com> @ 2015-02-27 14:30 ` Daniel Baluta 2015-02-27 15:14 ` Jonathan Cameron 0 siblings, 1 reply; 8+ messages in thread From: Daniel Baluta @ 2015-02-27 14:30 UTC (permalink / raw) To: s.rawat, linux-iio@vger.kernel.org On Fri, Feb 27, 2015 at 3:18 PM, s.rawat <imsaurabhrawat@gmail.com> wrote: > Hi Daniel, > I got a failure in sending last mail to iio mailing list.Can you please fwd > it to that chain while i subscribe my self to it. > Many thanks. Not sure if you need to be subscribed in order to post there. Cc'ed linux-iio, anyway. > > On Fri, Feb 27, 2015 at 6:45 PM, s.rawat <imsaurabhrawat@gmail.com> wrote: >> >> Do I need to define the all the Usage Tags in the input report of a sensor >> to retrieve minimum any one field or Only a Usage Tag which I wanted to >> retrieve is enough. >> e.g for an input report of an accelerometer which has the below >> fields(added new one in Bold), >> >> HID_USAGE_SENSOR_ACCEL_X_AXIS >> HID_USAGE_SENSOR_ACCEL_Y_AXIS >> HID_USAGE_SENSOR_ACCEL_Z_AXIS >> HID_USAGE_SENSOR_DATA_MOTION_STATE, >> HID_USAGE_SENSOR_DATA_CUSTOM_VALUE_2 >> HID_USAGE_SENSOR_DATA_CUSTOM_VALUE_3 >> HID_USAGE_SENSOR_DATA_CUSTOM_VALUE_4 >> >> I want to retrieve Custom_Value_4 do I also need to define parameters for >> Data_Motion_state, Custom_Value2,Custom_Value3 as well apart from >> Custom_Value4 in the below structure. >> >> enum accel_3d_channel {.. } >> struct accel_3d_state {.. } >> static const struct iio_chan_spec accel_3d_channels[] = { ..} >> >> I did so but was getting error - "failed to setup attributes" but after I >> modified the code in the function : accel_3d_parse_report() like below to >> accommodate all the non Contigous Usage Tags and associated them with their >> channels - *_SCAN_INDEX_* . I did not get this error but some other error >> (listed at the end of the mail) >> >> >> //First Three channel X,Y and Z whose Usage Tags are contionus - >> 0x200453/54/55 >> for (i = 0; i <= CHANNEL_SCAN_INDEX_Z; ++i) { >> >> ret = sensor_hub_input_get_attribute_info(hsdev, >> HID_INPUT_REPORT, >> usage_id, >> HID_USAGE_SENSOR_ACCEL_X_AXIS + i, >> &st->accel[CHANNEL_SCAN_INDEX_X + i]); >> accel_3d_adjust_channel_bit_mask(channels, >> CHANNEL_SCAN_INDEX_X + i, >> st->accel[CHANNEL_SCAN_INDEX_X + i].size); >> } >> >> //Fourth channel For Data Motion - 0x200451 >> ret = sensor_hub_input_get_attribute_info(hsdev, >> HID_INPUT_REPORT, >> usage_id, >> HID_USAGE_SENSOR_DATA_MOTION_STATE, // For CHANNEL_SCAN_DATA_MOTION >> &st->accel[CHANNEL_SCAN_INDEX_X + i]); >> accel_3d_adjust_channel_bit_mask(channels, >> CHANNEL_SCAN_INDEX_X + i, >> st->accel[CHANNEL_SCAN_INDEX_X + i].size); >> >> //Last Three Channel for Custom Value 2,3,4 - 0x200545/46/47 >> for (i = 0; i <= 2; ++i) { >> >> ret = sensor_hub_input_get_attribute_info(hsdev, >> HID_INPUT_REPORT, >> usage_id, >> HID_USAGE_SENSOR_DATA_CUSTOM_VALUE_2 + i, >> &st->accel[CHANNEL_SCAN_INDEX_X + i + 4]); //start after >> CHANNEL_SCAN_DATA_MOTION Channel >> accel_3d_adjust_channel_bit_mask(channels, >> CHANNEL_SCAN_INDEX_X + i + 4, >> st->accel[CHANNEL_SCAN_INDEX_X + i].size); >> } >> >> >> >> But now I am getting a different error : >> >> [13778.127716] iio iio:device4: tried to double register : >> in_accel_x_index >> [13778.127899] hid_sensor_accel_3d HID-SENSOR-200073.3.auto: failed to >> initialize trigger buffer >> [13778.143676] hid_sensor_accel_3d: probe of HID-SENSOR-200073.3.auto >> failed with error -16 >> >> I am still figuring out where else Do I have to modify the code in order >> to receive the above custom values .. >> Thanks, >> S >> >> >> >> On Thu, Feb 26, 2015 at 6:54 PM, Daniel Baluta <daniel.baluta@gmail.com> >> wrote: >>> >>> + linux-iio list. >>> >>> On Thu, Feb 26, 2015 at 8:04 AM, s.rawat <imsaurabhrawat@gmail.com> >>> wrote: >>> > I have modified the hid-sensor-accel_3d.c driver to add the custom >>> > fields - >>> > CHANNEL_SCAN_DATA_MOTION and HID_USAGE_SENSOR_DATA_CUSTOM_VALUEX ( X = >>> > 2,3,4). >>> > Below are my modifications : >>> > >>> > enum accel_3d_channel { >>> > CHANNEL_SCAN_INDEX_X, >>> > CHANNEL_SCAN_INDEX_Y, >>> > CHANNEL_SCAN_INDEX_Z, >>> > CHANNEL_SCAN_DATA_MOTION, >>> > CHANNEL_CUSTOM_VALUE_2, >>> > CHANNEL_CUSTOM_VALUE_3, >>> > CHANNEL_CUSTOM_VALUE_4, >>> > ACCEL_3D_CHANNEL_MAX, >>> > >>> > static const u32 accel_3d_addresses[ACCEL_3D_CHANNEL_MAX] = { >>> > HID_USAGE_SENSOR_ACCEL_X_AXIS, >>> > HID_USAGE_SENSOR_ACCEL_Y_AXIS, >>> > HID_USAGE_SENSOR_ACCEL_Z_AXIS, >>> > HID_USAGE_SENSOR_DATA_MOTION_STATE, >>> > HID_USAGE_SENSOR_DATA_CUSTOM_VALUE2, >>> > HID_USAGE_SENSOR_DATA_CUSTOM_VALUE3, >>> > HID_USAGE_SENSOR_DATA_CUSTOM_VALUE4 >>> > }; >>> > >>> > >>> > >>> > /* Channel definitions */ >>> > static const struct iio_chan_spec accel_3d_channels[] = { >>> > { >>> > .. >>> > .. >>> > .. >>> > { >>> > .type = IIO_ACCEL, >>> > .modified = 1, >>> > .channel2 = IIO_MOD_X, >>> > .info_mask_separate = BIT(IIO_CHAN_INFO_RAW), >>> > .info_mask_shared_by_type = BIT(IIO_CHAN_INFO_OFFSET) | >>> > BIT(IIO_CHAN_INFO_SCALE) | >>> > BIT(IIO_CHAN_INFO_SAMP_FREQ) | >>> > BIT(IIO_CHAN_INFO_HYSTERESIS), >>> > .scan_index = CHANNEL_SCAN_DATA_MOTION, >>> > }, >>> > { >>> > .type = IIO_ACCEL, >>> > .modified = 1, >>> > .channel2 = IIO_MOD_X, >>> > .info_mask_separate = BIT(IIO_CHAN_INFO_RAW), >>> > .info_mask_shared_by_type = BIT(IIO_CHAN_INFO_OFFSET) | >>> > BIT(IIO_CHAN_INFO_SCALE) | >>> > BIT(IIO_CHAN_INFO_SAMP_FREQ) | >>> > BIT(IIO_CHAN_INFO_HYSTERESIS), >>> > .scan_index = CHANNEL_CUSTOM_VALUE_2, >>> > }, >>> > { >>> > .type = IIO_ACCEL, >>> > .modified = 1, >>> > .channel2 = IIO_MOD_X, >>> > .info_mask_separate = BIT(IIO_CHAN_INFO_RAW), >>> > .info_mask_shared_by_type = BIT(IIO_CHAN_INFO_OFFSET) | >>> > BIT(IIO_CHAN_INFO_SCALE) | >>> > BIT(IIO_CHAN_INFO_SAMP_FREQ) | >>> > BIT(IIO_CHAN_INFO_HYSTERESIS), >>> > .scan_index = CHANNEL_CUSTOM_VALUE_3, >>> > }, >>> > { >>> > .type = IIO_ACCEL, >>> > .modified = 1, >>> > .channel2 = IIO_MOD_X, >>> > .info_mask_separate = BIT(IIO_CHAN_INFO_RAW), >>> > .info_mask_shared_by_type = BIT(IIO_CHAN_INFO_OFFSET) | >>> > BIT(IIO_CHAN_INFO_SCALE) | >>> > BIT(IIO_CHAN_INFO_SAMP_FREQ) | >>> > BIT(IIO_CHAN_INFO_HYSTERESIS), >>> > .scan_index = CHANNEL_CUSTOM_VALUE_4, >>> > } >>> > >>> > >>> > >>> > /* Capture samples in local storage */ >>> > static int accel_3d_capture_sample(struct hid_sensor_hub_device *hsdev, >>> > unsigned usage_id, >>> > size_t raw_len, char *raw_data, >>> > void *priv) >>> > { >>> > struct iio_dev *indio_dev = platform_get_drvdata(priv); >>> > struct accel_3d_state *accel_state = iio_priv(indio_dev); >>> > int offset; >>> > int ret = -EINVAL; >>> > >>> > switch (usage_id) { >>> > case HID_USAGE_SENSOR_ACCEL_X_AXIS: >>> > case HID_USAGE_SENSOR_ACCEL_Y_AXIS: >>> > case HID_USAGE_SENSOR_ACCEL_Z_AXIS: >>> > case HID_USAGE_SENSOR_DATA_MOTION_STATE: >>> > case HID_USAGE_SENSOR_DATA_CUSTOM_VALUE2: >>> > case HID_USAGE_SENSOR_DATA_CUSTOM_VALUE3: >>> > case HID_USAGE_SENSOR_DATA_CUSTOM_VALUE4: >>> > offset = usage_id - HID_USAGE_SENSOR_ACCEL_X_AXIS; >>> > >>> > >>> > >>> > /* Parse report which is specific to an usage id*/ >>> > static int accel_3d_parse_report(struct platform_device *pdev, >>> > struct hid_sensor_hub_device *hsdev, >>> > struct iio_chan_spec *channels, >>> > unsigned usage_id, >>> > struct accel_3d_state *st) >>> > { >>> > int ret; >>> > int i; >>> > >>> > for (i = 0; i <= CHANNEL_CUSTOM_VALUE_4; ++i) { //previously < >>> > CHANNEL_SCAN_INDEX_Z >>> > ret = sensor_hub_input_get_attribute_info(hsdev, >>> > >>> > >>> > >>> > After build /insmod i get the following dmesg : >>> > >>> > hid_sensor_accel_3d:HID-SENSOR-200073.3 auto : failed to setup >>> > attributes >>> > hid_sensor_accel_3d:HID-SENSOR-200073.3 auto.failed with error -1 >>> > >>> > >>> > I am not getting what else I have to modify to avoid this error .If i >>> > remove >>> > the portion in bold(and use this original code >>> > >>> > :http://lxr.free-electrons.com/source/drivers/iio/accel/hid-sensor-accel-3d.c) >>> > I can happily insert the module without any error and can interact with >>> > the >>> > driver using my application. >>> > >>> > >>> > _______________________________________________ >>> > Kernelnewbies mailing list >>> > Kernelnewbies@kernelnewbies.org >>> > http://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies >>> > >> >> > ^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: Getting error "failed to setup attributes" on Adding Custom Fields in accelerometer HID driver 2015-02-27 14:30 ` Daniel Baluta @ 2015-02-27 15:14 ` Jonathan Cameron 2015-02-28 11:43 ` Jonathan Cameron 0 siblings, 1 reply; 8+ messages in thread From: Jonathan Cameron @ 2015-02-27 15:14 UTC (permalink / raw) To: Daniel Baluta, s.rawat, linux-iio@vger.kernel.org On 27 February 2015 14:30:13 GMT+00:00, Daniel Baluta <daniel.baluta@gmail.com> wrote: >On Fri, Feb 27, 2015 at 3:18 PM, s.rawat <imsaurabhrawat@gmail.com> >wrote: >> Hi Daniel, >> I got a failure in sending last mail to iio mailing list.Can you >please fwd >> it to that chain while i subscribe my self to it. >> Many thanks. > >Not sure if you need to be subscribed in order to post there. > >Cc'ed linux-iio, anyway. You don't I am forever emailling from random accounts. If it bounced for a non obvious reason we probably want to check with the vger admins! J > >> >> On Fri, Feb 27, 2015 at 6:45 PM, s.rawat <imsaurabhrawat@gmail.com> >wrote: >>> >>> Do I need to define the all the Usage Tags in the input report of a >sensor >>> to retrieve minimum any one field or Only a Usage Tag which I wanted >to >>> retrieve is enough. >>> e.g for an input report of an accelerometer which has the below >>> fields(added new one in Bold), >>> >>> HID_USAGE_SENSOR_ACCEL_X_AXIS >>> HID_USAGE_SENSOR_ACCEL_Y_AXIS >>> HID_USAGE_SENSOR_ACCEL_Z_AXIS >>> HID_USAGE_SENSOR_DATA_MOTION_STATE, >>> HID_USAGE_SENSOR_DATA_CUSTOM_VALUE_2 >>> HID_USAGE_SENSOR_DATA_CUSTOM_VALUE_3 >>> HID_USAGE_SENSOR_DATA_CUSTOM_VALUE_4 >>> >>> I want to retrieve Custom_Value_4 do I also need to define >parameters for >>> Data_Motion_state, Custom_Value2,Custom_Value3 as well apart from >>> Custom_Value4 in the below structure. >>> >>> enum accel_3d_channel {.. } >>> struct accel_3d_state {.. } >>> static const struct iio_chan_spec accel_3d_channels[] = { ..} >>> >>> I did so but was getting error - "failed to setup attributes" but >after I >>> modified the code in the function : accel_3d_parse_report() like >below to >>> accommodate all the non Contigous Usage Tags and associated them >with their >>> channels - *_SCAN_INDEX_* . I did not get this error but some other >error >>> (listed at the end of the mail) >>> >>> >>> //First Three channel X,Y and Z whose Usage Tags are contionus - >>> 0x200453/54/55 >>> for (i = 0; i <= CHANNEL_SCAN_INDEX_Z; ++i) { >>> >>> ret = sensor_hub_input_get_attribute_info(hsdev, >>> HID_INPUT_REPORT, >>> usage_id, >>> HID_USAGE_SENSOR_ACCEL_X_AXIS + i, >>> &st->accel[CHANNEL_SCAN_INDEX_X + i]); >>> accel_3d_adjust_channel_bit_mask(channels, >>> CHANNEL_SCAN_INDEX_X + i, >>> st->accel[CHANNEL_SCAN_INDEX_X + i].size); >>> } >>> >>> //Fourth channel For Data Motion - 0x200451 >>> ret = sensor_hub_input_get_attribute_info(hsdev, >>> HID_INPUT_REPORT, >>> usage_id, >>> HID_USAGE_SENSOR_DATA_MOTION_STATE, // For CHANNEL_SCAN_DATA_MOTION >>> &st->accel[CHANNEL_SCAN_INDEX_X + i]); >>> accel_3d_adjust_channel_bit_mask(channels, >>> CHANNEL_SCAN_INDEX_X + i, >>> st->accel[CHANNEL_SCAN_INDEX_X + i].size); >>> >>> //Last Three Channel for Custom Value 2,3,4 - 0x200545/46/47 >>> for (i = 0; i <= 2; ++i) { >>> >>> ret = sensor_hub_input_get_attribute_info(hsdev, >>> HID_INPUT_REPORT, >>> usage_id, >>> HID_USAGE_SENSOR_DATA_CUSTOM_VALUE_2 + i, >>> &st->accel[CHANNEL_SCAN_INDEX_X + i + 4]); //start after >>> CHANNEL_SCAN_DATA_MOTION Channel >>> accel_3d_adjust_channel_bit_mask(channels, >>> CHANNEL_SCAN_INDEX_X + i + 4, >>> st->accel[CHANNEL_SCAN_INDEX_X + i].size); >>> } >>> >>> >>> >>> But now I am getting a different error : >>> >>> [13778.127716] iio iio:device4: tried to double register : >>> in_accel_x_index >>> [13778.127899] hid_sensor_accel_3d HID-SENSOR-200073.3.auto: failed >to >>> initialize trigger buffer >>> [13778.143676] hid_sensor_accel_3d: probe of >HID-SENSOR-200073.3.auto >>> failed with error -16 >>> >>> I am still figuring out where else Do I have to modify the code in >order >>> to receive the above custom values .. >>> Thanks, >>> S >>> >>> >>> >>> On Thu, Feb 26, 2015 at 6:54 PM, Daniel Baluta ><daniel.baluta@gmail.com> >>> wrote: >>>> >>>> + linux-iio list. >>>> >>>> On Thu, Feb 26, 2015 at 8:04 AM, s.rawat <imsaurabhrawat@gmail.com> >>>> wrote: >>>> > I have modified the hid-sensor-accel_3d.c driver to add the >custom >>>> > fields - >>>> > CHANNEL_SCAN_DATA_MOTION and HID_USAGE_SENSOR_DATA_CUSTOM_VALUEX >( X = >>>> > 2,3,4). >>>> > Below are my modifications : >>>> > >>>> > enum accel_3d_channel { >>>> > CHANNEL_SCAN_INDEX_X, >>>> > CHANNEL_SCAN_INDEX_Y, >>>> > CHANNEL_SCAN_INDEX_Z, >>>> > CHANNEL_SCAN_DATA_MOTION, >>>> > CHANNEL_CUSTOM_VALUE_2, >>>> > CHANNEL_CUSTOM_VALUE_3, >>>> > CHANNEL_CUSTOM_VALUE_4, >>>> > ACCEL_3D_CHANNEL_MAX, >>>> > >>>> > static const u32 accel_3d_addresses[ACCEL_3D_CHANNEL_MAX] = { >>>> > HID_USAGE_SENSOR_ACCEL_X_AXIS, >>>> > HID_USAGE_SENSOR_ACCEL_Y_AXIS, >>>> > HID_USAGE_SENSOR_ACCEL_Z_AXIS, >>>> > HID_USAGE_SENSOR_DATA_MOTION_STATE, >>>> > HID_USAGE_SENSOR_DATA_CUSTOM_VALUE2, >>>> > HID_USAGE_SENSOR_DATA_CUSTOM_VALUE3, >>>> > HID_USAGE_SENSOR_DATA_CUSTOM_VALUE4 >>>> > }; >>>> > >>>> > >>>> > >>>> > /* Channel definitions */ >>>> > static const struct iio_chan_spec accel_3d_channels[] = { >>>> > { >>>> > .. >>>> > .. >>>> > .. >>>> > { >>>> > .type = IIO_ACCEL, >>>> > .modified = 1, >>>> > .channel2 = IIO_MOD_X, >>>> > .info_mask_separate = BIT(IIO_CHAN_INFO_RAW), >>>> > .info_mask_shared_by_type = BIT(IIO_CHAN_INFO_OFFSET) | >>>> > BIT(IIO_CHAN_INFO_SCALE) | >>>> > BIT(IIO_CHAN_INFO_SAMP_FREQ) | >>>> > BIT(IIO_CHAN_INFO_HYSTERESIS), >>>> > .scan_index = CHANNEL_SCAN_DATA_MOTION, >>>> > }, >>>> > { >>>> > .type = IIO_ACCEL, >>>> > .modified = 1, >>>> > .channel2 = IIO_MOD_X, >>>> > .info_mask_separate = BIT(IIO_CHAN_INFO_RAW), >>>> > .info_mask_shared_by_type = BIT(IIO_CHAN_INFO_OFFSET) | >>>> > BIT(IIO_CHAN_INFO_SCALE) | >>>> > BIT(IIO_CHAN_INFO_SAMP_FREQ) | >>>> > BIT(IIO_CHAN_INFO_HYSTERESIS), >>>> > .scan_index = CHANNEL_CUSTOM_VALUE_2, >>>> > }, >>>> > { >>>> > .type = IIO_ACCEL, >>>> > .modified = 1, >>>> > .channel2 = IIO_MOD_X, >>>> > .info_mask_separate = BIT(IIO_CHAN_INFO_RAW), >>>> > .info_mask_shared_by_type = BIT(IIO_CHAN_INFO_OFFSET) | >>>> > BIT(IIO_CHAN_INFO_SCALE) | >>>> > BIT(IIO_CHAN_INFO_SAMP_FREQ) | >>>> > BIT(IIO_CHAN_INFO_HYSTERESIS), >>>> > .scan_index = CHANNEL_CUSTOM_VALUE_3, >>>> > }, >>>> > { >>>> > .type = IIO_ACCEL, >>>> > .modified = 1, >>>> > .channel2 = IIO_MOD_X, >>>> > .info_mask_separate = BIT(IIO_CHAN_INFO_RAW), >>>> > .info_mask_shared_by_type = BIT(IIO_CHAN_INFO_OFFSET) | >>>> > BIT(IIO_CHAN_INFO_SCALE) | >>>> > BIT(IIO_CHAN_INFO_SAMP_FREQ) | >>>> > BIT(IIO_CHAN_INFO_HYSTERESIS), >>>> > .scan_index = CHANNEL_CUSTOM_VALUE_4, >>>> > } >>>> > >>>> > >>>> > >>>> > /* Capture samples in local storage */ >>>> > static int accel_3d_capture_sample(struct hid_sensor_hub_device >*hsdev, >>>> > unsigned usage_id, >>>> > size_t raw_len, char *raw_data, >>>> > void *priv) >>>> > { >>>> > struct iio_dev *indio_dev = platform_get_drvdata(priv); >>>> > struct accel_3d_state *accel_state = iio_priv(indio_dev); >>>> > int offset; >>>> > int ret = -EINVAL; >>>> > >>>> > switch (usage_id) { >>>> > case HID_USAGE_SENSOR_ACCEL_X_AXIS: >>>> > case HID_USAGE_SENSOR_ACCEL_Y_AXIS: >>>> > case HID_USAGE_SENSOR_ACCEL_Z_AXIS: >>>> > case HID_USAGE_SENSOR_DATA_MOTION_STATE: >>>> > case HID_USAGE_SENSOR_DATA_CUSTOM_VALUE2: >>>> > case HID_USAGE_SENSOR_DATA_CUSTOM_VALUE3: >>>> > case HID_USAGE_SENSOR_DATA_CUSTOM_VALUE4: >>>> > offset = usage_id - HID_USAGE_SENSOR_ACCEL_X_AXIS; >>>> > >>>> > >>>> > >>>> > /* Parse report which is specific to an usage id*/ >>>> > static int accel_3d_parse_report(struct platform_device *pdev, >>>> > struct hid_sensor_hub_device *hsdev, >>>> > struct iio_chan_spec *channels, >>>> > unsigned usage_id, >>>> > struct accel_3d_state *st) >>>> > { >>>> > int ret; >>>> > int i; >>>> > >>>> > for (i = 0; i <= CHANNEL_CUSTOM_VALUE_4; ++i) { //previously < >>>> > CHANNEL_SCAN_INDEX_Z >>>> > ret = sensor_hub_input_get_attribute_info(hsdev, >>>> > >>>> > >>>> > >>>> > After build /insmod i get the following dmesg : >>>> > >>>> > hid_sensor_accel_3d:HID-SENSOR-200073.3 auto : failed to setup >>>> > attributes >>>> > hid_sensor_accel_3d:HID-SENSOR-200073.3 auto.failed with error -1 >>>> > >>>> > >>>> > I am not getting what else I have to modify to avoid this error >.If i >>>> > remove >>>> > the portion in bold(and use this original code >>>> > >>>> > >:http://lxr.free-electrons.com/source/drivers/iio/accel/hid-sensor-accel-3d.c) >>>> > I can happily insert the module without any error and can >interact with >>>> > the >>>> > driver using my application. >>>> > >>>> > >>>> > _______________________________________________ >>>> > Kernelnewbies mailing list >>>> > Kernelnewbies@kernelnewbies.org >>>> > http://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies >>>> > >>> >>> >> >-- >To unsubscribe from this list: send the line "unsubscribe linux-iio" in >the body of a message to majordomo@vger.kernel.org >More majordomo info at http://vger.kernel.org/majordomo-info.html -- Sent from my Android device with K-9 Mail. Please excuse my brevity. ^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: Getting error "failed to setup attributes" on Adding Custom Fields in accelerometer HID driver 2015-02-27 15:14 ` Jonathan Cameron @ 2015-02-28 11:43 ` Jonathan Cameron 2015-03-02 4:41 ` s.rawat 0 siblings, 1 reply; 8+ messages in thread From: Jonathan Cameron @ 2015-02-28 11:43 UTC (permalink / raw) To: Jonathan Cameron, Daniel Baluta, s.rawat, linux-iio@vger.kernel.org On 27/02/15 15:14, Jonathan Cameron wrote: > > > On 27 February 2015 14:30:13 GMT+00:00, Daniel Baluta <daniel.baluta@gmail.com> wrote: >> On Fri, Feb 27, 2015 at 3:18 PM, s.rawat <imsaurabhrawat@gmail.com> >> wrote: >>> Hi Daniel, >>> I got a failure in sending last mail to iio mailing list.Can you >> please fwd >>> it to that chain while i subscribe my self to it. >>> Many thanks. >> >> Not sure if you need to be subscribed in order to post there. >> >> Cc'ed linux-iio, anyway. > You don't I am forever emailling from random accounts. If it bounced for a non obvious reason we probably want to check with the vger admins! > > J Anyhow, now to actually look at the question! >> >>> >>> On Fri, Feb 27, 2015 at 6:45 PM, s.rawat <imsaurabhrawat@gmail.com> >> wrote: >>>> >>>> Do I need to define the all the Usage Tags in the input report of a >> sensor >>>> to retrieve minimum any one field or Only a Usage Tag which I wanted >> to >>>> retrieve is enough. >>>> e.g for an input report of an accelerometer which has the below >>>> fields(added new one in Bold), >>>> >>>> HID_USAGE_SENSOR_ACCEL_X_AXIS >>>> HID_USAGE_SENSOR_ACCEL_Y_AXIS >>>> HID_USAGE_SENSOR_ACCEL_Z_AXIS >>>> HID_USAGE_SENSOR_DATA_MOTION_STATE, >>>> HID_USAGE_SENSOR_DATA_CUSTOM_VALUE_2 >>>> HID_USAGE_SENSOR_DATA_CUSTOM_VALUE_3 >>>> HID_USAGE_SENSOR_DATA_CUSTOM_VALUE_4 >>>> >>>> I want to retrieve Custom_Value_4 do I also need to define >> parameters for >>>> Data_Motion_state, Custom_Value2,Custom_Value3 as well apart from >>>> Custom_Value4 in the below structure. >>>> >>>> enum accel_3d_channel {.. } >>>> struct accel_3d_state {.. } >>>> static const struct iio_chan_spec accel_3d_channels[] = { ..} >>>> >>>> I did so but was getting error - "failed to setup attributes" but >> after I >>>> modified the code in the function : accel_3d_parse_report() like >> below to >>>> accommodate all the non Contigous Usage Tags and associated them >> with their >>>> channels - *_SCAN_INDEX_* . I did not get this error but some other >> error >>>> (listed at the end of the mail) >>>> >>>> >>>> //First Three channel X,Y and Z whose Usage Tags are contionus - >>>> 0x200453/54/55 >>>> for (i = 0; i <= CHANNEL_SCAN_INDEX_Z; ++i) { >>>> >>>> ret = sensor_hub_input_get_attribute_info(hsdev, >>>> HID_INPUT_REPORT, >>>> usage_id, >>>> HID_USAGE_SENSOR_ACCEL_X_AXIS + i, >>>> &st->accel[CHANNEL_SCAN_INDEX_X + i]); >>>> accel_3d_adjust_channel_bit_mask(channels, >>>> CHANNEL_SCAN_INDEX_X + i, >>>> st->accel[CHANNEL_SCAN_INDEX_X + i].size); >>>> } >>>> >>>> //Fourth channel For Data Motion - 0x200451 >>>> ret = sensor_hub_input_get_attribute_info(hsdev, >>>> HID_INPUT_REPORT, >>>> usage_id, >>>> HID_USAGE_SENSOR_DATA_MOTION_STATE, // For CHANNEL_SCAN_DATA_MOTION >>>> &st->accel[CHANNEL_SCAN_INDEX_X + i]); >>>> accel_3d_adjust_channel_bit_mask(channels, >>>> CHANNEL_SCAN_INDEX_X + i, >>>> st->accel[CHANNEL_SCAN_INDEX_X + i].size); >>>> >>>> //Last Three Channel for Custom Value 2,3,4 - 0x200545/46/47 >>>> for (i = 0; i <= 2; ++i) { >>>> >>>> ret = sensor_hub_input_get_attribute_info(hsdev, >>>> HID_INPUT_REPORT, >>>> usage_id, >>>> HID_USAGE_SENSOR_DATA_CUSTOM_VALUE_2 + i, >>>> &st->accel[CHANNEL_SCAN_INDEX_X + i + 4]); //start after >>>> CHANNEL_SCAN_DATA_MOTION Channel >>>> accel_3d_adjust_channel_bit_mask(channels, >>>> CHANNEL_SCAN_INDEX_X + i + 4, >>>> st->accel[CHANNEL_SCAN_INDEX_X + i].size); >>>> } >>>> >>>> >>>> >>>> But now I am getting a different error : >>>> >>>> [13778.127716] iio iio:device4: tried to double register : >>>> in_accel_x_index >>>> [13778.127899] hid_sensor_accel_3d HID-SENSOR-200073.3.auto: failed >> to >>>> initialize trigger buffer >>>> [13778.143676] hid_sensor_accel_3d: probe of >> HID-SENSOR-200073.3.auto >>>> failed with error -16 >>>> >>>> I am still figuring out where else Do I have to modify the code in >> order >>>> to receive the above custom values .. >>>> Thanks, >>>> S >>>> >>>> >>>> >>>> On Thu, Feb 26, 2015 at 6:54 PM, Daniel Baluta >> <daniel.baluta@gmail.com> >>>> wrote: >>>>> >>>>> + linux-iio list. >>>>> >>>>> On Thu, Feb 26, 2015 at 8:04 AM, s.rawat <imsaurabhrawat@gmail.com> >>>>> wrote: >>>>>> I have modified the hid-sensor-accel_3d.c driver to add the >> custom >>>>>> fields - >>>>>> CHANNEL_SCAN_DATA_MOTION and HID_USAGE_SENSOR_DATA_CUSTOM_VALUEX >> ( X = >>>>>> 2,3,4). >>>>>> Below are my modifications : >>>>>> >>>>>> enum accel_3d_channel { >>>>>> CHANNEL_SCAN_INDEX_X, >>>>>> CHANNEL_SCAN_INDEX_Y, >>>>>> CHANNEL_SCAN_INDEX_Z, >>>>>> CHANNEL_SCAN_DATA_MOTION, >>>>>> CHANNEL_CUSTOM_VALUE_2, >>>>>> CHANNEL_CUSTOM_VALUE_3, >>>>>> CHANNEL_CUSTOM_VALUE_4, >>>>>> ACCEL_3D_CHANNEL_MAX, >>>>>> >>>>>> static const u32 accel_3d_addresses[ACCEL_3D_CHANNEL_MAX] = { >>>>>> HID_USAGE_SENSOR_ACCEL_X_AXIS, >>>>>> HID_USAGE_SENSOR_ACCEL_Y_AXIS, >>>>>> HID_USAGE_SENSOR_ACCEL_Z_AXIS, >>>>>> HID_USAGE_SENSOR_DATA_MOTION_STATE, >>>>>> HID_USAGE_SENSOR_DATA_CUSTOM_VALUE2, >>>>>> HID_USAGE_SENSOR_DATA_CUSTOM_VALUE3, >>>>>> HID_USAGE_SENSOR_DATA_CUSTOM_VALUE4 >>>>>> }; >>>>>> >>>>>> >>>>>> >>>>>> /* Channel definitions */ >>>>>> static const struct iio_chan_spec accel_3d_channels[] = { >>>>>> { >>>>>> .. >>>>>> .. >>>>>> .. >>>>>> { >>>>>> .type = IIO_ACCEL, >>>>>> .modified = 1, >>>>>> .channel2 = IIO_MOD_X, >>>>>> .info_mask_separate = BIT(IIO_CHAN_INFO_RAW), >>>>>> .info_mask_shared_by_type = BIT(IIO_CHAN_INFO_OFFSET) | >>>>>> BIT(IIO_CHAN_INFO_SCALE) | >>>>>> BIT(IIO_CHAN_INFO_SAMP_FREQ) | >>>>>> BIT(IIO_CHAN_INFO_HYSTERESIS), >>>>>> .scan_index = CHANNEL_SCAN_DATA_MOTION, >>>>>> }, >>>>>> { >>>>>> .type = IIO_ACCEL, >>>>>> .modified = 1, >>>>>> .channel2 = IIO_MOD_X, >>>>>> .info_mask_separate = BIT(IIO_CHAN_INFO_RAW), >>>>>> .info_mask_shared_by_type = BIT(IIO_CHAN_INFO_OFFSET) | >>>>>> BIT(IIO_CHAN_INFO_SCALE) | >>>>>> BIT(IIO_CHAN_INFO_SAMP_FREQ) | >>>>>> BIT(IIO_CHAN_INFO_HYSTERESIS), >>>>>> .scan_index = CHANNEL_CUSTOM_VALUE_2, >>>>>> }, >>>>>> { >>>>>> .type = IIO_ACCEL, >>>>>> .modified = 1, >>>>>> .channel2 = IIO_MOD_X, >>>>>> .info_mask_separate = BIT(IIO_CHAN_INFO_RAW), >>>>>> .info_mask_shared_by_type = BIT(IIO_CHAN_INFO_OFFSET) | >>>>>> BIT(IIO_CHAN_INFO_SCALE) | >>>>>> BIT(IIO_CHAN_INFO_SAMP_FREQ) | >>>>>> BIT(IIO_CHAN_INFO_HYSTERESIS), >>>>>> .scan_index = CHANNEL_CUSTOM_VALUE_3, >>>>>> }, >>>>>> { >>>>>> .type = IIO_ACCEL, >>>>>> .modified = 1, >>>>>> .channel2 = IIO_MOD_X, >>>>>> .info_mask_separate = BIT(IIO_CHAN_INFO_RAW), >>>>>> .info_mask_shared_by_type = BIT(IIO_CHAN_INFO_OFFSET) | >>>>>> BIT(IIO_CHAN_INFO_SCALE) | >>>>>> BIT(IIO_CHAN_INFO_SAMP_FREQ) | >>>>>> BIT(IIO_CHAN_INFO_HYSTERESIS), >>>>>> .scan_index = CHANNEL_CUSTOM_VALUE_4, >>>>>> } This channel array will attempt to create a whole load of identical attributes. in_accel_x_raw for each entry. I suspect you want is to have in_accel0_x_raw in_accel1_x_raw etc? In which case you'll need to also specify .indexed = 1, .index = N That is probably the cause of the error you saw (it'll also clash on the attribute for the index as seen above!) >>>>>> >>>>>> >>>>>> >>>>>> /* Capture samples in local storage */ >>>>>> static int accel_3d_capture_sample(struct hid_sensor_hub_device >> *hsdev, >>>>>> unsigned usage_id, >>>>>> size_t raw_len, char *raw_data, >>>>>> void *priv) >>>>>> { >>>>>> struct iio_dev *indio_dev = platform_get_drvdata(priv); >>>>>> struct accel_3d_state *accel_state = iio_priv(indio_dev); >>>>>> int offset; >>>>>> int ret = -EINVAL; >>>>>> >>>>>> switch (usage_id) { >>>>>> case HID_USAGE_SENSOR_ACCEL_X_AXIS: >>>>>> case HID_USAGE_SENSOR_ACCEL_Y_AXIS: >>>>>> case HID_USAGE_SENSOR_ACCEL_Z_AXIS: >>>>>> case HID_USAGE_SENSOR_DATA_MOTION_STATE: >>>>>> case HID_USAGE_SENSOR_DATA_CUSTOM_VALUE2: >>>>>> case HID_USAGE_SENSOR_DATA_CUSTOM_VALUE3: >>>>>> case HID_USAGE_SENSOR_DATA_CUSTOM_VALUE4: >>>>>> offset = usage_id - HID_USAGE_SENSOR_ACCEL_X_AXIS; >>>>>> >>>>>> >>>>>> >>>>>> /* Parse report which is specific to an usage id*/ >>>>>> static int accel_3d_parse_report(struct platform_device *pdev, >>>>>> struct hid_sensor_hub_device *hsdev, >>>>>> struct iio_chan_spec *channels, >>>>>> unsigned usage_id, >>>>>> struct accel_3d_state *st) >>>>>> { >>>>>> int ret; >>>>>> int i; >>>>>> >>>>>> for (i = 0; i <= CHANNEL_CUSTOM_VALUE_4; ++i) { //previously < >>>>>> CHANNEL_SCAN_INDEX_Z >>>>>> ret = sensor_hub_input_get_attribute_info(hsdev, >>>>>> >>>>>> >>>>>> >>>>>> After build /insmod i get the following dmesg : >>>>>> >>>>>> hid_sensor_accel_3d:HID-SENSOR-200073.3 auto : failed to setup >>>>>> attributes >>>>>> hid_sensor_accel_3d:HID-SENSOR-200073.3 auto.failed with error -1 >>>>>> >>>>>> >>>>>> I am not getting what else I have to modify to avoid this error >> .If i >>>>>> remove >>>>>> the portion in bold(and use this original code >>>>>> >>>>>> >> :http://lxr.free-electrons.com/source/drivers/iio/accel/hid-sensor-accel-3d.c) >>>>>> I can happily insert the module without any error and can >> interact with >>>>>> the >>>>>> driver using my application. >>>>>> >>>>>> >>>>>> _______________________________________________ >>>>>> Kernelnewbies mailing list >>>>>> Kernelnewbies@kernelnewbies.org >>>>>> http://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies >>>>>> >>>> >>>> >>> >> -- >> To unsubscribe from this list: send the line "unsubscribe linux-iio" in >> the body of a message to majordomo@vger.kernel.org >> More majordomo info at http://vger.kernel.org/majordomo-info.html > ^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: Getting error "failed to setup attributes" on Adding Custom Fields in accelerometer HID driver 2015-02-28 11:43 ` Jonathan Cameron @ 2015-03-02 4:41 ` s.rawat 0 siblings, 0 replies; 8+ messages in thread From: s.rawat @ 2015-03-02 4:41 UTC (permalink / raw) To: Jonathan Cameron Cc: Jonathan Cameron, Daniel Baluta, linux-iio@vger.kernel.org [-- Attachment #1: Type: text/plain, Size: 12422 bytes --] On Sat, Feb 28, 2015 at 5:13 PM, Jonathan Cameron <jic23@kernel.org> wrote: > On 27/02/15 15:14, Jonathan Cameron wrote: > > > > > > On 27 February 2015 14:30:13 GMT+00:00, Daniel Baluta < > daniel.baluta@gmail.com> wrote: > >> On Fri, Feb 27, 2015 at 3:18 PM, s.rawat <imsaurabhrawat@gmail.com> > >> wrote: > >>> Hi Daniel, > >>> I got a failure in sending last mail to iio mailing list.Can you > >> please fwd > >>> it to that chain while i subscribe my self to it. > >>> Many thanks. > >> > >> Not sure if you need to be subscribed in order to post there. > >> > >> Cc'ed linux-iio, anyway. > > You don't I am forever emailling from random accounts. If it bounced > for a non obvious reason we probably want to check with the vger admins! > > > > J > Anyhow, now to actually look at the question! > >> > >>> > >>> On Fri, Feb 27, 2015 at 6:45 PM, s.rawat <imsaurabhrawat@gmail.com> > >> wrote: > >>>> > >>>> Do I need to define the all the Usage Tags in the input report of a > >> sensor > >>>> to retrieve minimum any one field or Only a Usage Tag which I wanted > >> to > >>>> retrieve is enough. > >>>> e.g for an input report of an accelerometer which has the below > >>>> fields(added new one in Bold), > >>>> > >>>> HID_USAGE_SENSOR_ACCEL_X_AXIS > >>>> HID_USAGE_SENSOR_ACCEL_Y_AXIS > >>>> HID_USAGE_SENSOR_ACCEL_Z_AXIS > >>>> HID_USAGE_SENSOR_DATA_MOTION_STATE, > >>>> HID_USAGE_SENSOR_DATA_CUSTOM_VALUE_2 > >>>> HID_USAGE_SENSOR_DATA_CUSTOM_VALUE_3 > >>>> HID_USAGE_SENSOR_DATA_CUSTOM_VALUE_4 > >>>> > >>>> I want to retrieve Custom_Value_4 do I also need to define > >> parameters for > >>>> Data_Motion_state, Custom_Value2,Custom_Value3 as well apart from > >>>> Custom_Value4 in the below structure. > >>>> > >>>> enum accel_3d_channel {.. } > >>>> struct accel_3d_state {.. } > >>>> static const struct iio_chan_spec accel_3d_channels[] = { ..} > >>>> > >>>> I did so but was getting error - "failed to setup attributes" but > >> after I > >>>> modified the code in the function : accel_3d_parse_report() like > >> below to > >>>> accommodate all the non Contigous Usage Tags and associated them > >> with their > >>>> channels - *_SCAN_INDEX_* . I did not get this error but some other > >> error > >>>> (listed at the end of the mail) > >>>> > >>>> > >>>> //First Three channel X,Y and Z whose Usage Tags are contionus - > >>>> 0x200453/54/55 > >>>> for (i = 0; i <= CHANNEL_SCAN_INDEX_Z; ++i) { > >>>> > >>>> ret = sensor_hub_input_get_attribute_info(hsdev, > >>>> HID_INPUT_REPORT, > >>>> usage_id, > >>>> HID_USAGE_SENSOR_ACCEL_X_AXIS + i, > >>>> &st->accel[CHANNEL_SCAN_INDEX_X + i]); > >>>> accel_3d_adjust_channel_bit_mask(channels, > >>>> CHANNEL_SCAN_INDEX_X + i, > >>>> st->accel[CHANNEL_SCAN_INDEX_X + i].size); > >>>> } > >>>> > >>>> //Fourth channel For Data Motion - 0x200451 > >>>> ret = sensor_hub_input_get_attribute_info(hsdev, > >>>> HID_INPUT_REPORT, > >>>> usage_id, > >>>> HID_USAGE_SENSOR_DATA_MOTION_STATE, // For CHANNEL_SCAN_DATA_MOTION > >>>> &st->accel[CHANNEL_SCAN_INDEX_X + i]); > >>>> accel_3d_adjust_channel_bit_mask(channels, > >>>> CHANNEL_SCAN_INDEX_X + i, > >>>> st->accel[CHANNEL_SCAN_INDEX_X + i].size); > >>>> > >>>> //Last Three Channel for Custom Value 2,3,4 - 0x200545/46/47 > >>>> for (i = 0; i <= 2; ++i) { > >>>> > >>>> ret = sensor_hub_input_get_attribute_info(hsdev, > >>>> HID_INPUT_REPORT, > >>>> usage_id, > >>>> HID_USAGE_SENSOR_DATA_CUSTOM_VALUE_2 + i, > >>>> &st->accel[CHANNEL_SCAN_INDEX_X + i + 4]); //start after > >>>> CHANNEL_SCAN_DATA_MOTION Channel > >>>> accel_3d_adjust_channel_bit_mask(channels, > >>>> CHANNEL_SCAN_INDEX_X + i + 4, > >>>> st->accel[CHANNEL_SCAN_INDEX_X + i].size); > >>>> } > >>>> > >>>> > >>>> > >>>> But now I am getting a different error : > >>>> > >>>> [13778.127716] iio iio:device4: tried to double register : > >>>> in_accel_x_index > >>>> [13778.127899] hid_sensor_accel_3d HID-SENSOR-200073.3.auto: failed > >> to > >>>> initialize trigger buffer > >>>> [13778.143676] hid_sensor_accel_3d: probe of > >> HID-SENSOR-200073.3.auto > >>>> failed with error -16 > >>>> > >>>> I am still figuring out where else Do I have to modify the code in > >> order > >>>> to receive the above custom values .. > >>>> Thanks, > >>>> S > >>>> > >>>> > >>>> > >>>> On Thu, Feb 26, 2015 at 6:54 PM, Daniel Baluta > >> <daniel.baluta@gmail.com> > >>>> wrote: > >>>>> > >>>>> + linux-iio list. > >>>>> > >>>>> On Thu, Feb 26, 2015 at 8:04 AM, s.rawat <imsaurabhrawat@gmail.com> > >>>>> wrote: > >>>>>> I have modified the hid-sensor-accel_3d.c driver to add the > >> custom > >>>>>> fields - > >>>>>> CHANNEL_SCAN_DATA_MOTION and HID_USAGE_SENSOR_DATA_CUSTOM_VALUEX > >> ( X = > >>>>>> 2,3,4). > >>>>>> Below are my modifications : > >>>>>> > >>>>>> enum accel_3d_channel { > >>>>>> CHANNEL_SCAN_INDEX_X, > >>>>>> CHANNEL_SCAN_INDEX_Y, > >>>>>> CHANNEL_SCAN_INDEX_Z, > >>>>>> CHANNEL_SCAN_DATA_MOTION, > >>>>>> CHANNEL_CUSTOM_VALUE_2, > >>>>>> CHANNEL_CUSTOM_VALUE_3, > >>>>>> CHANNEL_CUSTOM_VALUE_4, > >>>>>> ACCEL_3D_CHANNEL_MAX, > >>>>>> > >>>>>> static const u32 accel_3d_addresses[ACCEL_3D_CHANNEL_MAX] = { > >>>>>> HID_USAGE_SENSOR_ACCEL_X_AXIS, > >>>>>> HID_USAGE_SENSOR_ACCEL_Y_AXIS, > >>>>>> HID_USAGE_SENSOR_ACCEL_Z_AXIS, > >>>>>> HID_USAGE_SENSOR_DATA_MOTION_STATE, > >>>>>> HID_USAGE_SENSOR_DATA_CUSTOM_VALUE2, > >>>>>> HID_USAGE_SENSOR_DATA_CUSTOM_VALUE3, > >>>>>> HID_USAGE_SENSOR_DATA_CUSTOM_VALUE4 > >>>>>> }; > >>>>>> > >>>>>> > >>>>>> > >>>>>> /* Channel definitions */ > >>>>>> static const struct iio_chan_spec accel_3d_channels[] = { > >>>>>> { > >>>>>> .. > >>>>>> .. > >>>>>> .. > >>>>>> { > >>>>>> .type = IIO_ACCEL, > >>>>>> .modified = 1, > >>>>>> .channel2 = IIO_MOD_X, > >>>>>> .info_mask_separate = BIT(IIO_CHAN_INFO_RAW), > >>>>>> .info_mask_shared_by_type = BIT(IIO_CHAN_INFO_OFFSET) | > >>>>>> BIT(IIO_CHAN_INFO_SCALE) | > >>>>>> BIT(IIO_CHAN_INFO_SAMP_FREQ) | > >>>>>> BIT(IIO_CHAN_INFO_HYSTERESIS), > >>>>>> .scan_index = CHANNEL_SCAN_DATA_MOTION, > >>>>>> }, > >>>>>> { > >>>>>> .type = IIO_ACCEL, > >>>>>> .modified = 1, > >>>>>> .channel2 = IIO_MOD_X, > >>>>>> .info_mask_separate = BIT(IIO_CHAN_INFO_RAW), > >>>>>> .info_mask_shared_by_type = BIT(IIO_CHAN_INFO_OFFSET) | > >>>>>> BIT(IIO_CHAN_INFO_SCALE) | > >>>>>> BIT(IIO_CHAN_INFO_SAMP_FREQ) | > >>>>>> BIT(IIO_CHAN_INFO_HYSTERESIS), > >>>>>> .scan_index = CHANNEL_CUSTOM_VALUE_2, > >>>>>> }, > >>>>>> { > >>>>>> .type = IIO_ACCEL, > >>>>>> .modified = 1, > >>>>>> .channel2 = IIO_MOD_X, > >>>>>> .info_mask_separate = BIT(IIO_CHAN_INFO_RAW), > >>>>>> .info_mask_shared_by_type = BIT(IIO_CHAN_INFO_OFFSET) | > >>>>>> BIT(IIO_CHAN_INFO_SCALE) | > >>>>>> BIT(IIO_CHAN_INFO_SAMP_FREQ) | > >>>>>> BIT(IIO_CHAN_INFO_HYSTERESIS), > >>>>>> .scan_index = CHANNEL_CUSTOM_VALUE_3, > >>>>>> }, > >>>>>> { > >>>>>> .type = IIO_ACCEL, > >>>>>> .modified = 1, > >>>>>> .channel2 = IIO_MOD_X, > >>>>>> .info_mask_separate = BIT(IIO_CHAN_INFO_RAW), > >>>>>> .info_mask_shared_by_type = BIT(IIO_CHAN_INFO_OFFSET) | > >>>>>> BIT(IIO_CHAN_INFO_SCALE) | > >>>>>> BIT(IIO_CHAN_INFO_SAMP_FREQ) | > >>>>>> BIT(IIO_CHAN_INFO_HYSTERESIS), > >>>>>> .scan_index = CHANNEL_CUSTOM_VALUE_4, > >>>>>> } > Jonathan Cameron wrote : > This channel array will attempt to create a whole load of identical > attributes. > in_accel_x_raw for each entry. > > I suspect you want is to have > in_accel0_x_raw > in_accel1_x_raw etc? In which case you'll need to also specify > .indexed = 1, > .index = N > > That is probably the cause of the error you saw > (it'll also clash on the attribute for the index as seen above!) > This channel array will attempt to create a whole load of identical attributes. in_accel_x_raw for each entry. Saurabh : >>But Now I didn't get any such error like "failed to setup attributes" , I think attributes has been set fine .Now the problem is in the initialization of trigger buffer.Is the reason same as you said above. I still get the same error : [13778.127716] iio iio:device4: tried to double register : in_accel_x_index [13778.127899] hid_sensor_accel_3d HID-SENSOR-200073.3.auto: failed to initialize trigger buffer [13778.143676] hid_sensor_accel_3d: probe of HID-SENSOR-200073.3.auto failed with error -16 After I modified like this(in *bold*) for the below channel attributes: { .type = IIO_ACCEL, .modified = 1, *.indexed = 1,* .channel2 = IIO_MOD_X, .info_mask_separate = BIT(IIO_CHAN_INFO_RAW), .info_mask_shared_by_type = BIT(IIO_CHAN_INFO_OFFSET) | BIT(IIO_CHAN_INFO_SCALE) | BIT(IIO_CHAN_INFO_SAMP_FREQ) | BIT(IIO_CHAN_INFO_HYSTERESIS), .scan_index = CHANNEL_SCAN_DATA_MOTION, }, { .type = IIO_ACCEL, .modified = 1, *.indexed = 2,* .channel2 = IIO_MOD_X, .info_mask_separate = BIT(IIO_CHAN_INFO_RAW), .info_mask_shared_by_type = BIT(IIO_CHAN_INFO_OFFSET) | BIT(IIO_CHAN_INFO_SCALE) | BIT(IIO_CHAN_INFO_SAMP_FREQ) | BIT(IIO_CHAN_INFO_HYSTERESIS), .scan_index = CHANNEL_CUSTOM_VALUE_2, }, { .type = IIO_ACCEL, .modified = 1, *.indexed = 3,* .channel2 = IIO_MOD_X, .info_mask_separate = BIT(IIO_CHAN_INFO_RAW), .info_mask_shared_by_type = BIT(IIO_CHAN_INFO_OFFSET) | BIT(IIO_CHAN_INFO_SCALE) | BIT(IIO_CHAN_INFO_SAMP_FREQ) | BIT(IIO_CHAN_INFO_HYSTERESIS), .scan_index = CHANNEL_CUSTOM_VALUE_3, }, { .type = IIO_ACCEL, .modified = 1, *.indexed = 4,* .channel2 = IIO_MOD_X, .info_mask_separate = BIT(IIO_CHAN_INFO_RAW), .info_mask_shared_by_type = BIT(IIO_CHAN_INFO_OFFSET) | BIT(IIO_CHAN_INFO_SCALE) | BIT(IIO_CHAN_INFO_SAMP_FREQ) | BIT(IIO_CHAN_INFO_HYSTERESIS), .scan_index = CHANNEL_CUSTOM_VALUE_4, } >From the firmware in the accel input report I sent data_motion, custom value2,3 and 4 apart from usual x,y and z values.I want to retrieve the custom value 2 , 3 and 4 .Once the driver is loaded fine I will modify the generic_buffer.c application in the drivers/staging/iio/Documentation. > >>>>>> > >>>>>> > >>>>>> > >>>>>> /* Capture samples in local storage */ > >>>>>> static int accel_3d_capture_sample(struct hid_sensor_hub_device > >> *hsdev, > >>>>>> unsigned usage_id, > >>>>>> size_t raw_len, char *raw_data, > >>>>>> void *priv) > >>>>>> { > >>>>>> struct iio_dev *indio_dev = platform_get_drvdata(priv); > >>>>>> struct accel_3d_state *accel_state = iio_priv(indio_dev); > >>>>>> int offset; > >>>>>> int ret = -EINVAL; > >>>>>> > >>>>>> switch (usage_id) { > >>>>>> case HID_USAGE_SENSOR_ACCEL_X_AXIS: > >>>>>> case HID_USAGE_SENSOR_ACCEL_Y_AXIS: > >>>>>> case HID_USAGE_SENSOR_ACCEL_Z_AXIS: > >>>>>> case HID_USAGE_SENSOR_DATA_MOTION_STATE: > >>>>>> case HID_USAGE_SENSOR_DATA_CUSTOM_VALUE2: > >>>>>> case HID_USAGE_SENSOR_DATA_CUSTOM_VALUE3: > >>>>>> case HID_USAGE_SENSOR_DATA_CUSTOM_VALUE4: > >>>>>> offset = usage_id - HID_USAGE_SENSOR_ACCEL_X_AXIS; > >>>>>> > >>>>>> > >>>>>> > >>>>>> /* Parse report which is specific to an usage id*/ > >>>>>> static int accel_3d_parse_report(struct platform_device *pdev, > >>>>>> struct hid_sensor_hub_device *hsdev, > >>>>>> struct iio_chan_spec *channels, > >>>>>> unsigned usage_id, > >>>>>> struct accel_3d_state *st) > >>>>>> { > >>>>>> int ret; > >>>>>> int i; > >>>>>> > >>>>>> for (i = 0; i <= CHANNEL_CUSTOM_VALUE_4; ++i) { //previously < > >>>>>> CHANNEL_SCAN_INDEX_Z > >>>>>> ret = sensor_hub_input_get_attribute_info(hsdev, > >>>>>> > >>>>>> > >>>>>> > >>>>>> After build /insmod i get the following dmesg : > >>>>>> > >>>>>> hid_sensor_accel_3d:HID-SENSOR-200073.3 auto : failed to setup > >>>>>> attributes > >>>>>> hid_sensor_accel_3d:HID-SENSOR-200073.3 auto.failed with error -1 > >>>>>> > >>>>>> > >>>>>> I am not getting what else I have to modify to avoid this error > >> .If i > >>>>>> remove > >>>>>> the portion in bold(and use this original code > >>>>>> > >>>>>> > >> : > http://lxr.free-electrons.com/source/drivers/iio/accel/hid-sensor-accel-3d.c > ) > >>>>>> I can happily insert the module without any error and can > >> interact with > >>>>>> the > >>>>>> driver using my application. > >>>>>> > >>>>>> > >>>>>> _______________________________________________ > >>>>>> Kernelnewbies mailing list > >>>>>> Kernelnewbies@kernelnewbies.org > >>>>>> http://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies > >>>>>> > >>>> > >>>> > >>> > >> -- > >> To unsubscribe from this list: send the line "unsubscribe linux-iio" in > >> the body of a message to majordomo@vger.kernel.org > >> More majordomo info at http://vger.kernel.org/majordomo-info.html > > > > [-- Attachment #2: Type: text/html, Size: 19721 bytes --] ^ permalink raw reply [flat|nested] 8+ messages in thread
* Getting error "failed to setup attributes" on Adding Custom Fields in accelerometer HID driver
@ 2015-02-26 6:04 s.rawat
2015-02-26 13:24 ` Daniel Baluta
0 siblings, 1 reply; 8+ messages in thread
From: s.rawat @ 2015-02-26 6:04 UTC (permalink / raw)
To: kernelnewbies
I have modified the hid-sensor-accel_3d.c driver to add the custom fields
- CHANNEL_SCAN_DATA_MOTION and HID_USAGE_SENSOR_DATA_CUSTOM_VALUEX ( X =
2,3,4).
Below are my modifications :
enum accel_3d_channel {
CHANNEL_SCAN_INDEX_X,
CHANNEL_SCAN_INDEX_Y,
CHANNEL_SCAN_INDEX_Z,
*CHANNEL_SCAN_DATA_MOTION,*
* CHANNEL_CUSTOM_VALUE_2,*
* CHANNEL_CUSTOM_VALUE_3,*
* CHANNEL_CUSTOM_VALUE_4,*
ACCEL_3D_CHANNEL_MAX,
static const u32 accel_3d_addresses[ACCEL_3D_CHANNEL_MAX] = {
HID_USAGE_SENSOR_ACCEL_X_AXIS,
HID_USAGE_SENSOR_ACCEL_Y_AXIS,
HID_USAGE_SENSOR_ACCEL_Z_AXIS,
*HID_USAGE_SENSOR_DATA_MOTION_STATE,*
* HID_USAGE_SENSOR_DATA_CUSTOM_VALUE2, *
* HID_USAGE_SENSOR_DATA_CUSTOM_VALUE3, *
* HID_USAGE_SENSOR_DATA_CUSTOM_VALUE4*
};
/* Channel definitions */
static const struct iio_chan_spec accel_3d_channels[] = {
{
..
..
..
*{*
* .type = IIO_ACCEL,*
* .modified = 1,*
* .channel2 = IIO_MOD_X,*
* .info_mask_separate = BIT(IIO_CHAN_INFO_RAW),*
* .info_mask_shared_by_type = BIT(IIO_CHAN_INFO_OFFSET) |*
* BIT(IIO_CHAN_INFO_SCALE) |*
* BIT(IIO_CHAN_INFO_SAMP_FREQ) |*
* BIT(IIO_CHAN_INFO_HYSTERESIS),*
* .scan_index = CHANNEL_SCAN_DATA_MOTION,*
* },*
*{*
* .type = IIO_ACCEL,*
* .modified = 1,*
* .channel2 = IIO_MOD_X,*
* .info_mask_separate = BIT(IIO_CHAN_INFO_RAW),*
* .info_mask_shared_by_type = BIT(IIO_CHAN_INFO_OFFSET) |*
* BIT(IIO_CHAN_INFO_SCALE) |*
* BIT(IIO_CHAN_INFO_SAMP_FREQ) |*
* BIT(IIO_CHAN_INFO_HYSTERESIS),*
* .scan_index = CHANNEL_CUSTOM_VALUE_2,*
* },*
* {*
* .type = IIO_ACCEL,*
* .modified = 1,*
* .channel2 = IIO_MOD_X,*
* .info_mask_separate = BIT(IIO_CHAN_INFO_RAW),*
* .info_mask_shared_by_type = BIT(IIO_CHAN_INFO_OFFSET) |*
* BIT(IIO_CHAN_INFO_SCALE) |*
* BIT(IIO_CHAN_INFO_SAMP_FREQ) |*
* BIT(IIO_CHAN_INFO_HYSTERESIS),*
* .scan_index = CHANNEL_CUSTOM_VALUE_3,*
* },*
* {*
* .type = IIO_ACCEL,*
* .modified = 1,*
* .channel2 = IIO_MOD_X,*
* .info_mask_separate = BIT(IIO_CHAN_INFO_RAW),*
* .info_mask_shared_by_type = BIT(IIO_CHAN_INFO_OFFSET) |*
* BIT(IIO_CHAN_INFO_SCALE) |*
* BIT(IIO_CHAN_INFO_SAMP_FREQ) |*
* BIT(IIO_CHAN_INFO_HYSTERESIS),*
* .scan_index = CHANNEL_CUSTOM_VALUE_4,*
* }*
/* Capture samples in local storage */
static int accel_3d_capture_sample(struct hid_sensor_hub_device *hsdev,
unsigned usage_id,
size_t raw_len, char *raw_data,
void *priv)
{
struct iio_dev *indio_dev = platform_get_drvdata(priv);
struct accel_3d_state *accel_state = iio_priv(indio_dev);
int offset;
int ret = -EINVAL;
switch (usage_id) {
case HID_USAGE_SENSOR_ACCEL_X_AXIS:
case HID_USAGE_SENSOR_ACCEL_Y_AXIS:
case HID_USAGE_SENSOR_ACCEL_Z_AXIS:
* case HID_USAGE_SENSOR_DATA_MOTION_STATE:*
* case HID_USAGE_SENSOR_DATA_CUSTOM_VALUE2:*
* case HID_USAGE_SENSOR_DATA_CUSTOM_VALUE3:*
* case HID_USAGE_SENSOR_DATA_CUSTOM_VALUE4:*
offset = usage_id - HID_USAGE_SENSOR_ACCEL_X_AXIS;
/* Parse report which is specific to an usage id*/
static int accel_3d_parse_report(struct platform_device *pdev,
struct hid_sensor_hub_device *hsdev,
struct iio_chan_spec *channels,
unsigned usage_id,
struct accel_3d_state *st)
{
int ret;
int i;
*for (i = 0; i <= CHANNEL_CUSTOM_VALUE_4; ++i) { //previously <
CHANNEL_SCAN_INDEX_Z*
ret = sensor_hub_input_get_attribute_info(hsdev,
After build /insmod i get the following dmesg :
*hid_sensor_accel_3d:HID-SENSOR-200073.3 auto : failed to setup attributes*
*hid_sensor_accel_3d:HID-SENSOR-200073.3 auto.failed with error -1*
I am not getting what else I have to modify to avoid this error .If i
remove the portion in bold(and use this original code :
http://lxr.free-electrons.com/source/drivers/iio/accel/hid-sensor-accel-3d.c)
I can happily insert the module without any error and can interact with the
driver using my application.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.kernelnewbies.org/pipermail/kernelnewbies/attachments/20150226/4b1b0597/attachment.html
^ permalink raw reply [flat|nested] 8+ messages in thread* Getting error "failed to setup attributes" on Adding Custom Fields in accelerometer HID driver 2015-02-26 6:04 s.rawat @ 2015-02-26 13:24 ` Daniel Baluta 0 siblings, 0 replies; 8+ messages in thread From: Daniel Baluta @ 2015-02-26 13:24 UTC (permalink / raw) To: kernelnewbies + linux-iio list. On Thu, Feb 26, 2015 at 8:04 AM, s.rawat <imsaurabhrawat@gmail.com> wrote: > I have modified the hid-sensor-accel_3d.c driver to add the custom fields - > CHANNEL_SCAN_DATA_MOTION and HID_USAGE_SENSOR_DATA_CUSTOM_VALUEX ( X = > 2,3,4). > Below are my modifications : > > enum accel_3d_channel { > CHANNEL_SCAN_INDEX_X, > CHANNEL_SCAN_INDEX_Y, > CHANNEL_SCAN_INDEX_Z, > CHANNEL_SCAN_DATA_MOTION, > CHANNEL_CUSTOM_VALUE_2, > CHANNEL_CUSTOM_VALUE_3, > CHANNEL_CUSTOM_VALUE_4, > ACCEL_3D_CHANNEL_MAX, > > static const u32 accel_3d_addresses[ACCEL_3D_CHANNEL_MAX] = { > HID_USAGE_SENSOR_ACCEL_X_AXIS, > HID_USAGE_SENSOR_ACCEL_Y_AXIS, > HID_USAGE_SENSOR_ACCEL_Z_AXIS, > HID_USAGE_SENSOR_DATA_MOTION_STATE, > HID_USAGE_SENSOR_DATA_CUSTOM_VALUE2, > HID_USAGE_SENSOR_DATA_CUSTOM_VALUE3, > HID_USAGE_SENSOR_DATA_CUSTOM_VALUE4 > }; > > > > /* Channel definitions */ > static const struct iio_chan_spec accel_3d_channels[] = { > { > .. > .. > .. > { > .type = IIO_ACCEL, > .modified = 1, > .channel2 = IIO_MOD_X, > .info_mask_separate = BIT(IIO_CHAN_INFO_RAW), > .info_mask_shared_by_type = BIT(IIO_CHAN_INFO_OFFSET) | > BIT(IIO_CHAN_INFO_SCALE) | > BIT(IIO_CHAN_INFO_SAMP_FREQ) | > BIT(IIO_CHAN_INFO_HYSTERESIS), > .scan_index = CHANNEL_SCAN_DATA_MOTION, > }, > { > .type = IIO_ACCEL, > .modified = 1, > .channel2 = IIO_MOD_X, > .info_mask_separate = BIT(IIO_CHAN_INFO_RAW), > .info_mask_shared_by_type = BIT(IIO_CHAN_INFO_OFFSET) | > BIT(IIO_CHAN_INFO_SCALE) | > BIT(IIO_CHAN_INFO_SAMP_FREQ) | > BIT(IIO_CHAN_INFO_HYSTERESIS), > .scan_index = CHANNEL_CUSTOM_VALUE_2, > }, > { > .type = IIO_ACCEL, > .modified = 1, > .channel2 = IIO_MOD_X, > .info_mask_separate = BIT(IIO_CHAN_INFO_RAW), > .info_mask_shared_by_type = BIT(IIO_CHAN_INFO_OFFSET) | > BIT(IIO_CHAN_INFO_SCALE) | > BIT(IIO_CHAN_INFO_SAMP_FREQ) | > BIT(IIO_CHAN_INFO_HYSTERESIS), > .scan_index = CHANNEL_CUSTOM_VALUE_3, > }, > { > .type = IIO_ACCEL, > .modified = 1, > .channel2 = IIO_MOD_X, > .info_mask_separate = BIT(IIO_CHAN_INFO_RAW), > .info_mask_shared_by_type = BIT(IIO_CHAN_INFO_OFFSET) | > BIT(IIO_CHAN_INFO_SCALE) | > BIT(IIO_CHAN_INFO_SAMP_FREQ) | > BIT(IIO_CHAN_INFO_HYSTERESIS), > .scan_index = CHANNEL_CUSTOM_VALUE_4, > } > > > > /* Capture samples in local storage */ > static int accel_3d_capture_sample(struct hid_sensor_hub_device *hsdev, > unsigned usage_id, > size_t raw_len, char *raw_data, > void *priv) > { > struct iio_dev *indio_dev = platform_get_drvdata(priv); > struct accel_3d_state *accel_state = iio_priv(indio_dev); > int offset; > int ret = -EINVAL; > > switch (usage_id) { > case HID_USAGE_SENSOR_ACCEL_X_AXIS: > case HID_USAGE_SENSOR_ACCEL_Y_AXIS: > case HID_USAGE_SENSOR_ACCEL_Z_AXIS: > case HID_USAGE_SENSOR_DATA_MOTION_STATE: > case HID_USAGE_SENSOR_DATA_CUSTOM_VALUE2: > case HID_USAGE_SENSOR_DATA_CUSTOM_VALUE3: > case HID_USAGE_SENSOR_DATA_CUSTOM_VALUE4: > offset = usage_id - HID_USAGE_SENSOR_ACCEL_X_AXIS; > > > > /* Parse report which is specific to an usage id*/ > static int accel_3d_parse_report(struct platform_device *pdev, > struct hid_sensor_hub_device *hsdev, > struct iio_chan_spec *channels, > unsigned usage_id, > struct accel_3d_state *st) > { > int ret; > int i; > > for (i = 0; i <= CHANNEL_CUSTOM_VALUE_4; ++i) { //previously < > CHANNEL_SCAN_INDEX_Z > ret = sensor_hub_input_get_attribute_info(hsdev, > > > > After build /insmod i get the following dmesg : > > hid_sensor_accel_3d:HID-SENSOR-200073.3 auto : failed to setup attributes > hid_sensor_accel_3d:HID-SENSOR-200073.3 auto.failed with error -1 > > > I am not getting what else I have to modify to avoid this error .If i remove > the portion in bold(and use this original code > :http://lxr.free-electrons.com/source/drivers/iio/accel/hid-sensor-accel-3d.c) > I can happily insert the module without any error and can interact with the > driver using my application. > > > _______________________________________________ > Kernelnewbies mailing list > Kernelnewbies at kernelnewbies.org > http://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies > ^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: Getting error "failed to setup attributes" on Adding Custom Fields in accelerometer HID driver @ 2015-02-26 13:24 ` Daniel Baluta 0 siblings, 0 replies; 8+ messages in thread From: Daniel Baluta @ 2015-02-26 13:24 UTC (permalink / raw) To: s.rawat, linux-iio@vger.kernel.org; +Cc: kernelnewbies + linux-iio list. On Thu, Feb 26, 2015 at 8:04 AM, s.rawat <imsaurabhrawat@gmail.com> wrote: > I have modified the hid-sensor-accel_3d.c driver to add the custom fields - > CHANNEL_SCAN_DATA_MOTION and HID_USAGE_SENSOR_DATA_CUSTOM_VALUEX ( X = > 2,3,4). > Below are my modifications : > > enum accel_3d_channel { > CHANNEL_SCAN_INDEX_X, > CHANNEL_SCAN_INDEX_Y, > CHANNEL_SCAN_INDEX_Z, > CHANNEL_SCAN_DATA_MOTION, > CHANNEL_CUSTOM_VALUE_2, > CHANNEL_CUSTOM_VALUE_3, > CHANNEL_CUSTOM_VALUE_4, > ACCEL_3D_CHANNEL_MAX, > > static const u32 accel_3d_addresses[ACCEL_3D_CHANNEL_MAX] = { > HID_USAGE_SENSOR_ACCEL_X_AXIS, > HID_USAGE_SENSOR_ACCEL_Y_AXIS, > HID_USAGE_SENSOR_ACCEL_Z_AXIS, > HID_USAGE_SENSOR_DATA_MOTION_STATE, > HID_USAGE_SENSOR_DATA_CUSTOM_VALUE2, > HID_USAGE_SENSOR_DATA_CUSTOM_VALUE3, > HID_USAGE_SENSOR_DATA_CUSTOM_VALUE4 > }; > > > > /* Channel definitions */ > static const struct iio_chan_spec accel_3d_channels[] = { > { > .. > .. > .. > { > .type = IIO_ACCEL, > .modified = 1, > .channel2 = IIO_MOD_X, > .info_mask_separate = BIT(IIO_CHAN_INFO_RAW), > .info_mask_shared_by_type = BIT(IIO_CHAN_INFO_OFFSET) | > BIT(IIO_CHAN_INFO_SCALE) | > BIT(IIO_CHAN_INFO_SAMP_FREQ) | > BIT(IIO_CHAN_INFO_HYSTERESIS), > .scan_index = CHANNEL_SCAN_DATA_MOTION, > }, > { > .type = IIO_ACCEL, > .modified = 1, > .channel2 = IIO_MOD_X, > .info_mask_separate = BIT(IIO_CHAN_INFO_RAW), > .info_mask_shared_by_type = BIT(IIO_CHAN_INFO_OFFSET) | > BIT(IIO_CHAN_INFO_SCALE) | > BIT(IIO_CHAN_INFO_SAMP_FREQ) | > BIT(IIO_CHAN_INFO_HYSTERESIS), > .scan_index = CHANNEL_CUSTOM_VALUE_2, > }, > { > .type = IIO_ACCEL, > .modified = 1, > .channel2 = IIO_MOD_X, > .info_mask_separate = BIT(IIO_CHAN_INFO_RAW), > .info_mask_shared_by_type = BIT(IIO_CHAN_INFO_OFFSET) | > BIT(IIO_CHAN_INFO_SCALE) | > BIT(IIO_CHAN_INFO_SAMP_FREQ) | > BIT(IIO_CHAN_INFO_HYSTERESIS), > .scan_index = CHANNEL_CUSTOM_VALUE_3, > }, > { > .type = IIO_ACCEL, > .modified = 1, > .channel2 = IIO_MOD_X, > .info_mask_separate = BIT(IIO_CHAN_INFO_RAW), > .info_mask_shared_by_type = BIT(IIO_CHAN_INFO_OFFSET) | > BIT(IIO_CHAN_INFO_SCALE) | > BIT(IIO_CHAN_INFO_SAMP_FREQ) | > BIT(IIO_CHAN_INFO_HYSTERESIS), > .scan_index = CHANNEL_CUSTOM_VALUE_4, > } > > > > /* Capture samples in local storage */ > static int accel_3d_capture_sample(struct hid_sensor_hub_device *hsdev, > unsigned usage_id, > size_t raw_len, char *raw_data, > void *priv) > { > struct iio_dev *indio_dev = platform_get_drvdata(priv); > struct accel_3d_state *accel_state = iio_priv(indio_dev); > int offset; > int ret = -EINVAL; > > switch (usage_id) { > case HID_USAGE_SENSOR_ACCEL_X_AXIS: > case HID_USAGE_SENSOR_ACCEL_Y_AXIS: > case HID_USAGE_SENSOR_ACCEL_Z_AXIS: > case HID_USAGE_SENSOR_DATA_MOTION_STATE: > case HID_USAGE_SENSOR_DATA_CUSTOM_VALUE2: > case HID_USAGE_SENSOR_DATA_CUSTOM_VALUE3: > case HID_USAGE_SENSOR_DATA_CUSTOM_VALUE4: > offset = usage_id - HID_USAGE_SENSOR_ACCEL_X_AXIS; > > > > /* Parse report which is specific to an usage id*/ > static int accel_3d_parse_report(struct platform_device *pdev, > struct hid_sensor_hub_device *hsdev, > struct iio_chan_spec *channels, > unsigned usage_id, > struct accel_3d_state *st) > { > int ret; > int i; > > for (i = 0; i <= CHANNEL_CUSTOM_VALUE_4; ++i) { //previously < > CHANNEL_SCAN_INDEX_Z > ret = sensor_hub_input_get_attribute_info(hsdev, > > > > After build /insmod i get the following dmesg : > > hid_sensor_accel_3d:HID-SENSOR-200073.3 auto : failed to setup attributes > hid_sensor_accel_3d:HID-SENSOR-200073.3 auto.failed with error -1 > > > I am not getting what else I have to modify to avoid this error .If i remove > the portion in bold(and use this original code > :http://lxr.free-electrons.com/source/drivers/iio/accel/hid-sensor-accel-3d.c) > I can happily insert the module without any error and can interact with the > driver using my application. > > > _______________________________________________ > Kernelnewbies mailing list > Kernelnewbies@kernelnewbies.org > http://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies > ^ permalink raw reply [flat|nested] 8+ messages in thread
end of thread, other threads:[~2015-03-02 4:41 UTC | newest]
Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-02-27 13:15 Getting error "failed to setup attributes" on Adding Custom Fields in accelerometer HID driver s.rawat
[not found] ` <CALwa49uj+e-=fqkppQPd+NfXwG03+joHqBHGYyjvOWgrmvD-4Q@mail.gmail.com>
2015-02-27 14:30 ` Daniel Baluta
2015-02-27 15:14 ` Jonathan Cameron
2015-02-28 11:43 ` Jonathan Cameron
2015-03-02 4:41 ` s.rawat
-- strict thread matches above, loose matches on Subject: below --
2015-02-26 6:04 s.rawat
2015-02-26 13:24 ` Daniel Baluta
2015-02-26 13:24 ` Daniel Baluta
This is an external index of several public inboxes, see mirroring instructions on how to clone and mirror all data and code used by this external index.