int wmt_vid_i2c_read16addr(int chipId ,unsigned int index) { int ret=0; struct i2c_msg msg[2]; unsigned char buf[2]; unsigned int val; if (vid_i2c_gpio_en) { printk("wmt_vid_i2c_read16addr() Not support GPIO mode now"); return -1; } buf[0]=((index>>8) & 0xff); buf[1]=(index & 0xff); msg[0].addr = chipId; msg[0].flags = 0; msg[0].flags &= ~(I2C_M_RD); msg[0].len = 2; msg[0].buf = buf; msg[1].addr = chipId; msg[1].flags = 0; msg[1].flags |= (I2C_M_RD); msg[1].len = 1; msg[1].buf = buf; ret = wmt_i2c_xfer_continue_if_4(msg,2,1); val=buf[0]; return val; }
/*! * \brief * set VID mode * \retval 0 if success */ int wmt_vid_i2c_read_page(int chipId ,unsigned int index,char *pdata,int len) { struct i2c_msg msg[2]; unsigned char buf[len+1]; memset(buf,0x55,len+1); buf[0] = index; msg[0].addr = chipId; msg[0].flags = 0 ; msg[0].flags &= ~(I2C_M_RD); msg[0].len = 1; msg[0].buf = buf; msg[1].addr = chipId; msg[1].flags = 0 ; msg[1].flags |= (I2C_M_RD); msg[1].len = len; msg[1].buf = buf; wmt_i2c_xfer_continue_if_4(msg, 2,1); memcpy(pdata,buf,len); return 0; } /* End of wmt_vid_i2c_read_page() */
static int pixcir_write(struct pixcir_data *pixcir, u8 *txdata, int length) { int ret; struct i2c_msg msg[1]; msg[0].addr = pixcir->addr; msg[0].flags = 0; msg[0].len = length; msg[0].buf = txdata; ret = wmt_i2c_xfer_continue_if_4(msg, 1, I2C_BUS1); if (ret <= 0) dbg_err("msg i2c read error: %d\n", ret); return ret; }
int wmt_vid_i2c_write_page(int chipId ,unsigned int index,char *pdata,int len) { struct i2c_msg msg[1]; unsigned char buf[len+1]; buf[0] = index; memcpy(&buf[1],pdata,len); msg[0].addr = chipId; msg[0].flags = 0 ; msg[0].flags &= ~(I2C_M_RD); msg[0].len = len; msg[0].buf = buf; wmt_i2c_xfer_continue_if_4(msg,1,1); return 0; } /* End of wmt_vid_i2c_write_page() */
int wmt_vid_gpio_i2c_write16addr(int chipId ,unsigned int index,unsigned int data) { int ret=0; struct i2c_msg msg[1]; unsigned char buf[4]; buf[0]=((index>>8) & 0xff); buf[1]=(index & 0xff); buf[2]=(data & 0xff); msg[0].addr = chipId; msg[0].flags = 0; msg[0].flags &= ~(I2C_M_RD); msg[0].len = 3; msg[0].buf = buf; ret = wmt_i2c_xfer_continue_if_4(msg,1,1); return 0; }
/*! * \brief * set VID mode * \retval 0 if success */ int wmt_vid_i2c_write16addr(int chipId ,unsigned int index,unsigned int data) { int ret=0; struct i2c_msg msg[1]; unsigned char buf[4]; if (vid_i2c_gpio_en) { printk("wmt_vid_i2c_write16addr() Not support GPIO mode now"); return -1; } buf[0]=((index>>8) & 0xff); buf[1]=(index & 0xff); buf[2]=(data & 0xff); msg[0].addr = chipId; msg[0].flags = 0; msg[0].flags &= ~(I2C_M_RD); msg[0].len = 3; msg[0].buf = buf; ret = wmt_i2c_xfer_continue_if_4(msg,1,1); return 0; }