Changeset 9dddb3d in mainline
- Timestamp:
- 2011-05-24T21:52:44Z (13 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- fa8d346
- Parents:
- a28b41d
- Location:
- uspace/lib
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/lib/drv/generic/remote_usbhid.c
ra28b41d r9dddb3d 117 117 async_answer_0(data_callid, EINVAL); 118 118 async_answer_0(callid, EINVAL); 119 return; 119 120 } 120 121 … … 125 126 async_answer_0(data_callid, ENOMEM); 126 127 async_answer_0(callid, ENOMEM); 128 return; 127 129 } 128 130 … … 133 135 async_answer_0(data_callid, rc); 134 136 async_answer_0(callid, rc); 137 return; 135 138 } 136 139 if (act_length >= len) { … … 147 150 } 148 151 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 } 152 void 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 166 void 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 160 216 161 217 /** -
uspace/lib/drv/include/usbhid_iface.h
ra28b41d r9dddb3d 71 71 * - none 72 72 * Answer: 73 * - Size of one report in bytes. 74 * - 75 * 76 * @todo Finish this comment 73 * - EOK - method is implemented (expected always) 74 * Parameters of the answer: 75 * - Size of the report in bytes. 77 76 */ 78 77 IPC_M_USBHID_GET_REPORT_DESCRIPTOR_LENGTH, … … 82 81 * Parameters: 83 82 * - none 83 * The call is followed by data read expecting the descriptor itself. 84 84 * Answer: 85 85 * - EOK - report descriptor returned. 86 * -87 *88 * @todo Finish this comment89 86 */ 90 87 IPC_M_USBHID_GET_REPORT_DESCRIPTOR … … 125 122 * @param[in] fun DDF function answering the request. 126 123 * @param[out] desc Buffer with the report descriptor. 127 * @param[out] size Size of the report descriptors in bytes. 124 * @param[in] size Size of the allocated @p desc buffer. 125 * @param[out] act_size Actual size of the report descriptor returned. 128 126 * @return Error code. 129 127 */ -
uspace/lib/usbhid/src/hidiface.c
ra28b41d r9dddb3d 56 56 IPC_M_USBHID_GET_EVENT_LENGTH, &len); 57 57 if (rc == EOK) { 58 *size = (size_t) len; 58 if (size != NULL) { 59 *size = (size_t) len; 60 } 59 61 } 60 62 … … 148 150 int usbhid_dev_get_report_descriptor_length(int dev_phone, size_t *size) 149 151 { 150 /** @todo Implement! */ 151 return ENOTSUP; 152 if (dev_phone < 0) { 153 return EINVAL; 154 } 155 156 sysarg_t arg_size; 157 int rc = async_req_1_1(dev_phone, DEV_IFACE_ID(USBHID_DEV_IFACE), 158 IPC_M_USBHID_GET_REPORT_DESCRIPTOR_LENGTH, &arg_size); 159 if (rc == EOK) { 160 if (size != NULL) { 161 *size = (size_t) arg_size; 162 } 163 } 164 return rc; 152 165 } 153 166 … … 155 168 size_t *actual_size) 156 169 { 157 /** @todo Implement! */ 158 return ENOTSUP; 170 if (dev_phone < 0) { 171 return EINVAL; 172 } 173 if ((buf == NULL)) { 174 return ENOMEM; 175 } 176 if (size == 0) { 177 return EINVAL; 178 } 179 180 aid_t opening_request = async_send_1(dev_phone, 181 DEV_IFACE_ID(USBHID_DEV_IFACE), IPC_M_USBHID_GET_REPORT_DESCRIPTOR, 182 NULL); 183 if (opening_request == 0) { 184 return ENOMEM; 185 } 186 187 ipc_call_t data_request_call; 188 aid_t data_request = async_data_read(dev_phone, buf, size, 189 &data_request_call); 190 if (data_request == 0) { 191 async_wait_for(opening_request, NULL); 192 return ENOMEM; 193 } 194 195 sysarg_t data_request_rc; 196 sysarg_t opening_request_rc; 197 async_wait_for(data_request, &data_request_rc); 198 async_wait_for(opening_request, &opening_request_rc); 199 200 if (data_request_rc != EOK) { 201 /* Prefer return code of the opening request. */ 202 if (opening_request_rc != EOK) { 203 return (int) opening_request_rc; 204 } else { 205 return (int) data_request_rc; 206 } 207 } 208 209 if (opening_request_rc != EOK) { 210 return (int) opening_request_rc; 211 } 212 213 size_t act_size = IPC_GET_ARG2(data_request_call); 214 215 if (actual_size != NULL) { 216 *actual_size = act_size; 217 } 218 219 return EOK; 159 220 } 160 221
Note:
See TracChangeset
for help on using the changeset viewer.