Ignore:
Timestamp:
2011-05-24T21:52:44Z (14 years ago)
Author:
Lubos Slovak <lubos.slovak@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
fa8d346
Parents:
a28b41d
Message:

Implemented stubs for getting descriptor and its length

  • Work done by VH.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • uspace/lib/drv/generic/remote_usbhid.c

    ra28b41d r9dddb3d  
    117117                async_answer_0(data_callid, EINVAL);
    118118                async_answer_0(callid, EINVAL);
     119                return;
    119120        }
    120121
     
    125126                async_answer_0(data_callid, ENOMEM);
    126127                async_answer_0(callid, ENOMEM);
     128                return;
    127129        }
    128130
     
    133135                async_answer_0(data_callid, rc);
    134136                async_answer_0(callid, rc);
     137                return;
    135138        }
    136139        if (act_length >= len) {
     
    147150}
    148151
    149 void remote_usbhid_get_report_descriptor(ddf_fun_t *fun, void *iface,
    150     ipc_callid_t callid, ipc_call_t *call)
    151 {
    152         /** @todo Implement! */
    153 }
    154 
    155 void remote_usbhid_get_report_descriptor_length(ddf_fun_t *fun, void *iface,
    156     ipc_callid_t callid, ipc_call_t *call)
    157 {
    158         /** @todo Implement! */
    159 }
     152void remote_usbhid_get_report_descriptor_length(ddf_fun_t *fun, void *iface,
     153    ipc_callid_t callid, ipc_call_t *call)
     154{
     155        usbhid_iface_t *hid_iface = (usbhid_iface_t *) iface;
     156
     157        if (!hid_iface->get_report_descriptor_length) {
     158                async_answer_0(callid, ENOTSUP);
     159                return;
     160        }
     161
     162        size_t len = hid_iface->get_report_descriptor_length(fun);
     163        async_answer_1(callid, EOK, (sysarg_t) len);
     164}
     165
     166void remote_usbhid_get_report_descriptor(ddf_fun_t *fun, void *iface,
     167    ipc_callid_t callid, ipc_call_t *call)
     168{
     169        usbhid_iface_t *hid_iface = (usbhid_iface_t *) iface;
     170
     171        if (!hid_iface->get_report_descriptor) {
     172                async_answer_0(callid, ENOTSUP);
     173                return;
     174        }
     175
     176        size_t len;
     177        ipc_callid_t data_callid;
     178        if (!async_data_read_receive(&data_callid, &len)) {
     179                async_answer_0(callid, EINVAL);
     180                return;
     181        }
     182
     183        if (len == 0) {
     184                async_answer_0(data_callid, EINVAL);
     185                async_answer_0(callid, EINVAL);
     186                return;
     187        }
     188
     189        uint8_t *descriptor = malloc(len);
     190        if (descriptor == NULL) {
     191                async_answer_0(data_callid, ENOMEM);
     192                async_answer_0(callid, ENOMEM);
     193                return;
     194        }
     195
     196        size_t act_len = 0;
     197        int rc = hid_iface->get_report_descriptor(fun, descriptor, len,
     198            &act_len);
     199        if (act_len > len) {
     200                rc = ELIMIT;
     201        }
     202        if (rc != EOK) {
     203                free(descriptor);
     204                async_answer_0(data_callid, rc);
     205                async_answer_0(callid, rc);
     206                return;
     207        }
     208
     209        async_data_read_finalize(data_callid, descriptor, act_len);
     210        async_answer_0(callid, EOK);
     211
     212        free(descriptor);
     213}
     214
     215
    160216
    161217/**
Note: See TracChangeset for help on using the changeset viewer.