FreeBSD/sbin/ifconfig/sfp.c
/*
 * Converts value in @xbuf to both milliwats and dBm
 * human representation.
 */
Converts value in @xbuf to both milliwats and dBm
human representation.
Converts value in @xbuf to both milliwats and dBm human representation .
static void
convert_sff_power(struct i2c_info *ii, char *buf, size_t size, uint8_t *xbuf)
{
	uint16_t mW;
	double dbm;
	mW = (xbuf[0] << 8) + xbuf[1];
	dbm = 10.0 * log10(1.0 * mW / 10000);
	snprintf(buf, size, "%d.%02d mW (%.2f dBm)",
    	    mW / 10000, (mW % 10000) / 100, dbm);
}
static void convert_sff_power ( struct i2c_info * ii , char * buf , size_t size , uint8_t * xbuf ) { uint16_t mW ; double dbm ; mW = ( xbuf [ 0 ] << 8 ) + xbuf [ 1 ] ; dbm = 10.0 * log10 ( 1.0 * mW / 10000 ) ; snprintf ( buf , size , " " , mW / 10000 , ( mW % 10000 ) / 100 , dbm ) ; }
Converts value in @xbuf to both milliwats and dBm
 human representation.
Converts value in @xbuf to both milliwats and dBm human representation .
/* Convert mw to dbm */ /*
	 * Assume internally-calibrated data.
	 * This is always true for SFF-8346, and explicitly
	 * checked for SFF-8472.
	 */ /* Table 3.9, bit 5 is set, internally calibrated */