Changes in uspace/drv/bus/usb/usbhid/multimedia/multimedia.c [2a5b62b:5da7199] in mainline
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/drv/bus/usb/usbhid/multimedia/multimedia.c
r2a5b62b r5da7199 64 64 //int32_t *keys; 65 65 /** Count of stored keys (i.e. number of keys in the report). */ 66 //size_t key_count; 66 //size_t key_count; 67 67 /** IPC session to the console device (for sending key events). */ 68 68 async_sess_t *console_sess; 69 /** DDF function */70 ddf_fun_t *fun;71 69 } usb_multimedia_t; 72 70 … … 88 86 { 89 87 usb_log_debug(NAME " default_connection_handler()\n"); 90 88 91 89 usb_multimedia_t *multim_dev = (usb_multimedia_t *)fun->driver_data; 92 90 93 91 if (multim_dev == NULL) { 94 92 async_answer_0(icallid, EINVAL); 95 93 return; 96 94 } 97 95 98 96 async_sess_t *sess = 99 97 async_callback_receive_start(EXCHANGE_SERIALIZE, icall); … … 139 137 assert(hid_dev != NULL); 140 138 assert(multim_dev != NULL); 141 139 142 140 kbd_event_t ev; 143 141 144 142 ev.type = type; 145 143 ev.key = key; … … 153 151 return; 154 152 } 155 153 156 154 async_exch_t *exch = async_exchange_begin(multim_dev->console_sess); 157 155 async_msg_4(exch, KBDEV_EVENT, ev.type, ev.key, ev.mods, ev.c); … … 171 169 return ENOMEM; 172 170 } 173 171 174 172 fun->ops = &multimedia_ops; 175 173 fun->driver_data = multim_dev; // TODO: maybe change to hid_dev->data 176 174 177 175 int rc = ddf_fun_bind(fun); 178 176 if (rc != EOK) { 179 177 usb_log_error("Could not bind DDF function: %s.\n", 180 178 str_error(rc)); 179 // TODO: Can / should I destroy the DDF function? 181 180 ddf_fun_destroy(fun); 182 181 return rc; 183 182 } 184 183 185 184 usb_log_debug("%s function created (handle: %" PRIun ").\n", 186 185 NAME, fun->handle); 187 186 188 187 rc = ddf_fun_add_to_category(fun, "keyboard"); 189 188 if (rc != EOK) { … … 191 190 "Could not add DDF function to category 'keyboard': %s.\n", 192 191 str_error(rc)); 192 // TODO: Can / should I destroy the DDF function? 193 193 ddf_fun_destroy(fun); 194 194 return rc; 195 195 } 196 multim_dev->fun = fun; 197 196 198 197 return EOK; 199 198 } … … 206 205 return EINVAL; /*! @todo Other return code? */ 207 206 } 208 207 209 208 usb_log_debug(NAME " Initializing HID/multimedia structure...\n"); 210 209 211 210 usb_multimedia_t *multim_dev = (usb_multimedia_t *)malloc( 212 211 sizeof(usb_multimedia_t)); … … 214 213 return ENOMEM; 215 214 } 216 215 217 216 multim_dev->console_sess = NULL; 218 217 219 218 /*! @todo Autorepeat */ 220 219 221 220 // save the KBD device structure into the HID device structure 222 221 *data = multim_dev; 223 222 224 223 usb_log_debug(NAME " HID/multimedia device structure initialized.\n"); 225 224 226 225 int rc = usb_multimedia_create_function(hid_dev, multim_dev); 227 226 if (rc != EOK) 228 227 return rc; 229 228 230 229 usb_log_debug(NAME " HID/multimedia structure initialized.\n"); 231 230 232 231 return EOK; 233 232 } … … 240 239 return; 241 240 } 242 241 243 242 if (data != NULL) { 244 243 usb_multimedia_t *multim_dev = (usb_multimedia_t *)data; 245 244 // hangup session to the console 246 245 async_hangup(multim_dev->console_sess); 247 const int ret = ddf_fun_unbind(multim_dev->fun);248 if (ret != EOK) {249 usb_log_error("Failed to unbind multim function.\n");250 } else {251 usb_log_debug2("%s unbound.\n", multim_dev->fun->name);252 ddf_fun_destroy(multim_dev->fun);253 }254 246 } 255 247 } … … 265 257 266 258 usb_multimedia_t *multim_dev = (usb_multimedia_t *)data; 267 259 268 260 usb_hid_report_path_t *path = usb_hid_report_path(); 269 261 usb_hid_report_path_append_item(path, USB_HIDUT_PAGE_CONSUMER, 0); … … 291 283 key); 292 284 } 293 285 294 286 field = usb_hid_report_get_sibling( 295 287 hid_dev->report, field, path, USB_HID_PATH_COMPARE_END 296 288 | USB_HID_PATH_COMPARE_USAGE_PAGE_ONLY, 297 289 USB_HID_REPORT_TYPE_INPUT); 298 } 290 } 299 291 300 292 usb_hid_report_path_free(path); 301 293 302 294 return true; 303 295 }
Note:
See TracChangeset
for help on using the changeset viewer.