Ejemplo n.º 1
0
static int
get_biref_pixel (SchroMotion *motion, int i, int j, int k, int x, int y)
{
  SchroParams *params = motion->params;
  SchroMotionVector *mv;
  int value;
  int dx0, dx1, dy0, dy1;

  mv = &motion->motion_vectors[j*params->x_num_blocks + i];
  if (mv->using_global) {
    schro_motion_get_global_vector (motion, 0, x, y, &dx0, &dy0);
    schro_motion_get_global_vector (motion, 1, x, y, &dx1, &dy1);
  } else {
    dx0 = mv->dx[0];
    dy0 = mv->dy[0];
    dx1 = mv->dx[1];
    dy1 = mv->dy[1];
  }

  value = motion->ref1_weight *
    get_pixel (motion, k, motion->src1, x, y, dx0, dy0);
  value += motion->ref2_weight *
    get_pixel (motion, k, motion->src2, x, y, dx1, dy1);

  return ROUND_SHIFT(value, motion->ref_weight_precision);
}
Ejemplo n.º 2
0
static int
schro_motion_pixel_predict (SchroMotion *motion, int x, int y, int k)
{
  int i,j;
  int value;

  i = (x + motion->xoffset) / motion->xbsep - 1;
  j = (y + motion->yoffset) / motion->ybsep - 1;

  value = schro_motion_pixel_predict_block (motion, x, y, k, i, j);
  value += schro_motion_pixel_predict_block (motion, x, y, k, i + 1, j);
  value += schro_motion_pixel_predict_block (motion, x, y, k, i, j + 1);
  value += schro_motion_pixel_predict_block (motion, x, y, k, i + 1, j + 1);

  return ROUND_SHIFT(value, 6);
}
Ejemplo n.º 3
0
static int
get_ref1_pixel (SchroMotion *motion, int i, int j, int k, int x, int y)
{
  SchroParams *params = motion->params;
  SchroMotionVector *mv;
  int value;
  int dx, dy;

  mv = &motion->motion_vectors[j*params->x_num_blocks + i];
  if (mv->using_global) {
    schro_motion_get_global_vector (motion, 0, x, y, &dx, &dy);
  } else {
    dx = mv->dx[0];
    dy = mv->dy[0];
  }

  value = (motion->ref1_weight + motion->ref2_weight) *
      get_pixel (motion, k, motion->src1, x, y, dx, dy);

  return ROUND_SHIFT(value, motion->ref_weight_precision);
}
Ejemplo n.º 4
0
/***************************************************************************
 * sab_baudstd:      Function to compute the "standard " baudrate.
 *                
 *
 *     Parameters   : 
 *                  encbaud  2* the baudrate. We use the
 *                           double value so as to support 134.5 (in only)
 *                  clkspeed The board clock speed in Hz.
 *                  bgr      Value of reg BGR for baudrate(output)
 *                  ccr2     Value of reg CCR2 for baudrate (output)
 *                  ccr4     Value of reg CCR4 for baudrate (output)
 *                  truebaud The actual baudrate achieved (output).
 *
 *
 *     Return value : Return FALSE the parameters could not be computed, 
 *
 *     Prerequisite : The various ports must have been initialized
 *
 *     Remark       : Stolen from the Aurora ase driver.
 *
 *     Author       : fw
 *
 *     Revision     : Oct 9 2000, creation
 ***************************************************************************/
