>From 618161afc79c5c2e4a7fb8a836d3c92cdc89a155 Mon Sep 17 00:00:00 2001 From: Wen Wang <[email protected]> Date: Fri, 24 Dec 2010 02:33:33 +0800 Subject: [PATCH] Update DIS71430M camera driver with Medfield CI specific features
This patch updates DIS71430M camera driver with Medfield CI following features: 1. Camera sensor ISO control 2. Camera sensor aperture control Signed-off-by: Wen Wang <[email protected]> Signed-off-by: Xiaolin Zhang <[email protected]> --- drivers/media/video/discam.c | 230 ++++++++++++++++++++++++++++++++++++++++++ 1 files changed, 230 insertions(+), 0 deletions(-) diff --git a/drivers/media/video/discam.c b/drivers/media/video/discam.c index 486d442..535b850 100644 --- a/drivers/media/video/discam.c +++ b/drivers/media/video/discam.c @@ -677,6 +677,112 @@ static int set_itg_time(struct i2c_client *client, /* * DIS-AN10-1003: * + * if an illegal ISO speed value (>1600) is requested, + * DIS_CMD_WRONG_PARAMETER is returned. + */ +static int set_iso(struct i2c_client *client, u16 iso, u16 * actual_iso) +{ + int ret = 0; + struct dis_cmd cmd; + + memset(&cmd, 0, sizeof(cmd)); + + /* + * setup manual ISO. + * + * if an illegal ISO speed value (>1600) is requested, + * DIS_CMD_WRONG_PARAMETER retuned. + * + * return actual ISO speed. there's the ability that the requested + * ISO could not be set exactly due to gain specification of the + * sensor. in this case the nearest possible ISO is setup and + * returned. + * + * this function must be called when sensor is in "wakeup" or + * "viewfinder" mode. it will wake up sensor first if it is in + * "power down" or "standby" mode. + * + * CMD: DIS_CMD_REQ_ISO_SPEED + * ARG: PROC_REG0 -- ISO (MSB) + * PROC_REG1 -- ISO (LSB) + * RET: PROC_REG1 -- actual ISO (MSB) + * PROC_REG2 -- actual ISO (LSB) + */ + cmd.proc_cmd = DIS_CMD_REQ_ISO_SPEED; + cmd.proc_reg0 = ((iso) >> 8); /* MSB */ + cmd.proc_reg1 = (u8) iso; + + dev_dbg(&client->dev, "iso = %d\n", iso); + + ret = discam_excute_cmd(client, &cmd); + if (ret) { + dev_err(&client->dev, "discam_excute_cmd err.\n"); + return -1; + } + + discam_check_cmd_retval_return(cmd); + + (*actual_iso) = (((u16) cmd.ret_reg1) << 8) | ((u16) cmd.ret_reg2); + + dev_dbg(&client->dev, "actual iso = %d\n", (*actual_iso)); + + return ret; +} + +/* + * DIS-AN10-1003: + * + * set aperture opening factor. + * + * 0 - closed (0%) + * . + * 25 - F#5.6 (25%) + * . + * 100 - open (100%) + */ +static int set_aperture_pos(struct i2c_client *client, u8 factor) +{ + int ret = 0; + struct dis_cmd cmd; + + memset(&cmd, 0, sizeof(cmd)); + + /* + * setup aperture factor (opening percent) + * + * this function must be called when sensor is in "wakeup" or + * "viewfinder" mode. it will wake up sensor first if it is in + * "power down" or "standby" mode. + * + * valid range: 0~100(0x64), 100 means 100%, fully open. + * 0 means closed. + * + * example: + * F#4.0 ~ 50% + * F#5.6 ~ 25% + * + * CMD: DIS_CMD_SET_APERTURE_POS + * ARG: PROC_REG0 aperture factor + */ + cmd.proc_cmd = DIS_CMD_SET_APERTURE_POS; + cmd.proc_reg0 = factor; + + dev_dbg(&client->dev, "aperture factor = %d\n", factor); + + ret = discam_excute_cmd(client, &cmd); + if (ret) { + dev_err(&client->dev, "discam_excute_cmd err.\n"); + return -1; + } + + discam_check_cmd_retval_return(cmd); + + return ret; +} + +/* + * DIS-AN10-1003: + * * get actual exposure setting * * integration time is given in 100/256 us steps @@ -1174,6 +1280,64 @@ static int discam_set_itg_time(struct v4l2_subdev *sd, } /* + * setup manual ISO. + */ +static int discam_set_iso(struct v4l2_subdev *sd, u16 iso, u16 *actual_iso) +{ + struct i2c_client *client; + struct discam_device *dev; + int ret = 0; + + if (!sd) + return -EINVAL; + + dev = to_discam_device(sd); + client = v4l2_get_subdevdata(sd); + + ret = discam_wakeup(sd); + + /* + * Add code to check iso valid ? + */ + ret = set_iso(client, iso, actual_iso); + if (ret) { + dev_err(&client->dev, "set_iso err.\n"); + return -1; + } + + return 0; +} + +/* + * setup aperture factor (opening percent) + */ +static int discam_set_aperture(struct v4l2_subdev *sd, u8 aperture_factor) +{ + struct i2c_client *client; + struct discam_device *dev; + int ret = 0; + + if (!sd) + return -EINVAL; + + dev = to_discam_device(sd); + client = v4l2_get_subdevdata(sd); + + ret = discam_wakeup(sd); + + /* + * Add code to check aperture_factor valid ? + */ + ret = set_aperture_pos(client, aperture_factor); + if (ret) { + dev_err(&client->dev, "set_aperture_pos err.\n"); + return -1; + } + + return 0; +} + +/* * get current exposure control settings. */ static int discam_get_exposure_setting(struct v4l2_subdev *sd, @@ -1302,6 +1466,62 @@ static int discam_g_exposure(struct v4l2_subdev *sd, u32 * val) return 0; } +static int discam_s_iso(struct v4l2_subdev *sd, u32 val) +{ + u16 real; + + if (!sd) + return -EINVAL; + + return discam_set_iso(sd, (u16) val, &real); +} + +static int discam_g_iso(struct v4l2_subdev *sd, u32 * val) +{ + int ret; + u32 itg_time; + u16 iso; + u8 aperture; + + if (!sd) + return -EINVAL; + + ret = discam_get_exposure_setting(sd, &itg_time, &iso, &aperture); + if (ret) + return -1; + + (*val) = iso; + + return 0; +} + +static int discam_s_aperture(struct v4l2_subdev *sd, u32 val) +{ + if (!sd) + return -EINVAL; + + return discam_set_aperture(sd, (u8) val); +} + +static int discam_g_aperture(struct v4l2_subdev *sd, u32 * val) +{ + int ret; + u32 itg_time; + u16 iso; + u8 aperture; + + if (!sd) + return -EINVAL; + + ret = discam_get_exposure_setting(sd, &itg_time, &iso, &aperture); + if (ret) + return -1; + + (*val) = aperture; + + return 0; +} + static int discam_s_focus(struct v4l2_subdev *sd, u32 val) { if (!sd) @@ -1333,6 +1553,14 @@ static const struct s_ctrl_id DISCAM_CTRLS[] = { "Absolute Exposure", 0, 0xffff, 1, 0, 0, discam_s_exposure, discam_g_exposure), + s_ctrl_id_entry_integer(V4L2_CID_ISO_ABSOLUTE, + "Absolute ISO", 0, 0xffff, 1, 0, 0, + discam_s_iso, + discam_g_iso), + s_ctrl_id_entry_integer(V4L2_CID_APERTURE_ABSOLUTE, + "Absolute Aperture", 0, 0xffff, 1, 0, 0, + discam_s_aperture, + discam_g_aperture), s_ctrl_id_entry_integer(V4L2_CID_FOCUS_ABSOLUTE, "Absolute Focus", 0, 0xffff, 1, 0, 0, discam_s_focus, @@ -1403,6 +1631,8 @@ static int discam_start_viewfinder(struct v4l2_subdev *sd, u8 mode) client = v4l2_get_subdevdata(sd); discam_s_exposure(sd, (int)(500)); + discam_s_iso(sd, 80); + discam_s_aperture(sd, 100); /* * after discam_startup, the camera is in DIS_STATUS_ACTIVE mode. -- 1.5.4.3
0001-Update-DIS71430M-camera-driver-with-Medfield-CI-spec.patch
Description: 0001-Update-DIS71430M-camera-driver-with-Medfield-CI-spec.patch
_______________________________________________ MeeGo-kernel mailing list [email protected] http://lists.meego.com/listinfo/meego-kernel
