more N-PHY, cordic stuff
cover more N-PHY, cordic stuff
This adds more N-PHY code and modifies cordic function that is currently used by LP-PHY code. Larry checked this and it still works fine on his LP-PHY card.
Rafał Miłecki (4):
b43: N-PHY: fix one bit off in parsing RF Ctrl Override arguments
b43: make cordic common (LP-PHY and N-PHY need it)
b43: update cordic code to match current specs
b43: N-PHY: use cordic to generate samples
drivers/net/wireless/b43/phy_common.c | 45 ++++++++++++++++++++++++++++ drivers/net/wireless/b43/phy_common.h | 7 ++++ drivers/net/wireless/b43/phy_lp.c | 52 ++++----------------------------- drivers/net/wireless/b43/phy_n.c | 23 ++++++++------ 4 files changed, 71 insertions(+), 56 deletions(-)
PATCH 1/4 b43: N-PHY: fix one bit off in parsing RF Ctrl Override arguments
--- drivers/net/wireless/b43/phy_n.c | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-)
drivers/net/wireless/b43/phy_n.c +1 -1
@@ -1031,7 +1031,7 @@ static void b43_nphy_rf_control_override(struct b43_wldev *dev, u16 field,u8 index =fls (field);u8 addr, en_addr, val_addr;/* we expect only one bit set */ -B43_WARN_ON (field & (~(1 << index))); +B43_WARN_ON (field & (~(1 << (index -1 ))));if (dev->phy.rev >=3 ) {const struct nphy_rf_control_override_rev3 *rf_ctrl;
Signature · 1 line
1.6.4.2
PATCH 2/4 b43: make cordic common (LP-PHY and N-PHY need it)
In reply to Rafał Miłecki--- drivers/net/wireless/b43/phy_common.c | 38 +++++++++++++++++++++++++++ drivers/net/wireless/b43/phy_common.h | 3 ++ drivers/net/wireless/b43/phy_lp.c | 45 +------------------------------- 3 files changed, 43 insertions(+), 43 deletions(-)
drivers/net/wireless/b43/phy_common.c +38 -0
@@ -421,3 +421,41 @@ void b43_phyop_switch_analog_generic(struct b43_wldev *dev, bool on) {b43_write16 (dev,B43_MMIO_PHY0 , on ?0 :0xF4 ); } + +b43_c32 b43_cordic (int theta) +{ +u32 arctg[] = {2949120 ,1740967 ,919879 ,466945 ,234379 ,117304 , +58666 ,29335 ,14668 ,7334 ,3667 ,1833 ,917 ,458 , +229 ,115 ,57 ,29 , }; +int i, tmp, signx =1 , angle =0 ; +b43_c32 ret = { .i =39797 , .q =0 , }; + + theta =clamp_t (int, theta,-180 ,180 ); + +if (theta >90 ) { + theta -=180 ; + signx =-1 ; + }else if (theta <-90 ) { + theta +=180 ; + signx =-1 ; + } + +for (i =0 ; i <=17 ; i++) { +if (theta > angle) { + tmp = ret.i - (ret.q >> i); + ret.q += ret.i >> i; + ret.i = tmp; + angle += arctg[i]; + }else { + tmp = ret.i + (ret.q >> i); + ret.q -= ret.i >> i; + ret.i = tmp; + angle -= arctg[i]; + } + } + + ret.i *= signx; + ret.q *= signx; + +return ret; +}
drivers/net/wireless/b43/phy_common.h +3 -0
@@ -5,6 +5,8 @@struct b43_wldev ; +/* Complex number using 2 32-bit signed integers */ +typedef struct {s32 i, q; }b43_c32 ;/* PHY register routing bits */ #define B43_PHYROUTE 0x0C00/* PHY register routing bits mask */
@@ -421,5 +423,6 @@ int b43_phy_shm_tssi_read(struct b43_wldev *dev, u16 shm_offset);*/ void b43_phyop_switch_analog_generic (struct b43_wldev *dev,bool on); +b43_c32 b43_cordic (int theta);#endif /* LINUX_B43_PHY_COMMON_H_ */
drivers/net/wireless/b43/phy_lp.c +2 -43
63 lines not on this page · raw message
Signature · 1 line
1.6.4.2
Re: [PATCH 2/4] b43: make cordic common (LP-PHY and N-PHY need it)
drivers/net/wireless/b43/phy_common.h line 9
Quoted 2 lines · On Monday 25 January 2010 18:59:59 Rafał Miłecki wrote:
drivers/net/wireless/b43/phy_common.h +2
-0+/* Complex number using 2 32-bit signed integers */ +typedef struct {s32 i, q; }b43_c32 ;
No typedef. ever.
Signature · 1 line
Greetings, Michael.
Re: [PATCH 2/4] b43: make cordic common (LP-PHY and N-PHY need it)
2010/1/25 Michael Buesch <[email protected]>:
Quoted 5 lines · On Monday 25 January 2010 18:59:59 Rafał Miłecki wrote:
drivers/net/wireless/b43/phy_common.h line 9
Quoted 2 lines
drivers/net/wireless/b43/phy_common.h +2
-0+/* Complex number using 2 32-bit signed integers */ +typedef struct {s32 i, q; }b43_c32 ;No typedef. ever.
Well, I just copied (Gabor's?) code here. But of course I can fix this by the way, no problem :)
Just read about typedef in Linux Kernel Coding Style, didn't know about this earlier. Thanks for pointing.
Signature · 1 line
Rafał
Re: [PATCH 2/4] b43: make cordic common (LP-PHY and N-PHY need it)
W dniu 25 stycznia 2010 19:35 użytkownik Rafał Miłecki
Quoted 7 lines · <[email protected]> napisał:
2010/1/25 Michael Buesch <[email protected]>:
Quoted 5 lines · On Monday 25 January 2010 18:59:59 Rafał Miłecki wrote:
drivers/net/wireless/b43/phy_common.h line 9
Quoted 2 lines
drivers/net/wireless/b43/phy_common.h +2
-0+/* Complex number using 2 32-bit signed integers */ +typedef struct {s32 i, q; }b43_c32 ;No typedef. ever.
Quoted 5 lines
Well, I just copied (Gabor's?) code here. But of course I can fix this by the way, no problem :)
Just read about typedef in Linux Kernel Coding Style, didn't know about this earlier. Thanks for pointing.
Is this OK to fix this in separated patch? Or should I modify this set of patches?
Signature · 1 line
Rafał
Re: [PATCH 2/4] b43: make cordic common (LP-PHY and N-PHY need it)
Quoted 11 lines · On Monday 25 January 2010 19:36:27 Rafał Miłecki wrote:
W dniu 25 stycznia 2010 19:35 użytkownik Rafał Miłecki
Quoted 9 lines · <[email protected]> napisał:
2010/1/25 Michael Buesch <[email protected]>:
Quoted 5 lines · On Monday 25 January 2010 18:59:59 Rafał Miłecki wrote:
drivers/net/wireless/b43/phy_common.h line 9
Quoted 2 lines
drivers/net/wireless/b43/phy_common.h +2
-0+/* Complex number using 2 32-bit signed integers */ +typedef struct {s32 i, q; }b43_c32 ;No typedef. ever.
Well, I just copied (Gabor's?) code here. But of course I can fix this by the way, no problem :)
Yeah, I saw that. We can fix it while we're at it. ;)
Quoted 5 lines
Quoted 2 lines
Just read about typedef in Linux Kernel Coding Style, didn't know about this earlier. Thanks for pointing.
Is this OK to fix this in separated patch? Or should I modify this set of patches?
Well, as you touch any reference to the typedef anyway (you renamed it),
you can just put the keyword "struct" in front of the references and no separate patch is needed. It won't even grow your current patch in the number of changed lines.
Signature · 1 line
Greetings, Michael.
Re: [PATCH 2/4] b43: make cordic common (LP-PHY and N-PHY need it)
Quoted 18 lines · Michael Buesch
Quoted 11 lines · On Monday 25 January 2010 19:36:27 Rafał Miłecki wrote:
W dniu 25 stycznia 2010 19:35 użytkownik Rafał Miłecki
Quoted 9 lines · <[email protected]> napisał:
2010/1/25 Michael Buesch <[email protected]>:
Quoted 5 lines · On Monday 25 January 2010 18:59:59 Rafał Miłecki wrote:
drivers/net/wireless/b43/phy_common.h line 9
Quoted 2 lines
drivers/net/wireless/b43/phy_common.h +2
-0+/* Complex number using 2 32-bit signed integers */ +typedef struct {s32 i, q; }b43_c32 ;No typedef. ever.
Well, I just copied (Gabor's?) code here. But of course I can fix this by the way, no problem :)
Yeah, I saw that. We can fix it while we're at it. ;)
Quoted 3 lines
Quoted 2 lines
Just read about typedef in Linux Kernel Coding Style, didn't know about this earlier. Thanks for pointing.
Quoted 6 lines
Quoted 2 lines
Is this OK to fix this in separated patch? Or should I modify this set of patches?
Well, as you touch any reference to the typedef anyway (you renamed it),
you can just put the keyword "struct" in front of the references and no separate patch is needed. It won't even grow your current patch in the number of changed lines.
I took care of these modifications to the original patch...
John
Signature · 2 lines
John W. Linville Someday the world will need a hero, and you [email protected] might be all we have. Be ready.
Re: [PATCH 2/4] b43: make cordic common (LP-PHY and N-PHY need it)
2010/1/25 John W. Linville <[email protected]>:
Quoted 19 lines · Michael Buesch
Quoted 18 lines · On Monday 25 January 2010 19:36:27 Rafał Miłecki wrote:
Quoted 11 lines
W dniu 25 stycznia 2010 19:35 użytkownik Rafał Miłecki
Quoted 9 lines · <[email protected]> napisał:
2010/1/25 Michael Buesch <[email protected]>:
Quoted 5 lines · On Monday 25 January 2010 18:59:59 Rafał Miłecki wrote:
drivers/net/wireless/b43/phy_common.h line 9
Quoted 2 lines
drivers/net/wireless/b43/phy_common.h +2
-0+/* Complex number using 2 32-bit signed integers */ +typedef struct {s32 i, q; }b43_c32 ;No typedef. ever.
Well, I just copied (Gabor's?) code here. But of course I can fix this by the way, no problem :)
Yeah, I saw that. We can fix it while we're at it. ;)
Quoted 3 lines
Quoted 2 lines
Just read about typedef in Linux Kernel Coding Style, didn't know about this earlier. Thanks for pointing.
Quoted 8 lines
Quoted 6 lines
Quoted 2 lines
Is this OK to fix this in separated patch? Or should I modify this set of patches?
Well, as you touch any reference to the typedef anyway (you renamed it),
you can just put the keyword "struct" in front of the references and no separate patch is needed. It won't even grow your current patch in the number of changed lines.I took care of these modifications to the original patch...
Hey, thank you! :)
Signature · 1 line
Rafał
PATCH 3/4 b43: update cordic code to match current specs
In reply to Rafał Miłecki--- drivers/net/wireless/b43/phy_common.c | 19 +++++++++++++------ drivers/net/wireless/b43/phy_common.h | 4 ++++ drivers/net/wireless/b43/phy_lp.c | 7 ++++--- 3 files changed, 21 insertions(+), 9 deletions(-)
drivers/net/wireless/b43/phy_common.c +13 -6
@@ -422,21 +422,28 @@ void b43_phyop_switch_analog_generic(struct b43_wldev *dev, bool on)b43_write16 (dev,B43_MMIO_PHY0 , on ?0 :0xF4 ); } +/* http://bcm-v4.sipsolutions.net/802.11/PHY/Cordic */ b43_c32 b43_cordic (int theta) {u32 arctg[] = {2949120 ,1740967 ,919879 ,466945 ,234379 ,117304 ,58666 ,29335 ,14668 ,7334 ,3667 ,1833 ,917 ,458 ,229 ,115 ,57 ,29 , }; -int i, tmp, signx =1 , angle =0 ; +u8 i; +s32 tmp; +s8 signx =1 ; +u32 angle =0 ;b43_c32 ret = { .i =39797 , .q =0 , }; - theta =clamp_t (int, theta,-180 ,180 ); +while (theta > (180 <<16 )) + theta -= (360 <<16 ); +while (theta < -(180 <<16 )) + theta += (360 <<16 ); -if (theta >90 ) { - theta -=180 ; +if (theta > (90 <<16 )) { + theta -= (180 <<16 ); signx =-1 ; - }else if (theta <-90 ) { - theta +=180 ; + }else if (theta < -(90 <<16 )) { + theta += (180 <<16 ); signx =-1 ; }
drivers/net/wireless/b43/phy_common.h +4 -0
@@ -8,6 +8,10 @@ struct b43_wldev;/* Complex number using 2 32-bit signed integers */ typedef struct {s32 i, q; }b43_c32 ; +#define CORDIC_CONVERT (value) (((value) >= 0) ? \ + ((((value) >> 15) + 1) >> 1) : \ + -((((-(value)) >> 15) + 1) >> 1)) +/* PHY register routing bits */ #define B43_PHYROUTE 0x0C00/* PHY register routing bits mask */ #define B43_PHYROUTE_BASE 0x0000/* Base registers */
drivers/net/wireless/b43/phy_lp.c +4 -3
@@ -1784,7 +1784,8 @@ static void lpphy_start_tx_tone(struct b43_wldev *dev, s32 freq, u16 max) {struct b43_phy_lp *lpphy = dev->phy.lp;u16 buf[64 ]; -int i, samples =0 , angle =0 , rotation = (9 * freq) /500 ; +int i, samples =0 , angle =0 ; +int rotation = (((36 * freq) /20 ) <<16 ) /100 ;b43_c32 sample; lpphy->tx_tone_freq = freq;
@@ -1803,8 +1804,8 @@ static void lpphy_start_tx_tone(struct b43_wldev *dev, s32 freq, u16 max)for (i =0 ; i < samples; i++) { sample =b43_cordic (angle); angle += rotation; - buf[i] = ((sample.i * max) &0xFF ) <<8 ; - buf[i] |= (sample.q * max) &0xFF ; + buf[i] =CORDIC_CONVERT ((sample.i * max) &0xFF ) <<8 ; + buf[i] |=CORDIC_CONVERT ((sample.q * max) &0xFF ); }b43_lptab_write_bulk (dev,B43_LPTAB16 (5 ,0 ), samples, buf);
Signature · 1 line
1.6.4.2
PATCH 4/4 b43: N-PHY: use cordic to generate samples
In reply to Rafał Miłecki--- drivers/net/wireless/b43/phy_n.c | 21 ++++++++++++--------- 1 files changed, 12 insertions(+), 9 deletions(-)
drivers/net/wireless/b43/phy_n.c +12 -9
@@ -821,8 +821,9 @@ static u16 b43_nphy_gen_load_samples(struct b43_wldev *dev, u32 freq, u16 max, bool test) {int i; -u16 bw, len, num, rot, angle; -/* TODO: *buffer; */ +u16 bw, len, rot, angle; +b43_c32 *samples; + bw = (dev->phy.is_40mhz) ?40 :20 ; len = bw <<3 ;
@@ -839,18 +840,20 @@ static u16 b43_nphy_gen_load_samples(struct b43_wldev *dev, u32 freq, u16 max, len = bw <<1 ; } -/* TODO: buffer = kzalloc(len * sizeof(u32), GFP_KERNEL); */ - num = len; + samples =kzalloc (len *sizeof (b43_c32),GFP_KERNEL ); rot = (((freq *36 ) / bw) <<16 ) /100 ; angle =0 ; -for (i =0 ; i < num; i++) { -/* TODO */ +for (i =0 ; i < len; i++) { + samples[i] =b43_cordic (angle); + angle += rot; + samples[i].q =CORDIC_CONVERT (samples[i].q * max); + samples[i].i =CORDIC_CONVERT (samples[i].i * max); } -/* TODO: Call N PHY Load Sample Table with buffer, num as arguments */ -/* TODO: kfree(buffer); */ -return num; +/* TODO: Call N PHY Load Sample Table with buffer, len as arguments */ +kfree (samples); +return len; }/* http://bcm-v4.sipsolutions.net/802.11/PHY/N/RunSamples */
Signature · 1 line
1.6.4.2