From 93553faeed1c4b0f03141bbb6791bafa8be4814d Mon Sep 17 00:00:00 2001 From: Oliver Schinagl Date: Tue, 21 Feb 2012 16:32:26 +0100 Subject: Fix compilation errors Thanks to Jozef Gercak some compilation errors are fixed. --- Makefile | 2 +- api/driver_tua8010.c | 4 +- api/driver_tua9001.c | 8 +- api/i2c_driver.c | 2 +- api/i2c_driver.h | 2 +- api/standard.c | 90 ++++++++---------- api/type.h | 11 +++ api/usb2impl.c | 13 ++- src/af903x-core.c | 33 +++---- src/af903x-devices.c | 138 ++++++++++----------------- src/af903x-drv.c | 257 ++++++++++++++++++++++----------------------------- src/af903x-fe.c | 42 +++++---- src/af903x-tuner.c | 4 +- src/af903x.h | 4 +- src/userdef.h | 2 + 15 files changed, 270 insertions(+), 342 deletions(-) diff --git a/Makefile b/Makefile index c162f7b..1a983a4 100644 --- a/Makefile +++ b/Makefile @@ -41,7 +41,7 @@ remove: @files='dvb-af903x.ko'; for i in $$files;do if [ -e $(KDIR26)/$$i ]; then echo -n "$$i "; rm $(KDIR26)/$$i; fi; done; for i in $$files;do if [ -e $(KDIR26)/$$i.gz ]; then echo -n "$$i.gz "; rm $(KDIR26)/$$i.gz; fi; done; echo; clean: - @-rm -f *~ *.o *.ko .*.o.cmd .*.ko.cmd *.mod.c *.*~ *.c *.h \ + @-rm -rf *~ *.o *.ko .*.o.cmd .*.ko.cmd *.mod.c *.*~ *.c *.h .tmp_versions \ demux.h dmxdev.h dvb-pll.h dvb-usb-ids.h dvb-usb.h dvb_demux.h dvb_frontend.h \ dvb_net.h dvb_ringbuffer.h dvbdev.h modules.order Module.markers Module.symvers diff --git a/api/driver_tua8010.c b/api/driver_tua8010.c index 7c9b0ec..6f34bde 100644 --- a/api/driver_tua8010.c +++ b/api/driver_tua8010.c @@ -31,8 +31,8 @@ Local compiler keeys ( usage depends on the application ) ============================================================================*/ #define CRYSTAL_26_MHZ -//#define CRYSTAL_19.2_MHZ -//#define CRYSTAL_20.48_MHZ +//#define CRYSTAL_19_MHZ +//#define CRYSTAL_20_MHZ //#define AGC_BY_IIC //#define AGC_BY_AGC_BUS diff --git a/api/driver_tua9001.c b/api/driver_tua9001.c index cf61fe9..04e2f76 100644 --- a/api/driver_tua9001.c +++ b/api/driver_tua9001.c @@ -32,8 +32,8 @@ Local compiler keeys ( usage depends on the application ) ============================================================================*/ #define CRYSTAL_26_MHZ -//#define CRYSTAL_19.2_MHZ -//#define CRYSTAL_20.48_MHZ +//#define CRYSTAL_19_MHZ +//#define CRYSTAL_20_MHZ //#define AGC_BY_IIC #define AGC_BY_AGC_BUS @@ -175,13 +175,13 @@ int initializeTua9001 (void) i2cseq[1] = 0x78; i2cBusWrite (TUNERs_TUA9001_DEVADDR, 0x40, i2cseq, 2); -#elif defined(CRYSTAL_19.2_MHZ) /* Frequency 19.2 MHz */ +#elif defined(CRYSTAL_19_MHZ) /* Frequency 19.2 MHz */ i2cseq[0] = 0x01; i2cseq[1] = 0xA0; i2cBusWrite (TUNERs_TUA9001_DEVADDR, 0x1d, i2cseq, 2); /* Note: Insert optimised register values for 0x40 / 0x41 for used crystal */ /* contact application support for further information */ -#elif defined(CRYSTAL_20.48_MHZ) /* Frequency 20,48 MHz */ +#elif defined(CRYSTAL_20_MHZ) /* Frequency 20.48 MHz */ i2cseq[0] = 0x01; i2cseq[1] = 0xA8; i2cBusWrite (TUNERs_TUA9001_DEVADDR, 0x1d, i2cseq, 2); diff --git a/api/i2c_driver.c b/api/i2c_driver.c index 5c5460d..ef6285d 100644 --- a/api/i2c_driver.c +++ b/api/i2c_driver.c @@ -37,7 +37,7 @@ int xc_read_i2c_data(unsigned char *bytes_received, int nb_bytes_to_receive) return (error); } -int xc_reset() +int xc_reset(void) { Dword error = Error_NO_ERROR; diff --git a/api/i2c_driver.h b/api/i2c_driver.h index 7826dce..5a76504 100644 --- a/api/i2c_driver.h +++ b/api/i2c_driver.h @@ -12,7 +12,7 @@ int xc_send_i2c_data(unsigned char *bytes_to_send, int nb_bytes_to_send); int xc_read_i2c_data(unsigned char *bytes_received, int nb_bytes_to_receive); // Does hardware reset -int xc_reset(); +int xc_reset(void); // Waits for wait_ms milliseconds void xc_wait(int wait_ms); diff --git a/api/standard.c b/api/standard.c index bcbe2fc..c677234 100644 --- a/api/standard.c +++ b/api/standard.c @@ -1,8 +1,6 @@ #include "standard.h" #include "cmd.h" #include "user.h" - - #include "firmware.h" #ifndef Firmware_FORMAT_VER1 @@ -108,7 +106,7 @@ Dword Standard_getDriver ( /** Close the key */ RegCloseKey(hKey); -exit : +exit: *handle = CreateFile (name, GENERIC_READ | GENERIC_WRITE, 0, NULL, OPEN_EXISTING, 0, NULL); return (error); @@ -231,7 +229,7 @@ Dword Standard_computeFcw ( *fcw = controlWord & 0x7FFFFF; -exit : +exit: return (error); } @@ -269,7 +267,7 @@ Dword Standard_programFcw ( error = Standard_writeRegister (demodulator, chip, Processor_OFDM, p_reg_bfs_fcw_22_16, temp2); if (error) goto exit; -exit : +exit: return (error); } @@ -295,7 +293,7 @@ Dword Standard_maskDcaOutput ( User_delay (demodulator, 5); } -exit : +exit: return (error); } @@ -935,7 +933,7 @@ Dword Standard_selectBandwidth ( error = Standard_writeRegisters (demodulator, chip, Processor_OFDM, cfoe_NS_2048_coeff1_25_24, 36, buffer); if (error) goto exit; -exit : +exit: return (error); } @@ -996,7 +994,7 @@ Dword Standard_setFrequency ( ganymede->frequency[chip] = frequency; -exit : +exit: return (error); } @@ -1077,7 +1075,7 @@ Dword Standard_loadFirmware ( if (version == 0) error = Error_BOOT_FAIL; -exit : +exit: return (error); } @@ -1190,7 +1188,7 @@ Dword Standard_loadScript ( if (error) goto exit; } -exit : +exit: return (error); } @@ -1737,7 +1735,7 @@ Dword Standard_readRegisterBits ( #endif -exit : +exit: return (error); } @@ -1761,7 +1759,7 @@ Dword Standard_getHardwareVersion ( /** HW Version = HWVer + Top_Ver */ *version = (Dword) (hwVer1 << 8) + (Dword) hwVer0; -exit : +exit: #endif return (error); @@ -1826,7 +1824,7 @@ Dword Standard_getFirmwareVersion ( if (error == 0x01000009) { /* Boot code*/ readBuffer[0] = readBuffer[1] = readBuffer[2] = readBuffer[3] = 0; error = 0; - } else if (error = 0x010000FA) { /* Firmware code*/ + } else if (error == 0x010000FA) { /* Firmware code*/ if (processor == Processor_LINK) { error = Standard_readRegisters (demodulator, 0, Processor_LINK, 0x83E9, 1, readBuffer); @@ -1861,7 +1859,7 @@ Dword Standard_getFirmwareVersion ( *version = (Dword) (((Dword) readBuffer[0] << 24) + ((Dword) readBuffer[1] << 16) + ((Dword) readBuffer[2] << 8) + (Dword) readBuffer[3]); -exit : +exit: #endif return (error); @@ -1911,7 +1909,7 @@ Dword Standard_getPostVitBer ( *postBitCount = bitCount * 204 * 8; } -exit : +exit: return (error); } @@ -1995,7 +1993,7 @@ Dword Standard_getSignalStrengthDbm ( *strengthDbm = (Long) (temp * -1); -exit : +exit: return (error); } @@ -2025,7 +2023,7 @@ Dword Standard_loadIrTable ( } } -exit : +exit: return (error); } @@ -2352,7 +2350,7 @@ Dword Standard_isTpsLocked ( if (error) goto exit; if (temp) *locked = True; -exit : +exit: #endif return (error); @@ -2376,7 +2374,7 @@ Dword Standard_isMpeg2Locked ( if (error) goto exit; if (temp) *locked = True; -exit : +exit: #endif return (error); @@ -2427,10 +2425,7 @@ Dword Standard_isLocked ( } #else Ganymede* ganymede; - ganymede = (Ganymede*) demodulator; - - *locked = False; if (ganymede->architecture == Architecture_DCA) { @@ -2517,7 +2512,7 @@ Dword Standard_isLocked ( ganymede->statistic[i].signalQuality = 0; ganymede->statistic[i].signalStrength = 20; } - + return (error); exit: #endif @@ -2571,7 +2566,7 @@ Dword Standard_reset ( if (error) goto exit; } -exit : +exit: #endif return (error); @@ -2662,7 +2657,7 @@ Dword Standard_getChannelModulation ( /** Get frequency */ channelModulation->frequency = ganymede->frequency[chip]; -exit : +exit: #endif return (error); @@ -2687,32 +2682,29 @@ Dword Standard_acquireChannel ( BOOL result; AcquireChannelRequest request; Ganymede* ganymede; - ganymede = (Ganymede*) demodulator; - if (ganymede->driver != NULL) { request.chip = chip; request.frequency = frequency; request.bandwidth = bandwidth; result = DeviceIoControl ( - ganymede->driver, - IOCTL_AFA_DEMOD_ACQUIRECHANNEL, - &request, - sizeof (request), - NULL, - 0, - &number, - NULL + ganymede->driver, + IOCTL_AFA_DEMOD_ACQUIRECHANNEL, + &request, + sizeof (request), + NULL, + 0, + &number, + NULL ); error = request.error; } else { error = Error_DRIVER_INVALID; } #else - Ganymede* ganymede; + Ganymede* ganymede; ganymede = (Ganymede*) demodulator; - if (ganymede->architecture == Architecture_DCA) { begin = 0; end = ganymede->chipNumber; @@ -2737,7 +2729,7 @@ Dword Standard_acquireChannel ( if (error) goto exit; } -exit : +exit: #endif return (error); @@ -2775,7 +2767,6 @@ Dword Standard_setStreamType ( error = Error_DRIVER_INVALID; } #else - Dword warning = Error_NO_ERROR; Ganymede* ganymede; Byte i; @@ -2917,12 +2908,14 @@ Dword Standard_setStreamType ( } } break; + default: + break; } error = User_mpegConfig (demodulator); ganymede->streamType = streamType; -exit : +exit: #endif return (error); @@ -3441,7 +3434,7 @@ Dword Standard_getStatistic ( *statistic = ganymede->statistic[chip]; -exit : +exit: #endif return (error); @@ -3595,7 +3588,6 @@ Dword Standard_getDatagram ( Ganymede* ganymede; Dword length = 0; Byte value; - Bool ready = False; ganymede = (Ganymede*) demodulator; @@ -3676,7 +3668,7 @@ Dword Standard_getIrCode ( *code = (Dword) ((readBuffer[0] << 24) + (readBuffer[1] << 16) + (readBuffer[2] << 8) + readBuffer[3]); -exit : +exit: return (error); } @@ -3722,7 +3714,7 @@ Dword Standard_reboot ( ganymede->booted = False; -exit : +exit: return (error); } @@ -3846,7 +3838,7 @@ Dword Standard_controlPowerSaving ( } } -exit : +exit: #endif return (error); @@ -3939,7 +3931,7 @@ Dword Standard_resetPidFilter ( error = Standard_writeRegisterBits (demodulator, chip, Processor_OFDM, p_mp2if_pid_rst, mp2if_pid_rst_pos, mp2if_pid_rst_len, 1); if (error) goto exit; -exit : +exit: #endif return (error); @@ -4001,7 +3993,7 @@ Dword Standard_addPidToFilter ( error = Standard_writeRegister (demodulator, chip, Processor_OFDM, p_mp2if_pid_index, index); if (error) goto exit; -exit : +exit: #endif return (error); @@ -4056,7 +4048,7 @@ Dword Standard_setBurstSize ( break; } -exit : +exit: return (error); } @@ -4088,6 +4080,6 @@ Dword Standard_getBurstSize ( } } -exit : +exit: return (error); } diff --git a/api/type.h b/api/type.h index df56aad..d7cf236 100644 --- a/api/type.h +++ b/api/type.h @@ -3,6 +3,17 @@ #include "userdef.h"// for Linux + + +#ifdef IN +#undef IN +#endif + +#ifdef OUT +#undef OUT +#endif + + #define IN #define OUT #define INOUT diff --git a/api/usb2impl.c b/api/usb2impl.c index 30e6265..5fb785a 100644 --- a/api/usb2impl.c +++ b/api/usb2impl.c @@ -1,12 +1,11 @@ // all for Linux -#include +#include #include #include #include #include #include #include -#include #include #include #include @@ -128,17 +127,17 @@ Dword Usb2_writeControlBus ( IN Byte* buffer ) { -// Ganymede *pGanymede = (Ganymede *)demodulator; Dword ret,act_len; ret = 0; +// printk("- Enter %s Function -\n",__FUNCTION__); ret = usb_bulk_msg(usb_get_dev(udevs), usb_sndbulkpipe(usb_get_dev(udevs), 0x02), buffer, bufferLength, &act_len, 100000); - - if (ret) deb_data(" Usb2_writeControlBus fail : %d!\n", ret); + + if (ret) printk(" Usb2_writeControlBus fail : %d!\n", (int) ret); return (Error_NO_ERROR); } @@ -150,9 +149,9 @@ Dword Usb2_readControlBus ( OUT Byte* buffer ) { -// Ganymede *pGanymede = (Ganymede *)demodulator; Dword ret, nBytesRead; ret = 0; +// printk("- Enter %s Function -\n",__FUNCTION__); ret = usb_bulk_msg(usb_get_dev(udevs), usb_rcvbulkpipe(usb_get_dev(udevs),129), buffer, @@ -161,7 +160,7 @@ Dword Usb2_readControlBus ( 100000); - if (ret) deb_data(" Usb2_readControlBus fail : %d!\n", ret); + if (ret) printk(" Usb2_readControlBus fail : %d!\n", (int) ret); return (Error_NO_ERROR); } diff --git a/src/af903x-core.c b/src/af903x-core.c index cf69d6a..5d49694 100644 --- a/src/af903x-core.c +++ b/src/af903x-core.c @@ -10,10 +10,10 @@ static int af903x_probe(struct usb_interface *intf, int retval = -ENOMEM; int i; - deb_data("===af903x usb device pluged in!! ===\n"); + printk("===af903x usb device pluged in!! ===\n"); retval = Device_init(interface_to_usbdev(intf),&DC, true); if (retval){ - if(retval) deb_data("Device_init Fail: 0x%08x\n", retval); + printk("Device_init Fail: 0x%08x\n", retval); return retval; } @@ -22,23 +22,16 @@ static int af903x_probe(struct usb_interface *intf, for (i = 0; i < af903x_device_count; i++) { -#if LINUX_VERSION_CODE > KERNEL_VERSION(2,6,18) if (DC.architecture == Architecture_PIP) af903x_properties[i].num_adapters = 2; -#endif - -#if LINUX_VERSION_CODE <= KERNEL_VERSION(2,6,25) - if (dvb_usb_device_init(intf, &af903x_properties[i], THIS_MODULE, NULL) == 0) - {deb_data("dvb_usb_device_init success!!\n");return 0;} -#else if (dvb_usb_device_init(intf, &af903x_properties[i], THIS_MODULE, NULL,adapter_nr) == 0) - {deb_data("dvb_usb_device_init success!!\n");return 0;} -#endif + {printk("dvb_usb_device_init success!!\n");return 0;} } return -ENOMEM; } -static int af903x_suspend(struct usb_interface *intf, u32 state) + +/*static int af903x_suspend(struct usb_interface *intf, u32 state) { int error; deb_data("Enter %s Function\n",__FUNCTION__); @@ -48,8 +41,8 @@ static int af903x_suspend(struct usb_interface *intf, u32 state) #else if (DevicePower) { - error = DL_CheckTunerInited(0, &TunerInited0); - error = DL_CheckTunerInited(1, &TunerInited1); + error = DL_CheckTunerInited(0, (Bool *) &TunerInited0); + error = DL_CheckTunerInited(1, (Bool *) &TunerInited1); error = DL_ApCtrl(0, 0); error = DL_ApCtrl(1, 0); @@ -59,9 +52,9 @@ static int af903x_suspend(struct usb_interface *intf, u32 state) } #endif return 0; -} +}*/ -static int af903x_resume(struct usb_interface *intf) +/*static int af903x_resume(struct usb_interface *intf) { int retval = -ENOMEM; int error; @@ -73,7 +66,7 @@ static int af903x_resume(struct usb_interface *intf) { retval = Device_init(interface_to_usbdev(intf),&DC, false); if (retval) - if(retval) deb_data("Device_init Fail: 0x%08x\n", retval); + if(retval) printk("Device_init Fail: 0x%08x\n", retval); if (TunerInited0) error = DL_ApCtrl(0, 1); @@ -82,7 +75,7 @@ static int af903x_resume(struct usb_interface *intf) } #endif return 0; -} +}*/ static struct usb_driver af903x_driver = { @@ -102,7 +95,7 @@ static int __init af903x_module_init(void) int result; info("%s",__FUNCTION__); - deb_data("dvb_usb_af903x Module is loaded \n"); + printk("dvb_usb_af903x Module is loaded \n"); if ((result = usb_register(&af903x_driver))) { err("usb_register failed. Error number %d",result); @@ -113,7 +106,7 @@ static int __init af903x_module_init(void) static void __exit af903x_module_exit(void) { - deb_data("dvb_usb_af903x Module is unloaded!\n"); + printk("dvb_usb_af903x Module is unloaded!\n"); usb_deregister(&af903x_driver); } diff --git a/src/af903x-devices.c b/src/af903x-devices.c index c8691cd..8e82aaa 100644 --- a/src/af903x-devices.c +++ b/src/af903x-devices.c @@ -4,7 +4,6 @@ bool DevicePower; static int af903x_pid_filter_ctrl(struct dvb_usb_adapter *adap, int onoff) { int ret =0; -#if LINUX_VERSION_CODE > KERNEL_VERSION(2,6,18) deb_data("%s: onoff:%d\n", __func__, onoff); if ( PDC->fc[adap->id].bEnPID != onoff ) @@ -13,7 +12,6 @@ static int af903x_pid_filter_ctrl(struct dvb_usb_adapter *adap, int onoff) PDC->fc[adap->id].bEnPID = onoff; DL_PIDOnOff((BYTE)adap->id,onoff); -#endif return ret; } @@ -22,7 +20,6 @@ static int af903x_pid_filter(struct dvb_usb_adapter *adap, int index, u16 pidnum int onoff) { int ret = 0; - #if LINUX_VERSION_CODE > KERNEL_VERSION(2,6,18) Pid pid; deb_data("- %s: set pid filter, index %d, pid %x, onoff %d, now_onoff %d.\n", __func__, index, pidnum, onoff, PDC->fc[adap->id].bEnPID); @@ -43,8 +40,6 @@ static int af903x_pid_filter(struct dvb_usb_adapter *adap, int index, u16 pidnum }else{ ret = DL_RemovePID((BYTE)adap->id, index, pid); } -#endif - return ret; } @@ -62,15 +57,9 @@ static int af903x_powerctrl(struct dvb_usb_device *d, int onoff) int ret; DevicePower = onoff; -#if LINUX_VERSION_CODE > KERNEL_VERSION(2,6,18) deb_data("- Enter %s Function - chip=%d:%s\n",__FUNCTION__, d->adapter->id, onoff?"ON":"OFF"); ret = DL_ApCtrl(d->adapter->id, onoff); -#else - deb_data("- Enter %s Function - %s\n",__FUNCTION__, onoff?"ON":"OFF"); - ret = DL_ApCtrl(0, onoff); -#endif if(ret) deb_data(" af903x_powerctrl Fail: 0x%04X\n", ret); - return ret; } @@ -85,89 +74,59 @@ static int af903x_identify_state(struct usb_device *udev, struct dvb_usb_device_ static int af903x_frontend_attach(struct dvb_usb_adapter *adap) { -#if LINUX_VERSION_CODE > KERNEL_VERSION(2,6,18) deb_data("- Enter %s Function - chip=%d\n", __FUNCTION__, adap->id); -#else - deb_data("- Enter %s Function - \n", __FUNCTION__); -#endif adap->fe = af903x_attach(1); - return adap->fe == NULL ? -ENODEV : 0; } static int af903x_tuner_attach(struct dvb_usb_adapter *adap) { -#if LINUX_VERSION_CODE > KERNEL_VERSION(2,6,18) deb_data("- Enter %s Function - chip=%d\n",__FUNCTION__, adap->id); -#else - deb_data("- Enter %s Function - \n", __FUNCTION__); -#endif tuner_attach(adap->fe); return 0; } static int af903x_streaming_ctrl(struct dvb_usb_adapter *adap, int onoff) { -#if LINUX_VERSION_CODE > KERNEL_VERSION(2,6,18) deb_data("- Enter %s Function - (%s) streaming state for chip=%d\n",__FUNCTION__, onoff?"ON":"OFF", adap->id); //PID off DL_ResetPID((BYTE)adap->id); PDC->fc[adap->id].bEnPID = 0; DL_PIDOnOff((BYTE)adap->id,0); -#else - deb_data("- Enter %s Function - (%s) streaming state \n",__FUNCTION__, onoff?"ON":"OFF"); -#endif - return 0; } + struct usb_device_id af903x_usb_id_table[] = { - { USB_DEVICE(0x15A4,0x1000) }, - { USB_DEVICE(0x15A4,0x1001) }, - { USB_DEVICE(0x15A4,0x1002) }, - { USB_DEVICE(0x15A4,0x1003) }, - { USB_DEVICE(0x15A4,0x9035) }, - { USB_DEVICE(USB_VID_ASUS, USB_PID_ASUS_U3100MINI_PLUS) }, - { 0}, /* Terminating entry */ + { USB_DEVICE(0x15A4,0x1000) }, + { USB_DEVICE(0x15A4,0x1001) }, + { USB_DEVICE(0x15A4,0x1002) }, + { USB_DEVICE(0x15A4,0x1003) }, + { USB_DEVICE(0x15A4,0x9035) }, + { USB_DEVICE(USB_VID_ASUS, USB_PID_ASUS_U3100MINI_PLUS) }, + { 0}, /* Terminating entry */ }; + MODULE_DEVICE_TABLE(usb, af903x_usb_id_table); struct dvb_usb_device_properties af903x_properties[] = { { - .usb_ctrl = DEVICE_SPECIFIC, + .usb_ctrl = DEVICE_SPECIFIC, .download_firmware = af903x_download_firmware, - .no_reconnect = 1, - .power_ctrl = af903x_powerctrl, - .identify_state = af903x_identify_state, - -#if LINUX_VERSION_CODE == KERNEL_VERSION(2,6,18) - .caps = DVB_USB_HAS_PID_FILTER | DVB_USB_NEED_PID_FILTERING, - .pid_filter_count = 32, - .frontend_attach = af903x_frontend_attach, - .tuner_attach = af903x_tuner_attach, - .streaming_ctrl = af903x_streaming_ctrl, - .urb = { - .type = DVB_USB_BULK, - .count = 10, - .endpoint = 0x84, - .u = { - .bulk = { - .buffersize = 65424, - } - } - }, -#else - .num_adapters = 1, + .no_reconnect = 1, + .power_ctrl = af903x_powerctrl, + .identify_state = af903x_identify_state, + .num_adapters = 2, .adapter = { { .caps = DVB_USB_ADAP_HAS_PID_FILTER | DVB_USB_ADAP_PID_FILTER_CAN_BE_TURNED_OFF, .pid_filter_count = 32, - .pid_filter = af903x_pid_filter, - .pid_filter_ctrl = af903x_pid_filter_ctrl, - .frontend_attach = af903x_frontend_attach, - .tuner_attach = af903x_tuner_attach, - .streaming_ctrl = af903x_streaming_ctrl, - .stream = { + .pid_filter = af903x_pid_filter, + .pid_filter_ctrl = af903x_pid_filter_ctrl, + .frontend_attach = af903x_frontend_attach, + .tuner_attach = af903x_tuner_attach, + .streaming_ctrl = af903x_streaming_ctrl, + .stream = { .type = USB_BULK, .count = 4, .endpoint = 0x84, @@ -177,47 +136,50 @@ struct dvb_usb_device_properties af903x_properties[] = { } } } - }, - { + }, { .caps = DVB_USB_ADAP_HAS_PID_FILTER | DVB_USB_ADAP_PID_FILTER_CAN_BE_TURNED_OFF, .pid_filter_count = 32, - .pid_filter = af903x_pid_filter, - .pid_filter_ctrl = af903x_pid_filter_ctrl, - .frontend_attach = af903x_frontend_attach, - .tuner_attach = af903x_tuner_attach, - .streaming_ctrl = af903x_streaming_ctrl, + .pid_filter = af903x_pid_filter, + .pid_filter_ctrl = af903x_pid_filter_ctrl, + .frontend_attach = af903x_frontend_attach, + .tuner_attach = af903x_tuner_attach, + .streaming_ctrl = af903x_streaming_ctrl, .stream = { .type = USB_BULK, .count = 4, .endpoint = 0x85, .u = { - .bulk = { - .buffersize = 65424, - } + .bulk = { + .buffersize = 65424, + } } } }, }, -#endif .num_device_descs = 2, - .devices = { - {"ITEtech USB2.0 DVB-T Receiver", - {&af903x_usb_id_table[0], - &af903x_usb_id_table[1], - &af903x_usb_id_table[2], - &af903x_usb_id_table[3], - &af903x_usb_id_table[4], - NULL}, - {NULL}, - }, - {"Asus U3100MINI_PLUS/T/RC Receiver", - {&af903x_usb_id_table[5], - NULL}, - {NULL}, + .devices = { + { + "ITEtech USB2.0 DVB-T Receiver", { + &af903x_usb_id_table[0], + &af903x_usb_id_table[1], + &af903x_usb_id_table[2], + &af903x_usb_id_table[3], + &af903x_usb_id_table[4], + NULL + }, { + NULL + } + }, { + "Asus U3100MINI_PLUS/T/RC Receiver", { + &af903x_usb_id_table[5], + NULL + }, { + NULL + } }, { NULL - }, - } + } + } } }; diff --git a/src/af903x-drv.c b/src/af903x-drv.c index 6ba44bf..ea1d7f2 100644 --- a/src/af903x-drv.c +++ b/src/af903x-drv.c @@ -1,4 +1,5 @@ #include "af903x.h" +#include "firmware.h" #define FW_VER 0x08060000 int dvb_usb_af903x_debug; @@ -18,7 +19,7 @@ static DWORD DRV_IrTblDownload(IN void * handle) PDEVICE_CONTEXT pdc = (PDEVICE_CONTEXT)handle; struct file *filp; unsigned char b_buf[512] ; - int i, fileSize; + int fileSize; mm_segment_t oldfs; deb_data("- Enter %s Function -\n",__FUNCTION__); @@ -28,32 +29,24 @@ static DWORD DRV_IrTblDownload(IN void * handle) filp=filp_open("/lib/firmware/af35irtbl.bin", O_RDWR,0644); if ( IS_ERR(filp) ) { - deb_data(" LoadIrTable : Can't open file\n");goto exit;} + printk(" LoadIrTable : Can't open file\n");goto exit;} if ( (filp->f_op) == NULL ) { - deb_data(" LoadIrTable : File Operation Method Error!!\n");goto exit;} - + printk(" LoadIrTable : File Operation Method Error!!\n");goto exit;} + deb_data("/lib/firmware/af35irtbl.bin - fw loaded"); filp->f_pos=0x00; fileSize = filp->f_op->read(filp,b_buf,sizeof(b_buf),&filp->f_pos); - for(i=0; iDemodulator, (Word)fileSize, b_buf); - if (dwError) {deb_data("Demodulator_loadIrTable fail"); goto exit;} + if (dwError) {printk("Demodulator_loadIrTable fail"); goto exit;} filp_close(filp, NULL); set_fs(oldfs); return (dwError); exit: - deb_data("LoadIrTable fail!\n"); - + printk("LoadIrTable fail!\n"); + return (dwError); } static DWORD DRV_GetEEPROMConfig2( @@ -88,13 +81,11 @@ static DWORD DRV_SetFreqBw( ) { DWORD dwError = Error_NO_ERROR; - PDEVICE_CONTEXT pdc = (PDEVICE_CONTEXT)handle; - Bool bLock = true; deb_data("- Enter %s Function -\n ",__FUNCTION__); - deb_data(" ucSlaveDemod = %d, Freq= %d, BW=%d\n", ucSlaveDemod, dwFreq, ucBw); + deb_data(" ucSlaveDemod = %d, Freq= %d, BW=%d\n", (int) ucSlaveDemod, (int) dwFreq, (int) ucBw); if (pdc->fc[ucSlaveDemod].bEnPID) { @@ -120,7 +111,7 @@ static DWORD DRV_SetFreqBw( ucBw = pdc->fc[ucSlaveDemod].ucDesiredBandWidth; } - deb_data(" Real Freq= %d, BW=%d\n", pdc->fc[ucSlaveDemod].ulDesiredFrequency, pdc->fc[ucSlaveDemod].ucDesiredBandWidth); + deb_data(" Real Freq= %d, BW=%d\n", (int) pdc->fc[ucSlaveDemod].ulDesiredFrequency, (int) pdc->fc[ucSlaveDemod].ucDesiredBandWidth); if(!PTI.bTunerInited){ @@ -132,12 +123,12 @@ static DWORD DRV_SetFreqBw( if (pdc->fc[ucSlaveDemod].ulDesiredFrequency!=0 && pdc->fc[ucSlaveDemod].ucDesiredBandWidth!=0) { - deb_data(" AcquireChannel : Real Freq= %d, BW=%d\n", pdc->fc[ucSlaveDemod].ulDesiredFrequency, pdc->fc[ucSlaveDemod].ucDesiredBandWidth); + deb_data(" AcquireChannel : Real Freq= %d, BW=%d\n",(int) pdc->fc[ucSlaveDemod].ulDesiredFrequency,(int) pdc->fc[ucSlaveDemod].ucDesiredBandWidth); dwError = Demodulator_acquireChannel ((Demodulator*) &pdc->Demodulator, ucSlaveDemod, pdc->fc[ucSlaveDemod].ucDesiredBandWidth, pdc->fc[ucSlaveDemod].ulDesiredFrequency); //PTI.bSettingFreq = false; if (dwError) { - deb_data(" Demod_acquireChannel fail! 0x%08x\n", dwError); + printk(" Demod_acquireChannel fail! 0x%08x\n", (int) dwError); goto exit; } else //when success acquireChannel, record currentFreq/currentBW. @@ -151,10 +142,10 @@ static DWORD DRV_SetFreqBw( PDC->fc[ucSlaveDemod].OvrFlwChk = 5; } - /*if (pdc->fc[ucSlaveDemod].ulDesiredFrequency!=0 && pdc->fc[ucSlaveDemod].ucDesiredBandWidth!=0) + if (pdc->fc[ucSlaveDemod].ulDesiredFrequency!=0 && pdc->fc[ucSlaveDemod].ucDesiredBandWidth!=0) { // patch for Demodulator_isLocked - //mdelay(700); + mdelay(700); dwError= Demodulator_isLocked((Demodulator*) &pdc->Demodulator, ucSlaveDemod, &bLock); if(dwError) @@ -168,7 +159,7 @@ static DWORD DRV_SetFreqBw( mdelay(500); } } - }*/ + } PTI.bTunerOK = true; @@ -179,20 +170,13 @@ exit: return(dwError); } -DWORD DRV_ResetPID( - IN void* handle, - IN BYTE chip -) -{ - deb_data("- Enter %s Function -\n ",__FUNCTION__); - - DWORD dwError = Error_NO_ERROR; +DWORD DRV_ResetPID( IN void* handle, IN BYTE chip){ + DWORD dwError = Error_NO_ERROR; PDEVICE_CONTEXT pdc = (PDEVICE_CONTEXT)handle; - + deb_data("- Enter %s Function -\n ",__FUNCTION__); //Clear pidTable dwError = Demodulator_resetPid ((Demodulator*) &pdc->Demodulator, chip); - return(dwError); } @@ -203,12 +187,13 @@ DWORD DRV_AddPID( IN Byte index, IN Pid pid ) + { - deb_data("- Enter %s Function - , index:%d, pid:%x \n",__FUNCTION__, index, pid.value); DWORD dwError = Error_NO_ERROR; PDEVICE_CONTEXT pdc = (PDEVICE_CONTEXT)handle; + deb_data("- Enter %s Function - , index:%d, pid:%x \n",__FUNCTION__, index, pid.value); dwError = Demodulator_addPidToFilter ((Demodulator*) &pdc->Demodulator, ucSlaveDemod,index, pid); @@ -223,11 +208,11 @@ DWORD DRV_RemovePID( IN Pid pid ) { - deb_data("- Enter %s Function - , index:%d, pid:%x \n",__FUNCTION__, index, pid.value); DWORD dwError = Error_NO_ERROR; PDEVICE_CONTEXT pdc = (PDEVICE_CONTEXT)handle; + deb_data("- Enter %s Function - , index:%d, pid:%x \n",__FUNCTION__, index, pid.value); dwError = Demodulator_removePidAt ((Demodulator*) &pdc->Demodulator, ucSlaveDemod,index, pid); @@ -241,11 +226,11 @@ DWORD DRV_PIDOnOff( IN bool bOn ) { - deb_data("- Enter %s Function -onoff:%d\n ",__FUNCTION__, bOn); DWORD dwError = Error_NO_ERROR; PDEVICE_CONTEXT pdc = (PDEVICE_CONTEXT)handle; + deb_data("- Enter %s Function -onoff:%d\n ",__FUNCTION__, bOn); if (bOn) dwError = Demodulator_controlPidFilter ((Demodulator*) &pdc->Demodulator, ucSlaveDemod, 1); @@ -310,7 +295,7 @@ static DWORD DRV_getSignalStrengthDbm( if(dwError) deb_data(" Demodulator_getSignalStrengthDbm is failed!\n"); else - deb_data(" The signal strengthDbm is %d \n", *strengthDbm); + deb_data(" The signal strengthDbm is %d \n", ( int ) *strengthDbm); return(dwError); } @@ -424,16 +409,16 @@ static DWORD DRV_Initialize( //use "Command_QUERYINFO" to get fw version error = Demodulator_getFirmwareVersion((Demodulator*) &pdc->Demodulator, Processor_OFDM, &cmdVersion); - if(error) deb_data("DRV_Initialize : Demodulator_getFirmwareVersion : error = 0x%08x\n", error); + if(error) deb_data("DRV_Initialize : Demodulator_getFirmwareVersion : error = 0x%08x\n",(int) error); if(cmdVersion != fileVersion) { - deb_data("Reboot: Outside Fw = 0x%X, Inside Fw = 0x%X", fileVersion, cmdVersion); + deb_data("Reboot: Outside Fw = 0x%X, Inside Fw = 0x%X", (int) fileVersion, (int) cmdVersion); error = Demodulator_reboot((Demodulator*) &pdc->Demodulator); pdc->bBootCode = true; if(error) { - deb_data("Demodulator_reboot : error = 0x%08x\n", error); + deb_data("Demodulator_reboot : error = 0x%08x\n",(int) error); return error; } else { @@ -442,7 +427,7 @@ static DWORD DRV_Initialize( } else { - deb_data(" Fw version is the same!\n"); + printk(" Fw version is the same!\n"); error = Error_NO_ERROR; } }//pdc->Demodulator.booted @@ -451,12 +436,12 @@ ReInit: //Patch for NIM fail or disappear, Maggie error = Demodulator_initialize ((Demodulator*) &pdc->Demodulator, pdc->Demodulator.chipNumber , 8000, pdc->StreamType, pdc->architecture); if (error) { - deb_data("Device initialize fail : 0x%08x\n", error); + printk("Device initialize fail : 0x%08x\n", (int) error); if( ((error&Error_FIRMWARE_STATUS) && (error&0x10)) && (pdc->Demodulator.chipNumber>1) ) { pdc->Demodulator.cmdDescription->sendCommand ((Demodulator*) &pdc->Demodulator, Command_FW_DOWNLOAD_END, 0, Processor_LINK, 0, NULL, 0, NULL); - deb_data(" Retry to download FW with Single TS\n"); + printk(" Retry to download FW with Single TS\n"); pdc->Demodulator.chipNumber = 1; pdc->bDualTs = false; error = Demodulator_writeRegister ((Demodulator*) &pdc->Demodulator, 0, Processor_LINK, 0x417F, 0); @@ -464,13 +449,13 @@ ReInit: //Patch for NIM fail or disappear, Maggie } } else { - deb_data(" Device initialize Ok!!\n"); + printk(" Device initialize Ok!!\n"); } Demodulator_getFirmwareVersion ((Demodulator*) &pdc->Demodulator, Processor_OFDM, &cmdVersion); - deb_data(" FwVer OFDM = 0x%X, ", cmdVersion); + deb_data(" FwVer OFDM = 0x%X, ", (int) cmdVersion); Demodulator_getFirmwareVersion ((Demodulator*) &pdc->Demodulator, Processor_LINK, &cmdVersion); - deb_data("FwVer LINK = 0x%X\n", cmdVersion); + deb_data("FwVer LINK = 0x%X\n", (int) cmdVersion); return error; @@ -487,7 +472,7 @@ static DWORD DRV_InitDevInfo( PDC->fc[ucSlaveDemod].ucCurrentBandWidth = 0; PDC->fc[ucSlaveDemod].ulDesiredFrequency = 0; - PDC->fc[ucSlaveDemod].ucDesiredBandWidth = 6000; + PDC->fc[ucSlaveDemod].ucDesiredBandWidth = 8000; //For PID Filter Setting //PDC->fc[ucSlaveDemod].ulcPIDs = 0; @@ -520,8 +505,8 @@ static DWORD DRV_GetEEPROMConfig( dwError = Demodulator_readRegisters((Demodulator*) &pdc->Demodulator, 0, Processor_LINK, EEPROM_IRMODE, 1, &btmp); if (dwError) return(dwError); PDC->bIrTblDownload = btmp ? true:false; - deb_data( "EEPROM_IRMODE = 0x%02X, ", btmp); - deb_data("bIrTblDownload %s\n", PDC->bIrTblDownload?"ON":"OFF"); + printk( "EEPROM_IRMODE = 0x%02X, ", btmp); + printk("bIrTblDownload %s\n", PDC->bIrTblDownload?"ON":"OFF"); PDC->bDualTs = false; PDC->architecture = Architecture_DCA; @@ -531,13 +516,13 @@ static DWORD DRV_GetEEPROMConfig( //bDualTs option dwError = Demodulator_readRegisters((Demodulator*) &pdc->Demodulator, 0, Processor_LINK,EEPROM_TSMODE, 1, &btmp); if (dwError) return(dwError); - deb_data("EEPROM_TSMODE = 0x%02X", btmp); + printk("EEPROM_TSMODE = 0x%02X", btmp); if (btmp == 0) - deb_data("TSMode = TS1 mode\n"); + printk("TSMode = TS1 mode\n"); else if (btmp == 1) { - deb_data("TSMode = DCA+PIP mode\n"); + printk("TSMode = DCA+PIP mode\n"); PDC->architecture = Architecture_DCA; PDC->Demodulator.chipNumber = 2; PDC->bDualTs = true; @@ -566,6 +551,7 @@ static DWORD DRV_GetEEPROMConfig( for(ucSlaveDemod; ucSlaveDemod < cnt; ucSlaveDemod++) { + deb_data("ucSlaveDemod: %d \n",cnt); dwError = DRV_GetEEPROMConfig2(pdc, ucSlaveDemod); if (dwError) return(dwError); dwError = DRV_InitDevInfo(pdc, ucSlaveDemod); @@ -590,8 +576,8 @@ static DWORD DRV_SetBusTuner( deb_data("busId = 0x%x, tunerId =0x%x\n", busId, tunerId); if ((pdc->UsbMode==0x0110) && (busId==Bus_USB)) { - busId=Bus_USB11; - } + busId=Bus_USB11; + } dwError = Demodulator_setBusTuner ((Demodulator*) &pdc->Demodulator, busId, tunerId); if (dwError) {deb_data("Demodulator_setBusTuner error\n");return dwError;} @@ -637,7 +623,7 @@ static DWORD DRV_TunerPowerCtrl( { dwError = Demodulator_writeRegisterBits((Demodulator*) &pdc->Demodulator, 0, Processor_LINK, p_reg_top_gpioh7_o, reg_top_gpioh7_o_pos, reg_top_gpioh7_o_len, 1); - if(pdc->bTunerPowerOff == true) + if( pdc->bTunerPowerOff == (Bool) true) { dwError = Demodulator_initialize ((Demodulator*) &pdc->Demodulator, pdc->Demodulator.chipNumber , pdc->Demodulator.bandwidth[0], pdc->StreamType, pdc->architecture); pdc->bTunerPowerOff = false; @@ -647,9 +633,9 @@ static DWORD DRV_TunerPowerCtrl( { if(pdc->architecture == Architecture_PIP) { - if(pdc->fc[0].tunerinfo.bTunerInited == false && pdc->fc[1].tunerinfo.bTunerInited == false) + if(pdc->fc[0].tunerinfo.bTunerInited == (Bool) false && pdc->fc[1].tunerinfo.bTunerInited == (Bool) false) { - if(pdc->bTunerPowerOff == false) + if(pdc->bTunerPowerOff == (Bool) false) { dwError = Demodulator_finalize((Demodulator*) &pdc->Demodulator); pdc->bTunerPowerOff = true; @@ -660,7 +646,7 @@ static DWORD DRV_TunerPowerCtrl( } else { - if(pdc->bTunerPowerOff == false) + if(pdc->bTunerPowerOff == (Bool) false) { dwError = Demodulator_finalize((Demodulator*) &pdc->Demodulator); pdc->bTunerPowerOff = true; @@ -689,11 +675,11 @@ static DWORD DRV_ApCtrl ( //deb_data("enter DRV_ApCtrl: Demod[%d].GraphBuilt = %d", ucSlaveDemod, pdc->fc[ucSlaveDemod].GraphBuilt); dwError = DRV_TunerPowerCtrl(pdc, ucSlaveDemod, bOn); - if(dwError) { deb_data(" DRV_TunerPowerCtrl Fail: 0x%08x\n", dwError); return(dwError);} + if(dwError) { deb_data(" DRV_TunerPowerCtrl Fail: 0x%08x\n", (int) dwError); return(dwError);} dwError = Demodulator_controlPowerSaving((Demodulator*) &pdc->Demodulator, ucSlaveDemod, bOn); - if(dwError) { deb_data(" DRV_ApCtrl: Demodulator_controlPowerSaving error = 0x%08x\n", dwError); return(dwError);} + if(dwError) { deb_data(" DRV_ApCtrl: Demodulator_controlPowerSaving error = 0x%08x\n", (int) dwError); return(dwError);} return(dwError); } @@ -711,7 +697,7 @@ static DWORD DRV_TunerWakeup( //tuner power on dwError = Demodulator_writeRegisterBits((Demodulator*) &pdc->Demodulator, 0, Processor_LINK, p_reg_top_gpioh7_o, reg_top_gpioh7_o_pos, reg_top_gpioh7_o_len, 1); - + if(dwError) deb_data(" DRV_TunerWakeup Fail: 0x%08x\n", (int) dwError); return(dwError); } @@ -740,10 +726,8 @@ static DWORD DRV_USBSetup( DWORD dwError = Error_NO_ERROR; PDEVICE_CONTEXT pdc = (PDEVICE_CONTEXT) handle; - - deb_data("- Enter %s Function -\n",__FUNCTION__); - int i; + deb_data("- Enter %s Function -\n",__FUNCTION__); if (pdc->Demodulator.chipNumber == 2) { @@ -765,11 +749,11 @@ static DWORD DRV_NIMSuspend( ) { - deb_data("- Enter DRV_NIMSuspend : bSuspend = %s\n", bSuspend ? "ON":"OFF"); DWORD dwError = Error_NO_ERROR; PDEVICE_CONTEXT pdc = (PDEVICE_CONTEXT) handle; + deb_data("- Enter DRV_NIMSuspend : bSuspend = %s\n", bSuspend ? "ON":"OFF"); if(bSuspend) //sleep { @@ -789,11 +773,9 @@ static DWORD DRV_InitNIMSuspendRegs( void * handle ) { - deb_data("- Enter %s Function -\n",__FUNCTION__); - DWORD dwError = Error_NO_ERROR; - PDEVICE_CONTEXT pdc = (PDEVICE_CONTEXT) handle; + deb_data("- Enter %s Function -\n",__FUNCTION__); dwError = Demodulator_writeRegisterBits((Demodulator*) &pdc->Demodulator, 0, Processor_LINK, p_reg_top_gpioh5_en, reg_top_gpioh5_en_pos, reg_top_gpioh5_en_len, 1); dwError = Demodulator_writeRegisterBits((Demodulator*) &pdc->Demodulator, 0, Processor_LINK, p_reg_top_gpioh5_on, reg_top_gpioh5_on_pos, reg_top_gpioh5_on_len, 1); @@ -810,11 +792,10 @@ static DWORD DRV_NIMReset( void * handle ) { - deb_data("- Enter %s Function -\n",__FUNCTION__); DWORD dwError = Error_NO_ERROR; - PDEVICE_CONTEXT pdc = (PDEVICE_CONTEXT)handle; + deb_data("- Enter %s Function -\n",__FUNCTION__); //Set AF0350 GPIOH1 to 0 to reset AF0351 @@ -836,9 +817,9 @@ static DWORD DL_NIMReset( ) { - mutex_lock(&mymutex); DWORD dwError = Error_NO_ERROR; + mutex_lock(&mymutex); dwError = DRV_NIMReset(handle); @@ -851,11 +832,10 @@ static DWORD DL_USBSetup( void * handle ) { + DWORD dwError = Error_NO_ERROR; mutex_lock(&mymutex); - DWORD dwError = Error_NO_ERROR; - dwError = DRV_USBSetup(handle); mutex_unlock(&mymutex); @@ -868,13 +848,9 @@ static DWORD DL_NIMSuspend( bool bSuspend ) { - - mutex_lock(&mymutex); - DWORD dwError = Error_NO_ERROR; - + mutex_lock(&mymutex); dwError = DRV_NIMSuspend(handle, bSuspend); - mutex_unlock(&mymutex); return (dwError); @@ -884,10 +860,10 @@ static DWORD DL_InitNIMSuspendRegs( void * handle ) { + DWORD dwError = Error_NO_ERROR; mutex_lock(&mymutex); - DWORD dwError = Error_NO_ERROR; dwError = DRV_InitNIMSuspendRegs(handle); @@ -899,15 +875,10 @@ static DWORD DL_Initialize( void * handle ) { - - mutex_lock(&mymutex); - DWORD dwError = Error_NO_ERROR; - + mutex_lock(&mymutex); dwError = DRV_Initialize(handle); - mutex_unlock(&mymutex); - return (dwError); } @@ -919,13 +890,11 @@ static DWORD DL_SetBusTuner( ) { - mutex_lock(&mymutex); DWORD dwError = Error_NO_ERROR; - - dwError = DRV_SetBusTuner(handle, busId, tunerId); - - mutex_unlock(&mymutex); + mutex_lock(&mymutex); + dwError = DRV_SetBusTuner(handle, busId, tunerId); + mutex_unlock(&mymutex); return (dwError); @@ -936,9 +905,9 @@ static DWORD DL_GetEEPROMConfig( ) { - mutex_lock(&mymutex); DWORD dwError = Error_NO_ERROR; + mutex_lock(&mymutex); dwError = DRV_GetEEPROMConfig(handle); @@ -952,9 +921,9 @@ static DWORD DL_TunerWakeup( ) { - mutex_lock(&mymutex); DWORD dwError = Error_NO_ERROR; + mutex_lock(&mymutex); dwError = DRV_TunerWakeup(handle); @@ -967,9 +936,9 @@ static DWORD DL_IrTblDownload( ) { - mutex_lock(&mymutex); DWORD dwError = Error_NO_ERROR; + mutex_lock(&mymutex); dwError = DRV_IrTblDownload(handle); @@ -983,17 +952,16 @@ DWORD DL_TunerPowerCtrl(u8 bPowerOn) { - mutex_lock(&mymutex); - DWORD dwError = Error_NO_ERROR; BYTE ucSlaveDemod=0; + mutex_lock(&mymutex); deb_data("enter DL_TunerPowerCtrl: bOn = %s\n", bPowerOn?"ON":"OFF"); for (ucSlaveDemod=0; ucSlaveDemodDemodulator.chipNumber; ucSlaveDemod++) { dwError = DRV_TunerPowerCtrl(PDC, ucSlaveDemod, bPowerOn); - if(dwError) deb_data(" DRV_TunerPowerCtrl Fail: 0x%08x\n", dwError); + if(dwError) deb_data(" DRV_TunerPowerCtrl Fail: 0x%08x\n", (int) dwError); } mutex_unlock(&mymutex); @@ -1006,9 +974,11 @@ DWORD DL_ResetPID( IN BYTE chip ) { + DWORD dwError = Error_NO_ERROR; + mutex_lock(&mymutex); - DWORD dwError = DRV_ResetPID(PDC, chip); + dwError = DRV_ResetPID(PDC, chip); mutex_unlock(&mymutex); @@ -1021,9 +991,11 @@ DWORD DL_AddPID( IN Pid pid ) { + DWORD dwError = Error_NO_ERROR; + mutex_lock(&mymutex); - DWORD dwError = DRV_AddPID(PDC, ucSlaveDemod,index, pid); + dwError = DRV_AddPID(PDC, ucSlaveDemod,index, pid); mutex_unlock(&mymutex); @@ -1036,9 +1008,12 @@ DWORD DL_RemovePID( IN Pid pid ) { + DWORD dwError = Error_NO_ERROR; + + mutex_lock(&mymutex); - DWORD dwError = DRV_RemovePID(PDC, ucSlaveDemod,index, pid); + dwError = DRV_RemovePID(PDC, ucSlaveDemod,index, pid); mutex_unlock(&mymutex); @@ -1050,9 +1025,10 @@ DWORD DL_PIDOnOff( IN bool bOn ) { + DWORD dwError = Error_NO_ERROR; mutex_lock(&mymutex); - DWORD dwError = DRV_PIDOnOff(PDC, ucSlaveDemod, bOn); + dwError = DRV_PIDOnOff(PDC, ucSlaveDemod, bOn); mutex_unlock(&mymutex); @@ -1064,12 +1040,10 @@ DWORD DL_ApCtrl ( Bool bOn ) { - + DWORD dwError = Error_NO_ERROR; + BYTE i=0; mutex_lock(&mymutex); - DWORD dwError = Error_NO_ERROR; - BYTE i=0; - deb_data("- Enter %s Function -",__FUNCTION__); deb_data(" chip = %d bOn = %s\n", ucSlaveDemod, bOn?"ON":"OFF"); @@ -1082,7 +1056,7 @@ DWORD DL_ApCtrl ( if (bOn) dwError = DRV_ApCtrl (PDC, i, bOn); else - if (PDC->bTunerPowerOff != true) dwError = DRV_ApCtrl (PDC, i, bOn); + if (PDC->bTunerPowerOff != (Bool) true) dwError = DRV_ApCtrl (PDC, i, bOn); if(!bOn) { @@ -1109,9 +1083,9 @@ DWORD DL_ApCtrl ( PDC->fc[ucSlaveDemod].GraphBuilt = 0; - if (PDC->bTunerPowerOff != true) dwError = DRV_ApCtrl (PDC, ucSlaveDemod, bOn); + if (PDC->bTunerPowerOff != (Bool) true) dwError = DRV_ApCtrl (PDC, ucSlaveDemod, bOn); - if (PDC->fc[0].GraphBuilt == 0 && PDC->fc[1].GraphBuilt == 0 && PDC->bTunerPowerOff == true) + if (PDC->fc[0].GraphBuilt == 0 && PDC->fc[1].GraphBuilt == 0 && PDC->bTunerPowerOff == (Bool) true) dwError = DL_NIMSuspend(PDC, true); } } @@ -1124,10 +1098,10 @@ DWORD DL_ApCtrl ( DWORD DL_Tuner_SetFreqBw(BYTE ucSlaveDemod, u32 dwFreq,u8 ucBw) { + DWORD dwError = Error_NO_ERROR; mutex_lock(&mymutex); - DWORD dwError = Error_NO_ERROR; deb_data("- Enter %s Function -\n",__FUNCTION__); if (PDC->fc[ucSlaveDemod].ulDesiredFrequency!=dwFreq || PDC->fc[ucSlaveDemod].ucDesiredBandWidth!=ucBw*1000) @@ -1140,11 +1114,10 @@ DWORD DL_Tuner_SetFreqBw(BYTE ucSlaveDemod, u32 dwFreq,u8 ucBw) DWORD DL_isLocked(BYTE ucSlaveDemod, Bool *bLock ) { + DWORD dwError = Error_NO_ERROR; mutex_lock(&mymutex); - DWORD dwError = Error_NO_ERROR; - deb_data("- Enter %s Function -\n",__FUNCTION__); dwError = DRV_isLocked(PDC, ucSlaveDemod, bLock); @@ -1155,16 +1128,15 @@ DWORD DL_isLocked(BYTE ucSlaveDemod, Bool *bLock ) DWORD DL_getSignalStrength(BYTE ucSlaveDemod, BYTE* strength) { + DWORD dwError = Error_NO_ERROR; mutex_lock(&mymutex); - DWORD dwError = Error_NO_ERROR; - deb_data("- Enter %s Function -\n",__FUNCTION__); dwError = DRV_getSignalStrength(PDC, ucSlaveDemod, strength); -// deb_data(" The signal strength is %d \n", *strength); + deb_data(" The signal strength is %d \n", *strength); mutex_unlock(&mymutex); return(dwError); @@ -1172,11 +1144,10 @@ DWORD DL_getSignalStrength(BYTE ucSlaveDemod, BYTE* strength) DWORD DL_getSignalStrengthDbm(BYTE ucSlaveDemod, Long* strengthDbm) { + DWORD dwError = Error_NO_ERROR; mutex_lock(&mymutex); - DWORD dwError = Error_NO_ERROR; - deb_data("- Enter %s Function -\n",__FUNCTION__); dwError = DRV_getSignalStrengthDbm(PDC, ucSlaveDemod, strengthDbm); @@ -1187,11 +1158,10 @@ mutex_unlock(&mymutex); DWORD DL_getChannelStatistic(BYTE ucSlaveDemod, ChannelStatistic* channelStatistic) { + DWORD dwError = Error_NO_ERROR; mutex_lock(&mymutex); - DWORD dwError = Error_NO_ERROR; - deb_data("- Enter %s Function -\n",__FUNCTION__); dwError = DRV_getChannelStatistic(PDC, ucSlaveDemod, channelStatistic); @@ -1203,11 +1173,10 @@ DWORD DL_getChannelStatistic(BYTE ucSlaveDemod, ChannelStatistic* channelStatist DWORD DL_getChannelModulation(BYTE ucSlaveDemod, ChannelModulation* channelModulation) { + DWORD dwError = Error_NO_ERROR; mutex_lock(&mymutex); - DWORD dwError = Error_NO_ERROR; - deb_data("- Enter %s Function -\n",__FUNCTION__); dwError = DRV_getChannelModulation(PDC, ucSlaveDemod, channelModulation); @@ -1219,12 +1188,10 @@ DWORD DL_getChannelModulation(BYTE ucSlaveDemod, ChannelModulation* channelMo DWORD DL_getSNR(BYTE ucSlaveDemod, Constellation* constellation, BYTE* snr) { - - mutex_lock(&mymutex); - DWORD dwError = Error_NO_ERROR; ChannelModulation channelModulation; DWORD snr_value; + mutex_lock(&mymutex); deb_data("- Enter %s Function -\n",__FUNCTION__); @@ -1340,10 +1307,10 @@ DWORD DL_getSNR(BYTE ucSlaveDemod, Constellation* constellation, BYTE* snr) DWORD DL_ReSetInterval(void) { + DWORD dwError = Error_NO_ERROR; mutex_lock(&mymutex); - DWORD dwError = Error_NO_ERROR; mutex_unlock(&mymutex); @@ -1354,10 +1321,10 @@ DWORD DL_ReSetInterval(void) DWORD DL_Reboot(void) { + DWORD dwError = Error_NO_ERROR; mutex_lock(&mymutex); - DWORD dwError = Error_NO_ERROR; deb_data("- Enter %s Function -\n",__FUNCTION__); @@ -1370,11 +1337,10 @@ DWORD DL_Reboot(void) DWORD DL_CheckTunerInited(BYTE ucSlaveDemod, Bool *bOn ) { + DWORD dwError = Error_NO_ERROR; mutex_lock(&mymutex); - DWORD dwError = Error_NO_ERROR; - deb_data("- Enter %s Function -\n",__FUNCTION__); *bOn = PTI.bTunerInited; @@ -1386,43 +1352,43 @@ DWORD DL_CheckTunerInited(BYTE ucSlaveDemod, Bool *bOn ) DWORD Device_init(struct usb_device *udev,PDEVICE_CONTEXT PDCs, Bool bBoot) { + int errcount=0; DWORD error = Error_NO_ERROR; BYTE filterIdx=0; udevs=udev; PDC=PDCs; - int errcount=0; deb_data("- Enter %s Function -\n",__FUNCTION__); // define in Af903x.h #ifdef QuantaMID - printk(" === AfaDTV on Quanta ===\n"); + deb_data(" === AfaDTV on Quanta ===\n"); #endif #ifdef EEEPC - printk(" === AfaDTV on EEEPC ===\n"); + deb_data(" === AfaDTV on EEEPC ===\n"); #endif #ifdef DRIVER_RELEASE_VERSION printk(" DRIVER_RELEASE_VERSION : %s\n", DRIVER_RELEASE_VERSION); #else - printk(" DRIVER_RELEASE_VERSION : v0.0-0\n"); + deb_data(" DRIVER_RELEASE_VERSION : v0.0-0\n"); #endif #ifdef FW_RELEASE_VERSION - printk(" FW_RELEASE_VERSION : %s\n", FW_RELEASE_VERSION); + deb_data(" FW_RELEASE_VERSION : %s\n", FW_RELEASE_VERSION); #else - printk(" FW_RELEASE_VERSION : v0_0_0_0\n"); + deb_data(" FW_RELEASE_VERSION : v0_0_0_0\n"); #endif #ifdef Version_NUMBER - printk(" API_RELEASE_VERSION : %X.%X.%X\n", Version_NUMBER, Version_DATE, Version_BUILD); + deb_data(" API_RELEASE_VERSION : %X.%X.%X\n", Version_NUMBER, Version_DATE, Version_BUILD); #else - printk(" API_RELEASE_VERSION :000.00000000.0\n"); + deb_data(" API_RELEASE_VERSION :000.00000000.0\n"); #endif -// printk(" FW_RELEASE_VERSION : %s\n", FW_RELEASE_VERSION); -// printk(" API_RELEASE_VERSION : %X.%X.%X\n", Version_NUMBER, Version_DATE, Version_BUILD); +// deb_data(" FW_RELEASE_VERSION : %s\n", FW_RELEASE_VERSION); +// deb_data(" API_RELEASE_VERSION : %X.%X.%X\n", Version_NUMBER, Version_DATE, Version_BUILD); //************* Set Device init Info *************// @@ -1438,7 +1404,7 @@ DWORD Device_init(struct usb_device *udev,PDEVICE_CONTEXT PDCs, Bool bBoot) PDC->Demodulator.userData = (Handle)PDC; PDC->Demodulator.chipNumber = 1; PDC->architecture=Architecture_DCA; - PDC->Demodulator.frequency[0] = 666000; + PDC->Demodulator.frequency[0] = 546000; PDC->Demodulator.bandwidth[0] = 8000; PDC->bIrTblDownload = false; PDC->fc[0].tunerinfo.TunerId = 0; @@ -1476,13 +1442,13 @@ DWORD Device_init(struct usb_device *udev,PDEVICE_CONTEXT PDCs, Bool bBoot) if(bBoot) { //patch for eeepc - error = DL_SetBusTuner (PDC, Bus_USB, Tuner_Afatech_AF9007); + error = DL_SetBusTuner (PDC, Bus_USB, Tuner_FCI_FC2580); PDC->UsbCtrlTimeOut = 5; - error = DL_SetBusTuner (PDC, Bus_USB, Tuner_Afatech_AF9007); + error = DL_SetBusTuner (PDC, Bus_USB, Tuner_FCI_FC2580); if (error) { - deb_data("First DL_SetBusTuner fail : 0x%08x\n",error ); + deb_data("First DL_SetBusTuner fail : 0x%08x\n", (int) error ); errcount++; goto Exit; } @@ -1490,13 +1456,13 @@ DWORD Device_init(struct usb_device *udev,PDEVICE_CONTEXT PDCs, Bool bBoot) error =DL_GetEEPROMConfig(PDC); if (error) { - deb_data("DL_GetEEPROMConfig fail : 0x%08x\n", error); + deb_data("DL_GetEEPROMConfig fail : 0x%08x\n", (int) error); errcount++; goto Exit; } }//bBoot - error = DL_SetBusTuner(PDC, Bus_USB, PDC->fc[0].tunerinfo.TunerId); + error = DL_SetBusTuner(PDC, Bus_USB, Tuner_FCI_FC2580); if (error) { deb_data("DL_SetBusTuner fail!\n"); @@ -1525,13 +1491,14 @@ DWORD Device_init(struct usb_device *udev,PDEVICE_CONTEXT PDCs, Bool bBoot) error = DL_Initialize(PDC); if (error) { - deb_data("DL_Initialize fail! 0x%08x\n", error); + deb_data("DL_Initialize fail! 0x%08x\n", (int) error); errcount++; goto Exit; } if (PDC->bIrTblDownload) { + deb_data("Loading firmware."); error = DL_IrTblDownload(PDC); if (error) {deb_data("DL_IrTblDownload fail");errcount++;} } @@ -1566,7 +1533,7 @@ DWORD Device_init(struct usb_device *udev,PDEVICE_CONTEXT PDCs, Bool bBoot) } } */ - deb_data(" %s success!! \n",__FUNCTION__); + printk(" %s success!! \n",__FUNCTION__); Exit: #endif //AFA_USB_DEVICE diff --git a/src/af903x-fe.c b/src/af903x-fe.c index 1939671..f9b12c0 100644 --- a/src/af903x-fe.c +++ b/src/af903x-fe.c @@ -11,12 +11,12 @@ static int af903x_init(struct dvb_frontend *demod) DWORD error = Error_NO_ERROR; deb_data("- Enter %s Function - chip=%d\n",__FUNCTION__, demod->dvb->num); -/* error = DL_ApCtrl(demod->dvb->num,1 ); + error = DL_ApCtrl(demod->dvb->num,1 ); if(error){ - printk("af903x_init return error\n"); + deb_data("af903x_init return error\n"); return error; } -*/ + return 0; } @@ -27,12 +27,12 @@ static int af903x_sleep(struct dvb_frontend *demod) DeviceReboot = false; - /* error = DL_ApCtrl(demod->dvb->num, 0); + error = DL_ApCtrl(demod->dvb->num, 0); if (error){ - printk("af903x_sleep return error\n"); + deb_data("af903x_sleep return error\n"); return error; } -*/ + return 0; } @@ -75,26 +75,29 @@ static int af903x_set_frontend(struct dvb_frontend* fe, ch.RF_kHz = 950000; error = DL_Tuner_SetFreqBw(fe->dvb->num,ch.RF_kHz,ch.Bw); - if (error) printk("af903x_set_frontend return error\n"); + if (error) deb_data("af903x_set_frontend return error\n"); return 0; } static int af903x_read_status(struct dvb_frontend *fe, fe_status_t *stat) { - //deb_data("- Enter %s Function -chip=%d\n",__FUNCTION__, fe->dvb->num); - struct af903xm_state *state = fe->demodulator_priv; + //struct af903xm_state *state = fe->demodulator_priv; DWORD error = Error_NO_ERROR; Bool bLock; + deb_data("- Enter %s Function - chip=%d\n",__FUNCTION__, fe->dvb->num); *stat = 0; error = DL_isLocked(fe->dvb->num, &bLock); + deb_data("DEBUG1 - code=: %d\n",(int) error); if(error) return 0;//return error; - + deb_data("DEBUG2 - code=: %d\n",(int) error); + if (bLock) { + deb_data("DEBUG3 - code=: %d\n",(int) error); // It's seems ok that always return lock to AP *stat |= FE_HAS_SIGNAL; *stat |= FE_HAS_CARRIER; @@ -102,13 +105,15 @@ static int af903x_read_status(struct dvb_frontend *fe, fe_status_t *stat) *stat |= FE_HAS_VITERBI; *stat |= FE_HAS_SYNC; } + deb_data("DEBUG4 - code=: %d\n",(int) error); + return 0; } static int af903x_read_ber(struct dvb_frontend *fe, u32 *ber) { - struct af903xm_state *state = fe->demodulator_priv; + //struct af903xm_state *state = fe->demodulator_priv; DWORD error = Error_NO_ERROR; @@ -117,7 +122,7 @@ static int af903x_read_ber(struct dvb_frontend *fe, u32 *ber) error = DL_getChannelStatistic(fe->dvb->num, &channelStatistic); if(error) return error; - deb_data("- af903x_read_ber postVitErrorCount : %d, postVitBitCount :%d -\n",channelStatistic.postVitErrorCount, channelStatistic.postVitBitCount); + deb_data("- af903x_read_ber postVitErrorCount : %d, postVitBitCount :%d -\n",( int ) channelStatistic.postVitErrorCount,(int) channelStatistic.postVitBitCount); *ber = channelStatistic.postVitErrorCount * (0xFFFFFFFF / channelStatistic.postVitBitCount); return 0; @@ -125,9 +130,7 @@ static int af903x_read_ber(struct dvb_frontend *fe, u32 *ber) static int af903x_read_snr(struct dvb_frontend* fe, u16 *snr) { -// (void) fe; -// *snr = 0x0000; - struct af903xm_state *state = fe->demodulator_priv; + *snr = 0; DWORD error = Error_NO_ERROR; Constellation constellation; @@ -162,20 +165,19 @@ static int af903x_read_unc_blocks(struct dvb_frontend *fe, u32 *unc) } static int af903x_read_signal_strength(struct dvb_frontend *fe, u16 *strength) { - struct af903xm_state *state = fe->demodulator_priv; - DWORD error = Error_NO_ERROR; BYTE SignalStrength = 0; - Long SignalStrengthdbm; - deb_data("- Enter %s Function -\n",__FUNCTION__); #ifdef QuantaMID + Long SignalStrengthdbm; + deb_data("- Enter %s Function -\n",__FUNCTION__); error = DL_getSignalStrengthDbm(fe->dvb->num, &SignalStrengthdbm); if(error) return error; - deb_data("- af903x_read_signal_strengthDbm is -%d -\n",-SignalStrengthdbm); *strength = (u16)(-SignalStrengthdbm); #else + deb_data("- Enter %s Function -\n",__FUNCTION__); + error = DL_getSignalStrength(fe->dvb->num, &SignalStrength); if(error) return error; diff --git a/src/af903x-tuner.c b/src/af903x-tuner.c index 20b3a2a..c45f1ae 100644 --- a/src/af903x-tuner.c +++ b/src/af903x-tuner.c @@ -9,6 +9,8 @@ #define IF2 36150 // IF2 frequency = 36.150 MHz #define FREF 16000 // Quartz oscillator 16 MHz + + static int tuner_set_params(struct dvb_frontend *fe, struct dvb_frontend_parameters *params) { struct tuner_priv *priv=NULL; @@ -17,7 +19,7 @@ static int tuner_set_params(struct dvb_frontend *fe, struct dvb_frontend_paramet priv->bandwidth = (fe->ops.info.type == FE_OFDM) ? params->u.ofdm.bandwidth : 0; - deb_data("%s - freq : %d , bandwidth : %dn",__FUNCTION__, freq,priv->bandwidth); + deb_data("%s - freq : %d , bandwidth : %dn",__FUNCTION__, (int) freq,priv->bandwidth); dwError =DL_Tuner_SetFreqBw(fe->dvb->num, freq,priv->bandwidth); if (dwError) deb_data("tuner_set_params Fail !\n"); diff --git a/src/af903x.h b/src/af903x.h index 4158343..5c3b9ad 100644 --- a/src/af903x.h +++ b/src/af903x.h @@ -9,14 +9,12 @@ #include #include #include -#include #include #include #include "dvb-usb.h" #include "af903x-ioctl.h" #include "demodulator.h" #include "userdef.h" -#include "firmware.h" #include "type.h" #include "Common.h" #include @@ -79,7 +77,7 @@ extern int dvb_usb_af903x_debug; //#define deb_data(args...) dprintk(dvb_usb_af903x_debug,0x08,args) -//#define DEBUG 1 +//#define DEBUG #ifdef DEBUG #define deb_data(args...) printk(KERN_NOTICE args) #else diff --git a/src/userdef.h b/src/userdef.h index 612ff9d..0a113ee 100644 --- a/src/userdef.h +++ b/src/userdef.h @@ -8,7 +8,9 @@ typedef int INT; // 4 bytes //typedef void * HANDLE; +#ifndef NULL #define NULL 0 +#endif #ifdef IN #undef IN -- cgit v0.12