smsendian.c 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102
  1. /****************************************************************
  2. Siano Mobile Silicon, Inc.
  3. MDTV receiver kernel modules.
  4. Copyright (C) 2006-2009, Uri Shkolnik
  5. This program is free software: you can redistribute it and/or modify
  6. it under the terms of the GNU General Public License as published by
  7. the Free Software Foundation, either version 2 of the License, or
  8. (at your option) any later version.
  9. This program is distributed in the hope that it will be useful,
  10. but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  12. GNU General Public License for more details.
  13. You should have received a copy of the GNU General Public License
  14. along with this program. If not, see <http://www.gnu.org/licenses/>.
  15. ****************************************************************/
  16. #include <asm/byteorder.h>
  17. #include "smsendian.h"
  18. #include "smscoreapi.h"
  19. void smsendian_handle_tx_message(void *buffer)
  20. {
  21. #ifdef __BIG_ENDIAN
  22. struct SmsMsgData_ST *msg = (struct SmsMsgData_ST *)buffer;
  23. int i;
  24. int msgWords;
  25. switch (msg->xMsgHeader.msgType) {
  26. case MSG_SMS_DATA_DOWNLOAD_REQ:
  27. {
  28. msg->msgData[0] = le32_to_cpu(msg->msgData[0]);
  29. break;
  30. }
  31. default:
  32. msgWords = (msg->xMsgHeader.msgLength -
  33. sizeof(struct SmsMsgHdr_ST))/4;
  34. for (i = 0; i < msgWords; i++)
  35. msg->msgData[i] = le32_to_cpu(msg->msgData[i]);
  36. break;
  37. }
  38. #endif /* __BIG_ENDIAN */
  39. }
  40. EXPORT_SYMBOL_GPL(smsendian_handle_tx_message);
  41. void smsendian_handle_rx_message(void *buffer)
  42. {
  43. #ifdef __BIG_ENDIAN
  44. struct SmsMsgData_ST *msg = (struct SmsMsgData_ST *)buffer;
  45. int i;
  46. int msgWords;
  47. switch (msg->xMsgHeader.msgType) {
  48. case MSG_SMS_GET_VERSION_EX_RES:
  49. {
  50. struct SmsVersionRes_ST *ver =
  51. (struct SmsVersionRes_ST *) msg;
  52. ver->ChipModel = le16_to_cpu(ver->ChipModel);
  53. break;
  54. }
  55. case MSG_SMS_DVBT_BDA_DATA:
  56. case MSG_SMS_DAB_CHANNEL:
  57. case MSG_SMS_DATA_MSG:
  58. {
  59. break;
  60. }
  61. default:
  62. {
  63. msgWords = (msg->xMsgHeader.msgLength -
  64. sizeof(struct SmsMsgHdr_ST))/4;
  65. for (i = 0; i < msgWords; i++)
  66. msg->msgData[i] = le32_to_cpu(msg->msgData[i]);
  67. break;
  68. }
  69. }
  70. #endif /* __BIG_ENDIAN */
  71. }
  72. EXPORT_SYMBOL_GPL(smsendian_handle_rx_message);
  73. void smsendian_handle_message_header(void *msg)
  74. {
  75. #ifdef __BIG_ENDIAN
  76. struct SmsMsgHdr_ST *phdr = (struct SmsMsgHdr_ST *)msg;
  77. phdr->msgType = le16_to_cpu(phdr->msgType);
  78. phdr->msgLength = le16_to_cpu(phdr->msgLength);
  79. phdr->msgFlags = le16_to_cpu(phdr->msgFlags);
  80. #endif /* __BIG_ENDIAN */
  81. }
  82. EXPORT_SYMBOL_GPL(smsendian_handle_message_header);