RE: [REVIEW][PATCH] LV8093: Add driver for LV8093 lens actuator.
-Original Message- From: Juan Jesús García de Soria Lucena [mailto:skanda...@gmail.com] Sent: Thursday, February 05, 2009 1:26 AM To: Curran, Dominic Cc: linux-media@vger.kernel.org Subject: Re: [REVIEW][PATCH] LV8093: Add driver for LV8093 lens actuator. Hi. 2009/2/4 Dominic Curran dcur...@ti.com: The device has only one read register which contains a single BUSY bit. For large relative lens movements the device can be busy for sometime and we need to know when the lens has stopped moving. My question is what is the most appropriate mechanism to read the BUSY bit ? Currently the driver uses the VIDIOC_G_CTRL ioctl + V4L2_CID_FOCUS_RELATIVE ctrl ID to return the BUSY bit. Is this acceptable ? [...] A 3rd solution is to read the BUSY bit everytime after a write and not return until device is ready. However this adds extra time to the operation (particularly for small lens moves) and I would like the user to be in change of when the reads of BUSY bit occur. And what about waiting for not BUSY at the *beginning* of the next lens adjustment if the previous one hasn't finished yet? This could be combined with either a polling interface or a sync style interface (wait for not BUSY function) for the case in which the user wants to actually be sure that the lens got up to its target state. Yes, poll would be a good solution, but I'm can not workout how I can add a poll() method to a v4l slave driver ? Are there an examples of such v4l slave drivers you can point me too ? All the v4l drivers I can find that have .poll fops register using video_register_device(). My slave driver uses v4l2_int_device_register(). Any pointers appreciated. Thanks dom -- To unsubscribe from this list: send the line unsubscribe linux-media in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [REVIEW][PATCH] LV8093: Add driver for LV8093 lens actuator.
Hello, Dominic May i make few comments ? On Wed, 2009-02-04 at 12:40 -0600, Dominic Curran wrote: Hi Below is a new driver for the LV8093 lens actuator. Of course all comments are welcome, however I have a specific issue that i am concerned about... The lens position cannot be read back from this device, and it only takes relative positions (it uses V4L2_CID_FOCUS_RELATIVE ctrl ID). The device has only one read register which contains a single BUSY bit. For large relative lens movements the device can be busy for sometime and we need to know when the lens has stopped moving. My question is what is the most appropriate mechanism to read the BUSY bit ? Currently the driver uses the VIDIOC_G_CTRL ioctl + V4L2_CID_FOCUS_RELATIVE ctrl ID to return the BUSY bit. Is this acceptable ? The only other solution I can think of is: * Use does VIDIOC_S_CTRL ioctl .id = V4L2_CID_FOCUS_RELATIVE .value = 0 * If driver detects .value=0 then it reads the BUSY bit and returns either 0 - Ready -EBUSY - lens busy A 3rd solution is to read the BUSY bit everytime after a write and not return until device is ready. However this adds extra time to the operation (particularly for small lens moves) and I would like the user to be in change of when the reads of BUSY bit occur. I hope I have made my question clear. Any guidance appreciated thanks dom From: Dominic Curran dcur...@ti.com Subject: [PATCH v2 1/3] LV8093: Add driver for LV8093 lens actuator. Support for the Sanyo LV8093CS piezo-actuator lens driver. The lens position cannot be read back from this device, and it only takes relative positions. Thus it: - Supports the VIDIOC_G_CTRL ioctl to return BUSY bit (0 - Ready, ~0 - Busy) - Supports the VIDIOC_S_CTRL ioctl with the V4L2_CID_FOCUS_RELATIVE control ID. One relative step requested through the V4L2_CID_FOCUS_RELATIVE control will produce a 5.0um step @ 5.2mm/s of the lens. Signed-off-by: Kraig Proehl kraig.pro...@hp.com Signed-off-by: Dominic Curran dcur...@ti.com --- drivers/media/video/lv8093.c | 595 +++ drivers/media/video/lv8093.h | 92 ++ 2 files changed, 687 insertions(+) Index: omapzoom04/drivers/media/video/lv8093.c === --- /dev/null +++ omapzoom04/drivers/media/video/lv8093.c @@ -0,0 +1,595 @@ +/* + * drivers/media/video/lv8093.c + * + * LV8093 Piezo Motor (LENS) driver + * + * Copyright (C) 2008-2009 Texas Instruments. + * Copyright (C) 2009 Hewlett-Packard. + * + * This package is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2 as + * published by the Free Software Foundation. + * + * THIS PACKAGE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR + * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED + * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE. + */ + +#include linux/mutex.h +#include linux/i2c.h +#include linux/delay.h +#include linux/platform_device.h +#include linux/cdev.h +#include linux/device.h + +#include media/v4l2-int-device.h +#include mach/gpio.h + +#include lv8093.h + +static int +lv8093_probe(struct i2c_client *client, const struct i2c_device_id *id); +static int __exit lv8093_remove(struct i2c_client *client); + +struct lv8093_device { + const struct lv8093_platform_data *pdata; + struct v4l2_int_device *v4l2_int_device; + struct i2c_client *i2c_client; + int state; + int power_state; +}; + +static const struct i2c_device_id lv8093_id[] = { + {LV8093_NAME, 0}, + {} +}; + +MODULE_DEVICE_TABLE(i2c, lv8093_id); + +static struct i2c_driver lv8093_i2c_driver = { + .driver = { +.name = LV8093_NAME, +.owner = THIS_MODULE, +}, + .probe = lv8093_probe, + .remove = __exit_p(lv8093_remove), + .id_table = lv8093_id, +}; + +static struct lv8093_device lv8093 = { + .state = LENS_NOT_DETECTED, +}; + +static struct vcontrol { + struct v4l2_queryctrl qc; +} video_control[] = { + { + { + .id = V4L2_CID_FOCUS_RELATIVE, + .type = V4L2_CTRL_TYPE_INTEGER, + .name = Lens Relative Position, + .minimum = 0, + .maximum = 0, + .step = LV8093_MAX_RELATIVE_STEP, + .default_value = 0, + } + ,} +}; + +static struct i2c_driver lv8093_i2c_driver; + +static struct lv8093_lens_settings { + u8 reg; + u8 val; +} lens_settings[] = { + { /* Set control register */ + .reg = CAMAF_LV8093_CTL_REG, + .val = CAMAF_LV8093_GATE0 | + CAMAF_LV8093_ENIN | + CAMAF_LV8093_CKSEL_ONE | +
[REVIEW][PATCH] LV8093: Add driver for LV8093 lens actuator.
Hi Below is a new driver for the LV8093 lens actuator. Of course all comments are welcome, however I have a specific issue that i am concerned about... The lens position cannot be read back from this device, and it only takes relative positions (it uses V4L2_CID_FOCUS_RELATIVE ctrl ID). The device has only one read register which contains a single BUSY bit. For large relative lens movements the device can be busy for sometime and we need to know when the lens has stopped moving. My question is what is the most appropriate mechanism to read the BUSY bit ? Currently the driver uses the VIDIOC_G_CTRL ioctl + V4L2_CID_FOCUS_RELATIVE ctrl ID to return the BUSY bit. Is this acceptable ? The only other solution I can think of is: * Use does VIDIOC_S_CTRL ioctl .id = V4L2_CID_FOCUS_RELATIVE .value = 0 * If driver detects .value=0 then it reads the BUSY bit and returns either 0 - Ready -EBUSY - lens busy A 3rd solution is to read the BUSY bit everytime after a write and not return until device is ready. However this adds extra time to the operation (particularly for small lens moves) and I would like the user to be in change of when the reads of BUSY bit occur. I hope I have made my question clear. Any guidance appreciated thanks dom From: Dominic Curran dcur...@ti.com Subject: [PATCH v2 1/3] LV8093: Add driver for LV8093 lens actuator. Support for the Sanyo LV8093CS piezo-actuator lens driver. The lens position cannot be read back from this device, and it only takes relative positions. Thus it: - Supports the VIDIOC_G_CTRL ioctl to return BUSY bit (0 - Ready, ~0 - Busy) - Supports the VIDIOC_S_CTRL ioctl with the V4L2_CID_FOCUS_RELATIVE control ID. One relative step requested through the V4L2_CID_FOCUS_RELATIVE control will produce a 5.0um step @ 5.2mm/s of the lens. Signed-off-by: Kraig Proehl kraig.pro...@hp.com Signed-off-by: Dominic Curran dcur...@ti.com --- drivers/media/video/lv8093.c | 595 +++ drivers/media/video/lv8093.h | 92 ++ 2 files changed, 687 insertions(+) Index: omapzoom04/drivers/media/video/lv8093.c === --- /dev/null +++ omapzoom04/drivers/media/video/lv8093.c @@ -0,0 +1,595 @@ +/* + * drivers/media/video/lv8093.c + * + * LV8093 Piezo Motor (LENS) driver + * + * Copyright (C) 2008-2009 Texas Instruments. + * Copyright (C) 2009 Hewlett-Packard. + * + * This package is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2 as + * published by the Free Software Foundation. + * + * THIS PACKAGE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR + * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED + * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE. + */ + +#include linux/mutex.h +#include linux/i2c.h +#include linux/delay.h +#include linux/platform_device.h +#include linux/cdev.h +#include linux/device.h + +#include media/v4l2-int-device.h +#include mach/gpio.h + +#include lv8093.h + +static int +lv8093_probe(struct i2c_client *client, const struct i2c_device_id *id); +static int __exit lv8093_remove(struct i2c_client *client); + +struct lv8093_device { + const struct lv8093_platform_data *pdata; + struct v4l2_int_device *v4l2_int_device; + struct i2c_client *i2c_client; + int state; + int power_state; +}; + +static const struct i2c_device_id lv8093_id[] = { + {LV8093_NAME, 0}, + {} +}; + +MODULE_DEVICE_TABLE(i2c, lv8093_id); + +static struct i2c_driver lv8093_i2c_driver = { + .driver = { + .name = LV8093_NAME, + .owner = THIS_MODULE, + }, + .probe = lv8093_probe, + .remove = __exit_p(lv8093_remove), + .id_table = lv8093_id, +}; + +static struct lv8093_device lv8093 = { + .state = LENS_NOT_DETECTED, +}; + +static struct vcontrol { + struct v4l2_queryctrl qc; +} video_control[] = { + { + { + .id = V4L2_CID_FOCUS_RELATIVE, + .type = V4L2_CTRL_TYPE_INTEGER, + .name = Lens Relative Position, + .minimum = 0, + .maximum = 0, + .step = LV8093_MAX_RELATIVE_STEP, + .default_value = 0, + } + ,} +}; + +static struct i2c_driver lv8093_i2c_driver; + +static struct lv8093_lens_settings { + u8 reg; + u8 val; +} lens_settings[] = { + { /* Set control register */ + .reg = CAMAF_LV8093_CTL_REG, + .val = CAMAF_LV8093_GATE0 | + CAMAF_LV8093_ENIN | + CAMAF_LV8093_CKSEL_ONE | + CAMAF_LV8093_RET2 | + CAMAF_LV8093_INIT_OFF, + }, + { /* Specify number of clocks per period */ + .reg =