diff options
Diffstat (limited to 'drivers/media/video/ov7670.c')
| -rw-r--r-- | drivers/media/video/ov7670.c | 74 |
1 files changed, 32 insertions, 42 deletions
diff --git a/drivers/media/video/ov7670.c b/drivers/media/video/ov7670.c index c881a64b41fd..d4e7c11553c3 100644 --- a/drivers/media/video/ov7670.c +++ b/drivers/media/video/ov7670.c | |||
| @@ -1449,47 +1449,6 @@ static int ov7670_g_chip_ident(struct v4l2_subdev *sd, | |||
| 1449 | return v4l2_chip_ident_i2c_client(client, chip, V4L2_IDENT_OV7670, 0); | 1449 | return v4l2_chip_ident_i2c_client(client, chip, V4L2_IDENT_OV7670, 0); |
| 1450 | } | 1450 | } |
| 1451 | 1451 | ||
| 1452 | static int ov7670_s_config(struct v4l2_subdev *sd, int dumb, void *data) | ||
| 1453 | { | ||
| 1454 | struct i2c_client *client = v4l2_get_subdevdata(sd); | ||
| 1455 | struct ov7670_config *config = data; | ||
| 1456 | struct ov7670_info *info = to_state(sd); | ||
| 1457 | int ret; | ||
| 1458 | |||
| 1459 | info->clock_speed = 30; /* default: a guess */ | ||
| 1460 | |||
| 1461 | /* | ||
| 1462 | * Must apply configuration before initializing device, because it | ||
| 1463 | * selects I/O method. | ||
| 1464 | */ | ||
| 1465 | if (config) { | ||
| 1466 | info->min_width = config->min_width; | ||
| 1467 | info->min_height = config->min_height; | ||
| 1468 | info->use_smbus = config->use_smbus; | ||
| 1469 | |||
| 1470 | if (config->clock_speed) | ||
| 1471 | info->clock_speed = config->clock_speed; | ||
| 1472 | } | ||
| 1473 | |||
| 1474 | /* Make sure it's an ov7670 */ | ||
| 1475 | ret = ov7670_detect(sd); | ||
| 1476 | if (ret) { | ||
| 1477 | v4l_dbg(1, debug, client, | ||
| 1478 | "chip found @ 0x%x (%s) is not an ov7670 chip.\n", | ||
| 1479 | client->addr << 1, client->adapter->name); | ||
| 1480 | kfree(info); | ||
| 1481 | return ret; | ||
| 1482 | } | ||
| 1483 | v4l_info(client, "chip found @ 0x%02x (%s)\n", | ||
| 1484 | client->addr << 1, client->adapter->name); | ||
| 1485 | |||
| 1486 | info->fmt = &ov7670_formats[0]; | ||
| 1487 | info->sat = 128; /* Review this */ | ||
| 1488 | info->clkrc = info->clock_speed / 30; | ||
| 1489 | |||
| 1490 | return 0; | ||
| 1491 | } | ||
| 1492 | |||
| 1493 | #ifdef CONFIG_VIDEO_ADV_DEBUG | 1452 | #ifdef CONFIG_VIDEO_ADV_DEBUG |
| 1494 | static int ov7670_g_register(struct v4l2_subdev *sd, struct v4l2_dbg_register *reg) | 1453 | static int ov7670_g_register(struct v4l2_subdev *sd, struct v4l2_dbg_register *reg) |
| 1495 | { | 1454 | { |
| @@ -1528,7 +1487,6 @@ static const struct v4l2_subdev_core_ops ov7670_core_ops = { | |||
| 1528 | .s_ctrl = ov7670_s_ctrl, | 1487 | .s_ctrl = ov7670_s_ctrl, |
| 1529 | .queryctrl = ov7670_queryctrl, | 1488 | .queryctrl = ov7670_queryctrl, |
| 1530 | .reset = ov7670_reset, | 1489 | .reset = ov7670_reset, |
| 1531 | .s_config = ov7670_s_config, | ||
| 1532 | .init = ov7670_init, | 1490 | .init = ov7670_init, |
| 1533 | #ifdef CONFIG_VIDEO_ADV_DEBUG | 1491 | #ifdef CONFIG_VIDEO_ADV_DEBUG |
| 1534 | .g_register = ov7670_g_register, | 1492 | .g_register = ov7670_g_register, |
| @@ -1558,6 +1516,7 @@ static int ov7670_probe(struct i2c_client *client, | |||
| 1558 | { | 1516 | { |
| 1559 | struct v4l2_subdev *sd; | 1517 | struct v4l2_subdev *sd; |
| 1560 | struct ov7670_info *info; | 1518 | struct ov7670_info *info; |
| 1519 | int ret; | ||
| 1561 | 1520 | ||
| 1562 | info = kzalloc(sizeof(struct ov7670_info), GFP_KERNEL); | 1521 | info = kzalloc(sizeof(struct ov7670_info), GFP_KERNEL); |
| 1563 | if (info == NULL) | 1522 | if (info == NULL) |
| @@ -1565,6 +1524,37 @@ static int ov7670_probe(struct i2c_client *client, | |||
| 1565 | sd = &info->sd; | 1524 | sd = &info->sd; |
| 1566 | v4l2_i2c_subdev_init(sd, client, &ov7670_ops); | 1525 | v4l2_i2c_subdev_init(sd, client, &ov7670_ops); |
| 1567 | 1526 | ||
| 1527 | info->clock_speed = 30; /* default: a guess */ | ||
| 1528 | if (client->dev.platform_data) { | ||
| 1529 | struct ov7670_config *config = client->dev.platform_data; | ||
| 1530 | |||
| 1531 | /* | ||
| 1532 | * Must apply configuration before initializing device, because it | ||
| 1533 | * selects I/O method. | ||
| 1534 | */ | ||
| 1535 | info->min_width = config->min_width; | ||
| 1536 | info->min_height = config->min_height; | ||
| 1537 | info->use_smbus = config->use_smbus; | ||
| 1538 | |||
| 1539 | if (config->clock_speed) | ||
| 1540 | info->clock_speed = config->clock_speed; | ||
| 1541 | } | ||
| 1542 | |||
| 1543 | /* Make sure it's an ov7670 */ | ||
| 1544 | ret = ov7670_detect(sd); | ||
| 1545 | if (ret) { | ||
| 1546 | v4l_dbg(1, debug, client, | ||
| 1547 | "chip found @ 0x%x (%s) is not an ov7670 chip.\n", | ||
| 1548 | client->addr << 1, client->adapter->name); | ||
| 1549 | kfree(info); | ||
| 1550 | return ret; | ||
| 1551 | } | ||
| 1552 | v4l_info(client, "chip found @ 0x%02x (%s)\n", | ||
| 1553 | client->addr << 1, client->adapter->name); | ||
| 1554 | |||
| 1555 | info->fmt = &ov7670_formats[0]; | ||
| 1556 | info->sat = 128; /* Review this */ | ||
| 1557 | info->clkrc = info->clock_speed / 30; | ||
| 1568 | return 0; | 1558 | return 0; |
| 1569 | } | 1559 | } |
| 1570 | 1560 | ||