static unsigned int
sab8253x_baudstd(unsigned long encbaud, unsigned long clk_speed,
		 unsigned char *bgr, unsigned char *ccr2,
		 unsigned long *truebaudp)
{
  register unsigned short	 quot;
  register unsigned char	 ccr2tmp;
  
  if (encbaud == 0) 
  {
	  return FALSE;
  }
  
  /*
   * This divisor algorithm is a little strange.  The
   *  divisors are all multiples of 2, except for the
   *  magic value of 1.
   *
   * What we do is do most of the algorithm for multiples
   *  of 1, and then switch at the last minute to multiples
   *  of 2.
   */
  
  /*
   * Will we lose any information by left shifting encbaud?
   *  If so, then right shift clk_speed instead.
   */
  if (!HIZERO(encbaud, 3)) 
  {
	  quot = (unsigned short) ROUND_DIV(ROUND_SHIFT(clk_speed, 3),
					    encbaud);
	  /* quot = (clk_speed / 8) / (baud * 2) = clk_speed / (16 * baud) */
  }
  else 
  {
	  /* encbaud isn't a multiple of 2^29 (baud not mult. of 2^28) */
	  quot = (unsigned short) ROUND_DIV(clk_speed, encbaud << 3);
  }
  
  /* quot = clk_speed / (baud * 16) */
  if (quot < 2) 
  {
	  /* bgr and ccr2 should be initialized to 0 */
	  *truebaudp = ROUND_SHIFT(clk_speed, 4);
	  return TRUE;
  }
  
  /*
   * Divide the quotient by two.
   */
  quot = ROUND_SHIFT(quot, 1);
  
  if (quot <= 0x400) 
  {
	  /* quot = [1, 0x400]  -> (quot << 5) != 0 */
	  *truebaudp = ROUND_DIV(clk_speed, ((unsigned long) quot << 5));
	  quot--;
	  
	  ccr2tmp = SAB82532_CCR2_BDF;
	  if ((quot & 0x200) != 0) 
	  {
		  ccr2tmp |= SAB82532_CCR2_BR9;
	  }
	  if ((quot & 0x100) != 0) 
	  {
		  ccr2tmp |=SAB82532_CCR2_BR8;
	  }
	  
	  *ccr2 = ccr2tmp | (*ccr2 & ~(SAB82532_CCR2_BDF|SAB82532_CCR2_BR8|SAB82532_CCR2_BR9));
	  *bgr = (unsigned char) quot;
  }
  else 
  {			/* the baud rate is too small. */
	  return FALSE;
  }
  
  return TRUE;
}
Ejemplo n.º 5
0
static unsigned int
sab8253x_baudenh(unsigned long encbaud, unsigned long clk_speed,
		 unsigned char *bgr, unsigned char *ccr2,
		 unsigned long *truebaudp)
{
	register unsigned short	 tmp;
	register unsigned char	 ccr2tmp;
	unsigned long		 power2, mant;
	unsigned int			 fastclock;
	
	if (encbaud == 0) {
		return FALSE;
	}
	
	/*
	 * Keep dividing quotien by two until it is between the value of 1 and 64,
	 *  inclusive.
	 */
	
	fastclock = (clk_speed >= 10000000);	/* >= 10 MHz */
	
	for (power2 = 0; power2 < 16; power2++) 
	{
		/* divisor = baud * 2^M * 16 */
		if (!HIZERO(encbaud, power2 + 3)) 
		{
			if (!HIZERO(encbaud, power2)) 
			{	/* baud rate still too big? */
				mant = ROUND_DIV(ROUND_SHIFT(clk_speed, power2 + 3), encbaud);
				
				/* mant = (clk_speed / (8 * 2^M)) / (baud * 2) */
				/*	= clk_speed / (baud * 16 * 2^M) */
			}
			else 
			{
				mant = ROUND_DIV(ROUND_SHIFT(clk_speed, 3), encbaud << power2);
				/* mant = (clk_speed / 8) / (baud * 2 * 2^M) */
				/*	= clk_speed / (baud * 16 * 2^M) */
			}
		}
		else 
		{
			mant = ROUND_DIV(clk_speed, encbaud << (power2 + 3));
			/* mant = clk_speed / (baud * 2 * 8 * 2^M) */
			/*	    = clk_speed / (baud * 16 * 2^M) */
		}
		
		/* mant = clk_speed / (baud * 2^M * 16) */
		
		if (mant < 2
		    || (mant <= 64 && (!fastclock || power2 != 0))) 
		{
			break;
		}
	}
	
	/*
	 * Did we not succeed?  (Baud rate is too small)
	 */
	if (mant > 64) 
	{
		return FALSE;
	}
	
	/*
	 * Now, calculate the true baud rate.
	 */
	
	if (mant < 1 || (mant == 1 && power2 == 0)) 
	{
		/* bgr and ccr2 should be initialized to 0 */
		*truebaudp = ROUND_SHIFT(clk_speed, 4);
	}
	else 
	{
		*truebaudp = ROUND_DIV(clk_speed, mant << (4 + power2));
		/* divisor is not zero because mant is [1, 64] */
		mant--; /* now [0, 63] */
		
		/*
		 * Encode the N and M values into the bgr and ccr2 registers.
		 */
		
		tmp = ((unsigned short) mant) | ((unsigned short) power2 << 6);
		
		ccr2tmp = SAB82532_CCR2_BDF;
		if ((tmp & 0x200) != 0) 
		{
			ccr2tmp |= SAB82532_CCR2_BR9;
		}
		if ((tmp & 0x100) != 0) 
		{
			ccr2tmp |= SAB82532_CCR2_BR8;
		}
		
		*ccr2 = ccr2tmp | (*ccr2 & ~(SAB82532_CCR2_BDF|SAB82532_CCR2_BR8|SAB82532_CCR2_BR9));
		*bgr = (unsigned char) tmp;
	}
	
	return TRUE;
}