当前位置: 首页>>代码示例>>C++>>正文


C++ i2c_transfer函数代码示例

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


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

示例1: philips_fmd1216_pll_init

static int philips_fmd1216_pll_init(struct dvb_frontend *fe)
{
	struct cx8802_dev *dev= fe->dvb->priv;

	/* this message is to set up ATC and ALC */
	static u8 fmd1216_init[] = { 0x0b, 0xdc, 0x9c, 0xa0 };
	struct i2c_msg msg =
		{ .addr = dev->core->pll_addr, .flags = 0,
		  .buf = fmd1216_init, .len = sizeof(fmd1216_init) };
	int err;

	if (fe->ops.i2c_gate_ctrl)
		fe->ops.i2c_gate_ctrl(fe, 1);
	if ((err = i2c_transfer(&dev->core->i2c_adap, &msg, 1)) != 1) {
		if (err < 0)
			return err;
		else
			return -EREMOTEIO;
	}

	return 0;
}

static int dntv_live_dvbt_pro_tuner_set_params(struct dvb_frontend* fe,
					       struct dvb_frontend_parameters* params)
{
	struct cx8802_dev *dev= fe->dvb->priv;
	u8 buf[4];
	struct i2c_msg msg =
		{ .addr = dev->core->pll_addr, .flags = 0,
		  .buf = buf, .len = 4 };
	int err;

	/* Switch PLL to DVB mode */
	err = philips_fmd1216_pll_init(fe);
	if (err)
		return err;

	/* Tune PLL */
	dvb_pll_configure(dev->core->pll_desc, buf,
			  params->frequency,
			  params->u.ofdm.bandwidth);
	if (fe->ops.i2c_gate_ctrl)
		fe->ops.i2c_gate_ctrl(fe, 1);
	if ((err = i2c_transfer(&dev->core->i2c_adap, &msg, 1)) != 1) {

		printk(KERN_WARNING "cx88-dvb: %s error "
		       "(addr %02x <- %02x, err = %i)\n",
		       __FUNCTION__, dev->core->pll_addr, buf[0], err);
		if (err < 0)
			return err;
		else
			return -EREMOTEIO;
	}

	return 0;
}

static struct mt352_config dntv_live_dvbt_pro_config = {
	.demod_address = 0x0f,
	.no_tuner      = 1,
	.demod_init    = dntv_live_dvbt_pro_demod_init,
};
#endif

static struct zl10353_config dvico_fusionhdtv_hybrid = {
	.demod_address = 0x0f,
	.no_tuner      = 1,
};

static struct zl10353_config dvico_fusionhdtv_plus_v1_1 = {
	.demod_address = 0x0f,
};

static struct cx22702_config connexant_refboard_config = {
	.demod_address = 0x43,
	.output_mode   = CX22702_SERIAL_OUTPUT,
};

static struct cx22702_config hauppauge_hvr_config = {
	.demod_address = 0x63,
	.output_mode   = CX22702_SERIAL_OUTPUT,
};

static int or51132_set_ts_param(struct dvb_frontend* fe, int is_punctured)
{
	struct cx8802_dev *dev= fe->dvb->priv;
	dev->ts_gen_cntrl = is_punctured ? 0x04 : 0x00;
	return 0;
}

static struct or51132_config pchdtv_hd3000 = {
	.demod_address = 0x15,
	.set_ts_params = or51132_set_ts_param,
};

