[linux-dvb] [PATCH] cx24123 (NOVA S plus) signal strengh reporting
Sigmund Augdal Helberg
sigmund at snap.tv
Thu Jan 12 11:57:33 CET 2006
On Thu, 2006-01-12 at 11:42 +0100, Romain DEGEZ wrote:
> Sigmund Augdal Helberg wrote:
> > Two's complement format is the common format used nearly everywhere for
> > storing signed numbers.
> First of all, thanks for your anwser.
> Ok got it but ... does the statement "X is in two's complement format" imply that
> X is used to represent a signed value ? :-)
As far as I know, yes.
> Moreover I do not understand the need of a signed value in our case (AGC accumulator).
> A negative value should be nonsense and the precision of the positive value is /2 compared
> to an unsigned one.
I do not understand this either. It is possible that the register only
handles 8 bit signed values and the manufaturers decided that the
interval [-127 127] was better than having only [0 127]. This would also
make sense considering the comment stating larger is better, but not
saying anything about the absolute origin of the value.
> >>So, I think the following line should be corrected (patch attached).
> >>- *signal_strength = cx24123_readreg(state, 0x3b) << 8; /* larger = better */
> >>+ *signal_strength = ~(cx24123_readreg(state, 0x3b) - 1) << 8; /* larger = better */
> > This piece of code would be the proper way to change sign of a number
> > Does the following line give meaningful values for you?
> > *signal_strength = (cx24123_readreg(state, 0x3b)+0x80) << 8; /* larger =
> > better */
> > This would turn the number into an unsigned.
> Wow. Are you sure of this ?
> By doing this you add 1000000 to the return value (say 0x23 so 00100011).
> So now we have 10100011. Look like a negative value in 2's complement format ?
> I'm lost here :-)
at this point we are working in maching native ints ie. 32 or 64 bit. So
10100011 is actually 00000000000000000000000010100011, so a positive
value in 2's complement format.
> Anyway by doing this, I have:
> using '/dev/dvb/adapter0/frontend0'
> FE: Hauppauge Nova-S-Plus CX24123/CX24109 (SAT)
> signal%: 63| snr%: 00
> status 1f| signal a300| snr 0000| ber 003fffff| unc 003fffff| FE_HAS_LOCK
> The signal value (63%) is still very different from what I should have (~70%).
But much closer than what you had, right? Anyway, could you try these
three methods (original way, your change and my change) under different
signal conditions. That would be interresting to see the dynamics of
things. For instance try to find these values when the cable is
> > Warning: My memory of these things is a bit shaken, I could be very
> > wrong here.
> I wasn't aware of such things (1's and 2's complement format) until yesterday
> so anyway I learnt something here :-)
I learnt this at school some years back, but you know school teachings,
doesn't really stick.
More information about the linux-dvb