本文整理汇总了C++中i2c_new_device函数的典型用法代码示例。如果您正苦于以下问题:C++ i2c_new_device函数的具体用法?C++ i2c_new_device怎么用?C++ i2c_new_device使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了i2c_new_device函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: BUG_ON
/* Load an i2c sub-device. */
struct v4l2_subdev *v4l2_i2c_new_subdev_board(struct v4l2_device *v4l2_dev,
struct i2c_adapter *adapter, struct i2c_board_info *info,
const unsigned short *probe_addrs)
{
struct v4l2_subdev *sd = NULL;
struct i2c_client *client;
BUG_ON(!v4l2_dev);
request_module(I2C_MODULE_PREFIX "%s", info->type);
/* Create the i2c client */
if (info->addr == 0 && probe_addrs)
client = i2c_new_probed_device(adapter, info, probe_addrs,
NULL);
else
client = i2c_new_device(adapter, info);
/* Note: by loading the module first we are certain that c->driver
will be set if the driver was found. If the module was not loaded
first, then the i2c core tries to delay-load the module for us,
and then c->driver is still NULL until the module is finally
loaded. This delay-load mechanism doesn't work if other drivers
want to use the i2c device, so explicitly loading the module
is the best alternative. */
if (client == NULL || client->driver == NULL)
goto error;
/* Lock the module so we can safely get the v4l2_subdev pointer */
if (!try_module_get(client->driver->driver.owner))
goto error;
sd = i2c_get_clientdata(client);
/* Register with the v4l2_device which increases the module's
use count as well. */
if (v4l2_device_register_subdev(v4l2_dev, sd))
sd = NULL;
/* Decrease the module use count to match the first try_module_get. */
module_put(client->driver->driver.owner);
error:
/* If we have a client but no subdev, then something went wrong and
we must unregister the client. */
if (client && sd == NULL)
i2c_unregister_device(client);
return sd;
}
示例2: I2C_BOARD_INFO
struct i2c_client *hdpvr_register_ir_rx_i2c(struct hdpvr_device *dev)
{
struct IR_i2c_init_data *init_data = &dev->ir_i2c_init_data;
struct i2c_board_info hdpvr_ir_rx_i2c_board_info = {
I2C_BOARD_INFO("ir_rx_z8f0811_hdpvr", Z8F0811_IR_RX_I2C_ADDR),
};
/* Our default information for ir-kbd-i2c.c to use */
init_data->ir_codes = RC_MAP_HAUPPAUGE;
init_data->internal_get_key_func = IR_KBD_GET_KEY_HAUP_XVR;
init_data->type = RC_BIT_RC5;
init_data->name = "HD-PVR";
init_data->polling_interval = 405; /* ms, duplicated from Windows */
hdpvr_ir_rx_i2c_board_info.platform_data = init_data;
return i2c_new_device(&dev->i2c_adapter, &hdpvr_ir_rx_i2c_board_info);
}
示例3: init_bttv_i2c_ir
/* Instantiate the I2C IR receiver device, if present */
void init_bttv_i2c_ir(struct bttv *btv)
{
const unsigned short addr_list[] = {
0x1a, 0x18, 0x64, 0x30, 0x71,
I2C_CLIENT_END
};
struct i2c_board_info info;
struct i2c_client *i2c_dev;
if (0 != btv->i2c_rc)
return;
memset(&info, 0, sizeof(struct i2c_board_info));
memset(&btv->init_data, 0, sizeof(btv->init_data));
strlcpy(info.type, "ir_video", I2C_NAME_SIZE);
switch (btv->c.type) {
case BTTV_BOARD_PV951:
btv->init_data.name = "PV951";
btv->init_data.get_key = get_key_pv951;
btv->init_data.ir_codes = RC_MAP_PV951;
info.addr = 0x4b;
break;
}
if (btv->init_data.name) {
info.platform_data = &btv->init_data;
i2c_dev = i2c_new_device(&btv->c.i2c_adap, &info);
} else {
/*
* The external IR receiver is at i2c address 0x34 (0x35 for
* reads). Future Hauppauge cards will have an internal
* receiver at 0x30 (0x31 for reads). In theory, both can be
* fitted, and Hauppauge suggest an external overrides an
* internal.
* That's why we probe 0x1a (~0x34) first. CB
*/
i2c_dev = i2c_new_probed_device(&btv->c.i2c_adap, &info, addr_list, NULL);
}
if (NULL == i2c_dev)
return;
#if defined(CONFIG_MODULES) && defined(MODULE)
request_module("ir-kbd-i2c");
#endif
}
示例4: cx231xx_ir_init
int cx231xx_ir_init(struct cx231xx *dev)
{
struct i2c_board_info info;
u8 ir_i2c_bus;
dev_dbg(&dev->udev->dev, "%s\n", __func__);
/* Only initialize if a rc keycode map is defined */
if (!cx231xx_boards[dev->model].rc_map_name)
return -ENODEV;
request_module("ir-kbd-i2c");
memset(&info, 0, sizeof(struct i2c_board_info));
memset(&dev->init_data, 0, sizeof(dev->init_data));
dev->init_data.rc_dev = rc_allocate_device();
if (!dev->init_data.rc_dev)
return -ENOMEM;
dev->init_data.name = cx231xx_boards[dev->model].name;
strlcpy(info.type, "ir_video", I2C_NAME_SIZE);
info.platform_data = &dev->init_data;
/*
* Board-dependent values
*
* For now, there's just one type of hardware design using
* an i2c device.
*/
dev->init_data.get_key = get_key_isdbt;
dev->init_data.ir_codes = cx231xx_boards[dev->model].rc_map_name;
/* The i2c micro-controller only outputs the cmd part of NEC protocol */
dev->init_data.rc_dev->scanmask = 0xff;
dev->init_data.rc_dev->driver_name = "cx231xx";
dev->init_data.type = RC_BIT_NEC;
info.addr = 0x30;
/* Load and bind ir-kbd-i2c */
ir_i2c_bus = cx231xx_boards[dev->model].ir_i2c_master;
dev_dbg(&dev->udev->dev, "Trying to bind ir at bus %d, addr 0x%02x\n",
ir_i2c_bus, info.addr);
dev->ir_i2c_client = i2c_new_device(&dev->i2c_bus[ir_i2c_bus].i2c_adap, &info);
return 0;
}
示例5: aml_audio_codec_probe
static int aml_audio_codec_probe(struct platform_device *pdev)
{
struct device_node* audio_codec_node = pdev->dev.of_node;
struct device_node* child;
struct i2c_board_info board_info;
struct i2c_adapter *adapter;
struct i2c_client *client;
aml_audio_codec_info_t temp_audio_codec;
#ifdef CONFIG_SND_AML_M6TV_AUDIO_CODEC
struct tas57xx_platform_data *pdata;
char tmp[NAME_SIZE];
pdata = kzalloc(sizeof(struct tas57xx_platform_data), GFP_KERNEL);
if (!pdata) {
printk("ERROR, NO enough mem for tas57xx_platform_data!\n");
return -ENOMEM;
}
#endif
memset(&board_info, 0, sizeof(board_info));
audio_codec_pdev = pdev;
for_each_child_of_node(audio_codec_node, child) {
memset(&temp_audio_codec, 0, sizeof(aml_audio_codec_info_t));
regist_codec_info(child,&temp_audio_codec);
if (get_audio_codec_i2c_info(child, &temp_audio_codec)) {
continue;
}
memset(&board_info, 0, sizeof(board_info));
strncpy(board_info.type, temp_audio_codec.name, I2C_NAME_SIZE);
adapter = i2c_get_adapter(temp_audio_codec.i2c_bus_type);
board_info.addr = temp_audio_codec.i2c_addr;
board_info.platform_data = &temp_audio_codec;
client = i2c_new_device(adapter, &board_info);
#ifdef CONFIG_SND_AML_M6TV_AUDIO_CODEC
snprintf(tmp, I2C_NAME_SIZE, "%s", temp_audio_codec.name);
strlcpy(codec_info.name, tmp, I2C_NAME_SIZE);
snprintf(tmp, I2C_NAME_SIZE, "%s.%s", temp_audio_codec.name, dev_name(&client->dev));
strlcpy(codec_info.name_bus, tmp, I2C_NAME_SIZE);
codec_get_of_pdata(pdata, child);
client->dev.platform_data = pdata;
#endif
}
示例6: bq27520_bat_upt_i2c_init
int bq27520_bat_upt_i2c_init(void)
{
int ret = 0;
struct i2c_adapter *adapter = NULL;
struct i2c_client *client = NULL;
struct i2c_board_info *board_info= NULL;
BAT_DBG("++++ %s ++++\n", __func__);
//register i2c device
board_info = &bq27520_bat_upt_i2c_board_info;
adapter = i2c_get_adapter(((struct bq27520_bat_platform_data *)board_info->platform_data)->i2c_bus_id);
if (adapter == NULL) {
BAT_DBG_E("can not get i2c adapter, client address error\n");
ret = -ENODEV;
goto get_adapter_fail;
}
client = i2c_new_device(adapter, board_info);
if (client == NULL) {
BAT_DBG("allocate i2c client failed\n");
ret = -ENOMEM;
goto register_i2c_device_fail;
}
i2c_put_adapter(adapter);
mutex_lock(&batt_dev_upt_mutex);
batt_upt_dev_info.i2c = client;
mutex_unlock(&batt_dev_upt_mutex);
//register i2c driver
ret = i2c_add_driver(&bq27520_bat_upt_i2c_driver);
if (ret) {
BAT_DBG("register bq27520 battery update i2c driver failed\n");
goto i2c_register_driver_fail;
}
return ret;
i2c_register_driver_fail:
i2c_unregister_device(client);
register_i2c_device_fail:
get_adapter_fail:
return ret;
}
示例7: camera_auto_detect
static int camera_auto_detect(void)
{
struct i2c_adapter *adap = i2c_get_adapter(2);
pr_info("%s ++ %04x - %04x - %04x\n",
__func__, ad5816_devid, dw9718_devid, max77387_devid);
if ((ad5816_devid & 0xff00) == 0x2400) {
if ((max77387_devid & 0xff) == 0x91) {
/* IMX135 found */
i2c_new_device(adap, &pluto_i2c_board_info_imx135);
} else {
/* IMX091 found*/
i2c_new_device(adap, &pluto_i2c_board_info_imx091);
}
} else if (dw9718_devid) {
if (!max77387_devid) {
/* board e1823, IMX135 found */
i2c_new_device(adap, &pluto_i2c_board_info_imx135);
/* remove current dw9718 */
device_for_each_child(&adap->dev,
&pluto_i2c_board_info_dw9718.addr,
pluto_chk_conflict);
/* reinstall with new device node */
pluto_dw9718_pdata.num = 0;
i2c_new_device(adap, &pluto_i2c_board_info_dw9718);
} else {
/* AR0833 found */
i2c_new_device(adap, &pluto_i2c_board_info_ar0833);
}
} else { /* default using ov5693 + ad5823 */
device_for_each_child(&adap->dev,
&pluto_i2c_board_info_ad5823.addr,
pluto_chk_conflict);
i2c_new_device(adap, &pluto_i2c_board_info_ov5693);
i2c_new_device(adap, &pluto_i2c_board_info_ad5823);
}
i2c_new_device(adap, &pluto_i2c_board_info_imx132);
pr_info("%s --\n", __func__);
return 0;
}
示例8: stmvl6180_init_i2c
int stmvl6180_init_i2c(void)
{
int ret = 0;
#ifdef STM_TEST
struct i2c_client *client = NULL;
struct i2c_adapter *adapter;
struct i2c_board_info info = {
.type = "stmvl6180",
.addr = VL6180_I2C_ADDRESS,
};
#endif
vl6180_dbgmsg("Enter\n");
/* register as a i2c client device */
ret = i2c_add_driver(&stmvl6180_driver);
if (ret)
vl6180_errmsg("%d erro ret:%d\n", __LINE__, ret);
#ifdef STM_TEST
if (!ret) {
adapter = i2c_get_adapter(4);
if (!adapter)
ret = -EINVAL;
else
client = i2c_new_device(adapter, &info);
if (!client)
ret = -EINVAL;
}
#endif
vl6180_dbgmsg("End with rc:%d\n", ret);
return ret;
}
void stmvl6180_exit_i2c(void *i2c_object)
{
vl6180_dbgmsg("Enter\n");
i2c_del_driver(&stmvl6180_driver);
vl6180_dbgmsg("End\n");
}
示例9: vt1603_bat_i2c_init
static int __init vt1603_bat_i2c_init(void)
{
int ret = 0;
struct i2c_adapter *adapter = NULL;
struct i2c_client *client = NULL;
struct i2c_board_info *vt1603_i2c_bi = NULL;
bat_dbg("Enter\n");
ret = vt1603_bat_uboot_env_check();
if (ret) {
bat_dbg("vt1603_bat uboot env check failed\n");
goto out;
}
vt1603_i2c_bi = &vt1603_bat_i2c_board_info;
adapter = i2c_get_adapter(vt1603_bat_pdata.i2c_bus_id);
if (NULL == adapter) {
bat_dbg("can not get i2c adapter, client address error\n");
ret = -ENODEV;
goto out;
}
client = i2c_new_device(adapter, vt1603_i2c_bi);
if (client == NULL) {
bat_dbg("allocate i2c client failed\n");
ret = -ENOMEM;
goto out;
}
i2c_put_adapter(adapter);
ret = i2c_add_driver(&vt1603_bat_i2c_driver);
if (ret) {
bat_dbg("register vt1603 battery i2c driver failed\n");
goto release_client;
}
bat_dbg("Exit\n");
goto out;
release_client:
i2c_unregister_device(client);
client = NULL;
out:
return ret;
}
示例10: apds9960_init
static int __init apds9960_init(void)
{
int i = 0;
struct i2c_adapter *adap = NULL;
for (i = 0; i < 3; i++) {
adap = i2c_get_adapter(i);
if (!adap)
return -1;
if (!strcmp(adap->name, "Synopsys DesignWare I2C adapter"))
break;
}
apds9960_accel_device.irq = gpio_to_irq(APDS9960_I2C_IRQ);
i2c_client = i2c_new_device(adap, &apds9960_accel_device);
return 0;
}
示例11: register_i2c_codec_device
static int register_i2c_codec_device(aml_audio_codec_info_t* audio_codec_dev)
{
struct i2c_adapter *adapter;
struct i2c_client *client;
struct i2c_board_info board_info;
char tmp[NAME_SIZE];
strncpy(board_info.type, audio_codec_dev->name, I2C_NAME_SIZE);
board_info.addr = audio_codec_dev->i2c_addr;
adapter = i2c_get_adapter(audio_codec_dev->i2c_bus_type);
client = i2c_new_device(adapter, &board_info);
snprintf(tmp, NAME_SIZE, "%s", audio_codec_dev->name);
strlcpy(codec_info.name, tmp, NAME_SIZE);
snprintf(tmp, NAME_SIZE, "%s.%s", audio_codec_dev->name, dev_name(&client->dev));
strlcpy(codec_info.name_bus, tmp, NAME_SIZE);
return 0;
}
示例12: mma7660_init
static int __init mma7660_init(void)
{
#if CFG_GSENSOR_USE_CONFIG > 0
struct i2c_adapter *i2c_adap;
unsigned int cfg_i2c_adap_id;
int ret;
ret = get_config(CFG_GSENSOR_ADAP_ID, (char *)(&cfg_i2c_adap_id), sizeof(unsigned int));
if (ret != 0) {
printk(KERN_ERR"get i2c_adap_id %d fail\n", cfg_i2c_adap_id);
return ret;
}
i2c_adap = i2c_get_adapter(cfg_i2c_adap_id);
mma7660_client = i2c_new_device(i2c_adap, &mma7660_board_info);
i2c_put_adapter(i2c_adap);
#endif
return i2c_add_driver(&mma7660_driver);
}
示例13: probe_monitoring_device
static bool
probe_monitoring_device(struct nouveau_i2c_chan *i2c,
struct i2c_board_info *info)
{
struct i2c_client *client;
request_module("%s%s", I2C_MODULE_PREFIX, info->type);
client = i2c_new_device(&i2c->adapter, info);
if (!client)
return false;
if (!client->driver || client->driver->detect(client, info)) {
i2c_unregister_device(client);
return false;
}
return true;
}
示例14: dev_dbg
static struct i2c_client *of_i2c_register_device(struct i2c_adapter *adap,
struct device_node *node)
{
struct i2c_client *client;
struct i2c_board_info info;
int ret;
dev_dbg(&adap->dev, "of_i2c: register %pOF\n", node);
ret = of_i2c_get_board_info(&adap->dev, node, &info);
if (ret)
return ERR_PTR(ret);
client = i2c_new_device(adap, &info);
if (!client) {
dev_err(&adap->dev, "of_i2c: Failure registering %pOF\n", node);
return ERR_PTR(-EINVAL);
}
return client;
}
示例15: bq27x00_battery_i2c_init
static inline int bq27x00_battery_i2c_init(void)
{
struct i2c_adapter *adapter;
struct i2c_client *client;
int ret = i2c_add_driver(&bq27x00_battery_driver);
if (ret)
printk(KERN_ERR "Unable to register BQ27x00 i2c driver\n");
adapter = i2c_get_adapter(0);
if (!adapter)
return -ENODEV;
client = i2c_new_device(adapter, i2c_board_info);
i2c_put_adapter(adapter);
if (!client)
return -ENODEV;
return ret;
}