• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

C++ GET_BITS函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C++中GET_BITS函数的典型用法代码示例。如果您正苦于以下问题:C++ GET_BITS函数的具体用法?C++ GET_BITS怎么用?C++ GET_BITS使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了GET_BITS函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。

示例1: spi_txrx

int spi_txrx(int port, const uint8_t* outBuffer, int outLen, uint8_t* inBuffer, int inLen, int block)
{
	if(port > (NUM_SPIPORTS - 1)) {
		return -1;
	}

	SET_REG(SPIRegs[port].control, GET_REG(SPIRegs[port].control) | (1 << 2));
	SET_REG(SPIRegs[port].control, GET_REG(SPIRegs[port].control) | (1 << 3));

	spi_info[port].txBuffer = outBuffer;

	if(outLen > MAX_TX_BUFFER)
		spi_info[port].txCurrentLen = MAX_TX_BUFFER;
	else
		spi_info[port].txCurrentLen = outLen;

	spi_info[port].txTotalLen = outLen;
	spi_info[port].txDone = FALSE;

	spi_info[port].rxBuffer = inBuffer;
	spi_info[port].rxDone = FALSE;
	spi_info[port].rxCurrentLen = 0;
	spi_info[port].rxTotalLen = inLen;
	spi_info[port].counter = 0;

	spi_txdata(port, outBuffer, 0, spi_info[port].txCurrentLen);

	SET_REG(SPIRegs[port].cnt, (inLen + ((1<<spi_info[port].wordSize)-1)) >> spi_info[port].wordSize);
	SET_REG(SPIRegs[port].control, 1);

	if(block) {
		while(!spi_info[port].txDone || !spi_info[port].rxDone || GET_BITS(GET_REG(SPIRegs[port].status), 4, 4) != 0) {
			// yield
		}
		return inLen;
	} else {
		return 0;
	}
}
开发者ID:Anon0,项目名称:openiBoot,代码行数:39,代码来源:spi.c


示例2: spi_tx

int spi_tx(int port, uint8_t* buffer, int len, int block, int unknown) {
	if(port >= (NUM_SPIPORTS - 1)) {
		return -1;
	}

	SET_REG(SPIRegs[port].control, GET_REG(SPIRegs[port].control) | (1 << 2));
	SET_REG(SPIRegs[port].control, GET_REG(SPIRegs[port].control) | (1 << 3));

	spi_info[port].txBuffer = buffer;

	if(len > MAX_TX_BUFFER)
		spi_info[port].txCurrentLen = MAX_TX_BUFFER;
	else
		spi_info[port].txCurrentLen = len;

	spi_info[port].txTotalLen = len;
	spi_info[port].txDone = FALSE;

	if(unknown == 0) {
		SET_REG(SPIRegs[port].unkReg2, 0);
	}

	int i;
	for(i = 0; i < spi_info[port].txCurrentLen; i++) {
		SET_REG(SPIRegs[port].txData, buffer[i]);
	}

	SET_REG(SPIRegs[port].control, 1);

	if(block) {
		while(!spi_info[port].txDone || GET_BITS(GET_REG(SPIRegs[port].status), 4, 4) != 0) {
			// yield
		}
		return len;
	} else {
		return 0;
	}
}
开发者ID:baliking,项目名称:iphonelinux,代码行数:38,代码来源:spi.c


示例3: de_get_mclk_src

u32 de_get_mclk_src(__hdle clk_hdl)
{
	u32 i;
	u32 count;
	u32 src_sel;
	u32 reg_val;

	clk_mod_para *hdl = (clk_mod_para*)clk_hdl;
	count = sizeof(disp_clk_mod_tbl) / sizeof(clk_mod_para);

	for(i = 0; i < count; i++)
	{
		if(disp_clk_mod_tbl[i].clk_id == hdl->clk_id)
		{
			reg_val = readl(disp_clk_mod_tbl[i].mod_adr);
			src_sel = GET_BITS(disp_clk_mod_tbl[i].mod_src_shift, disp_clk_mod_tbl[i].mod_src_bit_num, reg_val);
			if(src_sel == 0)
			{
				return SYS_CLK_PLL3;
			}
			else if(src_sel == 4)
			{
				return SYS_CLK_MIPIPLL;
			}
			else if(src_sel == 5)
			{
				return SYS_CLK_PLL10;
			}
			else
			{
				break;
			}
		}
	}
	__wrn("get mod clock src fail!\n");
	return 0;
}
开发者ID:Aorjoa,项目名称:bootloader,代码行数:37,代码来源:de_clock.c


示例4: gpio_pulldown_configure

void gpio_pulldown_configure(int port, GPIOPDSetting setting)
{
	uint32_t bit = 1 << GET_BITS(port, 0, 3);

	switch(setting)
	{
		case GPIOPDDisabled:
			GPIORegs[GET_BITS(port, 8, 5)].PUD1 &= ~bit;
			GPIORegs[GET_BITS(port, 8, 5)].PUD2 &= ~bit;
			break;

		case GPIOPDUp:
			GPIORegs[GET_BITS(port, 8, 5)].PUD1 |= bit;
			GPIORegs[GET_BITS(port, 8, 5)].PUD2 &= ~bit;
			break;

		case GPIOPDDown:
			GPIORegs[GET_BITS(port, 8, 5)].PUD1 &= ~bit;
			GPIORegs[GET_BITS(port, 8, 5)].PUD2 |= bit;
			break;
	}
}
开发者ID:BluwinterFX,项目名称:openiBoot,代码行数:22,代码来源:gpio.c


示例5: aac_sensor_read