static int lgdt330x_pll_rf_set(struct dvb_frontend* fe, int index)
{
	struct cx8802_dev *dev= fe->dvb->priv;
	struct cx88_core *core = dev->core;
//.........这里部分代码省略.........
开发者ID:ivucica,项目名称:linux,代码行数:101,代码来源:cx88-dvb.c

示例2: atbm8830_write_reg

static int atbm8830_write_reg(struct atbm_state *priv, u16 reg, u8 data)
{
	int ret = 0;
	u8 dev_addr;
	u8 buf1[] = { reg >> 8, reg & 0xFF };
	u8 buf2[] = { data };
	struct i2c_msg msg1 = { .flags = 0, .buf = buf1, .len = 2 };
	struct i2c_msg msg2 = { .flags = 0, .buf = buf2, .len = 1 };

	dev_addr = priv->config->demod_address;
	msg1.addr = dev_addr;
	msg2.addr = dev_addr;

	if (debug >= 2)
		dprintk("%s: reg=0x%04X, data=0x%02X\n", __func__, reg, data);

	ret = i2c_transfer(priv->i2c, &msg1, 1);
	if (ret != 1)
		return -EIO;

	ret = i2c_transfer(priv->i2c, &msg2, 1);
	return (ret != 1) ? -EIO : 0;
}

static int atbm8830_read_reg(struct atbm_state *priv, u16 reg, u8 *p_data)
{
	int ret;
	u8 dev_addr;

	u8 buf1[] = { reg >> 8, reg & 0xFF };
	u8 buf2[] = { 0 };
	struct i2c_msg msg1 = { .flags = 0, .buf = buf1, .len = 2 };
	struct i2c_msg msg2 = { .flags = I2C_M_RD, .buf = buf2, .len = 1 };

	dev_addr = priv->config->demod_address;
	msg1.addr = dev_addr;
	msg2.addr = dev_addr;

	ret = i2c_transfer(priv->i2c, &msg1, 1);
	if (ret != 1) {
		dprintk("%s: error reg=0x%04x, ret=%i\n", __func__, reg, ret);
		return -EIO;
	}

	ret = i2c_transfer(priv->i2c, &msg2, 1);
	if (ret != 1)
		return -EIO;

	*p_data = buf2[0];
	if (debug >= 2)
		dprintk("%s: reg=0x%04X, data=0x%02X\n",
			__func__, reg, buf2[0]);

	return 0;
}

/* Lock register latch so that multi-register read is atomic */
static inline int atbm8830_reglatch_lock(struct atbm_state *priv, int lock)
{
	return atbm8830_write_reg(priv, REG_READ_LATCH, lock ? 1 : 0);
}

static int set_osc_freq(struct atbm_state *priv, u32 freq /*in kHz*/)
{
	u32 val;
	u64 t;

	/* 0x100000 * freq / 30.4MHz */
	t = (u64)0x100000 * freq;
	do_div(t, 30400);
	val = t;

	atbm8830_write_reg(priv, REG_OSC_CLK, val);
	atbm8830_write_reg(priv, REG_OSC_CLK + 1, val >> 8);
	atbm8830_write_reg(priv, REG_OSC_CLK + 2, val >> 16);

	return 0;
}

static int set_if_freq(struct atbm_state *priv, u32 freq /*in kHz*/)
{

	u32 fs = priv->config->osc_clk_freq;
	u64 t;
	u32 val;
	u8 dat;

	if (freq != 0) {
		/* 2 * PI * (freq - fs) / fs * (2 ^ 22) */
		t = (u64) 2 * 31416 * (freq - fs);
		t <<= 22;
		do_div(t, fs);
		do_div(t, 1000);
		val = t;

		atbm8830_write_reg(priv, REG_TUNER_BASEBAND, 1);
		atbm8830_write_reg(priv, REG_IF_FREQ, val);
		atbm8830_write_reg(priv, REG_IF_FREQ+1, val >> 8);
		atbm8830_write_reg(priv, REG_IF_FREQ+2, val >> 16);

//.........这里部分代码省略.........
开发者ID:119-org,项目名称:hi3518-osdrv,代码行数:101,代码来源:atbm8830.c

示例3: i2c_transfer

		{
			.addr	= this_client->addr,
			.flags	= 0,
			.len	= 1,
			.buf	= rxdata,
		},
		{
			.addr	= this_client->addr,
			.flags	= I2C_M_RD,
			.len	= length,
			.buf	= rxdata,
		},
	};

    //msleep(1);
	ret = i2c_transfer(this_client->adapter, msgs, 2);
	if (ret < 0)
		pr_err("msg %s i2c read error: %d\n", __func__, ret);
	
	return ret;
}
/***********************************************************************************************
Name	:	 

Input	:	
                     

Output	:	

function	:	
开发者ID:abazad,项目名称:7300-kern,代码行数:30,代码来源:focaltech5x06.c

示例4: cvmx_twsix_read_ia

/**
 * Do a twsi read from a 7 bit device address using an (optional) internal address.
 * Up to 8 bytes can be read at a time.
 *
 * @param twsi_id   which Octeon TWSI bus to use
 * @param dev_addr  Device address (7 bit)
 * @param internal_addr
 *                  Internal address.  Can be 0, 1 or 2 bytes in width
 * @param num_bytes Number of data bytes to read
 * @param ia_width_bytes
 *                  Internal address size in bytes (0, 1, or 2)
 * @param data      Pointer argument where the read data is returned.
 *
 * @return read data returned in 'data' argument
 *         Number of bytes read on success
 *         -1 on failure
 */
int cvmx_twsix_read_ia(int twsi_id, uint8_t dev_addr, uint16_t internal_addr, int num_bytes, int ia_width_bytes, uint64_t *data)
{
#ifdef CVMX_BUILD_FOR_LINUX_KERNEL
# if defined(CONFIG_I2C) || defined(CONFIG_I2C_MODULE)
	struct i2c_adapter *adapter;
	u8 data_buf[8];
	u8 addr_buf[8];
	struct i2c_msg msg[2];
	uint64_t r;
	int i, j;

	if (ia_width_bytes == 0)
		return cvmx_twsix_read(twsi_id, dev_addr, num_bytes, data);

	BUG_ON(ia_width_bytes > 2);
	BUG_ON(num_bytes > 8 || num_bytes < 1);

	adapter = __cvmx_twsix_get_adapter(twsi_id);
	if (adapter == NULL)
		return -1;

	for (j = 0, i = ia_width_bytes - 1; i >= 0; i--, j++)
		addr_buf[j] = (u8)(internal_addr >> (i * 8));

	msg[0].addr = dev_addr;
	msg[0].flags = 0;
	msg[0].len = ia_width_bytes;
	msg[0].buf = addr_buf;

	msg[1].addr = dev_addr;
	msg[1].flags = I2C_M_RD;
	msg[1].len = num_bytes;
	msg[1].buf = data_buf;

	i = i2c_transfer(adapter, msg, 2);

	i2c_put_adapter(adapter);

	if (i == 2) {
		r = 0;
		for (i = 0; i < num_bytes; i++)
			r = (r << 8) | data_buf[i];
		*data = r;
		return num_bytes;
	} else {
		return -1;
	}
# else
	BUG(); /* The I2C driver is not compiled in */
# endif
#else
	cvmx_mio_twsx_sw_twsi_t sw_twsi_val;
	cvmx_mio_twsx_sw_twsi_ext_t twsi_ext;

	if (num_bytes < 1 || num_bytes > 8 || !data || ia_width_bytes < 0 || ia_width_bytes > 2)
		return -1;

	twsi_ext.u64 = 0;
	sw_twsi_val.u64 = 0;
	sw_twsi_val.s.v = 1;
	sw_twsi_val.s.r = 1;
	sw_twsi_val.s.sovr = 1;
	sw_twsi_val.s.size = num_bytes - 1;
	sw_twsi_val.s.a = dev_addr;

	if (ia_width_bytes > 0) {
		sw_twsi_val.s.op = 1;
		sw_twsi_val.s.ia = (internal_addr >> 3) & 0x1f;
		sw_twsi_val.s.eop_ia = internal_addr & 0x7;
	}
开发者ID:AlickHill,项目名称:Lantern,代码行数:87,代码来源:cvmx-twsi.c

示例5: sizeof

{
	int ret;
	u8 buf[len+1];
	struct i2c_msg msg[1] = {
		{
			.addr = priv->cfg.i2c_address,
			.flags = 0,
			.len = sizeof(buf),
			.buf = buf,
		}
	};

	buf[0] = reg;
	memcpy(&buf[1], val, len);

	ret = i2c_transfer(priv->i2c, msg, 1);
	if (ret == 1) {
		ret = 0;
	} else {
		dev_warn(&priv->i2c->dev, "%s: i2c wr failed=%d reg=%02x " \
				"len=%d\n", KBUILD_MODNAME, ret, reg, len);
		ret = -EREMOTEIO;
	}
	return ret;
}

/* read multiple registers */
static int tda10071_rd_regs(struct tda10071_priv *priv, u8 reg, u8 *val,
	int len)
{
	int ret;
开发者ID:AdrianHuang,项目名称:linux-3.8.13,代码行数:31,代码来源:tda10071.c

示例6: be32_to_cpu

	return be32_to_cpu(resp);
}

int escore_i2c_read(struct escore_priv *escore, void *buf, int len)
{
	struct i2c_msg msg[] = {
		{
			.addr = escore_i2c->addr,
			.flags = I2C_M_RD,
			.len = len,
			.buf = buf,
		},
	};
	int rc = 0;

	rc = i2c_transfer(escore_i2c->adapter, msg, 1);
	/*
	 * i2c_transfer returns number of messages executed. Since we
	 * are always sending only 1 msg, return value should be 1 for
	 * success case
	 */
	if (rc != 1) {
		pr_err("%s(): i2c_transfer() failed, rc = %d, msg_len = %d\n",
			__func__, rc, len);
		return -EIO;
	} else {
		return 0;
	}
}

int escore_i2c_write(struct escore_priv *escore, const void *buf, int len)
开发者ID:faust93,项目名称:kernel_meizu_m576,代码行数:31,代码来源:escore-i2c.c

示例7: siinfo_get_boxid

int siinfo_get_boxid(void)
{
	return detected_boxid;
}
EXPORT_SYMBOL(siinfo_get_boxid);

static int i2c_autodetect (struct i2c_adapter *adapter, unsigned char i2c_addr, unsigned char dev_addr)
{
  	unsigned char buf[2] = { 0, 0 };
  	struct i2c_msg msg[] = { 
		{ .addr = i2c_addr, .flags = 0, .buf = &dev_addr, .len = 1 },
		{ .addr = i2c_addr, .flags = I2C_M_RD, .buf = &buf[0], .len = 1 } 
	};
  	int b;

  	b = i2c_transfer(adapter,msg,1);
  	b |= i2c_transfer(adapter,msg+1,1);

  	if (b != 1) 
		return -1;

  	return buf[0];
}

static int detect_boxid(void)
{
	struct i2c_adapter *adap;

	// model detection:
	//   1, cicam check? ok => 9900hd
	if((adap = i2c_get_adapter(CICAM_I2C_BUS)) == NULL) {
开发者ID:Audioniek,项目名称:driver,代码行数:31,代码来源:siinfo.c

示例8: sn3193_write

}

static int sn3193_write(struct sn3193_driver_data* dd, u8 *cmd,
							int length)
{
    int ret;
    
    struct i2c_msg msgs[] = {
        [0] = {
            .addr   = dd->client->addr,
            .flags  = 0,
            .buf    = (void *)cmd,
            .len    = length
        },
    };
    ret = i2c_transfer(dd->client->adapter, msgs, 1);
    return (ret < 0) ? -1 : 0;    
}

static int sn3193_pins_config(struct sn3193_driver_data* dd)
{
	int rc = 0;
    u8 cmd[2] = {0, 0};

    if (dd->chg_led_ctrl_pin != 255){
        rc = gpio_request(dd->chg_led_ctrl_pin, "CHG LED CTRL");
        if (rc < 0) {
            dev_err(&dd->client->dev, "failed to request %d GPIO\n",
                        dd->chg_led_ctrl_pin);
            return rc;
        }
开发者ID:chen2011521,项目名称:xt560_kernel,代码行数:31,代码来源:leds-sn3193.c

示例9: ltc3577_i2c_commit

static int ltc3577_i2c_commit( struct i2c_client *client,
                               ltc3577_msg_t     *write_buf,
                               ltc3577_msg_t     *read_buf,
                               uint8_t lock )
{
    struct  ltc3577_i2c_driver *driver = (struct ltc3577_i2c_driver *) container_of(client, struct ltc3577_i2c_driver, client);
    struct  i2c_msg msgs[LTC3577_ADDR_MAX];
    uint8_t count = 0;
    uint8_t i;
    int     rc;

    /* Get the lock. This before someone else modifies something. */
    if (lock)
        down( &ltc3577_register_cache_lock );

    if (atomic_read(&driver->suspended))  {
        printk( KERN_ERR "LTC3577: Cannot commit transaction. LTC3577 driver suspended or not initialized\n" );
        if (lock)
            up( &ltc3577_register_cache_lock );
        return -1;
    }

    /* Prepare one transfer */
    for (i = 0; i < LTC3577_ADDR_MAX; i++) {
        if (write_buf[i].commit) {

            msgs[count].addr    = client->addr;
            msgs[count].flags   = client->flags & I2C_M_TEN;
            msgs[count].len     = LTC3577_WRITE_SIZE;
            msgs[count].buf     = write_buf[i].data;
            write_buf[i].commit = FALSE;
            count++;
        }
    }

    /* Send all messages at once */
    rc = i2c_transfer(client->adapter, msgs, count);
    if( rc < 0 ) {
        if (lock)
            up( &ltc3577_register_cache_lock );
        return rc;
    }

    /* Check whether we need to read sth */
    if (NULL == read_buf) {
        if (lock)
            up( &ltc3577_register_cache_lock );
        return 0;
    }

    /* Read LTC3577 status register */
    if (read_buf->commit) {
        uint8_t data;

        read_buf->commit = FALSE;
        rc = i2c_master_recv( client, &data, sizeof(data));
        if( rc < 0 ) {
            if (lock)
                up( &ltc3577_register_cache_lock );
            return rc;
        }
        read_buf->data[LTC3577_DATA] = data;
    }

    if (lock)
        up( &ltc3577_register_cache_lock );
    return 0;
}
开发者ID:kzlin129,项目名称:tt-gpl,代码行数:68,代码来源:ltc3577-pmic.c

示例10: MMS_IL_PRINT

TIMM_OSAL_ERRORTYPE CComponentDispatcherI2CReadHandle::Process(void* pMessage)
{
    //unsigned int nPayloadSize = ((systemMessage_t *)pMessage)->nPayloadSize;
    struct i2c_msg msg;
    TIMM_OSAL_U8* data = NULL;

    I2CMessage_t* pI2CMessage = (I2CMessage_t*)((systemMessage_t *)pMessage)->pPayload;

    if (dispatcher->I2C_device <= 0 )
    {
        MMS_IL_PRINT("Device is closed!\n");
        return TIMM_OSAL_ERR_UNKNOWN;
    }

    I2CData_t* pI2CData = (I2CData_t*)(pI2CMessage->pData);
    if (pI2CData == NULL)
    {
        MMS_IL_PRINT("pI2CMessage is NULL\n");
        return TIMM_OSAL_ERR_UNKNOWN;
    }

   int SubAddr = pI2CData->nSubAddr;
   if (TIMM_OSAL_ERR_NONE != set_slave_addr(dispatcher->I2C_device, pI2CMessage->nSlaveAddr,SubAddr ))
    {
        MMS_IL_PRINT("Slave address not set!\n");
        return TIMM_OSAL_ERR_UNKNOWN;
    }

    MMS_IL_PRINT("Reading from slave addres 0x%04X\n", pI2CMessage->nSlaveAddr);

   int pldSz = pI2CData->nPayloadSize;
   data = (TIMM_OSAL_U8*)malloc(pldSz * sizeof(TIMM_OSAL_U8));
   if (data == NULL)
   {
        MMS_IL_PRINT("Error allocating memory!\n");
        return TIMM_OSAL_ERR_ALLOC;
   }
   memset(data, 0, pldSz);

   MMS_IL_PRINT("Reading from Subaddres 0x%04X, %d bytes\n", SubAddr, pldSz);
   msg.addr = pI2CMessage->nSlaveAddr;
   msg.flags = I2C_M_RD;
   msg.len = pldSz;
   msg.buf = data;

   if (TIMM_OSAL_ERR_NONE != i2c_transfer(dispatcher->I2C_device, &msg))
   {
      MMS_IL_PRINT("i2c_smbus_read Failed\n");
      return TIMM_OSAL_ERR_UNKNOWN;
   }

   for(int i = pldSz - 1, j = 0; i >= 0; i--, j++)
   {
       pI2CData->pPayloadData[i] = (TIMM_OSAL_U8)msg.buf[j];
       //MMS_IL_PRINT("msg.buf 0x%08X\n", msg.buf[j]);
       //MMS_IL_PRINT("pI2CData->pPayloadData 0x%08X\n", pI2CData->pPayloadData[i]);
   }

   free(data);
   MMS_IL_PRINT("0\n")
   return TIMM_OSAL_ERR_NONE;
}
开发者ID:aplced,项目名称:il_module,代码行数:62,代码来源:CComponentDispatcherI2CReadHandle.cpp

示例11: stb6000_sleep

static int stb6000_sleep(struct dvb_frontend *fe)
{
	struct stb6000_priv *priv = fe->tuner_priv;
	int ret;
	u8 buf[] = { 10, 0 };
	struct i2c_msg msg = {
		.addr = priv->i2c_address,
		.flags = 0,
		.buf = buf,
		.len = 2
	};

	dprintk("%s:\n", __func__);

	if (fe->ops.i2c_gate_ctrl)
		fe->ops.i2c_gate_ctrl(fe, 1);

	ret = i2c_transfer(priv->i2c, &msg, 1);
	if (ret != 1)
		dprintk("%s: i2c error\n", __func__);

	if (fe->ops.i2c_gate_ctrl)
		fe->ops.i2c_gate_ctrl(fe, 0);

	return (ret == 1) ? 0 : ret;
}

static int stb6000_set_params(struct dvb_frontend *fe)
{
	struct dtv_frontend_properties *p = &fe->dtv_property_cache;
	struct stb6000_priv *priv = fe->tuner_priv;
	unsigned int n, m;
	int ret;
	u32 freq_mhz;
	int bandwidth;
	u8 buf[12];
	struct i2c_msg msg = {
		.addr = priv->i2c_address,
		.flags = 0,
		.buf = buf,
		.len = 12
	};

	dprintk("%s:\n", __func__);

	freq_mhz = p->frequency / 1000;
	bandwidth = p->symbol_rate / 1000000;

	if (bandwidth > 31)
		bandwidth = 31;

	if ((freq_mhz > 949) && (freq_mhz < 2151)) {
		buf[0] = 0x01;
		buf[1] = 0xac;
		if (freq_mhz < 1950)
			buf[1] = 0xaa;
		if (freq_mhz < 1800)
			buf[1] = 0xa8;
		if (freq_mhz < 1650)
			buf[1] = 0xa6;
		if (freq_mhz < 1530)
			buf[1] = 0xa5;
		if (freq_mhz < 1470)
			buf[1] = 0xa4;
		if (freq_mhz < 1370)
			buf[1] = 0xa2;
		if (freq_mhz < 1300)
			buf[1] = 0xa1;
		if (freq_mhz < 1200)
			buf[1] = 0xa0;
		if (freq_mhz < 1075)
			buf[1] = 0xbc;
		if (freq_mhz < 1000)
			buf[1] = 0xba;
		if (freq_mhz < 1075) {
			n = freq_mhz / 8; /*          */
			m = 2;
		} else {
			n = freq_mhz / 16; /*          */
			m = 1;
		}
		buf[2] = n >> 1;
		buf[3] = (unsigned char)(((n & 1) << 7) |
					(m * freq_mhz - n * 16) | 0x60);
		buf[4] = 0x04;
		buf[5] = 0x0e;

		buf[6] = (unsigned char)(bandwidth);

		buf[7] = 0xd8;
		buf[8] = 0xd0;
		buf[9] = 0x50;
		buf[10] = 0xeb;
		buf[11] = 0x4f;

		if (fe->ops.i2c_gate_ctrl)
			fe->ops.i2c_gate_ctrl(fe, 1);

		ret = i2c_transfer(priv->i2c, &msg, 1);
		if (ret != 1)
//.........这里部分代码省略.........
开发者ID:romanbb,项目名称:android_kernel_lge_d851,代码行数:101,代码来源:stb6000.c

示例12: i2c_transfer

		{
			.addr = i2c->addr,
			.flags = 0,
			.len = 1,
			.buf = rxData,
		},
		{
			.addr = i2c->addr,
			.flags = I2C_M_RD,
			.len = length,
			.buf = rxData,
		},
	};
	uint8_t addr = rxData[0];

	ret = i2c_transfer(i2c->adapter, msgs, ARRAY_SIZE(msgs));
	if (ret < 0) {
		dev_err(&i2c->dev, "%s: transfer failed.", __func__);
		return ret;
	} else if (ret != ARRAY_SIZE(msgs)) {
		dev_err(&i2c->dev, "%s: transfer failed(size error).\n",
				__func__);
		return -ENXIO;
	}

	dev_vdbg(&i2c->dev, "RxData: len=%02x, addr=%02x, data=%02x",
		length, addr, rxData[0]);

	return 0;
}
开发者ID:AD5GB,项目名称:kernel_n5_3.10-experimental,代码行数:30,代码来源:akm09911.c

示例13: mxb_init_done

static int mxb_init_done(struct saa7146_dev* dev)
{
    struct mxb* mxb = (struct mxb*)dev->ext_priv;
    struct i2c_msg msg;
    struct tuner_setup tun_setup;
    v4l2_std_id std = V4L2_STD_PAL_BG;

    int i = 0, err = 0;


    saa7111a_call(mxb, core, s_std, std);


    i = 0;
    saa7111a_call(mxb, video, s_routing, SAA7115_COMPOSITE0,
                  SAA7111_FMT_CCIR, 0);


    tun_setup.mode_mask = T_ANALOG_TV;
    tun_setup.addr = ADDR_UNSET;
    tun_setup.type = TUNER_PHILIPS_PAL;
    tuner_call(mxb, tuner, s_type_addr, &tun_setup);

    mxb->cur_freq.tuner = 0;
    mxb->cur_freq.type = V4L2_TUNER_ANALOG_TV;
    mxb->cur_freq.frequency = freq;
    tuner_call(mxb, tuner, s_frequency, &mxb->cur_freq);


    tuner_call(mxb, core, s_std, std);


    tea6420_route_line(mxb, 6);
    tea6420_route_cd(mxb, 6);


    tea6415c_call(mxb, video, s_routing, 3, 17, 0);


    tea6415c_call(mxb, video, s_routing, 3, 13, 0);


    mxb->cur_input = 0;
    mxb->cur_mute = 1;

    mxb->cur_mode = V4L2_TUNER_MODE_STEREO;

    msg.addr = 0x1b;
    msg.flags = 0;
    msg.len = mxb_saa7740_init[0].length;
    msg.buf = &mxb_saa7740_init[0].data[0];

    err = i2c_transfer(&mxb->i2c_adapter, &msg, 1);
    if (err == 1) {
        extension.flags &= ~SAA7146_USE_I2C_IRQ;
        for (i = 1; ; i++) {
            if (-1 == mxb_saa7740_init[i].length)
                break;

            msg.len = mxb_saa7740_init[i].length;
            msg.buf = &mxb_saa7740_init[i].data[0];
            err = i2c_transfer(&mxb->i2c_adapter, &msg, 1);
            if (err != 1) {
                DEB_D("failed to initialize 'sound arena module'\n");
                goto err;
            }
        }
        pr_info("'sound arena module' detected\n");
    }
err:




    saa7146_set_hps_source_and_sync(dev, input_port_selection[mxb->cur_input].hps_source,
                                    input_port_selection[mxb->cur_input].hps_sync);



    saa7146_write(dev, DD1_STREAM_B,	0x00000000);
    saa7146_write(dev, DD1_INIT,		0x02000200);
    saa7146_write(dev, MC2, (MASK_09 | MASK_25 | MASK_10 | MASK_26));

    return 0;
}
开发者ID:MiniBlu,项目名称:cm11_kernel_htc_msm8974a3ul,代码行数:85,代码来源:mxb.c

示例14: ARRAY_SIZE

	reg & 0xff,
	value & 0xff,
	(value >> 8) & 0xff,
	(value >> 16) & 0xff,
	(value >> 24) & 0xff,
	};
	struct i2c_msg msgs[] = {
		{
			.addr = client->addr,
			.flags = 0,
			.buf = tx_data,
			.len = ARRAY_SIZE(tx_data),
		},
	};

	r = i2c_transfer(client->adapter, msgs, ARRAY_SIZE(msgs));
	if (r < 0) {
		dev_err(&client->dev, "%s: reg 0x%04x val 0x%08x error %d\n",
			__func__, reg, value, r);
		return r;
	}

	if (r < ARRAY_SIZE(msgs)) {
		dev_err(&client->dev, "%s: reg 0x%04x val 0x%08x msgs %d\n",
			__func__, reg, value, r);
		return -EAGAIN;
	}

	return 0;
}
static
开发者ID:yutokt,项目名称:android_kernel_intel_anzhen4,代码行数:31,代码来源:tc35876x_vid.c

示例15: i2c_transfer

	for (retries = 3; retries > 0; retries--) {
		struct i2c_msg msgs[] = {
			{
				.addr   = DDC_ADDR,
				.flags  = 0,
				.len    = 1,
				.buf    = &offset,
			}, {
				.addr   = DDC_ADDR,
				.flags  = I2C_M_RD,
				.len    = count,
				.buf    = buf,
			}
		};

		r = i2c_transfer(adapter, msgs, 2);
		if (r == 2)
			return 0;

		if (r != -EAGAIN)
			break;
	}

	return r < 0 ? r : -EIO;
}

static int dvic_read_edid(struct omap_dss_device *dssdev,
		u8 *edid, int len)
{
	struct panel_drv_data *ddata = to_panel_data(dssdev);
	int r, l, bytes_read;
开发者ID:383530895,项目名称:linux,代码行数:31,代码来源:connector-dvi.c


注:本文中的i2c_transfer函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。