Skip to contentSkip to conversation

Add sms2270 support to siano driver

PATCH New Mauro Carvalho Chehab 1 participant 47 messages Mar 19, 2013

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

cover Add sms2270 support to siano driver

Back in September, 2011, Doron Cohen <[email protected]> submitted a series of patches meant to add support for newer siano chipsets.

That series of patches had several pointed issues:
- It were just a diff from Siano's internal git tree and upstreamed one. Due to that, applying it would cause regressions;

- Among the regressions, the newer code would break rc_core support, causing regressions for IR;

- It also breaks support for Hauppauge devices with old firmware (version 2.1);

- It added support for a Siano proprietary API.

On that time, I waited for Doron to submit a newer patch series. Unfortunately, this never happened.

As I received a sms2270 device, I decided to take some time to understand the changes proposed by Dohen, port the ones that are pertinent to upstream, and make it to work. I also took care to fix it for older devices.

I also did a few clean ups on some bad things on it, and added an experimental debugfs support, to allow displaying the complete data inside the device's statistics reports. That helped to port it to use the new DVBv5 stats.

There are still plenty of space to clean it up, like removing the CamelCase and cleaning its structures. I won't doubt that there are lots of unused stuff there at the core.

Anyway, with this patchset, both Hauppauge model 55009 Rev B1F7-02D and an unbranded Siano Rio (187f:0600) device are working fine on a x86, via USB interface. I didn't test it with arm or with a big endian system.

As nobody is currently maintaining this driver, I'm also adding a MAINTAINERS entry on this series, with "Odd fixes".

Mauro Carvalho Chehab (46):
[media] siano: Change GPIO voltage setting names
[media] siano: Add the new voltage definitions for GPIO [media] siano: remove a duplicated structure definition [media] siano: update message macros
[media] siano: better debug send/receive messages
[media] siano: add the remaining new defines from new driver [media] siano: Properly initialize board information [media] siano: add additional attributes to cards entries [media] siano: use USB endpoint descriptors for in/out endp [media] siano: store firmware version
[media] siano: make load firmware logic to work with newer firmwares [media] siano: report the choosed firmware in debug [media] siano: fix the debug message
[media] siano: always load smsdvb
[media] siano: cleanups at smscoreapi.c
[media] siano: add some new messages to the smscoreapi [media] siano: use a separate completion for stats [media] siano: add support for ISDB-T full-seg
[media] siano: add support for LNA on ISDB-T
[media] siano: use the newer stats message for recent firmwares [media] siano: add new devices to the Siano Driver [media] siano: Configure board's mtu and xtal
[media] siano: call MSG_SMS_INIT_DEVICE_REQ
[media] siano: simplify message endianness logic
[media] siano: split get_frontend into per-std functions [media] siano: split debug logic from the status update routine [media] siano: Convert it to report DVBv5 stats
[media] siano: fix start of statistics
[media] siano: allow showing the complete statistics via debugfs [media] siano: split debugfs code into a separate file [media] siano: add two missing fields to ISDB-T stats debugfs [media] siano: don't request statistics too fast
[media] siano: fix signal strength and CNR stats measurements [media] siano: fix PER/BER report on DVBv5
[media] siano: Fix bandwidth report
[media] siano: Only feed DVB data when there's a feed [media] siano: fix status report with old firmware and ISDB-T [media] siano: add support for .poll on debugfs
[media] siano: simplify firmware lookup logic
[media] siano: honour per-card default mode
[media] siano: remove the bogus firmware lookup code [media] siano: reorder smscore_get_fw_filename() function [media] siano: add a MAINTAINERS entry for it
[media] siano: remove a bogus printk line
[media] siano: remove doubled new line
[media] siano: Remove bogus complain about MSG_SMS_DVBT_BDA_DATA

 MAINTAINERS                                 |   11 +
 drivers/media/common/siano/Kconfig          |   12 +
 drivers/media/common/siano/Makefile         |    5 +
 drivers/media/common/siano/sms-cards.c      |   99 ++-
 drivers/media/common/siano/sms-cards.h      |   14 +
 drivers/media/common/siano/smscoreapi.c     |  918 +++++++++++++++-----
 drivers/media/common/siano/smscoreapi.h     |  607 ++++++++++---
 drivers/media/common/siano/smsdvb-debugfs.c |  554 ++++++++++++
 drivers/media/common/siano/smsdvb-main.c    | 1226 +++++++++++++++++++++++++++
 drivers/media/common/siano/smsdvb.c         | 1078 -----------------------
 drivers/media/common/siano/smsdvb.h         |  129 +++
 drivers/media/mmc/siano/smssdio.c           |   13 +
 drivers/media/usb/siano/smsusb.c            |  130 ++-
 13 files changed, 3373 insertions(+), 1423 deletions(-)
 create mode 100644 drivers/media/common/siano/smsdvb-debugfs.c
 create mode 100644 drivers/media/common/siano/smsdvb-main.c
 delete mode 100644 drivers/media/common/siano/smsdvb.c
 create mode 100644 drivers/media/common/siano/smsdvb.h
Signature · 1 line
1.8.1.4
#1 lore raw

PATCH 1/46 siano: Change GPIO voltage setting names

Siano changed the namespace on more recent API, and re-used some of the old names. In order to be able to update the API to support newer chips, the better is to follow this change.

---
 drivers/media/common/siano/sms-cards.c  | 2 +-
 drivers/media/common/siano/smscoreapi.c | 8 ++++----
 drivers/media/common/siano/smscoreapi.h | 8 ++++----
 3 files changed, 9 insertions(+), 9 deletions(-)
drivers/media/common/siano/sms-cards.c +1 -1
index 680c781..8ee2e92 100644
@@ -183,7 +183,7 @@ static int sms_set_gpio(struct smscore_device_t *coredev, int pin, int enable)
 		.pullupdown           = SMS_GPIO_PULLUPDOWN_NONE,
 		.inputcharacteristics = SMS_GPIO_INPUTCHARACTERISTICS_NORMAL,
 		.outputslewrate       = SMS_GPIO_OUTPUTSLEWRATE_FAST,
-		.outputdriving        = SMS_GPIO_OUTPUTDRIVING_4mA,
+		.outputdriving        = SMS_GPIO_OUTPUTDRIVING_S_4mA,
 	};
 
 	if (pin == 0)
drivers/media/common/siano/smscoreapi.c +4 -4
index 1842e64..d0592b5 100644
@@ -1306,16 +1306,16 @@ int smscore_configure_gpio(struct smscore_device_t *coredev, u32 pin,
 		msg.data[2] = pinconfig->outputslewrate == 0 ? 3 : 0;
 
 		switch (pinconfig->outputdriving) {
-		case SMS_GPIO_OUTPUTDRIVING_16mA:
+		case SMS_GPIO_OUTPUTDRIVING_S_16mA:
 			msg.data[3] = 7; /* Nova - 16mA */
 			break;
-		case SMS_GPIO_OUTPUTDRIVING_12mA:
+		case SMS_GPIO_OUTPUTDRIVING_S_12mA:
 			msg.data[3] = 5; /* Nova - 11mA */
 			break;
-		case SMS_GPIO_OUTPUTDRIVING_8mA:
+		case SMS_GPIO_OUTPUTDRIVING_S_8mA:
 			msg.data[3] = 3; /* Nova - 7mA */
 			break;
-		case SMS_GPIO_OUTPUTDRIVING_4mA:
+		case SMS_GPIO_OUTPUTDRIVING_S_4mA:
 		default:
 			msg.data[3] = 2; /* Nova - 4mA */
 			break;
drivers/media/common/siano/smscoreapi.h +4 -4
index c592ae0..a6d29a2 100644
@@ -642,10 +642,10 @@ struct smscore_config_gpio {
 #define SMS_GPIO_OUTPUTSLEWRATE_SLOW 1
 	u8 outputslewrate;
 
-#define SMS_GPIO_OUTPUTDRIVING_4mA  0
-#define SMS_GPIO_OUTPUTDRIVING_8mA  1
-#define SMS_GPIO_OUTPUTDRIVING_12mA 2
-#define SMS_GPIO_OUTPUTDRIVING_16mA 3
+#define SMS_GPIO_OUTPUTDRIVING_S_4mA  0
+#define SMS_GPIO_OUTPUTDRIVING_S_8mA  1
+#define SMS_GPIO_OUTPUTDRIVING_S_12mA 2
+#define SMS_GPIO_OUTPUTDRIVING_S_16mA 3
 	u8 outputdriving;
 };
 
Signature · 1 line
1.8.1.4
#2 lore raw

PATCH 2/46 siano: Add the new voltage definitions for GPIO

In reply to Mauro Carvalho Chehab

Those new definitions came from this patch, from Doron Cohen:

	http://patchwork.linuxtv.org/patch/7882/
---
 drivers/media/common/siano/smscoreapi.h | 12 ++++++++++++
 1 file changed, 12 insertions(+)
drivers/media/common/siano/smscoreapi.h +12 -0
index a6d29a2..62f05e8 100644
@@ -642,10 +642,22 @@ struct smscore_config_gpio {
 #define SMS_GPIO_OUTPUTSLEWRATE_SLOW 1
 	u8 outputslewrate;
 
+	/* 10xx */
 #define SMS_GPIO_OUTPUTDRIVING_S_4mA  0
 #define SMS_GPIO_OUTPUTDRIVING_S_8mA  1
 #define SMS_GPIO_OUTPUTDRIVING_S_12mA 2
 #define SMS_GPIO_OUTPUTDRIVING_S_16mA 3
+
+	/* 11xx*/
+#define SMS_GPIO_OUTPUTDRIVING_1_5mA	0
+#define SMS_GPIO_OUTPUTDRIVING_2_8mA	1
+#define SMS_GPIO_OUTPUTDRIVING_4mA	2
+#define SMS_GPIO_OUTPUTDRIVING_7mA	3
+#define SMS_GPIO_OUTPUTDRIVING_10mA	4
+#define SMS_GPIO_OUTPUTDRIVING_11mA	5
+#define SMS_GPIO_OUTPUTDRIVING_14mA	6
+#define SMS_GPIO_OUTPUTDRIVING_16mA	7
+
 	u8 outputdriving;
 };
 
Signature · 1 line
1.8.1.4
#3 lore raw

PATCH 3/46 siano: remove a duplicated structure definition

In reply to Mauro Carvalho Chehab

The same GPIO config struct was declared twice at the driver, with different names and different macros:
struct smscore_config_gpio
struct smscore_config_gpio

Remove the one that uses CamelCase and fix the references to its attributes/macros.

No functional changes.

---
 drivers/media/common/siano/sms-cards.c  | 18 +++++------
 drivers/media/common/siano/smscoreapi.c | 20 ++++++------
 drivers/media/common/siano/smscoreapi.h | 55 +++++++--------------------------
 3 files changed, 30 insertions(+), 63 deletions(-)
drivers/media/common/siano/sms-cards.c +9 -9
index 8ee2e92..b22b61d 100644
@@ -109,18 +109,18 @@ struct sms_board *sms_get_board(unsigned id)
 }
 EXPORT_SYMBOL_GPL(sms_get_board);
 static inline void sms_gpio_assign_11xx_default_led_config(
-		struct smscore_gpio_config *pGpioConfig) {
-	pGpioConfig->Direction = SMS_GPIO_DIRECTION_OUTPUT;
-	pGpioConfig->InputCharacteristics =
-		SMS_GPIO_INPUT_CHARACTERISTICS_NORMAL;
-	pGpioConfig->OutputDriving = SMS_GPIO_OUTPUT_DRIVING_4mA;
-	pGpioConfig->OutputSlewRate = SMS_GPIO_OUTPUT_SLEW_RATE_0_45_V_NS;
-	pGpioConfig->PullUpDown = SMS_GPIO_PULL_UP_DOWN_NONE;
+		struct smscore_config_gpio *pGpioConfig) {
+	pGpioConfig->direction = SMS_GPIO_DIRECTION_OUTPUT;
+	pGpioConfig->inputcharacteristics =
+		SMS_GPIO_INPUTCHARACTERISTICS_NORMAL;
+	pGpioConfig->outputdriving = SMS_GPIO_OUTPUTDRIVING_4mA;
+	pGpioConfig->outputslewrate = SMS_GPIO_OUTPUT_SLEW_RATE_0_45_V_NS;
+	pGpioConfig->pullupdown = SMS_GPIO_PULLUPDOWN_NONE;
 }
 
 int sms_board_event(struct smscore_device_t *coredev,
 		enum SMS_BOARD_EVENTS gevent) {
-	struct smscore_gpio_config MyGpioConfig;
+	struct smscore_config_gpio MyGpioConfig;
 
 	sms_gpio_assign_11xx_default_led_config(&MyGpioConfig);
 
@@ -182,7 +182,7 @@ static int sms_set_gpio(struct smscore_device_t *coredev, int pin, int enable)
 		.direction            = SMS_GPIO_DIRECTION_OUTPUT,
 		.pullupdown           = SMS_GPIO_PULLUPDOWN_NONE,
 		.inputcharacteristics = SMS_GPIO_INPUTCHARACTERISTICS_NORMAL,
-		.outputslewrate       = SMS_GPIO_OUTPUTSLEWRATE_FAST,
+		.outputslewrate       = SMS_GPIO_OUTPUT_SLEW_RATE_FAST,
 		.outputdriving        = SMS_GPIO_OUTPUTDRIVING_S_4mA,
 	};
 
drivers/media/common/siano/smscoreapi.c +10 -10
index d0592b5..58371c3 100644
@@ -1406,7 +1406,7 @@ static int GetGpioPinParams(u32 PinNum, u32 *pTranslatedPinNum,
 }
 
 int smscore_gpio_configure(struct smscore_device_t *coredev, u8 PinNum,
-		struct smscore_gpio_config *pGpioConfig) {
+		struct smscore_config_gpio *pGpioConfig) {
 
 	u32 totalLen;
 	u32 TranslatedPinNum = 0;
@@ -1453,19 +1453,19 @@ int smscore_gpio_configure(struct smscore_device_t *coredev, u8 PinNum,
 
 		pMsg->msgData[1] = TranslatedPinNum;
 		pMsg->msgData[2] = GroupNum;
-		ElectricChar = (pGpioConfig->PullUpDown)
-				| (pGpioConfig->InputCharacteristics << 2)
-				| (pGpioConfig->OutputSlewRate << 3)
-				| (pGpioConfig->OutputDriving << 4);
+		ElectricChar = (pGpioConfig->pullupdown)
+				| (pGpioConfig->inputcharacteristics << 2)
+				| (pGpioConfig->outputslewrate << 3)
+				| (pGpioConfig->outputdriving << 4);
 		pMsg->msgData[3] = ElectricChar;
-		pMsg->msgData[4] = pGpioConfig->Direction;
+		pMsg->msgData[4] = pGpioConfig->direction;
 		pMsg->msgData[5] = groupCfg;
 	} else {
 		pMsg->xMsgHeader.msgType = MSG_SMS_GPIO_CONFIG_EX_REQ;
-		pMsg->msgData[1] = pGpioConfig->PullUpDown;
-		pMsg->msgData[2] = pGpioConfig->OutputSlewRate;
-		pMsg->msgData[3] = pGpioConfig->OutputDriving;
-		pMsg->msgData[4] = pGpioConfig->Direction;
+		pMsg->msgData[1] = pGpioConfig->pullupdown;
+		pMsg->msgData[2] = pGpioConfig->outputslewrate;
+		pMsg->msgData[3] = pGpioConfig->outputdriving;
+		pMsg->msgData[4] = pGpioConfig->direction;
 		pMsg->msgData[5] = 0;
 	}
 
drivers/media/common/siano/smscoreapi.h +11 -44

73 lines not on this page · raw message

Signature · 1 line
1.8.1.4
#4 lore raw

PATCH 4/46 siano: update message macros

In reply to Mauro Carvalho Chehab

Convert from #define into an enum and add the newer message macros as found on this patch from Doron Cohen:

	http://patchwork.linuxtv.org/patch/7882/

No messages got supressed.

---
 drivers/media/common/siano/smscoreapi.h | 374 +++++++++++++++++++++++++++-----
 1 file changed, 321 insertions(+), 53 deletions(-)
drivers/media/common/siano/smscoreapi.h +321 -53
index f2510f5..4a0a763 100644
@@ -194,59 +194,327 @@ struct smscore_device_t {
 #define SMS_MAX_PAYLOAD_SIZE				240
 #define SMS_TUNE_TIMEOUT					500
 
-#define MSG_SMS_GPIO_CONFIG_REQ				507
-#define MSG_SMS_GPIO_CONFIG_RES				508
-#define MSG_SMS_GPIO_SET_LEVEL_REQ			509
-#define MSG_SMS_GPIO_SET_LEVEL_RES			510
-#define MSG_SMS_GPIO_GET_LEVEL_REQ			511
-#define MSG_SMS_GPIO_GET_LEVEL_RES			512
-#define MSG_SMS_RF_TUNE_REQ					561
-#define MSG_SMS_RF_TUNE_RES					562
-#define MSG_SMS_INIT_DEVICE_REQ				578
-#define MSG_SMS_INIT_DEVICE_RES				579
-#define MSG_SMS_ADD_PID_FILTER_REQ			601
-#define MSG_SMS_ADD_PID_FILTER_RES			602
-#define MSG_SMS_REMOVE_PID_FILTER_REQ			603
-#define MSG_SMS_REMOVE_PID_FILTER_RES			604
-#define MSG_SMS_DAB_CHANNEL				607
-#define MSG_SMS_GET_PID_FILTER_LIST_REQ			608
-#define MSG_SMS_GET_PID_FILTER_LIST_RES			609
-#define MSG_SMS_GET_STATISTICS_RES			616
-#define MSG_SMS_GET_STATISTICS_REQ			615
-#define MSG_SMS_HO_PER_SLICES_IND			630
-#define MSG_SMS_SET_ANTENNA_CONFIG_REQ			651
-#define MSG_SMS_SET_ANTENNA_CONFIG_RES			652
-#define MSG_SMS_SLEEP_RESUME_COMP_IND			655
-#define MSG_SMS_DATA_DOWNLOAD_REQ			660
-#define MSG_SMS_DATA_DOWNLOAD_RES			661
-#define MSG_SMS_SWDOWNLOAD_TRIGGER_REQ		664
-#define MSG_SMS_SWDOWNLOAD_TRIGGER_RES		665
-#define MSG_SMS_SWDOWNLOAD_BACKDOOR_REQ		666
-#define MSG_SMS_SWDOWNLOAD_BACKDOOR_RES		667
-#define MSG_SMS_GET_VERSION_EX_REQ			668
-#define MSG_SMS_GET_VERSION_EX_RES			669
-#define MSG_SMS_SET_CLOCK_OUTPUT_REQ		670
-#define MSG_SMS_I2C_SET_FREQ_REQ			685
-#define MSG_SMS_GENERIC_I2C_REQ				687
-#define MSG_SMS_GENERIC_I2C_RES				688
-#define MSG_SMS_DVBT_BDA_DATA				693
-#define MSG_SW_RELOAD_REQ					697
-#define MSG_SMS_DATA_MSG					699
-#define MSG_SW_RELOAD_START_REQ				702
-#define MSG_SW_RELOAD_START_RES				703
-#define MSG_SW_RELOAD_EXEC_REQ				704
-#define MSG_SW_RELOAD_EXEC_RES				705
-#define MSG_SMS_SPI_INT_LINE_SET_REQ		710
-#define MSG_SMS_GPIO_CONFIG_EX_REQ			712
-#define MSG_SMS_GPIO_CONFIG_EX_RES			713
-#define MSG_SMS_ISDBT_TUNE_REQ				776
-#define MSG_SMS_ISDBT_TUNE_RES				777
-#define MSG_SMS_TRANSMISSION_IND			782
-#define MSG_SMS_START_IR_REQ				800
-#define MSG_SMS_START_IR_RES				801
-#define MSG_SMS_IR_SAMPLES_IND				802
-#define MSG_SMS_SIGNAL_DETECTED_IND			827
-#define MSG_SMS_NO_SIGNAL_IND				828
+enum msg_types {
+	MSG_TYPE_BASE_VAL = 500,
+	MSG_SMS_GET_VERSION_REQ = 503,
+	MSG_SMS_GET_VERSION_RES = 504,
+	MSG_SMS_MULTI_BRIDGE_CFG = 505,
+	MSG_SMS_GPIO_CONFIG_REQ = 507,
+	MSG_SMS_GPIO_CONFIG_RES = 508,
+	MSG_SMS_GPIO_SET_LEVEL_REQ = 509,
+	MSG_SMS_GPIO_SET_LEVEL_RES = 510,
+	MSG_SMS_GPIO_GET_LEVEL_REQ = 511,
+	MSG_SMS_GPIO_GET_LEVEL_RES = 512,
+	MSG_SMS_EEPROM_BURN_IND = 513,
+	MSG_SMS_LOG_ENABLE_CHANGE_REQ = 514,
+	MSG_SMS_LOG_ENABLE_CHANGE_RES = 515,
+	MSG_SMS_SET_MAX_TX_MSG_LEN_REQ = 516,
+	MSG_SMS_SET_MAX_TX_MSG_LEN_RES = 517,
+	MSG_SMS_SPI_HALFDUPLEX_TOKEN_HOST_TO_DEVICE = 518,
+	MSG_SMS_SPI_HALFDUPLEX_TOKEN_DEVICE_TO_HOST = 519,
+	MSG_SMS_BACKGROUND_SCAN_FLAG_CHANGE_REQ = 520,
+	MSG_SMS_BACKGROUND_SCAN_FLAG_CHANGE_RES = 521,
+	MSG_SMS_BACKGROUND_SCAN_SIGNAL_DETECTED_IND = 522,
+	MSG_SMS_BACKGROUND_SCAN_NO_SIGNAL_IND = 523,
+	MSG_SMS_CONFIGURE_RF_SWITCH_REQ = 524,
+	MSG_SMS_CONFIGURE_RF_SWITCH_RES = 525,
+	MSG_SMS_MRC_PATH_DISCONNECT_REQ = 526,
+	MSG_SMS_MRC_PATH_DISCONNECT_RES = 527,
+	MSG_SMS_RECEIVE_1SEG_THROUGH_FULLSEG_REQ = 528,
+	MSG_SMS_RECEIVE_1SEG_THROUGH_FULLSEG_RES = 529,
+	MSG_SMS_RECEIVE_VHF_VIA_VHF_INPUT_REQ = 530,
+	MSG_SMS_RECEIVE_VHF_VIA_VHF_INPUT_RES = 531,
+	MSG_WR_REG_RFT_REQ = 533,
+	MSG_WR_REG_RFT_RES = 534,
+	MSG_RD_REG_RFT_REQ = 535,
+	MSG_RD_REG_RFT_RES = 536,
+	MSG_RD_REG_ALL_RFT_REQ = 537,
+	MSG_RD_REG_ALL_RFT_RES = 538,
+	MSG_HELP_INT = 539,
+	MSG_RUN_SCRIPT_INT = 540,
+	MSG_SMS_EWS_INBAND_REQ = 541,
+	MSG_SMS_EWS_INBAND_RES = 542,
+	MSG_SMS_RFS_SELECT_REQ = 543,
+	MSG_SMS_RFS_SELECT_RES = 544,
+	MSG_SMS_MB_GET_VER_REQ = 545,
+	MSG_SMS_MB_GET_VER_RES = 546,
+	MSG_SMS_MB_WRITE_CFGFILE_REQ = 547,
+	MSG_SMS_MB_WRITE_CFGFILE_RES = 548,
+	MSG_SMS_MB_READ_CFGFILE_REQ = 549,
+	MSG_SMS_MB_READ_CFGFILE_RES = 550,
+	MSG_SMS_RD_MEM_REQ = 552,
+	MSG_SMS_RD_MEM_RES = 553,
+	MSG_SMS_WR_MEM_REQ = 554,
+	MSG_SMS_WR_MEM_RES = 555,
+	MSG_SMS_UPDATE_MEM_REQ = 556,
+	MSG_SMS_UPDATE_MEM_RES = 557,
+	MSG_SMS_ISDBT_ENABLE_FULL_PARAMS_SET_REQ = 558,
+	MSG_SMS_ISDBT_ENABLE_FULL_PARAMS_SET_RES = 559,
+	MSG_SMS_RF_TUNE_REQ = 561,
+	MSG_SMS_RF_TUNE_RES = 562,
+	MSG_SMS_ISDBT_ENABLE_HIGH_MOBILITY_REQ = 563,
+	MSG_SMS_ISDBT_ENABLE_HIGH_MOBILITY_RES = 564,
+	MSG_SMS_ISDBT_SB_RECEPTION_REQ = 565,
+	MSG_SMS_ISDBT_SB_RECEPTION_RES = 566,
+	MSG_SMS_GENERIC_EPROM_WRITE_REQ = 567,
+	MSG_SMS_GENERIC_EPROM_WRITE_RES = 568,
+	MSG_SMS_GENERIC_EPROM_READ_REQ = 569,
+	MSG_SMS_GENERIC_EPROM_READ_RES = 570,
+	MSG_SMS_EEPROM_WRITE_REQ = 571,
+	MSG_SMS_EEPROM_WRITE_RES = 572,
+	MSG_SMS_CUSTOM_READ_REQ = 574,
+	MSG_SMS_CUSTOM_READ_RES = 575,
+	MSG_SMS_CUSTOM_WRITE_REQ = 576,
+	MSG_SMS_CUSTOM_WRITE_RES = 577,
+	MSG_SMS_INIT_DEVICE_REQ = 578,
+	MSG_SMS_INIT_DEVICE_RES = 579,
+	MSG_SMS_ATSC_SET_ALL_IP_REQ = 580,
+	MSG_SMS_ATSC_SET_ALL_IP_RES = 581,
+	MSG_SMS_ATSC_START_ENSEMBLE_REQ = 582,
+	MSG_SMS_ATSC_START_ENSEMBLE_RES = 583,
+	MSG_SMS_SET_OUTPUT_MODE_REQ = 584,
+	MSG_SMS_SET_OUTPUT_MODE_RES = 585,
+	MSG_SMS_ATSC_IP_FILTER_GET_LIST_REQ = 586,
+	MSG_SMS_ATSC_IP_FILTER_GET_LIST_RES = 587,
+	MSG_SMS_SUB_CHANNEL_START_REQ = 589,
+	MSG_SMS_SUB_CHANNEL_START_RES = 590,
+	MSG_SMS_SUB_CHANNEL_STOP_REQ = 591,
+	MSG_SMS_SUB_CHANNEL_STOP_RES = 592,
+	MSG_SMS_ATSC_IP_FILTER_ADD_REQ = 593,
+	MSG_SMS_ATSC_IP_FILTER_ADD_RES = 594,
+	MSG_SMS_ATSC_IP_FILTER_REMOVE_REQ = 595,
+	MSG_SMS_ATSC_IP_FILTER_REMOVE_RES = 596,
+	MSG_SMS_ATSC_IP_FILTER_REMOVE_ALL_REQ = 597,
+	MSG_SMS_ATSC_IP_FILTER_REMOVE_ALL_RES = 598,
+	MSG_SMS_WAIT_CMD = 599,
+	MSG_SMS_ADD_PID_FILTER_REQ = 601,
+	MSG_SMS_ADD_PID_FILTER_RES = 602,
+	MSG_SMS_REMOVE_PID_FILTER_REQ = 603,
+	MSG_SMS_REMOVE_PID_FILTER_RES = 604,
+	MSG_SMS_FAST_INFORMATION_CHANNEL_REQ = 605,
+	MSG_SMS_FAST_INFORMATION_CHANNEL_RES = 606,
+	MSG_SMS_DAB_CHANNEL = 607,
+	MSG_SMS_GET_PID_FILTER_LIST_REQ = 608,
+	MSG_SMS_GET_PID_FILTER_LIST_RES = 609,
+	MSG_SMS_POWER_DOWN_REQ = 610,
+	MSG_SMS_POWER_DOWN_RES = 611,
+	MSG_SMS_ATSC_SLT_EXIST_IND = 612,
+	MSG_SMS_ATSC_NO_SLT_IND = 613,
+	MSG_SMS_GET_STATISTICS_REQ = 615,
+	MSG_SMS_GET_STATISTICS_RES = 616,
+	MSG_SMS_SEND_DUMP = 617,
+	MSG_SMS_SCAN_START_REQ = 618,
+	MSG_SMS_SCAN_START_RES = 619,
+	MSG_SMS_SCAN_STOP_REQ = 620,
+	MSG_SMS_SCAN_STOP_RES = 621,
+	MSG_SMS_SCAN_PROGRESS_IND = 622,
+	MSG_SMS_SCAN_COMPLETE_IND = 623,
+	MSG_SMS_LOG_ITEM = 624,
+	MSG_SMS_DAB_SUBCHANNEL_RECONFIG_REQ = 628,
+	MSG_SMS_DAB_SUBCHANNEL_RECONFIG_RES = 629,
+	MSG_SMS_HO_PER_SLICES_IND = 630,
+	MSG_SMS_HO_INBAND_POWER_IND = 631,
+	MSG_SMS_MANUAL_DEMOD_REQ = 632,
+	MSG_SMS_HO_TUNE_ON_REQ = 636,
+	MSG_SMS_HO_TUNE_ON_RES = 637,
+	MSG_SMS_HO_TUNE_OFF_REQ = 638,
+	MSG_SMS_HO_TUNE_OFF_RES = 639,
+	MSG_SMS_HO_PEEK_FREQ_REQ = 640,
+	MSG_SMS_HO_PEEK_FREQ_RES = 641,
+	MSG_SMS_HO_PEEK_FREQ_IND = 642,
+	MSG_SMS_MB_ATTEN_SET_REQ = 643,
+	MSG_SMS_MB_ATTEN_SET_RES = 644,
+	MSG_SMS_ENABLE_STAT_IN_I2C_REQ = 649,
+	MSG_SMS_ENABLE_STAT_IN_I2C_RES = 650,
+	MSG_SMS_SET_ANTENNA_CONFIG_REQ = 651,
+	MSG_SMS_SET_ANTENNA_CONFIG_RES = 652,
+	MSG_SMS_GET_STATISTICS_EX_REQ = 653,
+	MSG_SMS_GET_STATISTICS_EX_RES = 654,
+	MSG_SMS_SLEEP_RESUME_COMP_IND = 655,
+	MSG_SMS_SWITCH_HOST_INTERFACE_REQ = 656,
+	MSG_SMS_SWITCH_HOST_INTERFACE_RES = 657,
+	MSG_SMS_DATA_DOWNLOAD_REQ = 660,
+	MSG_SMS_DATA_DOWNLOAD_RES = 661,
+	MSG_SMS_DATA_VALIDITY_REQ = 662,
+	MSG_SMS_DATA_VALIDITY_RES = 663,
+	MSG_SMS_SWDOWNLOAD_TRIGGER_REQ = 664,
+	MSG_SMS_SWDOWNLOAD_TRIGGER_RES = 665,
+	MSG_SMS_SWDOWNLOAD_BACKDOOR_REQ = 666,
+	MSG_SMS_SWDOWNLOAD_BACKDOOR_RES = 667,
+	MSG_SMS_GET_VERSION_EX_REQ = 668,
+	MSG_SMS_GET_VERSION_EX_RES = 669,
+	MSG_SMS_CLOCK_OUTPUT_CONFIG_REQ = 670,
+	MSG_SMS_CLOCK_OUTPUT_CONFIG_RES = 671,
+	MSG_SMS_I2C_SET_FREQ_REQ = 685,
+	MSG_SMS_I2C_SET_FREQ_RES = 686,
+	MSG_SMS_GENERIC_I2C_REQ = 687,
+	MSG_SMS_GENERIC_I2C_RES = 688,
+	MSG_SMS_DVBT_BDA_DATA = 693,
+	MSG_SW_RELOAD_REQ = 697,
+	MSG_SMS_DATA_MSG = 699,
+	MSG_TABLE_UPLOAD_REQ = 700,
+	MSG_TABLE_UPLOAD_RES = 701,
+	MSG_SW_RELOAD_START_REQ = 702,
+	MSG_SW_RELOAD_START_RES = 703,
+	MSG_SW_RELOAD_EXEC_REQ = 704,
+	MSG_SW_RELOAD_EXEC_RES = 705,
+	MSG_SMS_SPI_INT_LINE_SET_REQ = 710,
+	MSG_SMS_SPI_INT_LINE_SET_RES = 711,
+	MSG_SMS_GPIO_CONFIG_EX_REQ = 712,
+	MSG_SMS_GPIO_CONFIG_EX_RES = 713,
+	MSG_SMS_WATCHDOG_ACT_REQ = 716,
+	MSG_SMS_WATCHDOG_ACT_RES = 717,
+	MSG_SMS_LOOPBACK_REQ = 718,
+	MSG_SMS_LOOPBACK_RES = 719,
+	MSG_SMS_RAW_CAPTURE_START_REQ = 720,
+	MSG_SMS_RAW_CAPTURE_START_RES = 721,
+	MSG_SMS_RAW_CAPTURE_ABORT_REQ = 722,
+	MSG_SMS_RAW_CAPTURE_ABORT_RES = 723,
+	MSG_SMS_RAW_CAPTURE_COMPLETE_IND = 728,
+	MSG_SMS_DATA_PUMP_IND = 729,
+	MSG_SMS_DATA_PUMP_REQ = 730,
+	MSG_SMS_DATA_PUMP_RES = 731,
+	MSG_SMS_FLASH_DL_REQ = 732,
+	MSG_SMS_EXEC_TEST_1_REQ = 734,
+	MSG_SMS_EXEC_TEST_1_RES = 735,
+	MSG_SMS_ENBALE_TS_INTERFACE_REQ = 736,
+	MSG_SMS_ENBALE_TS_INTERFACE_RES = 737,
+	MSG_SMS_SPI_SET_BUS_WIDTH_REQ = 738,
+	MSG_SMS_SPI_SET_BUS_WIDTH_RES = 739,
+	MSG_SMS_SEND_EMM_REQ = 740,
+	MSG_SMS_SEND_EMM_RES = 741,
+	MSG_SMS_DISABLE_TS_INTERFACE_REQ = 742,
+	MSG_SMS_DISABLE_TS_INTERFACE_RES = 743,
+	MSG_SMS_IS_BUF_FREE_REQ = 744,
+	MSG_SMS_IS_BUF_FREE_RES = 745,
+	MSG_SMS_EXT_ANTENNA_REQ = 746,
+	MSG_SMS_EXT_ANTENNA_RES = 747,
+	MSG_SMS_CMMB_GET_NET_OF_FREQ_REQ_OBSOLETE = 748,
+	MSG_SMS_CMMB_GET_NET_OF_FREQ_RES_OBSOLETE = 749,
+	MSG_SMS_BATTERY_LEVEL_REQ = 750,
+	MSG_SMS_BATTERY_LEVEL_RES = 751,
+	MSG_SMS_CMMB_INJECT_TABLE_REQ_OBSOLETE = 752,
+	MSG_SMS_CMMB_INJECT_TABLE_RES_OBSOLETE = 753,
+	MSG_SMS_FM_RADIO_BLOCK_IND = 754,
+	MSG_SMS_HOST_NOTIFICATION_IND = 755,
+	MSG_SMS_CMMB_GET_CONTROL_TABLE_REQ_OBSOLETE = 756,
+	MSG_SMS_CMMB_GET_CONTROL_TABLE_RES_OBSOLETE = 757,
+	MSG_SMS_CMMB_GET_NETWORKS_REQ = 760,
+	MSG_SMS_CMMB_GET_NETWORKS_RES = 761,
+	MSG_SMS_CMMB_START_SERVICE_REQ = 762,
+	MSG_SMS_CMMB_START_SERVICE_RES = 763,
+	MSG_SMS_CMMB_STOP_SERVICE_REQ = 764,
+	MSG_SMS_CMMB_STOP_SERVICE_RES = 765,
+	MSG_SMS_CMMB_ADD_CHANNEL_FILTER_REQ = 768,
+	MSG_SMS_CMMB_ADD_CHANNEL_FILTER_RES = 769,
+	MSG_SMS_CMMB_REMOVE_CHANNEL_FILTER_REQ = 770,
+	MSG_SMS_CMMB_REMOVE_CHANNEL_FILTER_RES = 771,
+	MSG_SMS_CMMB_START_CONTROL_INFO_REQ = 772,
+	MSG_SMS_CMMB_START_CONTROL_INFO_RES = 773,
+	MSG_SMS_CMMB_STOP_CONTROL_INFO_REQ = 774,
+	MSG_SMS_CMMB_STOP_CONTROL_INFO_RES = 775,
+	MSG_SMS_ISDBT_TUNE_REQ = 776,
+	MSG_SMS_ISDBT_TUNE_RES = 777,
+	MSG_SMS_TRANSMISSION_IND = 782,
+	MSG_SMS_PID_STATISTICS_IND = 783,
+	MSG_SMS_POWER_DOWN_IND = 784,
+	MSG_SMS_POWER_DOWN_CONF = 785,
+	MSG_SMS_POWER_UP_IND = 786,
+	MSG_SMS_POWER_UP_CONF = 787,
+	MSG_SMS_POWER_MODE_SET_REQ = 790,
+	MSG_SMS_POWER_MODE_SET_RES = 791,
+	MSG_SMS_DEBUG_HOST_EVENT_REQ = 792,
+	MSG_SMS_DEBUG_HOST_EVENT_RES = 793,
+	MSG_SMS_NEW_CRYSTAL_REQ = 794,
+	MSG_SMS_NEW_CRYSTAL_RES = 795,
+	MSG_SMS_CONFIG_SPI_REQ = 796,
+	MSG_SMS_CONFIG_SPI_RES = 797,
+	MSG_SMS_I2C_SHORT_STAT_IND = 798,
+	MSG_SMS_START_IR_REQ = 800,
+	MSG_SMS_START_IR_RES = 801,
+	MSG_SMS_IR_SAMPLES_IND = 802,
+	MSG_SMS_CMMB_CA_SERVICE_IND = 803,
+	MSG_SMS_SLAVE_DEVICE_DETECTED = 804,
+	MSG_SMS_INTERFACE_LOCK_IND = 805,
+	MSG_SMS_INTERFACE_UNLOCK_IND = 806,
+	MSG_SMS_SEND_ROSUM_BUFF_REQ = 810,
+	MSG_SMS_SEND_ROSUM_BUFF_RES = 811,
+	MSG_SMS_ROSUM_BUFF = 812,
+	MSG_SMS_SET_AES128_KEY_REQ = 815,
+	MSG_SMS_SET_AES128_KEY_RES = 816,
+	MSG_SMS_MBBMS_WRITE_REQ = 817,
+	MSG_SMS_MBBMS_WRITE_RES = 818,
+	MSG_SMS_MBBMS_READ_IND = 819,
+	MSG_SMS_IQ_STREAM_START_REQ = 820,
+	MSG_SMS_IQ_STREAM_START_RES = 821,
+	MSG_SMS_IQ_STREAM_STOP_REQ = 822,
+	MSG_SMS_IQ_STREAM_STOP_RES = 823,
+	MSG_SMS_IQ_STREAM_DATA_BLOCK = 824,
+	MSG_SMS_GET_EEPROM_VERSION_REQ = 825,
+	MSG_SMS_GET_EEPROM_VERSION_RES = 826,
+	MSG_SMS_SIGNAL_DETECTED_IND = 827,
+	MSG_SMS_NO_SIGNAL_IND = 828,
+	MSG_SMS_MRC_SHUTDOWN_SLAVE_REQ = 830,
+	MSG_SMS_MRC_SHUTDOWN_SLAVE_RES = 831,
+	MSG_SMS_MRC_BRINGUP_SLAVE_REQ = 832,
+	MSG_SMS_MRC_BRINGUP_SLAVE_RES = 833,
+	MSG_SMS_EXTERNAL_LNA_CTRL_REQ = 834,
+	MSG_SMS_EXTERNAL_LNA_CTRL_RES = 835,
+	MSG_SMS_SET_PERIODIC_STATISTICS_REQ = 836,
+	MSG_SMS_SET_PERIODIC_STATISTICS_RES = 837,
+	MSG_SMS_CMMB_SET_AUTO_OUTPUT_TS0_REQ = 838,
+	MSG_SMS_CMMB_SET_AUTO_OUTPUT_TS0_RES = 839,
+	LOCAL_TUNE = 850,
+	LOCAL_IFFT_H_ICI = 851,
+	MSG_RESYNC_REQ = 852,
+	MSG_SMS_CMMB_GET_MRC_STATISTICS_REQ = 853,
+	MSG_SMS_CMMB_GET_MRC_STATISTICS_RES = 854,
+	MSG_SMS_LOG_EX_ITEM = 855,
+	MSG_SMS_DEVICE_DATA_LOSS_IND = 856,
+	MSG_SMS_MRC_WATCHDOG_TRIGGERED_IND = 857,
+	MSG_SMS_USER_MSG_REQ = 858,
+	MSG_SMS_USER_MSG_RES = 859,
+	MSG_SMS_SMART_CARD_INIT_REQ = 860,
+	MSG_SMS_SMART_CARD_INIT_RES = 861,
+	MSG_SMS_SMART_CARD_WRITE_REQ = 862,
+	MSG_SMS_SMART_CARD_WRITE_RES = 863,
+	MSG_SMS_SMART_CARD_READ_IND = 864,
+	MSG_SMS_TSE_ENABLE_REQ = 866,
+	MSG_SMS_TSE_ENABLE_RES = 867,
+	MSG_SMS_CMMB_GET_SHORT_STATISTICS_REQ = 868,
+	MSG_SMS_CMMB_GET_SHORT_STATISTICS_RES = 869,
+	MSG_SMS_LED_CONFIG_REQ = 870,
+	MSG_SMS_LED_CONFIG_RES = 871,
+	MSG_PWM_ANTENNA_REQ = 872,
+	MSG_PWM_ANTENNA_RES = 873,
+	MSG_SMS_CMMB_SMD_SN_REQ = 874,
+	MSG_SMS_CMMB_SMD_SN_RES = 875,
+	MSG_SMS_CMMB_SET_CA_CW_REQ = 876,
+	MSG_SMS_CMMB_SET_CA_CW_RES = 877,
+	MSG_SMS_CMMB_SET_CA_SALT_REQ = 878,
+	MSG_SMS_CMMB_SET_CA_SALT_RES = 879,
+	MSG_SMS_NSCD_INIT_REQ = 880,
+	MSG_SMS_NSCD_INIT_RES = 881,
+	MSG_SMS_NSCD_PROCESS_SECTION_REQ = 882,
+	MSG_SMS_NSCD_PROCESS_SECTION_RES = 883,
+	MSG_SMS_DBD_CREATE_OBJECT_REQ = 884,
+	MSG_SMS_DBD_CREATE_OBJECT_RES = 885,
+	MSG_SMS_DBD_CONFIGURE_REQ = 886,
+	MSG_SMS_DBD_CONFIGURE_RES = 887,
+	MSG_SMS_DBD_SET_KEYS_REQ = 888,
+	MSG_SMS_DBD_SET_KEYS_RES = 889,
+	MSG_SMS_DBD_PROCESS_HEADER_REQ = 890,
+	MSG_SMS_DBD_PROCESS_HEADER_RES = 891,
+	MSG_SMS_DBD_PROCESS_DATA_REQ = 892,
+	MSG_SMS_DBD_PROCESS_DATA_RES = 893,
+	MSG_SMS_DBD_PROCESS_GET_DATA_REQ = 894,
+	MSG_SMS_DBD_PROCESS_GET_DATA_RES = 895,
+	MSG_SMS_NSCD_OPEN_SESSION_REQ = 896,
+	MSG_SMS_NSCD_OPEN_SESSION_RES = 897,
+	MSG_SMS_SEND_HOST_DATA_TO_DEMUX_REQ = 898,
+	MSG_SMS_SEND_HOST_DATA_TO_DEMUX_RES = 899,
+	MSG_LAST_MSG_TYPE = 900,
+};
 
 #define SMS_INIT_MSG_EX(ptr, type, src, dst, len) do { \
 	(ptr)->msgType = type; (ptr)->msgSrcId = src; (ptr)->msgDstId = dst; \
Signature · 1 line
1.8.1.4
#5 lore raw

PATCH 5/46 siano: better debug send/receive messages

In reply to Mauro Carvalho Chehab

Instead of printing a message for some random messages, print it for all sent/received ones. That helps a lot to debug what's going on.

---
 drivers/media/common/siano/smscoreapi.c | 351 +++++++++++++++++++++++++++++++-
 drivers/media/common/siano/smscoreapi.h |   2 +
 drivers/media/common/siano/smsdvb.c     |  10 +-
 drivers/media/usb/siano/smsusb.c        |   9 +
 4 files changed, 354 insertions(+), 18 deletions(-)
drivers/media/common/siano/smscoreapi.c +342 -9
index 58371c3..4c83d3c 100644
@@ -63,6 +63,345 @@ struct smscore_client_t {
 	onremove_t		onremove_handler;
 };
 
+static char *siano_msgs[] = {
+	[MSG_TYPE_BASE_VAL                           - MSG_TYPE_BASE_VAL] = "MSG_TYPE_BASE_VAL",
+	[MSG_SMS_GET_VERSION_REQ                     - MSG_TYPE_BASE_VAL] = "MSG_SMS_GET_VERSION_REQ",
+	[MSG_SMS_GET_VERSION_RES                     - MSG_TYPE_BASE_VAL] = "MSG_SMS_GET_VERSION_RES",
+	[MSG_SMS_MULTI_BRIDGE_CFG                    - MSG_TYPE_BASE_VAL] = "MSG_SMS_MULTI_BRIDGE_CFG",
+	[MSG_SMS_GPIO_CONFIG_REQ                     - MSG_TYPE_BASE_VAL] = "MSG_SMS_GPIO_CONFIG_REQ",
+	[MSG_SMS_GPIO_CONFIG_RES                     - MSG_TYPE_BASE_VAL] = "MSG_SMS_GPIO_CONFIG_RES",
+	[MSG_SMS_GPIO_SET_LEVEL_REQ                  - MSG_TYPE_BASE_VAL] = "MSG_SMS_GPIO_SET_LEVEL_REQ",
+	[MSG_SMS_GPIO_SET_LEVEL_RES                  - MSG_TYPE_BASE_VAL] = "MSG_SMS_GPIO_SET_LEVEL_RES",
+	[MSG_SMS_GPIO_GET_LEVEL_REQ                  - MSG_TYPE_BASE_VAL] = "MSG_SMS_GPIO_GET_LEVEL_REQ",
+	[MSG_SMS_GPIO_GET_LEVEL_RES                  - MSG_TYPE_BASE_VAL] = "MSG_SMS_GPIO_GET_LEVEL_RES",
+	[MSG_SMS_EEPROM_BURN_IND                     - MSG_TYPE_BASE_VAL] = "MSG_SMS_EEPROM_BURN_IND",
+	[MSG_SMS_LOG_ENABLE_CHANGE_REQ               - MSG_TYPE_BASE_VAL] = "MSG_SMS_LOG_ENABLE_CHANGE_REQ",
+	[MSG_SMS_LOG_ENABLE_CHANGE_RES               - MSG_TYPE_BASE_VAL] = "MSG_SMS_LOG_ENABLE_CHANGE_RES",
+	[MSG_SMS_SET_MAX_TX_MSG_LEN_REQ              - MSG_TYPE_BASE_VAL] = "MSG_SMS_SET_MAX_TX_MSG_LEN_REQ",
+	[MSG_SMS_SET_MAX_TX_MSG_LEN_RES              - MSG_TYPE_BASE_VAL] = "MSG_SMS_SET_MAX_TX_MSG_LEN_RES",
+	[MSG_SMS_SPI_HALFDUPLEX_TOKEN_HOST_TO_DEVICE - MSG_TYPE_BASE_VAL] = "MSG_SMS_SPI_HALFDUPLEX_TOKEN_HOST_TO_DEVICE",
+	[MSG_SMS_SPI_HALFDUPLEX_TOKEN_DEVICE_TO_HOST - MSG_TYPE_BASE_VAL] = "MSG_SMS_SPI_HALFDUPLEX_TOKEN_DEVICE_TO_HOST",
+	[MSG_SMS_BACKGROUND_SCAN_FLAG_CHANGE_REQ     - MSG_TYPE_BASE_VAL] = "MSG_SMS_BACKGROUND_SCAN_FLAG_CHANGE_REQ",
+	[MSG_SMS_BACKGROUND_SCAN_FLAG_CHANGE_RES     - MSG_TYPE_BASE_VAL] = "MSG_SMS_BACKGROUND_SCAN_FLAG_CHANGE_RES",
+	[MSG_SMS_BACKGROUND_SCAN_SIGNAL_DETECTED_IND - MSG_TYPE_BASE_VAL] = "MSG_SMS_BACKGROUND_SCAN_SIGNAL_DETECTED_IND",
+	[MSG_SMS_BACKGROUND_SCAN_NO_SIGNAL_IND       - MSG_TYPE_BASE_VAL] = "MSG_SMS_BACKGROUND_SCAN_NO_SIGNAL_IND",
+	[MSG_SMS_CONFIGURE_RF_SWITCH_REQ             - MSG_TYPE_BASE_VAL] = "MSG_SMS_CONFIGURE_RF_SWITCH_REQ",
+	[MSG_SMS_CONFIGURE_RF_SWITCH_RES             - MSG_TYPE_BASE_VAL] = "MSG_SMS_CONFIGURE_RF_SWITCH_RES",
+	[MSG_SMS_MRC_PATH_DISCONNECT_REQ             - MSG_TYPE_BASE_VAL] = "MSG_SMS_MRC_PATH_DISCONNECT_REQ",
+	[MSG_SMS_MRC_PATH_DISCONNECT_RES             - MSG_TYPE_BASE_VAL] = "MSG_SMS_MRC_PATH_DISCONNECT_RES",
+	[MSG_SMS_RECEIVE_1SEG_THROUGH_FULLSEG_REQ    - MSG_TYPE_BASE_VAL] = "MSG_SMS_RECEIVE_1SEG_THROUGH_FULLSEG_REQ",
+	[MSG_SMS_RECEIVE_1SEG_THROUGH_FULLSEG_RES    - MSG_TYPE_BASE_VAL] = "MSG_SMS_RECEIVE_1SEG_THROUGH_FULLSEG_RES",
+	[MSG_SMS_RECEIVE_VHF_VIA_VHF_INPUT_REQ       - MSG_TYPE_BASE_VAL] = "MSG_SMS_RECEIVE_VHF_VIA_VHF_INPUT_REQ",
+	[MSG_SMS_RECEIVE_VHF_VIA_VHF_INPUT_RES       - MSG_TYPE_BASE_VAL] = "MSG_SMS_RECEIVE_VHF_VIA_VHF_INPUT_RES",
+	[MSG_WR_REG_RFT_REQ                          - MSG_TYPE_BASE_VAL] = "MSG_WR_REG_RFT_REQ",
+	[MSG_WR_REG_RFT_RES                          - MSG_TYPE_BASE_VAL] = "MSG_WR_REG_RFT_RES",
+	[MSG_RD_REG_RFT_REQ                          - MSG_TYPE_BASE_VAL] = "MSG_RD_REG_RFT_REQ",
+	[MSG_RD_REG_RFT_RES                          - MSG_TYPE_BASE_VAL] = "MSG_RD_REG_RFT_RES",
+	[MSG_RD_REG_ALL_RFT_REQ                      - MSG_TYPE_BASE_VAL] = "MSG_RD_REG_ALL_RFT_REQ",
+	[MSG_RD_REG_ALL_RFT_RES                      - MSG_TYPE_BASE_VAL] = "MSG_RD_REG_ALL_RFT_RES",
+	[MSG_HELP_INT                                - MSG_TYPE_BASE_VAL] = "MSG_HELP_INT",
+	[MSG_RUN_SCRIPT_INT                          - MSG_TYPE_BASE_VAL] = "MSG_RUN_SCRIPT_INT",
+	[MSG_SMS_EWS_INBAND_REQ                      - MSG_TYPE_BASE_VAL] = "MSG_SMS_EWS_INBAND_REQ",
+	[MSG_SMS_EWS_INBAND_RES                      - MSG_TYPE_BASE_VAL] = "MSG_SMS_EWS_INBAND_RES",
+	[MSG_SMS_RFS_SELECT_REQ                      - MSG_TYPE_BASE_VAL] = "MSG_SMS_RFS_SELECT_REQ",
+	[MSG_SMS_RFS_SELECT_RES                      - MSG_TYPE_BASE_VAL] = "MSG_SMS_RFS_SELECT_RES",
+	[MSG_SMS_MB_GET_VER_REQ                      - MSG_TYPE_BASE_VAL] = "MSG_SMS_MB_GET_VER_REQ",
+	[MSG_SMS_MB_GET_VER_RES                      - MSG_TYPE_BASE_VAL] = "MSG_SMS_MB_GET_VER_RES",
+	[MSG_SMS_MB_WRITE_CFGFILE_REQ                - MSG_TYPE_BASE_VAL] = "MSG_SMS_MB_WRITE_CFGFILE_REQ",
+	[MSG_SMS_MB_WRITE_CFGFILE_RES                - MSG_TYPE_BASE_VAL] = "MSG_SMS_MB_WRITE_CFGFILE_RES",
+	[MSG_SMS_MB_READ_CFGFILE_REQ                 - MSG_TYPE_BASE_VAL] = "MSG_SMS_MB_READ_CFGFILE_REQ",
+	[MSG_SMS_MB_READ_CFGFILE_RES                 - MSG_TYPE_BASE_VAL] = "MSG_SMS_MB_READ_CFGFILE_RES",
+	[MSG_SMS_RD_MEM_REQ                          - MSG_TYPE_BASE_VAL] = "MSG_SMS_RD_MEM_REQ",
+	[MSG_SMS_RD_MEM_RES                          - MSG_TYPE_BASE_VAL] = "MSG_SMS_RD_MEM_RES",
+	[MSG_SMS_WR_MEM_REQ                          - MSG_TYPE_BASE_VAL] = "MSG_SMS_WR_MEM_REQ",
+	[MSG_SMS_WR_MEM_RES                          - MSG_TYPE_BASE_VAL] = "MSG_SMS_WR_MEM_RES",
+	[MSG_SMS_UPDATE_MEM_REQ                      - MSG_TYPE_BASE_VAL] = "MSG_SMS_UPDATE_MEM_REQ",
+	[MSG_SMS_UPDATE_MEM_RES                      - MSG_TYPE_BASE_VAL] = "MSG_SMS_UPDATE_MEM_RES",
+	[MSG_SMS_ISDBT_ENABLE_FULL_PARAMS_SET_REQ    - MSG_TYPE_BASE_VAL] = "MSG_SMS_ISDBT_ENABLE_FULL_PARAMS_SET_REQ",
+	[MSG_SMS_ISDBT_ENABLE_FULL_PARAMS_SET_RES    - MSG_TYPE_BASE_VAL] = "MSG_SMS_ISDBT_ENABLE_FULL_PARAMS_SET_RES",
+	[MSG_SMS_RF_TUNE_REQ                         - MSG_TYPE_BASE_VAL] = "MSG_SMS_RF_TUNE_REQ",
+	[MSG_SMS_RF_TUNE_RES                         - MSG_TYPE_BASE_VAL] = "MSG_SMS_RF_TUNE_RES",
+	[MSG_SMS_ISDBT_ENABLE_HIGH_MOBILITY_REQ      - MSG_TYPE_BASE_VAL] = "MSG_SMS_ISDBT_ENABLE_HIGH_MOBILITY_REQ",
+	[MSG_SMS_ISDBT_ENABLE_HIGH_MOBILITY_RES      - MSG_TYPE_BASE_VAL] = "MSG_SMS_ISDBT_ENABLE_HIGH_MOBILITY_RES",
+	[MSG_SMS_ISDBT_SB_RECEPTION_REQ              - MSG_TYPE_BASE_VAL] = "MSG_SMS_ISDBT_SB_RECEPTION_REQ",
+	[MSG_SMS_ISDBT_SB_RECEPTION_RES              - MSG_TYPE_BASE_VAL] = "MSG_SMS_ISDBT_SB_RECEPTION_RES",
+	[MSG_SMS_GENERIC_EPROM_WRITE_REQ             - MSG_TYPE_BASE_VAL] = "MSG_SMS_GENERIC_EPROM_WRITE_REQ",
+	[MSG_SMS_GENERIC_EPROM_WRITE_RES             - MSG_TYPE_BASE_VAL] = "MSG_SMS_GENERIC_EPROM_WRITE_RES",
+	[MSG_SMS_GENERIC_EPROM_READ_REQ              - MSG_TYPE_BASE_VAL] = "MSG_SMS_GENERIC_EPROM_READ_REQ",
+	[MSG_SMS_GENERIC_EPROM_READ_RES              - MSG_TYPE_BASE_VAL] = "MSG_SMS_GENERIC_EPROM_READ_RES",
+	[MSG_SMS_EEPROM_WRITE_REQ                    - MSG_TYPE_BASE_VAL] = "MSG_SMS_EEPROM_WRITE_REQ",
+	[MSG_SMS_EEPROM_WRITE_RES                    - MSG_TYPE_BASE_VAL] = "MSG_SMS_EEPROM_WRITE_RES",
+	[MSG_SMS_CUSTOM_READ_REQ                     - MSG_TYPE_BASE_VAL] = "MSG_SMS_CUSTOM_READ_REQ",
+	[MSG_SMS_CUSTOM_READ_RES                     - MSG_TYPE_BASE_VAL] = "MSG_SMS_CUSTOM_READ_RES",
+	[MSG_SMS_CUSTOM_WRITE_REQ                    - MSG_TYPE_BASE_VAL] = "MSG_SMS_CUSTOM_WRITE_REQ",
+	[MSG_SMS_CUSTOM_WRITE_RES                    - MSG_TYPE_BASE_VAL] = "MSG_SMS_CUSTOM_WRITE_RES",
+	[MSG_SMS_INIT_DEVICE_REQ                     - MSG_TYPE_BASE_VAL] = "MSG_SMS_INIT_DEVICE_REQ",
+	[MSG_SMS_INIT_DEVICE_RES                     - MSG_TYPE_BASE_VAL] = "MSG_SMS_INIT_DEVICE_RES",
+	[MSG_SMS_ATSC_SET_ALL_IP_REQ                 - MSG_TYPE_BASE_VAL] = "MSG_SMS_ATSC_SET_ALL_IP_REQ",
+	[MSG_SMS_ATSC_SET_ALL_IP_RES                 - MSG_TYPE_BASE_VAL] = "MSG_SMS_ATSC_SET_ALL_IP_RES",
+	[MSG_SMS_ATSC_START_ENSEMBLE_REQ             - MSG_TYPE_BASE_VAL] = "MSG_SMS_ATSC_START_ENSEMBLE_REQ",
+	[MSG_SMS_ATSC_START_ENSEMBLE_RES             - MSG_TYPE_BASE_VAL] = "MSG_SMS_ATSC_START_ENSEMBLE_RES",
+	[MSG_SMS_SET_OUTPUT_MODE_REQ                 - MSG_TYPE_BASE_VAL] = "MSG_SMS_SET_OUTPUT_MODE_REQ",
+	[MSG_SMS_SET_OUTPUT_MODE_RES                 - MSG_TYPE_BASE_VAL] = "MSG_SMS_SET_OUTPUT_MODE_RES",
+	[MSG_SMS_ATSC_IP_FILTER_GET_LIST_REQ         - MSG_TYPE_BASE_VAL] = "MSG_SMS_ATSC_IP_FILTER_GET_LIST_REQ",
+	[MSG_SMS_ATSC_IP_FILTER_GET_LIST_RES         - MSG_TYPE_BASE_VAL] = "MSG_SMS_ATSC_IP_FILTER_GET_LIST_RES",
+	[MSG_SMS_SUB_CHANNEL_START_REQ               - MSG_TYPE_BASE_VAL] = "MSG_SMS_SUB_CHANNEL_START_REQ",
+	[MSG_SMS_SUB_CHANNEL_START_RES               - MSG_TYPE_BASE_VAL] = "MSG_SMS_SUB_CHANNEL_START_RES",
+	[MSG_SMS_SUB_CHANNEL_STOP_REQ                - MSG_TYPE_BASE_VAL] = "MSG_SMS_SUB_CHANNEL_STOP_REQ",
+	[MSG_SMS_SUB_CHANNEL_STOP_RES                - MSG_TYPE_BASE_VAL] = "MSG_SMS_SUB_CHANNEL_STOP_RES",
+	[MSG_SMS_ATSC_IP_FILTER_ADD_REQ              - MSG_TYPE_BASE_VAL] = "MSG_SMS_ATSC_IP_FILTER_ADD_REQ",
+	[MSG_SMS_ATSC_IP_FILTER_ADD_RES              - MSG_TYPE_BASE_VAL] = "MSG_SMS_ATSC_IP_FILTER_ADD_RES",
+	[MSG_SMS_ATSC_IP_FILTER_REMOVE_REQ           - MSG_TYPE_BASE_VAL] = "MSG_SMS_ATSC_IP_FILTER_REMOVE_REQ",
+	[MSG_SMS_ATSC_IP_FILTER_REMOVE_RES           - MSG_TYPE_BASE_VAL] = "MSG_SMS_ATSC_IP_FILTER_REMOVE_RES",
+	[MSG_SMS_ATSC_IP_FILTER_REMOVE_ALL_REQ       - MSG_TYPE_BASE_VAL] = "MSG_SMS_ATSC_IP_FILTER_REMOVE_ALL_REQ",
+	[MSG_SMS_ATSC_IP_FILTER_REMOVE_ALL_RES       - MSG_TYPE_BASE_VAL] = "MSG_SMS_ATSC_IP_FILTER_REMOVE_ALL_RES",
+	[MSG_SMS_WAIT_CMD                            - MSG_TYPE_BASE_VAL] = "MSG_SMS_WAIT_CMD",
+	[MSG_SMS_ADD_PID_FILTER_REQ                  - MSG_TYPE_BASE_VAL] = "MSG_SMS_ADD_PID_FILTER_REQ",
+	[MSG_SMS_ADD_PID_FILTER_RES                  - MSG_TYPE_BASE_VAL] = "MSG_SMS_ADD_PID_FILTER_RES",
+	[MSG_SMS_REMOVE_PID_FILTER_REQ               - MSG_TYPE_BASE_VAL] = "MSG_SMS_REMOVE_PID_FILTER_REQ",
+	[MSG_SMS_REMOVE_PID_FILTER_RES               - MSG_TYPE_BASE_VAL] = "MSG_SMS_REMOVE_PID_FILTER_RES",
+	[MSG_SMS_FAST_INFORMATION_CHANNEL_REQ        - MSG_TYPE_BASE_VAL] = "MSG_SMS_FAST_INFORMATION_CHANNEL_REQ",
+	[MSG_SMS_FAST_INFORMATION_CHANNEL_RES        - MSG_TYPE_BASE_VAL] = "MSG_SMS_FAST_INFORMATION_CHANNEL_RES",
+	[MSG_SMS_DAB_CHANNEL                         - MSG_TYPE_BASE_VAL] = "MSG_SMS_DAB_CHANNEL",
+	[MSG_SMS_GET_PID_FILTER_LIST_REQ             - MSG_TYPE_BASE_VAL] = "MSG_SMS_GET_PID_FILTER_LIST_REQ",
+	[MSG_SMS_GET_PID_FILTER_LIST_RES             - MSG_TYPE_BASE_VAL] = "MSG_SMS_GET_PID_FILTER_LIST_RES",
+	[MSG_SMS_POWER_DOWN_REQ                      - MSG_TYPE_BASE_VAL] = "MSG_SMS_POWER_DOWN_REQ",
+	[MSG_SMS_POWER_DOWN_RES                      - MSG_TYPE_BASE_VAL] = "MSG_SMS_POWER_DOWN_RES",
+	[MSG_SMS_ATSC_SLT_EXIST_IND                  - MSG_TYPE_BASE_VAL] = "MSG_SMS_ATSC_SLT_EXIST_IND",
+	[MSG_SMS_ATSC_NO_SLT_IND                     - MSG_TYPE_BASE_VAL] = "MSG_SMS_ATSC_NO_SLT_IND",
+	[MSG_SMS_GET_STATISTICS_REQ                  - MSG_TYPE_BASE_VAL] = "MSG_SMS_GET_STATISTICS_REQ",
+	[MSG_SMS_GET_STATISTICS_RES                  - MSG_TYPE_BASE_VAL] = "MSG_SMS_GET_STATISTICS_RES",
+	[MSG_SMS_SEND_DUMP                           - MSG_TYPE_BASE_VAL] = "MSG_SMS_SEND_DUMP",
+	[MSG_SMS_SCAN_START_REQ                      - MSG_TYPE_BASE_VAL] = "MSG_SMS_SCAN_START_REQ",
+	[MSG_SMS_SCAN_START_RES                      - MSG_TYPE_BASE_VAL] = "MSG_SMS_SCAN_START_RES",
+	[MSG_SMS_SCAN_STOP_REQ                       - MSG_TYPE_BASE_VAL] = "MSG_SMS_SCAN_STOP_REQ",
+	[MSG_SMS_SCAN_STOP_RES                       - MSG_TYPE_BASE_VAL] = "MSG_SMS_SCAN_STOP_RES",
+	[MSG_SMS_SCAN_PROGRESS_IND                   - MSG_TYPE_BASE_VAL] = "MSG_SMS_SCAN_PROGRESS_IND",
+	[MSG_SMS_SCAN_COMPLETE_IND                   - MSG_TYPE_BASE_VAL] = "MSG_SMS_SCAN_COMPLETE_IND",
+	[MSG_SMS_LOG_ITEM                            - MSG_TYPE_BASE_VAL] = "MSG_SMS_LOG_ITEM",
+	[MSG_SMS_DAB_SUBCHANNEL_RECONFIG_REQ         - MSG_TYPE_BASE_VAL] = "MSG_SMS_DAB_SUBCHANNEL_RECONFIG_REQ",
+	[MSG_SMS_DAB_SUBCHANNEL_RECONFIG_RES         - MSG_TYPE_BASE_VAL] = "MSG_SMS_DAB_SUBCHANNEL_RECONFIG_RES",
+	[MSG_SMS_HO_PER_SLICES_IND                   - MSG_TYPE_BASE_VAL] = "MSG_SMS_HO_PER_SLICES_IND",
+	[MSG_SMS_HO_INBAND_POWER_IND                 - MSG_TYPE_BASE_VAL] = "MSG_SMS_HO_INBAND_POWER_IND",
+	[MSG_SMS_MANUAL_DEMOD_REQ                    - MSG_TYPE_BASE_VAL] = "MSG_SMS_MANUAL_DEMOD_REQ",
+	[MSG_SMS_HO_TUNE_ON_REQ                      - MSG_TYPE_BASE_VAL] = "MSG_SMS_HO_TUNE_ON_REQ",
+	[MSG_SMS_HO_TUNE_ON_RES                      - MSG_TYPE_BASE_VAL] = "MSG_SMS_HO_TUNE_ON_RES",
+	[MSG_SMS_HO_TUNE_OFF_REQ                     - MSG_TYPE_BASE_VAL] = "MSG_SMS_HO_TUNE_OFF_REQ",
+	[MSG_SMS_HO_TUNE_OFF_RES                     - MSG_TYPE_BASE_VAL] = "MSG_SMS_HO_TUNE_OFF_RES",
+	[MSG_SMS_HO_PEEK_FREQ_REQ                    - MSG_TYPE_BASE_VAL] = "MSG_SMS_HO_PEEK_FREQ_REQ",
+	[MSG_SMS_HO_PEEK_FREQ_RES                    - MSG_TYPE_BASE_VAL] = "MSG_SMS_HO_PEEK_FREQ_RES",
+	[MSG_SMS_HO_PEEK_FREQ_IND                    - MSG_TYPE_BASE_VAL] = "MSG_SMS_HO_PEEK_FREQ_IND",
+	[MSG_SMS_MB_ATTEN_SET_REQ                    - MSG_TYPE_BASE_VAL] = "MSG_SMS_MB_ATTEN_SET_REQ",
+	[MSG_SMS_MB_ATTEN_SET_RES                    - MSG_TYPE_BASE_VAL] = "MSG_SMS_MB_ATTEN_SET_RES",
+	[MSG_SMS_ENABLE_STAT_IN_I2C_REQ              - MSG_TYPE_BASE_VAL] = "MSG_SMS_ENABLE_STAT_IN_I2C_REQ",
+	[MSG_SMS_ENABLE_STAT_IN_I2C_RES              - MSG_TYPE_BASE_VAL] = "MSG_SMS_ENABLE_STAT_IN_I2C_RES",
+	[MSG_SMS_SET_ANTENNA_CONFIG_REQ              - MSG_TYPE_BASE_VAL] = "MSG_SMS_SET_ANTENNA_CONFIG_REQ",
+	[MSG_SMS_SET_ANTENNA_CONFIG_RES              - MSG_TYPE_BASE_VAL] = "MSG_SMS_SET_ANTENNA_CONFIG_RES",
+	[MSG_SMS_GET_STATISTICS_EX_REQ               - MSG_TYPE_BASE_VAL] = "MSG_SMS_GET_STATISTICS_EX_REQ",
+	[MSG_SMS_GET_STATISTICS_EX_RES               - MSG_TYPE_BASE_VAL] = "MSG_SMS_GET_STATISTICS_EX_RES",
+	[MSG_SMS_SLEEP_RESUME_COMP_IND               - MSG_TYPE_BASE_VAL] = "MSG_SMS_SLEEP_RESUME_COMP_IND",
+	[MSG_SMS_SWITCH_HOST_INTERFACE_REQ           - MSG_TYPE_BASE_VAL] = "MSG_SMS_SWITCH_HOST_INTERFACE_REQ",
+	[MSG_SMS_SWITCH_HOST_INTERFACE_RES           - MSG_TYPE_BASE_VAL] = "MSG_SMS_SWITCH_HOST_INTERFACE_RES",
+	[MSG_SMS_DATA_DOWNLOAD_REQ                   - MSG_TYPE_BASE_VAL] = "MSG_SMS_DATA_DOWNLOAD_REQ",
+	[MSG_SMS_DATA_DOWNLOAD_RES                   - MSG_TYPE_BASE_VAL] = "MSG_SMS_DATA_DOWNLOAD_RES",
+	[MSG_SMS_DATA_VALIDITY_REQ                   - MSG_TYPE_BASE_VAL] = "MSG_SMS_DATA_VALIDITY_REQ",
+	[MSG_SMS_DATA_VALIDITY_RES                   - MSG_TYPE_BASE_VAL] = "MSG_SMS_DATA_VALIDITY_RES",
+	[MSG_SMS_SWDOWNLOAD_TRIGGER_REQ              - MSG_TYPE_BASE_VAL] = "MSG_SMS_SWDOWNLOAD_TRIGGER_REQ",
+	[MSG_SMS_SWDOWNLOAD_TRIGGER_RES              - MSG_TYPE_BASE_VAL] = "MSG_SMS_SWDOWNLOAD_TRIGGER_RES",
+	[MSG_SMS_SWDOWNLOAD_BACKDOOR_REQ             - MSG_TYPE_BASE_VAL] = "MSG_SMS_SWDOWNLOAD_BACKDOOR_REQ",
+	[MSG_SMS_SWDOWNLOAD_BACKDOOR_RES             - MSG_TYPE_BASE_VAL] = "MSG_SMS_SWDOWNLOAD_BACKDOOR_RES",
+	[MSG_SMS_GET_VERSION_EX_REQ                  - MSG_TYPE_BASE_VAL] = "MSG_SMS_GET_VERSION_EX_REQ",
+	[MSG_SMS_GET_VERSION_EX_RES                  - MSG_TYPE_BASE_VAL] = "MSG_SMS_GET_VERSION_EX_RES",
+	[MSG_SMS_CLOCK_OUTPUT_CONFIG_REQ             - MSG_TYPE_BASE_VAL] = "MSG_SMS_CLOCK_OUTPUT_CONFIG_REQ",
+	[MSG_SMS_CLOCK_OUTPUT_CONFIG_RES             - MSG_TYPE_BASE_VAL] = "MSG_SMS_CLOCK_OUTPUT_CONFIG_RES",
+	[MSG_SMS_I2C_SET_FREQ_REQ                    - MSG_TYPE_BASE_VAL] = "MSG_SMS_I2C_SET_FREQ_REQ",
+	[MSG_SMS_I2C_SET_FREQ_RES                    - MSG_TYPE_BASE_VAL] = "MSG_SMS_I2C_SET_FREQ_RES",
+	[MSG_SMS_GENERIC_I2C_REQ                     - MSG_TYPE_BASE_VAL] = "MSG_SMS_GENERIC_I2C_REQ",
+	[MSG_SMS_GENERIC_I2C_RES                     - MSG_TYPE_BASE_VAL] = "MSG_SMS_GENERIC_I2C_RES",
+	[MSG_SMS_DVBT_BDA_DATA                       - MSG_TYPE_BASE_VAL] = "MSG_SMS_DVBT_BDA_DATA",
+	[MSG_SW_RELOAD_REQ                           - MSG_TYPE_BASE_VAL] = "MSG_SW_RELOAD_REQ",
+	[MSG_SMS_DATA_MSG                            - MSG_TYPE_BASE_VAL] = "MSG_SMS_DATA_MSG",
+	[MSG_TABLE_UPLOAD_REQ                        - MSG_TYPE_BASE_VAL] = "MSG_TABLE_UPLOAD_REQ",
+	[MSG_TABLE_UPLOAD_RES                        - MSG_TYPE_BASE_VAL] = "MSG_TABLE_UPLOAD_RES",
+	[MSG_SW_RELOAD_START_REQ                     - MSG_TYPE_BASE_VAL] = "MSG_SW_RELOAD_START_REQ",
+	[MSG_SW_RELOAD_START_RES                     - MSG_TYPE_BASE_VAL] = "MSG_SW_RELOAD_START_RES",
+	[MSG_SW_RELOAD_EXEC_REQ                      - MSG_TYPE_BASE_VAL] = "MSG_SW_RELOAD_EXEC_REQ",
+	[MSG_SW_RELOAD_EXEC_RES                      - MSG_TYPE_BASE_VAL] = "MSG_SW_RELOAD_EXEC_RES",
+	[MSG_SMS_SPI_INT_LINE_SET_REQ                - MSG_TYPE_BASE_VAL] = "MSG_SMS_SPI_INT_LINE_SET_REQ",
+	[MSG_SMS_SPI_INT_LINE_SET_RES                - MSG_TYPE_BASE_VAL] = "MSG_SMS_SPI_INT_LINE_SET_RES",
+	[MSG_SMS_GPIO_CONFIG_EX_REQ                  - MSG_TYPE_BASE_VAL] = "MSG_SMS_GPIO_CONFIG_EX_REQ",
+	[MSG_SMS_GPIO_CONFIG_EX_RES                  - MSG_TYPE_BASE_VAL] = "MSG_SMS_GPIO_CONFIG_EX_RES",
+	[MSG_SMS_WATCHDOG_ACT_REQ                    - MSG_TYPE_BASE_VAL] = "MSG_SMS_WATCHDOG_ACT_REQ",
+	[MSG_SMS_WATCHDOG_ACT_RES                    - MSG_TYPE_BASE_VAL] = "MSG_SMS_WATCHDOG_ACT_RES",
+	[MSG_SMS_LOOPBACK_REQ                        - MSG_TYPE_BASE_VAL] = "MSG_SMS_LOOPBACK_REQ",
+	[MSG_SMS_LOOPBACK_RES                        - MSG_TYPE_BASE_VAL] = "MSG_SMS_LOOPBACK_RES",
+	[MSG_SMS_RAW_CAPTURE_START_REQ               - MSG_TYPE_BASE_VAL] = "MSG_SMS_RAW_CAPTURE_START_REQ",
+	[MSG_SMS_RAW_CAPTURE_START_RES               - MSG_TYPE_BASE_VAL] = "MSG_SMS_RAW_CAPTURE_START_RES",
+	[MSG_SMS_RAW_CAPTURE_ABORT_REQ               - MSG_TYPE_BASE_VAL] = "MSG_SMS_RAW_CAPTURE_ABORT_REQ",
+	[MSG_SMS_RAW_CAPTURE_ABORT_RES               - MSG_TYPE_BASE_VAL] = "MSG_SMS_RAW_CAPTURE_ABORT_RES",
+	[MSG_SMS_RAW_CAPTURE_COMPLETE_IND            - MSG_TYPE_BASE_VAL] = "MSG_SMS_RAW_CAPTURE_COMPLETE_IND",
+	[MSG_SMS_DATA_PUMP_IND                       - MSG_TYPE_BASE_VAL] = "MSG_SMS_DATA_PUMP_IND",
+	[MSG_SMS_DATA_PUMP_REQ                       - MSG_TYPE_BASE_VAL] = "MSG_SMS_DATA_PUMP_REQ",
+	[MSG_SMS_DATA_PUMP_RES                       - MSG_TYPE_BASE_VAL] = "MSG_SMS_DATA_PUMP_RES",
+	[MSG_SMS_FLASH_DL_REQ                        - MSG_TYPE_BASE_VAL] = "MSG_SMS_FLASH_DL_REQ",
+	[MSG_SMS_EXEC_TEST_1_REQ                     - MSG_TYPE_BASE_VAL] = "MSG_SMS_EXEC_TEST_1_REQ",
+	[MSG_SMS_EXEC_TEST_1_RES                     - MSG_TYPE_BASE_VAL] = "MSG_SMS_EXEC_TEST_1_RES",
+	[MSG_SMS_ENBALE_TS_INTERFACE_REQ             - MSG_TYPE_BASE_VAL] = "MSG_SMS_ENBALE_TS_INTERFACE_REQ",
+	[MSG_SMS_ENBALE_TS_INTERFACE_RES             - MSG_TYPE_BASE_VAL] = "MSG_SMS_ENBALE_TS_INTERFACE_RES",
+	[MSG_SMS_SPI_SET_BUS_WIDTH_REQ               - MSG_TYPE_BASE_VAL] = "MSG_SMS_SPI_SET_BUS_WIDTH_REQ",
+	[MSG_SMS_SPI_SET_BUS_WIDTH_RES               - MSG_TYPE_BASE_VAL] = "MSG_SMS_SPI_SET_BUS_WIDTH_RES",
+	[MSG_SMS_SEND_EMM_REQ                        - MSG_TYPE_BASE_VAL] = "MSG_SMS_SEND_EMM_REQ",
+	[MSG_SMS_SEND_EMM_RES                        - MSG_TYPE_BASE_VAL] = "MSG_SMS_SEND_EMM_RES",
+	[MSG_SMS_DISABLE_TS_INTERFACE_REQ            - MSG_TYPE_BASE_VAL] = "MSG_SMS_DISABLE_TS_INTERFACE_REQ",
+	[MSG_SMS_DISABLE_TS_INTERFACE_RES            - MSG_TYPE_BASE_VAL] = "MSG_SMS_DISABLE_TS_INTERFACE_RES",
+	[MSG_SMS_IS_BUF_FREE_REQ                     - MSG_TYPE_BASE_VAL] = "MSG_SMS_IS_BUF_FREE_REQ",
+	[MSG_SMS_IS_BUF_FREE_RES                     - MSG_TYPE_BASE_VAL] = "MSG_SMS_IS_BUF_FREE_RES",
+	[MSG_SMS_EXT_ANTENNA_REQ                     - MSG_TYPE_BASE_VAL] = "MSG_SMS_EXT_ANTENNA_REQ",
+	[MSG_SMS_EXT_ANTENNA_RES                     - MSG_TYPE_BASE_VAL] = "MSG_SMS_EXT_ANTENNA_RES",
+	[MSG_SMS_CMMB_GET_NET_OF_FREQ_REQ_OBSOLETE   - MSG_TYPE_BASE_VAL] = "MSG_SMS_CMMB_GET_NET_OF_FREQ_REQ_OBSOLETE",
+	[MSG_SMS_CMMB_GET_NET_OF_FREQ_RES_OBSOLETE   - MSG_TYPE_BASE_VAL] = "MSG_SMS_CMMB_GET_NET_OF_FREQ_RES_OBSOLETE",
+	[MSG_SMS_BATTERY_LEVEL_REQ                   - MSG_TYPE_BASE_VAL] = "MSG_SMS_BATTERY_LEVEL_REQ",
+	[MSG_SMS_BATTERY_LEVEL_RES                   - MSG_TYPE_BASE_VAL] = "MSG_SMS_BATTERY_LEVEL_RES",
+	[MSG_SMS_CMMB_INJECT_TABLE_REQ_OBSOLETE      - MSG_TYPE_BASE_VAL] = "MSG_SMS_CMMB_INJECT_TABLE_REQ_OBSOLETE",
+	[MSG_SMS_CMMB_INJECT_TABLE_RES_OBSOLETE      - MSG_TYPE_BASE_VAL] = "MSG_SMS_CMMB_INJECT_TABLE_RES_OBSOLETE",
+	[MSG_SMS_FM_RADIO_BLOCK_IND                  - MSG_TYPE_BASE_VAL] = "MSG_SMS_FM_RADIO_BLOCK_IND",
+	[MSG_SMS_HOST_NOTIFICATION_IND               - MSG_TYPE_BASE_VAL] = "MSG_SMS_HOST_NOTIFICATION_IND",
+	[MSG_SMS_CMMB_GET_CONTROL_TABLE_REQ_OBSOLETE - MSG_TYPE_BASE_VAL] = "MSG_SMS_CMMB_GET_CONTROL_TABLE_REQ_OBSOLETE",
+	[MSG_SMS_CMMB_GET_CONTROL_TABLE_RES_OBSOLETE - MSG_TYPE_BASE_VAL] = "MSG_SMS_CMMB_GET_CONTROL_TABLE_RES_OBSOLETE",
+	[MSG_SMS_CMMB_GET_NETWORKS_REQ               - MSG_TYPE_BASE_VAL] = "MSG_SMS_CMMB_GET_NETWORKS_REQ",
+	[MSG_SMS_CMMB_GET_NETWORKS_RES               - MSG_TYPE_BASE_VAL] = "MSG_SMS_CMMB_GET_NETWORKS_RES",
+	[MSG_SMS_CMMB_START_SERVICE_REQ              - MSG_TYPE_BASE_VAL] = "MSG_SMS_CMMB_START_SERVICE_REQ",
+	[MSG_SMS_CMMB_START_SERVICE_RES              - MSG_TYPE_BASE_VAL] = "MSG_SMS_CMMB_START_SERVICE_RES",
+	[MSG_SMS_CMMB_STOP_SERVICE_REQ               - MSG_TYPE_BASE_VAL] = "MSG_SMS_CMMB_STOP_SERVICE_REQ",
+	[MSG_SMS_CMMB_STOP_SERVICE_RES               - MSG_TYPE_BASE_VAL] = "MSG_SMS_CMMB_STOP_SERVICE_RES",
+	[MSG_SMS_CMMB_ADD_CHANNEL_FILTER_REQ         - MSG_TYPE_BASE_VAL] = "MSG_SMS_CMMB_ADD_CHANNEL_FILTER_REQ",
+	[MSG_SMS_CMMB_ADD_CHANNEL_FILTER_RES         - MSG_TYPE_BASE_VAL] = "MSG_SMS_CMMB_ADD_CHANNEL_FILTER_RES",
+	[MSG_SMS_CMMB_REMOVE_CHANNEL_FILTER_REQ      - MSG_TYPE_BASE_VAL] = "MSG_SMS_CMMB_REMOVE_CHANNEL_FILTER_REQ",
+	[MSG_SMS_CMMB_REMOVE_CHANNEL_FILTER_RES      - MSG_TYPE_BASE_VAL] = "MSG_SMS_CMMB_REMOVE_CHANNEL_FILTER_RES",
+	[MSG_SMS_CMMB_START_CONTROL_INFO_REQ         - MSG_TYPE_BASE_VAL] = "MSG_SMS_CMMB_START_CONTROL_INFO_REQ",
+	[MSG_SMS_CMMB_START_CONTROL_INFO_RES         - MSG_TYPE_BASE_VAL] = "MSG_SMS_CMMB_START_CONTROL_INFO_RES",
+	[MSG_SMS_CMMB_STOP_CONTROL_INFO_REQ          - MSG_TYPE_BASE_VAL] = "MSG_SMS_CMMB_STOP_CONTROL_INFO_REQ",
+	[MSG_SMS_CMMB_STOP_CONTROL_INFO_RES          - MSG_TYPE_BASE_VAL] = "MSG_SMS_CMMB_STOP_CONTROL_INFO_RES",
+	[MSG_SMS_ISDBT_TUNE_REQ                      - MSG_TYPE_BASE_VAL] = "MSG_SMS_ISDBT_TUNE_REQ",
+	[MSG_SMS_ISDBT_TUNE_RES                      - MSG_TYPE_BASE_VAL] = "MSG_SMS_ISDBT_TUNE_RES",
+	[MSG_SMS_TRANSMISSION_IND                    - MSG_TYPE_BASE_VAL] = "MSG_SMS_TRANSMISSION_IND",
+	[MSG_SMS_PID_STATISTICS_IND                  - MSG_TYPE_BASE_VAL] = "MSG_SMS_PID_STATISTICS_IND",
+	[MSG_SMS_POWER_DOWN_IND                      - MSG_TYPE_BASE_VAL] = "MSG_SMS_POWER_DOWN_IND",
+	[MSG_SMS_POWER_DOWN_CONF                     - MSG_TYPE_BASE_VAL] = "MSG_SMS_POWER_DOWN_CONF",
+	[MSG_SMS_POWER_UP_IND                        - MSG_TYPE_BASE_VAL] = "MSG_SMS_POWER_UP_IND",
+	[MSG_SMS_POWER_UP_CONF                       - MSG_TYPE_BASE_VAL] = "MSG_SMS_POWER_UP_CONF",
+	[MSG_SMS_POWER_MODE_SET_REQ                  - MSG_TYPE_BASE_VAL] = "MSG_SMS_POWER_MODE_SET_REQ",
+	[MSG_SMS_POWER_MODE_SET_RES                  - MSG_TYPE_BASE_VAL] = "MSG_SMS_POWER_MODE_SET_RES",
+	[MSG_SMS_DEBUG_HOST_EVENT_REQ                - MSG_TYPE_BASE_VAL] = "MSG_SMS_DEBUG_HOST_EVENT_REQ",
+	[MSG_SMS_DEBUG_HOST_EVENT_RES                - MSG_TYPE_BASE_VAL] = "MSG_SMS_DEBUG_HOST_EVENT_RES",
+	[MSG_SMS_NEW_CRYSTAL_REQ                     - MSG_TYPE_BASE_VAL] = "MSG_SMS_NEW_CRYSTAL_REQ",
+	[MSG_SMS_NEW_CRYSTAL_RES                     - MSG_TYPE_BASE_VAL] = "MSG_SMS_NEW_CRYSTAL_RES",
+	[MSG_SMS_CONFIG_SPI_REQ                      - MSG_TYPE_BASE_VAL] = "MSG_SMS_CONFIG_SPI_REQ",
+	[MSG_SMS_CONFIG_SPI_RES                      - MSG_TYPE_BASE_VAL] = "MSG_SMS_CONFIG_SPI_RES",
+	[MSG_SMS_I2C_SHORT_STAT_IND                  - MSG_TYPE_BASE_VAL] = "MSG_SMS_I2C_SHORT_STAT_IND",
+	[MSG_SMS_START_IR_REQ                        - MSG_TYPE_BASE_VAL] = "MSG_SMS_START_IR_REQ",
+	[MSG_SMS_START_IR_RES                        - MSG_TYPE_BASE_VAL] = "MSG_SMS_START_IR_RES",
+	[MSG_SMS_IR_SAMPLES_IND                      - MSG_TYPE_BASE_VAL] = "MSG_SMS_IR_SAMPLES_IND",
+	[MSG_SMS_CMMB_CA_SERVICE_IND                 - MSG_TYPE_BASE_VAL] = "MSG_SMS_CMMB_CA_SERVICE_IND",
+	[MSG_SMS_SLAVE_DEVICE_DETECTED               - MSG_TYPE_BASE_VAL] = "MSG_SMS_SLAVE_DEVICE_DETECTED",
+	[MSG_SMS_INTERFACE_LOCK_IND                  - MSG_TYPE_BASE_VAL] = "MSG_SMS_INTERFACE_LOCK_IND",
+	[MSG_SMS_INTERFACE_UNLOCK_IND                - MSG_TYPE_BASE_VAL] = "MSG_SMS_INTERFACE_UNLOCK_IND",
+	[MSG_SMS_SEND_ROSUM_BUFF_REQ                 - MSG_TYPE_BASE_VAL] = "MSG_SMS_SEND_ROSUM_BUFF_REQ",
+	[MSG_SMS_SEND_ROSUM_BUFF_RES                 - MSG_TYPE_BASE_VAL] = "MSG_SMS_SEND_ROSUM_BUFF_RES",
+	[MSG_SMS_ROSUM_BUFF                          - MSG_TYPE_BASE_VAL] = "MSG_SMS_ROSUM_BUFF",
+	[MSG_SMS_SET_AES128_KEY_REQ                  - MSG_TYPE_BASE_VAL] = "MSG_SMS_SET_AES128_KEY_REQ",
+	[MSG_SMS_SET_AES128_KEY_RES                  - MSG_TYPE_BASE_VAL] = "MSG_SMS_SET_AES128_KEY_RES",
+	[MSG_SMS_MBBMS_WRITE_REQ                     - MSG_TYPE_BASE_VAL] = "MSG_SMS_MBBMS_WRITE_REQ",
+	[MSG_SMS_MBBMS_WRITE_RES                     - MSG_TYPE_BASE_VAL] = "MSG_SMS_MBBMS_WRITE_RES",
+	[MSG_SMS_MBBMS_READ_IND                      - MSG_TYPE_BASE_VAL] = "MSG_SMS_MBBMS_READ_IND",
+	[MSG_SMS_IQ_STREAM_START_REQ                 - MSG_TYPE_BASE_VAL] = "MSG_SMS_IQ_STREAM_START_REQ",
+	[MSG_SMS_IQ_STREAM_START_RES                 - MSG_TYPE_BASE_VAL] = "MSG_SMS_IQ_STREAM_START_RES",
+	[MSG_SMS_IQ_STREAM_STOP_REQ                  - MSG_TYPE_BASE_VAL] = "MSG_SMS_IQ_STREAM_STOP_REQ",
+	[MSG_SMS_IQ_STREAM_STOP_RES                  - MSG_TYPE_BASE_VAL] = "MSG_SMS_IQ_STREAM_STOP_RES",
+	[MSG_SMS_IQ_STREAM_DATA_BLOCK                - MSG_TYPE_BASE_VAL] = "MSG_SMS_IQ_STREAM_DATA_BLOCK",
+	[MSG_SMS_GET_EEPROM_VERSION_REQ              - MSG_TYPE_BASE_VAL] = "MSG_SMS_GET_EEPROM_VERSION_REQ",
+	[MSG_SMS_GET_EEPROM_VERSION_RES              - MSG_TYPE_BASE_VAL] = "MSG_SMS_GET_EEPROM_VERSION_RES",
+	[MSG_SMS_SIGNAL_DETECTED_IND                 - MSG_TYPE_BASE_VAL] = "MSG_SMS_SIGNAL_DETECTED_IND",
+	[MSG_SMS_NO_SIGNAL_IND                       - MSG_TYPE_BASE_VAL] = "MSG_SMS_NO_SIGNAL_IND",
+	[MSG_SMS_MRC_SHUTDOWN_SLAVE_REQ              - MSG_TYPE_BASE_VAL] = "MSG_SMS_MRC_SHUTDOWN_SLAVE_REQ",
+	[MSG_SMS_MRC_SHUTDOWN_SLAVE_RES              - MSG_TYPE_BASE_VAL] = "MSG_SMS_MRC_SHUTDOWN_SLAVE_RES",
+	[MSG_SMS_MRC_BRINGUP_SLAVE_REQ               - MSG_TYPE_BASE_VAL] = "MSG_SMS_MRC_BRINGUP_SLAVE_REQ",
+	[MSG_SMS_MRC_BRINGUP_SLAVE_RES               - MSG_TYPE_BASE_VAL] = "MSG_SMS_MRC_BRINGUP_SLAVE_RES",
+	[MSG_SMS_EXTERNAL_LNA_CTRL_REQ               - MSG_TYPE_BASE_VAL] = "MSG_SMS_EXTERNAL_LNA_CTRL_REQ",
+	[MSG_SMS_EXTERNAL_LNA_CTRL_RES               - MSG_TYPE_BASE_VAL] = "MSG_SMS_EXTERNAL_LNA_CTRL_RES",
+	[MSG_SMS_SET_PERIODIC_STATISTICS_REQ         - MSG_TYPE_BASE_VAL] = "MSG_SMS_SET_PERIODIC_STATISTICS_REQ",
+	[MSG_SMS_SET_PERIODIC_STATISTICS_RES         - MSG_TYPE_BASE_VAL] = "MSG_SMS_SET_PERIODIC_STATISTICS_RES",
+	[MSG_SMS_CMMB_SET_AUTO_OUTPUT_TS0_REQ        - MSG_TYPE_BASE_VAL] = "MSG_SMS_CMMB_SET_AUTO_OUTPUT_TS0_REQ",
+	[MSG_SMS_CMMB_SET_AUTO_OUTPUT_TS0_RES        - MSG_TYPE_BASE_VAL] = "MSG_SMS_CMMB_SET_AUTO_OUTPUT_TS0_RES",
+	[LOCAL_TUNE                                  - MSG_TYPE_BASE_VAL] = "LOCAL_TUNE",
+	[LOCAL_IFFT_H_ICI                            - MSG_TYPE_BASE_VAL] = "LOCAL_IFFT_H_ICI",
+	[MSG_RESYNC_REQ                              - MSG_TYPE_BASE_VAL] = "MSG_RESYNC_REQ",
+	[MSG_SMS_CMMB_GET_MRC_STATISTICS_REQ         - MSG_TYPE_BASE_VAL] = "MSG_SMS_CMMB_GET_MRC_STATISTICS_REQ",
+	[MSG_SMS_CMMB_GET_MRC_STATISTICS_RES         - MSG_TYPE_BASE_VAL] = "MSG_SMS_CMMB_GET_MRC_STATISTICS_RES",
+	[MSG_SMS_LOG_EX_ITEM                         - MSG_TYPE_BASE_VAL] = "MSG_SMS_LOG_EX_ITEM",
+	[MSG_SMS_DEVICE_DATA_LOSS_IND                - MSG_TYPE_BASE_VAL] = "MSG_SMS_DEVICE_DATA_LOSS_IND",
+	[MSG_SMS_MRC_WATCHDOG_TRIGGERED_IND          - MSG_TYPE_BASE_VAL] = "MSG_SMS_MRC_WATCHDOG_TRIGGERED_IND",
+	[MSG_SMS_USER_MSG_REQ                        - MSG_TYPE_BASE_VAL] = "MSG_SMS_USER_MSG_REQ",
+	[MSG_SMS_USER_MSG_RES                        - MSG_TYPE_BASE_VAL] = "MSG_SMS_USER_MSG_RES",
+	[MSG_SMS_SMART_CARD_INIT_REQ                 - MSG_TYPE_BASE_VAL] = "MSG_SMS_SMART_CARD_INIT_REQ",
+	[MSG_SMS_SMART_CARD_INIT_RES                 - MSG_TYPE_BASE_VAL] = "MSG_SMS_SMART_CARD_INIT_RES",
+	[MSG_SMS_SMART_CARD_WRITE_REQ                - MSG_TYPE_BASE_VAL] = "MSG_SMS_SMART_CARD_WRITE_REQ",
+	[MSG_SMS_SMART_CARD_WRITE_RES                - MSG_TYPE_BASE_VAL] = "MSG_SMS_SMART_CARD_WRITE_RES",
+	[MSG_SMS_SMART_CARD_READ_IND                 - MSG_TYPE_BASE_VAL] = "MSG_SMS_SMART_CARD_READ_IND",
+	[MSG_SMS_TSE_ENABLE_REQ                      - MSG_TYPE_BASE_VAL] = "MSG_SMS_TSE_ENABLE_REQ",
+	[MSG_SMS_TSE_ENABLE_RES                      - MSG_TYPE_BASE_VAL] = "MSG_SMS_TSE_ENABLE_RES",
+	[MSG_SMS_CMMB_GET_SHORT_STATISTICS_REQ       - MSG_TYPE_BASE_VAL] = "MSG_SMS_CMMB_GET_SHORT_STATISTICS_REQ",
+	[MSG_SMS_CMMB_GET_SHORT_STATISTICS_RES       - MSG_TYPE_BASE_VAL] = "MSG_SMS_CMMB_GET_SHORT_STATISTICS_RES",
+	[MSG_SMS_LED_CONFIG_REQ                      - MSG_TYPE_BASE_VAL] = "MSG_SMS_LED_CONFIG_REQ",
+	[MSG_SMS_LED_CONFIG_RES                      - MSG_TYPE_BASE_VAL] = "MSG_SMS_LED_CONFIG_RES",
+	[MSG_PWM_ANTENNA_REQ                         - MSG_TYPE_BASE_VAL] = "MSG_PWM_ANTENNA_REQ",
+	[MSG_PWM_ANTENNA_RES                         - MSG_TYPE_BASE_VAL] = "MSG_PWM_ANTENNA_RES",
+	[MSG_SMS_CMMB_SMD_SN_REQ                     - MSG_TYPE_BASE_VAL] = "MSG_SMS_CMMB_SMD_SN_REQ",
+	[MSG_SMS_CMMB_SMD_SN_RES                     - MSG_TYPE_BASE_VAL] = "MSG_SMS_CMMB_SMD_SN_RES",
+	[MSG_SMS_CMMB_SET_CA_CW_REQ                  - MSG_TYPE_BASE_VAL] = "MSG_SMS_CMMB_SET_CA_CW_REQ",
+	[MSG_SMS_CMMB_SET_CA_CW_RES                  - MSG_TYPE_BASE_VAL] = "MSG_SMS_CMMB_SET_CA_CW_RES",
+	[MSG_SMS_CMMB_SET_CA_SALT_REQ                - MSG_TYPE_BASE_VAL] = "MSG_SMS_CMMB_SET_CA_SALT_REQ",
+	[MSG_SMS_CMMB_SET_CA_SALT_RES                - MSG_TYPE_BASE_VAL] = "MSG_SMS_CMMB_SET_CA_SALT_RES",
+	[MSG_SMS_NSCD_INIT_REQ                       - MSG_TYPE_BASE_VAL] = "MSG_SMS_NSCD_INIT_REQ",
+	[MSG_SMS_NSCD_INIT_RES                       - MSG_TYPE_BASE_VAL] = "MSG_SMS_NSCD_INIT_RES",
+	[MSG_SMS_NSCD_PROCESS_SECTION_REQ            - MSG_TYPE_BASE_VAL] = "MSG_SMS_NSCD_PROCESS_SECTION_REQ",
+	[MSG_SMS_NSCD_PROCESS_SECTION_RES            - MSG_TYPE_BASE_VAL] = "MSG_SMS_NSCD_PROCESS_SECTION_RES",
+	[MSG_SMS_DBD_CREATE_OBJECT_REQ               - MSG_TYPE_BASE_VAL] = "MSG_SMS_DBD_CREATE_OBJECT_REQ",
+	[MSG_SMS_DBD_CREATE_OBJECT_RES               - MSG_TYPE_BASE_VAL] = "MSG_SMS_DBD_CREATE_OBJECT_RES",
+	[MSG_SMS_DBD_CONFIGURE_REQ                   - MSG_TYPE_BASE_VAL] = "MSG_SMS_DBD_CONFIGURE_REQ",
+	[MSG_SMS_DBD_CONFIGURE_RES                   - MSG_TYPE_BASE_VAL] = "MSG_SMS_DBD_CONFIGURE_RES",
+	[MSG_SMS_DBD_SET_KEYS_REQ                    - MSG_TYPE_BASE_VAL] = "MSG_SMS_DBD_SET_KEYS_REQ",
+	[MSG_SMS_DBD_SET_KEYS_RES                    - MSG_TYPE_BASE_VAL] = "MSG_SMS_DBD_SET_KEYS_RES",
+	[MSG_SMS_DBD_PROCESS_HEADER_REQ              - MSG_TYPE_BASE_VAL] = "MSG_SMS_DBD_PROCESS_HEADER_REQ",
+	[MSG_SMS_DBD_PROCESS_HEADER_RES              - MSG_TYPE_BASE_VAL] = "MSG_SMS_DBD_PROCESS_HEADER_RES",
+	[MSG_SMS_DBD_PROCESS_DATA_REQ                - MSG_TYPE_BASE_VAL] = "MSG_SMS_DBD_PROCESS_DATA_REQ",
+	[MSG_SMS_DBD_PROCESS_DATA_RES                - MSG_TYPE_BASE_VAL] = "MSG_SMS_DBD_PROCESS_DATA_RES",
+	[MSG_SMS_DBD_PROCESS_GET_DATA_REQ            - MSG_TYPE_BASE_VAL] = "MSG_SMS_DBD_PROCESS_GET_DATA_REQ",
+	[MSG_SMS_DBD_PROCESS_GET_DATA_RES            - MSG_TYPE_BASE_VAL] = "MSG_SMS_DBD_PROCESS_GET_DATA_RES",
+	[MSG_SMS_NSCD_OPEN_SESSION_REQ               - MSG_TYPE_BASE_VAL] = "MSG_SMS_NSCD_OPEN_SESSION_REQ",
+	[MSG_SMS_NSCD_OPEN_SESSION_RES               - MSG_TYPE_BASE_VAL] = "MSG_SMS_NSCD_OPEN_SESSION_RES",
+	[MSG_SMS_SEND_HOST_DATA_TO_DEMUX_REQ         - MSG_TYPE_BASE_VAL] = "MSG_SMS_SEND_HOST_DATA_TO_DEMUX_REQ",
+	[MSG_SMS_SEND_HOST_DATA_TO_DEMUX_RES         - MSG_TYPE_BASE_VAL] = "MSG_SMS_SEND_HOST_DATA_TO_DEMUX_RES",
+	[MSG_LAST_MSG_TYPE                           - MSG_TYPE_BASE_VAL] = "MSG_LAST_MSG_TYPE",
+};
+
+char *smscore_translate_msg(enum msg_types msgtype)
+{
+	int i = msgtype - MSG_TYPE_BASE_VAL;
+	char *msg;
+
+	if (i < 0 || i > ARRAY_SIZE(siano_msgs))
+		return "Unknown msg type";
+
+	msg = siano_msgs[i];
+
+	if (!*msg)
+		return "Unknown msg type";
+
+	return msg;
+}
+EXPORT_SYMBOL_GPL(smscore_translate_msg);
+
 void smscore_set_board_id(struct smscore_device_t *core, int id)
 {
 	core->board_id = id;
@@ -1013,8 +1352,7 @@ void smscore_onresponse(struct smscore_device_t *coredev,
 		{
 			struct SmsVersionRes_ST *ver =
 				(struct SmsVersionRes_ST *) phdr;
-			sms_debug("MSG_SMS_GET_VERSION_EX_RES "
-				  "id %d prots 0x%x ver %d.%d",
+			sms_debug("Firmware id %d prots 0x%x ver %d.%d",
 				  ver->FirmwareId, ver->SupportedProtocols,
 				  ver->RomVersionMajor, ver->RomVersionMinor);
 
@@ -1026,39 +1364,33 @@ void smscore_onresponse(struct smscore_device_t *coredev,
 			break;
 		}
 		case MSG_SMS_INIT_DEVICE_RES:
-			sms_debug("MSG_SMS_INIT_DEVICE_RES");
 			complete(&coredev->init_device_done);
 			break;
 		case MSG_SW_RELOAD_START_RES:
-			sms_debug("MSG_SW_RELOAD_START_RES");
 			complete(&coredev->reload_start_done);
 			break;
 		case MSG_SMS_DATA_DOWNLOAD_RES:
 			complete(&coredev->data_download_done);
 			break;
 		case MSG_SW_RELOAD_EXEC_RES:
-			sms_debug("MSG_SW_RELOAD_EXEC_RES");
 			break;
 		case MSG_SMS_SWDOWNLOAD_TRIGGER_RES:
-			sms_debug("MSG_SMS_SWDOWNLOAD_TRIGGER_RES");
 			complete(&coredev->trigger_done);
 			break;
 		case MSG_SMS_SLEEP_RESUME_COMP_IND:
 			complete(&coredev->resume_done);
 			break;
 		case MSG_SMS_GPIO_CONFIG_EX_RES:
-			sms_debug("MSG_SMS_GPIO_CONFIG_EX_RES");
 			complete(&coredev->gpio_configuration_done);
 			break;
 		case MSG_SMS_GPIO_SET_LEVEL_RES:
-			sms_debug("MSG_SMS_GPIO_SET_LEVEL_RES");
 			complete(&coredev->gpio_set_level_done);
 			break;
 		case MSG_SMS_GPIO_GET_LEVEL_RES:
 		{
 			u32 *msgdata = (u32 *) phdr;
 			coredev->gpio_get_res = msgdata[1];
-			sms_debug("MSG_SMS_GPIO_GET_LEVEL_RES gpio level %d",
+			sms_debug("gpio level %d",
 					coredev->gpio_get_res);
 			complete(&coredev->gpio_get_level_done);
 			break;
@@ -1076,6 +1408,7 @@ void smscore_onresponse(struct smscore_device_t *coredev,
 			break;
 
 		default:
+			sms_debug("message not handled.\n");
 			break;
 		}
 		smscore_putbuffer(coredev, cb);
drivers/media/common/siano/smscoreapi.h +2 -0
index 4a0a763..0078fef 100644
@@ -937,6 +937,8 @@ struct smscore_config_gpio {
 	u8 outputdriving;
 };
 
+char *smscore_translate_msg(enum msg_types msgtype);
+
 extern void smscore_registry_setmode(char *devpath, int mode);
 extern int smscore_registry_getmode(char *devpath);
 
drivers/media/common/siano/smsdvb.c +1 -9
index aa77e54..57f3560 100644
@@ -249,20 +249,16 @@ static int smsdvb_onresponse(void *context, struct smscore_buffer_t *cb)
 		break;
 
 	case MSG_SMS_SIGNAL_DETECTED_IND:
-		sms_info("MSG_SMS_SIGNAL_DETECTED_IND");
 		client->sms_stat_dvb.TransmissionData.IsDemodLocked = true;
 		is_status_update = true;
 		break;
 
 	case MSG_SMS_NO_SIGNAL_IND:
-		sms_info("MSG_SMS_NO_SIGNAL_IND");
 		client->sms_stat_dvb.TransmissionData.IsDemodLocked = false;
 		is_status_update = true;
 		break;
 
 	case MSG_SMS_TRANSMISSION_IND: {
-		sms_info("MSG_SMS_TRANSMISSION_IND");
-
 		pMsgData++;
 		memcpy(&client->sms_stat_dvb.TransmissionData, pMsgData,
 				sizeof(struct TRANSMISSION_STATISTICS_S));
@@ -281,7 +277,6 @@ static int smsdvb_onresponse(void *context, struct smscore_buffer_t *cb)
 				&client->sms_stat_dvb.ReceptionData;
 		struct SRVM_SIGNAL_STATUS_S SignalStatusData;
 
-		/*sms_info("MSG_SMS_HO_PER_SLICES_IND");*/
 		pMsgData++;
 		SignalStatusData.result = pMsgData[0];
 		SignalStatusData.snr = pMsgData[1];
@@ -336,8 +331,6 @@ static int smsdvb_onresponse(void *context, struct smscore_buffer_t *cb)
 		struct RECEPTION_STATISTICS_S *pReceptionData =
 				&client->sms_stat_dvb.ReceptionData;
 
-		sms_info("MSG_SMS_GET_STATISTICS_RES");
-
 		is_status_update = true;
 
 		switch (smscore_get_device_mode(client->coredev)) {
@@ -360,8 +353,7 @@ static int smsdvb_onresponse(void *context, struct smscore_buffer_t *cb)
 		break;
 	}
 	default:
-		sms_info("Unhandled message %d", phdr->msgType);
-
+		sms_info("message not handled");
 	}
 	smscore_putbuffer(client->coredev, cb);
 
drivers/media/usb/siano/smsusb.c +9 -0
index de2c102..2050e4c 100644
@@ -106,6 +106,10 @@ static void smsusb_onresponse(struct urb *urb)
 			} else
 				surb->cb->offset = 0;
 
+			sms_debug("received %s(%d) size: %d",
+				  smscore_translate_msg(phdr->msgType),
+				  phdr->msgType, phdr->msgLength);
+
 			smscore_onresponse(dev->coredev, surb->cb);
 			surb->cb = NULL;
 		} else {
@@ -181,8 +185,13 @@ static int smsusb_start_streaming(struct smsusb_device_t *dev)
 static int smsusb_sendrequest(void *context, void *buffer, size_t size)
 {
 	struct smsusb_device_t *dev = (struct smsusb_device_t *) context;
+	struct SmsMsgHdr_ST *phdr = (struct SmsMsgHdr_ST *) buffer;
 	int dummy;
 
+	sms_debug("sending %s(%d) size: %d",
+		  smscore_translate_msg(phdr->msgType), phdr->msgType,
+		  phdr->msgLength);
+
 	smsendian_handle_message_header((struct SmsMsgHdr_ST *)buffer);
 	return usb_bulk_msg(dev->udev, usb_sndbulkpipe(dev->udev, 2),
 			    buffer, size, &dummy, 1000);
Signature · 1 line
1.8.1.4
#6 lore raw

PATCH 6/46 siano: add the remaining new defines from new driver

In reply to Mauro Carvalho Chehab

Add the remaining new defines/enums from Doron Cohen's patch:

        http://patchwork.linuxtv.org/patch/7882/
---
 drivers/media/common/siano/smscoreapi.h | 39 ++++++++++++++++++++++++++++-----
 1 file changed, 33 insertions(+), 6 deletions(-)
drivers/media/common/siano/smscoreapi.h +33 -6
index 0078fef..fc451e2 100644
@@ -50,18 +50,31 @@ along with this program.  If not, see <http://www.gnu.org/licenses/>.
 #define SMS_ALIGN_ADDRESS(addr) \
 	((((uintptr_t)(addr)) + (SMS_DMA_ALIGNMENT-1)) & ~(SMS_DMA_ALIGNMENT-1))
 
+#define SMS_DEVICE_FAMILY1				0
 #define SMS_DEVICE_FAMILY2				1
 #define SMS_ROM_NO_RESPONSE				2
 #define SMS_DEVICE_NOT_READY				0x8000000
 
 enum sms_device_type_st {
+	SMS_UNKNOWN_TYPE = -1,
 	SMS_STELLAR = 0,
 	SMS_NOVA_A0,
 	SMS_NOVA_B0,
 	SMS_VEGA,
+	SMS_VENICE,
+	SMS_MING,
+	SMS_PELE,
+	SMS_RIO,
+	SMS_DENVER_1530,
+	SMS_DENVER_2160,
 	SMS_NUM_OF_DEVICE_TYPES
 };
 
+enum sms_power_mode_st {
+	SMS_POWER_MODE_ACTIVE,
+	SMS_POWER_MODE_SUSPENDED
+};
+
 struct smscore_device_t;
 struct smscore_client_t;
 struct smscore_buffer_t;
@@ -176,18 +189,29 @@ struct smscore_device_t {
 #define SMS_ANTENNA_GPIO_0					1
 #define SMS_ANTENNA_GPIO_1					0
 
-#define BW_8_MHZ							0
-#define BW_7_MHZ							1
-#define BW_6_MHZ							2
-#define BW_5_MHZ							3
-#define BW_ISDBT_1SEG						4
-#define BW_ISDBT_3SEG						5
+enum sms_bandwidth_mode {
+	BW_8_MHZ = 0,
+	BW_7_MHZ = 1,
+	BW_6_MHZ = 2,
+	BW_5_MHZ = 3,
+	BW_ISDBT_1SEG = 4,
+	BW_ISDBT_3SEG = 5,
+	BW_2_MHZ = 6,
+	BW_FM_RADIO = 7,
+	BW_ISDBT_13SEG = 8,
+	BW_1_5_MHZ = 15,
+	BW_UNKNOWN = 0xffff
+};
+
 
 #define MSG_HDR_FLAG_SPLIT_MSG				4
 
 #define MAX_GPIO_PIN_NUMBER					31
 
 #define HIF_TASK							11
+#define HIF_TASK_SLAVE					22
+#define HIF_TASK_SLAVE2					33
+#define HIF_TASK_SLAVE3					44
 #define SMS_HOST_LIB						150
 #define DVBT_BDA_CONTROL_MSG_ID				201
 
@@ -545,6 +569,9 @@ enum SMS_DEVICE_MODE {
 	DEVICE_MODE_ISDBT_BDA,
 	DEVICE_MODE_CMMB,
 	DEVICE_MODE_RAW_TUNER,
+	DEVICE_MODE_FM_RADIO,
+	DEVICE_MODE_FM_RADIO_BDA,
+	DEVICE_MODE_ATSC,
 	DEVICE_MODE_MAX,
 };
 
Signature · 1 line
1.8.1.4
#7 lore raw

PATCH 7/46 siano: Properly initialize board information

In reply to Mauro Carvalho Chehab

Board #0 is an existing one. Instead of initializing the driver with it, use a different value to detect if board is unknown.

---
 drivers/media/common/siano/smscoreapi.c | 1 +
 1 file changed, 1 insertion(+)
drivers/media/common/siano/smscoreapi.c +1 -0
index 4c83d3c..7377c16 100644
@@ -723,6 +723,7 @@ int smscore_register_device(struct smsdevice_params_t *params,
 	sms_info("allocated %d buffers", dev->num_buffers);
 
 	dev->mode = DEVICE_MODE_NONE;
+	dev->board_id = SMS_BOARD_UNKNOWN;
 	dev->context = params->context;
 	dev->device = params->device;
 	dev->setmode_handler = params->setmode_handler;
Signature · 1 line
1.8.1.4
#8 lore raw

PATCH 8/46 siano: add additional attributes to cards entries

In reply to Mauro Carvalho Chehab

Those attributes will be used by the newer sms2xxx cards.

---
 drivers/media/common/siano/sms-cards.h | 6 ++++++
 1 file changed, 6 insertions(+)
drivers/media/common/siano/sms-cards.h +6 -0
index d8cdf75..60d26be 100644
@@ -79,6 +79,12 @@ struct sms_board {
 
 	/* gpios */
 	int led_power, led_hi, led_lo, lna_ctrl, rf_switch;
+
+	char intf_num;
+	int default_mode;
+	unsigned int mtu;
+	unsigned int crystal;
+	struct sms_antenna_config_ST* antenna_config;
 };
 
 struct sms_board *sms_get_board(unsigned id);
Signature · 1 line
1.8.1.4
#9 lore raw

PATCH 9/46 siano: use USB endpoint descriptors for in/out endp

In reply to Mauro Carvalho Chehab

Instead of using hardcoded descriptors, detect them from the USB descriptors.

This patch is rebased form Doron Cohen's patch:

	http://patchwork.linuxtv.org/patch/7883/
---
 drivers/media/usb/siano/smsusb.c | 99 +++++++++++++++++++++++++++++-----------
 1 file changed, 73 insertions(+), 26 deletions(-)
drivers/media/usb/siano/smsusb.c +73 -26
index 2050e4c..a31bf74 100644
@@ -35,16 +35,23 @@ module_param_named(debug, sms_dbg, int, 0644);
 MODULE_PARM_DESC(debug, "set debug level (info=1, adv=2 (or-able))");
 
 #define USB1_BUFFER_SIZE		0x1000
-#define USB2_BUFFER_SIZE		0x4000
+#define USB2_BUFFER_SIZE		0x2000
 
 #define MAX_BUFFERS		50
 #define MAX_URBS		10
 
 struct smsusb_device_t;
 
+enum smsusb_state {
+	SMSUSB_DISCONNECTED,
+	SMSUSB_SUSPENDED,
+	SMSUSB_ACTIVE
+};
+
 struct smsusb_urb_t {
+	struct list_head entry;
 	struct smscore_buffer_t *cb;
-	struct smsusb_device_t	*dev;
+	struct smsusb_device_t *dev;
 
 	struct urb urb;
 };
@@ -57,11 +64,23 @@ struct smsusb_device_t {
 
 	int		response_alignment;
 	int		buffer_size;
+
+	unsigned char in_ep;
+	unsigned char out_ep;
+	enum smsusb_state state;
 };
 
 static int smsusb_submit_urb(struct smsusb_device_t *dev,
 			     struct smsusb_urb_t *surb);
 
+/**
+ * Completing URB's callback handler - top half (interrupt context)
+ * adds completing sms urb to the global surbs list and activtes the worker
+ * thread the surb
+ * IMPORTANT - blocking functions must not be called from here !!!
+
+ * @param urb pointer to a completing urb object
+ */
 static void smsusb_onresponse(struct urb *urb)
 {
 	struct smsusb_urb_t *surb = (struct smsusb_urb_t *) urb->context;
@@ -140,7 +159,7 @@ static int smsusb_submit_urb(struct smsusb_device_t *dev,
 	usb_fill_bulk_urb(
 		&surb->urb,
 		dev->udev,
-		usb_rcvbulkpipe(dev->udev, 0x81),
+		usb_rcvbulkpipe(dev->udev, dev->in_ep),
 		surb->cb->p,
 		dev->buffer_size,
 		smsusb_onresponse,
@@ -192,6 +211,9 @@ static int smsusb_sendrequest(void *context, void *buffer, size_t size)
 		  smscore_translate_msg(phdr->msgType), phdr->msgType,
 		  phdr->msgLength);
 
+	if (dev->state != SMSUSB_ACTIVE)
+		return -ENOENT;
+
 	smsendian_handle_message_header((struct SmsMsgHdr_ST *)buffer);
 	return usb_bulk_msg(dev->udev, usb_sndbulkpipe(dev->udev, 2),
 			    buffer, size, &dummy, 1000);
@@ -301,13 +323,15 @@ static void smsusb_term_device(struct usb_interface *intf)
 	struct smsusb_device_t *dev = usb_get_intfdata(intf);
 
 	if (dev) {
+		dev->state = SMSUSB_DISCONNECTED;
+
 		smsusb_stop_streaming(dev);
 
 		/* unregister from smscore */
 		if (dev->coredev)
 			smscore_unregister_device(dev->coredev);
 
-		sms_info("device %p destroyed", dev);
+		sms_info("device 0x%p destroyed", dev);
 		kfree(dev);
 	}
 
@@ -330,6 +354,7 @@ static int smsusb_init_device(struct usb_interface *intf, int board_id)
 	memset(&params, 0, sizeof(params));
 	usb_set_intfdata(intf, dev);
 	dev->udev = interface_to_usbdev(intf);
+	dev->state = SMSUSB_DISCONNECTED;
 
 	params.device_type = sms_get_board(board_id)->type;
 
@@ -346,6 +371,8 @@ static int smsusb_init_device(struct usb_interface *intf, int board_id)
 	case SMS_NOVA_A0:
 	case SMS_NOVA_B0:
 	case SMS_VEGA:
+	case SMS_VENICE:
+	case SMS_DENVER_1530:
 		dev->buffer_size = USB2_BUFFER_SIZE;
 		dev->response_alignment =
 		    le16_to_cpu(dev->udev->ep_in[1]->desc.wMaxPacketSize) -
@@ -355,6 +382,16 @@ static int smsusb_init_device(struct usb_interface *intf, int board_id)
 		break;
 	}
 
+	for (i = 0; i < intf->cur_altsetting->desc.bNumEndpoints; i++) {
+		if (intf->cur_altsetting->endpoint[i].desc. bEndpointAddress & USB_DIR_IN)
+			dev->in_ep = intf->cur_altsetting->endpoint[i].desc.bEndpointAddress;
+		else
+			dev->out_ep = intf->cur_altsetting->endpoint[i].desc.bEndpointAddress;
+	}
+
+	sms_info("in_ep = %02x, out_ep = %02x",
+		dev->in_ep, dev->out_ep);
+
 	params.device = &dev->udev->dev;
 	params.buffer_size = dev->buffer_size;
 	params.num_buffers = MAX_BUFFERS;
@@ -386,6 +423,8 @@ static int smsusb_init_device(struct usb_interface *intf, int board_id)
 		return rc;
 	}
 
+	dev->state = SMSUSB_ACTIVE;
+
 	rc = smscore_start_device(dev->coredev);
 	if (rc < 0) {
 		sms_err("smscore_start_device(...) failed");
@@ -393,7 +432,7 @@ static int smsusb_init_device(struct usb_interface *intf, int board_id)
 		return rc;
 	}
 
-	sms_info("device %p created", dev);
+	sms_info("device 0x%p created", dev);
 
 	return rc;
 }
@@ -402,15 +441,23 @@ static int smsusb_probe(struct usb_interface *intf,
 			const struct usb_device_id *id)
 {
 	struct usb_device *udev = interface_to_usbdev(intf);
-	char devpath[32];
 	int i, rc;
 
-	rc = usb_clear_halt(udev, usb_rcvbulkpipe(udev, 0x81));
-	rc = usb_clear_halt(udev, usb_rcvbulkpipe(udev, 0x02));
+	sms_info("interface number %d",
+		 intf->cur_altsetting->desc.bInterfaceNumber);
 
-	if (intf->num_altsetting > 0) {
-		rc = usb_set_interface(
-			udev, intf->cur_altsetting->desc.bInterfaceNumber, 0);
+	if (sms_get_board(id->driver_info)->intf_num !=
+	    intf->cur_altsetting->desc.bInterfaceNumber) {
+		sms_err("interface number is %d expecting %d",
+			sms_get_board(id->driver_info)->intf_num,
+			intf->cur_altsetting->desc.bInterfaceNumber);
+		return -ENODEV;
+	}
+
+	if (intf->num_altsetting > 1) {
+		rc = usb_set_interface(udev,
+				       intf->cur_altsetting->desc.bInterfaceNumber,
+				       0);
 		if (rc < 0) {
 			sms_err("usb_set_interface failed, rc %d", rc);
 			return rc;
@@ -419,27 +466,25 @@ static int smsusb_probe(struct usb_interface *intf,
 
 	sms_info("smsusb_probe %d",
 	       intf->cur_altsetting->desc.bInterfaceNumber);
-	for (i = 0; i < intf->cur_altsetting->desc.bNumEndpoints; i++)
+	for (i = 0; i < intf->cur_altsetting->desc.bNumEndpoints; i++) {
 		sms_info("endpoint %d %02x %02x %d", i,
 		       intf->cur_altsetting->endpoint[i].desc.bEndpointAddress,
 		       intf->cur_altsetting->endpoint[i].desc.bmAttributes,
 		       intf->cur_altsetting->endpoint[i].desc.wMaxPacketSize);
-
+		if (intf->cur_altsetting->endpoint[i].desc.bEndpointAddress &
+		    USB_DIR_IN)
+			rc = usb_clear_halt(udev, usb_rcvbulkpipe(udev,
+				intf->cur_altsetting->endpoint[i].desc.bEndpointAddress));
+		else
+			rc = usb_clear_halt(udev, usb_sndbulkpipe(udev,
+				intf->cur_altsetting->endpoint[i].desc.bEndpointAddress));
+	}
 	if ((udev->actconfig->desc.bNumInterfaces == 2) &&
 	    (intf->cur_altsetting->desc.bInterfaceNumber == 0)) {
 		sms_err("rom interface 0 is not used");
 		return -ENODEV;
 	}
 
-	if (intf->cur_altsetting->desc.bInterfaceNumber == 1) {
-		snprintf(devpath, sizeof(devpath), "usb\\%d-%s",
-			 udev->bus->busnum, udev->devpath);
-		sms_info("stellar device was found.");
-		return smsusb1_load_firmware(
-				udev, smscore_registry_getmode(devpath),
-				id->driver_info);
-	}
-
 	rc = smsusb_init_device(intf, id->driver_info);
 	sms_info("rc %d", rc);
 	sms_board_load_modules(id->driver_info);
@@ -454,7 +499,9 @@ static void smsusb_disconnect(struct usb_interface *intf)
 static int smsusb_suspend(struct usb_interface *intf, pm_message_t msg)
 {
 	struct smsusb_device_t *dev = usb_get_intfdata(intf);
-	printk(KERN_INFO "%s: Entering status %d.\n", __func__, msg.event);
+	printk(KERN_INFO "%s  Entering status %d.\n", __func__, msg.event);
+	dev->state = SMSUSB_SUSPENDED;
+	/*smscore_set_power_mode(dev, SMS_POWER_MODE_SUSPENDED);*/
 	smsusb_stop_streaming(dev);
 	return 0;
 }
@@ -465,9 +512,9 @@ static int smsusb_resume(struct usb_interface *intf)
 	struct smsusb_device_t *dev = usb_get_intfdata(intf);
 	struct usb_device *udev = interface_to_usbdev(intf);
 
-	printk(KERN_INFO "%s: Entering.\n", __func__);
-	usb_clear_halt(udev, usb_rcvbulkpipe(udev, 0x81));
-	usb_clear_halt(udev, usb_rcvbulkpipe(udev, 0x02));
+	printk(KERN_INFO "%s  Entering.\n", __func__);
+	usb_clear_halt(udev, usb_rcvbulkpipe(udev, dev->in_ep));
+	usb_clear_halt(udev, usb_sndbulkpipe(udev, dev->out_ep));
 
 	for (i = 0; i < intf->cur_altsetting->desc.bNumEndpoints; i++)
 		printk(KERN_INFO "endpoint %d %02x %02x %d\n", i,
Signature · 1 line
1.8.1.4
#10 lore raw

PATCH 10/46 siano: store firmware version

In reply to Mauro Carvalho Chehab

As there are some changes that seem to be firmware-dependent, we need to store the firmware version, as we don't want to break support for existing cards that use a legacy (and sometimes custom) firmware.

---
 drivers/media/common/siano/smscoreapi.c | 2 ++
 drivers/media/common/siano/smscoreapi.h | 1 +
 2 files changed, 3 insertions(+)
drivers/media/common/siano/smscoreapi.c +2 -0
index 7377c16..0bfb429 100644
@@ -1360,6 +1360,8 @@ void smscore_onresponse(struct smscore_device_t *coredev,
 			coredev->mode = ver->FirmwareId == 255 ?
 				DEVICE_MODE_NONE : ver->FirmwareId;
 			coredev->modes_supported = ver->SupportedProtocols;
+			coredev->fw_version = ver->RomVersionMajor << 8 |
+					      ver->RomVersionMinor;
 
 			complete(&coredev->version_ex_done);
 			break;
drivers/media/common/siano/smscoreapi.h +1 -0
index fc451e2..f1440a5 100644
@@ -178,6 +178,7 @@ struct smscore_device_t {
 	/* Firmware */
 	u8 *fw_buf;
 	u32 fw_buf_size;
+	u16 fw_version;
 
 	/* Infrared (IR) */
 	struct ir_t ir;
Signature · 1 line
1.8.1.4
#11 lore raw

PATCH 11/46 siano: make load firmware logic to work with newer firmwares

In reply to Mauro Carvalho Chehab

There are new firmwares for sms2xxx devices. Change the firmware load logic to handle those newer firmwares and devices.

---
 drivers/media/common/siano/smscoreapi.c | 348 ++++++++++++++++++++------------
 drivers/media/common/siano/smscoreapi.h |   8 +-
 2 files changed, 220 insertions(+), 136 deletions(-)
drivers/media/common/siano/smscoreapi.c +214 -134
index 0bfb429..74a2cb5 100644
@@ -683,6 +683,7 @@ int smscore_register_device(struct smsdevice_params_t *params,
 	/* init completion events */
 	init_completion(&dev->version_ex_done);
 	init_completion(&dev->data_download_done);
+	init_completion(&dev->data_validity_done);
 	init_completion(&dev->trigger_done);
 	init_completion(&dev->init_device_done);
 	init_completion(&dev->reload_start_done);
@@ -753,7 +754,13 @@ EXPORT_SYMBOL_GPL(smscore_register_device);
 
 static int smscore_sendrequest_and_wait(struct smscore_device_t *coredev,
 		void *buffer, size_t size, struct completion *completion) {
-	int rc = coredev->sendrequest_handler(coredev->context, buffer, size);
+	int rc;
+
+	if (completion == NULL)
+		return -EINVAL;
+	init_completion(completion);
+
+	rc = coredev->sendrequest_handler(coredev->context, buffer, size);
 	if (rc < 0) {
 		sms_info("sendrequest returned error %d", rc);
 		return rc;
@@ -850,8 +857,9 @@ static int smscore_load_firmware_family2(struct smscore_device_t *coredev,
 					 void *buffer, size_t size)
 {
 	struct SmsFirmware_ST *firmware = (struct SmsFirmware_ST *) buffer;
-	struct SmsMsgHdr_ST *msg;
-	u32 mem_address;
+	struct SmsMsgData_ST4 *msg;
+	u32 mem_address,  calc_checksum = 0;
+	u32 i, *ptr;
 	u8 *payload = firmware->Payload;
 	int rc = 0;
 	firmware->StartAddress = le32_to_cpu(firmware->StartAddress);
@@ -874,34 +882,35 @@ static int smscore_load_firmware_family2(struct smscore_device_t *coredev,
 
 	if (coredev->mode != DEVICE_MODE_NONE) {
 		sms_debug("sending reload command.");
-		SMS_INIT_MSG(msg, MSG_SW_RELOAD_START_REQ,
+		SMS_INIT_MSG(&msg->xMsgHeader, MSG_SW_RELOAD_START_REQ,
 			     sizeof(struct SmsMsgHdr_ST));
 		rc = smscore_sendrequest_and_wait(coredev, msg,
-						  msg->msgLength,
+						  msg->xMsgHeader.msgLength,
 						  &coredev->reload_start_done);
+		if (rc < 0) {
+			sms_err("device reload failed, rc %d", rc);
+			goto exit_fw_download;
+		}
 		mem_address = *(u32 *) &payload[20];
 	}
 
+	for (i = 0, ptr = (u32 *)firmware->Payload; i < firmware->Length/4 ;
+	     i++, ptr++)
+		calc_checksum += *ptr;
+
 	while (size && rc >= 0) {
 		struct SmsDataDownload_ST *DataMsg =
 			(struct SmsDataDownload_ST *) msg;
 		int payload_size = min((int) size, SMS_MAX_PAYLOAD_SIZE);
 
-		SMS_INIT_MSG(msg, MSG_SMS_DATA_DOWNLOAD_REQ,
+		SMS_INIT_MSG(&msg->xMsgHeader, MSG_SMS_DATA_DOWNLOAD_REQ,
 			     (u16)(sizeof(struct SmsMsgHdr_ST) +
 				      sizeof(u32) + payload_size));
 
 		DataMsg->MemAddr = mem_address;
 		memcpy(DataMsg->Payload, payload, payload_size);
 
-		if ((coredev->device_flags & SMS_ROM_NO_RESPONSE) &&
-		    (coredev->mode == DEVICE_MODE_NONE))
-			rc = coredev->sendrequest_handler(
-				coredev->context, DataMsg,
-				DataMsg->xMsgHeader.msgLength);
-		else
-			rc = smscore_sendrequest_and_wait(
-				coredev, DataMsg,
+		rc = smscore_sendrequest_and_wait(coredev, DataMsg,
 				DataMsg->xMsgHeader.msgLength,
 				&coredev->data_download_done);
 
@@ -910,44 +919,65 @@ static int smscore_load_firmware_family2(struct smscore_device_t *coredev,
 		mem_address += payload_size;
 	}
 
-	if (rc >= 0) {
-		if (coredev->mode == DEVICE_MODE_NONE) {
-			struct SmsMsgData_ST *TriggerMsg =
-				(struct SmsMsgData_ST *) msg;
-
-			SMS_INIT_MSG(msg, MSG_SMS_SWDOWNLOAD_TRIGGER_REQ,
-				     sizeof(struct SmsMsgHdr_ST) +
-				     sizeof(u32) * 5);
-
-			TriggerMsg->msgData[0] = firmware->StartAddress;
-						/* Entry point */
-			TriggerMsg->msgData[1] = 5; /* Priority */
-			TriggerMsg->msgData[2] = 0x200; /* Stack size */
-			TriggerMsg->msgData[3] = 0; /* Parameter */
-			TriggerMsg->msgData[4] = 4; /* Task ID */
-
-			if (coredev->device_flags & SMS_ROM_NO_RESPONSE) {
-				rc = coredev->sendrequest_handler(
-					coredev->context, TriggerMsg,
-					TriggerMsg->xMsgHeader.msgLength);
-				msleep(100);
-			} else
-				rc = smscore_sendrequest_and_wait(
-					coredev, TriggerMsg,
+	if (rc < 0)
+		goto exit_fw_download;
+
+	sms_err("sending MSG_SMS_DATA_VALIDITY_REQ expecting 0x%x",
+		calc_checksum);
+	SMS_INIT_MSG(&msg->xMsgHeader, MSG_SMS_DATA_VALIDITY_REQ,
+			sizeof(msg->xMsgHeader) +
+			sizeof(u32) * 3);
+	msg->msgData[0] = firmware->StartAddress;
+		/* Entry point */
+	msg->msgData[1] = firmware->Length;
+	msg->msgData[2] = 0; /* Regular checksum*/
+	smsendian_handle_tx_message(msg);
+	rc = smscore_sendrequest_and_wait(coredev, msg,
+					  msg->xMsgHeader.msgLength,
+					  &coredev->data_validity_done);
+	if (rc < 0)
+		goto exit_fw_download;
+
+	if (coredev->mode == DEVICE_MODE_NONE) {
+		struct SmsMsgData_ST *TriggerMsg =
+			(struct SmsMsgData_ST *) msg;
+
+		sms_debug("sending MSG_SMS_SWDOWNLOAD_TRIGGER_REQ");
+		SMS_INIT_MSG(&msg->xMsgHeader,
+				MSG_SMS_SWDOWNLOAD_TRIGGER_REQ,
+				sizeof(struct SmsMsgHdr_ST) +
+				sizeof(u32) * 5);
+
+		TriggerMsg->msgData[0] = firmware->StartAddress;
+					/* Entry point */
+		TriggerMsg->msgData[1] = 6; /* Priority */
+		TriggerMsg->msgData[2] = 0x200; /* Stack size */
+		TriggerMsg->msgData[3] = 0; /* Parameter */
+		TriggerMsg->msgData[4] = 4; /* Task ID */
+
+		smsendian_handle_tx_message((struct SmsMsgHdr_S *)msg);
+		rc = smscore_sendrequest_and_wait(coredev, TriggerMsg,
 					TriggerMsg->xMsgHeader.msgLength,
 					&coredev->trigger_done);
-		} else {
-			SMS_INIT_MSG(msg, MSG_SW_RELOAD_EXEC_REQ,
-				     sizeof(struct SmsMsgHdr_ST));
-
-			rc = coredev->sendrequest_handler(coredev->context,
-							  msg, msg->msgLength);
-		}
-		msleep(500);
+	} else {
+		SMS_INIT_MSG(&msg->xMsgHeader, MSG_SW_RELOAD_EXEC_REQ,
+				sizeof(struct SmsMsgHdr_ST));
+		smsendian_handle_tx_message((struct SmsMsgHdr_S *)msg);
+		rc = coredev->sendrequest_handler(coredev->context, msg,
+				msg->xMsgHeader.msgLength);
 	}
 
-	sms_debug("rc=%d, postload=%p ", rc,
-		  coredev->postload_handler);
+	if (rc < 0)
+		goto exit_fw_download;
+
+	/*
+	 * backward compatibility - wait to device_ready_done for
+	 * not more than 400 ms
+	 */
+	msleep(400);
+
+exit_fw_download:
+	sms_debug("rc=%d, postload=0x%p ", rc, coredev->postload_handler);
 
 	kfree(msg);
 
@@ -956,6 +986,10 @@ static int smscore_load_firmware_family2(struct smscore_device_t *coredev,
 		rc;
 }
 
+
+static char *smscore_get_fw_filename(struct smscore_device_t *coredev,
+			      int mode, int lookup);
+
 /**
  * loads specified firmware into a buffer and calls device loadfirmware_handler
  *
@@ -967,41 +1001,43 @@ static int smscore_load_firmware_family2(struct smscore_device_t *coredev,
  * @return 0 on success, <0 on error.
  */
 static int smscore_load_firmware_from_file(struct smscore_device_t *coredev,
-					   char *filename,
+					   int mode, int lookup,
 					   loadfirmware_t loadfirmware_handler)
 {
 	int rc = -ENOENT;
+	u8 *fw_buf;
+	u32 fw_buf_size;
 	const struct firmware *fw;
-	u8 *fw_buffer;
 
-	if (loadfirmware_handler == NULL && !(coredev->device_flags &
-					      SMS_DEVICE_FAMILY2))
+	char *fw_filename = smscore_get_fw_filename(coredev, mode, lookup);
+	if (!strcmp(fw_filename, "none"))
+		return -ENOENT;
+
+	if (loadfirmware_handler == NULL && !(coredev->device_flags
+			& SMS_DEVICE_FAMILY2))
 		return -EINVAL;
 
-	rc = request_firmware(&fw, filename, coredev->device);
+	rc = request_firmware(&fw, fw_filename, coredev->device);
 	if (rc < 0) {
-		sms_info("failed to open \"%s\"", filename);
+		sms_info("failed to open \"%s\"", fw_filename);
 		return rc;
 	}
-	sms_info("read FW %s, size=%zd", filename, fw->size);
-	fw_buffer = kmalloc(ALIGN(fw->size, SMS_ALLOC_ALIGNMENT),
-			    GFP_KERNEL | GFP_DMA);
-	if (fw_buffer) {
-		memcpy(fw_buffer, fw->data, fw->size);
-
-		rc = (coredev->device_flags & SMS_DEVICE_FAMILY2) ?
-		      smscore_load_firmware_family2(coredev,
-						    fw_buffer,
-						    fw->size) :
-		      loadfirmware_handler(coredev->context,
-					   fw_buffer, fw->size);
-
-		kfree(fw_buffer);
-	} else {
+	sms_info("read fw %s, buffer size=0x%zx", fw_filename, fw->size);
+	fw_buf = kmalloc(ALIGN(fw->size, SMS_ALLOC_ALIGNMENT),
+			 GFP_KERNEL | GFP_DMA);
+	if (!fw_buf) {
 		sms_info("failed to allocate firmware buffer");
-		rc = -ENOMEM;
+		return -ENOMEM;
 	}
+	memcpy(fw_buf, fw->data, fw->size);
+	fw_buf_size = fw->size;
+
+	rc = (coredev->device_flags & SMS_DEVICE_FAMILY2) ?
+		smscore_load_firmware_family2(coredev, fw_buf, fw_buf_size)
+		: loadfirmware_handler(coredev->context, fw_buf,
+		fw_buf_size);
 
+	kfree(fw_buf);
 	release_firmware(fw);
 
 	return rc;
@@ -1050,7 +1086,9 @@ void smscore_unregister_device(struct smscore_device_t *coredev)
 
 		sms_info("waiting for %d buffer(s)",
 			 coredev->num_buffers - num_buffers);
+		kmutex_unlock(&g_smscore_deviceslock);
 		msleep(100);
+		kmutex_lock(&g_smscore_deviceslock);
 	}
 
 	sms_info("freed %d buffers", num_buffers);
@@ -1108,30 +1146,73 @@ static int smscore_detect_mode(struct smscore_device_t *coredev)
 }
 
 static char *smscore_fw_lkup[][SMS_NUM_OF_DEVICE_TYPES] = {
-	/*Stellar		NOVA A0		Nova B0		VEGA*/
-	/*DVBT*/
-	{"none", "dvb_nova_12mhz.inp", "dvb_nova_12mhz_b0.inp", "none"},
-	/*DVBH*/
-	{"none", "dvb_nova_12mhz.inp", "dvb_nova_12mhz_b0.inp", "none"},
-	/*TDMB*/
-	{"none", "tdmb_nova_12mhz.inp", "tdmb_nova_12mhz_b0.inp", "none"},
-	/*DABIP*/
-	{"none", "none", "none", "none"},
-	/*BDA*/
-	{"none", "dvb_nova_12mhz.inp", "dvb_nova_12mhz_b0.inp", "none"},
-	/*ISDBT*/
-	{"none", "isdbt_nova_12mhz.inp", "isdbt_nova_12mhz_b0.inp", "none"},
-	/*ISDBTBDA*/
-	{"none", "isdbt_nova_12mhz.inp", "isdbt_nova_12mhz_b0.inp", "none"},
-	/*CMMB*/
-	{"none", "none", "none", "cmmb_vega_12mhz.inp"}
+	/*Stellar, NOVA A0, Nova B0, VEGA, VENICE, MING, PELE, RIO, DENVER_1530, DENVER_2160 */
+		/*DVBT*/
+	{ "none", "dvb_nova_12mhz.inp", "dvb_nova_12mhz_b0.inp", "none", "none", "none", "none", "dvb_rio.inp", "none", "none" },
+		/*DVBH*/
+	{ "none", "dvb_nova_12mhz.inp", "dvb_nova_12mhz_b0.inp", "none", "none", "none", "none", "dvbh_rio.inp", "none", "none" },
+		/*TDMB*/
+	{ "none", "tdmb_nova_12mhz.inp", "tdmb_nova_12mhz_b0.inp", "none", "none", "none", "none", "none", "none", "tdmb_denver.inp" },
+		/*DABIP*/
+	{ "none", "none", "none", "none", "none", "none", "none", "none", "none", "none" },
+		/*DVBT_BDA*/
+	{ "none", "dvb_nova_12mhz.inp", "dvb_nova_12mhz_b0.inp", "none", "none", "none", "none", "dvb_rio.inp", "none", "none" },
+		/*ISDBT*/
+	{ "none", "isdbt_nova_12mhz.inp", "isdbt_nova_12mhz_b0.inp", "none", "none", "none", "isdbt_pele.inp", "isdbt_rio.inp", "none", "none" },
+		/*ISDBT_BDA*/
+	{ "none", "isdbt_nova_12mhz.inp", "isdbt_nova_12mhz_b0.inp", "none", "none", "none", "isdbt_pele.inp", "isdbt_rio.inp", "none", "none" },
+		/*CMMB*/
+	{ "none", "none", "none", "cmmb_vega_12mhz.inp", "cmmb_venice_12mhz.inp", "cmmb_ming_app.inp", "none", "none", "none", 	"none" },
+		/*RAW - not supported*/
+	{ "none", "none", "none", "none", "none", "none", "none", "none", "none", "none" },
+		/*FM*/
+	{ "none", "none", "fm_radio.inp", "none", "none", "none", "none", "fm_radio_rio.inp", "none", "none" },
+		/*FM_BDA*/
+	{ "none", "none", "fm_radio.inp", "none", "none", "none", "none", "fm_radio_rio.inp", "none", "none" },
+		/*ATSC*/
+	{ "none", "none", "none", "none", "none", "none", "none", "none", "atsc_denver.inp", "none" }
 };
 
-static inline char *sms_get_fw_name(struct smscore_device_t *coredev,
-				    int mode, enum sms_device_type_st type)
+/**
+ * get firmware file name from one of the two mechanisms : sms_boards or
+ * smscore_fw_lkup.
+ * @param coredev pointer to a coredev object returned by
+ *		  smscore_register_device
+ * @param mode requested mode of operation
+ * @param lookup if 1, always get the fw filename from smscore_fw_lkup
+ *	 table. if 0, try first to get from sms_boards
+ *
+ * @return 0 on success, <0 on error.
+ */
+static char *smscore_get_fw_filename(struct smscore_device_t *coredev,
+			      int mode, int lookup)
 {
-	char **fw = sms_get_board(smscore_get_board_id(coredev))->fw;
-	return (fw && fw[mode]) ? fw[mode] : smscore_fw_lkup[mode][type];
+	char **fw;
+	int board_id = smscore_get_board_id(coredev);
+	enum sms_device_type_st type = smscore_registry_gettype(coredev->devpath);
+
+	if ((board_id == SMS_BOARD_UNKNOWN) || (lookup == 1)) {
+		sms_debug("trying to get fw name from lookup table mode %d type %d",
+			  mode, type);
+		return smscore_fw_lkup[mode][type];
+	}
+
+	sms_debug("trying to get fw name from sms_boards board_id %d mode %d",
+		  board_id, mode);
+	fw = sms_get_board(board_id)->fw;
+	if (fw == NULL) {
+		sms_debug("cannot find fw name in sms_boards, getting from lookup table mode %d type %d",
+			  mode, type);
+		return smscore_fw_lkup[mode][type];
+	}
+
+	if (fw[mode] == NULL) {
+		sms_debug("cannot find fw name in sms_boards, getting from lookup table mode %d type %d",
+			  mode, type);
+		return smscore_fw_lkup[mode][type];
+	}
+
+	return fw[mode];
 }
 
 /**
@@ -1146,9 +1227,7 @@ static inline char *sms_get_fw_name(struct smscore_device_t *coredev,
  */
 int smscore_set_device_mode(struct smscore_device_t *coredev, int mode)
 {
-	void *buffer;
 	int rc = 0;
-	enum sms_device_type_st type;
 
 	sms_debug("set device mode to %d", mode);
 	if (coredev->device_flags & SMS_DEVICE_FAMILY2) {
@@ -1173,55 +1252,30 @@ int smscore_set_device_mode(struct smscore_device_t *coredev, int mode)
 		}
 
 		if (!(coredev->modes_supported & (1 << mode))) {
-			char *fw_filename;
-
-			type = smscore_registry_gettype(coredev->devpath);
-			fw_filename = sms_get_fw_name(coredev, mode, type);
-
 			rc = smscore_load_firmware_from_file(coredev,
-							     fw_filename, NULL);
-			if (rc < 0) {
-				sms_warn("error %d loading firmware: %s, "
-					 "trying again with default firmware",
-					 rc, fw_filename);
+							     mode, 0, NULL);
 
-				/* try again with the default firmware */
-				fw_filename = smscore_fw_lkup[mode][type];
+			/*
+			* try again with the default firmware -
+			* get the fw filename from look-up table
+			*/
+			if (rc < 0) {
+				sms_debug("error %d loading firmware, trying again with default firmware",
+					  rc);
 				rc = smscore_load_firmware_from_file(coredev,
-							     fw_filename, NULL);
-
+								     mode, 1,
+								     NULL);
 				if (rc < 0) {
-					sms_warn("error %d loading "
-						 "firmware: %s", rc,
-						 fw_filename);
+					sms_debug("error %d loading firmware",
+						  rc);
 					return rc;
 				}
 			}
-			sms_log("firmware download success: %s", fw_filename);
-		} else
-			sms_info("mode %d supported by running "
-				 "firmware", mode);
-
-		buffer = kmalloc(sizeof(struct SmsMsgData_ST) +
-				 SMS_DMA_ALIGNMENT, GFP_KERNEL | GFP_DMA);
-		if (buffer) {
-			struct SmsMsgData_ST *msg =
-				(struct SmsMsgData_ST *)
-					SMS_ALIGN_ADDRESS(buffer);
-
-			SMS_INIT_MSG(&msg->xMsgHeader, MSG_SMS_INIT_DEVICE_REQ,
-				     sizeof(struct SmsMsgData_ST));
-			msg->msgData[0] = mode;
-
-			rc = smscore_sendrequest_and_wait(
-				coredev, msg, msg->xMsgHeader.msgLength,
-				&coredev->init_device_done);
-
-			kfree(buffer);
+			if (rc >= 0)
+				sms_info("firmware download success");
 		} else {
-			sms_err("Could not allocate buffer for "
-				"init device message.");
-			rc = -ENOMEM;
+			sms_info("mode %d is already supported by running firmware",
+				 mode);
 		}
 	} else {
 		if (mode < DEVICE_MODE_DVBT || mode > DEVICE_MODE_DVBT_BDA) {
@@ -1240,8 +1294,25 @@ int smscore_set_device_mode(struct smscore_device_t *coredev, int mode)
 	}
 
 	if (rc >= 0) {
+		char *buffer;
 		coredev->mode = mode;
 		coredev->device_flags &= ~SMS_DEVICE_NOT_READY;
+
+		buffer = kmalloc(sizeof(struct SmsMsgData_ST) +
+				 SMS_DMA_ALIGNMENT, GFP_KERNEL | GFP_DMA);
+		if (buffer) {
+			struct SmsMsgData_ST *msg =(struct SmsMsgData_ST *) SMS_ALIGN_ADDRESS(buffer);
+
+			SMS_INIT_MSG(&msg->xMsgHeader, MSG_SMS_INIT_DEVICE_REQ,
+				     sizeof(struct SmsMsgData_ST));
+			msg->msgData[0] = mode;
+
+			rc = smscore_sendrequest_and_wait(
+				coredev, msg, msg->xMsgHeader.msgLength,
+				&coredev->init_device_done);
+
+			kfree(buffer);
+		}
 	}
 
 	if (rc < 0)
@@ -1372,6 +1443,15 @@ void smscore_onresponse(struct smscore_device_t *coredev,
 		case MSG_SW_RELOAD_START_RES:
 			complete(&coredev->reload_start_done);
 			break;
+		case MSG_SMS_DATA_VALIDITY_RES:
+		{
+			struct SmsMsgData_ST *validity = (struct SmsMsgData_ST *) phdr;
+
+			sms_err("MSG_SMS_DATA_VALIDITY_RES, checksum = 0x%x",
+				validity->msgData[0]);
+			complete(&coredev->data_validity_done);
+			break;
+		}
 		case MSG_SMS_DATA_DOWNLOAD_RES:
 			complete(&coredev->data_download_done);
 			break;
drivers/media/common/siano/smscoreapi.h +6 -2
index f1440a5..91db853 100644
@@ -162,6 +162,7 @@ struct smscore_device_t {
 
 	/* host <--> device messages */
 	struct completion version_ex_done, data_download_done, trigger_done;
+	struct completion data_validity_done, device_ready_done;
 	struct completion init_device_done, reload_start_done, resume_done;
 	struct completion gpio_configuration_done, gpio_set_level_done;
 	struct completion gpio_get_level_done, ir_init_done;
@@ -594,6 +595,11 @@ struct SmsMsgData_ST2 {
 	u32 msgData[2];
 };
 
+struct SmsMsgData_ST4 {
+	struct SmsMsgHdr_ST xMsgHeader;
+	u32 msgData[4];
+};
+
 struct SmsDataDownload_ST {
 	struct SmsMsgHdr_ST	xMsgHeader;
 	u32			MemAddr;
@@ -998,8 +1004,6 @@ extern void smscore_onresponse(struct smscore_device_t *coredev,
 extern int smscore_get_common_buffer_size(struct smscore_device_t *coredev);
 extern int smscore_map_common_buffer(struct smscore_device_t *coredev,
 				      struct vm_area_struct *vma);
-extern int smscore_get_fw_filename(struct smscore_device_t *coredev,
-				   int mode, char *filename);
 extern int smscore_send_fw_file(struct smscore_device_t *coredev,
 				u8 *ufwbuf, int size);
 
Signature · 1 line
1.8.1.4
#12 lore raw

PATCH 12/46 siano: report the choosed firmware in debug

In reply to Mauro Carvalho Chehab

Don't keep in the dark: report the firmware file name after lookup. That helps to debug what's happening when a firmware is not found.

---
 drivers/media/common/siano/smscoreapi.c | 1 +
 1 file changed, 1 insertion(+)
drivers/media/common/siano/smscoreapi.c +1 -0
index 74a2cb5..250fe37 100644
@@ -1010,6 +1010,7 @@ static int smscore_load_firmware_from_file(struct smscore_device_t *coredev,
 	const struct firmware *fw;
 
 	char *fw_filename = smscore_get_fw_filename(coredev, mode, lookup);
+	sms_debug("Firmware name: %s\n", fw_filename);
 	if (!strcmp(fw_filename, "none"))
 		return -ENOENT;
 
Signature · 1 line
1.8.1.4
#13 lore raw

PATCH 13/46 siano: fix the debug message

In reply to Mauro Carvalho Chehab

Instead of displaying this:

	[   61.869415] smscore_load_firmware_family2: rc=0, postload=0x          (null)

Display, instead:

	[ 1348.441160] smscore_load_firmware_family2: rc=0
---
 drivers/media/common/siano/smscoreapi.c | 13 ++++++++-----
 1 file changed, 8 insertions(+), 5 deletions(-)
drivers/media/common/siano/smscoreapi.c +8 -5
index 250fe37..d5883bb 100644
@@ -977,13 +977,16 @@ static int smscore_load_firmware_family2(struct smscore_device_t *coredev,
 	msleep(400);
 
 exit_fw_download:
-	sms_debug("rc=%d, postload=0x%p ", rc, coredev->postload_handler);
-
 	kfree(msg);
 
-	return ((rc >= 0) && coredev->postload_handler) ?
-		coredev->postload_handler(coredev->context) :
-		rc;
+	if (coredev->postload_handler) {
+		sms_debug("rc=%d, postload=0x%p", rc, coredev->postload_handler);
+		if (rc >= 0)
+			return coredev->postload_handler(coredev->context);
+	}
+
+	sms_debug("rc=%d", rc);
+	return rc;
 }
 
 
Signature · 1 line
1.8.1.4
#14 lore raw

PATCH 14/46 siano: always load smsdvb

In reply to Mauro Carvalho Chehab

Without smsdvb, the driver actually does nothing, as it lacks the userspace API.

While I wrote it independently, in order to make a sms2270 board I have here to work, this patch is functionally identical to this patch from Doron Cohen:

	http://patchwork.linuxtv.org/patch/7894/
---
 drivers/media/common/siano/sms-cards.c | 14 +-------------
 1 file changed, 1 insertion(+), 13 deletions(-)
drivers/media/common/siano/sms-cards.c +1 -13
index b22b61d..04bb04c 100644
@@ -293,19 +293,7 @@ EXPORT_SYMBOL_GPL(sms_board_lna_control);
 
 int sms_board_load_modules(int id)
 {
-	switch (id) {
-	case SMS1XXX_BOARD_HAUPPAUGE_CATAMOUNT:
-	case SMS1XXX_BOARD_HAUPPAUGE_OKEMO_A:
-	case SMS1XXX_BOARD_HAUPPAUGE_OKEMO_B:
-	case SMS1XXX_BOARD_HAUPPAUGE_WINDHAM:
-	case SMS1XXX_BOARD_HAUPPAUGE_TIGER_MINICARD:
-	case SMS1XXX_BOARD_HAUPPAUGE_TIGER_MINICARD_R2:
-		request_module("smsdvb");
-		break;
-	default:
-		/* do nothing */
-		break;
-	}
+	request_module("smsdvb");
 	return 0;
 }
 EXPORT_SYMBOL_GPL(sms_board_load_modules);
Signature · 1 line
1.8.1.4
#15 lore raw

PATCH 15/46 siano: cleanups at smscoreapi.c

In reply to Mauro Carvalho Chehab

Some cleanups at smscoreapi. Most are just CodingStyle.

Also, use kzalloc when allocating a new buffer, as it initializes the allocated space with zero.

---
 drivers/media/common/siano/smscoreapi.c | 25 ++++++++++++++++---------
 drivers/media/common/siano/smscoreapi.h |  1 -
 2 files changed, 16 insertions(+), 10 deletions(-)
drivers/media/common/siano/smscoreapi.c +16 -9
index d5883bb..d928c22 100644
@@ -490,10 +490,10 @@ static enum sms_device_type_st smscore_registry_gettype(char *devpath)
 	else
 		sms_err("No registry found.");
 
-	return -1;
+	return -EINVAL;
 }
 
-void smscore_registry_setmode(char *devpath, int mode)
+static void smscore_registry_setmode(char *devpath, int mode)
 {
 	struct smscore_registry_entry_t *entry;
 
@@ -633,10 +633,11 @@ static struct
 smscore_buffer_t *smscore_createbuffer(u8 *buffer, void *common_buffer,
 				       dma_addr_t common_buffer_phys)
 {
-	struct smscore_buffer_t *cb =
-		kmalloc(sizeof(struct smscore_buffer_t), GFP_KERNEL);
+	struct smscore_buffer_t *cb;
+
+	cb = kzalloc(sizeof(struct smscore_buffer_t), GFP_KERNEL);
 	if (!cb) {
-		sms_info("kmalloc(...) failed");
+		sms_info("kzalloc(...) failed");
 		return NULL;
 	}
 
@@ -710,9 +711,10 @@ int smscore_register_device(struct smsdevice_params_t *params,
 	for (buffer = dev->common_buffer;
 	     dev->num_buffers < params->num_buffers;
 	     dev->num_buffers++, buffer += params->buffer_size) {
-		struct smscore_buffer_t *cb =
-			smscore_createbuffer(buffer, dev->common_buffer,
-					     dev->common_buffer_phys);
+		struct smscore_buffer_t *cb;
+
+		cb = smscore_createbuffer(buffer, dev->common_buffer,
+					  dev->common_buffer_phys);
 		if (!cb) {
 			smscore_unregister_device(dev);
 			return -ENOMEM;
@@ -1193,7 +1195,9 @@ static char *smscore_get_fw_filename(struct smscore_device_t *coredev,
 {
 	char **fw;
 	int board_id = smscore_get_board_id(coredev);
-	enum sms_device_type_st type = smscore_registry_gettype(coredev->devpath);
+	enum sms_device_type_st type;
+
+	type = smscore_registry_gettype(coredev->devpath);
 
 	if ((board_id == SMS_BOARD_UNKNOWN) || (lookup == 1)) {
 		sms_debug("trying to get fw name from lookup table mode %d type %d",
@@ -1321,6 +1325,9 @@ int smscore_set_device_mode(struct smscore_device_t *coredev, int mode)
 
 	if (rc < 0)
 		sms_err("return error code %d.", rc);
+	else
+		sms_debug("Success setting device mode.");
+
 	return rc;
 }
 
drivers/media/common/siano/smscoreapi.h +0 -1
index 91db853..8af94c4 100644
@@ -973,7 +973,6 @@ struct smscore_config_gpio {
 
 char *smscore_translate_msg(enum msg_types msgtype);
 
-extern void smscore_registry_setmode(char *devpath, int mode);
 extern int smscore_registry_getmode(char *devpath);
 
 extern int smscore_register_hotplug(hotplug_t hotplug);
Signature · 1 line
1.8.1.4
#16 lore raw

PATCH 16/46 siano: add some new messages to the smscoreapi

In reply to Mauro Carvalho Chehab

Based on Doron Cohen's patch:

	http://patchwork.linuxtv.org/patch/7887/
---
 drivers/media/common/siano/smscoreapi.c | 16 ++++++++++++++++
 1 file changed, 16 insertions(+)
drivers/media/common/siano/smscoreapi.c +16 -0
index d928c22..6e60c99 100644
@@ -1430,7 +1430,23 @@ void smscore_onresponse(struct smscore_device_t *coredev,
 		rc = client->onresponse_handler(client->context, cb);
 
 	if (rc < 0) {
+		smsendian_handle_rx_message((struct SmsMsgData_ST *)phdr);
+
 		switch (phdr->msgType) {
+		case MSG_SMS_ISDBT_TUNE_RES:
+			break;
+		case MSG_SMS_RF_TUNE_RES:
+			break;
+		case MSG_SMS_SIGNAL_DETECTED_IND:
+			break;
+		case MSG_SMS_NO_SIGNAL_IND:
+			break;
+		case MSG_SMS_SPI_INT_LINE_SET_RES:
+			break;
+		case MSG_SMS_INTERFACE_LOCK_IND:
+			break;
+		case MSG_SMS_INTERFACE_UNLOCK_IND:
+			break;
 		case MSG_SMS_GET_VERSION_EX_RES:
 		{
 			struct SmsVersionRes_ST *ver =
Signature · 1 line
1.8.1.4
#17 lore raw

PATCH 17/46 siano: use a separate completion for stats

In reply to Mauro Carvalho Chehab

Instead of re-use tune_done also for stats, the better is to use a different completion.

Also, it was noticed that sometimes, the driver answers with MSG_SMS_SIGNAL_DETECTED_IND for status request. Fix the code to also handle those other signal indicators.

---
 drivers/media/common/siano/smsdvb.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)
drivers/media/common/siano/smsdvb.c +4 -2
index 57f3560..f4fd670 100644
@@ -48,6 +48,7 @@ struct smsdvb_client_t {
 	fe_status_t             fe_status;
 
 	struct completion       tune_done;
+	struct completion       stats_done;
 
 	struct SMSHOSTLIB_STATISTICS_DVB_S sms_stat_dvb;
 	int event_fe_state;
@@ -349,7 +350,6 @@ static int smsdvb_onresponse(void *context, struct smscore_buffer_t *cb)
 			pReceptionData->ErrorTSPackets = 0;
 		}
 
-		complete(&client->tune_done);
 		break;
 	}
 	default:
@@ -376,6 +376,7 @@ static int smsdvb_onresponse(void *context, struct smscore_buffer_t *cb)
 				client->fe_status = 0;
 			sms_board_dvb3_event(client, DVB3_EVENT_FE_UNLOCK);
 		}
+		complete(&client->stats_done);
 	}
 
 	return 0;
@@ -471,7 +472,7 @@ static int smsdvb_send_statistics_request(struct smsdvb_client_t *client)
 				    sizeof(struct SmsMsgHdr_ST), 0 };
 
 	rc = smsdvb_sendrequest_and_wait(client, &Msg, sizeof(Msg),
-					  &client->tune_done);
+					 &client->stats_done);
 
 	return rc;
 }
@@ -1002,6 +1003,7 @@ static int smsdvb_hotplug(struct smscore_device_t *coredev,
 	client->coredev = coredev;
 
 	init_completion(&client->tune_done);
+	init_completion(&client->stats_done);
 
 	kmutex_lock(&g_smsdvb_clientslock);
 
Signature · 1 line
1.8.1.4
#18 lore raw

PATCH 18/46 siano: add support for ISDB-T full-seg

In reply to Mauro Carvalho Chehab

Fix the DVBv5 API handling for ISDB-T and add support for 13 segments.

---
 drivers/media/common/siano/smsdvb.c | 46 ++++++++++++++-----------------------
 1 file changed, 17 insertions(+), 29 deletions(-)
drivers/media/common/siano/smsdvb.c +17 -29
index f4fd670..4900aa9 100644
@@ -652,6 +652,9 @@ static int smsdvb_isdbt_set_frontend(struct dvb_frontend *fe)
 	struct dtv_frontend_properties *c = &fe->dtv_property_cache;
 	struct smsdvb_client_t *client =
 		container_of(fe, struct smsdvb_client_t, frontend);
+	int board_id = smscore_get_board_id(client->coredev);
+	struct sms_board *board = sms_get_board(board_id);
+	enum sms_device_type_st type = board->type;
 
 	struct {
 		struct SmsMsgHdr_ST	Msg;
@@ -669,40 +672,25 @@ static int smsdvb_isdbt_set_frontend(struct dvb_frontend *fe)
 	if (c->isdbt_sb_segment_idx == -1)
 		c->isdbt_sb_segment_idx = 0;
 
-	switch (c->isdbt_sb_segment_count) {
-	case 3:
-		Msg.Data[1] = BW_ISDBT_3SEG;
-		break;
-	case 1:
-		Msg.Data[1] = BW_ISDBT_1SEG;
-		break;
-	case 0:	/* AUTO */
-		switch (c->bandwidth_hz / 1000000) {
-		case 8:
-		case 7:
-			c->isdbt_sb_segment_count = 3;
-			Msg.Data[1] = BW_ISDBT_3SEG;
-			break;
-		case 6:
-			c->isdbt_sb_segment_count = 1;
-			Msg.Data[1] = BW_ISDBT_1SEG;
-			break;
-		default: /* Assumes 6 MHZ bw */
-			c->isdbt_sb_segment_count = 1;
-			c->bandwidth_hz = 6000;
-			Msg.Data[1] = BW_ISDBT_1SEG;
-			break;
-		}
-		break;
-	default:
-		sms_info("Segment count %d not supported", c->isdbt_sb_segment_count);
-		return -EINVAL;
-	}
+	if (!c->isdbt_layer_enabled)
+		c->isdbt_layer_enabled = 7;
 
 	Msg.Data[0] = c->frequency;
+	Msg.Data[1] = BW_ISDBT_1SEG;
 	Msg.Data[2] = 12000000;
 	Msg.Data[3] = c->isdbt_sb_segment_idx;
 
+	if (c->isdbt_partial_reception) {
+		if ((type == SMS_PELE || type == SMS_RIO) &&
+		    c->isdbt_sb_segment_count > 3)
+			Msg.Data[1] = BW_ISDBT_13SEG;
+		else if (c->isdbt_sb_segment_count > 1)
+			Msg.Data[1] = BW_ISDBT_3SEG;
+	} else if (type == SMS_PELE || type == SMS_RIO)
+		Msg.Data[1] = BW_ISDBT_13SEG;
+
+	c->bandwidth_hz = 6000000;
+
 	sms_info("%s: freq %d segwidth %d segindex %d\n", __func__,
 		 c->frequency, c->isdbt_sb_segment_count,
 		 c->isdbt_sb_segment_idx);
Signature · 1 line
1.8.1.4
#19 lore raw

PATCH 19/46 siano: add support for LNA on ISDB-T

In reply to Mauro Carvalho Chehab

The very same code also exists for DVB-T. Add it for ISDB-T.

---
 drivers/media/common/siano/smsdvb.c | 19 ++++++++++++++++++-
 1 file changed, 18 insertions(+), 1 deletion(-)
drivers/media/common/siano/smsdvb.c +18 -1
index 4900aa9..864f53e 100644
@@ -655,7 +655,7 @@ static int smsdvb_isdbt_set_frontend(struct dvb_frontend *fe)
 	int board_id = smscore_get_board_id(client->coredev);
 	struct sms_board *board = sms_get_board(board_id);
 	enum sms_device_type_st type = board->type;
-
+	int ret;
 	struct {
 		struct SmsMsgHdr_ST	Msg;
 		u32		Data[4];
@@ -695,6 +695,23 @@ static int smsdvb_isdbt_set_frontend(struct dvb_frontend *fe)
 		 c->frequency, c->isdbt_sb_segment_count,
 		 c->isdbt_sb_segment_idx);
 
+	/* Disable LNA, if any. An error is returned if no LNA is present */
+	ret = sms_board_lna_control(client->coredev, 0);
+	if (ret == 0) {
+		fe_status_t status;
+
+		/* tune with LNA off at first */
+		ret = smsdvb_sendrequest_and_wait(client, &Msg, sizeof(Msg),
+						  &client->tune_done);
+
+		smsdvb_read_status(fe, &status);
+
+		if (status & FE_HAS_LOCK)
+			return ret;
+
+		/* previous tune didn't lock - enable LNA and tune again */
+		sms_board_lna_control(client->coredev, 1);
+	}
 	return smsdvb_sendrequest_and_wait(client, &Msg, sizeof(Msg),
 					   &client->tune_done);
 }
Signature · 1 line
1.8.1.4
#20 lore raw

PATCH 20/46 siano: use the newer stats message for recent firmwares

In reply to Mauro Carvalho Chehab

The old statistics request don't work with newer firmwares. Add a logic to use the newer stats if firmware major is 8.

Note that I have only 2 devices here, one with firmware 2.1 (Hauppauge model 55009 Rev B1F7) and another one with firmware 8.1. We may need to adjust the firmware minimal version for the *_EX message variants, as we start finding firmware versions between 2.x and 8.x.

This patch was based on Doron Cohen patch:

	http://patchwork.linuxtv.org/patch/7886/
---
 drivers/media/common/siano/smscoreapi.h | 103 +++++++++++++++++++
 drivers/media/common/siano/smsdvb.c     | 177 ++++++++++++++++++++++++++++----
 2 files changed, 260 insertions(+), 20 deletions(-)
drivers/media/common/siano/smscoreapi.h +103 -0
index 8af94c4..7925c04 100644
@@ -800,6 +800,66 @@ struct SMSHOSTLIB_STATISTICS_ISDBT_ST {
 	u32 SmsToHostTxErrors; /* Total number of transmission errors. */
 };
 
+struct SMSHOSTLIB_STATISTICS_ISDBT_EX_ST {
+	u32 StatisticsType; /* Enumerator identifying the type of the
+				* structure.  Values are the same as
+				* SMSHOSTLIB_DEVICE_MODES_E
+				*
+				* This field MUST always be first in any
+				* statistics structure */
+
+	u32 FullSize; /* Total size of the structure returned by the modem.
+		       * If the size requested by the host is smaller than
+		       * FullSize, the struct will be truncated */
+
+	/* Common parameters */
+	u32 IsRfLocked; /* 0 - not locked, 1 - locked */
+	u32 IsDemodLocked; /* 0 - not locked, 1 - locked */
+	u32 IsExternalLNAOn; /* 0 - external LNA off, 1 - external LNA on */
+
+	/* Reception quality */
+	s32  SNR; /* dB */
+	s32  RSSI; /* dBm */
+	s32  InBandPwr; /* In band power in dBM */
+	s32  CarrierOffset; /* Carrier Offset in Hz */
+
+	/* Transmission parameters */
+	u32 Frequency; /* Frequency in Hz */
+	u32 Bandwidth; /* Bandwidth in MHz */
+	u32 TransmissionMode; /* ISDB-T transmission mode */
+	u32 ModemState; /* 0 - Acquisition, 1 - Locked */
+	u32 GuardInterval; /* Guard Interval, 1 divided by value */
+	u32 SystemType; /* ISDB-T system type (ISDB-T / ISDB-Tsb) */
+	u32 PartialReception; /* TRUE - partial reception, FALSE otherwise */
+	u32 NumOfLayers; /* Number of ISDB-T layers in the network */
+
+	u32 SegmentNumber; /* Segment number for ISDB-Tsb */
+	u32 TuneBW;	   /* Tuned bandwidth - BW_ISDBT_1SEG / BW_ISDBT_3SEG */
+
+	/* Per-layer information */
+	/* Layers A, B and C */
+	struct SMSHOSTLIB_ISDBT_LAYER_STAT_ST	LayerInfo[3];
+	/* Per-layer statistics, see SMSHOSTLIB_ISDBT_LAYER_STAT_ST */
+
+	/* Interface information */
+	u32 Reserved1;    /* Was SmsToHostTxErrors - obsolete . */
+ /* Proprietary information */
+	u32 ExtAntenna;    /* Obsolete field. */
+	u32 ReceptionQuality;
+	u32 EwsAlertActive;   /* Signals if EWS alert is currently on */
+	u32 LNAOnOff;	/* Internal LNA state: 0: OFF, 1: ON */
+
+	u32 RfAgcLevel;	 /* RF AGC Level [linear units], full gain = 65535 (20dB) */
+	u32 BbAgcLevel;    /* Baseband AGC level [linear units], full gain = 65535 (71.5dB) */
+	u32 FwErrorsCounter;   /* Application errors - should be always zero */
+	u8 FwErrorsHistoryArr[8]; /* Last FW errors IDs - first is most recent, last is oldest */
+
+	s32  MRC_SNR;     /* dB */
+	u32 SNRFullRes;    /* dB x 65536 */
+	u32 Reserved4[4];
+};
+
+
 struct PID_STATISTICS_DATA_S {
 	struct PID_BURST_S {
 		u32 size;
@@ -880,6 +940,35 @@ struct RECEPTION_STATISTICS_S {
 	s32 MRC_InBandPwr;	/* In band power in dBM */
 };
 
+struct RECEPTION_STATISTICS_EX_S {
+	u32 IsRfLocked;		/* 0 - not locked, 1 - locked */
+	u32 IsDemodLocked;	/* 0 - not locked, 1 - locked */
+	u32 IsExternalLNAOn;	/* 0 - external LNA off, 1 - external LNA on */
+
+	u32 ModemState;		/* from SMSHOSTLIB_DVB_MODEM_STATE_ET */
+	s32 SNR;		/* dB */
+	u32 BER;		/* Post Viterbi BER [1E-5] */
+	u32 BERErrorCount;	/* Number of erronous SYNC bits. */
+	u32 BERBitCount;	/* Total number of SYNC bits. */
+	u32 TS_PER;		/* Transport stream PER,
+	0xFFFFFFFF indicate N/A */
+	u32 MFER;		/* DVB-H frame error rate in percentage,
+	0xFFFFFFFF indicate N/A, valid only for DVB-H */
+	s32 RSSI;		/* dBm */
+	s32 InBandPwr;		/* In band power in dBM */
+	s32 CarrierOffset;	/* Carrier Offset in bin/1024 */
+	u32 ErrorTSPackets;	/* Number of erroneous
+	transport-stream packets */
+	u32 TotalTSPackets;	/* Total number of transport-stream packets */
+
+	s32  RefDevPPM;
+	s32  FreqDevHz;
+
+	s32 MRC_SNR;		/* dB */
+	s32 MRC_RSSI;		/* dBm */
+	s32 MRC_InBandPwr;	/* In band power in dBM */
+};
+
 
 /* Statistics information returned as response for
  * SmsHostApiGetStatisticsEx_Req for DVB applications, SMS1100 and up */
@@ -895,6 +984,20 @@ struct SMSHOSTLIB_STATISTICS_DVB_S {
 	struct PID_DATA_S PidData[SRVM_MAX_PID_FILTERS];
 };
 
+/* Statistics information returned as response for
+ * SmsHostApiGetStatisticsEx_Req for DVB applications, SMS1100 and up */
+struct SMSHOSTLIB_STATISTICS_DVB_EX_S {
+	/* Reception */
+	struct RECEPTION_STATISTICS_EX_S ReceptionData;
+
+	/* Transmission parameters */
+	struct TRANSMISSION_STATISTICS_S TransmissionData;
+
+	/* Burst parameters, valid only for DVB-H */
+#define	SRVM_MAX_PID_FILTERS 8
+	struct PID_DATA_S PidData[SRVM_MAX_PID_FILTERS];
+};
+
 struct SRVM_SIGNAL_STATUS_S {
 	u32 result;
 	u32 snr;
drivers/media/common/siano/smsdvb.c +157 -20

261 lines not on this page · raw message

Signature · 1 line
1.8.1.4
#21 lore raw

PATCH 21/46 siano: add new devices to the Siano Driver

In reply to Mauro Carvalho Chehab

This patch is based on Doron Cohen's patches:

	http://patchwork.linuxtv.org/patch/7881/
	http://patchwork.linuxtv.org/patch/7888/
	http://patchwork.linuxtv.org/patch/7883/

It basically merges the above patches, rebasing them to the macro definitions used upstream, with are different
than the ones used by them internally.

---
 drivers/media/common/siano/sms-cards.c | 65 ++++++++++++++++++++++++++++++++--
 drivers/media/common/siano/sms-cards.h |  8 +++++
 drivers/media/mmc/siano/smssdio.c      | 10 ++++++
 drivers/media/usb/siano/smsusb.c       | 31 ++++++++++++++++
 4 files changed, 111 insertions(+), 3 deletions(-)
drivers/media/common/siano/sms-cards.c +62 -3
index 04bb04c..bb6e558 100644
@@ -28,43 +28,53 @@ MODULE_PARM_DESC(cards_dbg, "set debug level (info=1, adv=2 (or-able))");
 static struct sms_board sms_boards[] = {
 	[SMS_BOARD_UNKNOWN] = {
 		.name	= "Unknown board",
+		.type = SMS_UNKNOWN_TYPE,
+		.default_mode = DEVICE_MODE_NONE,
 	},
 	[SMS1XXX_BOARD_SIANO_STELLAR] = {
 		.name	= "Siano Stellar Digital Receiver",
 		.type	= SMS_STELLAR,
+		.default_mode = DEVICE_MODE_DVBT_BDA,
 	},
 	[SMS1XXX_BOARD_SIANO_NOVA_A] = {
 		.name	= "Siano Nova A Digital Receiver",
 		.type	= SMS_NOVA_A0,
+		.default_mode = DEVICE_MODE_DVBT_BDA,
 	},
 	[SMS1XXX_BOARD_SIANO_NOVA_B] = {
 		.name	= "Siano Nova B Digital Receiver",
 		.type	= SMS_NOVA_B0,
+		.default_mode = DEVICE_MODE_DVBT_BDA,
 	},
 	[SMS1XXX_BOARD_SIANO_VEGA] = {
 		.name	= "Siano Vega Digital Receiver",
 		.type	= SMS_VEGA,
+		.default_mode = DEVICE_MODE_CMMB,
 	},
 	[SMS1XXX_BOARD_HAUPPAUGE_CATAMOUNT] = {
 		.name	= "Hauppauge Catamount",
 		.type	= SMS_STELLAR,
 		.fw[DEVICE_MODE_DVBT_BDA] = "sms1xxx-stellar-dvbt-01.fw",
+		.default_mode = DEVICE_MODE_DVBT_BDA,
 	},
 	[SMS1XXX_BOARD_HAUPPAUGE_OKEMO_A] = {
 		.name	= "Hauppauge Okemo-A",
 		.type	= SMS_NOVA_A0,
 		.fw[DEVICE_MODE_DVBT_BDA] = "sms1xxx-nova-a-dvbt-01.fw",
+		.default_mode = DEVICE_MODE_DVBT_BDA,
 	},
 	[SMS1XXX_BOARD_HAUPPAUGE_OKEMO_B] = {
 		.name	= "Hauppauge Okemo-B",
 		.type	= SMS_NOVA_B0,
 		.fw[DEVICE_MODE_DVBT_BDA] = "sms1xxx-nova-b-dvbt-01.fw",
+		.default_mode = DEVICE_MODE_DVBT_BDA,
 	},
 	[SMS1XXX_BOARD_HAUPPAUGE_WINDHAM] = {
 		.name	= "Hauppauge WinTV MiniStick",
 		.type	= SMS_NOVA_B0,
 		.fw[DEVICE_MODE_ISDBT_BDA] = "sms1xxx-hcw-55xxx-isdbt-02.fw",
 		.fw[DEVICE_MODE_DVBT_BDA] = "sms1xxx-hcw-55xxx-dvbt-02.fw",
+		.default_mode = DEVICE_MODE_DVBT_BDA,
 		.rc_codes = RC_MAP_HAUPPAUGE,
 		.board_cfg.leds_power = 26,
 		.board_cfg.led0 = 27,
@@ -78,6 +88,7 @@ static struct sms_board sms_boards[] = {
 		.name	= "Hauppauge WinTV MiniCard",
 		.type	= SMS_NOVA_B0,
 		.fw[DEVICE_MODE_DVBT_BDA] = "sms1xxx-hcw-55xxx-dvbt-02.fw",
+		.default_mode = DEVICE_MODE_DVBT_BDA,
 		.lna_ctrl  = 29,
 		.board_cfg.foreign_lna0_ctrl = 29,
 		.rf_switch = 17,
@@ -87,17 +98,64 @@ static struct sms_board sms_boards[] = {
 		.name	= "Hauppauge WinTV MiniCard",
 		.type	= SMS_NOVA_B0,
 		.fw[DEVICE_MODE_DVBT_BDA] = "sms1xxx-hcw-55xxx-dvbt-02.fw",
+		.default_mode = DEVICE_MODE_DVBT_BDA,
 		.lna_ctrl  = -1,
 	},
 	[SMS1XXX_BOARD_SIANO_NICE] = {
-	/* 11 */
 		.name = "Siano Nice Digital Receiver",
 		.type = SMS_NOVA_B0,
+		.default_mode = DEVICE_MODE_DVBT_BDA,
 	},
 	[SMS1XXX_BOARD_SIANO_VENICE] = {
-	/* 12 */
 		.name = "Siano Venice Digital Receiver",
 		.type = SMS_VEGA,
+		.default_mode = DEVICE_MODE_CMMB,
+	},
+	[SMS1XXX_BOARD_SIANO_STELLAR_ROM] = {
+		.name = "Siano Stellar Digital Receiver ROM",
+		.type = SMS_STELLAR,
+		.default_mode = DEVICE_MODE_DVBT_BDA,
+		.intf_num = 1,
+	},
+	[SMS1XXX_BOARD_ZTE_DVB_DATA_CARD] = {
+		.name = "ZTE Data Card Digital Receiver",
+		.type = SMS_NOVA_B0,
+		.default_mode = DEVICE_MODE_DVBT_BDA,
+		.intf_num = 5,
+		.mtu = 15792,
+	},
+	[SMS1XXX_BOARD_ONDA_MDTV_DATA_CARD] = {
+		.name = "ONDA Data Card Digital Receiver",
+		.type = SMS_NOVA_B0,
+		.default_mode = DEVICE_MODE_DVBT_BDA,
+		.intf_num = 6,
+		.mtu = 15792,
+	},
+	[SMS1XXX_BOARD_SIANO_MING] = {
+		.name = "Siano Ming Digital Receiver",
+		.type = SMS_MING,
+		.default_mode = DEVICE_MODE_CMMB,
+	},
+	[SMS1XXX_BOARD_SIANO_PELE] = {
+		.name = "Siano Pele Digital Receiver",
+		.type = SMS_PELE,
+		.default_mode = DEVICE_MODE_ISDBT_BDA,
+	},
+	[SMS1XXX_BOARD_SIANO_RIO] = {
+		.name = "Siano Rio Digital Receiver",
+		.type = SMS_RIO,
+		.default_mode = DEVICE_MODE_ISDBT_BDA,
+	},
+	[SMS1XXX_BOARD_SIANO_DENVER_1530] = {
+		.name = "Siano Denver (ATSC-M/H) Digital Receiver",
+		.type = SMS_DENVER_1530,
+		.default_mode = DEVICE_MODE_ATSC,
+		.crystal = 2400,
+	},
+	[SMS1XXX_BOARD_SIANO_DENVER_2160] = {
+		.name = "Siano Denver (TDMB) Digital Receiver",
+		.type = SMS_DENVER_2160,
+		.default_mode = DEVICE_MODE_DAB_TDMB,
 	},
 };
 
@@ -119,7 +177,8 @@ static inline void sms_gpio_assign_11xx_default_led_config(
 }
 
 int sms_board_event(struct smscore_device_t *coredev,
-		enum SMS_BOARD_EVENTS gevent) {
+		    enum SMS_BOARD_EVENTS gevent)
+{
 	struct smscore_config_gpio MyGpioConfig;
 
 	sms_gpio_assign_11xx_default_led_config(&MyGpioConfig);
drivers/media/common/siano/sms-cards.h +8 -0
index 60d26be..777a4a0 100644
@@ -37,6 +37,14 @@
 #define SMS1XXX_BOARD_HAUPPAUGE_TIGER_MINICARD_R2 10
 #define SMS1XXX_BOARD_SIANO_NICE	11
 #define SMS1XXX_BOARD_SIANO_VENICE	12
+#define SMS1XXX_BOARD_SIANO_STELLAR_ROM 13
+#define SMS1XXX_BOARD_ZTE_DVB_DATA_CARD	14
+#define SMS1XXX_BOARD_ONDA_MDTV_DATA_CARD 15
+#define SMS1XXX_BOARD_SIANO_MING	16
+#define SMS1XXX_BOARD_SIANO_PELE	17
+#define SMS1XXX_BOARD_SIANO_RIO		18
+#define SMS1XXX_BOARD_SIANO_DENVER_1530	19
+#define SMS1XXX_BOARD_SIANO_DENVER_2160 20
 
 struct sms_board_gpio_cfg {
 	int lna_vhf_exist;
drivers/media/mmc/siano/smssdio.c +10 -0
index 15d3493..c96da47 100644
@@ -61,6 +61,16 @@ static const struct sdio_device_id smssdio_ids[] = {
 	 .driver_data = SMS1XXX_BOARD_SIANO_VEGA},
 	{SDIO_DEVICE(SDIO_VENDOR_ID_SIANO, SDIO_DEVICE_ID_SIANO_VENICE),
 	 .driver_data = SMS1XXX_BOARD_SIANO_VEGA},
+	{SDIO_DEVICE(SDIO_VENDOR_ID_SIANO, 0x302),
+	.driver_data = SMS1XXX_BOARD_SIANO_MING},
+	{SDIO_DEVICE(SDIO_VENDOR_ID_SIANO, 0x500),
+	.driver_data = SMS1XXX_BOARD_SIANO_PELE},
+	{SDIO_DEVICE(SDIO_VENDOR_ID_SIANO, 0x600),
+	.driver_data = SMS1XXX_BOARD_SIANO_RIO},
+	{SDIO_DEVICE(SDIO_VENDOR_ID_SIANO, 0x700),
+	.driver_data = SMS1XXX_BOARD_SIANO_DENVER_2160},
+	{SDIO_DEVICE(SDIO_VENDOR_ID_SIANO, 0x800),
+	.driver_data = SMS1XXX_BOARD_SIANO_DENVER_1530},
 	{ /* end: all zeroes */ },
 };
 
drivers/media/usb/siano/smsusb.c +31 -0
index a31bf74..751c0d6 100644
@@ -441,6 +441,7 @@ static int smsusb_probe(struct usb_interface *intf,
 			const struct usb_device_id *id)
 {
 	struct usb_device *udev = interface_to_usbdev(intf);
+	char devpath[32];
 	int i, rc;
 
 	sms_info("interface number %d",
@@ -485,6 +486,16 @@ static int smsusb_probe(struct usb_interface *intf,
 		return -ENODEV;
 	}
 
+	if (id->driver_info == SMS1XXX_BOARD_SIANO_STELLAR_ROM) {
+		sms_info("stellar device was found.");
+		snprintf(devpath, sizeof(devpath), "usb\\%d-%s",
+			 udev->bus->busnum, udev->devpath);
+		sms_info("stellar device was found.");
+		return smsusb1_load_firmware(
+				udev, smscore_registry_getmode(devpath),
+				id->driver_info);
+	}
+
 	rc = smsusb_init_device(intf, id->driver_info);
 	sms_info("rc %d", rc);
 	sms_board_load_modules(id->driver_info);
@@ -602,6 +613,26 @@ static const struct usb_device_id smsusb_id_table[] = {
 		.driver_info = SMS1XXX_BOARD_HAUPPAUGE_WINDHAM },
 	{ USB_DEVICE(0x2040, 0xf5a0),
 		.driver_info = SMS1XXX_BOARD_HAUPPAUGE_WINDHAM },
+	{ USB_DEVICE(0x187f, 0x0202),
+		.driver_info = SMS1XXX_BOARD_SIANO_NICE },
+	{ USB_DEVICE(0x187f, 0x0301),
+		.driver_info = SMS1XXX_BOARD_SIANO_VENICE },
+	{ USB_DEVICE(0x187f, 0x0302),
+		.driver_info = SMS1XXX_BOARD_SIANO_VENICE },
+	{ USB_DEVICE(0x187f, 0x0310),
+		.driver_info = SMS1XXX_BOARD_SIANO_MING },
+	{ USB_DEVICE(0x187f, 0x0500),
+		.driver_info = SMS1XXX_BOARD_SIANO_PELE },
+	{ USB_DEVICE(0x187f, 0x0600),
+		.driver_info = SMS1XXX_BOARD_SIANO_RIO },
+	{ USB_DEVICE(0x187f, 0x0700),
+		.driver_info = SMS1XXX_BOARD_SIANO_DENVER_2160 },
+	{ USB_DEVICE(0x187f, 0x0800),
+		.driver_info = SMS1XXX_BOARD_SIANO_DENVER_1530 },
+	{ USB_DEVICE(0x19D2, 0x0086),
+		.driver_info = SMS1XXX_BOARD_ZTE_DVB_DATA_CARD },
+	{ USB_DEVICE(0x19D2, 0x0078),
+		.driver_info = SMS1XXX_BOARD_ONDA_MDTV_DATA_CARD },
 	{ } /* Terminating entry */
 	};
 
Signature · 1 line
1.8.1.4
#22 lore raw

PATCH 22/46 siano: Configure board's mtu and xtal

In reply to Mauro Carvalho Chehab

Backported from Doron Cohen's patch:

	http://patchwork.linuxtv.org/patch/7889/
---
 drivers/media/common/siano/smscoreapi.c | 56 +++++++++++++++++++++++++++++++++
 1 file changed, 56 insertions(+)
drivers/media/common/siano/smscoreapi.c +56 -0
index 6e60c99..acf28af 100644
@@ -825,6 +825,57 @@ static int smscore_init_ir(struct smscore_device_t *coredev)
 }
 
 /**
+ * configures device features according to board configuration structure.
+ *
+ * @param coredev pointer to a coredev object returned by
+ *                smscore_register_device
+ *
+ * @return 0 on success, <0 on error.
+ */
+int smscore_configure_board(struct smscore_device_t *coredev)
+{
+	struct sms_board *board;
+
+	board = sms_get_board(coredev->board_id);
+	if (!board) {
+		sms_err("no board configuration exist.");
+		return -EINVAL;
+	}
+
+	if (board->mtu) {
+		struct SmsMsgData_ST MtuMsg;
+		sms_debug("set max transmit unit %d", board->mtu);
+
+		MtuMsg.xMsgHeader.msgSrcId = 0;
+		MtuMsg.xMsgHeader.msgDstId = HIF_TASK;
+		MtuMsg.xMsgHeader.msgFlags = 0;
+		MtuMsg.xMsgHeader.msgType = MSG_SMS_SET_MAX_TX_MSG_LEN_REQ;
+		MtuMsg.xMsgHeader.msgLength = sizeof(MtuMsg);
+		MtuMsg.msgData[0] = board->mtu;
+
+		smsendian_handle_tx_message((struct SmsMsgHdr_ST *)&MtuMsg);
+		coredev->sendrequest_handler(coredev->context, &MtuMsg,
+					     sizeof(MtuMsg));
+	}
+
+	if (board->crystal) {
+		struct SmsMsgData_ST CrysMsg;
+		sms_debug("set crystal value %d", board->crystal);
+
+		SMS_INIT_MSG(&CrysMsg.xMsgHeader,
+				MSG_SMS_NEW_CRYSTAL_REQ,
+				sizeof(CrysMsg));
+		CrysMsg.msgData[0] = board->crystal;
+
+		smsendian_handle_tx_message((struct SmsMsgHdr_S *)&CrysMsg);
+		coredev->sendrequest_handler(coredev->context, &CrysMsg,
+					     sizeof(CrysMsg));
+	}
+
+	return 0;
+}
+
+/**
  * sets initial device mode and notifies client hotplugs that device is ready
  *
  * @param coredev pointer to a coredev object returned by
@@ -840,6 +891,11 @@ int smscore_start_device(struct smscore_device_t *coredev)
 		sms_info("set device mode faile , rc %d", rc);
 		return rc;
 	}
+	rc = smscore_configure_board(coredev);
+	if (rc < 0) {
+		sms_info("configure board failed , rc %d", rc);
+		return rc;
+	}
 
 	kmutex_lock(&g_smscore_deviceslock);
 
Signature · 1 line
1.8.1.4
#23 lore raw

PATCH 23/46 siano: call MSG_SMS_INIT_DEVICE_REQ

In reply to Mauro Carvalho Chehab

Newer firmwares seem to require an init device message. Apply such change from Doron Cohen's patch:

	http://patchwork.linuxtv.org/patch/7889/
---
 drivers/media/common/siano/smscoreapi.c | 43 ++++++++++++++++++++++++++++++++-
 1 file changed, 42 insertions(+), 1 deletion(-)
drivers/media/common/siano/smscoreapi.c +42 -1
index acf28af..35486c5 100644
@@ -1280,6 +1280,42 @@ static char *smscore_get_fw_filename(struct smscore_device_t *coredev,
 }
 
 /**
+ * send init device request and wait for response
+ *
+ * @param coredev pointer to a coredev object returned by
+ *                smscore_register_device
+ * @param mode requested mode of operation
+ *
+ * @return 0 on success, <0 on error.
+ */
+int smscore_init_device(struct smscore_device_t *coredev, int mode)
+{
+	void *buffer;
+	struct SmsMsgData_ST *msg;
+	int rc = 0;
+
+	buffer = kmalloc(sizeof(struct SmsMsgData_ST) +
+			SMS_DMA_ALIGNMENT, GFP_KERNEL | GFP_DMA);
+	if (!buffer) {
+		sms_err("Could not allocate buffer for init device message.");
+		return -ENOMEM;
+	}
+
+	msg = (struct SmsMsgData_ST *)SMS_ALIGN_ADDRESS(buffer);
+	SMS_INIT_MSG(&msg->xMsgHeader, MSG_SMS_INIT_DEVICE_REQ,
+			sizeof(struct SmsMsgData_ST));
+	msg->msgData[0] = mode;
+
+	smsendian_handle_tx_message((struct SmsMsgHdr_ST *)msg);
+	rc = smscore_sendrequest_and_wait(coredev, msg,
+			msg->xMsgHeader. msgLength,
+			&coredev->init_device_done);
+
+	kfree(buffer);
+	return rc;
+}
+
+/**
  * calls device handler to change mode of operation
  * NOTE: stellar/usb may disconnect when changing mode
  *
@@ -1341,8 +1377,13 @@ int smscore_set_device_mode(struct smscore_device_t *coredev, int mode)
 			sms_info("mode %d is already supported by running firmware",
 				 mode);
 		}
+		if (coredev->fw_version >= 0x800) {
+			rc = smscore_init_device(coredev, mode);
+			if (rc < 0)
+				sms_err("device init failed, rc %d.", rc);
+		}
 	} else {
-		if (mode < DEVICE_MODE_DVBT || mode > DEVICE_MODE_DVBT_BDA) {
+		if (mode < DEVICE_MODE_DVBT || mode > DEVICE_MODE_MAX) {
 			sms_err("invalid mode specified %d", mode);
 			return -EINVAL;
 		}
Signature · 1 line
1.8.1.4
#24 lore raw

PATCH 24/46 siano: simplify message endianness logic

In reply to Mauro Carvalho Chehab

Currently, every time a message is sent or received, the endiannes need to be fixed on big endian machines. This is currently done on every call to the send API, and on every msg reception logic.

Instead of doing that, move it to the send/receive functions.

That simplifies the logic and avoids the risk of forgetting to fix it somewhere.

---
 drivers/media/common/siano/smscoreapi.c | 14 --------------
 drivers/media/common/siano/smsdvb.c     |  8 --------
 drivers/media/mmc/siano/smssdio.c       |  3 +++
 drivers/media/usb/siano/smsusb.c        |  9 ++++++---
 4 files changed, 9 insertions(+), 25 deletions(-)
drivers/media/common/siano/smscoreapi.c +0 -14
index 35486c5..029dd6a 100644
@@ -37,7 +37,6 @@
 #include "smscoreapi.h"
 #include "sms-cards.h"
 #include "smsir.h"
-#include "smsendian.h"
 
 static int sms_dbg;
 module_param_named(debug, sms_dbg, int, 0644);
@@ -807,8 +806,6 @@ static int smscore_init_ir(struct smscore_device_t *coredev)
 				msg->msgData[0] = coredev->ir.controller;
 				msg->msgData[1] = coredev->ir.timeout;
 
-				smsendian_handle_tx_message(
-					(struct SmsMsgHdr_ST2 *)msg);
 				rc = smscore_sendrequest_and_wait(coredev, msg,
 						msg->xMsgHeader. msgLength,
 						&coredev->ir_init_done);
@@ -853,7 +850,6 @@ int smscore_configure_board(struct smscore_device_t *coredev)
 		MtuMsg.xMsgHeader.msgLength = sizeof(MtuMsg);
 		MtuMsg.msgData[0] = board->mtu;
 
-		smsendian_handle_tx_message((struct SmsMsgHdr_ST *)&MtuMsg);
 		coredev->sendrequest_handler(coredev->context, &MtuMsg,
 					     sizeof(MtuMsg));
 	}
@@ -867,7 +863,6 @@ int smscore_configure_board(struct smscore_device_t *coredev)
 				sizeof(CrysMsg));
 		CrysMsg.msgData[0] = board->crystal;
 
-		smsendian_handle_tx_message((struct SmsMsgHdr_S *)&CrysMsg);
 		coredev->sendrequest_handler(coredev->context, &CrysMsg,
 					     sizeof(CrysMsg));
 	}
@@ -989,7 +984,6 @@ static int smscore_load_firmware_family2(struct smscore_device_t *coredev,
 		/* Entry point */
 	msg->msgData[1] = firmware->Length;
 	msg->msgData[2] = 0; /* Regular checksum*/
-	smsendian_handle_tx_message(msg);
 	rc = smscore_sendrequest_and_wait(coredev, msg,
 					  msg->xMsgHeader.msgLength,
 					  &coredev->data_validity_done);
@@ -1013,14 +1007,12 @@ static int smscore_load_firmware_family2(struct smscore_device_t *coredev,
 		TriggerMsg->msgData[3] = 0; /* Parameter */
 		TriggerMsg->msgData[4] = 4; /* Task ID */
 
-		smsendian_handle_tx_message((struct SmsMsgHdr_S *)msg);
 		rc = smscore_sendrequest_and_wait(coredev, TriggerMsg,
 					TriggerMsg->xMsgHeader.msgLength,
 					&coredev->trigger_done);
 	} else {
 		SMS_INIT_MSG(&msg->xMsgHeader, MSG_SW_RELOAD_EXEC_REQ,
 				sizeof(struct SmsMsgHdr_ST));
-		smsendian_handle_tx_message((struct SmsMsgHdr_S *)msg);
 		rc = coredev->sendrequest_handler(coredev->context, msg,
 				msg->xMsgHeader.msgLength);
 	}
@@ -1306,7 +1298,6 @@ int smscore_init_device(struct smscore_device_t *coredev, int mode)
 			sizeof(struct SmsMsgData_ST));
 	msg->msgData[0] = mode;
 
-	smsendian_handle_tx_message((struct SmsMsgHdr_ST *)msg);
 	rc = smscore_sendrequest_and_wait(coredev, msg,
 			msg->xMsgHeader. msgLength,
 			&coredev->init_device_done);
@@ -1527,8 +1518,6 @@ void smscore_onresponse(struct smscore_device_t *coredev,
 		rc = client->onresponse_handler(client->context, cb);
 
 	if (rc < 0) {
-		smsendian_handle_rx_message((struct SmsMsgData_ST *)phdr);
-
 		switch (phdr->msgType) {
 		case MSG_SMS_ISDBT_TUNE_RES:
 			break;
@@ -2009,7 +1998,6 @@ int smscore_gpio_configure(struct smscore_device_t *coredev, u8 PinNum,
 		pMsg->msgData[5] = 0;
 	}
 
-	smsendian_handle_tx_message((struct SmsMsgHdr_ST *)pMsg);
 	rc = smscore_sendrequest_and_wait(coredev, pMsg, totalLen,
 			&coredev->gpio_configuration_done);
 
@@ -2059,7 +2047,6 @@ int smscore_gpio_set_level(struct smscore_device_t *coredev, u8 PinNum,
 	pMsg->msgData[1] = NewLevel;
 
 	/* Send message to SMS */
-	smsendian_handle_tx_message((struct SmsMsgHdr_ST *)pMsg);
 	rc = smscore_sendrequest_and_wait(coredev, pMsg, totalLen,
 			&coredev->gpio_set_level_done);
 
@@ -2108,7 +2095,6 @@ int smscore_gpio_get_level(struct smscore_device_t *coredev, u8 PinNum,
 	pMsg->msgData[1] = 0;
 
 	/* Send message to SMS */
-	smsendian_handle_tx_message((struct SmsMsgHdr_ST *)pMsg);
 	rc = smscore_sendrequest_and_wait(coredev, pMsg, totalLen,
 			&coredev->gpio_get_level_done);
 
drivers/media/common/siano/smsdvb.c +0 -8
index dbb807e..6335574 100644
@@ -29,7 +29,6 @@ along with this program.  If not, see <http://www.gnu.org/licenses/>.
 #include "dvb_frontend.h"
 
 #include "smscoreapi.h"
-#include "smsendian.h"
 #include "sms-cards.h"
 
 DVB_DEFINE_MOD_OPT_ADAPTER_NR(adapter_nr);
@@ -324,8 +323,6 @@ static int smsdvb_onresponse(void *context, struct smscore_buffer_t *cb)
 	/*u32 MsgDataLen = phdr->msgLength - sizeof(struct SmsMsgHdr_ST);*/
 	bool is_status_update = false;
 
-	smsendian_handle_rx_message((struct SmsMsgData_ST *) phdr);
-
 	switch (phdr->msgType) {
 	case MSG_SMS_DVBT_BDA_DATA:
 		dvb_dmx_swfilter(&client->demux, (u8 *)(phdr + 1),
@@ -545,7 +542,6 @@ static int smsdvb_start_feed(struct dvb_demux_feed *feed)
 	PidMsg.xMsgHeader.msgLength = sizeof(PidMsg);
 	PidMsg.msgData[0] = feed->pid;
 
-	smsendian_handle_tx_message((struct SmsMsgHdr_ST *)&PidMsg);
 	return smsclient_sendrequest(client->smsclient,
 				     &PidMsg, sizeof(PidMsg));
 }
@@ -566,7 +562,6 @@ static int smsdvb_stop_feed(struct dvb_demux_feed *feed)
 	PidMsg.xMsgHeader.msgLength = sizeof(PidMsg);
 	PidMsg.msgData[0] = feed->pid;
 
-	smsendian_handle_tx_message((struct SmsMsgHdr_ST *)&PidMsg);
 	return smsclient_sendrequest(client->smsclient,
 				     &PidMsg, sizeof(PidMsg));
 }
@@ -577,7 +572,6 @@ static int smsdvb_sendrequest_and_wait(struct smsdvb_client_t *client,
 {
 	int rc;
 
-	smsendian_handle_tx_message((struct SmsMsgHdr_ST *)buffer);
 	rc = smsclient_sendrequest(client->smsclient, buffer, size);
 	if (rc < 0)
 		return rc;
@@ -606,8 +600,6 @@ static int smsdvb_send_statistics_request(struct smsdvb_client_t *client)
 	else
 		Msg.msgType = MSG_SMS_GET_STATISTICS_REQ;
 
-	smsendian_handle_tx_message((struct SmsMsgHdr_S *)&Msg);
-
 	rc = smsdvb_sendrequest_and_wait(client, &Msg, sizeof(Msg),
 					 &client->stats_done);
 
drivers/media/mmc/siano/smssdio.c +3 -0
index c96da47..8834c43 100644
@@ -43,6 +43,7 @@
 
 #include "smscoreapi.h"
 #include "sms-cards.h"
+#include "smsendian.h"
 
 /* Registers */
 
@@ -97,6 +98,7 @@ static int smssdio_sendrequest(void *context, void *buffer, size_t size)
 
 	sdio_claim_host(smsdev->func);
 
+	smsendian_handle_tx_message((struct SmsMsgData_ST *) buffer);
 	while (size >= smsdev->func->cur_blksize) {
 		ret = sdio_memcpy_toio(smsdev->func, SMSSDIO_DATA,
 					buffer, smsdev->func->cur_blksize);
@@ -231,6 +233,7 @@ static void smssdio_interrupt(struct sdio_func *func)
 	cb->size = hdr->msgLength;
 	cb->offset = 0;
 
+	smsendian_handle_rx_message((struct SmsMsgData_ST *) cb->p);
 	smscore_onresponse(smsdev->coredev, cb);
 }
 
drivers/media/usb/siano/smsusb.c +6 -3
index 751c0d6..acd3d1e 100644
@@ -129,6 +129,8 @@ static void smsusb_onresponse(struct urb *urb)
 				  smscore_translate_msg(phdr->msgType),
 				  phdr->msgType, phdr->msgLength);
 
+			smsendian_handle_rx_message((struct SmsMsgData_ST *) phdr);
+
 			smscore_onresponse(dev->coredev, surb->cb);
 			surb->cb = NULL;
 		} else {
@@ -207,13 +209,14 @@ static int smsusb_sendrequest(void *context, void *buffer, size_t size)
 	struct SmsMsgHdr_ST *phdr = (struct SmsMsgHdr_ST *) buffer;
 	int dummy;
 
+	if (dev->state != SMSUSB_ACTIVE)
+		return -ENOENT;
+
 	sms_debug("sending %s(%d) size: %d",
 		  smscore_translate_msg(phdr->msgType), phdr->msgType,
 		  phdr->msgLength);
 
-	if (dev->state != SMSUSB_ACTIVE)
-		return -ENOENT;
-
+	smsendian_handle_tx_message((struct SmsMsgData_ST *) phdr);
 	smsendian_handle_message_header((struct SmsMsgHdr_ST *)buffer);
 	return usb_bulk_msg(dev->udev, usb_sndbulkpipe(dev->udev, 2),
 			    buffer, size, &dummy, 1000);
Signature · 1 line
1.8.1.4
#25 lore raw

PATCH 25/46 siano: split get_frontend into per-std functions

In reply to Mauro Carvalho Chehab

Instead of handling both DVB-T and ISDB-T at the same get_frontend function, break it intow one function per-delivery system.

That makes the code clearer as we start to add support for DVBv5 statistics, and for ISDB-T get frontend stuff.

---
 drivers/media/common/siano/smsdvb.c | 229 +++++++++++++++++++-----------------
 1 file changed, 124 insertions(+), 105 deletions(-)
drivers/media/common/siano/smsdvb.c +124 -105
index 6335574..1d6b8df 100644
@@ -863,131 +863,150 @@ static int smsdvb_set_frontend(struct dvb_frontend *fe)
 	}
 }
 
-static int smsdvb_get_frontend(struct dvb_frontend *fe)
+static int smsdvb_get_frontend_dvb(struct dvb_frontend *fe)
 {
 	struct dtv_frontend_properties *fep = &fe->dtv_property_cache;
 	struct smsdvb_client_t *client =
 		container_of(fe, struct smsdvb_client_t, frontend);
-	struct smscore_device_t *coredev = client->coredev;
 	struct TRANSMISSION_STATISTICS_S *td =
 		&client->sms_stat_dvb.TransmissionData;
 
-	switch (smscore_get_device_mode(coredev)) {
-	case DEVICE_MODE_DVBT:
-	case DEVICE_MODE_DVBT_BDA:
-		fep->frequency = td->Frequency;
-
-		switch (td->Bandwidth) {
-		case 6:
-			fep->bandwidth_hz = 6000000;
-			break;
-		case 7:
-			fep->bandwidth_hz = 7000000;
-			break;
-		case 8:
-			fep->bandwidth_hz = 8000000;
-			break;
-		}
+	fep->frequency = td->Frequency;
 
-		switch (td->TransmissionMode) {
-		case 2:
-			fep->transmission_mode = TRANSMISSION_MODE_2K;
-			break;
-		case 8:
-			fep->transmission_mode = TRANSMISSION_MODE_8K;
-		}
+	switch (td->Bandwidth) {
+	case 6:
+		fep->bandwidth_hz = 6000000;
+		break;
+	case 7:
+		fep->bandwidth_hz = 7000000;
+		break;
+	case 8:
+		fep->bandwidth_hz = 8000000;
+		break;
+	}
 
-		switch (td->GuardInterval) {
-		case 0:
-			fep->guard_interval = GUARD_INTERVAL_1_32;
-			break;
-		case 1:
-			fep->guard_interval = GUARD_INTERVAL_1_16;
-			break;
-		case 2:
-			fep->guard_interval = GUARD_INTERVAL_1_8;
-			break;
-		case 3:
-			fep->guard_interval = GUARD_INTERVAL_1_4;
-			break;
-		}
+	switch (td->TransmissionMode) {
+	case 2:
+		fep->transmission_mode = TRANSMISSION_MODE_2K;
+		break;
+	case 8:
+		fep->transmission_mode = TRANSMISSION_MODE_8K;
+	}
 
-		switch (td->CodeRate) {
-		case 0:
-			fep->code_rate_HP = FEC_1_2;
-			break;
-		case 1:
-			fep->code_rate_HP = FEC_2_3;
-			break;
-		case 2:
-			fep->code_rate_HP = FEC_3_4;
-			break;
-		case 3:
-			fep->code_rate_HP = FEC_5_6;
-			break;
-		case 4:
-			fep->code_rate_HP = FEC_7_8;
-			break;
-		}
+	switch (td->GuardInterval) {
+	case 0:
+		fep->guard_interval = GUARD_INTERVAL_1_32;
+		break;
+	case 1:
+		fep->guard_interval = GUARD_INTERVAL_1_16;
+		break;
+	case 2:
+		fep->guard_interval = GUARD_INTERVAL_1_8;
+		break;
+	case 3:
+		fep->guard_interval = GUARD_INTERVAL_1_4;
+		break;
+	}
 
-		switch (td->LPCodeRate) {
-		case 0:
-			fep->code_rate_LP = FEC_1_2;
-			break;
-		case 1:
-			fep->code_rate_LP = FEC_2_3;
-			break;
-		case 2:
-			fep->code_rate_LP = FEC_3_4;
-			break;
-		case 3:
-			fep->code_rate_LP = FEC_5_6;
-			break;
-		case 4:
-			fep->code_rate_LP = FEC_7_8;
-			break;
-		}
+	switch (td->CodeRate) {
+	case 0:
+		fep->code_rate_HP = FEC_1_2;
+		break;
+	case 1:
+		fep->code_rate_HP = FEC_2_3;
+		break;
+	case 2:
+		fep->code_rate_HP = FEC_3_4;
+		break;
+	case 3:
+		fep->code_rate_HP = FEC_5_6;
+		break;
+	case 4:
+		fep->code_rate_HP = FEC_7_8;
+		break;
+	}
 
-		switch (td->Constellation) {
-		case 0:
-			fep->modulation = QPSK;
-			break;
-		case 1:
-			fep->modulation = QAM_16;
-			break;
-		case 2:
-			fep->modulation = QAM_64;
-			break;
-		}
+	switch (td->LPCodeRate) {
+	case 0:
+		fep->code_rate_LP = FEC_1_2;
+		break;
+	case 1:
+		fep->code_rate_LP = FEC_2_3;
+		break;
+	case 2:
+		fep->code_rate_LP = FEC_3_4;
+		break;
+	case 3:
+		fep->code_rate_LP = FEC_5_6;
+		break;
+	case 4:
+		fep->code_rate_LP = FEC_7_8;
+		break;
+	}
 
-		switch (td->Hierarchy) {
-		case 0:
-			fep->hierarchy = HIERARCHY_NONE;
-			break;
-		case 1:
-			fep->hierarchy = HIERARCHY_1;
-			break;
-		case 2:
-			fep->hierarchy = HIERARCHY_2;
-			break;
-		case 3:
-			fep->hierarchy = HIERARCHY_4;
-			break;
-		}
+	switch (td->Constellation) {
+	case 0:
+		fep->modulation = QPSK;
+		break;
+	case 1:
+		fep->modulation = QAM_16;
+		break;
+	case 2:
+		fep->modulation = QAM_64;
+		break;
+	}
 
-		fep->inversion = INVERSION_AUTO;
+	switch (td->Hierarchy) {
+	case 0:
+		fep->hierarchy = HIERARCHY_NONE;
 		break;
+	case 1:
+		fep->hierarchy = HIERARCHY_1;
+		break;
+	case 2:
+		fep->hierarchy = HIERARCHY_2;
+		break;
+	case 3:
+		fep->hierarchy = HIERARCHY_4;
+		break;
+	}
+
+	fep->inversion = INVERSION_AUTO;
+
+	return 0;
+}
+
+static int smsdvb_get_frontend_isdb(struct dvb_frontend *fe)
+{
+	struct dtv_frontend_properties *fep = &fe->dtv_property_cache;
+	struct smsdvb_client_t *client =
+		container_of(fe, struct smsdvb_client_t, frontend);
+	struct TRANSMISSION_STATISTICS_S *td =
+		&client->sms_stat_dvb.TransmissionData;
+
+	fep->frequency = td->Frequency;
+	fep->bandwidth_hz = 6000000;
+	/* todo: retrive the other parameters */
+
+	return 0;
+}
+
+static int smsdvb_get_frontend(struct dvb_frontend *fe)
+{
+	struct smsdvb_client_t *client =
+		container_of(fe, struct smsdvb_client_t, frontend);
+	struct smscore_device_t *coredev = client->coredev;
+
+	switch (smscore_get_device_mode(coredev)) {
+	case DEVICE_MODE_DVBT:
+	case DEVICE_MODE_DVBT_BDA:
+		return smsdvb_get_frontend_dvb(fe);
 	case DEVICE_MODE_ISDBT:
 	case DEVICE_MODE_ISDBT_BDA:
-		fep->frequency = td->Frequency;
-		fep->bandwidth_hz = 6000000;
-		/* todo: retrive the other parameters */
-		break;
+		return smsdvb_get_frontend_isdb(fe);
 	default:
 		return -EINVAL;
 	}
-
-	return 0;
 }
 
 static int smsdvb_init(struct dvb_frontend *fe)
Signature · 1 line
1.8.1.4
#26 lore raw

PATCH 26/46 siano: split debug logic from the status update routine

In reply to Mauro Carvalho Chehab

It is confusing to merge both status updates with debug stuff. Also, it is a better idea to move those status updates to debugfs, instead of doing a large amount of printk's like that.

So, break them into a separate block of routines.

---
 drivers/media/common/siano/smsdvb.c | 250 +++++++++++++++++++-----------------
 1 file changed, 135 insertions(+), 115 deletions(-)
drivers/media/common/siano/smsdvb.c +135 -115
index 1d6b8df..04544f5 100644
@@ -61,6 +61,136 @@ static int sms_dbg;
 module_param_named(debug, sms_dbg, int, 0644);
 MODULE_PARM_DESC(debug, "set debug level (info=1, adv=2 (or-able))");
 
+static void smsdvb_print_dvb_stats(struct SMSHOSTLIB_STATISTICS_ST *p)
+{
+	if (!(sms_dbg & 2))
+		return;
+
+	printk(KERN_DEBUG "IsRfLocked = %d", p->IsRfLocked);
+	printk(KERN_DEBUG "IsDemodLocked = %d", p->IsDemodLocked);
+	printk(KERN_DEBUG "IsExternalLNAOn = %d", p->IsExternalLNAOn);
+	printk(KERN_DEBUG "SNR = %d", p->SNR);
+	printk(KERN_DEBUG "BER = %d", p->BER);
+	printk(KERN_DEBUG "FIB_CRC = %d", p->FIB_CRC);
+	printk(KERN_DEBUG "TS_PER = %d", p->TS_PER);
+	printk(KERN_DEBUG "MFER = %d", p->MFER);
+	printk(KERN_DEBUG "RSSI = %d", p->RSSI);
+	printk(KERN_DEBUG "InBandPwr = %d", p->InBandPwr);
+	printk(KERN_DEBUG "CarrierOffset = %d", p->CarrierOffset);
+	printk(KERN_DEBUG "ModemState = %d", p->ModemState);
+	printk(KERN_DEBUG "Frequency = %d", p->Frequency);
+	printk(KERN_DEBUG "Bandwidth = %d", p->Bandwidth);
+	printk(KERN_DEBUG "TransmissionMode = %d", p->TransmissionMode);
+	printk(KERN_DEBUG "ModemState = %d", p->ModemState);
+	printk(KERN_DEBUG "GuardInterval = %d", p->GuardInterval);
+	printk(KERN_DEBUG "CodeRate = %d", p->CodeRate);
+	printk(KERN_DEBUG "LPCodeRate = %d", p->LPCodeRate);
+	printk(KERN_DEBUG "Hierarchy = %d", p->Hierarchy);
+	printk(KERN_DEBUG "Constellation = %d", p->Constellation);
+	printk(KERN_DEBUG "BurstSize = %d", p->BurstSize);
+	printk(KERN_DEBUG "BurstDuration = %d", p->BurstDuration);
+	printk(KERN_DEBUG "BurstCycleTime = %d", p->BurstCycleTime);
+	printk(KERN_DEBUG "CalculatedBurstCycleTime = %d", p->CalculatedBurstCycleTime);
+	printk(KERN_DEBUG "NumOfRows = %d", p->NumOfRows);
+	printk(KERN_DEBUG "NumOfPaddCols = %d", p->NumOfPaddCols);
+	printk(KERN_DEBUG "NumOfPunctCols = %d", p->NumOfPunctCols);
+	printk(KERN_DEBUG "ErrorTSPackets = %d", p->ErrorTSPackets);
+	printk(KERN_DEBUG "TotalTSPackets = %d", p->TotalTSPackets);
+	printk(KERN_DEBUG "NumOfValidMpeTlbs = %d", p->NumOfValidMpeTlbs);
+	printk(KERN_DEBUG "NumOfInvalidMpeTlbs = %d", p->NumOfInvalidMpeTlbs);
+	printk(KERN_DEBUG "NumOfCorrectedMpeTlbs = %d", p->NumOfCorrectedMpeTlbs);
+	printk(KERN_DEBUG "BERErrorCount = %d", p->BERErrorCount);
+	printk(KERN_DEBUG "BERBitCount = %d", p->BERBitCount);
+	printk(KERN_DEBUG "SmsToHostTxErrors = %d", p->SmsToHostTxErrors);
+	printk(KERN_DEBUG "PreBER = %d", p->PreBER);
+	printk(KERN_DEBUG "CellId = %d", p->CellId);
+	printk(KERN_DEBUG "DvbhSrvIndHP = %d", p->DvbhSrvIndHP);
+	printk(KERN_DEBUG "DvbhSrvIndLP = %d", p->DvbhSrvIndLP);
+	printk(KERN_DEBUG "NumMPEReceived = %d", p->NumMPEReceived);
+}
+
+static void smsdvb_print_isdb_stats(struct SMSHOSTLIB_STATISTICS_ISDBT_ST *p)
+{
+	int i;
+
+	if (!(sms_dbg & 2))
+		return;
+
+	printk(KERN_DEBUG "IsRfLocked = %d", p->IsRfLocked);
+	printk(KERN_DEBUG "IsDemodLocked = %d", p->IsDemodLocked);
+	printk(KERN_DEBUG "IsExternalLNAOn = %d", p->IsExternalLNAOn);
+	printk(KERN_DEBUG "SNR = %d", p->SNR);
+	printk(KERN_DEBUG "RSSI = %d", p->RSSI);
+	printk(KERN_DEBUG "InBandPwr = %d", p->InBandPwr);
+	printk(KERN_DEBUG "CarrierOffset = %d", p->CarrierOffset);
+	printk(KERN_DEBUG "Frequency = %d", p->Frequency);
+	printk(KERN_DEBUG "Bandwidth = %d", p->Bandwidth);
+	printk(KERN_DEBUG "TransmissionMode = %d", p->TransmissionMode);
+	printk(KERN_DEBUG "ModemState = %d", p->ModemState);
+	printk(KERN_DEBUG "GuardInterval = %d", p->GuardInterval);
+	printk(KERN_DEBUG "SystemType = %d", p->SystemType);
+	printk(KERN_DEBUG "PartialReception = %d", p->PartialReception);
+	printk(KERN_DEBUG "NumOfLayers = %d", p->NumOfLayers);
+	printk(KERN_DEBUG "SmsToHostTxErrors = %d", p->SmsToHostTxErrors);
+
+	for (i = 0; i < 3; i++) {
+		printk(KERN_DEBUG "%d: CodeRate = %d", i, p->LayerInfo[i].CodeRate);
+		printk(KERN_DEBUG "%d: Constellation = %d", i, p->LayerInfo[i].Constellation);
+		printk(KERN_DEBUG "%d: BER = %d", i, p->LayerInfo[i].BER);
+		printk(KERN_DEBUG "%d: BERErrorCount = %d", i, p->LayerInfo[i].BERErrorCount);
+		printk(KERN_DEBUG "%d: BERBitCount = %d", i, p->LayerInfo[i].BERBitCount);
+		printk(KERN_DEBUG "%d: PreBER = %d", i, p->LayerInfo[i].PreBER);
+		printk(KERN_DEBUG "%d: TS_PER = %d", i, p->LayerInfo[i].TS_PER);
+		printk(KERN_DEBUG "%d: ErrorTSPackets = %d", i, p->LayerInfo[i].ErrorTSPackets);
+		printk(KERN_DEBUG "%d: TotalTSPackets = %d", i, p->LayerInfo[i].TotalTSPackets);
+		printk(KERN_DEBUG "%d: TILdepthI = %d", i, p->LayerInfo[i].TILdepthI);
+		printk(KERN_DEBUG "%d: NumberOfSegments = %d", i, p->LayerInfo[i].NumberOfSegments);
+		printk(KERN_DEBUG "%d: TMCCErrors = %d", i, p->LayerInfo[i].TMCCErrors);
+	}
+}
+
+static void
+smsdvb_print_isdb_stats_ex(struct SMSHOSTLIB_STATISTICS_ISDBT_EX_ST *p)
+{
+	int i;
+
+	if (!(sms_dbg & 2))
+		return;
+
+	printk(KERN_DEBUG "IsRfLocked = %d", p->IsRfLocked);
+	printk(KERN_DEBUG "IsDemodLocked = %d", p->IsDemodLocked);
+	printk(KERN_DEBUG "IsExternalLNAOn = %d", p->IsExternalLNAOn);
+	printk(KERN_DEBUG "SNR = %d", p->SNR);
+	printk(KERN_DEBUG "RSSI = %d", p->RSSI);
+	printk(KERN_DEBUG "InBandPwr = %d", p->InBandPwr);
+	printk(KERN_DEBUG "CarrierOffset = %d", p->CarrierOffset);
+	printk(KERN_DEBUG "Frequency = %d", p->Frequency);
+	printk(KERN_DEBUG "Bandwidth = %d", p->Bandwidth);
+	printk(KERN_DEBUG "TransmissionMode = %d", p->TransmissionMode);
+	printk(KERN_DEBUG "ModemState = %d", p->ModemState);
+	printk(KERN_DEBUG "GuardInterval = %d", p->GuardInterval);
+	printk(KERN_DEBUG "SystemType = %d", p->SystemType);
+	printk(KERN_DEBUG "PartialReception = %d", p->PartialReception);
+	printk(KERN_DEBUG "NumOfLayers = %d", p->NumOfLayers);
+	printk(KERN_DEBUG "SegmentNumber = %d", p->SegmentNumber);
+	printk(KERN_DEBUG "TuneBW = %d", p->TuneBW);
+
+	for (i = 0; i < 3; i++) {
+		printk(KERN_DEBUG "%d: CodeRate = %d", i, p->LayerInfo[i].CodeRate);
+		printk(KERN_DEBUG "%d: Constellation = %d", i, p->LayerInfo[i].Constellation);
+		printk(KERN_DEBUG "%d: BER = %d", i, p->LayerInfo[i].BER);
+		printk(KERN_DEBUG "%d: BERErrorCount = %d", i, p->LayerInfo[i].BERErrorCount);
+		printk(KERN_DEBUG "%d: BERBitCount = %d", i, p->LayerInfo[i].BERBitCount);
+		printk(KERN_DEBUG "%d: PreBER = %d", i, p->LayerInfo[i].PreBER);
+		printk(KERN_DEBUG "%d: TS_PER = %d", i, p->LayerInfo[i].TS_PER);
+		printk(KERN_DEBUG "%d: ErrorTSPackets = %d", i, p->LayerInfo[i].ErrorTSPackets);
+		printk(KERN_DEBUG "%d: TotalTSPackets = %d", i, p->LayerInfo[i].TotalTSPackets);
+		printk(KERN_DEBUG "%d: TILdepthI = %d", i, p->LayerInfo[i].TILdepthI);
+		printk(KERN_DEBUG "%d: NumberOfSegments = %d", i, p->LayerInfo[i].NumberOfSegments);
+		printk(KERN_DEBUG "%d: TMCCErrors = %d", i, p->LayerInfo[i].TMCCErrors);
+	}
+}
+
 /* Events that may come from DVB v3 adapter */
 static void sms_board_dvb3_event(struct smsdvb_client_t *client,
 		enum SMS_DVB3_EVENTS event) {
@@ -115,51 +245,9 @@ static void sms_board_dvb3_event(struct smsdvb_client_t *client,
 }
 
 static void smsdvb_update_dvb_stats(struct RECEPTION_STATISTICS_EX_S *pReceptionData,
-				   struct SMSHOSTLIB_STATISTICS_ST *p)
+				    struct SMSHOSTLIB_STATISTICS_ST *p)
 {
-	if (sms_dbg & 2) {
-		printk(KERN_DEBUG "IsRfLocked = %d", p->IsRfLocked);
-		printk(KERN_DEBUG "IsDemodLocked = %d", p->IsDemodLocked);
-		printk(KERN_DEBUG "IsExternalLNAOn = %d", p->IsExternalLNAOn);
-		printk(KERN_DEBUG "SNR = %d", p->SNR);
-		printk(KERN_DEBUG "BER = %d", p->BER);
-		printk(KERN_DEBUG "FIB_CRC = %d", p->FIB_CRC);
-		printk(KERN_DEBUG "TS_PER = %d", p->TS_PER);
-		printk(KERN_DEBUG "MFER = %d", p->MFER);
-		printk(KERN_DEBUG "RSSI = %d", p->RSSI);
-		printk(KERN_DEBUG "InBandPwr = %d", p->InBandPwr);
-		printk(KERN_DEBUG "CarrierOffset = %d", p->CarrierOffset);
-		printk(KERN_DEBUG "ModemState = %d", p->ModemState);
-		printk(KERN_DEBUG "Frequency = %d", p->Frequency);
-		printk(KERN_DEBUG "Bandwidth = %d", p->Bandwidth);
-		printk(KERN_DEBUG "TransmissionMode = %d", p->TransmissionMode);
-		printk(KERN_DEBUG "ModemState = %d", p->ModemState);
-		printk(KERN_DEBUG "GuardInterval = %d", p->GuardInterval);
-		printk(KERN_DEBUG "CodeRate = %d", p->CodeRate);
-		printk(KERN_DEBUG "LPCodeRate = %d", p->LPCodeRate);
-		printk(KERN_DEBUG "Hierarchy = %d", p->Hierarchy);
-		printk(KERN_DEBUG "Constellation = %d", p->Constellation);
-		printk(KERN_DEBUG "BurstSize = %d", p->BurstSize);
-		printk(KERN_DEBUG "BurstDuration = %d", p->BurstDuration);
-		printk(KERN_DEBUG "BurstCycleTime = %d", p->BurstCycleTime);
-		printk(KERN_DEBUG "CalculatedBurstCycleTime = %d", p->CalculatedBurstCycleTime);
-		printk(KERN_DEBUG "NumOfRows = %d", p->NumOfRows);
-		printk(KERN_DEBUG "NumOfPaddCols = %d", p->NumOfPaddCols);
-		printk(KERN_DEBUG "NumOfPunctCols = %d", p->NumOfPunctCols);
-		printk(KERN_DEBUG "ErrorTSPackets = %d", p->ErrorTSPackets);
-		printk(KERN_DEBUG "TotalTSPackets = %d", p->TotalTSPackets);
-		printk(KERN_DEBUG "NumOfValidMpeTlbs = %d", p->NumOfValidMpeTlbs);
-		printk(KERN_DEBUG "NumOfInvalidMpeTlbs = %d", p->NumOfInvalidMpeTlbs);
-		printk(KERN_DEBUG "NumOfCorrectedMpeTlbs = %d", p->NumOfCorrectedMpeTlbs);
-		printk(KERN_DEBUG "BERErrorCount = %d", p->BERErrorCount);
-		printk(KERN_DEBUG "BERBitCount = %d", p->BERBitCount);
-		printk(KERN_DEBUG "SmsToHostTxErrors = %d", p->SmsToHostTxErrors);
-		printk(KERN_DEBUG "PreBER = %d", p->PreBER);
-		printk(KERN_DEBUG "CellId = %d", p->CellId);
-		printk(KERN_DEBUG "DvbhSrvIndHP = %d", p->DvbhSrvIndHP);
-		printk(KERN_DEBUG "DvbhSrvIndLP = %d", p->DvbhSrvIndLP);
-		printk(KERN_DEBUG "NumMPEReceived = %d", p->NumMPEReceived);
-	}
+	smsdvb_print_dvb_stats(p);
 
 	/* update reception data */
 	pReceptionData->IsRfLocked = p->IsRfLocked;
@@ -179,43 +267,9 @@ static void smsdvb_update_dvb_stats(struct RECEPTION_STATISTICS_EX_S *pReception
 };
 
 static void smsdvb_update_isdbt_stats(struct RECEPTION_STATISTICS_EX_S *pReceptionData,
-				    struct SMSHOSTLIB_STATISTICS_ISDBT_ST *p)
+				      struct SMSHOSTLIB_STATISTICS_ISDBT_ST *p)
 {
-	int i;
-
-	if (sms_dbg & 2) {
-		printk(KERN_DEBUG "IsRfLocked = %d", p->IsRfLocked);
-		printk(KERN_DEBUG "IsDemodLocked = %d", p->IsDemodLocked);
-		printk(KERN_DEBUG "IsExternalLNAOn = %d", p->IsExternalLNAOn);
-		printk(KERN_DEBUG "SNR = %d", p->SNR);
-		printk(KERN_DEBUG "RSSI = %d", p->RSSI);
-		printk(KERN_DEBUG "InBandPwr = %d", p->InBandPwr);
-		printk(KERN_DEBUG "CarrierOffset = %d", p->CarrierOffset);
-		printk(KERN_DEBUG "Frequency = %d", p->Frequency);
-		printk(KERN_DEBUG "Bandwidth = %d", p->Bandwidth);
-		printk(KERN_DEBUG "TransmissionMode = %d", p->TransmissionMode);
-		printk(KERN_DEBUG "ModemState = %d", p->ModemState);
-		printk(KERN_DEBUG "GuardInterval = %d", p->GuardInterval);
-		printk(KERN_DEBUG "SystemType = %d", p->SystemType);
-		printk(KERN_DEBUG "PartialReception = %d", p->PartialReception);
-		printk(KERN_DEBUG "NumOfLayers = %d", p->NumOfLayers);
-		printk(KERN_DEBUG "SmsToHostTxErrors = %d", p->SmsToHostTxErrors);
-
-		for (i = 0; i < 3; i++) {
-			printk(KERN_DEBUG "%d: CodeRate = %d", i, p->LayerInfo[i].CodeRate);
-			printk(KERN_DEBUG "%d: Constellation = %d", i, p->LayerInfo[i].Constellation);
-			printk(KERN_DEBUG "%d: BER = %d", i, p->LayerInfo[i].BER);
-			printk(KERN_DEBUG "%d: BERErrorCount = %d", i, p->LayerInfo[i].BERErrorCount);
-			printk(KERN_DEBUG "%d: BERBitCount = %d", i, p->LayerInfo[i].BERBitCount);
-			printk(KERN_DEBUG "%d: PreBER = %d", i, p->LayerInfo[i].PreBER);
-			printk(KERN_DEBUG "%d: TS_PER = %d", i, p->LayerInfo[i].TS_PER);
-			printk(KERN_DEBUG "%d: ErrorTSPackets = %d", i, p->LayerInfo[i].ErrorTSPackets);
-			printk(KERN_DEBUG "%d: TotalTSPackets = %d", i, p->LayerInfo[i].TotalTSPackets);
-			printk(KERN_DEBUG "%d: TILdepthI = %d", i, p->LayerInfo[i].TILdepthI);
-			printk(KERN_DEBUG "%d: NumberOfSegments = %d", i, p->LayerInfo[i].NumberOfSegments);
-			printk(KERN_DEBUG "%d: TMCCErrors = %d", i, p->LayerInfo[i].TMCCErrors);
-		}
-	}
+	smsdvb_print_isdb_stats(p);
 
 	/* update reception data */
 	pReceptionData->IsRfLocked = p->IsRfLocked;
@@ -249,41 +303,7 @@ static void smsdvb_update_isdbt_stats(struct RECEPTION_STATISTICS_EX_S *pRecepti
 static void smsdvb_update_isdbt_stats_ex(struct RECEPTION_STATISTICS_EX_S *pReceptionData,
 				    struct SMSHOSTLIB_STATISTICS_ISDBT_EX_ST *p)
 {
-	int i;
-
-	if (sms_dbg & 2) {
-		printk(KERN_DEBUG "IsRfLocked = %d", p->IsRfLocked);
-		printk(KERN_DEBUG "IsDemodLocked = %d", p->IsDemodLocked);
-		printk(KERN_DEBUG "IsExternalLNAOn = %d", p->IsExternalLNAOn);
-		printk(KERN_DEBUG "SNR = %d", p->SNR);
-		printk(KERN_DEBUG "RSSI = %d", p->RSSI);
-		printk(KERN_DEBUG "InBandPwr = %d", p->InBandPwr);
-		printk(KERN_DEBUG "CarrierOffset = %d", p->CarrierOffset);
-		printk(KERN_DEBUG "Frequency = %d", p->Frequency);
-		printk(KERN_DEBUG "Bandwidth = %d", p->Bandwidth);
-		printk(KERN_DEBUG "TransmissionMode = %d", p->TransmissionMode);
-		printk(KERN_DEBUG "ModemState = %d", p->ModemState);
-		printk(KERN_DEBUG "GuardInterval = %d", p->GuardInterval);
-		printk(KERN_DEBUG "SystemType = %d", p->SystemType);
-		printk(KERN_DEBUG "PartialReception = %d", p->PartialReception);
-		printk(KERN_DEBUG "NumOfLayers = %d", p->NumOfLayers);
-		printk(KERN_DEBUG "SegmentNumber = %d", p->SegmentNumber);
-		printk(KERN_DEBUG "TuneBW = %d", p->TuneBW);
-		for (i = 0; i < 3; i++) {
-			printk(KERN_DEBUG "%d: CodeRate = %d", i, p->LayerInfo[i].CodeRate);
-			printk(KERN_DEBUG "%d: Constellation = %d", i, p->LayerInfo[i].Constellation);
-			printk(KERN_DEBUG "%d: BER = %d", i, p->LayerInfo[i].BER);
-			printk(KERN_DEBUG "%d: BERErrorCount = %d", i, p->LayerInfo[i].BERErrorCount);
-			printk(KERN_DEBUG "%d: BERBitCount = %d", i, p->LayerInfo[i].BERBitCount);
-			printk(KERN_DEBUG "%d: PreBER = %d", i, p->LayerInfo[i].PreBER);
-			printk(KERN_DEBUG "%d: TS_PER = %d", i, p->LayerInfo[i].TS_PER);
-			printk(KERN_DEBUG "%d: ErrorTSPackets = %d", i, p->LayerInfo[i].ErrorTSPackets);
-			printk(KERN_DEBUG "%d: TotalTSPackets = %d", i, p->LayerInfo[i].TotalTSPackets);
-			printk(KERN_DEBUG "%d: TILdepthI = %d", i, p->LayerInfo[i].TILdepthI);
-			printk(KERN_DEBUG "%d: NumberOfSegments = %d", i, p->LayerInfo[i].NumberOfSegments);
-			printk(KERN_DEBUG "%d: TMCCErrors = %d", i, p->LayerInfo[i].TMCCErrors);
-		}
-	}
+	smsdvb_print_isdb_stats_ex(p);
 
 	/* update reception data */
 	pReceptionData->IsRfLocked = p->IsRfLocked;
Signature · 1 line
1.8.1.4
#27 lore raw

PATCH 27/46 siano: Convert it to report DVBv5 stats

In reply to Mauro Carvalho Chehab

While this frontend provides a nice set of statistics, the way it is currently reported to userspace is poor. Worse than that, instead of using quality indicators that range from 0 to 65535, as expected by userspace, most indicators range from 0 to 100.

Improve it by using DVBv5 statistics API. The legacy indicators are still reported using the very same old way, but they're now using a proper range (0 to 65535 for quality indicadors; 0.1 dB for SNR).

---
 drivers/media/common/siano/smsdvb.c | 826 ++++++++++++++++++++----------------
 1 file changed, 468 insertions(+), 358 deletions(-)
drivers/media/common/siano/smsdvb.c +468 -358
index 04544f5..a5f5272 100644
@@ -49,7 +49,10 @@ struct smsdvb_client_t {
 	struct completion       tune_done;
 	struct completion       stats_done;
 
-	struct SMSHOSTLIB_STATISTICS_DVB_EX_S sms_stat_dvb;
+	int last_per;
+
+	int legacy_ber, legacy_per;
+
 	int event_fe_state;
 	int event_unc_state;
 };
@@ -61,6 +64,82 @@ static int sms_dbg;
 module_param_named(debug, sms_dbg, int, 0644);
 MODULE_PARM_DESC(debug, "set debug level (info=1, adv=2 (or-able))");
 
+/*
+ * This struct is a mix of RECEPTION_STATISTICS_EX_S and SRVM_SIGNAL_STATUS_S.
+ * It was obtained by comparing the way it was filled by the original code
+ */
+struct RECEPTION_STATISTICS_PER_SLICES_S {
+	u32 result;
+	u32 snr;
+	s32 inBandPower;
+	u32 tsPackets;
+	u32 etsPackets;
+	u32 constellation;
+	u32 hpCode;
+	u32 tpsSrvIndLP;
+	u32 tpsSrvIndHP;
+	u32 cellId;
+	u32 reason;
+	u32 requestId;
+	u32 ModemState;		/* from SMSHOSTLIB_DVB_MODEM_STATE_ET */
+
+	u32 BER;		/* Post Viterbi BER [1E-5] */
+	s32 RSSI;		/* dBm */
+	s32 CarrierOffset;	/* Carrier Offset in bin/1024 */
+
+	u32 IsRfLocked;		/* 0 - not locked, 1 - locked */
+	u32 IsDemodLocked;	/* 0 - not locked, 1 - locked */
+
+	u32 BERBitCount;	/* Total number of SYNC bits. */
+	u32 BERErrorCount;	/* Number of erronous SYNC bits. */
+
+	s32 MRC_SNR;		/* dB */
+	s32 MRC_InBandPwr;	/* In band power in dBM */
+	s32 MRC_RSSI;		/* dBm */
+};
+
+u32 sms_to_bw_table[] = {
+	[BW_8_MHZ]		= 8000000,
+	[BW_7_MHZ]		= 7000000,
+	[BW_6_MHZ]		= 6000000,
+	[BW_5_MHZ]		= 5000000,
+	[BW_2_MHZ]		= 2000000,
+	[BW_1_5_MHZ]		= 1500000,
+	[BW_ISDBT_1SEG]		= 6000000,
+	[BW_ISDBT_3SEG]		= 6000000,
+	[BW_ISDBT_13SEG]	= 6000000,
+};
+
+u32 sms_to_guard_interval_table[] = {
+	[0] = GUARD_INTERVAL_1_32,
+	[1] = GUARD_INTERVAL_1_16,
+	[2] = GUARD_INTERVAL_1_8,
+	[3] = GUARD_INTERVAL_1_4,
+};
+
+u32 sms_to_code_rate_table[] = {
+	[0] = FEC_1_2,
+	[1] = FEC_2_3,
+	[2] = FEC_3_4,
+	[3] = FEC_5_6,
+	[4] = FEC_7_8,
+};
+
+
+u32 sms_to_hierarchy_table[] = {
+	[0] = HIERARCHY_NONE,
+	[1] = HIERARCHY_1,
+	[2] = HIERARCHY_2,
+	[3] = HIERARCHY_4,
+};
+
+u32 sms_to_modulation_table[] = {
+	[0] = QPSK,
+	[1] = QAM_16,
+	[2] = QAM_64,
+	[3] = DQPSK,
+};
+
 static void smsdvb_print_dvb_stats(struct SMSHOSTLIB_STATISTICS_ST *p)
 {
 	if (!(sms_dbg & 2))
@@ -244,93 +323,350 @@ static void sms_board_dvb3_event(struct smsdvb_client_t *client,
 	}
 }
 
-static void smsdvb_update_dvb_stats(struct RECEPTION_STATISTICS_EX_S *pReceptionData,
+static void smsdvb_stats_not_ready(struct dvb_frontend *fe)
+{
+	struct smsdvb_client_t *client =
+		container_of(fe, struct smsdvb_client_t, frontend);
+	struct smscore_device_t *coredev = client->coredev;
+	struct dtv_frontend_properties *c = &fe->dtv_property_cache;
+	int i, n_layers;
+
+	switch (smscore_get_device_mode(coredev)) {
+	case DEVICE_MODE_ISDBT:
+	case DEVICE_MODE_ISDBT_BDA:
+		n_layers = 4;
+	default:
+		n_layers = 1;
+	}
+
+	/* Fill the length of each status counter */
+
+	/* Only global stats */
+	c->strength.len = 1;
+	c->cnr.len = 1;
+
+	/* Per-layer stats */
+	c->post_bit_error.len = n_layers;
+	c->post_bit_count.len = n_layers;
+	c->block_error.len = n_layers;
+	c->block_count.len = n_layers;
+
+	/* Signal is always available */
+	c->strength.stat[0].scale = FE_SCALE_RELATIVE;
+	c->strength.stat[0].uvalue = 0;
+
+	/* Put all of them at FE_SCALE_NOT_AVAILABLE */
+	for (i = 0; i < n_layers; i++) {
+		c->cnr.stat[i].scale = FE_SCALE_NOT_AVAILABLE;
+		c->post_bit_error.stat[i].scale = FE_SCALE_NOT_AVAILABLE;
+		c->post_bit_count.stat[i].scale = FE_SCALE_NOT_AVAILABLE;
+		c->block_error.stat[i].scale = FE_SCALE_NOT_AVAILABLE;
+		c->block_count.stat[i].scale = FE_SCALE_NOT_AVAILABLE;
+	}
+}
+
+static inline int sms_to_mode(u32 mode)
+{
+	switch (mode) {
+	case 2:
+		return TRANSMISSION_MODE_2K;
+	case 4:
+		return TRANSMISSION_MODE_4K;
+	case 8:
+		return TRANSMISSION_MODE_8K;
+	}
+	return TRANSMISSION_MODE_AUTO;
+}
+
+static inline int sms_to_status(u32 is_demod_locked, u32 is_rf_locked)
+{
+	if (is_demod_locked)
+		return FE_HAS_SIGNAL  | FE_HAS_CARRIER | FE_HAS_VITERBI |
+		       FE_HAS_SYNC    | FE_HAS_LOCK;
+
+	if (is_rf_locked)
+		return FE_HAS_SIGNAL | FE_HAS_CARRIER;
+
+	return 0;
+}
+
+
+#define convert_from_table(value, table, defval) ({			\
+	u32 __ret;							\
+	if (value < ARRAY_SIZE(table))					\
+		__ret = table[value];					\
+	else								\
+		__ret = defval;						\
+	__ret;								\
+})
+
+#define sms_to_bw(value)						\
+	convert_from_table(value, sms_to_bw_table, 0);
+
+#define sms_to_guard_interval(value)					\
+	convert_from_table(value, sms_to_guard_interval_table,		\
+			   GUARD_INTERVAL_AUTO);
+
+#define sms_to_code_rate(value)						\
+	convert_from_table(value, sms_to_code_rate_table,		\
+			   FEC_NONE);
+
+#define sms_to_hierarchy(value)						\
+	convert_from_table(value, sms_to_hierarchy_table,		\
+			   FEC_NONE);
+
+#define sms_to_modulation(value)					\
+	convert_from_table(value, sms_to_modulation_table,		\
+			   FEC_NONE);
+
+static void smsdvb_update_tx_params(struct smsdvb_client_t *client,
+				    struct TRANSMISSION_STATISTICS_S *p)
+{
+	struct dvb_frontend *fe = &client->frontend;
+	struct dtv_frontend_properties *c = &fe->dtv_property_cache;
+
+	c->frequency = p->Frequency;
+	client->fe_status = sms_to_status(p->IsDemodLocked, 0);
+	c->bandwidth_hz = sms_to_bw(p->Bandwidth);
+	c->transmission_mode = sms_to_mode(p->TransmissionMode);
+	c->guard_interval = sms_to_guard_interval(p->GuardInterval);
+	c->code_rate_HP = sms_to_code_rate(p->CodeRate);
+	c->code_rate_LP = sms_to_code_rate(p->LPCodeRate);
+	c->hierarchy = sms_to_hierarchy(p->Hierarchy);
+	c->modulation = sms_to_modulation(p->Constellation);
+}
+
+static void smsdvb_update_per_slices(struct smsdvb_client_t *client,
+				     struct RECEPTION_STATISTICS_PER_SLICES_S *p)
+{
+	struct dvb_frontend *fe = &client->frontend;
+	struct dtv_frontend_properties *c = &fe->dtv_property_cache;
+
+	client->fe_status = sms_to_status(p->IsDemodLocked, p->IsRfLocked);
+	c->modulation = sms_to_modulation(p->constellation);
+
+	/* TS PER */
+	client->last_per = c->block_error.stat[0].uvalue;
+	c->block_error.stat[0].scale = FE_SCALE_COUNTER;
+	c->block_count.stat[0].scale = FE_SCALE_COUNTER;
+	c->block_error.stat[0].uvalue += p->etsPackets;
+	c->block_count.stat[0].uvalue += p->etsPackets + p->tsPackets;
+
+	/* BER */
+	c->post_bit_error.stat[0].scale = FE_SCALE_COUNTER;
+	c->post_bit_count.stat[0].scale = FE_SCALE_COUNTER;
+	c->post_bit_error.stat[0].uvalue += p->BERErrorCount;
+	c->post_bit_count.stat[0].uvalue += p->BERBitCount;
+
+	/* Legacy PER/BER */
+	client->legacy_per = (p->etsPackets * 65535) /
+			     (p->tsPackets + p->etsPackets);
+
+	/* Signal Strength, in DBm */
+	c->strength.stat[0].uvalue = p->RSSI * 1000;
+
+	/* Carrier to Noise ratio, in DB */
+	c->cnr.stat[0].scale = FE_SCALE_DECIBEL;
+	c->cnr.stat[0].svalue = p->snr * 1000;
+}
+
+static void smsdvb_update_dvb_stats(struct smsdvb_client_t *client,
 				    struct SMSHOSTLIB_STATISTICS_ST *p)
 {
+	struct dvb_frontend *fe = &client->frontend;
+	struct dtv_frontend_properties *c = &fe->dtv_property_cache;
+
 	smsdvb_print_dvb_stats(p);
 
+	client->fe_status = sms_to_status(p->IsDemodLocked, p->IsRfLocked);
+
+	/* Update DVB modulation parameters */
+	c->frequency = p->Frequency;
+	client->fe_status = sms_to_status(p->IsDemodLocked, 0);
+	c->bandwidth_hz = sms_to_bw(p->Bandwidth);
+	c->transmission_mode = sms_to_mode(p->TransmissionMode);
+	c->guard_interval = sms_to_guard_interval(p->GuardInterval);
+	c->code_rate_HP = sms_to_code_rate(p->CodeRate);
+	c->code_rate_LP = sms_to_code_rate(p->LPCodeRate);
+	c->hierarchy = sms_to_hierarchy(p->Hierarchy);
+	c->modulation = sms_to_modulation(p->Constellation);
+
 	/* update reception data */
-	pReceptionData->IsRfLocked = p->IsRfLocked;
-	pReceptionData->IsDemodLocked = p->IsDemodLocked;
-	pReceptionData->IsExternalLNAOn = p->IsExternalLNAOn;
-	pReceptionData->ModemState = p->ModemState;
-	pReceptionData->SNR = p->SNR;
-	pReceptionData->BER = p->BER;
-	pReceptionData->BERErrorCount = p->BERErrorCount;
-	pReceptionData->BERBitCount = p->BERBitCount;
-	pReceptionData->RSSI = p->RSSI;
-	CORRECT_STAT_RSSI(*pReceptionData);
-	pReceptionData->InBandPwr = p->InBandPwr;
-	pReceptionData->CarrierOffset = p->CarrierOffset;
-	pReceptionData->ErrorTSPackets = p->ErrorTSPackets;
-	pReceptionData->TotalTSPackets = p->TotalTSPackets;
+	c->lna = p->IsExternalLNAOn ? 1 : 0;
+
+	/* Carrier to Noise ratio, in DB */
+	c->cnr.stat[0].scale = FE_SCALE_DECIBEL;
+	c->cnr.stat[0].svalue = p->SNR * 1000;
+
+	/* Signal Strength, in DBm */
+	c->strength.stat[0].uvalue = p->RSSI * 1000;
+
+	/* TS PER */
+	client->last_per = c->block_error.stat[0].uvalue;
+	c->block_error.stat[0].scale = FE_SCALE_COUNTER;
+	c->block_count.stat[0].scale = FE_SCALE_COUNTER;
+	c->block_error.stat[0].uvalue += p->ErrorTSPackets;
+	c->block_count.stat[0].uvalue += p->TotalTSPackets;
+
+	/* BER */
+	c->post_bit_error.stat[0].scale = FE_SCALE_COUNTER;
+	c->post_bit_count.stat[0].scale = FE_SCALE_COUNTER;
+	c->post_bit_error.stat[0].uvalue += p->BERErrorCount;
+	c->post_bit_count.stat[0].uvalue += p->BERBitCount;
+
+	/* Legacy PER/BER */
+	client->legacy_ber = p->BER;
 };
 
-static void smsdvb_update_isdbt_stats(struct RECEPTION_STATISTICS_EX_S *pReceptionData,
+static void smsdvb_update_isdbt_stats(struct smsdvb_client_t *client,
 				      struct SMSHOSTLIB_STATISTICS_ISDBT_ST *p)
 {
+	struct dvb_frontend *fe = &client->frontend;
+	struct dtv_frontend_properties *c = &fe->dtv_property_cache;
+	struct SMSHOSTLIB_ISDBT_LAYER_STAT_ST *lr;
+	int i, n_layers;
+
 	smsdvb_print_isdb_stats(p);
 
+	/* Update ISDB-T transmission parameters */
+	c->frequency = p->Frequency;
+	client->fe_status = sms_to_status(p->IsDemodLocked, 0);
+	c->bandwidth_hz = sms_to_bw(p->Bandwidth);
+	c->transmission_mode = sms_to_mode(p->TransmissionMode);
+	c->guard_interval = sms_to_guard_interval(p->GuardInterval);
+	c->isdbt_partial_reception = p->PartialReception ? 1 : 0;
+	n_layers = p->NumOfLayers;
+	if (n_layers < 1)
+		n_layers = 1;
+	if (n_layers > 3)
+		n_layers = 3;
+	c->isdbt_layer_enabled = 0;
+
 	/* update reception data */
-	pReceptionData->IsRfLocked = p->IsRfLocked;
-	pReceptionData->IsDemodLocked = p->IsDemodLocked;
-	pReceptionData->IsExternalLNAOn = p->IsExternalLNAOn;
-	pReceptionData->ModemState = p->ModemState;
-	pReceptionData->SNR = p->SNR;
-	pReceptionData->BER = p->LayerInfo[0].BER;
-	pReceptionData->BERErrorCount = p->LayerInfo[0].BERErrorCount;
-	pReceptionData->BERBitCount = p->LayerInfo[0].BERBitCount;
-	pReceptionData->RSSI = p->RSSI;
-	CORRECT_STAT_RSSI(*pReceptionData);
-	pReceptionData->InBandPwr = p->InBandPwr;
-
-	pReceptionData->CarrierOffset = p->CarrierOffset;
-	pReceptionData->ErrorTSPackets = p->LayerInfo[0].ErrorTSPackets;
-	pReceptionData->TotalTSPackets = p->LayerInfo[0].TotalTSPackets;
-	pReceptionData->MFER = 0;
+	c->lna = p->IsExternalLNAOn ? 1 : 0;
 
-	/* TS PER */
-	if ((p->LayerInfo[0].TotalTSPackets +
-		 p->LayerInfo[0].ErrorTSPackets) > 0) {
-		pReceptionData->TS_PER = (p->LayerInfo[0].ErrorTSPackets
-				* 100) / (p->LayerInfo[0].TotalTSPackets
-				+ p->LayerInfo[0].ErrorTSPackets);
-	} else {
-		pReceptionData->TS_PER = 0;
+	/* Carrier to Noise ratio, in DB */
+	c->cnr.stat[0].scale = FE_SCALE_DECIBEL;
+	c->cnr.stat[0].svalue = p->SNR * 1000;
+
+	/* Signal Strength, in DBm */
+	c->strength.stat[0].uvalue = p->RSSI * 1000;
+
+	client->last_per = c->block_error.stat[0].uvalue;
+
+	/* Clears global counters, as the code below will sum it again */
+	c->block_error.stat[0].uvalue = 0;
+	c->block_count.stat[0].uvalue = 0;
+	c->post_bit_error.stat[0].uvalue = 0;
+	c->post_bit_count.stat[0].uvalue = 0;
+
+	for (i = 0; i < n_layers; i++) {
+		lr = &p->LayerInfo[i];
+
+		/* Update per-layer transmission parameters */
+		if (lr->NumberOfSegments > 0 && lr->NumberOfSegments < 13) {
+			c->isdbt_layer_enabled |= 1 << i;
+			c->layer[i].segment_count = lr->NumberOfSegments;
+		} else {
+			continue;
+		}
+		c->layer[i].modulation = sms_to_modulation(lr->Constellation);
+
+		/* TS PER */
+		c->block_error.stat[i].scale = FE_SCALE_COUNTER;
+		c->block_count.stat[i].scale = FE_SCALE_COUNTER;
+		c->block_error.stat[i].uvalue += lr->ErrorTSPackets;
+		c->block_count.stat[i].uvalue += lr->TotalTSPackets;
+
+		/* Update global PER counter */
+		c->block_error.stat[0].uvalue += lr->ErrorTSPackets;
+		c->block_count.stat[0].uvalue += lr->TotalTSPackets;
+
+		/* BER */
+		c->post_bit_error.stat[i].scale = FE_SCALE_COUNTER;
+		c->post_bit_count.stat[i].scale = FE_SCALE_COUNTER;
+		c->post_bit_error.stat[i].uvalue += lr->BERErrorCount;
+		c->post_bit_count.stat[i].uvalue += lr->BERBitCount;
+
+		/* Update global BER counter */
+		c->post_bit_error.stat[0].uvalue += lr->BERErrorCount;
+		c->post_bit_count.stat[0].uvalue += lr->BERBitCount;
 	}
 }
 
-static void smsdvb_update_isdbt_stats_ex(struct RECEPTION_STATISTICS_EX_S *pReceptionData,
-				    struct SMSHOSTLIB_STATISTICS_ISDBT_EX_ST *p)
+static void smsdvb_update_isdbt_stats_ex(struct smsdvb_client_t *client,
+					 struct SMSHOSTLIB_STATISTICS_ISDBT_EX_ST *p)
 {
+	struct dvb_frontend *fe = &client->frontend;
+	struct dtv_frontend_properties *c = &fe->dtv_property_cache;
+	struct SMSHOSTLIB_ISDBT_LAYER_STAT_ST *lr;
+	int i, n_layers;
+
 	smsdvb_print_isdb_stats_ex(p);
 
+	/* Update ISDB-T transmission parameters */
+	c->frequency = p->Frequency;
+	client->fe_status = sms_to_status(p->IsDemodLocked, 0);
+	c->bandwidth_hz = sms_to_bw(p->Bandwidth);
+	c->transmission_mode = sms_to_mode(p->TransmissionMode);
+	c->guard_interval = sms_to_guard_interval(p->GuardInterval);
+	c->isdbt_partial_reception = p->PartialReception ? 1 : 0;
+	n_layers = p->NumOfLayers;
+	if (n_layers < 1)
+		n_layers = 1;
+	if (n_layers > 3)
+		n_layers = 3;
+	c->isdbt_layer_enabled = 0;
+
 	/* update reception data */
-	pReceptionData->IsRfLocked = p->IsRfLocked;
-	pReceptionData->IsDemodLocked = p->IsDemodLocked;
-	pReceptionData->IsExternalLNAOn = p->IsExternalLNAOn;
-	pReceptionData->ModemState = p->ModemState;
-	pReceptionData->SNR = p->SNR;
-	pReceptionData->BER = p->LayerInfo[0].BER;
-	pReceptionData->BERErrorCount = p->LayerInfo[0].BERErrorCount;
-	pReceptionData->BERBitCount = p->LayerInfo[0].BERBitCount;
-	pReceptionData->RSSI = p->RSSI;
-	CORRECT_STAT_RSSI(*pReceptionData);
-	pReceptionData->InBandPwr = p->InBandPwr;
-
-	pReceptionData->CarrierOffset = p->CarrierOffset;
-	pReceptionData->ErrorTSPackets = p->LayerInfo[0].ErrorTSPackets;
-	pReceptionData->TotalTSPackets = p->LayerInfo[0].TotalTSPackets;
-	pReceptionData->MFER = 0;
+	c->lna = p->IsExternalLNAOn ? 1 : 0;
 
-	/* TS PER */
-	if ((p->LayerInfo[0].TotalTSPackets +
-		 p->LayerInfo[0].ErrorTSPackets) > 0) {
-		pReceptionData->TS_PER = (p->LayerInfo[0].ErrorTSPackets
-				* 100) / (p->LayerInfo[0].TotalTSPackets
-				+ p->LayerInfo[0].ErrorTSPackets);
-	} else {
-		pReceptionData->TS_PER = 0;
+	/* Carrier to Noise ratio, in DB */
+	c->cnr.stat[0].scale = FE_SCALE_DECIBEL;
+	c->cnr.stat[0].svalue = p->SNR * 1000;
+
+	/* Signal Strength, in DBm */
+	c->strength.stat[0].uvalue = p->RSSI * 1000;
+
+	client->last_per = c->block_error.stat[0].uvalue;
+
+	/* Clears global counters, as the code below will sum it again */
+	c->block_error.stat[0].uvalue = 0;
+	c->block_count.stat[0].uvalue = 0;
+	c->post_bit_error.stat[0].uvalue = 0;
+	c->post_bit_count.stat[0].uvalue = 0;
+
+	for (i = 0; i < n_layers; i++) {
+		lr = &p->LayerInfo[i];
+
+		/* Update per-layer transmission parameters */
+		if (lr->NumberOfSegments > 0 && lr->NumberOfSegments < 13) {
+			c->isdbt_layer_enabled |= 1 << i;
+			c->layer[i].segment_count = lr->NumberOfSegments;
+		} else {
+			continue;
+		}
+		c->layer[i].modulation = sms_to_modulation(lr->Constellation);
+
+		/* TS PER */
+		c->block_error.stat[i].scale = FE_SCALE_COUNTER;
+		c->block_count.stat[i].scale = FE_SCALE_COUNTER;
+		c->block_error.stat[i].uvalue += lr->ErrorTSPackets;
+		c->block_count.stat[i].uvalue += lr->TotalTSPackets;
+
+		/* Update global PER counter */
+		c->block_error.stat[0].uvalue += lr->ErrorTSPackets;
+		c->block_count.stat[0].uvalue += lr->TotalTSPackets;
+
+		/* BER */
+		c->post_bit_error.stat[i].scale = FE_SCALE_COUNTER;
+		c->post_bit_count.stat[i].scale = FE_SCALE_COUNTER;
+		c->post_bit_error.stat[i].uvalue += lr->BERErrorCount;
+		c->post_bit_count.stat[i].uvalue += lr->BERBitCount;
+
+		/* Update global BER counter */
+		c->post_bit_error.stat[0].uvalue += lr->BERErrorCount;
+		c->post_bit_count.stat[0].uvalue += lr->BERBitCount;
 	}
 }
 
@@ -339,13 +675,14 @@ static int smsdvb_onresponse(void *context, struct smscore_buffer_t *cb)
 	struct smsdvb_client_t *client = (struct smsdvb_client_t *) context;
 	struct SmsMsgHdr_ST *phdr = (struct SmsMsgHdr_ST *) (((u8 *) cb->p)
 			+ cb->offset);
-	u32 *pMsgData = (u32 *) phdr + 1;
-	/*u32 MsgDataLen = phdr->msgLength - sizeof(struct SmsMsgHdr_ST);*/
+	void *p = phdr + 1;
+	struct dvb_frontend *fe = &client->frontend;
+	struct dtv_frontend_properties *c = &fe->dtv_property_cache;
 	bool is_status_update = false;
 
 	switch (phdr->msgType) {
 	case MSG_SMS_DVBT_BDA_DATA:
-		dvb_dmx_swfilter(&client->demux, (u8 *)(phdr + 1),
+		dvb_dmx_swfilter(&client->demux, p,
 				 cb->size - sizeof(struct SmsMsgHdr_ST));
 		break;
 
@@ -355,166 +692,64 @@ static int smsdvb_onresponse(void *context, struct smscore_buffer_t *cb)
 		break;
 
 	case MSG_SMS_SIGNAL_DETECTED_IND:
-		client->sms_stat_dvb.TransmissionData.IsDemodLocked = true;
+		client->fe_status = FE_HAS_SIGNAL  | FE_HAS_CARRIER |
+				    FE_HAS_VITERBI | FE_HAS_SYNC    |
+				    FE_HAS_LOCK;
+
 		is_status_update = true;
 		break;
 
 	case MSG_SMS_NO_SIGNAL_IND:
-		client->sms_stat_dvb.TransmissionData.IsDemodLocked = false;
+		client->fe_status = 0;
+
 		is_status_update = true;
 		break;
 
-	case MSG_SMS_TRANSMISSION_IND: {
-
-		pMsgData++;
-		memcpy(&client->sms_stat_dvb.TransmissionData, pMsgData,
-				sizeof(struct TRANSMISSION_STATISTICS_S));
+	case MSG_SMS_TRANSMISSION_IND:
+		smsdvb_update_tx_params(client, p);
 
-#if 1
-		/*
-		 * FIXME: newer driver doesn't have those fixes
-		 * Are those firmware-specific stuff?
-		 */
-
-		/* Mo need to correct guard interval
-		 * (as opposed to old statistics message).
-		 */
-		CORRECT_STAT_BANDWIDTH(client->sms_stat_dvb.TransmissionData);
-		CORRECT_STAT_TRANSMISSON_MODE(
-				client->sms_stat_dvb.TransmissionData);
-#endif
 		is_status_update = true;
 		break;
-	}
-	case MSG_SMS_HO_PER_SLICES_IND: {
-		struct RECEPTION_STATISTICS_EX_S *pReceptionData =
-				&client->sms_stat_dvb.ReceptionData;
-		struct SRVM_SIGNAL_STATUS_S SignalStatusData;
-
-		pMsgData++;
-		SignalStatusData.result = pMsgData[0];
-		SignalStatusData.snr = pMsgData[1];
-		SignalStatusData.inBandPower = (s32) pMsgData[2];
-		SignalStatusData.tsPackets = pMsgData[3];
-		SignalStatusData.etsPackets = pMsgData[4];
-		SignalStatusData.constellation = pMsgData[5];
-		SignalStatusData.hpCode = pMsgData[6];
-		SignalStatusData.tpsSrvIndLP = pMsgData[7] & 0x03;
-		SignalStatusData.tpsSrvIndHP = pMsgData[8] & 0x03;
-		SignalStatusData.cellId = pMsgData[9] & 0xFFFF;
-		SignalStatusData.reason = pMsgData[10];
-		SignalStatusData.requestId = pMsgData[11];
-		pReceptionData->IsRfLocked = pMsgData[16];
-		pReceptionData->IsDemodLocked = pMsgData[17];
-		pReceptionData->ModemState = pMsgData[12];
-		pReceptionData->SNR = pMsgData[1];
-		pReceptionData->BER = pMsgData[13];
-		pReceptionData->RSSI = pMsgData[14];
-		CORRECT_STAT_RSSI(client->sms_stat_dvb.ReceptionData);
-
-		pReceptionData->InBandPwr = (s32) pMsgData[2];
-		pReceptionData->CarrierOffset = (s32) pMsgData[15];
-		pReceptionData->TotalTSPackets = pMsgData[3];
-		pReceptionData->ErrorTSPackets = pMsgData[4];
 
-		/* TS PER */
-		if ((SignalStatusData.tsPackets + SignalStatusData.etsPackets)
-				> 0) {
-			pReceptionData->TS_PER = (SignalStatusData.etsPackets
-					* 100) / (SignalStatusData.tsPackets
-					+ SignalStatusData.etsPackets);
-		} else {
-			pReceptionData->TS_PER = 0;
-		}
-
-		pReceptionData->BERBitCount = pMsgData[18];
-		pReceptionData->BERErrorCount = pMsgData[19];
-
-		pReceptionData->MRC_SNR = pMsgData[20];
-		pReceptionData->MRC_InBandPwr = pMsgData[21];
-		pReceptionData->MRC_RSSI = pMsgData[22];
+	case MSG_SMS_HO_PER_SLICES_IND:
+		smsdvb_update_per_slices(client, p);
 
 		is_status_update = true;
 		break;
-	}
-	case MSG_SMS_GET_STATISTICS_RES: {
-		union {
-			struct SMSHOSTLIB_STATISTICS_ISDBT_ST  isdbt;
-			struct SmsMsgStatisticsInfo_ST         dvb;
-		} *p = (void *) (phdr + 1);
-		struct RECEPTION_STATISTICS_EX_S *pReceptionData =
-				&client->sms_stat_dvb.ReceptionData;
-
-		is_status_update = true;
 
+	case MSG_SMS_GET_STATISTICS_RES:
 		switch (smscore_get_device_mode(client->coredev)) {
 		case DEVICE_MODE_ISDBT:
 		case DEVICE_MODE_ISDBT_BDA:
-			smsdvb_update_isdbt_stats(pReceptionData, &p->isdbt);
+			smsdvb_update_isdbt_stats(client, p);
 			break;
 		default:
-			smsdvb_update_dvb_stats(pReceptionData, &p->dvb.Stat);
-		}
-		if (!pReceptionData->IsDemodLocked) {
-			pReceptionData->SNR = 0;
-			pReceptionData->BER = 0;
-			pReceptionData->BERErrorCount = 0;
-			pReceptionData->InBandPwr = 0;
-			pReceptionData->ErrorTSPackets = 0;
+			smsdvb_update_dvb_stats(client, p);
 		}
 
+		is_status_update = true;
 		break;
-	}
-	case MSG_SMS_GET_STATISTICS_EX_RES: {
-		union {
-			struct SMSHOSTLIB_STATISTICS_ISDBT_EX_ST isdbt;
-			struct SMSHOSTLIB_STATISTICS_ST          dvb;
-		} *p = (void *) (phdr + 1);
-		struct RECEPTION_STATISTICS_EX_S *pReceptionData =
-				&client->sms_stat_dvb.ReceptionData;
 
+	/* Only for ISDB-T */
+	case MSG_SMS_GET_STATISTICS_EX_RES:
+		smsdvb_update_isdbt_stats_ex(client, p);
 		is_status_update = true;
-
-		switch (smscore_get_device_mode(client->coredev)) {
-		case DEVICE_MODE_ISDBT:
-		case DEVICE_MODE_ISDBT_BDA:
-			smsdvb_update_isdbt_stats_ex(pReceptionData, &p->isdbt);
-			break;
-		default:
-			smsdvb_update_dvb_stats(pReceptionData, &p->dvb);
-		}
-		if (!pReceptionData->IsDemodLocked) {
-			pReceptionData->SNR = 0;
-			pReceptionData->BER = 0;
-			pReceptionData->BERErrorCount = 0;
-			pReceptionData->InBandPwr = 0;
-			pReceptionData->ErrorTSPackets = 0;
-		}
-
 		break;
-	}
 	default:
 		sms_info("message not handled");
 	}
 	smscore_putbuffer(client->coredev, cb);
 
 	if (is_status_update) {
-		if (client->sms_stat_dvb.ReceptionData.IsDemodLocked) {
-			client->fe_status = FE_HAS_SIGNAL | FE_HAS_CARRIER
-				| FE_HAS_VITERBI | FE_HAS_SYNC | FE_HAS_LOCK;
+		if (client->fe_status == FE_HAS_LOCK) {
 			sms_board_dvb3_event(client, DVB3_EVENT_FE_LOCK);
-			if (client->sms_stat_dvb.ReceptionData.ErrorTSPackets
-					== 0)
+			if (client->last_per == c->block_error.stat[0].uvalue)
 				sms_board_dvb3_event(client, DVB3_EVENT_UNC_OK);
 			else
-				sms_board_dvb3_event(client,
-						DVB3_EVENT_UNC_ERR);
-
+				sms_board_dvb3_event(client, DVB3_EVENT_UNC_ERR);
 		} else {
-			if (client->sms_stat_dvb.ReceptionData.IsRfLocked)
-				client->fe_status = FE_HAS_SIGNAL | FE_HAS_CARRIER;
-			else
-				client->fe_status = 0;
+			smsdvb_stats_not_ready(fe);
+
 			sms_board_dvb3_event(client, DVB3_EVENT_FE_UNLOCK);
 		}
 		complete(&client->stats_done);
@@ -612,13 +847,20 @@ static int smsdvb_send_statistics_request(struct smsdvb_client_t *client)
 	Msg.msgFlags = 0;
 	Msg.msgLength = sizeof(Msg);
 
-	/*
-	 * Check for firmware version, to avoid breaking for old cards
-	 */
-	if (client->coredev->fw_version >= 0x800)
-		Msg.msgType = MSG_SMS_GET_STATISTICS_EX_REQ;
-	else
+	switch (smscore_get_device_mode(client->coredev)) {
+	case DEVICE_MODE_ISDBT:
+	case DEVICE_MODE_ISDBT_BDA:
+		/*
+		* Check for firmware version, to avoid breaking for old cards
+		*/
+		if (client->coredev->fw_version >= 0x800)
+			Msg.msgType = MSG_SMS_GET_STATISTICS_EX_REQ;
+		else
+			Msg.msgType = MSG_SMS_GET_STATISTICS_REQ;
+		break;
+	default:
 		Msg.msgType = MSG_SMS_GET_STATISTICS_REQ;
+	}
 
 	rc = smsdvb_sendrequest_and_wait(client, &Msg, sizeof(Msg),
 					 &client->stats_done);
@@ -628,12 +870,12 @@ static int smsdvb_send_statistics_request(struct smsdvb_client_t *client)
 
 static inline int led_feedback(struct smsdvb_client_t *client)
 {
-	if (client->fe_status & FE_HAS_LOCK)
-		return sms_board_led_feedback(client->coredev,
-			(client->sms_stat_dvb.ReceptionData.BER
-			== 0) ? SMS_LED_HI : SMS_LED_LO);
-	else
+	if (!(client->fe_status & FE_HAS_LOCK))
 		return sms_board_led_feedback(client->coredev, SMS_LED_OFF);
+
+	return sms_board_led_feedback(client->coredev,
+				     (client->legacy_ber == 0) ?
+				     SMS_LED_HI : SMS_LED_LO);
 }
 
 static int smsdvb_read_status(struct dvb_frontend *fe, fe_status_t *stat)
@@ -655,11 +897,12 @@ static int smsdvb_read_ber(struct dvb_frontend *fe, u32 *ber)
 {
 	int rc;
 	struct smsdvb_client_t *client;
+
 	client = container_of(fe, struct smsdvb_client_t, frontend);
 
 	rc = smsdvb_send_statistics_request(client);
 
-	*ber = client->sms_stat_dvb.ReceptionData.BER;
+	*ber = client->legacy_ber;
 
 	led_feedback(client);
 
@@ -668,21 +911,21 @@ static int smsdvb_read_ber(struct dvb_frontend *fe, u32 *ber)
 
 static int smsdvb_read_signal_strength(struct dvb_frontend *fe, u16 *strength)
 {
+	struct dtv_frontend_properties *c = &fe->dtv_property_cache;
 	int rc;
-
+	s32 power = (s32) c->strength.stat[0].uvalue;
 	struct smsdvb_client_t *client;
+
 	client = container_of(fe, struct smsdvb_client_t, frontend);
 
 	rc = smsdvb_send_statistics_request(client);
 
-	if (client->sms_stat_dvb.ReceptionData.InBandPwr < -95)
+	if (power < -95)
 		*strength = 0;
-		else if (client->sms_stat_dvb.ReceptionData.InBandPwr > -29)
-			*strength = 100;
+		else if (power > -29)
+			*strength = 65535;
 		else
-			*strength =
-				(client->sms_stat_dvb.ReceptionData.InBandPwr
-				+ 95) * 3 / 2;
+			*strength = (power + 95) * 65535 / 66;
 
 	led_feedback(client);
 
@@ -691,13 +934,16 @@ static int smsdvb_read_signal_strength(struct dvb_frontend *fe, u16 *strength)
 
 static int smsdvb_read_snr(struct dvb_frontend *fe, u16 *snr)
 {
+	struct dtv_frontend_properties *c = &fe->dtv_property_cache;
 	int rc;
 	struct smsdvb_client_t *client;
+
 	client = container_of(fe, struct smsdvb_client_t, frontend);
 
 	rc = smsdvb_send_statistics_request(client);
 
-	*snr = client->sms_stat_dvb.ReceptionData.SNR;
+	/* Preferred scale for SNR with legacy API: 0.1 dB */
+	*snr = c->cnr.stat[0].svalue / 100;
 
 	led_feedback(client);
 
@@ -707,12 +953,14 @@ static int smsdvb_read_snr(struct dvb_frontend *fe, u16 *snr)
 static int smsdvb_read_ucblocks(struct dvb_frontend *fe, u32 *ucblocks)
 {
 	int rc;
+	struct dtv_frontend_properties *c = &fe->dtv_property_cache;
 	struct smsdvb_client_t *client;
+
 	client = container_of(fe, struct smsdvb_client_t, frontend);
 
 	rc = smsdvb_send_statistics_request(client);
 
-	*ucblocks = client->sms_stat_dvb.ReceptionData.ErrorTSPackets;
+	*ucblocks = c->block_error.stat[0].uvalue;
 
 	led_feedback(client);
 
@@ -743,7 +991,7 @@ static int smsdvb_dvbt_set_frontend(struct dvb_frontend *fe)
 
 	int ret;
 
-	client->fe_status = FE_HAS_SIGNAL;
+	client->fe_status = 0;
 	client->event_fe_state = -1;
 	client->event_unc_state = -1;
 	fe->dtv_property_cache.delivery_system = SYS_DVBT;
@@ -871,6 +1119,8 @@ static int smsdvb_set_frontend(struct dvb_frontend *fe)
 		container_of(fe, struct smsdvb_client_t, frontend);
 	struct smscore_device_t *coredev = client->coredev;
 
+	smsdvb_stats_not_ready(fe);
+
 	switch (smscore_get_device_mode(coredev)) {
 	case DEVICE_MODE_DVBT:
 	case DEVICE_MODE_DVBT_BDA:
@@ -883,150 +1133,10 @@ static int smsdvb_set_frontend(struct dvb_frontend *fe)
 	}
 }
 
-static int smsdvb_get_frontend_dvb(struct dvb_frontend *fe)
-{
-	struct dtv_frontend_properties *fep = &fe->dtv_property_cache;
-	struct smsdvb_client_t *client =
-		container_of(fe, struct smsdvb_client_t, frontend);
-	struct TRANSMISSION_STATISTICS_S *td =
-		&client->sms_stat_dvb.TransmissionData;
-
-	fep->frequency = td->Frequency;
-
-	switch (td->Bandwidth) {
-	case 6:
-		fep->bandwidth_hz = 6000000;
-		break;
-	case 7:
-		fep->bandwidth_hz = 7000000;
-		break;
-	case 8:
-		fep->bandwidth_hz = 8000000;
-		break;
-	}
-
-	switch (td->TransmissionMode) {
-	case 2:
-		fep->transmission_mode = TRANSMISSION_MODE_2K;
-		break;
-	case 8:
-		fep->transmission_mode = TRANSMISSION_MODE_8K;
-	}
-
-	switch (td->GuardInterval) {
-	case 0:
-		fep->guard_interval = GUARD_INTERVAL_1_32;
-		break;
-	case 1:
-		fep->guard_interval = GUARD_INTERVAL_1_16;
-		break;
-	case 2:
-		fep->guard_interval = GUARD_INTERVAL_1_8;
-		break;
-	case 3:
-		fep->guard_interval = GUARD_INTERVAL_1_4;
-		break;
-	}
-
-	switch (td->CodeRate) {
-	case 0:
-		fep->code_rate_HP = FEC_1_2;
-		break;
-	case 1:
-		fep->code_rate_HP = FEC_2_3;
-		break;
-	case 2:
-		fep->code_rate_HP = FEC_3_4;
-		break;
-	case 3:
-		fep->code_rate_HP = FEC_5_6;
-		break;
-	case 4:
-		fep->code_rate_HP = FEC_7_8;
-		break;
-	}
-
-	switch (td->LPCodeRate) {
-	case 0:
-		fep->code_rate_LP = FEC_1_2;
-		break;
-	case 1:
-		fep->code_rate_LP = FEC_2_3;
-		break;
-	case 2:
-		fep->code_rate_LP = FEC_3_4;
-		break;
-	case 3:
-		fep->code_rate_LP = FEC_5_6;
-		break;
-	case 4:
-		fep->code_rate_LP = FEC_7_8;
-		break;
-	}
-
-	switch (td->Constellation) {
-	case 0:
-		fep->modulation = QPSK;
-		break;
-	case 1:
-		fep->modulation = QAM_16;
-		break;
-	case 2:
-		fep->modulation = QAM_64;
-		break;
-	}
-
-	switch (td->Hierarchy) {
-	case 0:
-		fep->hierarchy = HIERARCHY_NONE;
-		break;
-	case 1:
-		fep->hierarchy = HIERARCHY_1;
-		break;
-	case 2:
-		fep->hierarchy = HIERARCHY_2;
-		break;
-	case 3:
-		fep->hierarchy = HIERARCHY_4;
-		break;
-	}
-
-	fep->inversion = INVERSION_AUTO;
-
-	return 0;
-}
-
-static int smsdvb_get_frontend_isdb(struct dvb_frontend *fe)
-{
-	struct dtv_frontend_properties *fep = &fe->dtv_property_cache;
-	struct smsdvb_client_t *client =
-		container_of(fe, struct smsdvb_client_t, frontend);
-	struct TRANSMISSION_STATISTICS_S *td =
-		&client->sms_stat_dvb.TransmissionData;
-
-	fep->frequency = td->Frequency;
-	fep->bandwidth_hz = 6000000;
-	/* todo: retrive the other parameters */
-
-	return 0;
-}
-
+/* Nothing to do here, as stats are automatically updated */
 static int smsdvb_get_frontend(struct dvb_frontend *fe)
 {
-	struct smsdvb_client_t *client =
-		container_of(fe, struct smsdvb_client_t, frontend);
-	struct smscore_device_t *coredev = client->coredev;
-
-	switch (smscore_get_device_mode(coredev)) {
-	case DEVICE_MODE_DVBT:
-	case DEVICE_MODE_DVBT_BDA:
-		return smsdvb_get_frontend_dvb(fe);
-	case DEVICE_MODE_ISDBT:
-	case DEVICE_MODE_ISDBT_BDA:
-		return smsdvb_get_frontend_isdb(fe);
-	default:
-		return -EINVAL;
-	}
+	return 0;
 }
 
 static int smsdvb_init(struct dvb_frontend *fe)
Signature · 1 line
1.8.1.4
#28 lore raw

PATCH 28/46 siano: fix start of statistics

In reply to Mauro Carvalho Chehab

It seems that the first u32 after the header for some stats are used by something not documented.

The stats struct starts after it.

---
 drivers/media/common/siano/smsdvb.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)
drivers/media/common/siano/smsdvb.c +4 -2
index a5f5272..70ea3e9 100644
@@ -724,7 +724,8 @@ static int smsdvb_onresponse(void *context, struct smscore_buffer_t *cb)
 			smsdvb_update_isdbt_stats(client, p);
 			break;
 		default:
-			smsdvb_update_dvb_stats(client, p);
+			/* Skip SmsMsgStatisticsInfo_ST:RequestResult field */
+			smsdvb_update_dvb_stats(client, p + sizeof(u32));
 		}
 
 		is_status_update = true;
@@ -732,7 +733,8 @@ static int smsdvb_onresponse(void *context, struct smscore_buffer_t *cb)
 
 	/* Only for ISDB-T */
 	case MSG_SMS_GET_STATISTICS_EX_RES:
-		smsdvb_update_isdbt_stats_ex(client, p);
+		/* Skip SmsMsgStatisticsInfo_ST:RequestResult field? */
+		smsdvb_update_isdbt_stats_ex(client, p + sizeof(u32));
 		is_status_update = true;
 		break;
 	default:
Signature · 1 line
1.8.1.4
#29 lore raw

PATCH 29/46 siano: allow showing the complete statistics via debugfs

In reply to Mauro Carvalho Chehab

Outputs the result of the statistics responses via debugfs. That can help to track bugs at the stats filling.

---
 drivers/media/common/siano/smsdvb.c | 464 +++++++++++++++++++++++++++---------
 1 file changed, 355 insertions(+), 109 deletions(-)
drivers/media/common/siano/smsdvb.c +355 -109
index 70ea3e9..aeadd8a 100644
@@ -22,6 +22,7 @@ along with this program.  If not, see <http://www.gnu.org/licenses/>.
 #include <linux/module.h>
 #include <linux/slab.h>
 #include <linux/init.h>
+#include <linux/debugfs.h>
 
 #include "dmxdev.h"
 #include "dvbdev.h"
@@ -55,6 +56,13 @@ struct smsdvb_client_t {
 
 	int event_fe_state;
 	int event_unc_state;
+
+	/* Stats debugfs data */
+	struct dentry		*debugfs;
+	char			*stats_data;
+	atomic_t		stats_count;
+	bool			stats_was_read;
+	wait_queue_head_t	stats_queue;
 };
 
 static struct list_head g_smsdvb_clients;
@@ -140,134 +148,358 @@ u32 sms_to_modulation_table[] = {
 	[3] = DQPSK,
 };
 
-static void smsdvb_print_dvb_stats(struct SMSHOSTLIB_STATISTICS_ST *p)
+static struct dentry *smsdvb_debugfs;
+
+static void smsdvb_print_dvb_stats(struct smsdvb_client_t *client,
+				   struct SMSHOSTLIB_STATISTICS_ST *p)
 {
-	if (!(sms_dbg & 2))
+	int n = 0;
+	char *buf;
+
+	if (!client->stats_data || atomic_read(&client->stats_count))
 		return;
 
-	printk(KERN_DEBUG "IsRfLocked = %d", p->IsRfLocked);
-	printk(KERN_DEBUG "IsDemodLocked = %d", p->IsDemodLocked);
-	printk(KERN_DEBUG "IsExternalLNAOn = %d", p->IsExternalLNAOn);
-	printk(KERN_DEBUG "SNR = %d", p->SNR);
-	printk(KERN_DEBUG "BER = %d", p->BER);
-	printk(KERN_DEBUG "FIB_CRC = %d", p->FIB_CRC);
-	printk(KERN_DEBUG "TS_PER = %d", p->TS_PER);
-	printk(KERN_DEBUG "MFER = %d", p->MFER);
-	printk(KERN_DEBUG "RSSI = %d", p->RSSI);
-	printk(KERN_DEBUG "InBandPwr = %d", p->InBandPwr);
-	printk(KERN_DEBUG "CarrierOffset = %d", p->CarrierOffset);
-	printk(KERN_DEBUG "ModemState = %d", p->ModemState);
-	printk(KERN_DEBUG "Frequency = %d", p->Frequency);
-	printk(KERN_DEBUG "Bandwidth = %d", p->Bandwidth);
-	printk(KERN_DEBUG "TransmissionMode = %d", p->TransmissionMode);
-	printk(KERN_DEBUG "ModemState = %d", p->ModemState);
-	printk(KERN_DEBUG "GuardInterval = %d", p->GuardInterval);
-	printk(KERN_DEBUG "CodeRate = %d", p->CodeRate);
-	printk(KERN_DEBUG "LPCodeRate = %d", p->LPCodeRate);
-	printk(KERN_DEBUG "Hierarchy = %d", p->Hierarchy);
-	printk(KERN_DEBUG "Constellation = %d", p->Constellation);
-	printk(KERN_DEBUG "BurstSize = %d", p->BurstSize);
-	printk(KERN_DEBUG "BurstDuration = %d", p->BurstDuration);
-	printk(KERN_DEBUG "BurstCycleTime = %d", p->BurstCycleTime);
-	printk(KERN_DEBUG "CalculatedBurstCycleTime = %d", p->CalculatedBurstCycleTime);
-	printk(KERN_DEBUG "NumOfRows = %d", p->NumOfRows);
-	printk(KERN_DEBUG "NumOfPaddCols = %d", p->NumOfPaddCols);
-	printk(KERN_DEBUG "NumOfPunctCols = %d", p->NumOfPunctCols);
-	printk(KERN_DEBUG "ErrorTSPackets = %d", p->ErrorTSPackets);
-	printk(KERN_DEBUG "TotalTSPackets = %d", p->TotalTSPackets);
-	printk(KERN_DEBUG "NumOfValidMpeTlbs = %d", p->NumOfValidMpeTlbs);
-	printk(KERN_DEBUG "NumOfInvalidMpeTlbs = %d", p->NumOfInvalidMpeTlbs);
-	printk(KERN_DEBUG "NumOfCorrectedMpeTlbs = %d", p->NumOfCorrectedMpeTlbs);
-	printk(KERN_DEBUG "BERErrorCount = %d", p->BERErrorCount);
-	printk(KERN_DEBUG "BERBitCount = %d", p->BERBitCount);
-	printk(KERN_DEBUG "SmsToHostTxErrors = %d", p->SmsToHostTxErrors);
-	printk(KERN_DEBUG "PreBER = %d", p->PreBER);
-	printk(KERN_DEBUG "CellId = %d", p->CellId);
-	printk(KERN_DEBUG "DvbhSrvIndHP = %d", p->DvbhSrvIndHP);
-	printk(KERN_DEBUG "DvbhSrvIndLP = %d", p->DvbhSrvIndLP);
-	printk(KERN_DEBUG "NumMPEReceived = %d", p->NumMPEReceived);
+	buf = client->stats_data;
+
+	n += snprintf(&buf[n], PAGE_SIZE - n,
+		      "IsRfLocked = %d\n", p->IsRfLocked);
+	n += snprintf(&buf[n], PAGE_SIZE - n,
+		      "IsDemodLocked = %d\n", p->IsDemodLocked);
+	n += snprintf(&buf[n], PAGE_SIZE - n,
+		      "IsExternalLNAOn = %d\n", p->IsExternalLNAOn);
+	n += snprintf(&buf[n], PAGE_SIZE - n,
+		      "SNR = %d\n", p->SNR);
+	n += snprintf(&buf[n], PAGE_SIZE - n,
+		      "BER = %d\n", p->BER);
+	n += snprintf(&buf[n], PAGE_SIZE - n,
+		      "FIB_CRC = %d\n", p->FIB_CRC);
+	n += snprintf(&buf[n], PAGE_SIZE - n,
+		      "TS_PER = %d\n", p->TS_PER);
+	n += snprintf(&buf[n], PAGE_SIZE - n,
+		      "MFER = %d\n", p->MFER);
+	n += snprintf(&buf[n], PAGE_SIZE - n,
+		      "RSSI = %d\n", p->RSSI);
+	n += snprintf(&buf[n], PAGE_SIZE - n,
+		      "InBandPwr = %d\n", p->InBandPwr);
+	n += snprintf(&buf[n], PAGE_SIZE - n,
+		      "CarrierOffset = %d\n", p->CarrierOffset);
+	n += snprintf(&buf[n], PAGE_SIZE - n,
+		      "ModemState = %d\n", p->ModemState);
+	n += snprintf(&buf[n], PAGE_SIZE - n,
+		      "Frequency = %d\n", p->Frequency);
+	n += snprintf(&buf[n], PAGE_SIZE - n,
+		      "Bandwidth = %d\n", p->Bandwidth);
+	n += snprintf(&buf[n], PAGE_SIZE - n,
+		      "TransmissionMode = %d\n", p->TransmissionMode);
+	n += snprintf(&buf[n], PAGE_SIZE - n,
+		      "ModemState = %d\n", p->ModemState);
+	n += snprintf(&buf[n], PAGE_SIZE - n,
+		      "GuardInterval = %d\n", p->GuardInterval);
+	n += snprintf(&buf[n], PAGE_SIZE - n,
+		      "CodeRate = %d\n", p->CodeRate);
+	n += snprintf(&buf[n], PAGE_SIZE - n,
+		      "LPCodeRate = %d\n", p->LPCodeRate);
+	n += snprintf(&buf[n], PAGE_SIZE - n,
+		      "Hierarchy = %d\n", p->Hierarchy);
+	n += snprintf(&buf[n], PAGE_SIZE - n,
+		      "Constellation = %d\n", p->Constellation);
+	n += snprintf(&buf[n], PAGE_SIZE - n,
+		      "BurstSize = %d\n", p->BurstSize);
+	n += snprintf(&buf[n], PAGE_SIZE - n,
+		      "BurstDuration = %d\n", p->BurstDuration);
+	n += snprintf(&buf[n], PAGE_SIZE - n,
+		      "BurstCycleTime = %d\n", p->BurstCycleTime);
+	n += snprintf(&buf[n], PAGE_SIZE - n,
+		      "CalculatedBurstCycleTime = %d\n",
+		      p->CalculatedBurstCycleTime);
+	n += snprintf(&buf[n], PAGE_SIZE - n,
+		      "NumOfRows = %d\n", p->NumOfRows);
+	n += snprintf(&buf[n], PAGE_SIZE - n,
+		      "NumOfPaddCols = %d\n", p->NumOfPaddCols);
+	n += snprintf(&buf[n], PAGE_SIZE - n,
+		      "NumOfPunctCols = %d\n", p->NumOfPunctCols);
+	n += snprintf(&buf[n], PAGE_SIZE - n,
+		      "ErrorTSPackets = %d\n", p->ErrorTSPackets);
+	n += snprintf(&buf[n], PAGE_SIZE - n,
+		      "TotalTSPackets = %d\n", p->TotalTSPackets);
+	n += snprintf(&buf[n], PAGE_SIZE - n,
+		      "NumOfValidMpeTlbs = %d\n", p->NumOfValidMpeTlbs);
+	n += snprintf(&buf[n], PAGE_SIZE - n,
+		      "NumOfInvalidMpeTlbs = %d\n", p->NumOfInvalidMpeTlbs);
+	n += snprintf(&buf[n], PAGE_SIZE - n,
+		      "NumOfCorrectedMpeTlbs = %d\n", p->NumOfCorrectedMpeTlbs);
+	n += snprintf(&buf[n], PAGE_SIZE - n,
+		      "BERErrorCount = %d\n", p->BERErrorCount);
+	n += snprintf(&buf[n], PAGE_SIZE - n,
+		      "BERBitCount = %d\n", p->BERBitCount);
+	n += snprintf(&buf[n], PAGE_SIZE - n,
+		      "SmsToHostTxErrors = %d\n", p->SmsToHostTxErrors);
+	n += snprintf(&buf[n], PAGE_SIZE - n,
+		      "PreBER = %d\n", p->PreBER);
+	n += snprintf(&buf[n], PAGE_SIZE - n,
+		      "CellId = %d\n", p->CellId);
+	n += snprintf(&buf[n], PAGE_SIZE - n,
+		      "DvbhSrvIndHP = %d\n", p->DvbhSrvIndHP);
+	n += snprintf(&buf[n], PAGE_SIZE - n,
+		      "DvbhSrvIndLP = %d\n", p->DvbhSrvIndLP);
+	n += snprintf(&buf[n], PAGE_SIZE - n,
+		      "NumMPEReceived = %d\n", p->NumMPEReceived);
+
+	atomic_set(&client->stats_count, n);
+	wake_up(&client->stats_queue);
 }
 
-static void smsdvb_print_isdb_stats(struct SMSHOSTLIB_STATISTICS_ISDBT_ST *p)
+static void smsdvb_print_isdb_stats(struct smsdvb_client_t *client,
+				    struct SMSHOSTLIB_STATISTICS_ISDBT_ST *p)
 {
-	int i;
+	int i, n = 0;
+	char *buf;
 
-	if (!(sms_dbg & 2))
+	if (!client->stats_data || atomic_read(&client->stats_count))
 		return;
 
-	printk(KERN_DEBUG "IsRfLocked = %d", p->IsRfLocked);
-	printk(KERN_DEBUG "IsDemodLocked = %d", p->IsDemodLocked);
-	printk(KERN_DEBUG "IsExternalLNAOn = %d", p->IsExternalLNAOn);
-	printk(KERN_DEBUG "SNR = %d", p->SNR);
-	printk(KERN_DEBUG "RSSI = %d", p->RSSI);
-	printk(KERN_DEBUG "InBandPwr = %d", p->InBandPwr);
-	printk(KERN_DEBUG "CarrierOffset = %d", p->CarrierOffset);
-	printk(KERN_DEBUG "Frequency = %d", p->Frequency);
-	printk(KERN_DEBUG "Bandwidth = %d", p->Bandwidth);
-	printk(KERN_DEBUG "TransmissionMode = %d", p->TransmissionMode);
-	printk(KERN_DEBUG "ModemState = %d", p->ModemState);
-	printk(KERN_DEBUG "GuardInterval = %d", p->GuardInterval);
-	printk(KERN_DEBUG "SystemType = %d", p->SystemType);
-	printk(KERN_DEBUG "PartialReception = %d", p->PartialReception);
-	printk(KERN_DEBUG "NumOfLayers = %d", p->NumOfLayers);
-	printk(KERN_DEBUG "SmsToHostTxErrors = %d", p->SmsToHostTxErrors);
+	buf = client->stats_data;
+
+	n += snprintf(&buf[n], PAGE_SIZE - n,
+		      "IsRfLocked = %d\t\t", p->IsRfLocked);
+	n += snprintf(&buf[n], PAGE_SIZE - n,
+		      "IsDemodLocked = %d\t", p->IsDemodLocked);
+	n += snprintf(&buf[n], PAGE_SIZE - n,
+		      "IsExternalLNAOn = %d\n", p->IsExternalLNAOn);
+	n += snprintf(&buf[n], PAGE_SIZE - n,
+		      "SNR = %d dB\t\t", p->SNR);
+	n += snprintf(&buf[n], PAGE_SIZE - n,
+		      "RSSI = %d dBm\t\t", p->RSSI);
+	n += snprintf(&buf[n], PAGE_SIZE - n,
+		      "InBandPwr = %d dBm\n", p->InBandPwr);
+	n += snprintf(&buf[n], PAGE_SIZE - n,
+		      "CarrierOffset = %d\t", p->CarrierOffset);
+	n += snprintf(&buf[n], PAGE_SIZE - n,
+		      "Bandwidth = %d\t\t", p->Bandwidth);
+	n += snprintf(&buf[n], PAGE_SIZE - n,
+		      "Frequency = %d Hz\n", p->Frequency);
+	n += snprintf(&buf[n], PAGE_SIZE - n,
+		      "TransmissionMode = %d\t", p->TransmissionMode);
+	n += snprintf(&buf[n], PAGE_SIZE - n,
+		      "ModemState = %d\t\t", p->ModemState);
+	n += snprintf(&buf[n], PAGE_SIZE - n,
+		      "GuardInterval = %d\n", p->GuardInterval);
+	n += snprintf(&buf[n], PAGE_SIZE - n,
+		      "SystemType = %d\t\t", p->SystemType);
+	n += snprintf(&buf[n], PAGE_SIZE - n,
+		      "PartialReception = %d\t", p->PartialReception);
+	n += snprintf(&buf[n], PAGE_SIZE - n,
+		      "NumOfLayers = %d\n", p->NumOfLayers);
+	n += snprintf(&buf[n], PAGE_SIZE - n,
+		      "SmsToHostTxErrors = %d\n", p->SmsToHostTxErrors);
 
 	for (i = 0; i < 3; i++) {
-		printk(KERN_DEBUG "%d: CodeRate = %d", i, p->LayerInfo[i].CodeRate);
-		printk(KERN_DEBUG "%d: Constellation = %d", i, p->LayerInfo[i].Constellation);
-		printk(KERN_DEBUG "%d: BER = %d", i, p->LayerInfo[i].BER);
-		printk(KERN_DEBUG "%d: BERErrorCount = %d", i, p->LayerInfo[i].BERErrorCount);
-		printk(KERN_DEBUG "%d: BERBitCount = %d", i, p->LayerInfo[i].BERBitCount);
-		printk(KERN_DEBUG "%d: PreBER = %d", i, p->LayerInfo[i].PreBER);
-		printk(KERN_DEBUG "%d: TS_PER = %d", i, p->LayerInfo[i].TS_PER);
-		printk(KERN_DEBUG "%d: ErrorTSPackets = %d", i, p->LayerInfo[i].ErrorTSPackets);
-		printk(KERN_DEBUG "%d: TotalTSPackets = %d", i, p->LayerInfo[i].TotalTSPackets);
-		printk(KERN_DEBUG "%d: TILdepthI = %d", i, p->LayerInfo[i].TILdepthI);
-		printk(KERN_DEBUG "%d: NumberOfSegments = %d", i, p->LayerInfo[i].NumberOfSegments);
-		printk(KERN_DEBUG "%d: TMCCErrors = %d", i, p->LayerInfo[i].TMCCErrors);
+		if (p->LayerInfo[i].NumberOfSegments < 1 ||
+		    p->LayerInfo[i].NumberOfSegments > 13)
+			continue;
+
+		n += snprintf(&buf[n], PAGE_SIZE - n, "\nLayer %d\n", i);
+		n += snprintf(&buf[n], PAGE_SIZE - n, "\tCodeRate = %d\t",
+			      p->LayerInfo[i].CodeRate);
+		n += snprintf(&buf[n], PAGE_SIZE - n, "Constellation = %d\n",
+			      p->LayerInfo[i].Constellation);
+		n += snprintf(&buf[n], PAGE_SIZE - n, "\tBER = %-5d\t",
+			      p->LayerInfo[i].BER);
+		n += snprintf(&buf[n], PAGE_SIZE - n, "\tBERErrorCount = %-5d\t",
+			      p->LayerInfo[i].BERErrorCount);
+		n += snprintf(&buf[n], PAGE_SIZE - n, "BERBitCount = %-5d\n",
+			      p->LayerInfo[i].BERBitCount);
+		n += snprintf(&buf[n], PAGE_SIZE - n, "\tPreBER = %-5d\t",
+			      p->LayerInfo[i].PreBER);
+		n += snprintf(&buf[n], PAGE_SIZE - n, "\tTS_PER = %-5d\n",
+			      p->LayerInfo[i].TS_PER);
+		n += snprintf(&buf[n], PAGE_SIZE - n, "\tErrorTSPackets = %-5d\t",
+			      p->LayerInfo[i].ErrorTSPackets);
+		n += snprintf(&buf[n], PAGE_SIZE - n, "TotalTSPackets = %-5d\t",
+			      p->LayerInfo[i].TotalTSPackets);
+		n += snprintf(&buf[n], PAGE_SIZE - n, "TILdepthI = %d\n",
+			      p->LayerInfo[i].TILdepthI);
+		n += snprintf(&buf[n], PAGE_SIZE - n,
+			      "\tNumberOfSegments = %d\t",
+			      p->LayerInfo[i].NumberOfSegments);
+		n += snprintf(&buf[n], PAGE_SIZE - n, "TMCCErrors = %d\n",
+			      p->LayerInfo[i].TMCCErrors);
 	}
+
+	atomic_set(&client->stats_count, n);
+	wake_up(&client->stats_queue);
 }
 
 static void
-smsdvb_print_isdb_stats_ex(struct SMSHOSTLIB_STATISTICS_ISDBT_EX_ST *p)
+smsdvb_print_isdb_stats_ex(struct smsdvb_client_t *client,
+			   struct SMSHOSTLIB_STATISTICS_ISDBT_EX_ST *p)
 {
-	int i;
+	int i, n = 0;
+	char *buf;
 
-	if (!(sms_dbg & 2))
+	if (!client->stats_data || atomic_read(&client->stats_count))
 		return;
 
-	printk(KERN_DEBUG "IsRfLocked = %d", p->IsRfLocked);
-	printk(KERN_DEBUG "IsDemodLocked = %d", p->IsDemodLocked);
-	printk(KERN_DEBUG "IsExternalLNAOn = %d", p->IsExternalLNAOn);
-	printk(KERN_DEBUG "SNR = %d", p->SNR);
-	printk(KERN_DEBUG "RSSI = %d", p->RSSI);
-	printk(KERN_DEBUG "InBandPwr = %d", p->InBandPwr);
-	printk(KERN_DEBUG "CarrierOffset = %d", p->CarrierOffset);
-	printk(KERN_DEBUG "Frequency = %d", p->Frequency);
-	printk(KERN_DEBUG "Bandwidth = %d", p->Bandwidth);
-	printk(KERN_DEBUG "TransmissionMode = %d", p->TransmissionMode);
-	printk(KERN_DEBUG "ModemState = %d", p->ModemState);
-	printk(KERN_DEBUG "GuardInterval = %d", p->GuardInterval);
-	printk(KERN_DEBUG "SystemType = %d", p->SystemType);
-	printk(KERN_DEBUG "PartialReception = %d", p->PartialReception);
-	printk(KERN_DEBUG "NumOfLayers = %d", p->NumOfLayers);
-	printk(KERN_DEBUG "SegmentNumber = %d", p->SegmentNumber);
-	printk(KERN_DEBUG "TuneBW = %d", p->TuneBW);
+	buf = client->stats_data;
+
+	n += snprintf(&buf[n], PAGE_SIZE - n,
+		      "IsRfLocked = %d\t\t", p->IsRfLocked);
+	n += snprintf(&buf[n], PAGE_SIZE - n,
+		      "IsDemodLocked = %d\t", p->IsDemodLocked);
+	n += snprintf(&buf[n], PAGE_SIZE - n,
+		      "IsExternalLNAOn = %d\n", p->IsExternalLNAOn);
+	n += snprintf(&buf[n], PAGE_SIZE - n,
+		      "SNR = %d dB\t\t", p->SNR);
+	n += snprintf(&buf[n], PAGE_SIZE - n,
+		      "RSSI = %d dBm\t\t", p->RSSI);
+	n += snprintf(&buf[n], PAGE_SIZE - n,
+		      "InBandPwr = %d dBm\n", p->InBandPwr);
+	n += snprintf(&buf[n], PAGE_SIZE - n,
+		      "CarrierOffset = %d\t", p->CarrierOffset);
+	n += snprintf(&buf[n], PAGE_SIZE - n,
+		      "Bandwidth = %d\t\t", p->Bandwidth);
+	n += snprintf(&buf[n], PAGE_SIZE - n,
+		      "Frequency = %d Hz\n", p->Frequency);
+	n += snprintf(&buf[n], PAGE_SIZE - n,
+		      "TransmissionMode = %d\t", p->TransmissionMode);
+	n += snprintf(&buf[n], PAGE_SIZE - n,
+		      "ModemState = %d\t\t", p->ModemState);
+	n += snprintf(&buf[n], PAGE_SIZE - n,
+		      "GuardInterval = %d\n", p->GuardInterval);
+	n += snprintf(&buf[n], PAGE_SIZE - n,
+		      "SystemType = %d\t\t", p->SystemType);
+	n += snprintf(&buf[n], PAGE_SIZE - n,
+		      "PartialReception = %d\t", p->PartialReception);
+	n += snprintf(&buf[n], PAGE_SIZE - n,
+		      "NumOfLayers = %d\n", p->NumOfLayers);
+	n += snprintf(&buf[n], PAGE_SIZE - n, "SegmentNumber = %d\t",
+		      p->SegmentNumber);
+	n += snprintf(&buf[n], PAGE_SIZE - n, "TuneBW = %d\n",
+		      p->TuneBW);
 
 	for (i = 0; i < 3; i++) {
-		printk(KERN_DEBUG "%d: CodeRate = %d", i, p->LayerInfo[i].CodeRate);
-		printk(KERN_DEBUG "%d: Constellation = %d", i, p->LayerInfo[i].Constellation);
-		printk(KERN_DEBUG "%d: BER = %d", i, p->LayerInfo[i].BER);
-		printk(KERN_DEBUG "%d: BERErrorCount = %d", i, p->LayerInfo[i].BERErrorCount);
-		printk(KERN_DEBUG "%d: BERBitCount = %d", i, p->LayerInfo[i].BERBitCount);
-		printk(KERN_DEBUG "%d: PreBER = %d", i, p->LayerInfo[i].PreBER);
-		printk(KERN_DEBUG "%d: TS_PER = %d", i, p->LayerInfo[i].TS_PER);
-		printk(KERN_DEBUG "%d: ErrorTSPackets = %d", i, p->LayerInfo[i].ErrorTSPackets);
-		printk(KERN_DEBUG "%d: TotalTSPackets = %d", i, p->LayerInfo[i].TotalTSPackets);
-		printk(KERN_DEBUG "%d: TILdepthI = %d", i, p->LayerInfo[i].TILdepthI);
-		printk(KERN_DEBUG "%d: NumberOfSegments = %d", i, p->LayerInfo[i].NumberOfSegments);
-		printk(KERN_DEBUG "%d: TMCCErrors = %d", i, p->LayerInfo[i].TMCCErrors);
+		if (p->LayerInfo[i].NumberOfSegments < 1 ||
+		    p->LayerInfo[i].NumberOfSegments > 13)
+			continue;
+
+		n += snprintf(&buf[n], PAGE_SIZE - n, "\nLayer %d\n", i);
+		n += snprintf(&buf[n], PAGE_SIZE - n, "\tCodeRate = %d\t",
+			      p->LayerInfo[i].CodeRate);
+		n += snprintf(&buf[n], PAGE_SIZE - n, "Constellation = %d\n",
+			      p->LayerInfo[i].Constellation);
+		n += snprintf(&buf[n], PAGE_SIZE - n, "\tBER = %-5d\t",
+			      p->LayerInfo[i].BER);
+		n += snprintf(&buf[n], PAGE_SIZE - n, "\tBERErrorCount = %-5d\t",
+			      p->LayerInfo[i].BERErrorCount);
+		n += snprintf(&buf[n], PAGE_SIZE - n, "BERBitCount = %-5d\n",
+			      p->LayerInfo[i].BERBitCount);
+		n += snprintf(&buf[n], PAGE_SIZE - n, "\tPreBER = %-5d\t",
+			      p->LayerInfo[i].PreBER);
+		n += snprintf(&buf[n], PAGE_SIZE - n, "\tTS_PER = %-5d\n",
+			      p->LayerInfo[i].TS_PER);
+		n += snprintf(&buf[n], PAGE_SIZE - n, "\tErrorTSPackets = %-5d\t",
+			      p->LayerInfo[i].ErrorTSPackets);
+		n += snprintf(&buf[n], PAGE_SIZE - n, "TotalTSPackets = %-5d\t",
+			      p->LayerInfo[i].TotalTSPackets);
+		n += snprintf(&buf[n], PAGE_SIZE - n, "TILdepthI = %d\n",
+			      p->LayerInfo[i].TILdepthI);
+		n += snprintf(&buf[n], PAGE_SIZE - n,
+			      "\tNumberOfSegments = %d\t",
+			      p->LayerInfo[i].NumberOfSegments);
+		n += snprintf(&buf[n], PAGE_SIZE - n, "TMCCErrors = %d\n",
+			      p->LayerInfo[i].TMCCErrors);
+	}
+
+	atomic_set(&client->stats_count, n);
+	wake_up(&client->stats_queue);
+}
+
+static int smsdvb_stats_open(struct inode *inode, struct file *file)
+{
+	struct smsdvb_client_t *client = inode->i_private;
+
+	atomic_set(&client->stats_count, 0);
+	client->stats_was_read = false;
+
+	init_waitqueue_head(&client->stats_queue);
+
+	client->stats_data = kmalloc(PAGE_SIZE, GFP_KERNEL);
+	if (client->stats_data == NULL)
+		return -ENOMEM;
+
+	file->private_data = client;
+
+	return 0;
+}
+
+static ssize_t smsdvb_stats_read(struct file *file, char __user *user_buf,
+				      size_t nbytes, loff_t *ppos)
+{
+	struct smsdvb_client_t *client = file->private_data;
+
+	if (!client->stats_data || client->stats_was_read)
+		return 0;
+
+	wait_event_interruptible(client->stats_queue,
+				 atomic_read(&client->stats_count));
+
+	return simple_read_from_buffer(user_buf, nbytes, ppos,
+				       client->stats_data,
+				       atomic_read(&client->stats_count));
+
+	client->stats_was_read = true;
+}
+
+static int smsdvb_stats_release(struct inode *inode, struct file *file)
+{
+	struct smsdvb_client_t *client = file->private_data;
+
+	kfree(client->stats_data);
+	client->stats_data = NULL;
+
+	return 0;
+}
+
+static const struct file_operations debugfs_stats_ops = {
+	.open = smsdvb_stats_open,
+	.read = smsdvb_stats_read,
+	.release = smsdvb_stats_release,
+	.llseek = generic_file_llseek,
+};
+
+static int create_stats_debugfs(struct smsdvb_client_t *client)
+{
+	struct smscore_device_t *coredev = client->coredev;
+	struct dentry *d;
+
+	if (!smsdvb_debugfs)
+		return -ENODEV;
+
+	client->debugfs = debugfs_create_dir(coredev->devpath, smsdvb_debugfs);
+	if (IS_ERR_OR_NULL(client->debugfs)) {
+		sms_info("Unable to create debugfs %s directory.\n",
+			 coredev->devpath);
+		return -ENODEV;
 	}
+
+	d = debugfs_create_file("stats", S_IRUGO | S_IWUSR, client->debugfs,
+				client, &debugfs_stats_ops);
+	if (!d) {
+		debugfs_remove(client->debugfs);
+		return -ENOMEM;
+	}
+
+	return 0;
+}
+
+static void release_stats_debugfs(struct smsdvb_client_t *client)
+{
+	if (!client->debugfs)
+		return;
+
+	debugfs_remove_recursive(client->debugfs);
+
+	client->debugfs = NULL;
 }
 
 /* Events that may come from DVB v3 adapter */
@@ -476,7 +708,7 @@ static void smsdvb_update_dvb_stats(struct smsdvb_client_t *client,
 	struct dvb_frontend *fe = &client->frontend;
 	struct dtv_frontend_properties *c = &fe->dtv_property_cache;
 
-	smsdvb_print_dvb_stats(p);
+	smsdvb_print_dvb_stats(client, p);
 
 	client->fe_status = sms_to_status(p->IsDemodLocked, p->IsRfLocked);
 
@@ -526,7 +758,7 @@ static void smsdvb_update_isdbt_stats(struct smsdvb_client_t *client,
 	struct SMSHOSTLIB_ISDBT_LAYER_STAT_ST *lr;
 	int i, n_layers;
 
-	smsdvb_print_isdb_stats(p);
+	smsdvb_print_isdb_stats(client, p);
 
 	/* Update ISDB-T transmission parameters */
 	c->frequency = p->Frequency;
@@ -602,7 +834,7 @@ static void smsdvb_update_isdbt_stats_ex(struct smsdvb_client_t *client,
 	struct SMSHOSTLIB_ISDBT_LAYER_STAT_ST *lr;
 	int i, n_layers;
 
-	smsdvb_print_isdb_stats_ex(p);
+	smsdvb_print_isdb_stats_ex(client, p);
 
 	/* Update ISDB-T transmission parameters */
 	c->frequency = p->Frequency;
@@ -766,6 +998,7 @@ static void smsdvb_unregister_client(struct smsdvb_client_t *client)
 
 	list_del(&client->entry);
 
+	release_stats_debugfs(client);
 	smscore_unregister_client(client->smsclient);
 	dvb_unregister_frontend(&client->frontend);
 	dvb_dmxdev_release(&client->dmxdev);
@@ -1303,6 +1536,9 @@ static int smsdvb_hotplug(struct smscore_device_t *coredev,
 	sms_info("success");
 	sms_board_setup(coredev);
 
+	if (create_stats_debugfs(client) < 0)
+		sms_info("failed to create debugfs node");
+
 	return 0;
 
 client_error:
@@ -1325,10 +1561,17 @@ adapter_error:
 static int __init smsdvb_module_init(void)
 {
 	int rc;
+	struct dentry *d;
 
 	INIT_LIST_HEAD(&g_smsdvb_clients);
 	kmutex_init(&g_smsdvb_clientslock);
 
+	d = debugfs_create_dir("smsdvb", usb_debug_root);
+	if (IS_ERR_OR_NULL(d))
+		sms_err("Couldn't create sysfs node for smsdvb");
+	else
+		smsdvb_debugfs = d;
+
 	rc = smscore_register_hotplug(smsdvb_hotplug);
 
 	sms_debug("");
@@ -1346,6 +1589,9 @@ static void __exit smsdvb_module_exit(void)
 	       smsdvb_unregister_client(
 			(struct smsdvb_client_t *) g_smsdvb_clients.next);
 
+	if (smsdvb_debugfs)
+		debugfs_remove_recursive(smsdvb_debugfs);
+
 	kmutex_unlock(&g_smsdvb_clientslock);
 }
 
Signature · 1 line
1.8.1.4
#30 lore raw

PATCH 30/46 siano: split debugfs code into a separate file

In reply to Mauro Carvalho Chehab

To avoid mixing two different things at the same place, move the debugfs code into a separate file.

---
 drivers/media/common/siano/Kconfig          |   12 +
 drivers/media/common/siano/Makefile         |    5 +
 drivers/media/common/siano/smscoreapi.h     |    6 +
 drivers/media/common/siano/smsdvb-debugfs.c |  503 +++++++++
 drivers/media/common/siano/smsdvb-main.c    | 1184 ++++++++++++++++++++
 drivers/media/common/siano/smsdvb.c         | 1603 ---------------------------
 drivers/media/common/siano/smsdvb.h         |  124 +++
 drivers/media/usb/siano/smsusb.c            |    2 +
 8 files changed, 1836 insertions(+), 1603 deletions(-)
 create mode 100644 drivers/media/common/siano/smsdvb-debugfs.c
 create mode 100644 drivers/media/common/siano/smsdvb-main.c
 delete mode 100644 drivers/media/common/siano/smsdvb.c
 create mode 100644 drivers/media/common/siano/smsdvb.h
drivers/media/common/siano/Kconfig +12 -0
index 68f0f60..f3f5ec4 100644
@@ -17,3 +17,15 @@ config SMS_SIANO_RC
 	default y
 	---help---
 	  Choose Y to select Remote Controller support for Siano driver.
+
+config SMS_SIANO_DEBUGFS
+	bool "Enable debugfs for smsdvb"
+	depends on SMS_SIANO_MDTV
+	depends on DEBUG_FS
+	depends on SMS_USB_DRV
+	---help---
+	  Choose Y to enable visualizing a dump of the frontend
+	  statistics response packets via debugfs. Currently, works
+	  only with Siano USB devices.
+
+	  Useful only for developers. In doubt, say N.
drivers/media/common/siano/Makefile +5 -0
index 81b1e98..4c0567f 100644
@@ -1,4 +1,5 @@
 smsmdtv-objs := smscoreapi.o sms-cards.o smsendian.o
+smsdvb-objs := smsdvb-main.o
 
 obj-$(CONFIG_SMS_SIANO_MDTV) += smsmdtv.o smsdvb.o
 
@@ -6,6 +7,10 @@ ifeq ($(CONFIG_SMS_SIANO_RC),y)
   smsmdtv-objs += smsir.o
 endif
 
+ifeq ($(CONFIG_SMS_SIANO_DEBUGFS),y)
+  smsdvb-objs += smsdvb-debugfs.o
+endif
+
 ccflags-y += -Idrivers/media/dvb-core
 ccflags-y += $(extra-cflags-y) $(extra-cflags-m)
 
drivers/media/common/siano/smscoreapi.h +6 -0
index 7925c04..53b81cb 100644
@@ -184,6 +184,12 @@ struct smscore_device_t {
 	/* Infrared (IR) */
 	struct ir_t ir;
 
+	/*
+	 * Identify if device is USB or not.
+	 * Used by smsdvb-sysfs to know the root node for debugfs
+	 */
+	bool is_usb_device;
+
 	int led_state;
 };
 
drivers/media/common/siano/smsdvb-debugfs.c new file +503 -0

503 lines not on this page · raw message

drivers/media/common/siano/smsdvb-main.c new file +1184 -0

1,184 lines not on this page · raw message

drivers/media/common/siano/smsdvb.c deleted +0 -1603

1,271 lines not on this page · raw message

drivers/media/common/siano/smsdvb.h new file +124 -0

124 lines not on this page · raw message

drivers/media/usb/siano/smsusb.c +2 -0
index acd3d1e..def5e41 100644

Lines of this file are not shown. View the raw message.

The rest of this diff is not shown. View the raw message.

Signature · 1 line
1.8.1.4

Part of the diff is not shown here. View the raw message.

#31 lore raw

PATCH 31/46 siano: add two missing fields to ISDB-T stats debugfs

In reply to Mauro Carvalho Chehab

Those fields help to identify the version of the ISDB stats. Useful while debuging the driver.

---
 drivers/media/common/siano/smsdvb-debugfs.c | 10 ++++++++++
 1 file changed, 10 insertions(+)
drivers/media/common/siano/smsdvb-debugfs.c +10 -0
index 4d5dd47..59c7323 100644
@@ -166,6 +166,11 @@ void smsdvb_print_isdb_stats(struct smsdvb_debugfs *debug_data,
 	buf = debug_data->stats_data;
 
 	n += snprintf(&buf[n], PAGE_SIZE - n,
+		      "StatisticsType = %d\t", p->StatisticsType);
+	n += snprintf(&buf[n], PAGE_SIZE - n,
+		      "FullSize = %d\n", p->FullSize);
+
+	n += snprintf(&buf[n], PAGE_SIZE - n,
 		      "IsRfLocked = %d\t\t", p->IsRfLocked);
 	n += snprintf(&buf[n], PAGE_SIZE - n,
 		      "IsDemodLocked = %d\t", p->IsDemodLocked);
@@ -251,6 +256,11 @@ void smsdvb_print_isdb_stats_ex(struct smsdvb_debugfs *debug_data,
 	buf = debug_data->stats_data;
 
 	n += snprintf(&buf[n], PAGE_SIZE - n,
+		      "StatisticsType = %d\t", p->StatisticsType);
+	n += snprintf(&buf[n], PAGE_SIZE - n,
+		      "FullSize = %d\n", p->FullSize);
+
+	n += snprintf(&buf[n], PAGE_SIZE - n,
 		      "IsRfLocked = %d\t\t", p->IsRfLocked);
 	n += snprintf(&buf[n], PAGE_SIZE - n,
 		      "IsDemodLocked = %d\t", p->IsDemodLocked);
Signature · 1 line
1.8.1.4
#32 lore raw

PATCH 32/46 siano: don't request statistics too fast

In reply to Mauro Carvalho Chehab

As each DVBv3 call may generate an stats overhead, prevent doing it too fast. This is specially useful if a burst of get stats DVBv3 call is sent.

---
 drivers/media/common/siano/smsdvb-main.c | 5 +++++
 drivers/media/common/siano/smsdvb.h      | 2 ++
 2 files changed, 7 insertions(+)
drivers/media/common/siano/smsdvb-main.c +5 -0
index c14f10d..4242005 100644
@@ -663,6 +663,11 @@ static int smsdvb_send_statistics_request(struct smsdvb_client_t *client)
 	int rc;
 	struct SmsMsgHdr_ST Msg;
 
+	/* Don't request stats too fast */
+	if (client->get_stats_jiffies &&
+	   (!time_after(jiffies, client->get_stats_jiffies)))
+		return 0;
+	client->get_stats_jiffies = jiffies + msecs_to_jiffies(100);
 
 	Msg.msgSrcId = DVBT_BDA_CONTROL_MSG_ID;
 	Msg.msgDstId = HIF_TASK;
drivers/media/common/siano/smsdvb.h +2 -0
index 09982bc..3422069 100644
@@ -52,6 +52,8 @@ struct smsdvb_client_t {
 	int event_fe_state;
 	int event_unc_state;
 
+	unsigned long		get_stats_jiffies;
+
 	/* Stats debugfs data */
 	struct dentry		*debugfs;
 
Signature · 1 line
1.8.1.4
#33 lore raw

PATCH 33/46 siano: fix signal strength and CNR stats measurements

In reply to Mauro Carvalho Chehab

There are a number of small issues with the stats refactoring:
- InBandPwr better represents the signal strength;
- Don't zero signal strength /cnr if no lock;
- Fix signal strength/cnr scale;
- Don't need to fill PER/BER if not locked, as the code will disable those stats anyway.

---
 drivers/media/common/siano/smsdvb-main.c | 57 ++++++++++++++++++++------------
 1 file changed, 35 insertions(+), 22 deletions(-)
drivers/media/common/siano/smsdvb-main.c +35 -22
index 4242005..90f6e89 100644
@@ -155,11 +155,11 @@ static void smsdvb_stats_not_ready(struct dvb_frontend *fe)
 		n_layers = 1;
 	}
 
-	/* Fill the length of each status counter */
-
-	/* Only global stats */
+	/* Global stats */
 	c->strength.len = 1;
 	c->cnr.len = 1;
+	c->strength.stat[0].scale = FE_SCALE_DECIBEL;
+	c->cnr.stat[0].scale = FE_SCALE_DECIBEL;
 
 	/* Per-layer stats */
 	c->post_bit_error.len = n_layers;
@@ -167,13 +167,11 @@ static void smsdvb_stats_not_ready(struct dvb_frontend *fe)
 	c->block_error.len = n_layers;
 	c->block_count.len = n_layers;
 
-	/* Signal is always available */
-	c->strength.stat[0].scale = FE_SCALE_RELATIVE;
-	c->strength.stat[0].uvalue = 0;
-
-	/* Put all of them at FE_SCALE_NOT_AVAILABLE */
+	/*
+	 * Put all of them at FE_SCALE_NOT_AVAILABLE. They're dynamically
+	 * changed when the stats become available.
+	 */
 	for (i = 0; i < n_layers; i++) {
-		c->cnr.stat[i].scale = FE_SCALE_NOT_AVAILABLE;
 		c->post_bit_error.stat[i].scale = FE_SCALE_NOT_AVAILABLE;
 		c->post_bit_count.stat[i].scale = FE_SCALE_NOT_AVAILABLE;
 		c->block_error.stat[i].scale = FE_SCALE_NOT_AVAILABLE;
@@ -261,6 +259,16 @@ static void smsdvb_update_per_slices(struct smsdvb_client_t *client,
 	client->fe_status = sms_to_status(p->IsDemodLocked, p->IsRfLocked);
 	c->modulation = sms_to_modulation(p->constellation);
 
+	/* Signal Strength, in DBm */
+	c->strength.stat[0].uvalue = p->inBandPower * 1000;
+
+	/* Carrier to Noise ratio, in DB */
+	c->cnr.stat[0].svalue = p->snr * 1000;
+
+	/* PER/BER requires demod lock */
+	if (!p->IsDemodLocked)
+		return;
+
 	/* TS PER */
 	client->last_per = c->block_error.stat[0].uvalue;
 	c->block_error.stat[0].scale = FE_SCALE_COUNTER;
@@ -277,13 +285,6 @@ static void smsdvb_update_per_slices(struct smsdvb_client_t *client,
 	/* Legacy PER/BER */
 	client->legacy_per = (p->etsPackets * 65535) /
 			     (p->tsPackets + p->etsPackets);
-
-	/* Signal Strength, in DBm */
-	c->strength.stat[0].uvalue = p->RSSI * 1000;
-
-	/* Carrier to Noise ratio, in DB */
-	c->cnr.stat[0].scale = FE_SCALE_DECIBEL;
-	c->cnr.stat[0].svalue = p->snr * 1000;
 }
 
 static void smsdvb_update_dvb_stats(struct smsdvb_client_t *client,
@@ -312,11 +313,14 @@ static void smsdvb_update_dvb_stats(struct smsdvb_client_t *client,
 	c->lna = p->IsExternalLNAOn ? 1 : 0;
 
 	/* Carrier to Noise ratio, in DB */
-	c->cnr.stat[0].scale = FE_SCALE_DECIBEL;
 	c->cnr.stat[0].svalue = p->SNR * 1000;
 
 	/* Signal Strength, in DBm */
-	c->strength.stat[0].uvalue = p->RSSI * 1000;
+	c->strength.stat[0].uvalue = p->InBandPwr * 1000;
+
+	/* PER/BER requires demod lock */
+	if (!p->IsDemodLocked)
+		return;
 
 	/* TS PER */
 	client->last_per = c->block_error.stat[0].uvalue;
@@ -364,11 +368,14 @@ static void smsdvb_update_isdbt_stats(struct smsdvb_client_t *client,
 	c->lna = p->IsExternalLNAOn ? 1 : 0;
 
 	/* Carrier to Noise ratio, in DB */
-	c->cnr.stat[0].scale = FE_SCALE_DECIBEL;
 	c->cnr.stat[0].svalue = p->SNR * 1000;
 
 	/* Signal Strength, in DBm */
-	c->strength.stat[0].uvalue = p->RSSI * 1000;
+	c->strength.stat[0].uvalue = p->InBandPwr * 1000;
+
+	/* PER/BER and per-layer stats require demod lock */
+	if (!p->IsDemodLocked)
+		return;
 
 	client->last_per = c->block_error.stat[0].uvalue;
 
@@ -441,11 +448,14 @@ static void smsdvb_update_isdbt_stats_ex(struct smsdvb_client_t *client,
 	c->lna = p->IsExternalLNAOn ? 1 : 0;
 
 	/* Carrier to Noise ratio, in DB */
-	c->cnr.stat[0].scale = FE_SCALE_DECIBEL;
 	c->cnr.stat[0].svalue = p->SNR * 1000;
 
 	/* Signal Strength, in DBm */
-	c->strength.stat[0].uvalue = p->RSSI * 1000;
+	c->strength.stat[0].uvalue = p->InBandPwr * 1000;
+
+	/* PER/BER and per-layer stats require demod lock */
+	if (!p->IsDemodLocked)
+		return;
 
 	client->last_per = c->block_error.stat[0].uvalue;
 
@@ -943,11 +953,14 @@ static int smsdvb_isdbt_set_frontend(struct dvb_frontend *fe)
 
 static int smsdvb_set_frontend(struct dvb_frontend *fe)
 {
+	struct dtv_frontend_properties *c = &fe->dtv_property_cache;
 	struct smsdvb_client_t *client =
 		container_of(fe, struct smsdvb_client_t, frontend);
 	struct smscore_device_t *coredev = client->coredev;
 
 	smsdvb_stats_not_ready(fe);
+	c->strength.stat[0].uvalue = 0;
+	c->cnr.stat[0].uvalue = 0;
 
 	switch (smscore_get_device_mode(coredev)) {
 	case DEVICE_MODE_DVBT:
Signature · 1 line
1.8.1.4
#34 lore raw

PATCH 34/46 siano: fix PER/BER report on DVBv5

In reply to Mauro Carvalho Chehab

The check for lock logic is broken. Due to that, no PER/BER stats will ever be showed, and the DVBV3 events will be wrong.

Also, the per-layer PER/BER stats for ISDB-T are filled with the wrong index.

---
 drivers/media/common/siano/smsdvb-main.c | 46 ++++++++++++++++++++------------
 1 file changed, 29 insertions(+), 17 deletions(-)
drivers/media/common/siano/smsdvb-main.c +29 -17
index 90f6e89..632a250 100644
@@ -382,8 +382,12 @@ static void smsdvb_update_isdbt_stats(struct smsdvb_client_t *client,
 	/* Clears global counters, as the code below will sum it again */
 	c->block_error.stat[0].uvalue = 0;
 	c->block_count.stat[0].uvalue = 0;
+	c->block_error.stat[0].scale = FE_SCALE_COUNTER;
+	c->block_count.stat[0].scale = FE_SCALE_COUNTER;
 	c->post_bit_error.stat[0].uvalue = 0;
 	c->post_bit_count.stat[0].uvalue = 0;
+	c->post_bit_error.stat[0].scale = FE_SCALE_COUNTER;
+	c->post_bit_count.stat[0].scale = FE_SCALE_COUNTER;
 
 	for (i = 0; i < n_layers; i++) {
 		lr = &p->LayerInfo[i];
@@ -398,20 +402,20 @@ static void smsdvb_update_isdbt_stats(struct smsdvb_client_t *client,
 		c->layer[i].modulation = sms_to_modulation(lr->Constellation);
 
 		/* TS PER */
-		c->block_error.stat[i].scale = FE_SCALE_COUNTER;
-		c->block_count.stat[i].scale = FE_SCALE_COUNTER;
-		c->block_error.stat[i].uvalue += lr->ErrorTSPackets;
-		c->block_count.stat[i].uvalue += lr->TotalTSPackets;
+		c->block_error.stat[i + 1].scale = FE_SCALE_COUNTER;
+		c->block_count.stat[i + 1].scale = FE_SCALE_COUNTER;
+		c->block_error.stat[i + 1].uvalue += lr->ErrorTSPackets;
+		c->block_count.stat[i + 1].uvalue += lr->TotalTSPackets;
 
 		/* Update global PER counter */
 		c->block_error.stat[0].uvalue += lr->ErrorTSPackets;
 		c->block_count.stat[0].uvalue += lr->TotalTSPackets;
 
 		/* BER */
-		c->post_bit_error.stat[i].scale = FE_SCALE_COUNTER;
-		c->post_bit_count.stat[i].scale = FE_SCALE_COUNTER;
-		c->post_bit_error.stat[i].uvalue += lr->BERErrorCount;
-		c->post_bit_count.stat[i].uvalue += lr->BERBitCount;
+		c->post_bit_error.stat[i + 1].scale = FE_SCALE_COUNTER;
+		c->post_bit_count.stat[i + 1].scale = FE_SCALE_COUNTER;
+		c->post_bit_error.stat[i + 1].uvalue += lr->BERErrorCount;
+		c->post_bit_count.stat[i + 1].uvalue += lr->BERBitCount;
 
 		/* Update global BER counter */
 		c->post_bit_error.stat[0].uvalue += lr->BERErrorCount;
@@ -462,9 +466,17 @@ static void smsdvb_update_isdbt_stats_ex(struct smsdvb_client_t *client,
 	/* Clears global counters, as the code below will sum it again */
 	c->block_error.stat[0].uvalue = 0;
 	c->block_count.stat[0].uvalue = 0;
+	c->block_error.stat[0].scale = FE_SCALE_COUNTER;
+	c->block_count.stat[0].scale = FE_SCALE_COUNTER;
 	c->post_bit_error.stat[0].uvalue = 0;
 	c->post_bit_count.stat[0].uvalue = 0;
+	c->post_bit_error.stat[0].scale = FE_SCALE_COUNTER;
+	c->post_bit_count.stat[0].scale = FE_SCALE_COUNTER;
 
+	c->post_bit_error.len = n_layers + 1;
+	c->post_bit_count.len = n_layers + 1;
+	c->block_error.len = n_layers + 1;
+	c->block_count.len = n_layers + 1;
 	for (i = 0; i < n_layers; i++) {
 		lr = &p->LayerInfo[i];
 
@@ -478,20 +490,20 @@ static void smsdvb_update_isdbt_stats_ex(struct smsdvb_client_t *client,
 		c->layer[i].modulation = sms_to_modulation(lr->Constellation);
 
 		/* TS PER */
-		c->block_error.stat[i].scale = FE_SCALE_COUNTER;
-		c->block_count.stat[i].scale = FE_SCALE_COUNTER;
-		c->block_error.stat[i].uvalue += lr->ErrorTSPackets;
-		c->block_count.stat[i].uvalue += lr->TotalTSPackets;
+		c->block_error.stat[i + 1].scale = FE_SCALE_COUNTER;
+		c->block_count.stat[i + 1].scale = FE_SCALE_COUNTER;
+		c->block_error.stat[i + 1].uvalue += lr->ErrorTSPackets;
+		c->block_count.stat[i + 1].uvalue += lr->TotalTSPackets;
 
 		/* Update global PER counter */
 		c->block_error.stat[0].uvalue += lr->ErrorTSPackets;
 		c->block_count.stat[0].uvalue += lr->TotalTSPackets;
 
 		/* BER */
-		c->post_bit_error.stat[i].scale = FE_SCALE_COUNTER;
-		c->post_bit_count.stat[i].scale = FE_SCALE_COUNTER;
-		c->post_bit_error.stat[i].uvalue += lr->BERErrorCount;
-		c->post_bit_count.stat[i].uvalue += lr->BERBitCount;
+		c->post_bit_error.stat[i + 1].scale = FE_SCALE_COUNTER;
+		c->post_bit_count.stat[i + 1].scale = FE_SCALE_COUNTER;
+		c->post_bit_error.stat[i + 1].uvalue += lr->BERErrorCount;
+		c->post_bit_count.stat[i + 1].uvalue += lr->BERBitCount;
 
 		/* Update global BER counter */
 		c->post_bit_error.stat[0].uvalue += lr->BERErrorCount;
@@ -572,7 +584,7 @@ static int smsdvb_onresponse(void *context, struct smscore_buffer_t *cb)
 	smscore_putbuffer(client->coredev, cb);
 
 	if (is_status_update) {
-		if (client->fe_status == FE_HAS_LOCK) {
+		if (client->fe_status & FE_HAS_LOCK) {
 			sms_board_dvb3_event(client, DVB3_EVENT_FE_LOCK);
 			if (client->last_per == c->block_error.stat[0].uvalue)
 				sms_board_dvb3_event(client, DVB3_EVENT_UNC_OK);
Signature · 1 line
1.8.1.4
#35 lore raw

PATCH 35/46 siano: Fix bandwidth report

In reply to Mauro Carvalho Chehab

It was expected that the bandwidth would be following the defines at smscoreapi.h. However, this doesn't work. Instead, this field brings just the bandwidth in MHz. Convert it to Hertz.

It should be noticed that, on ISDB, using the _EX request, the field TuneBW seems to show the value that matches the bandwidth code.

---
 drivers/media/common/siano/smsdvb-main.c | 18 +++---------------
 1 file changed, 3 insertions(+), 15 deletions(-)
drivers/media/common/siano/smsdvb-main.c +3 -15
index 632a250..b146064 100644
@@ -43,18 +43,6 @@ module_param_named(debug, sms_dbg, int, 0644);
 MODULE_PARM_DESC(debug, "set debug level (info=1, adv=2 (or-able))");
 
 
-u32 sms_to_bw_table[] = {
-	[BW_8_MHZ]		= 8000000,
-	[BW_7_MHZ]		= 7000000,
-	[BW_6_MHZ]		= 6000000,
-	[BW_5_MHZ]		= 5000000,
-	[BW_2_MHZ]		= 2000000,
-	[BW_1_5_MHZ]		= 1500000,
-	[BW_ISDBT_1SEG]		= 6000000,
-	[BW_ISDBT_3SEG]		= 6000000,
-	[BW_ISDBT_13SEG]	= 6000000,
-};
-
 u32 sms_to_guard_interval_table[] = {
 	[0] = GUARD_INTERVAL_1_32,
 	[1] = GUARD_INTERVAL_1_16,
@@ -204,6 +192,9 @@ static inline int sms_to_status(u32 is_demod_locked, u32 is_rf_locked)
 	return 0;
 }
 
+static inline u32 sms_to_bw(u32 value) {
+	return value * 1000000;
+}
 
 #define convert_from_table(value, table, defval) ({			\
 	u32 __ret;							\
@@ -214,9 +205,6 @@ static inline int sms_to_status(u32 is_demod_locked, u32 is_rf_locked)
 	__ret;								\
 })
 
-#define sms_to_bw(value)						\
-	convert_from_table(value, sms_to_bw_table, 0);
-
 #define sms_to_guard_interval(value)					\
 	convert_from_table(value, sms_to_guard_interval_table,		\
 			   GUARD_INTERVAL_AUTO);
Signature · 1 line
1.8.1.4
#36 lore raw

PATCH 36/46 siano: Only feed DVB data when there's a feed

In reply to Mauro Carvalho Chehab

Right now, the driver sends DVB data even before tunning.

It was noticed that this may lead into some mistakes at DVB decode, as the PIDs from wrong channels may be associated with another frequency, as they may already be inside the PID buffers.

So, prevent it by not feeding DVB demux with data while there's no feed or while the device is not tuned.

---
 drivers/media/common/siano/smsdvb-main.c | 18 +++++++++++++++---
 drivers/media/common/siano/smsdvb.h      |  3 +++
 2 files changed, 18 insertions(+), 3 deletions(-)
drivers/media/common/siano/smsdvb-main.c +15 -3
index b146064..114fe57 100644
@@ -511,8 +511,13 @@ static int smsdvb_onresponse(void *context, struct smscore_buffer_t *cb)
 
 	switch (phdr->msgType) {
 	case MSG_SMS_DVBT_BDA_DATA:
-		dvb_dmx_swfilter(&client->demux, p,
-				 cb->size - sizeof(struct SmsMsgHdr_ST));
+		/*
+		 * Only feed data to dvb demux if are there any feed listening
+		 * to it and if the device has tuned
+		 */
+		if (client->feed_users && client->has_tuned)
+			dvb_dmx_swfilter(&client->demux, p,
+					 cb->size - sizeof(struct SmsMsgHdr_ST));
 		break;
 
 	case MSG_SMS_RF_TUNE_RES:
@@ -578,9 +583,10 @@ static int smsdvb_onresponse(void *context, struct smscore_buffer_t *cb)
 				sms_board_dvb3_event(client, DVB3_EVENT_UNC_OK);
 			else
 				sms_board_dvb3_event(client, DVB3_EVENT_UNC_ERR);
+			client->has_tuned = true;
 		} else {
 			smsdvb_stats_not_ready(fe);
-
+			client->has_tuned = false;
 			sms_board_dvb3_event(client, DVB3_EVENT_FE_UNLOCK);
 		}
 		complete(&client->stats_done);
@@ -622,6 +628,8 @@ static int smsdvb_start_feed(struct dvb_demux_feed *feed)
 	sms_debug("add pid %d(%x)",
 		  feed->pid, feed->pid);
 
+	client->feed_users++;
+
 	PidMsg.xMsgHeader.msgSrcId = DVBT_BDA_CONTROL_MSG_ID;
 	PidMsg.xMsgHeader.msgDstId = HIF_TASK;
 	PidMsg.xMsgHeader.msgFlags = 0;
@@ -642,6 +650,8 @@ static int smsdvb_stop_feed(struct dvb_demux_feed *feed)
 	sms_debug("remove pid %d(%x)",
 		  feed->pid, feed->pid);
 
+	client->feed_users--;
+
 	PidMsg.xMsgHeader.msgSrcId = DVBT_BDA_CONTROL_MSG_ID;
 	PidMsg.xMsgHeader.msgDstId = HIF_TASK;
 	PidMsg.xMsgHeader.msgFlags = 0;
@@ -962,6 +972,8 @@ static int smsdvb_set_frontend(struct dvb_frontend *fe)
 	c->strength.stat[0].uvalue = 0;
 	c->cnr.stat[0].uvalue = 0;
 
+	client->has_tuned = false;
+
 	switch (smscore_get_device_mode(coredev)) {
 	case DEVICE_MODE_DVBT:
 	case DEVICE_MODE_DVBT_BDA:
drivers/media/common/siano/smsdvb.h +3 -0
index 3422069..63cdd75 100644
@@ -54,6 +54,9 @@ struct smsdvb_client_t {
 
 	unsigned long		get_stats_jiffies;
 
+	int			feed_users;
+	bool			has_tuned;
+
 	/* Stats debugfs data */
 	struct dentry		*debugfs;
 
Signature · 1 line
1.8.1.4
#37 lore raw

PATCH 37/46 siano: fix status report with old firmware and ISDB-T

In reply to Mauro Carvalho Chehab

This seems to be ever broken. That's the status report with Firmware 2.1, before adding support for sms2270 is:

[22273.787218] smsdvb_onresponse: MSG_SMS_GET_STATISTICS_RES
[22273.792592] IsRfLocked = 1
[22273.792592] IsDemodLocked = 1
...
[22273.792598] TransmissionMode = -64

...
(all unshown fields are filled with zeros)

Of course, transmission mode being a negative number is wrong. So, we need to take a deeper look on it.

With the debugfs patches applied, it is possible to see that, instead of filling StatisticsType with 5, and FullSize with the size of the payload (this is what happens with sms2270 and firmware 8.1), those fields are also initialized with zero:

StatisticsType = 0 FullSize = 0
IsRfLocked = 1 IsDemodLocked = 1 IsExternalLNAOn = 0
SNR = 0 dB RSSI = 0 dBm InBandPwr = 0 dBm
CarrierOffset = 0 Bandwidth = 0 Frequency = 0 Hz
TransmissionMode = -64 ModemState = 0 GuardInterval = 0
SystemType = 0 PartialReception = 0 NumOfLayers = 0
SmsToHostTxErrors = 0

The data under "TransmissionMode" varies according with the signal, and it is negative. It also matches the value for InBandPwr when the tuner is on DVB-T (ok, signal doesn't lock, but the power level should be about the same with the antena fixed, and measured at about the same time).

So, there's a very high chance that, when StatisticsType is zero, the signal strength is at the same position as Transmission Mode.

So, discard all other parameters, and provide only signal/rf lock and signal strength if StatisticsType is 0, for ISDB-T.

---
 drivers/media/common/siano/smsdvb-main.c | 14 +++++++++++++-
 1 file changed, 13 insertions(+), 1 deletion(-)
drivers/media/common/siano/smsdvb-main.c +13 -1
index 114fe57..ce6ba7b 100644
@@ -338,9 +338,21 @@ static void smsdvb_update_isdbt_stats(struct smsdvb_client_t *client,
 	if (client->prt_isdb_stats)
 		client->prt_isdb_stats(client->debug_data, p);
 
+	client->fe_status = sms_to_status(p->IsDemodLocked, p->IsRfLocked);
+
+	/*
+	 * Firmware 2.1 seems to report only lock status and
+	 * Signal strength. The signal strength indicator is at the
+	 * wrong field.
+	 */
+	if (p->StatisticsType == 0) {
+		c->strength.stat[0].uvalue = ((s32)p->TransmissionMode) * 1000;
+		c->cnr.stat[0].scale = FE_SCALE_NOT_AVAILABLE;
+		return;
+	}
+
 	/* Update ISDB-T transmission parameters */
 	c->frequency = p->Frequency;
-	client->fe_status = sms_to_status(p->IsDemodLocked, 0);
 	c->bandwidth_hz = sms_to_bw(p->Bandwidth);
 	c->transmission_mode = sms_to_mode(p->TransmissionMode);
 	c->guard_interval = sms_to_guard_interval(p->GuardInterval);
Signature · 1 line
1.8.1.4
#38 lore raw

PATCH 38/46 siano: add support for .poll on debugfs

In reply to Mauro Carvalho Chehab

Implement poll() method for debugfs and be sure that the debug_data won't be freed on ir or on read().

With this change, poll() will return POLLIN if either data was filled or if data was read. That allows read() to return 0 to indicate EOF in the latter case.

As poll() is now provided, fix support for non-block mode.

---
 drivers/media/common/siano/smsdvb-debugfs.c | 77 ++++++++++++++++++++++-------
 1 file changed, 59 insertions(+), 18 deletions(-)
drivers/media/common/siano/smsdvb-debugfs.c +59 -18
index 59c7323..0219be3 100644
@@ -352,6 +352,14 @@ static int smsdvb_stats_open(struct inode *inode, struct file *file)
 	return 0;
 }
 
+static void smsdvb_debugfs_data_release(struct kref *ref)
+{
+	struct smsdvb_debugfs *debug_data;
+
+	debug_data = container_of(ref, struct smsdvb_debugfs, refcount);
+	kfree(debug_data);
+}
+
 static int smsdvb_stats_wait_read(struct smsdvb_debugfs *debug_data)
 {
 	int rc = 1;
@@ -368,33 +376,65 @@ exit:
 	return rc;
 }
 
-static ssize_t smsdvb_stats_read(struct file *file, char __user *user_buf,
-				      size_t nbytes, loff_t *ppos)
+static unsigned int smsdvb_stats_poll(struct file *file, poll_table *wait)
 {
-	int rc = 0;
 	struct smsdvb_debugfs *debug_data = file->private_data;
+	int rc;
 
-	rc = wait_event_interruptible(debug_data->stats_queue,
-				      smsdvb_stats_wait_read(debug_data));
-	if (rc < 0)
-		return rc;
+	kref_get(&debug_data->refcount);
 
-	rc = simple_read_from_buffer(user_buf, nbytes, ppos,
-				     debug_data->stats_data,
-				     debug_data->stats_count);
-	spin_lock(&debug_data->lock);
-	debug_data->stats_was_read = true;
-	spin_unlock(&debug_data->lock);
+	poll_wait(file, &debug_data->stats_queue, wait);
+
+	rc = smsdvb_stats_wait_read(debug_data);
+	if (rc > 0)
+		rc = POLLIN | POLLRDNORM;
+
+	kref_put(&debug_data->refcount, smsdvb_debugfs_data_release);
 
 	return rc;
 }
 
-static void smsdvb_debugfs_data_release(struct kref *ref)
+static ssize_t smsdvb_stats_read(struct file *file, char __user *user_buf,
+				      size_t nbytes, loff_t *ppos)
 {
-	struct smsdvb_debugfs *debug_data;
+	int rc = 0, len;
+	struct smsdvb_debugfs *debug_data = file->private_data;
 
-	debug_data = container_of(ref, struct smsdvb_debugfs, refcount);
-	kfree(debug_data);
+	kref_get(&debug_data->refcount);
+
+	if (file->f_flags & O_NONBLOCK) {
+		rc = smsdvb_stats_wait_read(debug_data);
+		if (!rc) {
+			rc = -EWOULDBLOCK;
+			goto ret;
+		}
+	} else {
+		rc = wait_event_interruptible(debug_data->stats_queue,
+				      smsdvb_stats_wait_read(debug_data));
+		if (rc < 0)
+			goto ret;
+	}
+
+	if (debug_data->stats_was_read) {
+		rc = 0;	/* EOF */
+		goto ret;
+	}
+
+	len = debug_data->stats_count - *ppos;
+	if (len >= 0)
+		rc = simple_read_from_buffer(user_buf, nbytes, ppos,
+					     debug_data->stats_data, len);
+	else
+		rc = 0;
+
+	if (*ppos >= debug_data->stats_count) {
+		spin_lock(&debug_data->lock);
+		debug_data->stats_was_read = true;
+		spin_unlock(&debug_data->lock);
+	}
+ret:
+	kref_put(&debug_data->refcount, smsdvb_debugfs_data_release);
+	return rc;
 }
 
 static int smsdvb_stats_release(struct inode *inode, struct file *file)
@@ -402,7 +442,7 @@ static int smsdvb_stats_release(struct inode *inode, struct file *file)
 	struct smsdvb_debugfs *debug_data = file->private_data;
 
 	spin_lock(&debug_data->lock);
-	debug_data->stats_was_read = true;
+	debug_data->stats_was_read = true;	/* return EOF to read() */
 	spin_unlock(&debug_data->lock);
 	wake_up_interruptible_sync(&debug_data->stats_queue);
 
@@ -414,6 +454,7 @@ static int smsdvb_stats_release(struct inode *inode, struct file *file)
 
 static const struct file_operations debugfs_stats_ops = {
 	.open = smsdvb_stats_open,
+	.poll = smsdvb_stats_poll,
 	.read = smsdvb_stats_read,
 	.release = smsdvb_stats_release,
 	.llseek = generic_file_llseek,
Signature · 1 line
1.8.1.4
#39 lore raw

PATCH 39/46 siano: simplify firmware lookup logic

In reply to Mauro Carvalho Chehab

There are two ways to specify firmware for siano devices: a per-device ID and a per-device type.

The per-device type logic is currently made by a 11x9 string table, sparsely filled. It is very hard to read the table at the source code, as there are too much "none" filling there ("none" there is a way to tell NULL).

Instead of using such problematic table, convert it into an easy to read table, where the unused values will be defaulted to NULL.

While here, also simplifies a little bit the logic and print a message if an user-selected mode doesn't exist.

---
 drivers/media/common/siano/smscoreapi.c | 91 +++++++++++++++++++--------------
 1 file changed, 54 insertions(+), 37 deletions(-)
drivers/media/common/siano/smscoreapi.c +54 -37
index 029dd6a..6db7fe5 100644
@@ -1063,9 +1063,11 @@ static int smscore_load_firmware_from_file(struct smscore_device_t *coredev,
 	const struct firmware *fw;
 
 	char *fw_filename = smscore_get_fw_filename(coredev, mode, lookup);
-	sms_debug("Firmware name: %s\n", fw_filename);
-	if (!strcmp(fw_filename, "none"))
+	if (!fw_filename) {
+		sms_info("mode %d not supported on this device", mode);
 		return -ENOENT;
+	}
+	sms_debug("Firmware name: %s", fw_filename);
 
 	if (loadfirmware_handler == NULL && !(coredev->device_flags
 			& SMS_DEVICE_FAMILY2))
@@ -1199,32 +1201,53 @@ static int smscore_detect_mode(struct smscore_device_t *coredev)
 	return rc;
 }
 
-static char *smscore_fw_lkup[][SMS_NUM_OF_DEVICE_TYPES] = {
-	/*Stellar, NOVA A0, Nova B0, VEGA, VENICE, MING, PELE, RIO, DENVER_1530, DENVER_2160 */
-		/*DVBT*/
-	{ "none", "dvb_nova_12mhz.inp", "dvb_nova_12mhz_b0.inp", "none", "none", "none", "none", "dvb_rio.inp", "none", "none" },
-		/*DVBH*/
-	{ "none", "dvb_nova_12mhz.inp", "dvb_nova_12mhz_b0.inp", "none", "none", "none", "none", "dvbh_rio.inp", "none", "none" },
-		/*TDMB*/
-	{ "none", "tdmb_nova_12mhz.inp", "tdmb_nova_12mhz_b0.inp", "none", "none", "none", "none", "none", "none", "tdmb_denver.inp" },
-		/*DABIP*/
-	{ "none", "none", "none", "none", "none", "none", "none", "none", "none", "none" },
-		/*DVBT_BDA*/
-	{ "none", "dvb_nova_12mhz.inp", "dvb_nova_12mhz_b0.inp", "none", "none", "none", "none", "dvb_rio.inp", "none", "none" },
-		/*ISDBT*/
-	{ "none", "isdbt_nova_12mhz.inp", "isdbt_nova_12mhz_b0.inp", "none", "none", "none", "isdbt_pele.inp", "isdbt_rio.inp", "none", "none" },
-		/*ISDBT_BDA*/
-	{ "none", "isdbt_nova_12mhz.inp", "isdbt_nova_12mhz_b0.inp", "none", "none", "none", "isdbt_pele.inp", "isdbt_rio.inp", "none", "none" },
-		/*CMMB*/
-	{ "none", "none", "none", "cmmb_vega_12mhz.inp", "cmmb_venice_12mhz.inp", "cmmb_ming_app.inp", "none", "none", "none", 	"none" },
-		/*RAW - not supported*/
-	{ "none", "none", "none", "none", "none", "none", "none", "none", "none", "none" },
-		/*FM*/
-	{ "none", "none", "fm_radio.inp", "none", "none", "none", "none", "fm_radio_rio.inp", "none", "none" },
-		/*FM_BDA*/
-	{ "none", "none", "fm_radio.inp", "none", "none", "none", "none", "fm_radio_rio.inp", "none", "none" },
-		/*ATSC*/
-	{ "none", "none", "none", "none", "none", "none", "none", "none", "atsc_denver.inp", "none" }
+static char *smscore_fw_lkup[][DEVICE_MODE_MAX] = {
+	[SMS_NOVA_A0] = {
+		[DEVICE_MODE_DVBT]		= "dvb_nova_12mhz.inp",
+		[DEVICE_MODE_DVBH]		= "dvb_nova_12mhz.inp",
+		[DEVICE_MODE_DAB_TDMB]		= "tdmb_nova_12mhz.inp",
+		[DEVICE_MODE_DVBT_BDA]		= "dvb_nova_12mhz.inp",
+		[DEVICE_MODE_ISDBT]		= "isdbt_nova_12mhz.inp",
+		[DEVICE_MODE_ISDBT_BDA]		= "isdbt_nova_12mhz.inp",
+	},
+	[SMS_NOVA_B0] = {
+		[DEVICE_MODE_DVBT]		= "dvb_nova_12mhz_b0.inp",
+		[DEVICE_MODE_DVBH]		= "dvb_nova_12mhz_b0.inp",
+		[DEVICE_MODE_DAB_TDMB]		= "tdmb_nova_12mhz_b0.inp",
+		[DEVICE_MODE_DVBT_BDA]		= "dvb_nova_12mhz_b0.inp",
+		[DEVICE_MODE_ISDBT]		= "isdbt_nova_12mhz_b0.inp",
+		[DEVICE_MODE_ISDBT_BDA]		= "isdbt_nova_12mhz_b0.inp",
+		[DEVICE_MODE_FM_RADIO]		= "fm_radio.inp",
+		[DEVICE_MODE_FM_RADIO_BDA]	= "fm_radio.inp",
+	},
+	[SMS_VEGA] = {
+		[DEVICE_MODE_CMMB]		= "cmmb_vega_12mhz.inp",
+	},
+	[SMS_VENICE] = {
+		[DEVICE_MODE_CMMB]		= "cmmb_venice_12mhz.inp",
+	},
+	[SMS_MING] = {
+		[DEVICE_MODE_CMMB]		= "cmmb_ming_app.inp",
+	},
+	[SMS_PELE] = {
+		[DEVICE_MODE_ISDBT]		= "isdbt_pele.inp",
+		[DEVICE_MODE_ISDBT_BDA]		= "isdbt_pele.inp",
+	},
+	[SMS_RIO] = {
+		[DEVICE_MODE_DVBT]		= "dvb_rio.inp",
+		[DEVICE_MODE_DVBH]		= "dvbh_rio.inp",
+		[DEVICE_MODE_DVBT_BDA]		= "dvb_rio.inp",
+		[DEVICE_MODE_ISDBT]		= "isdbt_rio.inp",
+		[DEVICE_MODE_ISDBT_BDA]		= "isdbt_rio.inp",
+		[DEVICE_MODE_FM_RADIO]		= "fm_radio_rio.inp",
+		[DEVICE_MODE_FM_RADIO_BDA]	= "fm_radio_rio.inp",
+	},
+	[SMS_DENVER_1530] = {
+		[DEVICE_MODE_ATSC]		= "atsc_denver.inp",
+	},
+	[SMS_DENVER_2160] = {
+		[DEVICE_MODE_DAB_TDMB]		= "tdmb_denver.inp",
+	},
 };
 
 /**
@@ -1250,22 +1273,16 @@ static char *smscore_get_fw_filename(struct smscore_device_t *coredev,
 	if ((board_id == SMS_BOARD_UNKNOWN) || (lookup == 1)) {
 		sms_debug("trying to get fw name from lookup table mode %d type %d",
 			  mode, type);
-		return smscore_fw_lkup[mode][type];
+		return smscore_fw_lkup[type][mode];
 	}
 
 	sms_debug("trying to get fw name from sms_boards board_id %d mode %d",
 		  board_id, mode);
 	fw = sms_get_board(board_id)->fw;
-	if (fw == NULL) {
-		sms_debug("cannot find fw name in sms_boards, getting from lookup table mode %d type %d",
-			  mode, type);
-		return smscore_fw_lkup[mode][type];
-	}
-
-	if (fw[mode] == NULL) {
+	if (!fw || !fw[mode]) {
 		sms_debug("cannot find fw name in sms_boards, getting from lookup table mode %d type %d",
 			  mode, type);
-		return smscore_fw_lkup[mode][type];
+		return smscore_fw_lkup[type][mode];
 	}
 
 	return fw[mode];
Signature · 1 line
1.8.1.4
#40 lore raw

PATCH 40/46 siano: honour per-card default mode

In reply to Mauro Carvalho Chehab

Instead of using a global default_mode, passed via modprobe parameter, use the one defined inside the cards struct.

That will prevent the need of manually specify it for each board, except, of course, if the user wants to do something different, on boards that accept multiple types.

---
 drivers/media/common/siano/smscoreapi.c | 23 ++++++++++++++++++-----
 1 file changed, 18 insertions(+), 5 deletions(-)
drivers/media/common/siano/smscoreapi.c +18 -5
index 6db7fe5..4fa3df2 100644
@@ -434,7 +434,7 @@ static struct mutex g_smscore_deviceslock;
 static struct list_head g_smscore_registry;
 static struct mutex g_smscore_registrylock;
 
-static int default_mode = 4;
+static int default_mode = DEVICE_MODE_NONE;
 
 module_param(default_mode, int, 0644);
 MODULE_PARM_DESC(default_mode, "default firmware id (device mode)");
@@ -880,8 +880,15 @@ int smscore_configure_board(struct smscore_device_t *coredev)
  */
 int smscore_start_device(struct smscore_device_t *coredev)
 {
-	int rc = smscore_set_device_mode(
-			coredev, smscore_registry_getmode(coredev->devpath));
+	int rc;
+	int board_id = smscore_get_board_id(coredev);
+	int mode = smscore_registry_getmode(coredev->devpath);
+
+	/* Device is initialized as DEVICE_MODE_NONE */
+	if (board_id != SMS_BOARD_UNKNOWN && mode == DEVICE_MODE_NONE)
+		mode = sms_get_board(board_id)->default_mode;
+
+	rc = smscore_set_device_mode(coredev, mode);
 	if (rc < 0) {
 		sms_info("set device mode faile , rc %d", rc);
 		return rc;
@@ -1270,6 +1277,12 @@ static char *smscore_get_fw_filename(struct smscore_device_t *coredev,
 
 	type = smscore_registry_gettype(coredev->devpath);
 
+	/* Prevent looking outside the smscore_fw_lkup table */
+	if (type <= SMS_UNKNOWN_TYPE || type >= SMS_NUM_OF_DEVICE_TYPES)
+		return NULL;
+	if (mode <= DEVICE_MODE_NONE || mode >= DEVICE_MODE_MAX)
+		return NULL;
+
 	if ((board_id == SMS_BOARD_UNKNOWN) || (lookup == 1)) {
 		sms_debug("trying to get fw name from lookup table mode %d type %d",
 			  mode, type);
@@ -1339,7 +1352,7 @@ int smscore_set_device_mode(struct smscore_device_t *coredev, int mode)
 
 	sms_debug("set device mode to %d", mode);
 	if (coredev->device_flags & SMS_DEVICE_FAMILY2) {
-		if (mode < DEVICE_MODE_DVBT || mode >= DEVICE_MODE_RAW_TUNER) {
+		if (mode <= DEVICE_MODE_NONE || mode >= DEVICE_MODE_MAX) {
 			sms_err("invalid mode specified %d", mode);
 			return -EINVAL;
 		}
@@ -1391,7 +1404,7 @@ int smscore_set_device_mode(struct smscore_device_t *coredev, int mode)
 				sms_err("device init failed, rc %d.", rc);
 		}
 	} else {
-		if (mode < DEVICE_MODE_DVBT || mode > DEVICE_MODE_MAX) {
+		if (mode <= DEVICE_MODE_NONE || mode >= DEVICE_MODE_MAX) {
 			sms_err("invalid mode specified %d", mode);
 			return -EINVAL;
 		}
Signature · 1 line
1.8.1.4
#41 lore raw

PATCH 41/46 siano: remove the bogus firmware lookup code

In reply to Mauro Carvalho Chehab

There is an special lookup code that is called when SMS_BOARD_UNKNOWN. The logic there is bogus and will cause an oops, as .type is SMS_UNKNOWN_TYPE (-1).

As the code would do:

	return smscore_fw_lkup[type][mode];

That would mean that it would try to go past the
smscore_fw_lkup table.

So, just remove that bogus code, simplifying the logic.

---
 drivers/media/common/siano/smscoreapi.c | 33 +++++----------------------------
 1 file changed, 5 insertions(+), 28 deletions(-)
drivers/media/common/siano/smscoreapi.c +5 -28
index 4fa3df2..f6619e0 100644
@@ -1048,7 +1048,7 @@ exit_fw_download:
 
 
 static char *smscore_get_fw_filename(struct smscore_device_t *coredev,
-			      int mode, int lookup);
+				     int mode);
 
 /**
  * loads specified firmware into a buffer and calls device loadfirmware_handler
@@ -1061,7 +1061,7 @@ static char *smscore_get_fw_filename(struct smscore_device_t *coredev,
  * @return 0 on success, <0 on error.
  */
 static int smscore_load_firmware_from_file(struct smscore_device_t *coredev,
-					   int mode, int lookup,
+					   int mode,
 					   loadfirmware_t loadfirmware_handler)
 {
 	int rc = -ENOENT;
@@ -1069,7 +1069,7 @@ static int smscore_load_firmware_from_file(struct smscore_device_t *coredev,
 	u32 fw_buf_size;
 	const struct firmware *fw;
 
-	char *fw_filename = smscore_get_fw_filename(coredev, mode, lookup);
+	char *fw_filename = smscore_get_fw_filename(coredev, mode);
 	if (!fw_filename) {
 		sms_info("mode %d not supported on this device", mode);
 		return -ENOENT;
@@ -1269,7 +1269,7 @@ static char *smscore_fw_lkup[][DEVICE_MODE_MAX] = {
  * @return 0 on success, <0 on error.
  */
 static char *smscore_get_fw_filename(struct smscore_device_t *coredev,
-			      int mode, int lookup)
+			      int mode)
 {
 	char **fw;
 	int board_id = smscore_get_board_id(coredev);
@@ -1283,12 +1283,6 @@ static char *smscore_get_fw_filename(struct smscore_device_t *coredev,
 	if (mode <= DEVICE_MODE_NONE || mode >= DEVICE_MODE_MAX)
 		return NULL;
 
-	if ((board_id == SMS_BOARD_UNKNOWN) || (lookup == 1)) {
-		sms_debug("trying to get fw name from lookup table mode %d type %d",
-			  mode, type);
-		return smscore_fw_lkup[type][mode];
-	}
-
 	sms_debug("trying to get fw name from sms_boards board_id %d mode %d",
 		  board_id, mode);
 	fw = sms_get_board(board_id)->fw;
@@ -1374,24 +1368,7 @@ int smscore_set_device_mode(struct smscore_device_t *coredev, int mode)
 
 		if (!(coredev->modes_supported & (1 << mode))) {
 			rc = smscore_load_firmware_from_file(coredev,
-							     mode, 0, NULL);
-
-			/*
-			* try again with the default firmware -
-			* get the fw filename from look-up table
-			*/
-			if (rc < 0) {
-				sms_debug("error %d loading firmware, trying again with default firmware",
-					  rc);
-				rc = smscore_load_firmware_from_file(coredev,
-								     mode, 1,
-								     NULL);
-				if (rc < 0) {
-					sms_debug("error %d loading firmware",
-						  rc);
-					return rc;
-				}
-			}
+							     mode, NULL);
 			if (rc >= 0)
 				sms_info("firmware download success");
 		} else {
Signature · 1 line
1.8.1.4
#42 lore raw

PATCH 42/46 siano: reorder smscore_get_fw_filename() function

In reply to Mauro Carvalho Chehab

Put this function earlier in the code, to avoid the need of defining a function stub.

No functional changes.

---
 drivers/media/common/siano/smscoreapi.c | 172 ++++++++++++++++----------------
 1 file changed, 84 insertions(+), 88 deletions(-)
drivers/media/common/siano/smscoreapi.c +84 -88
index f6619e0..5bfeeee 100644
@@ -1046,9 +1046,92 @@ exit_fw_download:
 	return rc;
 }
 
+static char *smscore_fw_lkup[][DEVICE_MODE_MAX] = {
+	[SMS_NOVA_A0] = {
+		[DEVICE_MODE_DVBT]		= "dvb_nova_12mhz.inp",
+		[DEVICE_MODE_DVBH]		= "dvb_nova_12mhz.inp",
+		[DEVICE_MODE_DAB_TDMB]		= "tdmb_nova_12mhz.inp",
+		[DEVICE_MODE_DVBT_BDA]		= "dvb_nova_12mhz.inp",
+		[DEVICE_MODE_ISDBT]		= "isdbt_nova_12mhz.inp",
+		[DEVICE_MODE_ISDBT_BDA]		= "isdbt_nova_12mhz.inp",
+	},
+	[SMS_NOVA_B0] = {
+		[DEVICE_MODE_DVBT]		= "dvb_nova_12mhz_b0.inp",
+		[DEVICE_MODE_DVBH]		= "dvb_nova_12mhz_b0.inp",
+		[DEVICE_MODE_DAB_TDMB]		= "tdmb_nova_12mhz_b0.inp",
+		[DEVICE_MODE_DVBT_BDA]		= "dvb_nova_12mhz_b0.inp",
+		[DEVICE_MODE_ISDBT]		= "isdbt_nova_12mhz_b0.inp",
+		[DEVICE_MODE_ISDBT_BDA]		= "isdbt_nova_12mhz_b0.inp",
+		[DEVICE_MODE_FM_RADIO]		= "fm_radio.inp",
+		[DEVICE_MODE_FM_RADIO_BDA]	= "fm_radio.inp",
+	},
+	[SMS_VEGA] = {
+		[DEVICE_MODE_CMMB]		= "cmmb_vega_12mhz.inp",
+	},
+	[SMS_VENICE] = {
+		[DEVICE_MODE_CMMB]		= "cmmb_venice_12mhz.inp",
+	},
+	[SMS_MING] = {
+		[DEVICE_MODE_CMMB]		= "cmmb_ming_app.inp",
+	},
+	[SMS_PELE] = {
+		[DEVICE_MODE_ISDBT]		= "isdbt_pele.inp",
+		[DEVICE_MODE_ISDBT_BDA]		= "isdbt_pele.inp",
+	},
+	[SMS_RIO] = {
+		[DEVICE_MODE_DVBT]		= "dvb_rio.inp",
+		[DEVICE_MODE_DVBH]		= "dvbh_rio.inp",
+		[DEVICE_MODE_DVBT_BDA]		= "dvb_rio.inp",
+		[DEVICE_MODE_ISDBT]		= "isdbt_rio.inp",
+		[DEVICE_MODE_ISDBT_BDA]		= "isdbt_rio.inp",
+		[DEVICE_MODE_FM_RADIO]		= "fm_radio_rio.inp",
+		[DEVICE_MODE_FM_RADIO_BDA]	= "fm_radio_rio.inp",
+	},
+	[SMS_DENVER_1530] = {
+		[DEVICE_MODE_ATSC]		= "atsc_denver.inp",
+	},
+	[SMS_DENVER_2160] = {
+		[DEVICE_MODE_DAB_TDMB]		= "tdmb_denver.inp",
+	},
+};
 
+/**
+ * get firmware file name from one of the two mechanisms : sms_boards or
+ * smscore_fw_lkup.
+ * @param coredev pointer to a coredev object returned by
+ *		  smscore_register_device
+ * @param mode requested mode of operation
+ * @param lookup if 1, always get the fw filename from smscore_fw_lkup
+ *	 table. if 0, try first to get from sms_boards
+ *
+ * @return 0 on success, <0 on error.
+ */
 static char *smscore_get_fw_filename(struct smscore_device_t *coredev,
-				     int mode);
+			      int mode)
+{
+	char **fw;
+	int board_id = smscore_get_board_id(coredev);
+	enum sms_device_type_st type;
+
+	type = smscore_registry_gettype(coredev->devpath);
+
+	/* Prevent looking outside the smscore_fw_lkup table */
+	if (type <= SMS_UNKNOWN_TYPE || type >= SMS_NUM_OF_DEVICE_TYPES)
+		return NULL;
+	if (mode <= DEVICE_MODE_NONE || mode >= DEVICE_MODE_MAX)
+		return NULL;
+
+	sms_debug("trying to get fw name from sms_boards board_id %d mode %d",
+		  board_id, mode);
+	fw = sms_get_board(board_id)->fw;
+	if (!fw || !fw[mode]) {
+		sms_debug("cannot find fw name in sms_boards, getting from lookup table mode %d type %d",
+			  mode, type);
+		return smscore_fw_lkup[type][mode];
+	}
+
+	return fw[mode];
+}
 
 /**
  * loads specified firmware into a buffer and calls device loadfirmware_handler
@@ -1208,93 +1291,6 @@ static int smscore_detect_mode(struct smscore_device_t *coredev)
 	return rc;
 }
 
-static char *smscore_fw_lkup[][DEVICE_MODE_MAX] = {
-	[SMS_NOVA_A0] = {
-		[DEVICE_MODE_DVBT]		= "dvb_nova_12mhz.inp",
-		[DEVICE_MODE_DVBH]		= "dvb_nova_12mhz.inp",
-		[DEVICE_MODE_DAB_TDMB]		= "tdmb_nova_12mhz.inp",
-		[DEVICE_MODE_DVBT_BDA]		= "dvb_nova_12mhz.inp",
-		[DEVICE_MODE_ISDBT]		= "isdbt_nova_12mhz.inp",
-		[DEVICE_MODE_ISDBT_BDA]		= "isdbt_nova_12mhz.inp",
-	},
-	[SMS_NOVA_B0] = {
-		[DEVICE_MODE_DVBT]		= "dvb_nova_12mhz_b0.inp",
-		[DEVICE_MODE_DVBH]		= "dvb_nova_12mhz_b0.inp",
-		[DEVICE_MODE_DAB_TDMB]		= "tdmb_nova_12mhz_b0.inp",
-		[DEVICE_MODE_DVBT_BDA]		= "dvb_nova_12mhz_b0.inp",
-		[DEVICE_MODE_ISDBT]		= "isdbt_nova_12mhz_b0.inp",
-		[DEVICE_MODE_ISDBT_BDA]		= "isdbt_nova_12mhz_b0.inp",
-		[DEVICE_MODE_FM_RADIO]		= "fm_radio.inp",
-		[DEVICE_MODE_FM_RADIO_BDA]	= "fm_radio.inp",
-	},
-	[SMS_VEGA] = {
-		[DEVICE_MODE_CMMB]		= "cmmb_vega_12mhz.inp",
-	},
-	[SMS_VENICE] = {
-		[DEVICE_MODE_CMMB]		= "cmmb_venice_12mhz.inp",
-	},
-	[SMS_MING] = {
-		[DEVICE_MODE_CMMB]		= "cmmb_ming_app.inp",
-	},
-	[SMS_PELE] = {
-		[DEVICE_MODE_ISDBT]		= "isdbt_pele.inp",
-		[DEVICE_MODE_ISDBT_BDA]		= "isdbt_pele.inp",
-	},
-	[SMS_RIO] = {
-		[DEVICE_MODE_DVBT]		= "dvb_rio.inp",
-		[DEVICE_MODE_DVBH]		= "dvbh_rio.inp",
-		[DEVICE_MODE_DVBT_BDA]		= "dvb_rio.inp",
-		[DEVICE_MODE_ISDBT]		= "isdbt_rio.inp",
-		[DEVICE_MODE_ISDBT_BDA]		= "isdbt_rio.inp",
-		[DEVICE_MODE_FM_RADIO]		= "fm_radio_rio.inp",
-		[DEVICE_MODE_FM_RADIO_BDA]	= "fm_radio_rio.inp",
-	},
-	[SMS_DENVER_1530] = {
-		[DEVICE_MODE_ATSC]		= "atsc_denver.inp",
-	},
-	[SMS_DENVER_2160] = {
-		[DEVICE_MODE_DAB_TDMB]		= "tdmb_denver.inp",
-	},
-};
-
-/**
- * get firmware file name from one of the two mechanisms : sms_boards or
- * smscore_fw_lkup.
- * @param coredev pointer to a coredev object returned by
- *		  smscore_register_device
- * @param mode requested mode of operation
- * @param lookup if 1, always get the fw filename from smscore_fw_lkup
- *	 table. if 0, try first to get from sms_boards
- *
- * @return 0 on success, <0 on error.
- */
-static char *smscore_get_fw_filename(struct smscore_device_t *coredev,
-			      int mode)
-{
-	char **fw;
-	int board_id = smscore_get_board_id(coredev);
-	enum sms_device_type_st type;
-
-	type = smscore_registry_gettype(coredev->devpath);
-
-	/* Prevent looking outside the smscore_fw_lkup table */
-	if (type <= SMS_UNKNOWN_TYPE || type >= SMS_NUM_OF_DEVICE_TYPES)
-		return NULL;
-	if (mode <= DEVICE_MODE_NONE || mode >= DEVICE_MODE_MAX)
-		return NULL;
-
-	sms_debug("trying to get fw name from sms_boards board_id %d mode %d",
-		  board_id, mode);
-	fw = sms_get_board(board_id)->fw;
-	if (!fw || !fw[mode]) {
-		sms_debug("cannot find fw name in sms_boards, getting from lookup table mode %d type %d",
-			  mode, type);
-		return smscore_fw_lkup[type][mode];
-	}
-
-	return fw[mode];
-}
-
 /**
  * send init device request and wait for response
  *
Signature · 1 line
1.8.1.4
#43 lore raw

PATCH 43/46 siano: add a MAINTAINERS entry for it

In reply to Mauro Carvalho Chehab

Nobody is maintaining this driver. The project started by a developer that used to work at Hauppauge. A Siano developer assumed its maintainership after that, but he left the company. Another Siano developer sent several patches updating it, but, after upstream feedback, it seems he gave up merging the driver, as he never answered back to the received feedbacks.

As I have a few siano devices here that work with ISDB-T, I can help to keep it into a good shape. So, better to take its maintainership.

I don't have any siano SDIO setup here, trough. So, I'll just apply without any test any patch that looks sane and touches only drivers/media/mmc/siano. So, let's tag it as "Odd fixes".

---
 MAINTAINERS | 11 +++++++++++
 1 file changed, 11 insertions(+)
MAINTAINERS +11 -0
index 90e1797..8d8e762 100644
@@ -7038,6 +7038,17 @@ F:	drivers/media/radio/si470x/radio-si470x-common.c
 F:	drivers/media/radio/si470x/radio-si470x.h
 F:	drivers/media/radio/si470x/radio-si470x-usb.c
 
+SIANO DVB DRIVER
+M:	Mauro Carvalho Chehab <[email protected]>
+L:	[email protected]
+W:	http://linuxtv.org
+T:	git git://linuxtv.org/media_tree.git
+S:	Odd fixes
+F:	drivers/media/common/siano/
+F:	drivers/media/dvb/siano/
+F:	drivers/media/usb/siano/
+F:	drivers/media/mmc/siano
+
 SH_VEU V4L2 MEM2MEM DRIVER
 M:	Guennadi Liakhovetski <[email protected]>
 L:	[email protected]
Signature · 1 line
1.8.1.4
#44 lore raw

PATCH 44/46 siano: remove a bogus printk line

In reply to Mauro Carvalho Chehab

The logic that detects the types of sms devices is bogus. It returns

	[ 4645.187790] smsusb_init_device: line: 372: Unspecified sms device type!

For several devices, including the one I have (SMS_RIO). In a matter of fact, the right thing to do there is to print an error only if the device is really unknown (SMS_UNKNOWN_TYPE).

---
 drivers/media/usb/siano/smsusb.c | 8 ++------
 1 file changed, 2 insertions(+), 6 deletions(-)
drivers/media/usb/siano/smsusb.c +2 -6
index def5e41..01a0f39 100644
@@ -368,14 +368,10 @@ static int smsusb_init_device(struct usb_interface *intf, int board_id)
 		params.setmode_handler = smsusb1_setmode;
 		params.detectmode_handler = smsusb1_detectmode;
 		break;
-	default:
+	case SMS_UNKNOWN_TYPE:
 		sms_err("Unspecified sms device type!");
 		/* fall-thru */
-	case SMS_NOVA_A0:
-	case SMS_NOVA_B0:
-	case SMS_VEGA:
-	case SMS_VENICE:
-	case SMS_DENVER_1530:
+	default:
 		dev->buffer_size = USB2_BUFFER_SIZE;
 		dev->response_alignment =
 		    le16_to_cpu(dev->udev->ep_in[1]->desc.wMaxPacketSize) -
Signature · 1 line
1.8.1.4
#45 lore raw

PATCH 45/46 siano: remove doubled new line

In reply to Mauro Carvalho Chehab

sms_debug() and sms_info() already adds a '\n' at the printed strings. No need to add more.

That helps to cleanup stuff like:

	[ 4868.205648] smscore_onresponse: message not handled.
	[ 4868.205898] smscore_onresponse: message not handled.

and:

	[ 5467.959769] smscore_onresponse:
	data rate 143069 bytes/secs

While here, provides the message name, when the message is not handled by the smsmdtv core.

---
 drivers/media/common/siano/smscoreapi.c  | 6 ++++--
 drivers/media/common/siano/smsdvb-main.c | 2 +-
 2 files changed, 5 insertions(+), 3 deletions(-)
drivers/media/common/siano/smscoreapi.c +4 -2
index 5bfeeee..244928b 100644
@@ -1496,7 +1496,7 @@ void smscore_onresponse(struct smscore_device_t *coredev,
 		last_sample_time = time_now;
 
 	if (time_now - last_sample_time > 10000) {
-		sms_debug("\ndata rate %d bytes/secs",
+		sms_debug("data rate %d bytes/secs",
 			  (int)((data_total * 1000) /
 				(time_now - last_sample_time)));
 
@@ -1607,7 +1607,9 @@ void smscore_onresponse(struct smscore_device_t *coredev,
 			break;
 
 		default:
-			sms_debug("message not handled.\n");
+			sms_debug("message %s(%d) not handled.",
+				  smscore_translate_msg(phdr->msgType),
+				  phdr->msgType);
 			break;
 		}
 		smscore_putbuffer(coredev, cb);
drivers/media/common/siano/smsdvb-main.c +1 -1
index ce6ba7b..7f84b5c 100644
@@ -948,7 +948,7 @@ static int smsdvb_isdbt_set_frontend(struct dvb_frontend *fe)
 
 	c->bandwidth_hz = 6000000;
 
-	sms_info("%s: freq %d segwidth %d segindex %d\n", __func__,
+	sms_info("%s: freq %d segwidth %d segindex %d", __func__,
 		 c->frequency, c->isdbt_sb_segment_count,
 		 c->isdbt_sb_segment_idx);
 
Signature · 1 line
1.8.1.4
#46 lore raw

PATCH 46/46 siano: Remove bogus complain about MSG_SMS_DVBT_BDA_DATA

In reply to Mauro Carvalho Chehab

When the driver is tuned into chanel, and it is removed/reinserted, the message stream data may be arriving during device probe:

	[ 5680.162004] smscore_set_device_mode: set device mode to 6
	[ 5680.162267] smscore_onresponse: message MSG_SMS_DVBT_BDA_DATA(693) not handled.
	[ 5680.162391] smscore_onresponse: message MSG_SMS_DVBT_BDA_DATA(693) not handled.
	[ 5680.162641] smscore_onresponse: message MSG_SMS_DVBT_BDA_DATA(693) not handled.
	[ 5680.162891] smscore_onresponse: message MSG_SMS_DVBT_BDA_DATA(693) not handled.
	[ 5680.163016] smscore_onresponse: message MSG_SMS_DVBT_BDA_DATA(693) not handled.
	[ 5680.163266] smscore_onresponse: message MSG_SMS_DVBT_BDA_DATA(693) not handled.
	[ 5680.163516] smscore_onresponse: message MSG_SMS_DVBT_BDA_DATA(693) not handled.
	[ 5680.163640] smscore_onresponse: message MSG_SMS_DVBT_BDA_DATA(693) not handled.
	[ 5680.163891] smscore_onresponse: message MSG_SMS_DVBT_BDA_DATA(693) not handled.
	[ 5680.164016] smscore_onresponse: message MSG_SMS_DVBT_BDA_DATA(693) not handled.
	[ 5680.164265] smscore_onresponse: message MSG_SMS_DVBT_BDA_DATA(693) not handled.
	[ 5680.164515] smscore_onresponse: message MSG_SMS_DVBT_BDA_DATA(693) not handled.
	[ 5680.164519] smscore_onresponse: Firmware id 6 prots 0x40 ver 8.1
	[ 5680.164766] smscore_onresponse: message MSG_SMS_DVBT_BDA_DATA(693) not handled.
	[ 5680.166018] smscore_onresponse: message MSG_SMS_DVBT_BDA_DATA(693) not handled.
	[ 5680.166438] DVB: registering new adapter (Siano Rio Digital Receiver)

Instead of complaining, just silently discard those messages, instead of complaining.

A proper fix is to put the device on suspend/power down mode when the module is removed.

---
 drivers/media/common/siano/smscoreapi.c | 9 +++++++++
 1 file changed, 9 insertions(+)
drivers/media/common/siano/smscoreapi.c +9 -0
index 244928b..c260974 100644
@@ -1606,6 +1606,15 @@ void smscore_onresponse(struct smscore_device_t *coredev,
 				- sizeof(struct SmsMsgHdr_ST));
 			break;
 
+		case MSG_SMS_DVBT_BDA_DATA:
+			/*
+			 * It can be received here, if the frontend is
+			 * tuned into a valid channel and the proper firmware
+			 * is loaded. That happens when the module got removed
+			 * and re-inserted, without powering the device off
+			 */
+			break;
+
 		default:
 			sms_debug("message %s(%d) not handled.",
 				  smscore_translate_msg(phdr->msgType),
Signature · 1 line
1.8.1.4