···4242typedef unsigned int uint;4343#endif44444545-/* define [u]int16/32/64, uintptr */4545+/* define [u]int32/64, uintptr */46464747#ifndef TYPEDEF_UINT324848typedef unsigned int uint32;···50505151#ifndef TYPEDEF_UINTPTR5252typedef unsigned int uintptr;5353-#endif5454-5555-#ifndef TYPEDEF_INT165656-typedef signed short int16;5753#endif58545955#ifndef TYPEDEF_INT32···7983#undef TYPEDEF_UINT8084#undef TYPEDEF_UINT328185#undef TYPEDEF_UINTPTR8282-#undef TYPEDEF_INT168386#undef TYPEDEF_INT3284878588/*
+4-4
drivers/staging/brcm80211/include/wlioctl.h
···5555 u8 channel; /* Channel no. */5656 u16 atim_window; /* units are Kusec */5757 u8 dtim_period; /* DTIM period */5858- int16 RSSI; /* receive signal strength (in dBm) */5858+ s16 RSSI; /* receive signal strength (in dBm) */5959 s8 phy_noise; /* noise (in dBm) */6060 uint32 ie_length; /* byte length of Information Elements */6161 /* variable length Information Elements */···8888 chanspec_t chanspec; /* chanspec for bss */8989 u16 atim_window; /* units are Kusec */9090 u8 dtim_period; /* DTIM period */9191- int16 RSSI; /* receive signal strength (in dBm) */9191+ s16 RSSI; /* receive signal strength (in dBm) */9292 s8 phy_noise; /* noise (in dBm) */93939494 u8 n_cap; /* BSS is 802.11N Capable */···132132 chanspec_t chanspec; /* chanspec for bss */133133 u16 atim_window; /* units are Kusec */134134 u8 dtim_period; /* DTIM period */135135- int16 RSSI; /* receive signal strength (in dBm) */135135+ s16 RSSI; /* receive signal strength (in dBm) */136136 s8 phy_noise; /* noise (in dBm) */137137138138 u8 n_cap; /* BSS is 802.11N Capable */···145145146146 u16 ie_offset; /* offset at which IEs start, from beginning */147147 uint32 ie_length; /* byte length of Information Elements */148148- int16 SNR; /* average SNR of during frame reception */148148+ s16 SNR; /* average SNR of during frame reception */149149 /* Add new fields here */150150 /* variable length Information Elements */151151} wl_bss_info_t;
···317317318318 /* fifo */319319 uint *txavail[NFIFO]; /* # tx descriptors available */320320- int16 txpktpend[NFIFO]; /* tx admission control */320320+ s16 txpktpend[NFIFO]; /* tx admission control */321321#endif /* WLC_LOW */322322323323 macstat_t *macstat_snapshot; /* mac hw prev read values */
+2-2
drivers/staging/brcm80211/sys/wlc_pub.h
···169169 u16 flags; /* flags for internal attributes */170170 u8 SSID_len; /* the length of SSID */171171 u8 SSID[32]; /* SSID string */172172- int16 RSSI; /* receive signal strength (in dBm) */173173- int16 SNR; /* receive signal SNR in dB */172172+ s16 RSSI; /* receive signal strength (in dBm) */173173+ s16 SNR; /* receive signal SNR in dB */174174 u16 beacon_period; /* units are Kusec */175175 u16 atim_window; /* units are Kusec */176176 chanspec_t chanspec; /* Channel num, bw, ctrl_sb and band */
+1-1
drivers/staging/brcm80211/sys/wlc_rate.c
···467467 mcsallow ? txstreams : 1);468468}469469470470-int16 BCMFASTPATH wlc_rate_legacy_phyctl(uint rate)470470+s16 BCMFASTPATH wlc_rate_legacy_phyctl(uint rate)471471{472472 uint i;473473 for (i = 0; i < LEGACY_PHYCFG_TABLE_SIZE; i++)
···2222else if input number is less than 0xffff8000 then output is saturated to 0xffff80002323else output is same as input.2424*/2525-int16 qm_sat32(int32 op)2525+s16 qm_sat32(int32 op)2626{2727- int16 result;2727+ s16 result;2828 if (op > (int32) 0x7fff) {2929 result = 0x7fff;3030 } else if (op < (int32) 0xffff8000) {3131- result = (int16) (0x8000);3131+ result = (s16) (0x8000);3232 } else {3333- result = (int16) op;3333+ result = (s16) op;3434 }3535 return result;3636}···414116 bit multiplication on the processor platform is cheaper than 32 bit multiplication (as4242the most of qmath functions can be replaced with processor intrinsic instructions).4343*/4444-int32 qm_mul321616(int16 op1, int16 op2)4444+int32 qm_mul321616(s16 op1, s16 op2)4545{4646 return (int32) (op1) * (int32) (op2);4747}···5151To fit the result into 16 bits the 32 bit multiplication result is right5252shifted by 16 bits.5353*/5454-int16 qm_mul16(int16 op1, int16 op2)5454+s16 qm_mul16(s16 op1, s16 op2)5555{5656 int32 result;5757 result = ((int32) (op1) * (int32) (op2));5858- return (int16) (result >> 16);5858+ return (s16) (result >> 16);5959}60606161/*···6565twice that of compiler multiplication. (i.e. qm_muls321616(2,3)=12).6666When both input 16 bit numbers are 0x8000, then the result is saturated to 0x7fffffff.6767*/6868-int32 qm_muls321616(int16 op1, int16 op2)6868+int32 qm_muls321616(s16 op1, s16 op2)6969{7070 int32 result;7171- if (op1 == (int16) (0x8000) && op2 == (int16) (0x8000)) {7171+ if (op1 == (s16) (0x8000) && op2 == (s16) (0x8000)) {7272 result = 0x7fffffff;7373 } else {7474 result = ((int32) (op1) * (int32) (op2));···9393due to the multiplication.9494When both the 16bit inputs are 0x8000 then the output is saturated to 0x7fffffff.9595*/9696-int16 qm_muls16(int16 op1, int16 op2)9696+s16 qm_muls16(s16 op1, s16 op2)9797{9898 int32 result;9999- if (op1 == (int16) 0x8000 && op2 == (int16) 0x8000) {9999+ if (op1 == (s16) 0x8000 && op2 == (s16) 0x8000) {100100 result = 0x7fffffff;101101 } else {102102 result = ((int32) (op1) * (int32) (op2));103103 }104104- return (int16) (result >> 15);104104+ return (s16) (result >> 15);105105}106106107107/*···124124Description: This function add two 16 bit numbers and return the 16bit result.125125If the result overflow 16 bits, the output will be saturated to 16bits.126126*/127127-int16 qm_add16(int16 op1, int16 op2)127127+s16 qm_add16(s16 op1, s16 op2)128128{129129- int16 result;129129+ s16 result;130130 int32 temp = (int32) op1 + (int32) op2;131131 if (temp > (int32) 0x7fff) {132132- result = (int16) 0x7fff;132132+ result = (s16) 0x7fff;133133 } else if (temp < (int32) 0xffff8000) {134134- result = (int16) 0xffff8000;134134+ result = (s16) 0xffff8000;135135 } else {136136- result = (int16) temp;136136+ result = (s16) temp;137137 }138138 return result;139139}···142142Description: This function make 16 bit subtraction and return the 16bit result.143143If the result overflow 16 bits, the output will be saturated to 16bits.144144*/145145-int16 qm_sub16(int16 op1, int16 op2)145145+s16 qm_sub16(s16 op1, s16 op2)146146{147147- int16 result;147147+ s16 result;148148 int32 temp = (int32) op1 - (int32) op2;149149 if (temp > (int32) 0x7fff) {150150- result = (int16) 0x7fff;150150+ result = (s16) 0x7fff;151151 } else if (temp < (int32) 0xffff8000) {152152- result = (int16) 0xffff8000;152152+ result = (s16) 0xffff8000;153153 } else {154154- result = (int16) temp;154154+ result = (s16) temp;155155 }156156 return result;157157}···177177into the input 32 bit number and return the 32 bit accumulated result.178178If the accumulation result in overflow, then the output will be saturated.179179*/180180-int32 qm_mac321616(int32 acc, int16 op1, int16 op2)180180+int32 qm_mac321616(int32 acc, s16 op1, s16 op2)181181{182182 int32 result;183183 result = qm_add32(acc, qm_mul321616(op1, op2));···223223is +ve. This function will make a 16 bit right shift when the specified shift is -ve.224224This function return the result after shifting operation.225225*/226226-int16 qm_shl16(int16 op, int shift)226226+s16 qm_shl16(s16 op, int shift)227227{228228 int i;229229- int16 result;229229+ s16 result;230230 result = op;231231 if (shift > 15)232232 shift = 15;···247247This function make a 16 bit saturated left shift when shift is -ve. This function248248return the result of the shift operation.249249*/250250-int16 qm_shr16(int16 op, int shift)250250+s16 qm_shr16(s16 op, int shift)251251{252252 return qm_shl16(op, -shift);253253}···256256Description: This function return the number of redundant sign bits in a 16 bit number.257257Example: qm_norm16(0x0080) = 7.258258*/259259-int16 qm_norm16(int16 op)259259+s16 qm_norm16(s16 op)260260{261261 u16 u16extraSignBits;262262 if (op == 0) {···275275Description: This function return the number of redundant sign bits in a 32 bit number.276276Example: qm_norm32(0x00000080) = 23277277*/278278-int16 qm_norm32(int32 op)278278+s16 qm_norm32(int32 op)279279{280280 u16 u16extraSignBits;281281 if (op == 0) {···295295The numerator should be less than denominator. So the quotient is always less than 1.296296This function return the quotient in q.15 format.297297*/298298-int16 qm_div_s(int16 num, int16 denom)298298+s16 qm_div_s(s16 num, s16 denom)299299{300300- int16 var_out;301301- int16 iteration;300300+ s16 var_out;301301+ s16 iteration;302302 int32 L_num;303303 int32 L_denom;304304 L_num = (num) << 15;···310310 L_num = qm_add32(L_num, 1);311311 }312312 }313313- var_out = (int16) (L_num & 0x7fff);313313+ var_out = (s16) (L_num & 0x7fff);314314 return var_out;315315}316316317317/*318318Description: This function compute the absolute value of a 16 bit number.319319*/320320-int16 qm_abs16(int16 op)320320+s16 qm_abs16(s16 op)321321{322322 if (op < 0) {323323- if (op == (int16) 0xffff8000) {323323+ if (op == (s16) 0xffff8000) {324324 return 0x7fff;325325 } else {326326 return -op;···337337to this function. The qformat of quotient is adjusted appropriately such that338338the quotient occupies all 16 bits.339339*/340340-int16 qm_div16(int16 num, int16 denom, int16 *qQuotient)340340+s16 qm_div16(s16 num, s16 denom, s16 *qQuotient)341341{342342- int16 sign;343343- int16 nNum, nDenom;342342+ s16 sign;343343+ s16 nNum, nDenom;344344 sign = num ^ denom;345345 num = qm_abs16(num);346346 denom = qm_abs16(denom);···380380to this function. The qformat of quotient is adjusted appropriately such that381381the quotient occupies all 16 bits.382382*/383383-int16 qm_div163232(int32 num, int32 denom, int16 *qquotient)383383+s16 qm_div163232(int32 num, int32 denom, s16 *qquotient)384384{385385 int32 sign;386386- int16 nNum, nDenom;386386+ s16 nNum, nDenom;387387 sign = num ^ denom;388388 num = qm_abs32(num);389389 denom = qm_abs32(denom);···393393 denom = qm_shl32(denom, nDenom);394394 *qquotient = nNum - 1 - nDenom + 15;395395 if (sign >= 0) {396396- return qm_div_s((int16) (num >> 16), (int16) (denom >> 16));396396+ return qm_div_s((s16) (num >> 16), (s16) (denom >> 16));397397 } else {398398- return -qm_div_s((int16) (num >> 16), (int16) (denom >> 16));398398+ return -qm_div_s((s16) (num >> 16), (s16) (denom >> 16));399399 }400400}401401···404404The multiplicaton result is right shifted by 16 bits to fit the result405405into 32 bit output.406406*/407407-int32 qm_mul323216(int32 op1, int16 op2)407407+int32 qm_mul323216(int32 op1, s16 op2)408408{409409- int16 hi;409409+ s16 hi;410410 u16 lo;411411 int32 result;412412 hi = op1 >> 16;413413- lo = (int16) (op1 & 0xffff);413413+ lo = (s16) (op1 & 0xffff);414414 result = qm_mul321616(hi, op2);415415 result = result + (qm_mulsu321616(op2, lo) >> 16);416416 return result;···420420Description: This function multiply signed 16 bit number with unsigned 16 bit number and return421421the result in 32 bits.422422*/423423-int32 qm_mulsu321616(int16 op1, u16 op2)423423+int32 qm_mulsu321616(s16 op1, u16 op2)424424{425425 return (int32) (op1) * op2;426426}···43143116 bits is done to remove the extra sign bit formed by multiplication from the return value.432432When the input numbers are 0x80000000, 0x8000 the return value is saturated to 0x7fffffff.433433*/434434-int32 qm_muls323216(int32 op1, int16 op2)434434+int32 qm_muls323216(int32 op1, s16 op2)435435{436436- int16 hi;436436+ s16 hi;437437 u16 lo;438438 int32 result;439439 hi = op1 >> 16;440440- lo = (int16) (op1 & 0xffff);440440+ lo = (s16) (op1 & 0xffff);441441 result = qm_muls321616(hi, op2);442442 result = qm_add32(result, (qm_mulsu321616(op2, lo) >> 15));443443 return result;···450450*/451451int32 qm_mul32(int32 a, int32 b)452452{453453- int16 hi1, hi2;453453+ s16 hi1, hi2;454454 u16 lo1, lo2;455455 int32 result;456456 hi1 = a >> 16;···473473*/474474int32 qm_muls32(int32 a, int32 b)475475{476476- int16 hi1, hi2;476476+ s16 hi1, hi2;477477 u16 lo1, lo2;478478 int32 result;479479 hi1 = a >> 16;···488488}489489490490/* This table is log2(1+(i/32)) where i=[0:1:31], in q.15 format */491491-static const int16 log_table[] = {491491+static const s16 log_table[] = {492492 0,493493 1455,494494 2866,···545545Note/Problem:546546For accurate results input should be in normalized or near normalized form.547547*/548548-void qm_log10(int32 N, int16 qN, int16 *log10N, int16 *qLog10N)548548+void qm_log10(int32 N, s16 qN, s16 *log10N, s16 *qLog10N)549549{550550- int16 s16norm, s16tableIndex, s16errorApproximation;550550+ s16 s16norm, s16tableIndex, s16errorApproximation;551551 u16 u16offset;552552 int32 s32log;553553···569569 qN = qN + s16norm - 30;570570571571 /* take the table index as the LOG2_OF_LOG_TABLE_SIZE bits right of the MSB */572572- s16tableIndex = (int16) (N >> (32 - (2 + LOG2_LOG_TABLE_SIZE)));572572+ s16tableIndex = (s16) (N >> (32 - (2 + LOG2_LOG_TABLE_SIZE)));573573574574 /* remove the MSB. the MSB is always 1 after normalization. */575575 s16tableIndex =576576- s16tableIndex & (int16) ((1 << LOG2_LOG_TABLE_SIZE) - 1);576576+ s16tableIndex & (s16) ((1 << LOG2_LOG_TABLE_SIZE) - 1);577577578578 /* remove the (1+LOG2_OF_LOG_TABLE_SIZE) MSBs in the N. */579579 N = N & ((1 << (32 - (2 + LOG2_LOG_TABLE_SIZE))) - 1);···586586 s32log = log_table[s16tableIndex]; /* q.15 format */587587588588 /* interpolate using the offset. */589589- s16errorApproximation = (int16) qm_mulu16(u16offset, (u16) (log_table[s16tableIndex + 1] - log_table[s16tableIndex])); /* q.15 */589589+ s16errorApproximation = (s16) qm_mulu16(u16offset, (u16) (log_table[s16tableIndex + 1] - log_table[s16tableIndex])); /* q.15 */590590591591- s32log = qm_add16((int16) s32log, s16errorApproximation); /* q.15 format */591591+ s32log = qm_add16((s16) s32log, s16errorApproximation); /* q.15 format */592592593593 /* adjust for the qformat of the N as594594 * log2(mag * 2^x) = log2(mag) + x···605605 * as log10(mag * 2^x) = log2(mag * 2^x) * log10(2)606606 * log10N in q.15+s16norm-16+1 (LOG10_2 is in q.16)607607 */608608- *log10N = qm_muls16((int16) s32log, (int16) LOG10_2);608608+ *log10N = qm_muls16((s16) s32log, (s16) LOG10_2);609609610610 /* write the q format of the result. */611611 *qLog10N = 15 + s16norm - 16 + 1;···631631qsqrtN - address where q format of 1/N has to be written.632632*/633633#define qx 29634634-void qm_1byN(int32 N, int16 qN, int32 *result, int16 *qResult)634634+void qm_1byN(int32 N, s16 qN, int32 *result, s16 *qResult)635635{636636- int16 normN;636636+ s16 normN;637637 int32 s32firstTerm, s32secondTerm, x;638638 int i;639639···657657 for (i = 0; i < 4; i++) {658658 s32firstTerm = qm_shl32(x, 1); /* s32firstTerm = 2*x in q.29 */659659 s32secondTerm =660660- qm_muls321616((int16) (s32firstTerm >> 16),661661- (int16) (s32firstTerm >> 16));660660+ qm_muls321616((s16) (s32firstTerm >> 16),661661+ (s16) (s32firstTerm >> 16));662662 /* s32secondTerm = x*x in q.(29+1-16)*2+1 */663663 s32secondTerm =664664- qm_muls321616((int16) (s32secondTerm >> 16), (int16) N);664664+ qm_muls321616((s16) (s32secondTerm >> 16), (s16) N);665665 /* s32secondTerm = N*x*x in q.((29+1-16)*2+1)-16+15+1 i.e. in q.29 */666666 x = qm_sub32(s32firstTerm, s32secondTerm);667667 /* can be added directly as both are in q.29 */