^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1) // SPDX-License-Identifier: GPL-2.0-or-later
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2) /****************************************************************
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4) Siano Mobile Silicon, Inc.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5) MDTV receiver kernel modules.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6) Copyright (C) 2006-2009, Uri Shkolnik
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9) ****************************************************************/
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 11) #include <linux/export.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 12) #include <asm/byteorder.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 13)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 14) #include "smsendian.h"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 15) #include "smscoreapi.h"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 16)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 17) void smsendian_handle_tx_message(void *buffer)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 18) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 19) #ifdef __BIG_ENDIAN
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 20) struct sms_msg_data *msg = (struct sms_msg_data *)buffer;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 21) int i;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 22) int msg_words;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 23)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 24) switch (msg->x_msg_header.msg_type) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 25) case MSG_SMS_DATA_DOWNLOAD_REQ:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 26) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 27) msg->msg_data[0] = le32_to_cpu((__force __le32)(msg->msg_data[0]));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 28) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 29) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 30)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 31) default:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 32) msg_words = (msg->x_msg_header.msg_length -
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 33) sizeof(struct sms_msg_hdr))/4;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 34)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 35) for (i = 0; i < msg_words; i++)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 36) msg->msg_data[i] = le32_to_cpu((__force __le32)msg->msg_data[i]);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 37)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 38) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 39) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 40) #endif /* __BIG_ENDIAN */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 41) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 42) EXPORT_SYMBOL_GPL(smsendian_handle_tx_message);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 43)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 44) void smsendian_handle_rx_message(void *buffer)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 45) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 46) #ifdef __BIG_ENDIAN
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 47) struct sms_msg_data *msg = (struct sms_msg_data *)buffer;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 48) int i;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 49) int msg_words;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 50)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 51) switch (msg->x_msg_header.msg_type) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 52) case MSG_SMS_GET_VERSION_EX_RES:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 53) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 54) struct sms_version_res *ver =
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 55) (struct sms_version_res *) msg;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 56) ver->chip_model = le16_to_cpu((__force __le16)ver->chip_model);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 57) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 58) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 59)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 60) case MSG_SMS_DVBT_BDA_DATA:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 61) case MSG_SMS_DAB_CHANNEL:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 62) case MSG_SMS_DATA_MSG:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 63) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 64) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 65) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 66)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 67) default:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 68) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 69) msg_words = (msg->x_msg_header.msg_length -
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 70) sizeof(struct sms_msg_hdr))/4;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 71)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 72) for (i = 0; i < msg_words; i++)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 73) msg->msg_data[i] = le32_to_cpu((__force __le32)msg->msg_data[i]);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 74)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 75) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 76) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 77) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 78) #endif /* __BIG_ENDIAN */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 79) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 80) EXPORT_SYMBOL_GPL(smsendian_handle_rx_message);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 81)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 82) void smsendian_handle_message_header(void *msg)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 83) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 84) #ifdef __BIG_ENDIAN
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 85) struct sms_msg_hdr *phdr = (struct sms_msg_hdr *)msg;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 86)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 87) phdr->msg_type = le16_to_cpu((__force __le16)phdr->msg_type);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 88) phdr->msg_length = le16_to_cpu((__force __le16)phdr->msg_length);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 89) phdr->msg_flags = le16_to_cpu((__force __le16)phdr->msg_flags);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 90) #endif /* __BIG_ENDIAN */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 91) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 92) EXPORT_SYMBOL_GPL(smsendian_handle_message_header);