static int aac_sensor_read(struct file *filp, char __user *buf, size_t count, loff_t *f_pos)
{
    struct sensor_device *dev;
    //sensors_vec_t vec[ID_MAX];
    int x=0,y=0,z=0,temp;
	char data[255],*curr;
    char bit;

    int event;

    int result;
    
    dev=&sensor_priv;

	event=wait_for_completion_timeout(&dev->data_comp,get_poll_time());
    result = aac_sensor_query(dev,event);  //get new data

    down(&sensor_data_mutex);

    curr=data;

    if(result == 0){
        if(event){
            bit=GET_BITS(dev->values[MMA_TILT],MMA_TILT_ALERT);
            if(!bit){
                bit=GET_BITS(dev->values[3],MMA_TILT_POLA);

               // board e2
              #if defined(CONFIG_BOARD_E2)  
                if(bit==POLA_LEFT){           
                    x=180;
                }else if(bit==POLA_RIGHT){
                    x=0;
                }else if(bit==POLA_UP){
                    x=270;
                }else if(bit==POLA_DOWN){
                    x=90;
                }else{
                    event=0;
                }
              #endif
                //board 3e
              #if defined(CONFIG_BOARD_E3)  
                if(bit==POLA_LEFT){          
                    x=0;
                }else if(bit==POLA_RIGHT){
                    x=180;
                }else if(bit==POLA_UP){
                    x=270;
                }else if(bit==POLA_DOWN){
                    x=90;
                }else{
                    event=0;
                }
              #endif               
                //board g0
              #if defined(CONFIG_BOARD_G0)||defined(CONFIG_BOARD_G0_3G)   
                if(bit==POLA_LEFT){           
                    x=90;
                }else if(bit==POLA_RIGHT){
                    x=270;
                }else if(bit==POLA_UP){
                    x=180;
                }else if(bit==POLA_DOWN){
                    x=0;
                }else{
                    event=0;
                }          
              #endif
                //board h0
              #if defined(CONFIG_BOARD_H0)    
                if(bit==POLA_LEFT){           
                    x=180;
                }else if(bit==POLA_RIGHT){
                    x=0;
                }else if(bit==POLA_UP){
                    x=90;
                }else if(bit==POLA_DOWN){
                    x=270;
                }else{
                    event=0;
                }          
              #endif              
                //board i0
              #if defined(CONFIG_BOARD_I0)||defined(CONFIG_BOARD_K0)
                if(bit==POLA_LEFT){           
                    x=270;
                }else if(bit==POLA_RIGHT){
                    x=90;
                }else if(bit==POLA_UP){
                    x=0;
                }else if(bit==POLA_DOWN){
                    x=180;
                }else{
                    event=0;
                }          
              #endif
                //board j0
              #if defined(CONFIG_BOARD_J0)||defined(CONFIG_BOARD_L0)
                if(bit==POLA_LEFT){           
//.........这里部分代码省略.........
开发者ID:hellove1985,项目名称:ZT-180,代码行数:101,代码来源:sensor_aac.c


示例6: sunxi_clk_factors_set_rate

static int sunxi_clk_factors_set_rate(struct clk_hw *hw, unsigned long rate, unsigned long parent_rate)
{
	unsigned long reg;
	struct clk_factors_value factor_val;
	struct sunxi_clk_factors *factor = to_clk_factor(hw);
	struct sunxi_clk_factors_config *config = factor->config;
	unsigned long flags = 0;

	if(!factor->get_factors)
		return 0;

	/* factor_val is initialized with its original value,
	 * it's factors(such as:M,N,K,P,d1,d2...) are Random Value.
	 * if donot judge the return value of "factor->get_factors",
	 * it may change the original register value.
	 */
	if(factor->get_factors(rate, parent_rate, &factor_val) < 0)
	{
		/* cannot get right factors for clk,just break */
		WARN(1, "clk %s set rate failed! Because cannot get right factors for clk\n", hw->clk->name);
		return 0;
	}

	if(factor->flags & CLK_RATE_FLAT_FACTORS)
		return sunxi_clk_factors_set_flat_facotrs(factor, &factor_val);

	if(factor->lock)
		spin_lock_irqsave(factor->lock, flags);

	sunxi_clk_disable_plllock(factor);

	reg = factor_readl(factor, factor->reg);
	if(config->sdmwidth)
	{
		factor_writel(factor, config->sdmval, (void __iomem *)config->sdmpat);
		reg = SET_BITS(config->sdmshift, config->sdmwidth, reg, 1);
	}
	if(config->nwidth)
		reg = SET_BITS(config->nshift, config->nwidth, reg, factor_val.factorn);
	if(config->kwidth)
		reg = SET_BITS(config->kshift, config->kwidth, reg, factor_val.factork);
	if(config->mwidth)
		reg = SET_BITS(config->mshift, config->mwidth, reg, factor_val.factorm);
	if(config->pwidth)
		reg = SET_BITS(config->pshift, config->pwidth, reg, factor_val.factorp);
	if(config->d1width)
		reg = SET_BITS(config->d1shift, config->d1width, reg, factor_val.factord1);
	if(config->d2width)
		reg = SET_BITS(config->d2shift, config->d2width, reg, factor_val.factord2);
	if(config->frac) {
		reg = SET_BITS(config->modeshift, 1, reg, factor_val.frac_mode);
		reg = SET_BITS(config->outshift, 1, reg, factor_val.frac_freq);
	}
	if(config->updshift) //update for pll_ddr register
		reg = SET_BITS(config->updshift, 1, reg, 1);
	factor_writel(factor,reg, factor->reg);

#ifndef CONFIG_SUNXI_CLK_DUMMY_DEBUG
	if(GET_BITS(config->enshift, 1, reg)) {
		if (sunxi_clk_is_lock(factor)) {
			if(factor->lock)
				spin_unlock_irqrestore(factor->lock, flags);
			WARN(1, "clk %s wait lock timeout\n", factor->hw.clk->name);
			return -1;
		}
	}
#endif

	if(factor->lock)
		spin_unlock_irqrestore(factor->lock, flags);

	return 0;
}
开发者ID:xalius,项目名称:linux-pine64,代码行数:73,代码来源:clk-factors.c


示例7: decode_mcu_AC_first

boolean decode_mcu_AC_first (j_decompress_ptr cinfo, JBLOCKROW *MCU_data)
{
    phuff_entropy_ptr entropy = (phuff_entropy_ptr) cinfo->entropy;
    int Se = cinfo->Se;
    int Al = cinfo->Al;
    register int s, k, r;
    unsigned int EOBRUN;
    JBLOCKROW block;
    BITREAD_STATE_VARS;
    d_derived_tbl * tbl;

    /* Process restart marker if needed; may have to suspend */
    if (cinfo->restart_interval)
    {
        if (entropy->restarts_to_go == 0)
            if (! process_restart(cinfo))
                return FALSE;
    }

    /* If we've run out of data, just leave the MCU set to zeroes.
     * This way, we return uniform gray for the remainder of the segment.
     */
    if (! entropy->pub.insufficient_data)
    {

        /* Load up working state.
         * We can avoid loading/saving bitread state if in an EOB run.
         */
        EOBRUN = entropy->saved.EOBRUN;	/* only part of saved state we need */

        /* There is always only one block per MCU */

        if (EOBRUN > 0)		/* if it's a band of zeroes... */
            EOBRUN--;			/* ...process it now (we do nothing) */
        else
        {
            BITREAD_LOAD_STATE(cinfo,entropy->bitstate);
            block = MCU_data[0];
            tbl = entropy->ac_derived_tbl;

            for (k = cinfo->Ss; k <= Se; k++)
            {
                if ( ! br_state.HUFF_DECODE(s, bits_left, get_buffer, tbl) )
                    return FALSE;

                r = s >> 4;
                s &= 15;
                if (s)
                {
                    k += r;
                    if ( ! br_state.CHECK_BIT_BUFFER(s, bits_left, get_buffer) )
                        return FALSE;

                    r = GET_BITS(s);
                    s = HUFF_EXTEND(r, s);
                    /* Scale and output coefficient in natural (dezigzagged) order */
                    (*block)[jpeg_natural_order[k]] = (JCOEF) (s << Al);
                }
                else
                {
                    if (r == 15)  	/* ZRL */
                    {
                        k += 15;		/* skip 15 zeroes in band */
                    }
                    else  		/* EOBr, run length is 2^r + appended bits */
                    {
                        EOBRUN = 1 << r;
                        if (r)  		/* EOBr, r > 0 */
                        {
                            if ( ! br_state.CHECK_BIT_BUFFER(r, bits_left, get_buffer) )
                                return FALSE;
                            r = GET_BITS(r);
                            EOBRUN += r;
                        }
                        EOBRUN--;		/* this band is processed at this moment */
                        break;		/* force end-of-band */
                    }
                }
            }

            BITREAD_SAVE_STATE(cinfo,entropy->bitstate);
        }

        /* Completed MCU, so update state */
        entropy->saved.EOBRUN = EOBRUN;	/* only part of saved state we need */
    }
开发者ID:jiangguang5201314,项目名称:ZNginx,代码行数:86,代码来源:jdphuff.cpp


示例8: crc_free_data_register_read

/*!
    \brief      read the free data register
    \param[in]  none
    \param[out] none
    \retval     32-bit value of the free data register
*/
uint32_t crc_free_data_register_read(void)
{
    uint32_t fdata;
    fdata = GET_BITS(CRC_FDATA, 0, 7);
    return (fdata);
}
开发者ID:Arcko,项目名称:trochili,代码行数:12,代码来源:gd32f1x0_crc.c


示例9: decode_mcu_AC_first

METHODDEF       boolean decode_mcu_AC_first(j_decompress_ptr cinfo, JBLOCKROW * MCU_data)
{
	phuff_entropy_ptr entropy = (phuff_entropy_ptr) cinfo->entropy;
	int             Se = cinfo->Se;
	int             Al = cinfo->Al;
	register int    s, k, r;
	unsigned int    EOBRUN;
	JBLOCKROW       block;

	BITREAD_STATE_VARS;
	d_derived_tbl  *tbl;

	/* Process restart marker if needed; may have to suspend */
	if(cinfo->restart_interval)
	{
		if(entropy->restarts_to_go == 0)
			if(!process_restart(cinfo))
				return FALSE;
	}

	/* Load up working state.
	 * We can avoid loading/saving bitread state if in an EOB run.
	 */
	EOBRUN = entropy->saved.EOBRUN;	/* only part of saved state we care about */

	/* There is always only one block per MCU */

	if(EOBRUN > 0)				/* if it's a band of zeroes... */
		EOBRUN--;				/* ...process it now (we do nothing) */
	else
	{
		BITREAD_LOAD_STATE(cinfo, entropy->bitstate);
		block = MCU_data[0];
		tbl = entropy->ac_derived_tbl;

		for(k = cinfo->Ss; k <= Se; k++)
		{
			HUFF_DECODE(s, br_state, tbl, return FALSE, label2);
			r = s >> 4;
			s &= 15;
			if(s)
			{
				k += r;
				CHECK_BIT_BUFFER(br_state, s, return FALSE);
				r = GET_BITS(s);
				s = HUFF_EXTEND(r, s);
				/* Scale and output coefficient in natural (dezigzagged) order */
				(*block)[jpeg_natural_order[k]] = (JCOEF) (s << Al);
			}
			else
			{
				if(r == 15)
				{				/* ZRL */
					k += 15;	/* skip 15 zeroes in band */
				}
				else
				{				/* EOBr, run length is 2^r + appended bits */
					EOBRUN = 1 << r;
					if(r)
					{			/* EOBr, r > 0 */
						CHECK_BIT_BUFFER(br_state, r, return FALSE);
						r = GET_BITS(r);
						EOBRUN += r;
					}
					EOBRUN--;	/* this band is processed at this moment */
					break;		/* force end-of-band */
				}
			}
		}

		BITREAD_SAVE_STATE(cinfo, entropy->bitstate);
	}
开发者ID:SinSiXX,项目名称:Rogue-Reborn,代码行数:72,代码来源:jdphuff.c


示例10: decode_mcu

decode_mcu (j_decompress_ptr cinfo, JBLOCKROW *MCU_data)
{
  huff_entropy_ptr entropy = (huff_entropy_ptr) cinfo->entropy;
__boundcheck_metadata_store((void *)(&entropy),(void *)((size_t)(&entropy)+sizeof(entropy)*8-1));

  register int s, k, r;
  int blkn;
__boundcheck_metadata_store((void *)(&blkn),(void *)((size_t)(&blkn)+sizeof(blkn)*8-1));
int  ci;
__boundcheck_metadata_store((void *)(&ci),(void *)((size_t)(&ci)+sizeof(ci)*8-1));

  JBLOCKROW block;
__boundcheck_metadata_store((void *)(&block),(void *)((size_t)(&block)+sizeof(block)*8-1));

  BITREAD_STATE_VARS;
__boundcheck_metadata_store((void *)(&br_state),(void *)((size_t)(&br_state)+sizeof(br_state)*8-1));

  savable_state state;
__boundcheck_metadata_store((void *)(&state),(void *)((size_t)(&state)+sizeof(state)*8-1));

  d_derived_tbl * dctbl;
__boundcheck_metadata_store((void *)(&dctbl),(void *)((size_t)(&dctbl)+sizeof(dctbl)*8-1));

  d_derived_tbl * actbl;
__boundcheck_metadata_store((void *)(&actbl),(void *)((size_t)(&actbl)+sizeof(actbl)*8-1));

  jpeg_component_info * compptr;
__boundcheck_metadata_store((void *)(&compptr),(void *)((size_t)(&compptr)+sizeof(compptr)*8-1));


  /* Process restart marker if needed; may have to suspend */
  if (cinfo->restart_interval) {
    if (entropy->restarts_to_go == 0)
      if (! process_restart(cinfo))
	return FALSE;
  }

  /* Load up working state */
  BITREAD_LOAD_STATE(cinfo,entropy->bitstate);
  ASSIGN_STATE(state, entropy->saved);

  /* Outer loop handles each block in the MCU */

  for (blkn = 0; blkn < cinfo->blocks_in_MCU; blkn++) {
    block = (*(JBLOCKROW *)(__boundcheck_ptr_reference(463,13,"decode_mcu",(void *)(&MCU_data[0]),(void *)(&MCU_data[blkn]))));
    ci = cinfo->MCU_membership[_RV_insert_check(0,10,464,10,"decode_mcu",blkn)];
    compptr = cinfo->cur_comp_info[_RV_insert_check(0,4,465,15,"decode_mcu",ci)];
    dctbl = entropy->dc_derived_tbls[_RV_insert_check(0,4,466,13,"decode_mcu",compptr->dc_tbl_no)];
    actbl = entropy->ac_derived_tbls[_RV_insert_check(0,4,467,13,"decode_mcu",compptr->ac_tbl_no)];

    /* Decode a single block's worth of coefficients */

    /* Section F.2.2.1: decode the DC coefficient difference */
    HUFF_DECODE(s, br_state, dctbl, return FALSE, label1);
    if (s) {
      CHECK_BIT_BUFFER(br_state, s, return FALSE);
      r = GET_BITS(s);
      s = HUFF_EXTEND(r, s);
    }

    /* Shortcut if component's values are not interesting */
    if (! compptr->component_needed)
      goto skip_ACs;

    /* Convert DC difference to actual value, update last_dc_val */
    s += state.last_dc_val[_RV_insert_check(0,4,484,10,"decode_mcu",ci)];
    state.last_dc_val[_RV_insert_check(0,4,485,5,"decode_mcu",ci)] = s;
    /* Output the DC coefficient (assumes jpeg_natural_order[0] = 0) */
    (*(JBLOCKROW)(__boundcheck_ptr_reference(487,7,"decode_mcu",(void *)(block),(void *)(block))))[0] = (JCOEF) s;

    /* Do we need to decode the AC coefficients for this component? */
    if (compptr->DCT_scaled_size > 1) {

      /* Section F.2.2.2: decode the AC coefficients */
      /* Since zeroes are skipped, output area must be cleared beforehand */
      for (k = 1; k < DCTSIZE2; k++) {
	HUFF_DECODE(s, br_state, actbl, return FALSE, label2);
      
	r = s >> 4;
	s &= 15;
      
	if (s) {
	  k += r;
	  CHECK_BIT_BUFFER(br_state, s, return FALSE);
	  r = GET_BITS(s);
	  s = HUFF_EXTEND(r, s);
	  /* Output coefficient in natural (dezigzagged) order.
	   * Note: the extra entries in jpeg_natural_order[] will save us
	   * if k >= DCTSIZE2, which could happen if the data is corrupted.
	   */
	  (*(JBLOCKROW)(__boundcheck_ptr_reference(509,6,"decode_mcu",(void *)(block),(void *)(block))))[(*(const int *)(__boundcheck_ptr_reference(509,13,"decode_mcu",(void *)(&jpeg_natural_order[0]),(void *)(&jpeg_natural_order[k]))))] = (JCOEF) s;
	} else {
	  if (r != 15)
	    break;
	  k += 15;
	}
      }

    } else {
开发者ID:Rambonuaa,项目名称:BoundCheck4,代码行数:99,代码来源:jdhuff.c


示例11: xge_rx_poll

static int xge_rx_poll(struct net_device *ndev, unsigned int budget)
{
	struct xge_pdata *pdata = netdev_priv(ndev);
	struct device *dev = &pdata->pdev->dev;
	struct xge_desc_ring *rx_ring;
	struct xge_raw_desc *raw_desc;
	struct sk_buff *skb;
	dma_addr_t dma_addr;
	int processed = 0;
	u8 head, rx_error;
	int i, ret;
	u32 data;
	u16 len;

	rx_ring = pdata->rx_ring;
	head = rx_ring->head;

	data = xge_rd_csr(pdata, DMARXSTATUS);
	if (!GET_BITS(RXPKTCOUNT, data))
		return 0;

	for (i = 0; i < budget; i++) {
		raw_desc = &rx_ring->raw_desc[head];

		if (GET_BITS(E, le64_to_cpu(raw_desc->m0)))
			break;

		dma_rmb();

		skb = rx_ring->pkt_info[head].skb;
		rx_ring->pkt_info[head].skb = NULL;
		dma_addr = rx_ring->pkt_info[head].dma_addr;
		len = GET_BITS(PKT_SIZE, le64_to_cpu(raw_desc->m0));
		dma_unmap_single(dev, dma_addr, XGENE_ENET_STD_MTU,
				 DMA_FROM_DEVICE);

		rx_error = GET_BITS(D, le64_to_cpu(raw_desc->m2));
		if (unlikely(rx_error)) {
			pdata->stats.rx_errors++;
			dev_kfree_skb_any(skb);
			goto out;
		}

		skb_put(skb, len);
		skb->protocol = eth_type_trans(skb, ndev);

		pdata->stats.rx_packets++;
		pdata->stats.rx_bytes += len;
		napi_gro_receive(&pdata->napi, skb);
out:
		ret = xge_refill_buffers(ndev, 1);
		xge_wr_csr(pdata, DMARXSTATUS, 1);
		xge_wr_csr(pdata, DMARXCTRL, 1);

		if (ret)
			break;

		head = (head + 1) & (XGENE_ENET_NUM_DESC - 1);
		processed++;
	}

	rx_ring->head = head;

	return processed;
}
开发者ID:Lyude,项目名称:linux,代码行数:65,代码来源:main.c


示例12: decode_mcus

decode_mcus (j_decompress_ptr cinfo, JDIFFIMAGE diff_buf,
         JDIMENSION MCU_row_num, JDIMENSION MCU_col_num, JDIMENSION nMCU)
{
  j_lossless_d_ptr losslsd = (j_lossless_d_ptr) cinfo->codec;
  lhuff_entropy_ptr entropy = (lhuff_entropy_ptr) losslsd->entropy_private;
  unsigned int mcu_num;
  int sampn, ci, yoffset, MCU_width, ptrn;
  BITREAD_STATE_VARS;

  /* Set output pointer locations based on MCU_col_num */
  for (ptrn = 0; ptrn < entropy->num_output_ptrs; ptrn++) {
    ci = entropy->output_ptr_info[ptrn].ci;
    yoffset = entropy->output_ptr_info[ptrn].yoffset;
    MCU_width = entropy->output_ptr_info[ptrn].MCU_width;
    entropy->output_ptr[ptrn] =
      diff_buf[ci][MCU_row_num + (JDIMENSION)yoffset] + MCU_col_num * (JDIMENSION)MCU_width;
  }

  /*
   * If we've run out of data, zero out the buffers and return.
   * By resetting the undifferencer, the output samples will be CENTERJSAMPLE.
   *
   * NB: We should find a way to do this without interacting with the
   * undifferencer module directly.
   */
  if (entropy->insufficient_data) {
    for (ptrn = 0; ptrn < entropy->num_output_ptrs; ptrn++)
      jzero_far((void FAR *) entropy->output_ptr[ptrn],
        nMCU * (size_t)entropy->output_ptr_info[ptrn].MCU_width * SIZEOF(JDIFF));

    (*losslsd->predict_process_restart) (cinfo);
  }

  else {

    /* Load up working state */
    BITREAD_LOAD_STATE(cinfo,entropy->bitstate);

    /* Outer loop handles the number of MCU requested */

    for (mcu_num = 0; mcu_num < nMCU; mcu_num++) {

      /* Inner loop handles the samples in the MCU */
      for (sampn = 0; sampn < cinfo->data_units_in_MCU; sampn++) {
    d_derived_tbl * dctbl = entropy->cur_tbls[sampn];
    register int s, r;

    /* Section H.2.2: decode the sample difference */
    HUFF_DECODE(s, br_state, dctbl, return mcu_num, label1);
    if (s) {
      if (s == 16)  /* special case: always output 32768 */
        s = 32768;
      else {    /* normal case: fetch subsequent bits */
        CHECK_BIT_BUFFER(br_state, s, return mcu_num);
        r = GET_BITS(s);
        s = HUFF_EXTEND(r, s);
      }
    }

    /* Output the sample difference */
    *entropy->output_ptr[entropy->output_ptr_index[sampn]]++ = (JDIFF) s;
      }

      /* Completed MCU, so update state */
      BITREAD_SAVE_STATE(cinfo,entropy->bitstate);
    }
  }

 return nMCU;
}
开发者ID:Anvendir,项目名称:aplikacjaSerwer,代码行数:70,代码来源:jdlhuff.c


示例13: spiIRQHandler

static void spiIRQHandler(uint32_t port) {
	if(port >= (NUM_SPIPORTS - 1)) {
		return;
	}

	uint32_t status = GET_REG(SPIRegs[port].status);
	if(status & (1 << 3)) {
		spi_info[port].counter++;
	}

	int i;

	if(status & (1 << 1)) {
		while(TRUE) {
			// take care of tx
			if(spi_info[port].txBuffer != NULL) {
				if(spi_info[port].txCurrentLen < spi_info[port].txTotalLen) {
					int toTX = spi_info[port].txTotalLen - spi_info[port].txCurrentLen;
					int canTX = MAX_TX_BUFFER - TX_BUFFER_LEFT(status);

					if(toTX > canTX)
						toTX = canTX;

					for(i = 0; i < toTX; i++) {
						SET_REG(SPIRegs[port].txData, spi_info[port].txBuffer[spi_info[port].txCurrentLen + i]);
					}

					spi_info[port].txCurrentLen += toTX;

				} else {
					spi_info[port].txDone = TRUE;
					spi_info[port].txBuffer = NULL;
				}
			}

dorx:
			// take care of rx
			if(spi_info[port].rxBuffer == NULL)
				break;

			int toRX = spi_info[port].rxTotalLen - spi_info[port].rxCurrentLen;
			int canRX = GET_BITS(status, 8, 4);

			if(toRX > canRX)
				toRX = canRX;

			for(i = 0; i < toRX; i++) {
				spi_info[port].rxBuffer[spi_info[port].rxCurrentLen + i] = GET_REG(SPIRegs[port].rxData);
			}

			spi_info[port].rxCurrentLen += toRX;

			if(spi_info[port].rxCurrentLen < spi_info[port].rxTotalLen)
				break;

			spi_info[port].rxDone = TRUE;
			spi_info[port].rxBuffer = NULL;

		}


	} else  if(status & (1 << 0)) {
		// jump into middle of the loop to handle rx only, stupidly
		goto dorx;
	}

	// acknowledge interrupt handling complete
	SET_REG(SPIRegs[port].status, status);
}
开发者ID:baliking,项目名称:iphonelinux,代码行数:69,代码来源:spi.c


示例14: decode_mcu

decode_mcu (j_decompress_ptr cinfo, JBLOCKROW *MCU_data)
{
  j_lossy_d_ptr lossyd = (j_lossy_d_ptr) cinfo->codec;
  shuff_entropy_ptr entropy = (shuff_entropy_ptr) lossyd->entropy_private;
  int blkn;
  BITREAD_STATE_VARS;
  savable_state state;

  /* Process restart marker if needed; may have to suspend */
  if (cinfo->restart_interval) {
    if (entropy->restarts_to_go == 0)
      if (! process_restart(cinfo))
	return FALSE;
  }

  /* If we've run out of data, just leave the MCU set to zeroes.
   * This way, we return uniform gray for the remainder of the segment.
   */
  if (! entropy->insufficient_data) {

    /* Load up working state */
    BITREAD_LOAD_STATE(cinfo,entropy->bitstate);
    ASSIGN_STATE(state, entropy->saved);

    /* Outer loop handles each block in the MCU */

    for (blkn = 0; blkn < cinfo->data_units_in_MCU; blkn++) {
      JBLOCKROW block = MCU_data[blkn];
      d_derived_tbl * dctbl = entropy->dc_cur_tbls[blkn];
      d_derived_tbl * actbl = entropy->ac_cur_tbls[blkn];
      register int s, k, r;

      /* Decode a single block's worth of coefficients */

      /* Section F.2.2.1: decode the DC coefficient difference */
      HUFF_DECODE(s, br_state, dctbl, return FALSE, label1);
      if (s) {
	CHECK_BIT_BUFFER(br_state, s, return FALSE);
	r = GET_BITS(s);
	s = HUFF_EXTEND(r, s);
      }

      if (entropy->dc_needed[blkn]) {
	/* Convert DC difference to actual value, update last_dc_val */
	int ci = cinfo->MCU_membership[blkn];
	s += state.last_dc_val[ci];
	state.last_dc_val[ci] = s;
	/* Output the DC coefficient (assumes jpeg_natural_order[0] = 0) */
	(*block)[0] = (JCOEF) s;
      }

      if (entropy->ac_needed[blkn]) {

	/* Section F.2.2.2: decode the AC coefficients */
	/* Since zeroes are skipped, output area must be cleared beforehand */
	for (k = 1; k < DCTSIZE2; k++) {
	  HUFF_DECODE(s, br_state, actbl, return FALSE, label2);
      
	  r = s >> 4;
	  s &= 15;
      
	  if (s) {
	    k += r;
	    CHECK_BIT_BUFFER(br_state, s, return FALSE);
	    r = GET_BITS(s);
	    s = HUFF_EXTEND(r, s);
	    /* Output coefficient in natural (dezigzagged) order.
	     * Note: the extra entries in jpeg_natural_order[] will save us
	     * if k >= DCTSIZE2, which could happen if the data is corrupted.
	     */
	    (*block)[jpeg_natural_order[k]] = (JCOEF) s;
	  } else {
	    if (r != 15)
	      break;
	    k += 15;
	  }
	}

      } else {

	/* Section F.2.2.2: decode the AC coefficients */
	/* In this path we just discard the values */
	for (k = 1; k < DCTSIZE2; k++) {
开发者ID:151706061,项目名称:ClearCanvas,代码行数:83,代码来源:jdshuff.c


示例15: gst_mpeg4_params_parse_vo

static gboolean
gst_mpeg4_params_parse_vo (MPEG4Params * params, GstBitReader * br)
{
  guint32 bits;
  guint16 time_increment_resolution = 0;
  guint16 fixed_time_increment = 0;
  gint aspect_ratio_width = -1, aspect_ratio_height = -1;
  gint height = -1, width = -1;

  /* expecting a video object startcode */
  GET_BITS (br, 32, &bits);
  if (bits > 0x11F)
    goto failed;

  /* expecting a video object layer startcode */
  GET_BITS (br, 32, &bits);
  if (bits < 0x120 || bits > 0x12F)
    goto failed;

  /* ignore random accessible vol  and video object type indication */
  GET_BITS (br, 9, &bits);

  GET_BITS (br, 1, &bits);
  if (bits) {
    /* skip video object layer verid and priority */
    GET_BITS (br, 7, &bits);
  }

  /* aspect ratio info */
  GET_BITS (br, 4, &bits);
  if (bits == 0)
    goto failed;

  /* check if aspect ratio info  is extended par */
  if (bits == 0xf) {
    GET_BITS (br, 8, &bits);
    aspect_ratio_width = bits;
    GET_BITS (br, 8, &bits);
    aspect_ratio_height = bits;
  } else if (bits < 0x6) {
    aspect_ratio_width = aspect_ratio_table[bits][0];
    aspect_ratio_height = aspect_ratio_table[bits][1];
  }
  GST_DEBUG ("aspect ratio %d/%d", aspect_ratio_width, aspect_ratio_height);

  GET_BITS (br, 1, &bits);
  if (bits) {
    /* vol control parameters, skip chroma and low delay */
    GET_BITS (br, 3, &bits);
    GET_BITS (br, 1, &bits);
    if (bits) {
      /* skip vbv_parameters */
      GET_BITS (br, 79, &bits);
    }
  }

  /* layer shape */
  GET_BITS (br, 2, &bits);
  /* only support rectangular */
  if (bits != 0)
    goto failed;

  MARKER_BIT (br);
  GET_BITS (br, 16, &bits);
  time_increment_resolution = bits;
  MARKER_BIT (br);

  GST_DEBUG ("time increment resolution %d", time_increment_resolution);

  GET_BITS (br, 1, &bits);
  if (bits) {
    /* fixed time increment */
    int n;

    /* Length of the time increment is the minimal number of bits needed to
     * represent time_increment_resolution */
    for (n = 0; (time_increment_resolution >> n) != 0; n++);
    GET_BITS (br, n, &bits);

    fixed_time_increment = bits;
  } else {
开发者ID:LCW523,项目名称:gst-plugins-bad,代码行数:81,代码来源:mpeg4parse.c


示例16: sunxi_clk_is_lock

static int sunxi_clk_is_lock(struct sunxi_clk_factors *factor)
{
	volatile u32 reg;
	u32 loop = 5000;

	switch (factor->lock_mode) {
		case PLL_LOCK_NEW_MODE: {
			/* enable pll new mode */
			reg = factor_readl(factor, factor->pll_lock_ctrl_reg);
			reg = SET_BITS(28, 1, reg, 1);
			factor_writel(factor, reg, factor->pll_lock_ctrl_reg);

			reg = factor_readl(factor, factor->pll_lock_ctrl_reg);
			reg = SET_BITS(factor->lock_en_bit, 1, reg, 1);
			factor_writel(factor, reg, factor->pll_lock_ctrl_reg);

			while(loop--) {
				reg = factor_readl(factor,factor->lock_reg);
				if(GET_BITS(factor->lock_bit, 1, reg)) {
					udelay(20);
					break;
				} else {
					udelay(1);
				}
			}

			reg = factor_readl(factor,factor->pll_lock_ctrl_reg);
			reg = SET_BITS(factor->lock_en_bit, 1, reg, 0);
			factor_writel(factor,reg, factor->pll_lock_ctrl_reg);

			reg = factor_readl(factor, factor->pll_lock_ctrl_reg);
			reg = SET_BITS(28, 1, reg, 0);
			factor_writel(factor, reg, factor->pll_lock_ctrl_reg);

			if(!loop) {
#if (defined CONFIG_FPGA_V4_PLATFORM) || (defined CONFIG_FPGA_V7_PLATFORM)
				printk("clk %s wait lock timeout\n", factor->hw.clk->name);
				return 0;
#else
				WARN(1, "clk %s wait lock timeout\n", factor->hw.clk->name);
				return -1;
#endif
			}
			return 0;
		}
		case PLL_LOCK_OLD_MODE:
		case PLL_LOCK_NONE_MODE: {
			while(loop--) {
				reg = factor_readl(factor,factor->lock_reg);
				if(GET_BITS(factor->lock_bit, 1, reg)) {
					udelay(20);
					break;
				} else {
					udelay(1);
				}
			}

			if(!loop) {
#if (defined CONFIG_FPGA_V4_PLATFORM) || (defined CONFIG_FPGA_V7_PLATFORM)
				printk("clk %s wait lock timeout\n", factor->hw.clk->name);
#else
				WARN(1, "clk %s wait lock timeout\n", factor->hw.clk->name);
				return -1;
#endif
			}
			return 0;
		}
		default: {
			WARN(1, "invaid pll lock mode:%u\n", factor->lock_mode);
			return -1;
		}
	}
}
开发者ID:xalius,项目名称:linux-pine64,代码行数:73,代码来源:clk-factors.c


示例17: decode_mcu

decode_mcu (j_decompress_ptr cinfo, JBLOCKROW *MCU_data)
{
    huff_entropy_ptr entropy = (huff_entropy_ptr) cinfo->entropy;
    register int s, k, r;
    int blkn, ci;
    JBLOCKROW block;
    BITREAD_STATE_VARS;
    savable_state state;
    d_derived_tbl * dctbl;
    d_derived_tbl * actbl;
    jpeg_component_info * compptr;

    /* Process restart marker if needed; may have to suspend */
    if (cinfo->restart_interval) {
        if (entropy->restarts_to_go == 0)
            if (! process_restart(cinfo))
                return FALSE;
    }

    /* Load up working state */
    BITREAD_LOAD_STATE(cinfo,entropy->bitstate);
    ASSIGN_STATE(state, entropy->saved);

    /* Outer loop handles each block in the MCU */

    for (blkn = 0; blkn < cinfo->blocks_in_MCU; blkn++) {
        block = MCU_data[blkn];
        ci = cinfo->MCU_membership[blkn];
        compptr = cinfo->cur_comp_info[ci];
        dctbl = entropy->dc_derived_tbls[compptr->dc_tbl_no];
        actbl = entropy->ac_derived_tbls[compptr->ac_tbl_no];

        /* Decode a single block's worth of coefficients */

        /* Section F.2.2.1: decode the DC coefficient difference */
        HUFF_DECODE(s, br_state, dctbl, return FALSE, label1);
        if (s) {
            CHECK_BIT_BUFFER(br_state, s, return FALSE);
            r = GET_BITS(s);
            s = HUFF_EXTEND(r, s);
        }

        /* Shortcut if component's values are not interesting */
        if (! compptr->component_needed)
            goto skip_ACs;

        /* Convert DC difference to actual value, update last_dc_val */
        s += state.last_dc_val[ci];
        state.last_dc_val[ci] = s;
        /* Output the DC coefficient (assumes jpeg_natural_order[0] = 0) */
        (*block)[0] = (JCOEF) s;

        /* Do we need to decode the AC coefficients for this component? */
        if (compptr->DCT_scaled_size > 1) {

            /* Section F.2.2.2: decode the AC coefficients */
            /* Since zeroes are skipped, output area must be cleared beforehand */
            for (k = 1; k < DCTSIZE2; k++) {
                HUFF_DECODE(s, br_state, actbl, return FALSE, label2);

                r = s >> 4;
                s &= 15;

                if (s) {
                    k += r;
                    CHECK_BIT_BUFFER(br_state, s, return FALSE);
                    r = GET_BITS(s);
                    s = HUFF_EXTEND(r, s);
                    /* Output coefficient in natural (dezigzagged) order.
                     * Note: the extra entries in jpeg_natural_order[] will save us
                     * if k >= DCTSIZE2, which could happen if the data is corrupted.
                     */
                    (*block)[jpeg_natural_order[k]] = (JCOEF) s;
                } else {
                    if (r != 15)
                        break;
                    k += 15;
                }
            }

        } else {
开发者ID:vugluskr86,项目名称:SeaOfMemes,代码行数:81,代码来源:jdhuff.cpp


示例18: gpio_setup

int gpio_setup() {
#if !defined(CONFIG_IPHONE_4) && !defined(CONFIG_IPAD)
	int i;

	GPIORegs = (GPIORegisters*) GPIO;

	for(i = 0; i < GPIO_NUMINTGROUPS; i++) {
		// writes to all the interrupt status register to acknowledge and discard any pending
		SET_REG(GPIOIC + GPIO_INTSTAT + (i * 0x4), GPIO_INTSTAT_RESET);

		// disable all interrupts
		SET_REG(GPIOIC + GPIO_INTEN + (i * 0x4), GPIO_INTEN_RESET);
	}

	memset(InterruptGroups, 0, sizeof(InterruptGroups));

	interrupt_install(0x21, gpio_handle_interrupt, 0);
	interrupt_install(0x20, gpio_handle_interrupt, 1);
	interrupt_install(0x1f, gpio_handle_interrupt, 2);
	interrupt_install(0x03, gpio_handle_interrupt, 3);
	interrupt_install(0x02, gpio_handle_interrupt, 4);
	interrupt_install(0x01, gpio_handle_interrupt, 5);
	interrupt_install(0x00, gpio_handle_interrupt, 6);

	interrupt_enable(0x21);
	interrupt_enable(0x20);
	interrupt_enable(0x1f);
	interrupt_enable(0x03);
	interrupt_enable(0x02);
	interrupt_enable(0x01);
	interrupt_enable(0x00);

	clock_gate_switch(GPIO_CLOCKGATE, ON);

	return 0;
#else
	uint8_t v[8];
	if (!(GET_REG(GPIO) & 1)) {
		gpio_set(0x502, 0);
		gpio_set(0x503, 0);
		gpio_set(0x504, 0);
		gpio_switch(0x502, 0xFFFFFFFF);
		gpio_switch(0x503, 0xFFFFFFFF);
		gpio_switch(0x504, 0xFFFFFFFF);
		gpio_set(0x202, 0);
		gpio_set(0x301, 0);
		gpio_set(0x304, 0);
		gpio_set(0x305, 0);
		gpio_switch(0x202, 0xFFFFFFFF);
		gpio_switch(0x301, 0xFFFFFFFF);
		gpio_switch(0x304, 0xFFFFFFFF);
		gpio_switch(0x305, 0xFFFFFFFF);
		udelay(100);
		v[0] = chipid_get_gpio();
		v[1] = gpio_pin_state(0x504);
		v[2] = gpio_pin_state(0x503);
		v[3] = gpio_pin_state(0x502);
		v[4] = gpio_pin_state(0x305);
		v[5] = gpio_pin_state(0x304);
		v[6] = gpio_pin_state(0x301);
		v[7] = gpio_pin_state(0x202);
		gpio_set(0x502, 4);
		gpio_set(0x503, 4);
		gpio_set(0x504, 4);
		gpio_set(0x202, 4);
		gpio_set(0x301, 4);
		gpio_set(0x304, 4);
		gpio_set(0x305, 4);
		uint32_t new_status = ((v[0] << 3 | v[1] << 2 | v[2] << 1 | v[3]) << 16) | ((v[4] << 3 | v[5] << 2 | v[6] << 1 | v[7]) << 8) | 1;
		SET_REG(POWER + POWER_ID, (GET_BITS(GET_REG(POWER + POWER_ID), 24, 8)) | (new_status & 0xFFFFFF));
	}

	return 0;
#endif
}
开发者ID:bhushangahire,项目名称:openiBoot,代码行数:75,代码来源:gpio.c


示例19: dma_set_aes

int dma_set_aes(int channel, dmaAES* dmaAESInfo) {
	//bufferPrintf("cdma: set_aes.\r\n");

    DMAInfo* dma = &dmaInfo[channel];
	uint32_t value;
	int i;

	dma->dmaAESInfo = dmaAESInfo;
	if(!dmaAESInfo)
		return 0;

	if (!dma->dmaAES_channel)
	{
		EnterCriticalSection();
		for (i = 2; i < 9; i++) {
			if (dmaAES_channel_used & (1 << i))
				continue;

			dmaAES_channel_used |= (1 << i);
			dma->dmaAES_channel = i;
			break;
		}
		LeaveCriticalSection();

		if (!dma->dmaAES_channel)
			system_panic("CDMA: no AES filter contexts: 0x%08x\r\n", dmaAES_channel_used);
	}

	uint32_t dmaAES_channel_reg = dma->dmaAES_channel << 12;

	value = ((channel & 0xFF) << 8) | 0x20000;
	if (!(dma->dmaAESInfo->inverse & 0xF))
		value |= 0x30000;

	switch(GET_BITS(dma->dmaAESInfo->type, 28, 4))
	{
		case 2: // AES 256
			value |= 0x80000;
			break;

		case 1: // AES 192
			value |= 0x40000;
			break;

		case 0: // AES 128
			break;

		default: // Fail
			return -1;
	}

	uint32_t someval = dma->dmaAESInfo->type & 0xFFF;
	if(someval == 0x200)
	{
		value |= 0x200000;
	}
	else if(someval == 0x201)
	{
		value |= 0x400000;
	}
	else if(someval == 0)
	{
		switch(GET_BITS(dma->dmaAESInfo->type, 28, 4))
		{
		case 2: // AES-256
			SET_REG(DMA + DMA_AES + DMA_AES_KEY_7 + dmaAES_channel_reg, dma->dmaAESInfo->key[7]);
			SET_REG(DMA + DMA_AES + DMA_AES_KEY_6 + dmaAES_channel_reg, dma->dmaAESInfo->key[6]);

		case 1: // AES-192
			SET_REG(DMA + DMA_AES + DMA_AES_KEY_5 + dmaAES_channel_reg, dma->dmaAESInfo->key[5]);
			SET_REG(DMA + DMA_AES + DMA_AES_KEY_4 + dmaAES_channel_reg, dma->dmaAESInfo->key[4]);

		case 0: // AES-128
			SET_REG(DMA + DMA_AES + DMA_AES_KEY_3 + dmaAES_channel_reg, dma->dmaAESInfo->key[3]);
			SET_REG(DMA + DMA_AES + DMA_AES_KEY_2 + dmaAES_channel_reg, dma->dmaAESInfo->key[2]);
			SET_REG(DMA + DMA_AES + DMA_AES_KEY_1 + dmaAES_channel_reg, dma->dmaAESInfo->key[1]);
			SET_REG(DMA + DMA_AES + DMA_AES_KEY_0 + dmaAES_channel_reg, dma->dmaAESInfo->key[0]);
			value |= 0x100000;
			break;

		default:
			return -1;
		}
	}
	else if(someval != 0x100)
		return -1;

	SET_REG(DMA + dm 

鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C++ GET_BSS_ROLE函数代码示例发布时间:2022-05-30
下一篇:
C++ GET_BITFIELD函数代码示例发布时间:2022-05-30
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap