Commit 82237416 authored by Michael Krufky's avatar Michael Krufky Committed by Mauro Carvalho Chehab

V4L/DVB (8280): sms1xxx: more codingstyle cleanups

Signed-off-by: default avatarMichael Krufky <mkrufky@linuxtv.org>
Signed-off-by: default avatarMauro Carvalho Chehab <mchehab@infradead.org>
parent 73104fb3
...@@ -33,23 +33,23 @@ ...@@ -33,23 +33,23 @@
#include "smscoreapi.h" #include "smscoreapi.h"
#define PERROR(fmt, args...) printk( KERN_ERR "smscore error: line %d- %s(): " fmt,__LINE__, __func__, ## args) #define PERROR(fmt, args...)\
printk(KERN_ERR "smscore error: line %d- %s(): " fmt, \
__LINE__, __func__, ## args)
#ifdef SMSCORE_DEBUG #ifdef SMSCORE_DEBUG
#undef PWARNING #undef PWARNING
# define PWARNING(fmt, args...) printk( KERN_INFO "smscore warning: line %d- %s(): " fmt,__LINE__, __func__, ## args) # define PWARNING(fmt, args...) printk(KERN_INFO "smscore warning: " \
"line %d- %s(): " fmt, \
__LINE__, __func__, ## args)
#undef PDEBUG /* undef it, just in case */ #undef PDEBUG /* undef it, just in case */
# define PDEBUG(fmt, args...) printk( KERN_INFO "smscore - %s(): " fmt, __func__, ## args) # define PDEBUG(fmt, args...) printk(KERN_INFO "smscore - %s(): " fmt, \
__func__, ## args)
#else /*SMSCORE_DEBUG*/ #else /*SMSCORE_DEBUG*/
#define PDEBUG(fmt, args...) #define PDEBUG(fmt, args...)
#define PWARNING(fmt, args...) #define PWARNING(fmt, args...)
#endif #endif
typedef struct _smscore_device_notifyee typedef struct _smscore_device_notifyee
{ {
struct list_head entry; struct list_head entry;
...@@ -129,94 +129,80 @@ static int default_mode = 1; ...@@ -129,94 +129,80 @@ static int default_mode = 1;
module_param(default_mode, int, 0644); module_param(default_mode, int, 0644);
MODULE_PARM_DESC(default_mode, "default firmware id (device mode)"); MODULE_PARM_DESC(default_mode, "default firmware id (device mode)");
static smscore_registry_entry_t *smscore_find_registry ( char *devpath ) static smscore_registry_entry_t *smscore_find_registry(char *devpath)
{ {
smscore_registry_entry_t *entry; smscore_registry_entry_t *entry;
struct list_head *next; struct list_head *next;
kmutex_lock(&g_smscore_registrylock); kmutex_lock(&g_smscore_registrylock);
for (next = g_smscore_registry.next; next != &g_smscore_registry; next = next->next) for (next = g_smscore_registry.next;
{ next != &g_smscore_registry;
next = next->next) {
entry = (smscore_registry_entry_t *) next; entry = (smscore_registry_entry_t *) next;
if (!strcmp(entry->devpath, devpath)) if (!strcmp(entry->devpath, devpath)) {
{
kmutex_unlock(&g_smscore_registrylock); kmutex_unlock(&g_smscore_registrylock);
return entry; return entry;
} }
} }
entry = (smscore_registry_entry_t *) kmalloc(sizeof(smscore_registry_entry_t), GFP_KERNEL); entry = (smscore_registry_entry_t *)
if (entry) kmalloc(sizeof(smscore_registry_entry_t), GFP_KERNEL);
{ if (entry) {
entry->mode = default_mode; entry->mode = default_mode;
strcpy(entry->devpath, devpath); strcpy(entry->devpath, devpath);
list_add(&entry->entry, &g_smscore_registry); list_add(&entry->entry, &g_smscore_registry);
} } else
else printk(KERN_ERR "%s failed to create smscore_registry.\n",
printk ( KERN_ERR "%s failed to create smscore_registry.\n", __func__ ); __func__);
kmutex_unlock(&g_smscore_registrylock); kmutex_unlock(&g_smscore_registrylock);
return entry; return entry;
} }
int smscore_registry_getmode ( char *devpath ) int smscore_registry_getmode(char *devpath)
{ {
smscore_registry_entry_t *entry; smscore_registry_entry_t *entry;
entry = smscore_find_registry ( devpath ); entry = smscore_find_registry(devpath);
if ( entry ) if (entry)
{
return entry->mode; return entry->mode;
}
else else
{ printk(KERN_ERR "%s No registry found.\n", __func__);
printk ( KERN_ERR "%s No registry found.\n", __func__ );
}
return default_mode; return default_mode;
} }
sms_device_type_st smscore_registry_gettype ( char *devpath ) sms_device_type_st smscore_registry_gettype(char *devpath)
{ {
smscore_registry_entry_t *entry; smscore_registry_entry_t *entry;
entry = smscore_find_registry ( devpath ); entry = smscore_find_registry(devpath);
if ( entry ) if (entry)
{
return entry->type; return entry->type;
}
else else
{ printk(KERN_ERR "%s No registry found.\n", __func__);
printk ( KERN_ERR "%s No registry found.\n", __func__ );
}
return -1; return -1;
} }
void smscore_registry_setmode ( char *devpath, int mode ) void smscore_registry_setmode(char *devpath, int mode)
{ {
smscore_registry_entry_t *entry; smscore_registry_entry_t *entry;
entry = smscore_find_registry ( devpath ); entry = smscore_find_registry(devpath);
if ( entry ) if (entry)
{
entry->mode = mode; entry->mode = mode;
}
else else
{ printk(KERN_ERR "%s No registry found.\n", __func__);
printk ( KERN_ERR "%s No registry found.\n", __func__ ); }
}
}
void smscore_registry_settype ( char *devpath, sms_device_type_st type ) void smscore_registry_settype(char *devpath, sms_device_type_st type)
{ {
smscore_registry_entry_t *entry; smscore_registry_entry_t *entry;
entry = smscore_find_registry ( devpath ); entry = smscore_find_registry(devpath);
if ( entry ) if (entry)
{
entry->type = type; entry->type = type;
}
else else
{ printk(KERN_ERR "%s No registry found.\n", __func__);
printk ( KERN_ERR "%s No registry found.\n", __func__ );
}
} }
...@@ -250,25 +236,22 @@ int smscore_register_hotplug(hotplug_t hotplug) ...@@ -250,25 +236,22 @@ int smscore_register_hotplug(hotplug_t hotplug)
kmutex_lock(&g_smscore_deviceslock); kmutex_lock(&g_smscore_deviceslock);
notifyee = kmalloc(sizeof(smscore_device_notifyee_t), GFP_KERNEL); notifyee = kmalloc(sizeof(smscore_device_notifyee_t), GFP_KERNEL);
if (notifyee) if (notifyee) {
{ /* now notify callback about existing devices */
// now notify callback about existing devices
first = &g_smscore_devices; first = &g_smscore_devices;
for (next = first->next; next != first && !rc; next = next->next) for (next = first->next;
{ next != first && !rc;
next = next->next) {
smscore_device_t *coredev = (smscore_device_t *) next; smscore_device_t *coredev = (smscore_device_t *) next;
rc = hotplug(coredev, coredev->device, 1); rc = hotplug(coredev, coredev->device, 1);
} }
if (rc >= 0) if (rc >= 0) {
{
notifyee->hotplug = hotplug; notifyee->hotplug = hotplug;
list_add(&notifyee->entry, &g_smscore_notifyees); list_add(&notifyee->entry, &g_smscore_notifyees);
} } else
else
kfree(notifyee); kfree(notifyee);
} } else
else
rc = -ENOMEM; rc = -ENOMEM;
kmutex_unlock(&g_smscore_deviceslock); kmutex_unlock(&g_smscore_deviceslock);
...@@ -290,13 +273,12 @@ void smscore_unregister_hotplug(hotplug_t hotplug) ...@@ -290,13 +273,12 @@ void smscore_unregister_hotplug(hotplug_t hotplug)
first = &g_smscore_notifyees; first = &g_smscore_notifyees;
for (next = first->next; next != first;) for (next = first->next; next != first;) {
{ smscore_device_notifyee_t *notifyee =
smscore_device_notifyee_t *notifyee = (smscore_device_notifyee_t *) next; (smscore_device_notifyee_t *) next;
next = next->next; next = next->next;
if (notifyee->hotplug == hotplug) if (notifyee->hotplug == hotplug) {
{
list_del(&notifyee->entry); list_del(&notifyee->entry);
kfree(notifyee); kfree(notifyee);
} }
...@@ -309,25 +291,24 @@ void smscore_notify_clients(smscore_device_t *coredev) ...@@ -309,25 +291,24 @@ void smscore_notify_clients(smscore_device_t *coredev)
{ {
smscore_client_t *client; smscore_client_t *client;
// the client must call smscore_unregister_client from remove handler /* the client must call smscore_unregister_client from remove handler */
while (!list_empty(&coredev->clients)) while (!list_empty(&coredev->clients)) {
{
client = (smscore_client_t *) coredev->clients.next; client = (smscore_client_t *) coredev->clients.next;
client->onremove_handler(client->context); client->onremove_handler(client->context);
} }
} }
int smscore_notify_callbacks(smscore_device_t *coredev, struct device *device, int arrival) int smscore_notify_callbacks(smscore_device_t *coredev, struct device *device,
int arrival)
{ {
struct list_head *next, *first; struct list_head *next, *first;
int rc = 0; int rc = 0;
// note: must be called under g_deviceslock /* note: must be called under g_deviceslock */
first = &g_smscore_notifyees; first = &g_smscore_notifyees;
for (next = first->next; next != first; next = next->next) for (next = first->next; next != first; next = next->next) {
{
rc = ((smscore_device_notifyee_t *) next)->hotplug(coredev, device, arrival); rc = ((smscore_device_notifyee_t *) next)->hotplug(coredev, device, arrival);
if (rc < 0) if (rc < 0)
break; break;
...@@ -340,8 +321,7 @@ smscore_buffer_t *smscore_createbuffer(u8 *buffer, void *common_buffer, ...@@ -340,8 +321,7 @@ smscore_buffer_t *smscore_createbuffer(u8 *buffer, void *common_buffer,
dma_addr_t common_buffer_phys) dma_addr_t common_buffer_phys)
{ {
smscore_buffer_t *cb = kmalloc(sizeof(smscore_buffer_t), GFP_KERNEL); smscore_buffer_t *cb = kmalloc(sizeof(smscore_buffer_t), GFP_KERNEL);
if (!cb) if (!cb) {
{
printk(KERN_INFO "%s kmalloc(...) failed\n", __func__); printk(KERN_INFO "%s kmalloc(...) failed\n", __func__);
return NULL; return NULL;
} }
...@@ -354,38 +334,38 @@ smscore_buffer_t *smscore_createbuffer(u8 *buffer, void *common_buffer, ...@@ -354,38 +334,38 @@ smscore_buffer_t *smscore_createbuffer(u8 *buffer, void *common_buffer,
} }
/** /**
* creates coredev object for a device, prepares buffers, creates buffer mappings, notifies * creates coredev object for a device, prepares buffers,
* registered hotplugs about new device. * creates buffer mappings, notifies registered hotplugs about new device.
* *
* @param params device pointer to struct with device specific parameters and handlers * @param params device pointer to struct with device specific parameters and handlers
* @param coredev pointer to a value that receives created coredev object * @param coredev pointer to a value that receives created coredev object
* *
* @return 0 on success, <0 on error. * @return 0 on success, <0 on error.
*/ */
int smscore_register_device(smsdevice_params_t *params, smscore_device_t **coredev) int smscore_register_device(smsdevice_params_t *params,
smscore_device_t **coredev)
{ {
smscore_device_t *dev; smscore_device_t *dev;
u8 *buffer; u8 *buffer;
dev = kzalloc(sizeof(smscore_device_t), GFP_KERNEL); dev = kzalloc(sizeof(smscore_device_t), GFP_KERNEL);
if (!dev) if (!dev) {
{
printk(KERN_INFO "%s kzalloc(...) failed\n", __func__); printk(KERN_INFO "%s kzalloc(...) failed\n", __func__);
return -ENOMEM; return -ENOMEM;
} }
// init list entry so it could be safe in smscore_unregister_device /* init list entry so it could be safe in smscore_unregister_device */
INIT_LIST_HEAD(&dev->entry); INIT_LIST_HEAD(&dev->entry);
// init queues /* init queues */
INIT_LIST_HEAD(&dev->clients); INIT_LIST_HEAD(&dev->clients);
INIT_LIST_HEAD(&dev->buffers); INIT_LIST_HEAD(&dev->buffers);
// init locks /* init locks */
spin_lock_init(&dev->clientslock); spin_lock_init(&dev->clientslock);
spin_lock_init(&dev->bufferslock); spin_lock_init(&dev->bufferslock);
// init completion events /* init completion events */
init_completion(&dev->version_ex_done); init_completion(&dev->version_ex_done);
init_completion(&dev->data_download_done); init_completion(&dev->data_download_done);
init_completion(&dev->trigger_done); init_completion(&dev->trigger_done);
...@@ -393,21 +373,22 @@ int smscore_register_device(smsdevice_params_t *params, smscore_device_t **cored ...@@ -393,21 +373,22 @@ int smscore_register_device(smsdevice_params_t *params, smscore_device_t **cored
init_completion(&dev->reload_start_done); init_completion(&dev->reload_start_done);
init_completion(&dev->resume_done); init_completion(&dev->resume_done);
// alloc common buffer /* alloc common buffer */
dev->common_buffer_size = params->buffer_size * params->num_buffers; dev->common_buffer_size = params->buffer_size * params->num_buffers;
dev->common_buffer = dma_alloc_coherent(NULL, dev->common_buffer_size, &dev->common_buffer_phys, GFP_KERNEL | GFP_DMA); dev->common_buffer = dma_alloc_coherent(NULL, dev->common_buffer_size,
if (!dev->common_buffer) &dev->common_buffer_phys,
{ GFP_KERNEL | GFP_DMA);
if (!dev->common_buffer) {
smscore_unregister_device(dev); smscore_unregister_device(dev);
return -ENOMEM; return -ENOMEM;
} }
// prepare dma buffers /* prepare dma buffers */
for (buffer = dev->common_buffer; dev->num_buffers < params->num_buffers; dev->num_buffers ++, buffer += params->buffer_size) for (buffer = dev->common_buffer;
{ dev->num_buffers < params->num_buffers;
dev->num_buffers ++, buffer += params->buffer_size) {
smscore_buffer_t *cb = smscore_createbuffer(buffer, dev->common_buffer, dev->common_buffer_phys); smscore_buffer_t *cb = smscore_createbuffer(buffer, dev->common_buffer, dev->common_buffer_phys);
if (!cb) if (!cb) {
{
smscore_unregister_device(dev); smscore_unregister_device(dev);
return -ENOMEM; return -ENOMEM;
} }
...@@ -415,7 +396,8 @@ int smscore_register_device(smsdevice_params_t *params, smscore_device_t **cored ...@@ -415,7 +396,8 @@ int smscore_register_device(smsdevice_params_t *params, smscore_device_t **cored
smscore_putbuffer(dev, cb); smscore_putbuffer(dev, cb);
} }
printk(KERN_INFO "%s allocated %d buffers\n", __func__, dev->num_buffers); printk(KERN_INFO "%s allocated %d buffers\n",
__func__, dev->num_buffers);
dev->mode = DEVICE_MODE_NONE; dev->mode = DEVICE_MODE_NONE;
dev->context = params->context; dev->context = params->context;
...@@ -429,9 +411,9 @@ int smscore_register_device(smsdevice_params_t *params, smscore_device_t **cored ...@@ -429,9 +411,9 @@ int smscore_register_device(smsdevice_params_t *params, smscore_device_t **cored
dev->device_flags = params->flags; dev->device_flags = params->flags;
strcpy(dev->devpath, params->devpath); strcpy(dev->devpath, params->devpath);
smscore_registry_settype ( dev->devpath, params->device_type ); smscore_registry_settype(dev->devpath, params->device_type);
// add device to devices list /* add device to devices list */
kmutex_lock(&g_smscore_deviceslock); kmutex_lock(&g_smscore_deviceslock);
list_add(&dev->entry, &g_smscore_devices); list_add(&dev->entry, &g_smscore_devices);
kmutex_unlock(&g_smscore_deviceslock); kmutex_unlock(&g_smscore_deviceslock);
...@@ -453,9 +435,8 @@ int smscore_register_device(smsdevice_params_t *params, smscore_device_t **cored ...@@ -453,9 +435,8 @@ int smscore_register_device(smsdevice_params_t *params, smscore_device_t **cored
int smscore_start_device(smscore_device_t *coredev) int smscore_start_device(smscore_device_t *coredev)
{ {
int rc = smscore_set_device_mode(coredev, smscore_registry_getmode(coredev->devpath)); int rc = smscore_set_device_mode(coredev, smscore_registry_getmode(coredev->devpath));
if (rc < 0) if (rc < 0) {
{ printk(KERN_INFO "%s set device mode faile , rc %d\n", __func__, rc);
printk ( KERN_INFO "%s set device mode faile , rc %d\n", __func__, rc );
return rc; return rc;
} }
...@@ -463,7 +444,8 @@ int smscore_start_device(smscore_device_t *coredev) ...@@ -463,7 +444,8 @@ int smscore_start_device(smscore_device_t *coredev)
rc = smscore_notify_callbacks(coredev, coredev->device, 1); rc = smscore_notify_callbacks(coredev, coredev->device, 1);
printk(KERN_INFO "%s device %p started, rc %d\n", __func__, coredev, rc); printk(KERN_INFO "%s device %p started, rc %d\n",
__func__, coredev, rc);
kmutex_unlock(&g_smscore_deviceslock); kmutex_unlock(&g_smscore_deviceslock);
...@@ -474,41 +456,46 @@ int smscore_sendrequest_and_wait(smscore_device_t *coredev, void *buffer, ...@@ -474,41 +456,46 @@ int smscore_sendrequest_and_wait(smscore_device_t *coredev, void *buffer,
size_t size, struct completion *completion) size_t size, struct completion *completion)
{ {
int rc = coredev->sendrequest_handler(coredev->context, buffer, size); int rc = coredev->sendrequest_handler(coredev->context, buffer, size);
if (rc < 0) if (rc < 0) {
{ printk(KERN_INFO "%s sendrequest returned error %d\n",
printk(KERN_INFO "%s sendrequest returned error %d\n", __func__, rc); __func__, rc);
return rc; return rc;
} }
return wait_for_completion_timeout(completion, msecs_to_jiffies(10000)) ? 0 : -ETIME; return wait_for_completion_timeout(completion,
msecs_to_jiffies(10000)) ?
0 : -ETIME;
} }
int smscore_load_firmware_family2(smscore_device_t *coredev, void *buffer, size_t size) int smscore_load_firmware_family2(smscore_device_t *coredev, void *buffer,
size_t size)
{ {
SmsFirmware_ST* firmware = (SmsFirmware_ST*) buffer; SmsFirmware_ST *firmware = (SmsFirmware_ST *) buffer;
SmsMsgHdr_ST *msg; SmsMsgHdr_ST *msg;
UINT32 mem_address = firmware->StartAddress; UINT32 mem_address = firmware->StartAddress;
u8 *payload = firmware->Payload; u8 *payload = firmware->Payload;
int rc = 0; int rc = 0;
printk(KERN_INFO "%s loading FW to addr 0x%x size %d\n", __func__, mem_address,firmware->Length); printk(KERN_INFO "%s loading FW to addr 0x%x size %d\n",
if (coredev->preload_handler) __func__, mem_address, firmware->Length);
{ if (coredev->preload_handler) {
rc = coredev->preload_handler(coredev->context); rc = coredev->preload_handler(coredev->context);
if (rc < 0) if (rc < 0)
return rc; return rc;
} }
// PAGE_SIZE buffer shall be enough and dma aligned /* PAGE_SIZE buffer shall be enough and dma aligned */
msg = (SmsMsgHdr_ST *) kmalloc(PAGE_SIZE, GFP_KERNEL | GFP_DMA); msg = (SmsMsgHdr_ST *) kmalloc(PAGE_SIZE, GFP_KERNEL | GFP_DMA);
if (!msg) if (!msg)
return -ENOMEM; return -ENOMEM;
if (coredev->mode != DEVICE_MODE_NONE) if (coredev->mode != DEVICE_MODE_NONE) {
{
PDEBUG("Sending reload command\n"); PDEBUG("Sending reload command\n");
SMS_INIT_MSG(msg, MSG_SW_RELOAD_START_REQ, sizeof(SmsMsgHdr_ST)); SMS_INIT_MSG(msg, MSG_SW_RELOAD_START_REQ,
rc = smscore_sendrequest_and_wait(coredev, msg, msg->msgLength, &coredev->reload_start_done); sizeof(SmsMsgHdr_ST));
rc = smscore_sendrequest_and_wait(coredev, msg,
msg->msgLength,
&coredev->reload_start_done);
mem_address = *(UINT32*) &payload[20]; mem_address = *(UINT32*) &payload[20];
} }
...@@ -517,12 +504,15 @@ int smscore_load_firmware_family2(smscore_device_t *coredev, void *buffer, size_ ...@@ -517,12 +504,15 @@ int smscore_load_firmware_family2(smscore_device_t *coredev, void *buffer, size_
SmsDataDownload_ST *DataMsg = (SmsDataDownload_ST *) msg; SmsDataDownload_ST *DataMsg = (SmsDataDownload_ST *) msg;
int payload_size = min((int) size, SMS_MAX_PAYLOAD_SIZE); int payload_size = min((int) size, SMS_MAX_PAYLOAD_SIZE);
SMS_INIT_MSG(msg, MSG_SMS_DATA_DOWNLOAD_REQ, (UINT16)(sizeof(SmsMsgHdr_ST) + sizeof(UINT32) + payload_size)); SMS_INIT_MSG(msg, MSG_SMS_DATA_DOWNLOAD_REQ,
(UINT16)(sizeof(SmsMsgHdr_ST) +
sizeof(UINT32) + payload_size));
DataMsg->MemAddr = mem_address; DataMsg->MemAddr = mem_address;
memcpy(DataMsg->Payload, payload, payload_size); memcpy(DataMsg->Payload, payload, payload_size);
if (coredev->device_flags & SMS_ROM_NO_RESPONSE && coredev->mode == DEVICE_MODE_NONE) if ((coredev->device_flags & SMS_ROM_NO_RESPONSE) &&
(coredev->mode == DEVICE_MODE_NONE))
rc = coredev->sendrequest_handler(coredev->context, DataMsg, DataMsg->xMsgHeader.msgLength); rc = coredev->sendrequest_handler(coredev->context, DataMsg, DataMsg->xMsgHeader.msgLength);
else else
rc = smscore_sendrequest_and_wait(coredev, DataMsg, DataMsg->xMsgHeader.msgLength, &coredev->data_download_done); rc = smscore_sendrequest_and_wait(coredev, DataMsg, DataMsg->xMsgHeader.msgLength, &coredev->data_download_done);
...@@ -532,13 +522,13 @@ int smscore_load_firmware_family2(smscore_device_t *coredev, void *buffer, size_ ...@@ -532,13 +522,13 @@ int smscore_load_firmware_family2(smscore_device_t *coredev, void *buffer, size_
mem_address += payload_size; mem_address += payload_size;
} }
if (rc >= 0) if (rc >= 0) {
{ if (coredev->mode == DEVICE_MODE_NONE) {
if (coredev->mode == DEVICE_MODE_NONE) SmsMsgData_ST *TriggerMsg = (SmsMsgData_ST *) msg;
{
SmsMsgData_ST* TriggerMsg = (SmsMsgData_ST*) msg;
SMS_INIT_MSG(msg, MSG_SMS_SWDOWNLOAD_TRIGGER_REQ, sizeof(SmsMsgHdr_ST) + sizeof(UINT32) * 5); SMS_INIT_MSG(msg, MSG_SMS_SWDOWNLOAD_TRIGGER_REQ,
sizeof(SmsMsgHdr_ST) +
sizeof(UINT32) * 5);
TriggerMsg->msgData[0] = firmware->StartAddress; // Entry point TriggerMsg->msgData[0] = firmware->StartAddress; // Entry point
TriggerMsg->msgData[1] = 5; // Priority TriggerMsg->msgData[1] = 5; // Priority
...@@ -546,24 +536,23 @@ int smscore_load_firmware_family2(smscore_device_t *coredev, void *buffer, size_ ...@@ -546,24 +536,23 @@ int smscore_load_firmware_family2(smscore_device_t *coredev, void *buffer, size_
TriggerMsg->msgData[3] = 0; // Parameter TriggerMsg->msgData[3] = 0; // Parameter
TriggerMsg->msgData[4] = 4; // Task ID TriggerMsg->msgData[4] = 4; // Task ID
if (coredev->device_flags & SMS_ROM_NO_RESPONSE) if (coredev->device_flags & SMS_ROM_NO_RESPONSE) {
{
rc = coredev->sendrequest_handler(coredev->context, TriggerMsg, TriggerMsg->xMsgHeader.msgLength); rc = coredev->sendrequest_handler(coredev->context, TriggerMsg, TriggerMsg->xMsgHeader.msgLength);
msleep(100); msleep(100);
} } else
else
rc = smscore_sendrequest_and_wait(coredev, TriggerMsg, TriggerMsg->xMsgHeader.msgLength, &coredev->trigger_done); rc = smscore_sendrequest_and_wait(coredev, TriggerMsg, TriggerMsg->xMsgHeader.msgLength, &coredev->trigger_done);
} } else {
else SMS_INIT_MSG(msg, MSG_SW_RELOAD_EXEC_REQ,
{ sizeof(SmsMsgHdr_ST));
SMS_INIT_MSG(msg, MSG_SW_RELOAD_EXEC_REQ, sizeof(SmsMsgHdr_ST));
rc = coredev->sendrequest_handler(coredev->context, msg, msg->msgLength); rc = coredev->sendrequest_handler(coredev->context,
msg, msg->msgLength);
} }
msleep ( 500 ); msleep(500);
} }
printk("%s rc=%d, postload=%p \n", __func__, rc, coredev->postload_handler); printk("%s rc=%d, postload=%p \n", __func__, rc,
coredev->postload_handler);
kfree(msg); kfree(msg);
...@@ -581,26 +570,29 @@ int smscore_load_firmware_family2(smscore_device_t *coredev, void *buffer, size_ ...@@ -581,26 +570,29 @@ int smscore_load_firmware_family2(smscore_device_t *coredev, void *buffer, size_
* *
* @return 0 on success, <0 on error. * @return 0 on success, <0 on error.
*/ */
int smscore_load_firmware_from_file(smscore_device_t *coredev, char *filename, loadfirmware_t loadfirmware_handler) int smscore_load_firmware_from_file(smscore_device_t *coredev, char *filename,
loadfirmware_t loadfirmware_handler)
{ {
int rc = -ENOENT; int rc = -ENOENT;
const struct firmware *fw; const struct firmware *fw;
u8 *fw_buffer; u8 *fw_buffer;
if (loadfirmware_handler == NULL && !(coredev->device_flags & SMS_DEVICE_FAMILY2)) if (loadfirmware_handler == NULL && !(coredev->device_flags &
SMS_DEVICE_FAMILY2))
return -EINVAL; return -EINVAL;
rc = request_firmware(&fw, filename, coredev->device); rc = request_firmware(&fw, filename, coredev->device);
if (rc < 0) if (rc < 0) {
{ printk(KERN_INFO "%s failed to open \"%s\"\n",
printk(KERN_INFO "%s failed to open \"%s\"\n", __func__, filename); __func__, filename);
return rc; return rc;
} }
printk(KERN_INFO "%s read FW %s, size=%d\"\n", __func__, filename, fw->size); printk(KERN_INFO "%s read FW %s, size=%d\"\n", __func__,
fw_buffer = kmalloc(ALIGN(fw->size, SMS_ALLOC_ALIGNMENT), GFP_KERNEL | GFP_DMA); filename, fw->size);
if (fw_buffer) fw_buffer = kmalloc(ALIGN(fw->size, SMS_ALLOC_ALIGNMENT),
{ GFP_KERNEL | GFP_DMA);
if (fw_buffer) {
memcpy(fw_buffer, fw->data, fw->size); memcpy(fw_buffer, fw->data, fw->size);
rc = (coredev->device_flags & SMS_DEVICE_FAMILY2) ? rc = (coredev->device_flags & SMS_DEVICE_FAMILY2) ?
...@@ -608,10 +600,9 @@ int smscore_load_firmware_from_file(smscore_device_t *coredev, char *filename, l ...@@ -608,10 +600,9 @@ int smscore_load_firmware_from_file(smscore_device_t *coredev, char *filename, l
loadfirmware_handler(coredev->context, fw_buffer, fw->size); loadfirmware_handler(coredev->context, fw_buffer, fw->size);
kfree(fw_buffer); kfree(fw_buffer);
} } else {
else printk(KERN_INFO "%s failed to allocate firmware buffer\n",
{ __func__);
printk(KERN_INFO "%s failed to allocate firmware buffer\n", __func__);
rc = -ENOMEM; rc = -ENOMEM;
} }
...@@ -620,7 +611,8 @@ int smscore_load_firmware_from_file(smscore_device_t *coredev, char *filename, l ...@@ -620,7 +611,8 @@ int smscore_load_firmware_from_file(smscore_device_t *coredev, char *filename, l
return rc; return rc;
} }
int smscore_load_firmware_from_buffer(smscore_device_t *coredev, u8 *buffer, int size, int new_mode) int smscore_load_firmware_from_buffer(smscore_device_t *coredev, u8 *buffer,
int size, int new_mode)
{ {
PERROR("Feature not implemented yet\n"); PERROR("Feature not implemented yet\n");
return -EFAULT; return -EFAULT;
...@@ -644,32 +636,33 @@ void smscore_unregister_device(smscore_device_t *coredev) ...@@ -644,32 +636,33 @@ void smscore_unregister_device(smscore_device_t *coredev)
smscore_notify_clients(coredev); smscore_notify_clients(coredev);
smscore_notify_callbacks(coredev, NULL, 0); smscore_notify_callbacks(coredev, NULL, 0);
// at this point all buffers should be back /* at this point all buffers should be back
// onresponse must no longer be called * onresponse must no longer be called */
while (1) while (1) {
{ while ((cb = smscore_getbuffer(coredev))) {
while ((cb = smscore_getbuffer(coredev)))
{
kfree(cb); kfree(cb);
num_buffers ++; num_buffers ++;
} }
if (num_buffers == coredev->num_buffers) if (num_buffers == coredev->num_buffers)
break; break;
if (++retry > 10) if (++retry > 10) {
{ printk(KERN_INFO "%s exiting although "
printk(KERN_INFO "%s exiting although not all buffers released.\n", __func__); "not all buffers released.\n", __func__);
break; break;
} }
printk(KERN_INFO "%s waiting for %d buffer(s)\n", __func__, coredev->num_buffers - num_buffers); printk(KERN_INFO "%s waiting for %d buffer(s)\n", __func__,
coredev->num_buffers - num_buffers);
msleep(100); msleep(100);
} }
printk(KERN_INFO "%s freed %d buffers\n", __func__, num_buffers); printk(KERN_INFO "%s freed %d buffers\n", __func__, num_buffers);
if (coredev->common_buffer) if (coredev->common_buffer)
dma_free_coherent(NULL, coredev->common_buffer_size, coredev->common_buffer, coredev->common_buffer_phys); dma_free_coherent(NULL, coredev->common_buffer_size,
coredev->common_buffer,
coredev->common_buffer_phys);
list_del(&coredev->entry); list_del(&coredev->entry);
kfree(coredev); kfree(coredev);
...@@ -681,7 +674,8 @@ void smscore_unregister_device(smscore_device_t *coredev) ...@@ -681,7 +674,8 @@ void smscore_unregister_device(smscore_device_t *coredev)
int smscore_detect_mode(smscore_device_t *coredev) int smscore_detect_mode(smscore_device_t *coredev)
{ {
void *buffer = kmalloc(sizeof(SmsMsgHdr_ST) + SMS_DMA_ALIGNMENT, GFP_KERNEL | GFP_DMA); void *buffer = kmalloc(sizeof(SmsMsgHdr_ST) + SMS_DMA_ALIGNMENT,
GFP_KERNEL | GFP_DMA);
SmsMsgHdr_ST *msg = (SmsMsgHdr_ST *) SMS_ALIGN_ADDRESS(buffer); SmsMsgHdr_ST *msg = (SmsMsgHdr_ST *) SMS_ALIGN_ADDRESS(buffer);
int rc; int rc;
...@@ -690,20 +684,17 @@ int smscore_detect_mode(smscore_device_t *coredev) ...@@ -690,20 +684,17 @@ int smscore_detect_mode(smscore_device_t *coredev)
SMS_INIT_MSG(msg, MSG_SMS_GET_VERSION_EX_REQ, sizeof(SmsMsgHdr_ST)); SMS_INIT_MSG(msg, MSG_SMS_GET_VERSION_EX_REQ, sizeof(SmsMsgHdr_ST));
rc = smscore_sendrequest_and_wait(coredev, msg, msg->msgLength, &coredev->version_ex_done); rc = smscore_sendrequest_and_wait(coredev, msg, msg->msgLength,
if (rc == -ETIME) &coredev->version_ex_done);
{ if (rc == -ETIME) {
printk("%s: MSG_SMS_GET_VERSION_EX_REQ failed first try\n", __func__); printk("%s: MSG_SMS_GET_VERSION_EX_REQ failed first try\n", __func__);
if (wait_for_completion_timeout(&coredev->resume_done, msecs_to_jiffies(5000))) if (wait_for_completion_timeout(&coredev->resume_done,
{ msecs_to_jiffies(5000))) {
rc = smscore_sendrequest_and_wait(coredev, msg, msg->msgLength, &coredev->version_ex_done); rc = smscore_sendrequest_and_wait(coredev, msg, msg->msgLength, &coredev->version_ex_done);
if (rc < 0) if (rc < 0)
{
printk("%s: MSG_SMS_GET_VERSION_EX_REQ failed second try, rc %d\n", __func__, rc); printk("%s: MSG_SMS_GET_VERSION_EX_REQ failed second try, rc %d\n", __func__, rc);
} } else
}
else
rc = -ETIME; rc = -ETIME;
} }
...@@ -712,12 +703,11 @@ int smscore_detect_mode(smscore_device_t *coredev) ...@@ -712,12 +703,11 @@ int smscore_detect_mode(smscore_device_t *coredev)
return rc; return rc;
} }
char *smscore_fw_lkup[][SMS_NUM_OF_DEVICE_TYPES] = char *smscore_fw_lkup[][SMS_NUM_OF_DEVICE_TYPES] = {
{
/*Stellar NOVA A0 Nova B0 VEGA*/ /*Stellar NOVA A0 Nova B0 VEGA*/
/*DVBT*/ {"none", "dvb_nova_12mhz.inp", "dvb_nova_12mhz_b0.inp", "none"}, /*DVBT*/ {"none", "dvb_nova_12mhz.inp", "dvb_nova_12mhz_b0.inp", "none"},
/*DVBH*/ {"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", "none" "none"}, /*TDMB*/ {"none", "tdmb_nova_12mhz.inp", "none", "none"},
/*DABIP*/ {"none", "none", "none", "none"}, /*DABIP*/ {"none", "none", "none", "none"},
/*BDA*/ {"none", "dvb_nova_12mhz.inp", "dvb_nova_12mhz_b0.inp", "none"}, /*BDA*/ {"none", "dvb_nova_12mhz.inp", "dvb_nova_12mhz_b0.inp", "none"},
/*ISDBT*/ {"none", "isdbt_nova_12mhz.inp", "dvb_nova_12mhz.inp", "none"}, /*ISDBT*/ {"none", "isdbt_nova_12mhz.inp", "dvb_nova_12mhz.inp", "none"},
...@@ -741,51 +731,44 @@ int smscore_set_device_mode(smscore_device_t *coredev, int mode) ...@@ -741,51 +731,44 @@ int smscore_set_device_mode(smscore_device_t *coredev, int mode)
int rc = 0; int rc = 0;
sms_device_type_st type; sms_device_type_st type;
PDEBUG("set device mode to %d\n", mode ); PDEBUG("set device mode to %d\n", mode);
if (coredev->device_flags & SMS_DEVICE_FAMILY2) if (coredev->device_flags & SMS_DEVICE_FAMILY2) {
{ if (mode < DEVICE_MODE_DVBT || mode > DEVICE_MODE_RAW_TUNER) {
if (mode < DEVICE_MODE_DVBT || mode > DEVICE_MODE_RAW_TUNER) printk(KERN_INFO "%s invalid mode specified %d\n",
{ __func__, mode);
printk(KERN_INFO "%s invalid mode specified %d\n", __func__, mode);
return -EINVAL; return -EINVAL;
} }
smscore_registry_setmode(coredev->devpath, mode); smscore_registry_setmode(coredev->devpath, mode);
if (!(coredev->device_flags & SMS_DEVICE_NOT_READY)) if (!(coredev->device_flags & SMS_DEVICE_NOT_READY)) {
{
rc = smscore_detect_mode(coredev); rc = smscore_detect_mode(coredev);
if (rc < 0) if (rc < 0) {
{ printk(KERN_INFO "%s mode detect failed %d\n",
printk(KERN_INFO "%s mode detect failed %d\n", __func__, rc); __func__, rc);
return rc; return rc;
} }
} }
if (coredev->mode == mode) if (coredev->mode == mode) {
{ printk(KERN_INFO "%s device mode %d already set\n",
printk(KERN_INFO "%s device mode %d already set\n", __func__, mode); __func__, mode);
return 0; return 0;
} }
if (!(coredev->modes_supported & (1 << mode))) if (!(coredev->modes_supported & (1 << mode))) {
{ type = smscore_registry_gettype(coredev->devpath);
type = smscore_registry_gettype ( coredev->devpath ); rc = smscore_load_firmware_from_file(coredev, smscore_fw_lkup[mode][type], NULL);
rc = smscore_load_firmware_from_file ( coredev, smscore_fw_lkup[mode][type], NULL ); if (rc < 0) {
if (rc < 0)
{
printk(KERN_INFO "%s load firmware failed %d\n", __func__, rc); printk(KERN_INFO "%s load firmware failed %d\n", __func__, rc);
return rc; return rc;
} }
} } else
else
{
printk(KERN_INFO "%s mode %d supported by running firmware\n", __func__, mode); printk(KERN_INFO "%s mode %d supported by running firmware\n", __func__, mode);
}
buffer = kmalloc(sizeof(SmsMsgData_ST) + SMS_DMA_ALIGNMENT, GFP_KERNEL | GFP_DMA); buffer = kmalloc(sizeof(SmsMsgData_ST) + SMS_DMA_ALIGNMENT,
if (buffer) GFP_KERNEL | GFP_DMA);
{ if (buffer) {
SmsMsgData_ST *msg = (SmsMsgData_ST *) SMS_ALIGN_ADDRESS(buffer); SmsMsgData_ST *msg = (SmsMsgData_ST *) SMS_ALIGN_ADDRESS(buffer);
SMS_INIT_MSG(&msg->xMsgHeader, MSG_SMS_INIT_DEVICE_REQ, sizeof(SmsMsgData_ST)); SMS_INIT_MSG(&msg->xMsgHeader, MSG_SMS_INIT_DEVICE_REQ, sizeof(SmsMsgData_ST));
...@@ -794,32 +777,28 @@ int smscore_set_device_mode(smscore_device_t *coredev, int mode) ...@@ -794,32 +777,28 @@ int smscore_set_device_mode(smscore_device_t *coredev, int mode)
rc = smscore_sendrequest_and_wait(coredev, msg, msg->xMsgHeader.msgLength, &coredev->init_device_done); rc = smscore_sendrequest_and_wait(coredev, msg, msg->xMsgHeader.msgLength, &coredev->init_device_done);
kfree(buffer); kfree(buffer);
} } else {
else
{
printk(KERN_INFO "%s Could not allocate buffer for init device message.\n", __func__); printk(KERN_INFO "%s Could not allocate buffer for init device message.\n", __func__);
rc = -ENOMEM; rc = -ENOMEM;
} }
} } else {
else if (mode < DEVICE_MODE_DVBT || mode > DEVICE_MODE_DVBT_BDA) {
{ printk(KERN_INFO "%s invalid mode specified %d\n",
if (mode < DEVICE_MODE_DVBT || mode > DEVICE_MODE_DVBT_BDA) __func__, mode);
{
printk(KERN_INFO "%s invalid mode specified %d\n", __func__, mode);
return -EINVAL; return -EINVAL;
} }
smscore_registry_setmode(coredev->devpath, mode); smscore_registry_setmode(coredev->devpath, mode);
if (coredev->detectmode_handler) if (coredev->detectmode_handler)
coredev->detectmode_handler(coredev->context, &coredev->mode); coredev->detectmode_handler(coredev->context,
&coredev->mode);
if (coredev->mode != mode && coredev->setmode_handler) if (coredev->mode != mode && coredev->setmode_handler)
rc = coredev->setmode_handler(coredev->context, mode); rc = coredev->setmode_handler(coredev->context, mode);
} }
if (rc >= 0) if (rc >= 0) {
{
coredev->mode = mode; coredev->mode = mode;
coredev->device_flags &= ~SMS_DEVICE_NOT_READY; coredev->device_flags &= ~SMS_DEVICE_NOT_READY;
} }
...@@ -847,7 +826,7 @@ int smscore_get_device_mode(smscore_device_t *coredev) ...@@ -847,7 +826,7 @@ int smscore_get_device_mode(smscore_device_t *coredev)
* *
* @param coredev pointer to a coredev object returned by smscore_register_device * @param coredev pointer to a coredev object returned by smscore_register_device
* @param data_type client data type (SMS_DONT_CARE for all types) * @param data_type client data type (SMS_DONT_CARE for all types)
* @param id client id (SMS_DONT_CARE for all id ) * @param id client id (SMS_DONT_CARE for all id)
* *
*/ */
smscore_client_t *smscore_find_client(smscore_device_t *coredev, int data_type, int id) smscore_client_t *smscore_find_client(smscore_device_t *coredev, int data_type, int id)
...@@ -860,15 +839,16 @@ smscore_client_t *smscore_find_client(smscore_device_t *coredev, int data_type, ...@@ -860,15 +839,16 @@ smscore_client_t *smscore_find_client(smscore_device_t *coredev, int data_type,
spin_lock_irqsave(&coredev->clientslock, flags); spin_lock_irqsave(&coredev->clientslock, flags);
first = &coredev->clients; first = &coredev->clients;
for (next = first->next; (next != first) && !client; next = next->next) for (next = first->next;
{ (next != first) && !client;
firstid = &((smscore_client_t*)next )->idlist; next = next->next) {
for (nextid = firstid->next ; nextid != firstid ; nextid = nextid->next) firstid = &((smscore_client_t*)next)->idlist;
{ for (nextid = firstid->next;
nextid != firstid;
nextid = nextid->next) {
if ((((smscore_idlist_t*)nextid)->id == id) && if ((((smscore_idlist_t*)nextid)->id == id) &&
(((smscore_idlist_t*)nextid)->data_type == data_type || (((smscore_idlist_t*)nextid)->data_type == data_type ||
(((smscore_idlist_t*)nextid)->data_type == 0))) (((smscore_idlist_t*)nextid)->data_type == 0))) {
{
client = (smscore_client_t*) next; client = (smscore_client_t*) next;
break; break;
} }
...@@ -889,7 +869,8 @@ smscore_client_t *smscore_find_client(smscore_device_t *coredev, int data_type, ...@@ -889,7 +869,8 @@ smscore_client_t *smscore_find_client(smscore_device_t *coredev, int data_type,
void smscore_onresponse(smscore_device_t *coredev, smscore_buffer_t *cb) void smscore_onresponse(smscore_device_t *coredev, smscore_buffer_t *cb)
{ {
SmsMsgHdr_ST *phdr = (SmsMsgHdr_ST *)((u8 *) cb->p + cb->offset); SmsMsgHdr_ST *phdr = (SmsMsgHdr_ST *)((u8 *) cb->p + cb->offset);
smscore_client_t *client = smscore_find_client(coredev, phdr->msgType, phdr->msgDstId); smscore_client_t *client = smscore_find_client(coredev, phdr->msgType,
phdr->msgDstId);
int rc = -EBUSY; int rc = -EBUSY;
static unsigned long last_sample_time = 0; static unsigned long last_sample_time = 0;
...@@ -901,67 +882,62 @@ void smscore_onresponse(smscore_device_t *coredev, smscore_buffer_t *cb) ...@@ -901,67 +882,62 @@ void smscore_onresponse(smscore_device_t *coredev, smscore_buffer_t *cb)
if (time_now - last_sample_time > 10000) if (time_now - last_sample_time > 10000)
{ {
printk("\n%s data rate %d bytes/secs\n", __func__, (int)((data_total * 1000) / (time_now - last_sample_time))); printk("\n%s data rate %d bytes/secs\n", __func__,
(int)((data_total * 1000) /
(time_now - last_sample_time)));
last_sample_time = time_now; last_sample_time = time_now;
data_total = 0; data_total = 0;
} }
data_total += cb->size; data_total += cb->size;
/* If no client registered for type & id, check for control client where type is not registered*/ /* If no client registered for type & id,
// if (!client) * check for control client where type is not registered */
// client = smscore_find_client( coredev, 0, phdr->msgDstId);
if (client) if (client)
rc = client->onresponse_handler(client->context, cb); rc = client->onresponse_handler(client->context, cb);
if (rc < 0) if (rc < 0) {
{ switch (phdr->msgType) {
switch (phdr->msgType)
{
case MSG_SMS_GET_VERSION_EX_RES: case MSG_SMS_GET_VERSION_EX_RES:
{ {
SmsVersionRes_ST *ver = (SmsVersionRes_ST*) phdr; SmsVersionRes_ST *ver = (SmsVersionRes_ST *) phdr;
printk("%s: MSG_SMS_GET_VERSION_EX_RES id %d prots 0x%x ver %d.%d\n", __func__, ver->FirmwareId, ver->SupportedProtocols, ver->RomVersionMajor, ver->RomVersionMinor); printk("%s: MSG_SMS_GET_VERSION_EX_RES id %d "
"prots 0x%x ver %d.%d\n", __func__,
ver->FirmwareId, ver->SupportedProtocols,
ver->RomVersionMajor, ver->RomVersionMinor);
coredev->mode = ver->FirmwareId == 255 ? DEVICE_MODE_NONE : ver->FirmwareId; coredev->mode = ver->FirmwareId == 255 ?
DEVICE_MODE_NONE : ver->FirmwareId;
coredev->modes_supported = ver->SupportedProtocols; coredev->modes_supported = ver->SupportedProtocols;
complete(&coredev->version_ex_done); complete(&coredev->version_ex_done);
break; break;
} }
case MSG_SMS_INIT_DEVICE_RES: case MSG_SMS_INIT_DEVICE_RES:
printk("%s: MSG_SMS_INIT_DEVICE_RES\n", __func__); printk("%s: MSG_SMS_INIT_DEVICE_RES\n", __func__);
complete(&coredev->init_device_done); complete(&coredev->init_device_done);
break; break;
case MSG_SW_RELOAD_START_RES: case MSG_SW_RELOAD_START_RES:
printk("%s: MSG_SW_RELOAD_START_RES\n", __func__); printk("%s: MSG_SW_RELOAD_START_RES\n", __func__);
complete(&coredev->reload_start_done); complete(&coredev->reload_start_done);
break; break;
case MSG_SMS_DATA_DOWNLOAD_RES: case MSG_SMS_DATA_DOWNLOAD_RES:
complete(&coredev->data_download_done); complete(&coredev->data_download_done);
break; break;
case MSG_SW_RELOAD_EXEC_RES: case MSG_SW_RELOAD_EXEC_RES:
printk("%s: MSG_SW_RELOAD_EXEC_RES\n", __func__); printk("%s: MSG_SW_RELOAD_EXEC_RES\n", __func__);
break; break;
case MSG_SMS_SWDOWNLOAD_TRIGGER_RES: case MSG_SMS_SWDOWNLOAD_TRIGGER_RES:
printk("%s: MSG_SMS_SWDOWNLOAD_TRIGGER_RES\n", __func__); printk("%s: MSG_SMS_SWDOWNLOAD_TRIGGER_RES\n",
__func__);
complete(&coredev->trigger_done); complete(&coredev->trigger_done);
break; break;
case MSG_SMS_SLEEP_RESUME_COMP_IND: case MSG_SMS_SLEEP_RESUME_COMP_IND:
complete(&coredev->resume_done); complete(&coredev->resume_done);
break; break;
default: default:
//printk(KERN_INFO "%s no client (%p) or error (%d), type:%d dstid:%d\n", __func__, client, rc, phdr->msgType, phdr->msgDstId);
break; break;
} }
smscore_putbuffer(coredev, cb); smscore_putbuffer(coredev, cb);
} }
} }
...@@ -980,8 +956,7 @@ smscore_buffer_t *smscore_getbuffer(smscore_device_t *coredev) ...@@ -980,8 +956,7 @@ smscore_buffer_t *smscore_getbuffer(smscore_device_t *coredev)
spin_lock_irqsave(&coredev->bufferslock, flags); spin_lock_irqsave(&coredev->bufferslock, flags);
if (!list_empty(&coredev->buffers)) if (!list_empty(&coredev->buffers)) {
{
cb = (smscore_buffer_t *) coredev->buffers.next; cb = (smscore_buffer_t *) coredev->buffers.next;
list_del(&cb->entry); list_del(&cb->entry);
} }
...@@ -1003,35 +978,33 @@ void smscore_putbuffer(smscore_device_t *coredev, smscore_buffer_t *cb) ...@@ -1003,35 +978,33 @@ void smscore_putbuffer(smscore_device_t *coredev, smscore_buffer_t *cb)
list_add_locked(&cb->entry, &coredev->buffers, &coredev->bufferslock); list_add_locked(&cb->entry, &coredev->buffers, &coredev->bufferslock);
} }
int smscore_validate_client(smscore_device_t *coredev, smscore_client_t *client, int data_type, int id) int smscore_validate_client(smscore_device_t *coredev,
smscore_client_t *client, int data_type, int id)
{ {
smscore_idlist_t *listentry; smscore_idlist_t *listentry;
smscore_client_t *registered_client; smscore_client_t *registered_client;
if ( !client ) if (!client) {
{
PERROR("bad parameter.\n"); PERROR("bad parameter.\n");
return -EFAULT; return -EFAULT;
} }
registered_client = smscore_find_client(coredev, data_type, id); registered_client = smscore_find_client(coredev, data_type, id);
if (registered_client == client) if (registered_client == client) {
{
return 0; return 0;
} }
if (registered_client) if (registered_client) {
{
PERROR("The msg ID already registered to another client.\n"); PERROR("The msg ID already registered to another client.\n");
return -EEXIST; return -EEXIST;
} }
listentry = kzalloc ( sizeof ( smscore_idlist_t ), GFP_KERNEL ); listentry = kzalloc(sizeof(smscore_idlist_t), GFP_KERNEL);
if ( !listentry ) if (!listentry) {
{
PERROR("Can't allocate memory for client id.\n"); PERROR("Can't allocate memory for client id.\n");
return -ENOMEM; return -ENOMEM;
} }
listentry->id = id; listentry->id = id;
listentry->data_type = data_type; listentry->data_type = data_type;
list_add_locked ( &listentry->entry, &client->idlist, &coredev->clientslock ); list_add_locked(&listentry->entry, &client->idlist,
&coredev->clientslock);
return 0; return 0;
} }
...@@ -1051,29 +1024,31 @@ int smscore_validate_client(smscore_device_t *coredev, smscore_client_t *client, ...@@ -1051,29 +1024,31 @@ int smscore_validate_client(smscore_device_t *coredev, smscore_client_t *client,
int smscore_register_client(smscore_device_t *coredev, smsclient_params_t *params, smscore_client_t **client) int smscore_register_client(smscore_device_t *coredev, smsclient_params_t *params, smscore_client_t **client)
{ {
smscore_client_t *newclient; smscore_client_t *newclient;
// check that no other channel with same parameters exists /* check that no other channel with same parameters exists */
if (smscore_find_client(coredev, params->data_type, params->initial_id)) if (smscore_find_client(coredev, params->data_type,
{ params->initial_id)) {
PERROR("Client already exist.\n"); PERROR("Client already exist.\n");
return -EEXIST; return -EEXIST;
} }
newclient = kzalloc(sizeof(smscore_client_t), GFP_KERNEL); newclient = kzalloc(sizeof(smscore_client_t), GFP_KERNEL);
if (!newclient) if (!newclient) {
{
PERROR("Failed to allocate memory for client.\n"); PERROR("Failed to allocate memory for client.\n");
return -ENOMEM; return -ENOMEM;
} }
INIT_LIST_HEAD ( &newclient->idlist); INIT_LIST_HEAD(&newclient->idlist);
newclient->coredev = coredev; newclient->coredev = coredev;
newclient->onresponse_handler = params->onresponse_handler; newclient->onresponse_handler = params->onresponse_handler;
newclient->onremove_handler = params->onremove_handler; newclient->onremove_handler = params->onremove_handler;
newclient->context = params->context; newclient->context = params->context;
list_add_locked(&newclient->entry, &coredev->clients, &coredev->clientslock); list_add_locked(&newclient->entry, &coredev->clients,
smscore_validate_client(coredev, newclient, params->data_type, params->initial_id); &coredev->clientslock);
smscore_validate_client(coredev, newclient, params->data_type,
params->initial_id);
*client = newclient; *client = newclient;
PDEBUG ( "%p %d %d\n", params->context, params->data_type, params->initial_id ); PDEBUG("%p %d %d\n", params->context, params->data_type,
params->initial_id);
return 0; return 0;
} }
...@@ -1092,11 +1067,11 @@ void smscore_unregister_client(smscore_client_t *client) ...@@ -1092,11 +1067,11 @@ void smscore_unregister_client(smscore_client_t *client)
spin_lock_irqsave(&coredev->clientslock, flags); spin_lock_irqsave(&coredev->clientslock, flags);
while (!list_empty( &client->idlist)) while (!list_empty(&client->idlist)) {
{ smscore_idlist_t *identry =
smscore_idlist_t *identry = (smscore_idlist_t*)client->idlist.next; (smscore_idlist_t*) client->idlist.next;
list_del ( &identry->entry ); list_del(&identry->entry);
kfree ( identry ); kfree(identry);
} }
printk(KERN_INFO "%s %p\n", __func__, client->context); printk(KERN_INFO "%s %p\n", __func__, client->context);
...@@ -1123,22 +1098,21 @@ int smsclient_sendrequest(smscore_client_t *client, void *buffer, size_t size) ...@@ -1123,22 +1098,21 @@ int smsclient_sendrequest(smscore_client_t *client, void *buffer, size_t size)
SmsMsgHdr_ST *phdr = (SmsMsgHdr_ST *) buffer; SmsMsgHdr_ST *phdr = (SmsMsgHdr_ST *) buffer;
int rc; int rc;
if ( client == NULL ) if (client == NULL) {
{ printk(KERN_ERR "%s Got NULL client\n", __func__);
printk(KERN_ERR "%s Got NULL client\n", __func__ );
return -EINVAL; return -EINVAL;
} }
coredev = client->coredev; coredev = client->coredev;
// check that no other channel with same id exists /* check that no other channel with same id exists */
if ( coredev == NULL ) if (coredev == NULL) {
{ printk(KERN_ERR "%s Got NULL coredev\n", __func__);
printk(KERN_ERR "%s Got NULL coredev\n", __func__ );
return -EINVAL; return -EINVAL;
} }
rc = smscore_validate_client(client->coredev, client, 0, phdr->msgSrcId); rc = smscore_validate_client(client->coredev, client, 0,
phdr->msgSrcId);
if (rc < 0) if (rc < 0)
return rc; return rc;
...@@ -1168,21 +1142,25 @@ int smscore_get_common_buffer_size(smscore_device_t *coredev) ...@@ -1168,21 +1142,25 @@ int smscore_get_common_buffer_size(smscore_device_t *coredev)
int smscore_map_common_buffer(smscore_device_t *coredev, int smscore_map_common_buffer(smscore_device_t *coredev,
struct vm_area_struct *vma) struct vm_area_struct *vma)
{ {
unsigned long end = vma->vm_end, start = vma->vm_start, size = PAGE_ALIGN(coredev->common_buffer_size); unsigned long end = vma->vm_end,
start = vma->vm_start,
size = PAGE_ALIGN(coredev->common_buffer_size);
if (!(vma->vm_flags & (VM_READ | VM_SHARED)) || (vma->vm_flags & VM_WRITE)) if (!(vma->vm_flags & (VM_READ | VM_SHARED)) ||
{ (vma->vm_flags & VM_WRITE)) {
printk(KERN_INFO "%s invalid vm flags\n", __func__); printk(KERN_INFO "%s invalid vm flags\n", __func__);
return -EINVAL; return -EINVAL;
} }
if ((end - start) != size) if ((end - start) != size) {
{ printk(KERN_INFO "%s invalid size %d expected %d\n",
printk(KERN_INFO "%s invalid size %d expected %d\n", __func__, (int)(end - start), (int) size); __func__, (int)(end - start), (int) size);
return -EINVAL; return -EINVAL;
} }
if (remap_pfn_range(vma, start, coredev->common_buffer_phys >> PAGE_SHIFT, size, pgprot_noncached(vma->vm_page_prot))) if (remap_pfn_range(vma, start,
coredev->common_buffer_phys >> PAGE_SHIFT,
size, pgprot_noncached(vma->vm_page_prot)))
{ {
printk(KERN_INFO "%s remap_page_range failed\n", __func__); printk(KERN_INFO "%s remap_page_range failed\n", __func__);
return -EAGAIN; return -EAGAIN;
...@@ -1217,9 +1195,9 @@ void smscore_module_exit(void) ...@@ -1217,9 +1195,9 @@ void smscore_module_exit(void)
{ {
kmutex_lock(&g_smscore_deviceslock); kmutex_lock(&g_smscore_deviceslock);
while (!list_empty(&g_smscore_notifyees)) while (!list_empty(&g_smscore_notifyees)) {
{ smscore_device_notifyee_t *notifyee =
smscore_device_notifyee_t *notifyee = (smscore_device_notifyee_t *) g_smscore_notifyees.next; (smscore_device_notifyee_t *) g_smscore_notifyees.next;
list_del(&notifyee->entry); list_del(&notifyee->entry);
kfree(notifyee); kfree(notifyee);
...@@ -1227,9 +1205,9 @@ void smscore_module_exit(void) ...@@ -1227,9 +1205,9 @@ void smscore_module_exit(void)
kmutex_unlock(&g_smscore_deviceslock); kmutex_unlock(&g_smscore_deviceslock);
kmutex_lock(&g_smscore_registrylock); kmutex_lock(&g_smscore_registrylock);
while (!list_empty(&g_smscore_registry)) while (!list_empty(&g_smscore_registry)) {
{ smscore_registry_entry_t *entry =
smscore_registry_entry_t *entry = (smscore_registry_entry_t *) g_smscore_registry.next; (smscore_registry_entry_t *) g_smscore_registry.next;
list_del(&entry->entry); list_del(&entry->entry);
kfree(entry); kfree(entry);
...@@ -1249,6 +1227,5 @@ module_init(smscore_module_init); ...@@ -1249,6 +1227,5 @@ module_init(smscore_module_init);
module_exit(smscore_module_exit); module_exit(smscore_module_exit);
MODULE_DESCRIPTION("smscore"); MODULE_DESCRIPTION("smscore");
MODULE_AUTHOR ( "Siano Mobile Silicon,,, (doronc@siano-ms.com)" ); MODULE_AUTHOR("Siano Mobile Silicon,,, (doronc@siano-ms.com)");
MODULE_LICENSE("GPL"); MODULE_LICENSE("GPL");
...@@ -82,12 +82,12 @@ typedef void (*onremove_t)(void *context); ...@@ -82,12 +82,12 @@ typedef void (*onremove_t)(void *context);
typedef struct _smscore_buffer typedef struct _smscore_buffer
{ {
// public members, once passed to clients can be changed freely /* public members, once passed to clients can be changed freely */
struct list_head entry; struct list_head entry;
int size; int size;
int offset; int offset;
// private members, read-only for clients /* private members, read-only for clients */
void *p; void *p;
dma_addr_t phys; dma_addr_t phys;
unsigned long offset_in_common; unsigned long offset_in_common;
...@@ -123,7 +123,7 @@ typedef struct _smsclient_params ...@@ -123,7 +123,7 @@ typedef struct _smsclient_params
void *context; void *context;
} smsclient_params_t; } smsclient_params_t;
// GPIO definitions for antenna frequency domain control (SMS8021) /* GPIO definitions for antenna frequency domain control (SMS8021) */
#define SMS_ANTENNA_GPIO_0 1 #define SMS_ANTENNA_GPIO_0 1
#define SMS_ANTENNA_GPIO_1 0 #define SMS_ANTENNA_GPIO_1 0
...@@ -223,7 +223,7 @@ typedef struct SmsMsgHdr_S ...@@ -223,7 +223,7 @@ typedef struct SmsMsgHdr_S
UINT16 msgType; UINT16 msgType;
UINT8 msgSrcId; UINT8 msgSrcId;
UINT8 msgDstId; UINT8 msgDstId;
UINT16 msgLength; // Length is of the entire message, including header UINT16 msgLength; /* Length of entire message, including header */
UINT16 msgFlags; UINT16 msgFlags;
} SmsMsgHdr_ST; } SmsMsgHdr_ST;
...@@ -244,12 +244,12 @@ typedef struct SmsVersionRes_S ...@@ -244,12 +244,12 @@ typedef struct SmsVersionRes_S
{ {
SmsMsgHdr_ST xMsgHeader; SmsMsgHdr_ST xMsgHeader;
UINT16 ChipModel; // e.g. 0x1102 for SMS-1102 "Nova" UINT16 ChipModel; /* e.g. 0x1102 for SMS-1102 "Nova" */
UINT8 Step; // 0 - Step A UINT8 Step; /* 0 - Step A */
UINT8 MetalFix; // 0 - Metal 0 UINT8 MetalFix; /* 0 - Metal 0 */
UINT8 FirmwareId; // 0xFF � ROM, otherwise the value indicated by SMSHOSTLIB_DEVICE_MODES_E UINT8 FirmwareId; /* 0xFF � ROM, otherwise the value indicated by SMSHOSTLIB_DEVICE_MODES_E */
UINT8 SupportedProtocols; // Bitwise OR combination of supported protocols UINT8 SupportedProtocols; /* Bitwise OR combination of supported protocols */
UINT8 VersionMajor; UINT8 VersionMajor;
UINT8 VersionMinor; UINT8 VersionMinor;
...@@ -274,59 +274,60 @@ typedef struct SmsFirmware_S ...@@ -274,59 +274,60 @@ typedef struct SmsFirmware_S
typedef struct SMSHOSTLIB_STATISTICS_S typedef struct SMSHOSTLIB_STATISTICS_S
{ {
UINT32 Reserved; //!< Reserved UINT32 Reserved; /* Reserved */
/// Common parameters /* Common parameters */
UINT32 IsRfLocked; //!< 0 - not locked, 1 - locked UINT32 IsRfLocked; /* 0 - not locked, 1 - locked */
UINT32 IsDemodLocked; //!< 0 - not locked, 1 - locked UINT32 IsDemodLocked; /* 0 - not locked, 1 - locked */
UINT32 IsExternalLNAOn; //!< 0 - external LNA off, 1 - external LNA on UINT32 IsExternalLNAOn; /* 0 - external LNA off, 1 - external LNA on */
/// Reception quality /* Reception quality */
INT32 SNR; //!< dB INT32 SNR; /* dB */
UINT32 BER; //!< Post Viterbi BER [1E-5] UINT32 BER; /* Post Viterbi BER [1E-5] */
UINT32 FIB_CRC; //!< CRC errors percentage, valid only for DAB UINT32 FIB_CRC; /* CRC errors percentage, valid only for DAB */
UINT32 TS_PER; //!< Transport stream PER, 0xFFFFFFFF indicate N/A, valid only for DVB-T/H UINT32 TS_PER; /* Transport stream PER, 0xFFFFFFFF indicate N/A, valid only for DVB-T/H */
UINT32 MFER; //!< DVB-H frame error rate in percentage, 0xFFFFFFFF indicate N/A, valid only for DVB-H UINT32 MFER; /* DVB-H frame error rate in percentage, 0xFFFFFFFF indicate N/A, valid only for DVB-H */
INT32 RSSI; //!< dBm INT32 RSSI; /* dBm */
INT32 InBandPwr; //!< In band power in dBM INT32 InBandPwr; /* In band power in dBM */
INT32 CarrierOffset; //!< Carrier Offset in bin/1024 INT32 CarrierOffset; /* Carrier Offset in bin/1024 */
/// Transmission parameters /* Transmission parameters */
UINT32 Frequency; //!< Frequency in Hz UINT32 Frequency; /* Frequency in Hz */
UINT32 Bandwidth; //!< Bandwidth in MHz, valid only for DVB-T/H UINT32 Bandwidth; /* Bandwidth in MHz, valid only for DVB-T/H */
UINT32 TransmissionMode; //!< Transmission Mode, for DAB modes 1-4, for DVB-T/H FFT mode carriers in Kilos UINT32 TransmissionMode; /* Transmission Mode, for DAB modes 1-4, for DVB-T/H FFT mode carriers in Kilos */
UINT32 ModemState; //!< from SMS_DvbModemState_ET , valid only for DVB-T/H UINT32 ModemState; /* from SMS_DvbModemState_ET , valid only for DVB-T/H */
UINT32 GuardInterval; //!< Guard Interval, 1 divided by value , valid only for DVB-T/H UINT32 GuardInterval; /* Guard Interval, 1 divided by value , valid only for DVB-T/H */
UINT32 CodeRate; //!< Code Rate from SMS_DvbModemState_ET, valid only for DVB-T/H UINT32 CodeRate; /* Code Rate from SMS_DvbModemState_ET, valid only for DVB-T/H */
UINT32 LPCodeRate; //!< Low Priority Code Rate from SMS_DvbModemState_ET, valid only for DVB-T/H UINT32 LPCodeRate; /* Low Priority Code Rate from SMS_DvbModemState_ET, valid only for DVB-T/H */
UINT32 Hierarchy; //!< Hierarchy from SMS_Hierarchy_ET, valid only for DVB-T/H UINT32 Hierarchy; /* Hierarchy from SMS_Hierarchy_ET, valid only for DVB-T/H */
UINT32 Constellation; //!< Constellation from SMS_Constellation_ET, valid only for DVB-T/H UINT32 Constellation; /* Constellation from SMS_Constellation_ET, valid only for DVB-T/H */
/// Burst parameters, valid only for DVB-H /* Burst parameters, valid only for DVB-H */
UINT32 BurstSize; //!< Current burst size in bytes, valid only for DVB-H UINT32 BurstSize; /* Current burst size in bytes, valid only for DVB-H */
UINT32 BurstDuration; //!< Current burst duration in mSec, valid only for DVB-H UINT32 BurstDuration; /* Current burst duration in mSec, valid only for DVB-H */
UINT32 BurstCycleTime; //!< Current burst cycle time in mSec, valid only for DVB-H UINT32 BurstCycleTime; /* Current burst cycle time in mSec, valid only for DVB-H */
UINT32 CalculatedBurstCycleTime;//!< Current burst cycle time in mSec, as calculated by demodulator, valid only for DVB-H UINT32 CalculatedBurstCycleTime; /* Current burst cycle time in mSec, as calculated by demodulator, valid only for DVB-H */
UINT32 NumOfRows; //!< Number of rows in MPE table, valid only for DVB-H UINT32 NumOfRows; /* Number of rows in MPE table, valid only for DVB-H */
UINT32 NumOfPaddCols; //!< Number of padding columns in MPE table, valid only for DVB-H UINT32 NumOfPaddCols; /* Number of padding columns in MPE table, valid only for DVB-H */
UINT32 NumOfPunctCols; //!< Number of puncturing columns in MPE table, valid only for DVB-H UINT32 NumOfPunctCols; /* Number of puncturing columns in MPE table, valid only for DVB-H */
UINT32 ErrorTSPackets; //!< Number of erroneous transport-stream packets UINT32 ErrorTSPackets; /* Number of erroneous transport-stream packets */
UINT32 TotalTSPackets; //!< Total number of transport-stream packets UINT32 TotalTSPackets; /* Total number of transport-stream packets */
UINT32 NumOfValidMpeTlbs; //!< Number of MPE tables which do not include errors after MPE RS decoding UINT32 NumOfValidMpeTlbs; /* Number of MPE tables which do not include errors after MPE RS decoding */
UINT32 NumOfInvalidMpeTlbs; //!< Number of MPE tables which include errors after MPE RS decoding UINT32 NumOfInvalidMpeTlbs; /* Number of MPE tables which include errors after MPE RS decoding */
UINT32 NumOfCorrectedMpeTlbs; //!< Number of MPE tables which were corrected by MPE RS decoding UINT32 NumOfCorrectedMpeTlbs; /* Number of MPE tables which were corrected by MPE RS decoding */
/// Common params
UINT32 BERErrorCount; //!< Number of errornous SYNC bits. /* Common params */
UINT32 BERBitCount; //!< Total number of SYNC bits. UINT32 BERErrorCount; /* Number of errornous SYNC bits. */
UINT32 BERBitCount; /* Total number of SYNC bits. */
/// Interface information
UINT32 SmsToHostTxErrors; //!< Total number of transmission errors. /* Interface information */
UINT32 SmsToHostTxErrors; /* Total number of transmission errors. */
/// DAB/T-DMB
UINT32 PreBER; //!< DAB/T-DMB only: Pre Viterbi BER [1E-5] /* DAB/T-DMB */
UINT32 PreBER; /* DAB/T-DMB only: Pre Viterbi BER [1E-5] */
/// DVB-H TPS parameters
UINT32 CellId; //!< TPS Cell ID in bits 15..0, bits 31..16 zero; if set to 0xFFFFFFFF cell_id not yet recovered /* DVB-H TPS parameters */
UINT32 CellId; /* TPS Cell ID in bits 15..0, bits 31..16 zero; if set to 0xFFFFFFFF cell_id not yet recovered */
} SMSHOSTLIB_STATISTICS_ST; } SMSHOSTLIB_STATISTICS_ST;
...@@ -336,147 +337,151 @@ typedef struct ...@@ -336,147 +337,151 @@ typedef struct
SMSHOSTLIB_STATISTICS_ST Stat; SMSHOSTLIB_STATISTICS_ST Stat;
// Split the calc of the SNR in DAB /* Split the calc of the SNR in DAB */
UINT32 Signal; //!< dB UINT32 Signal; /* dB */
UINT32 Noise; //!< dB UINT32 Noise; /* dB */
} SmsMsgStatisticsInfo_ST; } SmsMsgStatisticsInfo_ST;
typedef struct SMSHOSTLIB_ISDBT_LAYER_STAT_S typedef struct SMSHOSTLIB_ISDBT_LAYER_STAT_S
{ {
// Per-layer information /* Per-layer information */
UINT32 CodeRate; //!< Code Rate from SMSHOSTLIB_CODE_RATE_ET, 255 means layer does not exist UINT32 CodeRate; /* Code Rate from SMSHOSTLIB_CODE_RATE_ET, 255 means layer does not exist */
UINT32 Constellation; //!< Constellation from SMSHOSTLIB_CONSTELLATION_ET, 255 means layer does not exist UINT32 Constellation; /* Constellation from SMSHOSTLIB_CONSTELLATION_ET, 255 means layer does not exist */
UINT32 BER; //!< Post Viterbi BER [1E-5], 0xFFFFFFFF indicate N/A UINT32 BER; /* Post Viterbi BER [1E-5], 0xFFFFFFFF indicate N/A */
UINT32 BERErrorCount; //!< Post Viterbi Error Bits Count UINT32 BERErrorCount; /* Post Viterbi Error Bits Count */
UINT32 BERBitCount; //!< Post Viterbi Total Bits Count UINT32 BERBitCount; /* Post Viterbi Total Bits Count */
UINT32 PreBER; //!< Pre Viterbi BER [1E-5], 0xFFFFFFFF indicate N/A UINT32 PreBER; /* Pre Viterbi BER [1E-5], 0xFFFFFFFF indicate N/A */
UINT32 TS_PER; //!< Transport stream PER [%], 0xFFFFFFFF indicate N/A UINT32 TS_PER; /* Transport stream PER [%], 0xFFFFFFFF indicate N/A */
UINT32 ErrorTSPackets; //!< Number of erroneous transport-stream packets UINT32 ErrorTSPackets; /* Number of erroneous transport-stream packets */
UINT32 TotalTSPackets; //!< Total number of transport-stream packets UINT32 TotalTSPackets; /* Total number of transport-stream packets */
UINT32 TILdepthI; //!< Time interleaver depth I parameter, 255 means layer does not exist UINT32 TILdepthI; /* Time interleaver depth I parameter, 255 means layer does not exist */
UINT32 NumberOfSegments; //!< Number of segments in layer A, 255 means layer does not exist UINT32 NumberOfSegments; /* Number of segments in layer A, 255 means layer does not exist */
UINT32 TMCCErrors; //!< TMCC errors UINT32 TMCCErrors; /* TMCC errors */
} SMSHOSTLIB_ISDBT_LAYER_STAT_ST; } SMSHOSTLIB_ISDBT_LAYER_STAT_ST;
typedef struct SMSHOSTLIB_STATISTICS_ISDBT_S typedef struct SMSHOSTLIB_STATISTICS_ISDBT_S
{ {
UINT32 StatisticsType; //!< Enumerator identifying the type of the structure. Values are the same as SMSHOSTLIB_DEVICE_MODES_E UINT32 StatisticsType; /* Enumerator identifying the type of the
//!< This fiels MUST always first in any statistics structure * structure. Values are the same as
* SMSHOSTLIB_DEVICE_MODES_E
UINT32 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 * This field MUST always be first in any
* statistics structure */
// Common parameters
UINT32 IsRfLocked; //!< 0 - not locked, 1 - locked UINT32 FullSize; /* Total size of the structure returned by the modem. If the size requested by
UINT32 IsDemodLocked; //!< 0 - not locked, 1 - locked * the host is smaller than FullSize, the struct will be truncated */
UINT32 IsExternalLNAOn; //!< 0 - external LNA off, 1 - external LNA on
/* Common parameters */
// Reception quality UINT32 IsRfLocked; /* 0 - not locked, 1 - locked */
INT32 SNR; //!< dB UINT32 IsDemodLocked; /* 0 - not locked, 1 - locked */
INT32 RSSI; //!< dBm UINT32 IsExternalLNAOn; /* 0 - external LNA off, 1 - external LNA on */
INT32 InBandPwr; //!< In band power in dBM
INT32 CarrierOffset; //!< Carrier Offset in Hz /* Reception quality */
INT32 SNR; /* dB */
// Transmission parameters INT32 RSSI; /* dBm */
UINT32 Frequency; //!< Frequency in Hz INT32 InBandPwr; /* In band power in dBM */
UINT32 Bandwidth; //!< Bandwidth in MHz INT32 CarrierOffset; /* Carrier Offset in Hz */
UINT32 TransmissionMode; //!< ISDB-T transmission mode
UINT32 ModemState; //!< 0 - Acquisition, 1 - Locked /* Transmission parameters */
UINT32 GuardInterval; //!< Guard Interval, 1 divided by value UINT32 Frequency; /* Frequency in Hz */
UINT32 SystemType; //!< ISDB-T system type (ISDB-T / ISDB-Tsb) UINT32 Bandwidth; /* Bandwidth in MHz */
UINT32 PartialReception; //!< TRUE - partial reception, FALSE otherwise UINT32 TransmissionMode; /* ISDB-T transmission mode */
UINT32 NumOfLayers; //!< Number of ISDB-T layers in the network UINT32 ModemState; /* 0 - Acquisition, 1 - Locked */
UINT32 GuardInterval; /* Guard Interval, 1 divided by value */
// Per-layer information UINT32 SystemType; /* ISDB-T system type (ISDB-T / ISDB-Tsb) */
// Layers A, B and C UINT32 PartialReception; /* TRUE - partial reception, FALSE otherwise */
SMSHOSTLIB_ISDBT_LAYER_STAT_ST LayerInfo[3]; //!< Per-layer statistics, see SMSHOSTLIB_ISDBT_LAYER_STAT_ST UINT32 NumOfLayers; /* Number of ISDB-T layers in the network */
// Interface information /* Per-layer information */
UINT32 SmsToHostTxErrors; //!< Total number of transmission errors. /* Layers A, B and C */
SMSHOSTLIB_ISDBT_LAYER_STAT_ST LayerInfo[3]; /* Per-layer statistics, see SMSHOSTLIB_ISDBT_LAYER_STAT_ST */
/* Interface information */
UINT32 SmsToHostTxErrors; /* Total number of transmission errors. */
} SMSHOSTLIB_STATISTICS_ISDBT_ST; } SMSHOSTLIB_STATISTICS_ISDBT_ST;
typedef struct SMSHOSTLIB_STATISTICS_DVB_S typedef struct SMSHOSTLIB_STATISTICS_DVB_S
{ {
UINT32 StatisticsType; //!< Enumerator identifying the type of the structure. Values are the same as SMSHOSTLIB_DEVICE_MODES_E UINT32 StatisticsType; /* Enumerator identifying the type of the structure. Values are the same as SMSHOSTLIB_DEVICE_MODES_E
//!< This fiels MUST always first in any statistics structure * This fiels MUST always first in any statistics structure */
UINT32 FullSize; //!< Total size of the structure returned by the modem. If the size requested by UINT32 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 * the host is smaller than FullSize, the struct will be truncated */
// Common parameters /* Common parameters */
UINT32 IsRfLocked; //!< 0 - not locked, 1 - locked UINT32 IsRfLocked; /* 0 - not locked, 1 - locked */
UINT32 IsDemodLocked; //!< 0 - not locked, 1 - locked UINT32 IsDemodLocked; /* 0 - not locked, 1 - locked */
UINT32 IsExternalLNAOn; //!< 0 - external LNA off, 1 - external LNA on UINT32 IsExternalLNAOn; /* 0 - external LNA off, 1 - external LNA on */
// Reception quality /* Reception quality */
INT32 SNR; //!< dB INT32 SNR; /* dB */
UINT32 BER; //!< Post Viterbi BER [1E-5] UINT32 BER; /* Post Viterbi BER [1E-5] */
UINT32 BERErrorCount; //!< Number of errornous SYNC bits. UINT32 BERErrorCount; /* Number of errornous SYNC bits. */
UINT32 BERBitCount; //!< Total number of SYNC bits. UINT32 BERBitCount; /* Total number of SYNC bits. */
UINT32 TS_PER; //!< Transport stream PER, 0xFFFFFFFF indicate N/A UINT32 TS_PER; /* Transport stream PER, 0xFFFFFFFF indicate N/A */
UINT32 MFER; //!< DVB-H frame error rate in percentage, 0xFFFFFFFF indicate N/A, valid only for DVB-H UINT32 MFER; /* DVB-H frame error rate in percentage, 0xFFFFFFFF indicate N/A, valid only for DVB-H */
INT32 RSSI; //!< dBm INT32 RSSI; /* dBm */
INT32 InBandPwr; //!< In band power in dBM INT32 InBandPwr; /* In band power in dBM */
INT32 CarrierOffset; //!< Carrier Offset in bin/1024 INT32 CarrierOffset; /* Carrier Offset in bin/1024 */
// Transmission parameters /* Transmission parameters */
UINT32 Frequency; //!< Frequency in Hz UINT32 Frequency; /* Frequency in Hz */
UINT32 Bandwidth; //!< Bandwidth in MHz UINT32 Bandwidth; /* Bandwidth in MHz */
UINT32 ModemState; //!< from SMSHOSTLIB_DVB_MODEM_STATE_ET UINT32 ModemState; /* from SMSHOSTLIB_DVB_MODEM_STATE_ET */
UINT32 TransmissionMode; //!< FFT mode carriers in Kilos UINT32 TransmissionMode; /* FFT mode carriers in Kilos */
UINT32 GuardInterval; //!< Guard Interval, 1 divided by value UINT32 GuardInterval; /* Guard Interval, 1 divided by value */
UINT32 CodeRate; //!< Code Rate from SMSHOSTLIB_CODE_RATE_ET UINT32 CodeRate; /* Code Rate from SMSHOSTLIB_CODE_RATE_ET */
UINT32 LPCodeRate; //!< Low Priority Code Rate from SMSHOSTLIB_CODE_RATE_ET UINT32 LPCodeRate; /* Low Priority Code Rate from SMSHOSTLIB_CODE_RATE_ET */
UINT32 Hierarchy; //!< Hierarchy from SMSHOSTLIB_HIERARCHY_ET UINT32 Hierarchy; /* Hierarchy from SMSHOSTLIB_HIERARCHY_ET */
UINT32 Constellation; //!< Constellation from SMSHOSTLIB_CONSTELLATION_ET UINT32 Constellation; /* Constellation from SMSHOSTLIB_CONSTELLATION_ET */
// Burst parameters, valid only for DVB-H /* Burst parameters, valid only for DVB-H */
UINT32 BurstSize; //!< Current burst size in bytes, valid only for DVB-H UINT32 BurstSize; /* Current burst size in bytes, valid only for DVB-H */
UINT32 BurstDuration; //!< Current burst duration in mSec, valid only for DVB-H UINT32 BurstDuration; /* Current burst duration in mSec, valid only for DVB-H */
UINT32 BurstCycleTime; //!< Current burst cycle time in mSec, valid only for DVB-H UINT32 BurstCycleTime; /* Current burst cycle time in mSec, valid only for DVB-H */
UINT32 CalculatedBurstCycleTime;//!< Current burst cycle time in mSec, as calculated by demodulator, valid only for DVB-H UINT32 CalculatedBurstCycleTime; /* Current burst cycle time in mSec, as calculated by demodulator, valid only for DVB-H */
UINT32 NumOfRows; //!< Number of rows in MPE table, valid only for DVB-H UINT32 NumOfRows; /* Number of rows in MPE table, valid only for DVB-H */
UINT32 NumOfPaddCols; //!< Number of padding columns in MPE table, valid only for DVB-H UINT32 NumOfPaddCols; /* Number of padding columns in MPE table, valid only for DVB-H */
UINT32 NumOfPunctCols; //!< Number of puncturing columns in MPE table, valid only for DVB-H UINT32 NumOfPunctCols; /* Number of puncturing columns in MPE table, valid only for DVB-H */
UINT32 ErrorTSPackets; //!< Number of erroneous transport-stream packets UINT32 ErrorTSPackets; /* Number of erroneous transport-stream packets */
UINT32 TotalTSPackets; //!< Total number of transport-stream packets UINT32 TotalTSPackets; /* Total number of transport-stream packets */
UINT32 NumOfValidMpeTlbs; //!< Number of MPE tables which do not include errors after MPE RS decoding, valid only for DVB-H UINT32 NumOfValidMpeTlbs; /* Number of MPE tables which do not include errors after MPE RS decoding, valid only for DVB-H */
UINT32 NumOfInvalidMpeTlbs; //!< Number of MPE tables which include errors after MPE RS decoding, valid only for DVB-H UINT32 NumOfInvalidMpeTlbs; /* Number of MPE tables which include errors after MPE RS decoding, valid only for DVB-H */
UINT32 NumOfCorrectedMpeTlbs; //!< Number of MPE tables which were corrected by MPE RS decoding, valid only for DVB-H UINT32 NumOfCorrectedMpeTlbs; /* Number of MPE tables which were corrected by MPE RS decoding, valid only for DVB-H */
UINT32 NumMPEReceived; //!< DVB-H, Num MPE section received UINT32 NumMPEReceived; /* DVB-H, Num MPE section received */
// DVB-H TPS parameters /* DVB-H TPS parameters */
UINT32 CellId; //!< TPS Cell ID in bits 15..0, bits 31..16 zero; if set to 0xFFFFFFFF cell_id not yet recovered UINT32 CellId; /* TPS Cell ID in bits 15..0, bits 31..16 zero; if set to 0xFFFFFFFF cell_id not yet recovered */
UINT32 DvbhSrvIndHP; //!< DVB-H service indication info, bit 1 - Time Slicing indicator, bit 0 - MPE-FEC indicator UINT32 DvbhSrvIndHP; /* DVB-H service indication info, bit 1 - Time Slicing indicator, bit 0 - MPE-FEC indicator */
UINT32 DvbhSrvIndLP; //!< DVB-H service indication info, bit 1 - Time Slicing indicator, bit 0 - MPE-FEC indicator UINT32 DvbhSrvIndLP; /* DVB-H service indication info, bit 1 - Time Slicing indicator, bit 0 - MPE-FEC indicator */
// Interface information /* Interface information */
UINT32 SmsToHostTxErrors; //!< Total number of transmission errors. UINT32 SmsToHostTxErrors; /* Total number of transmission errors. */
} SMSHOSTLIB_STATISTICS_DVB_ST; } SMSHOSTLIB_STATISTICS_DVB_ST;
typedef struct SMSHOSTLIB_GPIO_CONFIG_S typedef struct SMSHOSTLIB_GPIO_CONFIG_S
{ {
UINT8 Direction; //!< GPIO direction: Input - 0, Output - 1 UINT8 Direction; /* GPIO direction: Input - 0, Output - 1 */
UINT8 PullUpDown; //!< PullUp/PullDown: None - 0, PullDown - 1, PullUp - 2, Keeper - 3 UINT8 PullUpDown; /* PullUp/PullDown: None - 0, PullDown - 1, PullUp - 2, Keeper - 3 */
UINT8 InputCharacteristics; //!< Input Characteristics: Normal - 0, Schmitt trigger - 1 UINT8 InputCharacteristics; /* Input Characteristics: Normal - 0, Schmitt trigger - 1 */
UINT8 OutputSlewRate; //!< Output Slew Rate: Fast slew rate - 0, Slow slew rate - 1 UINT8 OutputSlewRate; /* Output Slew Rate: Fast slew rate - 0, Slow slew rate - 1 */
UINT8 OutputDriving; //!< Output driving capability: 4mA - 0, 8mA - 1, 12mA - 2, 16mA - 3 UINT8 OutputDriving; /* Output driving capability: 4mA - 0, 8mA - 1, 12mA - 2, 16mA - 3 */
} SMSHOSTLIB_GPIO_CONFIG_ST; } SMSHOSTLIB_GPIO_CONFIG_ST;
typedef struct SMSHOSTLIB_I2C_REQ_S typedef struct SMSHOSTLIB_I2C_REQ_S
{ {
UINT32 DeviceAddress; // I2c device address UINT32 DeviceAddress; /* I2c device address */
UINT32 WriteCount; // number of bytes to write UINT32 WriteCount; /* number of bytes to write */
UINT32 ReadCount; // number of bytes to read UINT32 ReadCount; /* number of bytes to read */
UINT8 Data[1]; UINT8 Data[1];
} SMSHOSTLIB_I2C_REQ_ST; } SMSHOSTLIB_I2C_REQ_ST;
typedef struct SMSHOSTLIB_I2C_RES_S typedef struct SMSHOSTLIB_I2C_RES_S
{ {
UINT32 Status; // non-zero value in case of failure UINT32 Status; /* non-zero value in case of failure */
UINT32 ReadCount; // number of bytes read UINT32 ReadCount; /* number of bytes read */
UINT8 Data[1]; UINT8 Data[1];
} SMSHOSTLIB_I2C_RES_ST; } SMSHOSTLIB_I2C_RES_ST;
...@@ -497,7 +502,7 @@ typedef struct _smsdvb_client ...@@ -497,7 +502,7 @@ typedef struct _smsdvb_client
struct completion tune_done, stat_done; struct completion tune_done, stat_done;
// todo: save freq/band instead whole struct /* todo: save freq/band instead whole struct */
struct dvb_frontend_parameters fe_params; struct dvb_frontend_parameters fe_params;
} smsdvb_client_t; } smsdvb_client_t;
...@@ -508,14 +513,17 @@ extern int smscore_registry_getmode(char *devpath); ...@@ -508,14 +513,17 @@ extern int smscore_registry_getmode(char *devpath);
extern int smscore_register_hotplug(hotplug_t hotplug); extern int smscore_register_hotplug(hotplug_t hotplug);
extern void smscore_unregister_hotplug(hotplug_t hotplug); extern void smscore_unregister_hotplug(hotplug_t hotplug);
extern int smscore_register_device(smsdevice_params_t *params, smscore_device_t **coredev); extern int smscore_register_device(smsdevice_params_t *params,
smscore_device_t **coredev);
extern void smscore_unregister_device(smscore_device_t *coredev); extern void smscore_unregister_device(smscore_device_t *coredev);
extern int smscore_start_device(smscore_device_t *coredev); extern int smscore_start_device(smscore_device_t *coredev);
extern int smscore_load_firmware(smscore_device_t *coredev, char *filename, extern int smscore_load_firmware(smscore_device_t *coredev, char *filename,
loadfirmware_t loadfirmware_handler); loadfirmware_t loadfirmware_handler);
extern int smscore_load_firmware_from_buffer(smscore_device_t *coredev, u8 *buffer, int size, int new_mode); extern int smscore_load_firmware_from_buffer(smscore_device_t *coredev,
u8 *buffer, int size,
int new_mode);
extern int smscore_set_device_mode(smscore_device_t *coredev, int mode); extern int smscore_set_device_mode(smscore_device_t *coredev, int mode);
extern int smscore_get_device_mode(smscore_device_t *coredev); extern int smscore_get_device_mode(smscore_device_t *coredev);
...@@ -525,8 +533,10 @@ extern int smscore_register_client(smscore_device_t *coredev, ...@@ -525,8 +533,10 @@ extern int smscore_register_client(smscore_device_t *coredev,
smscore_client_t **client); smscore_client_t **client);
extern void smscore_unregister_client(smscore_client_t *client); extern void smscore_unregister_client(smscore_client_t *client);
extern int smsclient_sendrequest(smscore_client_t *client, void *buffer, size_t size); extern int smsclient_sendrequest(smscore_client_t *client,
extern void smscore_onresponse(smscore_device_t *coredev, smscore_buffer_t *cb); void *buffer, size_t size);
extern void smscore_onresponse(smscore_device_t *coredev,
smscore_buffer_t *cb);
extern int smscore_get_common_buffer_size(smscore_device_t *coredev); extern int smscore_get_common_buffer_size(smscore_device_t *coredev);
extern int smscore_map_common_buffer(smscore_device_t *coredev, extern int smscore_map_common_buffer(smscore_device_t *coredev,
...@@ -543,4 +553,4 @@ void smsdvb_unregister(void); ...@@ -543,4 +553,4 @@ void smsdvb_unregister(void);
int smsusb_register(void); int smsusb_register(void);
void smsusb_unregister(void); void smsusb_unregister(void);
#endif // __smscoreapi_h__ #endif /* __smscoreapi_h__ */
...@@ -34,8 +34,7 @@ int smsdvb_onresponse(void *context, smscore_buffer_t *cb) ...@@ -34,8 +34,7 @@ int smsdvb_onresponse(void *context, smscore_buffer_t *cb)
smsdvb_client_t *client = (smsdvb_client_t *) context; smsdvb_client_t *client = (smsdvb_client_t *) context;
SmsMsgHdr_ST *phdr = (SmsMsgHdr_ST *)(((u8 *) cb->p) + cb->offset); SmsMsgHdr_ST *phdr = (SmsMsgHdr_ST *)(((u8 *) cb->p) + cb->offset);
switch(phdr->msgType) switch(phdr->msgType) {
{
case MSG_SMS_DVBT_BDA_DATA: case MSG_SMS_DVBT_BDA_DATA:
dvb_dmx_swfilter(&client->demux, (u8 *)(phdr + 1), dvb_dmx_swfilter(&client->demux, (u8 *)(phdr + 1),
cb->size - sizeof(SmsMsgHdr_ST)); cb->size - sizeof(SmsMsgHdr_ST));
...@@ -52,7 +51,12 @@ int smsdvb_onresponse(void *context, smscore_buffer_t *cb) ...@@ -52,7 +51,12 @@ int smsdvb_onresponse(void *context, smscore_buffer_t *cb)
if (p->Stat.IsDemodLocked) if (p->Stat.IsDemodLocked)
{ {
client->fe_status = FE_HAS_SIGNAL | FE_HAS_CARRIER | FE_HAS_VITERBI | FE_HAS_SYNC | FE_HAS_LOCK; client->fe_status = FE_HAS_SIGNAL |
FE_HAS_CARRIER |
FE_HAS_VITERBI |
FE_HAS_SYNC |
FE_HAS_LOCK;
client->fe_snr = p->Stat.SNR; client->fe_snr = p->Stat.SNR;
client->fe_ber = p->Stat.BER; client->fe_ber = p->Stat.BER;
...@@ -61,10 +65,9 @@ int smsdvb_onresponse(void *context, smscore_buffer_t *cb) ...@@ -61,10 +65,9 @@ int smsdvb_onresponse(void *context, smscore_buffer_t *cb)
else if (p->Stat.InBandPwr > -29) else if (p->Stat.InBandPwr > -29)
client->fe_signal_strength = 100; client->fe_signal_strength = 100;
else else
client->fe_signal_strength = (p->Stat.InBandPwr + 95) * 3 / 2; client->fe_signal_strength =
} (p->Stat.InBandPwr + 95) * 3 / 2;
else } else {
{
client->fe_status = 0; client->fe_status = 0;
client->fe_snr = client->fe_snr =
client->fe_ber = client->fe_ber =
...@@ -73,8 +76,7 @@ int smsdvb_onresponse(void *context, smscore_buffer_t *cb) ...@@ -73,8 +76,7 @@ int smsdvb_onresponse(void *context, smscore_buffer_t *cb)
complete(&client->stat_done); complete(&client->stat_done);
break; break;
} } }
}
smscore_putbuffer(client->coredev, cb); smscore_putbuffer(client->coredev, cb);
...@@ -106,7 +108,8 @@ void smsdvb_onremove(void *context) ...@@ -106,7 +108,8 @@ void smsdvb_onremove(void *context)
static int smsdvb_start_feed(struct dvb_demux_feed *feed) static int smsdvb_start_feed(struct dvb_demux_feed *feed)
{ {
smsdvb_client_t *client = container_of(feed->demux, smsdvb_client_t, demux); smsdvb_client_t *client =
container_of(feed->demux, smsdvb_client_t, demux);
SmsMsgData_ST PidMsg; SmsMsgData_ST PidMsg;
printk("%s add pid %d(%x)\n", __func__, feed->pid, feed->pid); printk("%s add pid %d(%x)\n", __func__, feed->pid, feed->pid);
...@@ -118,12 +121,14 @@ static int smsdvb_start_feed(struct dvb_demux_feed *feed) ...@@ -118,12 +121,14 @@ static int smsdvb_start_feed(struct dvb_demux_feed *feed)
PidMsg.xMsgHeader.msgLength = sizeof(PidMsg); PidMsg.xMsgHeader.msgLength = sizeof(PidMsg);
PidMsg.msgData[0] = feed->pid; PidMsg.msgData[0] = feed->pid;
return smsclient_sendrequest(client->smsclient, &PidMsg, sizeof(PidMsg)); return smsclient_sendrequest(client->smsclient,
&PidMsg, sizeof(PidMsg));
} }
static int smsdvb_stop_feed(struct dvb_demux_feed *feed) static int smsdvb_stop_feed(struct dvb_demux_feed *feed)
{ {
smsdvb_client_t *client = container_of(feed->demux, smsdvb_client_t, demux); smsdvb_client_t *client =
container_of(feed->demux, smsdvb_client_t, demux);
SmsMsgData_ST PidMsg; SmsMsgData_ST PidMsg;
printk("%s remove pid %d(%x)\n", __func__, feed->pid, feed->pid); printk("%s remove pid %d(%x)\n", __func__, feed->pid, feed->pid);
...@@ -135,7 +140,8 @@ static int smsdvb_stop_feed(struct dvb_demux_feed *feed) ...@@ -135,7 +140,8 @@ static int smsdvb_stop_feed(struct dvb_demux_feed *feed)
PidMsg.xMsgHeader.msgLength = sizeof(PidMsg); PidMsg.xMsgHeader.msgLength = sizeof(PidMsg);
PidMsg.msgData[0] = feed->pid; PidMsg.msgData[0] = feed->pid;
return smsclient_sendrequest(client->smsclient, &PidMsg, sizeof(PidMsg)); return smsclient_sendrequest(client->smsclient,
&PidMsg, sizeof(PidMsg));
} }
static int smsdvb_sendrequest_and_wait(smsdvb_client_t *client, static int smsdvb_sendrequest_and_wait(smsdvb_client_t *client,
...@@ -146,13 +152,18 @@ static int smsdvb_sendrequest_and_wait(smsdvb_client_t *client, ...@@ -146,13 +152,18 @@ static int smsdvb_sendrequest_and_wait(smsdvb_client_t *client,
if (rc < 0) if (rc < 0)
return rc; return rc;
return wait_for_completion_timeout(completion, msecs_to_jiffies(2000)) ? 0 : -ETIME; return wait_for_completion_timeout(completion,
msecs_to_jiffies(2000)) ?
0 : -ETIME;
} }
static int smsdvb_send_statistics_request(smsdvb_client_t *client) static int smsdvb_send_statistics_request(smsdvb_client_t *client)
{ {
SmsMsgHdr_ST Msg = { MSG_SMS_GET_STATISTICS_REQ, DVBT_BDA_CONTROL_MSG_ID, HIF_TASK, sizeof(SmsMsgHdr_ST), 0 }; SmsMsgHdr_ST Msg = { MSG_SMS_GET_STATISTICS_REQ,
return smsdvb_sendrequest_and_wait(client, &Msg, sizeof(Msg), &client->stat_done); DVBT_BDA_CONTROL_MSG_ID,
HIF_TASK, sizeof(SmsMsgHdr_ST), 0 };
return smsdvb_sendrequest_and_wait(client, &Msg, sizeof(Msg),
&client->stat_done);
} }
static int smsdvb_read_status(struct dvb_frontend *fe, fe_status_t *stat) static int smsdvb_read_status(struct dvb_frontend *fe, fe_status_t *stat)
...@@ -199,7 +210,8 @@ static int smsdvb_read_snr(struct dvb_frontend *fe, u16 *snr) ...@@ -199,7 +210,8 @@ static int smsdvb_read_snr(struct dvb_frontend *fe, u16 *snr)
return rc; return rc;
} }
static int smsdvb_get_tune_settings(struct dvb_frontend *fe, struct dvb_frontend_tune_settings *tune) static int smsdvb_get_tune_settings(struct dvb_frontend *fe,
struct dvb_frontend_tune_settings *tune)
{ {
printk("%s\n", __func__); printk("%s\n", __func__);
...@@ -209,7 +221,8 @@ static int smsdvb_get_tune_settings(struct dvb_frontend *fe, struct dvb_frontend ...@@ -209,7 +221,8 @@ static int smsdvb_get_tune_settings(struct dvb_frontend *fe, struct dvb_frontend
return 0; return 0;
} }
static int smsdvb_set_frontend(struct dvb_frontend *fe, struct dvb_frontend_parameters *fep) static int smsdvb_set_frontend(struct dvb_frontend *fe,
struct dvb_frontend_parameters *fep)
{ {
smsdvb_client_t *client = container_of(fe, smsdvb_client_t, frontend); smsdvb_client_t *client = container_of(fe, smsdvb_client_t, frontend);
...@@ -227,29 +240,32 @@ static int smsdvb_set_frontend(struct dvb_frontend *fe, struct dvb_frontend_para ...@@ -227,29 +240,32 @@ static int smsdvb_set_frontend(struct dvb_frontend *fe, struct dvb_frontend_para
Msg.Data[0] = fep->frequency; Msg.Data[0] = fep->frequency;
Msg.Data[2] = 12000000; Msg.Data[2] = 12000000;
printk("%s freq %d band %d\n", __func__, fep->frequency, fep->u.ofdm.bandwidth); printk("%s freq %d band %d\n", __func__,
fep->frequency, fep->u.ofdm.bandwidth);
switch(fep->u.ofdm.bandwidth) switch(fep->u.ofdm.bandwidth)
{ {
case BANDWIDTH_8_MHZ: Msg.Data[1] = BW_8_MHZ; break; case BANDWIDTH_8_MHZ: Msg.Data[1] = BW_8_MHZ; break;
case BANDWIDTH_7_MHZ: Msg.Data[1] = BW_7_MHZ; break; case BANDWIDTH_7_MHZ: Msg.Data[1] = BW_7_MHZ; break;
case BANDWIDTH_6_MHZ: Msg.Data[1] = BW_6_MHZ; break; case BANDWIDTH_6_MHZ: Msg.Data[1] = BW_6_MHZ; break;
// case BANDWIDTH_5_MHZ: Msg.Data[1] = BW_5_MHZ; break;
case BANDWIDTH_AUTO: return -EOPNOTSUPP; case BANDWIDTH_AUTO: return -EOPNOTSUPP;
default: return -EINVAL; default: return -EINVAL;
} }
return smsdvb_sendrequest_and_wait(client, &Msg, sizeof(Msg), &client->tune_done); return smsdvb_sendrequest_and_wait(client, &Msg, sizeof(Msg),
&client->tune_done);
} }
static int smsdvb_get_frontend(struct dvb_frontend *fe, struct dvb_frontend_parameters *fep) static int smsdvb_get_frontend(struct dvb_frontend *fe,
struct dvb_frontend_parameters *fep)
{ {
smsdvb_client_t *client = container_of(fe, smsdvb_client_t, frontend); smsdvb_client_t *client = container_of(fe, smsdvb_client_t, frontend);
printk("%s\n", __func__); printk("%s\n", __func__);
// todo: // todo:
memcpy(fep, &client->fe_params, sizeof(struct dvb_frontend_parameters)); memcpy(fep, &client->fe_params,
sizeof(struct dvb_frontend_parameters));
return 0; return 0;
} }
...@@ -268,8 +284,8 @@ static struct dvb_frontend_ops smsdvb_fe_ops = { ...@@ -268,8 +284,8 @@ static struct dvb_frontend_ops smsdvb_fe_ops = {
.caps = FE_CAN_INVERSION_AUTO | .caps = FE_CAN_INVERSION_AUTO |
FE_CAN_FEC_1_2 | FE_CAN_FEC_2_3 | FE_CAN_FEC_3_4 | FE_CAN_FEC_1_2 | FE_CAN_FEC_2_3 | FE_CAN_FEC_3_4 |
FE_CAN_FEC_5_6 | FE_CAN_FEC_7_8 | FE_CAN_FEC_AUTO | FE_CAN_FEC_5_6 | FE_CAN_FEC_7_8 | FE_CAN_FEC_AUTO |
FE_CAN_QPSK | FE_CAN_QAM_16 | FE_CAN_QAM_64 | FE_CAN_QAM_AUTO | FE_CAN_QPSK | FE_CAN_QAM_16 | FE_CAN_QAM_64 |
FE_CAN_TRANSMISSION_MODE_AUTO | FE_CAN_QAM_AUTO | FE_CAN_TRANSMISSION_MODE_AUTO |
FE_CAN_GUARD_INTERVAL_AUTO | FE_CAN_GUARD_INTERVAL_AUTO |
FE_CAN_RECOVER | FE_CAN_RECOVER |
FE_CAN_HIERARCHY_AUTO, FE_CAN_HIERARCHY_AUTO,
...@@ -287,8 +303,8 @@ static struct dvb_frontend_ops smsdvb_fe_ops = { ...@@ -287,8 +303,8 @@ static struct dvb_frontend_ops smsdvb_fe_ops = {
.read_snr = smsdvb_read_snr, .read_snr = smsdvb_read_snr,
}; };
int smsdvb_hotplug(smscore_device_t *coredev, struct device *device, int smsdvb_hotplug(smscore_device_t *coredev,
int arrival) struct device *device, int arrival)
{ {
smsclient_params_t params; smsclient_params_t params;
smsdvb_client_t *client; smsdvb_client_t *client;
...@@ -298,23 +314,21 @@ int smsdvb_hotplug(smscore_device_t *coredev, struct device *device, ...@@ -298,23 +314,21 @@ int smsdvb_hotplug(smscore_device_t *coredev, struct device *device,
if (!arrival) if (!arrival)
return 0; return 0;
if (smscore_get_device_mode(coredev) != 4) if (smscore_get_device_mode(coredev) != 4) {
{
printk(KERN_ERR "%sSMS Device mode is not set for DVB operation.\n", __func__); printk(KERN_ERR "%sSMS Device mode is not set for DVB operation.\n", __func__);
return 0; return 0;
} }
client = kzalloc(sizeof(smsdvb_client_t), GFP_KERNEL); client = kzalloc(sizeof(smsdvb_client_t), GFP_KERNEL);
if (!client) if (!client) {
{
printk(KERN_INFO "%s kmalloc() failed\n", __func__); printk(KERN_INFO "%s kmalloc() failed\n", __func__);
return -ENOMEM; return -ENOMEM;
} }
// register dvb adapter // register dvb adapter
rc = dvb_register_adapter(&client->adapter, "Siano Digital Receiver", THIS_MODULE, device, adapter_nr); rc = dvb_register_adapter(&client->adapter, "Siano Digital Receiver",
if (rc < 0) THIS_MODULE, device, adapter_nr);
{ if (rc < 0) {
printk("%s dvb_register_adapter() failed %d\n", __func__, rc); printk("%s dvb_register_adapter() failed %d\n", __func__, rc);
goto adapter_error; goto adapter_error;
} }
...@@ -327,8 +341,7 @@ int smsdvb_hotplug(smscore_device_t *coredev, struct device *device, ...@@ -327,8 +341,7 @@ int smsdvb_hotplug(smscore_device_t *coredev, struct device *device,
client->demux.stop_feed = smsdvb_stop_feed; client->demux.stop_feed = smsdvb_stop_feed;
rc = dvb_dmx_init(&client->demux); rc = dvb_dmx_init(&client->demux);
if (rc < 0) if (rc < 0) {
{
printk("%s dvb_dmx_init failed %d\n\n", __func__, rc); printk("%s dvb_dmx_init failed %d\n\n", __func__, rc);
goto dvbdmx_error; goto dvbdmx_error;
} }
...@@ -339,18 +352,17 @@ int smsdvb_hotplug(smscore_device_t *coredev, struct device *device, ...@@ -339,18 +352,17 @@ int smsdvb_hotplug(smscore_device_t *coredev, struct device *device,
client->dmxdev.capabilities = 0; client->dmxdev.capabilities = 0;
rc = dvb_dmxdev_init(&client->dmxdev, &client->adapter); rc = dvb_dmxdev_init(&client->dmxdev, &client->adapter);
if (rc < 0) if (rc < 0) {
{
printk("%s dvb_dmxdev_init failed %d\n", __func__, rc); printk("%s dvb_dmxdev_init failed %d\n", __func__, rc);
goto dmxdev_error; goto dmxdev_error;
} }
// init and register frontend // init and register frontend
memcpy(&client->frontend.ops, &smsdvb_fe_ops, sizeof(struct dvb_frontend_ops)); memcpy(&client->frontend.ops, &smsdvb_fe_ops,
sizeof(struct dvb_frontend_ops));
rc = dvb_register_frontend(&client->adapter, &client->frontend); rc = dvb_register_frontend(&client->adapter, &client->frontend);
if (rc < 0) if (rc < 0) {
{
printk("%s frontend registration failed %d\n", __func__, rc); printk("%s frontend registration failed %d\n", __func__, rc);
goto frontend_error; goto frontend_error;
} }
...@@ -362,9 +374,9 @@ int smsdvb_hotplug(smscore_device_t *coredev, struct device *device, ...@@ -362,9 +374,9 @@ int smsdvb_hotplug(smscore_device_t *coredev, struct device *device,
params.context = client; params.context = client;
rc = smscore_register_client(coredev, &params, &client->smsclient); rc = smscore_register_client(coredev, &params, &client->smsclient);
if (rc < 0) if (rc < 0) {
{ printk(KERN_INFO "%s smscore_register_client() failed %d\n",
printk(KERN_INFO "%s smscore_register_client() failed %d\n", __func__, rc); __func__, rc);
goto client_error; goto client_error;
} }
...@@ -421,9 +433,8 @@ void smsdvb_unregister(void) ...@@ -421,9 +433,8 @@ void smsdvb_unregister(void)
kmutex_lock(&g_smsdvb_clientslock); kmutex_lock(&g_smsdvb_clientslock);
while (!list_empty(&g_smsdvb_clients)) while (!list_empty(&g_smsdvb_clients))
smsdvb_unregister_client((smsdvb_client_t *) g_smsdvb_clients.next); smsdvb_unregister_client(
(smsdvb_client_t *) g_smsdvb_clients.next);
kmutex_unlock(&g_smsdvb_clientslock); kmutex_unlock(&g_smsdvb_clientslock);
} }
...@@ -68,44 +68,50 @@ void smsusb_onresponse(struct urb *urb) ...@@ -68,44 +68,50 @@ void smsusb_onresponse(struct urb *urb)
smsusb_urb_t *surb = (smsusb_urb_t *) urb->context; smsusb_urb_t *surb = (smsusb_urb_t *) urb->context;
smsusb_device_t *dev = surb->dev; smsusb_device_t *dev = surb->dev;
if (urb->status < 0) if (urb->status < 0) {
{ printk(KERN_INFO "%s error, urb status %d, %d bytes\n",
printk(KERN_INFO "%s error, urb status %d, %d bytes\n", __func__, urb->status, urb->actual_length); __func__, urb->status, urb->actual_length);
return; return;
} }
if (urb->actual_length > 0) if (urb->actual_length > 0) {
{
SmsMsgHdr_ST *phdr = (SmsMsgHdr_ST *) surb->cb->p; SmsMsgHdr_ST *phdr = (SmsMsgHdr_ST *) surb->cb->p;
if (urb->actual_length >= phdr->msgLength) if (urb->actual_length >= phdr->msgLength) {
{
surb->cb->size = phdr->msgLength; surb->cb->size = phdr->msgLength;
if (dev->response_alignment && (phdr->msgFlags & MSG_HDR_FLAG_SPLIT_MSG)) if (dev->response_alignment &&
{ (phdr->msgFlags & MSG_HDR_FLAG_SPLIT_MSG)) {
surb->cb->offset = dev->response_alignment + ((phdr->msgFlags >> 8) & 3);
surb->cb->offset =
// sanity check dev->response_alignment +
if (((int) phdr->msgLength + surb->cb->offset) > urb->actual_length) ((phdr->msgFlags >> 8) & 3);
{
printk("%s: invalid response msglen %d offset %d size %d\n", __func__, phdr->msgLength, surb->cb->offset, urb->actual_length); /* sanity check */
if (((int) phdr->msgLength +
surb->cb->offset) > urb->actual_length) {
printk(KERN_INFO "%s: invalid "
"response msglen %d offset %d "
"size %d\n", __func__,
phdr->msgLength,
surb->cb->offset,
urb->actual_length);
goto exit_and_resubmit; goto exit_and_resubmit;
} }
// move buffer pointer and copy header to its new location /* move buffer pointer and
* copy header to its new location */
memcpy((char *) phdr + surb->cb->offset, memcpy((char *) phdr + surb->cb->offset,
phdr, sizeof(SmsMsgHdr_ST)); phdr, sizeof(SmsMsgHdr_ST));
} } else
else
surb->cb->offset = 0; surb->cb->offset = 0;
smscore_onresponse(dev->coredev, surb->cb); smscore_onresponse(dev->coredev, surb->cb);
surb->cb = NULL; surb->cb = NULL;
} } else {
else printk(KERN_INFO "%s invalid response "
{ "msglen %d actual %d\n", __func__,
printk("%s invalid response msglen %d actual %d\n", __func__, phdr->msgLength, urb->actual_length); phdr->msgLength, urb->actual_length);
} }
} }
...@@ -115,12 +121,11 @@ void smsusb_onresponse(struct urb *urb) ...@@ -115,12 +121,11 @@ void smsusb_onresponse(struct urb *urb)
int smsusb_submit_urb(smsusb_device_t *dev, smsusb_urb_t *surb) int smsusb_submit_urb(smsusb_device_t *dev, smsusb_urb_t *surb)
{ {
if (!surb->cb) if (!surb->cb) {
{
surb->cb = smscore_getbuffer(dev->coredev); surb->cb = smscore_getbuffer(dev->coredev);
if (!surb->cb) if (!surb->cb) {
{ printk(KERN_INFO "%s smscore_getbuffer(...) "
printk(KERN_INFO "%s smscore_getbuffer(...) returned NULL\n", __func__); "returned NULL\n", __func__);
return -ENOMEM; return -ENOMEM;
} }
} }
...@@ -144,12 +149,10 @@ void smsusb_stop_streaming(smsusb_device_t *dev) ...@@ -144,12 +149,10 @@ void smsusb_stop_streaming(smsusb_device_t *dev)
{ {
int i; int i;
for (i = 0; i < MAX_URBS; i ++) for (i = 0; i < MAX_URBS; i ++) {
{
usb_kill_urb(&dev->surbs[i].urb); usb_kill_urb(&dev->surbs[i].urb);
if (dev->surbs[i].cb) if (dev->surbs[i].cb) {
{
smscore_putbuffer(dev->coredev, dev->surbs[i].cb); smscore_putbuffer(dev->coredev, dev->surbs[i].cb);
dev->surbs[i].cb = NULL; dev->surbs[i].cb = NULL;
} }
...@@ -160,12 +163,11 @@ int smsusb_start_streaming(smsusb_device_t *dev) ...@@ -160,12 +163,11 @@ int smsusb_start_streaming(smsusb_device_t *dev)
{ {
int i, rc; int i, rc;
for (i = 0; i < MAX_URBS; i ++) for (i = 0; i < MAX_URBS; i ++) {
{
rc = smsusb_submit_urb(dev, &dev->surbs[i]); rc = smsusb_submit_urb(dev, &dev->surbs[i]);
if (rc < 0) if (rc < 0) {
{ printk(KERN_INFO "%s smsusb_submit_urb(...) "
printk(KERN_INFO "%s smsusb_submit_urb(...) failed\n", __func__); "failed\n", __func__);
smsusb_stop_streaming(dev); smsusb_stop_streaming(dev);
break; break;
} }
...@@ -179,11 +181,11 @@ int smsusb_sendrequest(void *context, void *buffer, size_t size) ...@@ -179,11 +181,11 @@ int smsusb_sendrequest(void *context, void *buffer, size_t size)
smsusb_device_t *dev = (smsusb_device_t *) context; smsusb_device_t *dev = (smsusb_device_t *) context;
int dummy; int dummy;
return usb_bulk_msg(dev->udev, usb_sndbulkpipe(dev->udev, 2), buffer, size, &dummy, 1000); return usb_bulk_msg(dev->udev, usb_sndbulkpipe(dev->udev, 2),
buffer, size, &dummy, 1000);
} }
char *smsusb1_fw_lkup[] = char *smsusb1_fw_lkup[] = {
{
"dvbt_stellar_usb.inp", "dvbt_stellar_usb.inp",
"dvbh_stellar_usb.inp", "dvbh_stellar_usb.inp",
"tdmb_stellar_usb.inp", "tdmb_stellar_usb.inp",
...@@ -197,32 +199,31 @@ int smsusb1_load_firmware(struct usb_device *udev, int id) ...@@ -197,32 +199,31 @@ int smsusb1_load_firmware(struct usb_device *udev, int id)
u8 *fw_buffer; u8 *fw_buffer;
int rc, dummy; int rc, dummy;
if (id < DEVICE_MODE_DVBT || id > DEVICE_MODE_DVBT_BDA) if (id < DEVICE_MODE_DVBT || id > DEVICE_MODE_DVBT_BDA) {
{ printk(KERN_INFO "%s invalid firmware id specified %d\n",
printk(KERN_INFO "%s invalid firmware id specified %d\n", __func__, id); __func__, id);
return -EINVAL; return -EINVAL;
} }
rc = request_firmware(&fw, smsusb1_fw_lkup[id], &udev->dev); rc = request_firmware(&fw, smsusb1_fw_lkup[id], &udev->dev);
if (rc < 0) if (rc < 0) {
{ printk(KERN_INFO "%s failed to open \"%s\" mode %d\n",
printk(KERN_INFO "%s failed to open \"%s\" mode %d\n", __func__, smsusb1_fw_lkup[id], id); __func__, smsusb1_fw_lkup[id], id);
return rc; return rc;
} }
fw_buffer = kmalloc(fw->size, GFP_KERNEL); fw_buffer = kmalloc(fw->size, GFP_KERNEL);
if (fw_buffer) if (fw_buffer) {
{
memcpy(fw_buffer, fw->data, fw->size); memcpy(fw_buffer, fw->data, fw->size);
rc = usb_bulk_msg(udev, usb_sndbulkpipe(udev, 2), fw_buffer, fw->size, &dummy, 1000); rc = usb_bulk_msg(udev, usb_sndbulkpipe(udev, 2),
fw_buffer, fw->size, &dummy, 1000);
printk(KERN_INFO "%s: sent %d(%d) bytes, rc %d\n", __func__, fw->size, dummy, rc); printk(KERN_INFO "%s: sent %d(%d) bytes, rc %d\n",
__func__, fw->size, dummy, rc);
kfree(fw_buffer); kfree(fw_buffer);
} } else {
else
{
printk(KERN_INFO "failed to allocate firmware buffer\n"); printk(KERN_INFO "failed to allocate firmware buffer\n");
rc = -ENOMEM; rc = -ENOMEM;
} }
...@@ -238,14 +239,10 @@ void smsusb1_detectmode(void *context, int *mode) ...@@ -238,14 +239,10 @@ void smsusb1_detectmode(void *context, int *mode)
*mode = DEVICE_MODE_NONE; *mode = DEVICE_MODE_NONE;
if (!product_string) if (!product_string) {
{
product_string = "none"; product_string = "none";
printk("%s product string not found\n", __func__); printk("%s product string not found\n", __func__);
} } else if (strstr(product_string, "DVBH"))
else
{
if (strstr(product_string, "DVBH"))
*mode = 1; *mode = 1;
else if (strstr(product_string, "BDA")) else if (strstr(product_string, "BDA"))
*mode = 4; *mode = 4;
...@@ -253,18 +250,18 @@ void smsusb1_detectmode(void *context, int *mode) ...@@ -253,18 +250,18 @@ void smsusb1_detectmode(void *context, int *mode)
*mode = 0; *mode = 0;
else if (strstr(product_string, "TDMB")) else if (strstr(product_string, "TDMB"))
*mode = 2; *mode = 2;
}
printk("%s: %d \"%s\"\n", __func__, *mode, product_string); printk("%s: %d \"%s\"\n", __func__, *mode, product_string);
} }
int smsusb1_setmode(void *context, int mode) int smsusb1_setmode(void *context, int mode)
{ {
SmsMsgHdr_ST Msg = { MSG_SW_RELOAD_REQ, 0, HIF_TASK, sizeof(SmsMsgHdr_ST), 0 }; SmsMsgHdr_ST Msg = { MSG_SW_RELOAD_REQ, 0, HIF_TASK,
sizeof(SmsMsgHdr_ST), 0 };
if (mode < DEVICE_MODE_DVBT || mode > DEVICE_MODE_DVBT_BDA) if (mode < DEVICE_MODE_DVBT || mode > DEVICE_MODE_DVBT_BDA) {
{ printk(KERN_INFO "%s invalid firmware id specified %d\n",
printk(KERN_INFO "%s invalid firmware id specified %d\n", __func__, mode); __func__, mode);
return -EINVAL; return -EINVAL;
} }
...@@ -275,8 +272,7 @@ void smsusb_term_device(struct usb_interface *intf) ...@@ -275,8 +272,7 @@ void smsusb_term_device(struct usb_interface *intf)
{ {
smsusb_device_t *dev = (smsusb_device_t *) usb_get_intfdata(intf); smsusb_device_t *dev = (smsusb_device_t *) usb_get_intfdata(intf);
if (dev) if (dev) {
{
smsusb_stop_streaming(dev); smsusb_stop_streaming(dev);
// unregister from smscore // unregister from smscore
...@@ -299,9 +295,9 @@ int smsusb_init_device(struct usb_interface *intf) ...@@ -299,9 +295,9 @@ int smsusb_init_device(struct usb_interface *intf)
// create device object // create device object
dev = kzalloc(sizeof(smsusb_device_t), GFP_KERNEL); dev = kzalloc(sizeof(smsusb_device_t), GFP_KERNEL);
if (!dev) if (!dev) {
{ printk(KERN_INFO "%s kzalloc(sizeof(smsusb_device_t) failed\n",
printk(KERN_INFO "%s kzalloc(sizeof(smsusb_device_t) failed\n", __func__); __func__);
return -ENOMEM; return -ENOMEM;
} }
...@@ -336,7 +332,9 @@ int smsusb_init_device(struct usb_interface *intf) ...@@ -336,7 +332,9 @@ int smsusb_init_device(struct usb_interface *intf)
} }
dev->buffer_size = USB2_BUFFER_SIZE; dev->buffer_size = USB2_BUFFER_SIZE;
dev->response_alignment = dev->udev->ep_in[1]->desc.wMaxPacketSize - sizeof(SmsMsgHdr_ST); dev->response_alignment =
dev->udev->ep_in[1]->desc.wMaxPacketSize -
sizeof(SmsMsgHdr_ST);
params.flags |= SMS_DEVICE_FAMILY2; params.flags |= SMS_DEVICE_FAMILY2;
break; break;
...@@ -347,37 +345,37 @@ int smsusb_init_device(struct usb_interface *intf) ...@@ -347,37 +345,37 @@ int smsusb_init_device(struct usb_interface *intf)
params.num_buffers = MAX_BUFFERS; params.num_buffers = MAX_BUFFERS;
params.sendrequest_handler = smsusb_sendrequest; params.sendrequest_handler = smsusb_sendrequest;
params.context = dev; params.context = dev;
snprintf(params.devpath, sizeof(params.devpath), "usb\\%d-%s", dev->udev->bus->busnum, dev->udev->devpath); snprintf(params.devpath, sizeof(params.devpath),
"usb\\%d-%s", dev->udev->bus->busnum, dev->udev->devpath);
// register in smscore /* register in smscore */
rc = smscore_register_device(&params, &dev->coredev); rc = smscore_register_device(&params, &dev->coredev);
if (rc < 0) if (rc < 0) {
{ printk(KERN_INFO "%s smscore_register_device(...) failed, "
printk(KERN_INFO "%s smscore_register_device(...) failed, rc %d\n", __func__, rc); "rc %d\n", __func__, rc);
smsusb_term_device(intf); smsusb_term_device(intf);
return rc; return rc;
} }
// initialize urbs // initialize urbs
for (i = 0; i < MAX_URBS; i ++) for (i = 0; i < MAX_URBS; i++) {
{
dev->surbs[i].dev = dev; dev->surbs[i].dev = dev;
usb_init_urb(&dev->surbs[i].urb); usb_init_urb(&dev->surbs[i].urb);
} }
printk(KERN_INFO "%s smsusb_start_streaming(...).\n", __func__); printk(KERN_INFO "%s smsusb_start_streaming(...).\n", __func__);
rc = smsusb_start_streaming(dev); rc = smsusb_start_streaming(dev);
if (rc < 0) if (rc < 0) {
{ printk(KERN_INFO "%s smsusb_start_streaming(...) failed\n",
printk(KERN_INFO "%s smsusb_start_streaming(...) failed\n", __func__); __func__);
smsusb_term_device(intf); smsusb_term_device(intf);
return rc; return rc;
} }
rc = smscore_start_device(dev->coredev); rc = smscore_start_device(dev->coredev);
if (rc < 0) if (rc < 0) {
{ printk(KERN_INFO "%s smscore_start_device(...) failed\n",
printk(KERN_INFO "%s smscore_start_device(...) failed\n", __func__); __func__);
smsusb_term_device(intf); smsusb_term_device(intf);
return rc; return rc;
} }
...@@ -396,29 +394,32 @@ int smsusb_probe(struct usb_interface *intf, const struct usb_device_id *id) ...@@ -396,29 +394,32 @@ int smsusb_probe(struct usb_interface *intf, const struct usb_device_id *id)
rc = usb_clear_halt(udev, usb_rcvbulkpipe(udev, 0x81)); rc = usb_clear_halt(udev, usb_rcvbulkpipe(udev, 0x81));
rc = usb_clear_halt(udev, usb_rcvbulkpipe(udev, 0x02)); rc = usb_clear_halt(udev, usb_rcvbulkpipe(udev, 0x02));
if (intf->num_altsetting > 0) if (intf->num_altsetting > 0) {
{
rc = usb_set_interface(udev, intf->cur_altsetting->desc.bInterfaceNumber, 0); rc = usb_set_interface(udev, intf->cur_altsetting->desc.bInterfaceNumber, 0);
if (rc < 0) if (rc < 0) {
{ printk(KERN_INFO "%s usb_set_interface failed, "
printk(KERN_INFO "%s usb_set_interface failed, rc %d\n", __func__, rc); "rc %d\n", __func__, rc);
return rc; return rc;
} }
} }
printk(KERN_INFO "smsusb_probe %d\n", intf->cur_altsetting->desc.bInterfaceNumber); printk(KERN_INFO "smsusb_probe %d\n",
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 ++)
printk(KERN_INFO "endpoint %d %02x %02x %d\n", i, intf->cur_altsetting->endpoint[i].desc.bEndpointAddress, intf->cur_altsetting->endpoint[i].desc.bmAttributes, intf->cur_altsetting->endpoint[i].desc.wMaxPacketSize); printk(KERN_INFO "endpoint %d %02x %02x %d\n", i,
intf->cur_altsetting->endpoint[i].desc.bEndpointAddress,
intf->cur_altsetting->endpoint[i].desc.bmAttributes,
intf->cur_altsetting->endpoint[i].desc.wMaxPacketSize);
if (udev->actconfig->desc.bNumInterfaces == 2 && intf->cur_altsetting->desc.bInterfaceNumber == 0) if ((udev->actconfig->desc.bNumInterfaces == 2) &&
{ (intf->cur_altsetting->desc.bInterfaceNumber == 0)) {
printk(KERN_INFO "rom interface 0 is not used\n"); printk(KERN_INFO "rom interface 0 is not used\n");
return -ENODEV; return -ENODEV;
} }
if (intf->cur_altsetting->desc.bInterfaceNumber == 1) if (intf->cur_altsetting->desc.bInterfaceNumber == 1) {
{ snprintf(devpath, sizeof(devpath), "usb\\%d-%s",
snprintf(devpath, sizeof(devpath), "usb\\%d-%s", udev->bus->busnum, udev->devpath); udev->bus->busnum, udev->devpath);
printk(KERN_INFO "stellar device was found.\n"); printk(KERN_INFO "stellar device was found.\n");
return smsusb1_load_firmware(udev, smscore_registry_getmode(devpath)); return smsusb1_load_firmware(udev, smscore_registry_getmode(devpath));
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment