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