diff options
Diffstat (limited to 'drivers/media/dvb/siano/smscoreapi.c')
-rw-r--r-- | drivers/media/dvb/siano/smscoreapi.c | 123 |
1 files changed, 85 insertions, 38 deletions
diff --git a/drivers/media/dvb/siano/smscoreapi.c b/drivers/media/dvb/siano/smscoreapi.c index e8267178c52c..084ddc39c989 100644 --- a/drivers/media/dvb/siano/smscoreapi.c +++ b/drivers/media/dvb/siano/smscoreapi.c | |||
@@ -309,7 +309,8 @@ int smscore_notify_callbacks(smscore_device_t *coredev, struct device *device, | |||
309 | first = &g_smscore_notifyees; | 309 | first = &g_smscore_notifyees; |
310 | 310 | ||
311 | for (next = first->next; next != first; next = next->next) { | 311 | for (next = first->next; next != first; next = next->next) { |
312 | rc = ((smscore_device_notifyee_t *) next)->hotplug(coredev, device, arrival); | 312 | rc = ((smscore_device_notifyee_t *) next)-> |
313 | hotplug(coredev, device, arrival); | ||
313 | if (rc < 0) | 314 | if (rc < 0) |
314 | break; | 315 | break; |
315 | } | 316 | } |
@@ -337,7 +338,8 @@ smscore_buffer_t *smscore_createbuffer(u8 *buffer, void *common_buffer, | |||
337 | * creates coredev object for a device, prepares buffers, | 338 | * creates coredev object for a device, prepares buffers, |
338 | * creates buffer mappings, notifies registered hotplugs about new device. | 339 | * creates buffer mappings, notifies registered hotplugs about new device. |
339 | * | 340 | * |
340 | * @param params device pointer to struct with device specific parameters and handlers | 341 | * @param params device pointer to struct with device specific parameters |
342 | * and handlers | ||
341 | * @param coredev pointer to a value that receives created coredev object | 343 | * @param coredev pointer to a value that receives created coredev object |
342 | * | 344 | * |
343 | * @return 0 on success, <0 on error. | 345 | * @return 0 on success, <0 on error. |
@@ -387,7 +389,9 @@ int smscore_register_device(smsdevice_params_t *params, | |||
387 | for (buffer = dev->common_buffer; | 389 | for (buffer = dev->common_buffer; |
388 | dev->num_buffers < params->num_buffers; | 390 | dev->num_buffers < params->num_buffers; |
389 | dev->num_buffers++, buffer += params->buffer_size) { | 391 | dev->num_buffers++, buffer += params->buffer_size) { |
390 | smscore_buffer_t *cb = smscore_createbuffer(buffer, dev->common_buffer, dev->common_buffer_phys); | 392 | smscore_buffer_t *cb = |
393 | smscore_createbuffer(buffer, dev->common_buffer, | ||
394 | dev->common_buffer_phys); | ||
391 | if (!cb) { | 395 | if (!cb) { |
392 | smscore_unregister_device(dev); | 396 | smscore_unregister_device(dev); |
393 | return -ENOMEM; | 397 | return -ENOMEM; |
@@ -428,15 +432,18 @@ int smscore_register_device(smsdevice_params_t *params, | |||
428 | /** | 432 | /** |
429 | * sets initial device mode and notifies client hotplugs that device is ready | 433 | * sets initial device mode and notifies client hotplugs that device is ready |
430 | * | 434 | * |
431 | * @param coredev pointer to a coredev object returned by smscore_register_device | 435 | * @param coredev pointer to a coredev object returned by |
436 | * smscore_register_device | ||
432 | * | 437 | * |
433 | * @return 0 on success, <0 on error. | 438 | * @return 0 on success, <0 on error. |
434 | */ | 439 | */ |
435 | int smscore_start_device(smscore_device_t *coredev) | 440 | int smscore_start_device(smscore_device_t *coredev) |
436 | { | 441 | { |
437 | int rc = smscore_set_device_mode(coredev, smscore_registry_getmode(coredev->devpath)); | 442 | int rc = smscore_set_device_mode( |
443 | coredev, smscore_registry_getmode(coredev->devpath)); | ||
438 | if (rc < 0) { | 444 | if (rc < 0) { |
439 | printk(KERN_INFO "%s set device mode faile , rc %d\n", __func__, rc); | 445 | printk(KERN_INFO "%s set device mode faile , rc %d\n", |
446 | __func__, rc); | ||
440 | return rc; | 447 | return rc; |
441 | } | 448 | } |
442 | 449 | ||
@@ -512,9 +519,14 @@ int smscore_load_firmware_family2(smscore_device_t *coredev, void *buffer, | |||
512 | 519 | ||
513 | if ((coredev->device_flags & SMS_ROM_NO_RESPONSE) && | 520 | if ((coredev->device_flags & SMS_ROM_NO_RESPONSE) && |
514 | (coredev->mode == DEVICE_MODE_NONE)) | 521 | (coredev->mode == DEVICE_MODE_NONE)) |
515 | rc = coredev->sendrequest_handler(coredev->context, DataMsg, DataMsg->xMsgHeader.msgLength); | 522 | rc = coredev->sendrequest_handler( |
523 | coredev->context, DataMsg, | ||
524 | DataMsg->xMsgHeader.msgLength); | ||
516 | else | 525 | else |
517 | rc = smscore_sendrequest_and_wait(coredev, DataMsg, DataMsg->xMsgHeader.msgLength, &coredev->data_download_done); | 526 | rc = smscore_sendrequest_and_wait( |
527 | coredev, DataMsg, | ||
528 | DataMsg->xMsgHeader.msgLength, | ||
529 | &coredev->data_download_done); | ||
518 | 530 | ||
519 | payload += payload_size; | 531 | payload += payload_size; |
520 | size -= payload_size; | 532 | size -= payload_size; |
@@ -529,17 +541,23 @@ int smscore_load_firmware_family2(smscore_device_t *coredev, void *buffer, | |||
529 | sizeof(SmsMsgHdr_ST) + | 541 | sizeof(SmsMsgHdr_ST) + |
530 | sizeof(u32) * 5); | 542 | sizeof(u32) * 5); |
531 | 543 | ||
532 | TriggerMsg->msgData[0] = firmware->StartAddress; /* Entry point */ | 544 | TriggerMsg->msgData[0] = firmware->StartAddress; |
545 | /* Entry point */ | ||
533 | TriggerMsg->msgData[1] = 5; /* Priority */ | 546 | TriggerMsg->msgData[1] = 5; /* Priority */ |
534 | TriggerMsg->msgData[2] = 0x200; /* Stack size */ | 547 | TriggerMsg->msgData[2] = 0x200; /* Stack size */ |
535 | TriggerMsg->msgData[3] = 0; /* Parameter */ | 548 | TriggerMsg->msgData[3] = 0; /* Parameter */ |
536 | TriggerMsg->msgData[4] = 4; /* Task ID */ | 549 | TriggerMsg->msgData[4] = 4; /* Task ID */ |
537 | 550 | ||
538 | if (coredev->device_flags & SMS_ROM_NO_RESPONSE) { | 551 | if (coredev->device_flags & SMS_ROM_NO_RESPONSE) { |
539 | rc = coredev->sendrequest_handler(coredev->context, TriggerMsg, TriggerMsg->xMsgHeader.msgLength); | 552 | rc = coredev->sendrequest_handler( |
553 | coredev->context, TriggerMsg, | ||
554 | TriggerMsg->xMsgHeader.msgLength); | ||
540 | msleep(100); | 555 | msleep(100); |
541 | } else | 556 | } else |
542 | rc = smscore_sendrequest_and_wait(coredev, TriggerMsg, TriggerMsg->xMsgHeader.msgLength, &coredev->trigger_done); | 557 | rc = smscore_sendrequest_and_wait( |
558 | coredev, TriggerMsg, | ||
559 | TriggerMsg->xMsgHeader.msgLength, | ||
560 | &coredev->trigger_done); | ||
543 | } else { | 561 | } else { |
544 | SMS_INIT_MSG(msg, MSG_SW_RELOAD_EXEC_REQ, | 562 | SMS_INIT_MSG(msg, MSG_SW_RELOAD_EXEC_REQ, |
545 | sizeof(SmsMsgHdr_ST)); | 563 | sizeof(SmsMsgHdr_ST)); |
@@ -563,7 +581,8 @@ int smscore_load_firmware_family2(smscore_device_t *coredev, void *buffer, | |||
563 | /** | 581 | /** |
564 | * loads specified firmware into a buffer and calls device loadfirmware_handler | 582 | * loads specified firmware into a buffer and calls device loadfirmware_handler |
565 | * | 583 | * |
566 | * @param coredev pointer to a coredev object returned by smscore_register_device | 584 | * @param coredev pointer to a coredev object returned by |
585 | * smscore_register_device | ||
567 | * @param filename null-terminated string specifies firmware file name | 586 | * @param filename null-terminated string specifies firmware file name |
568 | * @param loadfirmware_handler device handler that loads firmware | 587 | * @param loadfirmware_handler device handler that loads firmware |
569 | * | 588 | * |
@@ -595,8 +614,11 @@ int smscore_load_firmware_from_file(smscore_device_t *coredev, char *filename, | |||
595 | memcpy(fw_buffer, fw->data, fw->size); | 614 | memcpy(fw_buffer, fw->data, fw->size); |
596 | 615 | ||
597 | rc = (coredev->device_flags & SMS_DEVICE_FAMILY2) ? | 616 | rc = (coredev->device_flags & SMS_DEVICE_FAMILY2) ? |
598 | smscore_load_firmware_family2(coredev, fw_buffer, fw->size) : | 617 | smscore_load_firmware_family2(coredev, |
599 | loadfirmware_handler(coredev->context, fw_buffer, fw->size); | 618 | fw_buffer, |
619 | fw->size) : | ||
620 | loadfirmware_handler(coredev->context, | ||
621 | fw_buffer, fw->size); | ||
600 | 622 | ||
601 | kfree(fw_buffer); | 623 | kfree(fw_buffer); |
602 | } else { | 624 | } else { |
@@ -618,9 +640,11 @@ int smscore_load_firmware_from_buffer(smscore_device_t *coredev, u8 *buffer, | |||
618 | } | 640 | } |
619 | 641 | ||
620 | /** | 642 | /** |
621 | * notifies all clients registered with the device, notifies hotplugs, frees all buffers and coredev object | 643 | * notifies all clients registered with the device, notifies hotplugs, |
644 | * frees all buffers and coredev object | ||
622 | * | 645 | * |
623 | * @param coredev pointer to a coredev object returned by smscore_register_device | 646 | * @param coredev pointer to a coredev object returned by |
647 | * smscore_register_device | ||
624 | * | 648 | * |
625 | * @return 0 on success, <0 on error. | 649 | * @return 0 on success, <0 on error. |
626 | */ | 650 | */ |
@@ -686,13 +710,17 @@ int smscore_detect_mode(smscore_device_t *coredev) | |||
686 | rc = smscore_sendrequest_and_wait(coredev, msg, msg->msgLength, | 710 | rc = smscore_sendrequest_and_wait(coredev, msg, msg->msgLength, |
687 | &coredev->version_ex_done); | 711 | &coredev->version_ex_done); |
688 | if (rc == -ETIME) { | 712 | if (rc == -ETIME) { |
689 | printk("%s: MSG_SMS_GET_VERSION_EX_REQ failed first try\n", __func__); | 713 | printk("%s: MSG_SMS_GET_VERSION_EX_REQ failed first try\n", |
714 | __func__); | ||
690 | 715 | ||
691 | if (wait_for_completion_timeout(&coredev->resume_done, | 716 | if (wait_for_completion_timeout(&coredev->resume_done, |
692 | msecs_to_jiffies(5000))) { | 717 | msecs_to_jiffies(5000))) { |
693 | rc = smscore_sendrequest_and_wait(coredev, msg, msg->msgLength, &coredev->version_ex_done); | 718 | rc = smscore_sendrequest_and_wait( |
719 | coredev, msg, msg->msgLength, | ||
720 | &coredev->version_ex_done); | ||
694 | if (rc < 0) | 721 | if (rc < 0) |
695 | printk("%s: MSG_SMS_GET_VERSION_EX_REQ failed second try, rc %d\n", __func__, rc); | 722 | printk("%s: MSG_SMS_GET_VERSION_EX_REQ failed " |
723 | "second try, rc %d\n", __func__, rc); | ||
696 | } else | 724 | } else |
697 | rc = -ETIME; | 725 | rc = -ETIME; |
698 | } | 726 | } |
@@ -719,7 +747,8 @@ char *smscore_fw_lkup[][SMS_NUM_OF_DEVICE_TYPES] = { | |||
719 | * calls device handler to change mode of operation | 747 | * calls device handler to change mode of operation |
720 | * NOTE: stellar/usb may disconnect when changing mode | 748 | * NOTE: stellar/usb may disconnect when changing mode |
721 | * | 749 | * |
722 | * @param coredev pointer to a coredev object returned by smscore_register_device | 750 | * @param coredev pointer to a coredev object returned by |
751 | * smscore_register_device | ||
723 | * @param mode requested mode of operation | 752 | * @param mode requested mode of operation |
724 | * | 753 | * |
725 | * @return 0 on success, <0 on error. | 754 | * @return 0 on success, <0 on error. |
@@ -757,27 +786,35 @@ int smscore_set_device_mode(smscore_device_t *coredev, int mode) | |||
757 | 786 | ||
758 | if (!(coredev->modes_supported & (1 << mode))) { | 787 | if (!(coredev->modes_supported & (1 << mode))) { |
759 | type = smscore_registry_gettype(coredev->devpath); | 788 | type = smscore_registry_gettype(coredev->devpath); |
760 | rc = smscore_load_firmware_from_file(coredev, smscore_fw_lkup[mode][type], NULL); | 789 | rc = smscore_load_firmware_from_file( |
790 | coredev, smscore_fw_lkup[mode][type], NULL); | ||
761 | if (rc < 0) { | 791 | if (rc < 0) { |
762 | printk(KERN_INFO "%s load firmware failed %d\n", __func__, rc); | 792 | printk(KERN_INFO "%s load firmware " |
793 | "failed %d\n", __func__, rc); | ||
763 | return rc; | 794 | return rc; |
764 | } | 795 | } |
765 | } else | 796 | } else |
766 | printk(KERN_INFO "%s mode %d supported by running firmware\n", __func__, mode); | 797 | printk(KERN_INFO "%s mode %d supported by running " |
798 | "firmware\n", __func__, mode); | ||
767 | 799 | ||
768 | buffer = kmalloc(sizeof(SmsMsgData_ST) + SMS_DMA_ALIGNMENT, | 800 | buffer = kmalloc(sizeof(SmsMsgData_ST) + SMS_DMA_ALIGNMENT, |
769 | GFP_KERNEL | GFP_DMA); | 801 | GFP_KERNEL | GFP_DMA); |
770 | if (buffer) { | 802 | if (buffer) { |
771 | SmsMsgData_ST *msg = (SmsMsgData_ST *) SMS_ALIGN_ADDRESS(buffer); | 803 | SmsMsgData_ST *msg = |
804 | (SmsMsgData_ST *) SMS_ALIGN_ADDRESS(buffer); | ||
772 | 805 | ||
773 | SMS_INIT_MSG(&msg->xMsgHeader, MSG_SMS_INIT_DEVICE_REQ, sizeof(SmsMsgData_ST)); | 806 | SMS_INIT_MSG(&msg->xMsgHeader, MSG_SMS_INIT_DEVICE_REQ, |
807 | sizeof(SmsMsgData_ST)); | ||
774 | msg->msgData[0] = mode; | 808 | msg->msgData[0] = mode; |
775 | 809 | ||
776 | rc = smscore_sendrequest_and_wait(coredev, msg, msg->xMsgHeader.msgLength, &coredev->init_device_done); | 810 | rc = smscore_sendrequest_and_wait( |
811 | coredev, msg, msg->xMsgHeader.msgLength, | ||
812 | &coredev->init_device_done); | ||
777 | 813 | ||
778 | kfree(buffer); | 814 | kfree(buffer); |
779 | } else { | 815 | } else { |
780 | printk(KERN_INFO "%s Could not allocate buffer for init device message.\n", __func__); | 816 | printk(KERN_INFO "%s Could not allocate buffer for " |
817 | "init device message.\n", __func__); | ||
781 | rc = -ENOMEM; | 818 | rc = -ENOMEM; |
782 | } | 819 | } |
783 | } else { | 820 | } else { |
@@ -810,7 +847,8 @@ int smscore_set_device_mode(smscore_device_t *coredev, int mode) | |||
810 | /** | 847 | /** |
811 | * calls device handler to get current mode of operation | 848 | * calls device handler to get current mode of operation |
812 | * | 849 | * |
813 | * @param coredev pointer to a coredev object returned by smscore_register_device | 850 | * @param coredev pointer to a coredev object returned by |
851 | * smscore_register_device | ||
814 | * | 852 | * |
815 | * @return current mode | 853 | * @return current mode |
816 | */ | 854 | */ |
@@ -823,12 +861,14 @@ int smscore_get_device_mode(smscore_device_t *coredev) | |||
823 | * find client by response id & type within the clients list. | 861 | * find client by response id & type within the clients list. |
824 | * return client handle or NULL. | 862 | * return client handle or NULL. |
825 | * | 863 | * |
826 | * @param coredev pointer to a coredev object returned by smscore_register_device | 864 | * @param coredev pointer to a coredev object returned by |
865 | * smscore_register_device | ||
827 | * @param data_type client data type (SMS_DONT_CARE for all types) | 866 | * @param data_type client data type (SMS_DONT_CARE for all types) |
828 | * @param id client id (SMS_DONT_CARE for all id) | 867 | * @param id client id (SMS_DONT_CARE for all id) |
829 | * | 868 | * |
830 | */ | 869 | */ |
831 | smscore_client_t *smscore_find_client(smscore_device_t *coredev, int data_type, int id) | 870 | smscore_client_t *smscore_find_client(smscore_device_t *coredev, |
871 | int data_type, int id) | ||
832 | { | 872 | { |
833 | smscore_client_t *client = NULL; | 873 | smscore_client_t *client = NULL; |
834 | struct list_head *next, *first; | 874 | struct list_head *next, *first; |
@@ -861,15 +901,16 @@ smscore_client_t *smscore_find_client(smscore_device_t *coredev, int data_type, | |||
861 | * find client by response id/type, call clients onresponse handler | 901 | * find client by response id/type, call clients onresponse handler |
862 | * return buffer to pool on error | 902 | * return buffer to pool on error |
863 | * | 903 | * |
864 | * @param coredev pointer to a coredev object returned by smscore_register_device | 904 | * @param coredev pointer to a coredev object returned by |
905 | * smscore_register_device | ||
865 | * @param cb pointer to response buffer descriptor | 906 | * @param cb pointer to response buffer descriptor |
866 | * | 907 | * |
867 | */ | 908 | */ |
868 | void smscore_onresponse(smscore_device_t *coredev, smscore_buffer_t *cb) | 909 | void smscore_onresponse(smscore_device_t *coredev, smscore_buffer_t *cb) |
869 | { | 910 | { |
870 | SmsMsgHdr_ST *phdr = (SmsMsgHdr_ST *)((u8 *) cb->p + cb->offset); | 911 | SmsMsgHdr_ST *phdr = (SmsMsgHdr_ST *)((u8 *) cb->p + cb->offset); |
871 | smscore_client_t *client = smscore_find_client(coredev, phdr->msgType, | 912 | smscore_client_t *client = |
872 | phdr->msgDstId); | 913 | smscore_find_client(coredev, phdr->msgType, phdr->msgDstId); |
873 | int rc = -EBUSY; | 914 | int rc = -EBUSY; |
874 | 915 | ||
875 | static unsigned long last_sample_time = 0; | 916 | static unsigned long last_sample_time = 0; |
@@ -943,7 +984,8 @@ void smscore_onresponse(smscore_device_t *coredev, smscore_buffer_t *cb) | |||
943 | /** | 984 | /** |
944 | * return pointer to next free buffer descriptor from core pool | 985 | * return pointer to next free buffer descriptor from core pool |
945 | * | 986 | * |
946 | * @param coredev pointer to a coredev object returned by smscore_register_device | 987 | * @param coredev pointer to a coredev object returned by |
988 | * smscore_register_device | ||
947 | * | 989 | * |
948 | * @return pointer to descriptor on success, NULL on error. | 990 | * @return pointer to descriptor on success, NULL on error. |
949 | */ | 991 | */ |
@@ -967,7 +1009,8 @@ smscore_buffer_t *smscore_getbuffer(smscore_device_t *coredev) | |||
967 | /** | 1009 | /** |
968 | * return buffer descriptor to a pool | 1010 | * return buffer descriptor to a pool |
969 | * | 1011 | * |
970 | * @param coredev pointer to a coredev object returned by smscore_register_device | 1012 | * @param coredev pointer to a coredev object returned by |
1013 | * smscore_register_device | ||
971 | * @param cb pointer buffer descriptor | 1014 | * @param cb pointer buffer descriptor |
972 | * | 1015 | * |
973 | */ | 1016 | */ |
@@ -1019,7 +1062,9 @@ int smscore_validate_client(smscore_device_t *coredev, | |||
1019 | * | 1062 | * |
1020 | * @return 0 on success, <0 on error. | 1063 | * @return 0 on success, <0 on error. |
1021 | */ | 1064 | */ |
1022 | int smscore_register_client(smscore_device_t *coredev, smsclient_params_t *params, smscore_client_t **client) | 1065 | int smscore_register_client(smscore_device_t *coredev, |
1066 | smsclient_params_t *params, | ||
1067 | smscore_client_t **client) | ||
1023 | { | 1068 | { |
1024 | smscore_client_t *newclient; | 1069 | smscore_client_t *newclient; |
1025 | /* check that no other channel with same parameters exists */ | 1070 | /* check that no other channel with same parameters exists */ |
@@ -1054,7 +1099,8 @@ int smscore_register_client(smscore_device_t *coredev, smsclient_params_t *param | |||
1054 | /** | 1099 | /** |
1055 | * frees smsclient object and all subclients associated with it | 1100 | * frees smsclient object and all subclients associated with it |
1056 | * | 1101 | * |
1057 | * @param client pointer to smsclient object returned by smscore_register_client | 1102 | * @param client pointer to smsclient object returned by |
1103 | * smscore_register_client | ||
1058 | * | 1104 | * |
1059 | */ | 1105 | */ |
1060 | void smscore_unregister_client(smscore_client_t *client) | 1106 | void smscore_unregister_client(smscore_client_t *client) |
@@ -1084,7 +1130,8 @@ void smscore_unregister_client(smscore_client_t *client) | |||
1084 | * verifies that source id is not taken by another client, | 1130 | * verifies that source id is not taken by another client, |
1085 | * calls device handler to send requests to the device | 1131 | * calls device handler to send requests to the device |
1086 | * | 1132 | * |
1087 | * @param client pointer to smsclient object returned by smscore_register_client | 1133 | * @param client pointer to smsclient object returned by |
1134 | * smscore_register_client | ||
1088 | * @param buffer pointer to a request buffer | 1135 | * @param buffer pointer to a request buffer |
1089 | * @param size size (in bytes) of request buffer | 1136 | * @param size size (in bytes) of request buffer |
1090 | * | 1137 | * |