blob: 32a7b28bd324cc00c2f41af19401ccbd413b6be2 [file] [log] [blame]
Uri Shkolnikcb17f902009-04-20 13:00:52 -03001/****************************************************************
2
3 Siano Mobile Silicon, Inc.
4 MDTV receiver kernel modules.
5 Copyright (C) 2006-2009, Uri Shkolnik
6
7 This program is free software: you can redistribute it and/or modify
8 it under the terms of the GNU General Public License as published by
9 the Free Software Foundation, either version 2 of the License, or
10 (at your option) any later version.
11
12 This program is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 GNU General Public License for more details.
16
17 You should have received a copy of the GNU General Public License
18 along with this program. If not, see <http://www.gnu.org/licenses/>.
19
20 ****************************************************************/
21
Paul Gortmaker35a24632011-08-01 15:26:38 -040022#include <linux/export.h>
Uri Shkolnikcb17f902009-04-20 13:00:52 -030023#include <asm/byteorder.h>
24
25#include "smsendian.h"
26#include "smscoreapi.h"
27
28void smsendian_handle_tx_message(void *buffer)
29{
30#ifdef __BIG_ENDIAN
Mauro Carvalho Chehabdfef84f2013-03-21 08:49:43 -030031 struct sms_msg_data *msg = (struct sms_msg_data *)buffer;
Uri Shkolnikcb17f902009-04-20 13:00:52 -030032 int i;
33 int msgWords;
34
Mauro Carvalho Chehabdfef84f2013-03-21 08:49:43 -030035 switch (msg->x_msg_header.msg_type) {
Uri Shkolnikcb17f902009-04-20 13:00:52 -030036 case MSG_SMS_DATA_DOWNLOAD_REQ:
37 {
38 msg->msgData[0] = le32_to_cpu(msg->msgData[0]);
39 break;
40 }
41
42 default:
Mauro Carvalho Chehabdfef84f2013-03-21 08:49:43 -030043 msgWords = (msg->x_msg_header.msg_length -
44 sizeof(struct sms_msg_hdr))/4;
Uri Shkolnikcb17f902009-04-20 13:00:52 -030045
46 for (i = 0; i < msgWords; i++)
47 msg->msgData[i] = le32_to_cpu(msg->msgData[i]);
48
49 break;
50 }
51#endif /* __BIG_ENDIAN */
52}
Mauro Carvalho Chehab2c5582e2009-05-14 09:35:26 -030053EXPORT_SYMBOL_GPL(smsendian_handle_tx_message);
Uri Shkolnikcb17f902009-04-20 13:00:52 -030054
55void smsendian_handle_rx_message(void *buffer)
56{
57#ifdef __BIG_ENDIAN
Mauro Carvalho Chehabdfef84f2013-03-21 08:49:43 -030058 struct sms_msg_data *msg = (struct sms_msg_data *)buffer;
Uri Shkolnikcb17f902009-04-20 13:00:52 -030059 int i;
60 int msgWords;
61
Mauro Carvalho Chehabdfef84f2013-03-21 08:49:43 -030062 switch (msg->x_msg_header.msg_type) {
Uri Shkolnikcb17f902009-04-20 13:00:52 -030063 case MSG_SMS_GET_VERSION_EX_RES:
64 {
Mauro Carvalho Chehabdfef84f2013-03-21 08:49:43 -030065 struct sms_version_res *ver =
66 (struct sms_version_res *) msg;
67 ver->chip_model = le16_to_cpu(ver->chip_model);
Uri Shkolnikcb17f902009-04-20 13:00:52 -030068 break;
69 }
70
71 case MSG_SMS_DVBT_BDA_DATA:
72 case MSG_SMS_DAB_CHANNEL:
73 case MSG_SMS_DATA_MSG:
74 {
75 break;
76 }
77
78 default:
79 {
Mauro Carvalho Chehabdfef84f2013-03-21 08:49:43 -030080 msgWords = (msg->x_msg_header.msg_length -
81 sizeof(struct sms_msg_hdr))/4;
Uri Shkolnikcb17f902009-04-20 13:00:52 -030082
83 for (i = 0; i < msgWords; i++)
84 msg->msgData[i] = le32_to_cpu(msg->msgData[i]);
85
86 break;
87 }
88 }
89#endif /* __BIG_ENDIAN */
90}
Mauro Carvalho Chehab2c5582e2009-05-14 09:35:26 -030091EXPORT_SYMBOL_GPL(smsendian_handle_rx_message);
Uri Shkolnikcb17f902009-04-20 13:00:52 -030092
93void smsendian_handle_message_header(void *msg)
94{
95#ifdef __BIG_ENDIAN
Mauro Carvalho Chehabdfef84f2013-03-21 08:49:43 -030096 struct sms_msg_hdr *phdr = (struct sms_msg_hdr *)msg;
Uri Shkolnikcb17f902009-04-20 13:00:52 -030097
Mauro Carvalho Chehabdfef84f2013-03-21 08:49:43 -030098 phdr->msg_type = le16_to_cpu(phdr->msg_type);
99 phdr->msg_length = le16_to_cpu(phdr->msg_length);
100 phdr->msg_flags = le16_to_cpu(phdr->msg_flags);
Uri Shkolnikcb17f902009-04-20 13:00:52 -0300101#endif /* __BIG_ENDIAN */
102}
Mauro Carvalho Chehab2c5582e2009-05-14 09:35:26 -0300103EXPORT_SYMBOL_GPL(smsendian_handle_message_header);