Changeset 65b458c4 in mainline for uspace/drv/usbhid/multimedia/multimedia.c
- Timestamp:
- 2011-05-13T12:44:37Z (14 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- 37f87fa
- Parents:
- 97cb542
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/drv/usbhid/multimedia/multimedia.c
r97cb542 r65b458c4 87 87 sysarg_t method = IPC_GET_IMETHOD(*icall); 88 88 89 usb_hid_dev_t *hid_dev = (usb_hid_dev_t *)fun->driver_data; 90 91 if (hid_dev == NULL || hid_dev->data == NULL) { 89 usb_multimedia_t *multim_dev = (usb_multimedia_t *)fun->driver_data; 90 //usb_hid_dev_t *hid_dev = (usb_hid_dev_t *)fun->driver_data; 91 92 if (multim_dev == NULL) { 92 93 async_answer_0(icallid, EINVAL); 93 94 return; 94 95 } 95 96 assert(hid_dev != NULL);97 assert(hid_dev->data != NULL);98 usb_multimedia_t *multim_dev = (usb_multimedia_t *)hid_dev->data;99 96 100 97 if (method == IPC_M_CONNECT_TO_ME) { … … 139 136 * @param key Key code of the key according to HID Usage Tables. 140 137 */ 141 static void usb_multimedia_push_ev(usb_hid_dev_t *hid_dev, int type,142 u nsigned int key)138 static void usb_multimedia_push_ev(usb_hid_dev_t *hid_dev, 139 usb_multimedia_t *multim_dev, int type, unsigned int key) 143 140 { 144 141 assert(hid_dev != NULL); 145 assert( hid_dev->data!= NULL);146 147 usb_multimedia_t *multim_dev = (usb_multimedia_t *)hid_dev->data;142 assert(multim_dev != NULL); 143 144 // usb_multimedia_t *multim_dev = (usb_multimedia_t *)hid_dev->data; 148 145 149 146 console_event_t ev; … … 190 187 /*----------------------------------------------------------------------------*/ 191 188 192 static int usb_multimedia_create_function(usb_hid_dev_t *hid_dev) 189 static int usb_multimedia_create_function(usb_hid_dev_t *hid_dev, 190 usb_multimedia_t *multim_dev) 193 191 { 194 192 /* Create the function exposed under /dev/devices. */ … … 200 198 } 201 199 202 /*203 * Store the initialized HID device and HID ops204 * to the DDF function.205 */206 200 fun->ops = &multimedia_ops; 207 fun->driver_data = hid_dev; // TODO: maybe change to hid_dev->data201 fun->driver_data = multim_dev; // TODO: maybe change to hid_dev->data 208 202 209 203 int rc = ddf_fun_bind(fun); … … 231 225 /*----------------------------------------------------------------------------*/ 232 226 233 int usb_multimedia_init(struct usb_hid_dev *hid_dev )227 int usb_multimedia_init(struct usb_hid_dev *hid_dev, void **data) 234 228 { 235 229 if (hid_dev == NULL || hid_dev->usb_dev == NULL) { … … 282 276 283 277 // save the KBD device structure into the HID device structure 284 hid_dev->data = multim_dev;278 *data = multim_dev; 285 279 286 280 usb_log_debug(NAME " HID/multimedia device structure initialized.\n"); 287 281 288 int rc = usb_multimedia_create_function(hid_dev );282 int rc = usb_multimedia_create_function(hid_dev, multim_dev); 289 283 if (rc != EOK) { 290 284 usb_multimedia_free(&multim_dev); … … 299 293 /*----------------------------------------------------------------------------*/ 300 294 301 void usb_multimedia_deinit(struct usb_hid_dev *hid_dev )295 void usb_multimedia_deinit(struct usb_hid_dev *hid_dev, void *data) 302 296 { 303 297 if (hid_dev == NULL) { … … 305 299 } 306 300 307 if (hid_dev->data != NULL) { 308 usb_multimedia_t *multim_dev = 309 (usb_multimedia_t *)hid_dev->data; 301 if (data != NULL) { 302 usb_multimedia_t *multim_dev = (usb_multimedia_t *)data; 310 303 usb_multimedia_free(&multim_dev); 311 hid_dev->data = NULL; 312 } 313 } 314 315 /*----------------------------------------------------------------------------*/ 316 317 bool usb_multimedia_polling_callback(struct usb_hid_dev *hid_dev, 304 } 305 } 306 307 /*----------------------------------------------------------------------------*/ 308 309 bool usb_multimedia_polling_callback(struct usb_hid_dev *hid_dev, void *data, 318 310 uint8_t *buffer, size_t buffer_size) 319 311 { … … 322 314 usb_log_debug(NAME " usb_lgtch_polling_callback(%p, %p, %zu)\n", 323 315 hid_dev, buffer, buffer_size); 316 317 if (data == NULL) { 318 return EINVAL; // TODO: other error code? 319 } 320 321 usb_multimedia_t *multim_dev = (usb_multimedia_t *)data; 324 322 325 323 usb_log_debug(NAME " Calling usb_hid_parse_report() with " … … 361 359 usb_multimedia_usage_to_str(field->usage); 362 360 usb_log_info("Pressed key: %s\n", key_str); 363 usb_multimedia_push_ev(hid_dev, KEY_PRESS, key); 361 usb_multimedia_push_ev(hid_dev, multim_dev, KEY_PRESS, 362 key); 364 363 } 365 364
Note:
See TracChangeset
for help on using the changeset viewer.