WIP FPC-III support
[linux/fpc-iii.git] / drivers / media / common / siano / smsendian.c
blob8cb8853a1edb6ac1cdb6646a03561243de3bbeeb
1 // SPDX-License-Identifier: GPL-2.0-or-later
2 /****************************************************************
4 Siano Mobile Silicon, Inc.
5 MDTV receiver kernel modules.
6 Copyright (C) 2006-2009, Uri Shkolnik
9 ****************************************************************/
11 #include <linux/export.h>
12 #include <asm/byteorder.h>
14 #include "smsendian.h"
15 #include "smscoreapi.h"
17 void smsendian_handle_tx_message(void *buffer)
19 #ifdef __BIG_ENDIAN
20 struct sms_msg_data *msg = (struct sms_msg_data *)buffer;
21 int i;
22 int msg_words;
24 switch (msg->x_msg_header.msg_type) {
25 case MSG_SMS_DATA_DOWNLOAD_REQ:
27 msg->msg_data[0] = le32_to_cpu((__force __le32)(msg->msg_data[0]));
28 break;
31 default:
32 msg_words = (msg->x_msg_header.msg_length -
33 sizeof(struct sms_msg_hdr))/4;
35 for (i = 0; i < msg_words; i++)
36 msg->msg_data[i] = le32_to_cpu((__force __le32)msg->msg_data[i]);
38 break;
40 #endif /* __BIG_ENDIAN */
42 EXPORT_SYMBOL_GPL(smsendian_handle_tx_message);
44 void smsendian_handle_rx_message(void *buffer)
46 #ifdef __BIG_ENDIAN
47 struct sms_msg_data *msg = (struct sms_msg_data *)buffer;
48 int i;
49 int msg_words;
51 switch (msg->x_msg_header.msg_type) {
52 case MSG_SMS_GET_VERSION_EX_RES:
54 struct sms_version_res *ver =
55 (struct sms_version_res *) msg;
56 ver->chip_model = le16_to_cpu((__force __le16)ver->chip_model);
57 break;
60 case MSG_SMS_DVBT_BDA_DATA:
61 case MSG_SMS_DAB_CHANNEL:
62 case MSG_SMS_DATA_MSG:
64 break;
67 default:
69 msg_words = (msg->x_msg_header.msg_length -
70 sizeof(struct sms_msg_hdr))/4;
72 for (i = 0; i < msg_words; i++)
73 msg->msg_data[i] = le32_to_cpu((__force __le32)msg->msg_data[i]);
75 break;
78 #endif /* __BIG_ENDIAN */
80 EXPORT_SYMBOL_GPL(smsendian_handle_rx_message);
82 void smsendian_handle_message_header(void *msg)
84 #ifdef __BIG_ENDIAN
85 struct sms_msg_hdr *phdr = (struct sms_msg_hdr *)msg;
87 phdr->msg_type = le16_to_cpu((__force __le16)phdr->msg_type);
88 phdr->msg_length = le16_to_cpu((__force __le16)phdr->msg_length);
89 phdr->msg_flags = le16_to_cpu((__force __le16)phdr->msg_flags);
90 #endif /* __BIG_ENDIAN */
92 EXPORT_SYMBOL_GPL(smsendian_handle_message_header);