diff options
author | Liu Ying <b17645@freescale.com> | 2011-01-10 18:43:00 +0800 |
---|---|---|
committer | Liu Ying <b17645@freescale.com> | 2011-01-11 12:43:32 +0800 |
commit | c90b9ee1007764652f6081d3836afad64a18b752 (patch) | |
tree | 4b10dffd1dde803e241175b759cdac0ad2e65e3e /drivers/media | |
parent | 90fdf1cded2ce26ac6e8c81944a78a3f998ddaf2 (diff) |
ENGR00137783-2 OV3640:Add several internal ioctrl support
This patch adds format capability enumeration, frame size
enumeration and chip identification support.
Signed-off-by: Liu Ying <b17645@freescale.com>
Diffstat (limited to 'drivers/media')
-rw-r--r-- | drivers/media/video/mxc/capture/ov3640.c | 75 |
1 files changed, 71 insertions, 4 deletions
diff --git a/drivers/media/video/mxc/capture/ov3640.c b/drivers/media/video/mxc/capture/ov3640.c index b7b552a5c9ae..0613ea28508c 100644 --- a/drivers/media/video/mxc/capture/ov3640.c +++ b/drivers/media/video/mxc/capture/ov3640.c @@ -1,5 +1,5 @@ /* - * Copyright 2005-2010 Freescale Semiconductor, Inc. All Rights Reserved. + * Copyright 2005-2011 Freescale Semiconductor, Inc. All Rights Reserved. */ /* @@ -20,6 +20,7 @@ #include <linux/i2c.h> #include <linux/regulator/consumer.h> #include <linux/fsl_devices.h> +#include <media/v4l2-chip-ident.h> #include <media/v4l2-int-device.h> #include "mxc_v4l2_capture.h" @@ -28,7 +29,6 @@ #define OV3640_VOLTAGE_DIGITAL_IO 1800000 #define OV3640_VOLTAGE_DIGITAL_GPO 2800000 -/* Check these values! */ #define MIN_FPS 15 #define MAX_FPS 30 #define DEFAULT_FPS 30 @@ -792,6 +792,10 @@ static int ov3640_init_mode(enum ov3640_frame_rate frame_rate, ov3640_data.pix.width = ov3640_mode_info_data[frame_rate][mode].width; ov3640_data.pix.height = ov3640_mode_info_data[frame_rate][mode].height; + if (ov3640_data.pix.width == 0 || ov3640_data.pix.height == 0 || + pModeSetting == NULL || iModeSettingArySize == 0) + return -EINVAL; + for (i = 0; i < iModeSettingArySize; ++i, ++pModeSetting) { Delay_ms = pModeSetting->u32Delay_ms; RegAddr = pModeSetting->u16RegAddr; @@ -1128,6 +1132,47 @@ static int ioctl_s_ctrl(struct v4l2_int_device *s, struct v4l2_control *vc) } /*! + * ioctl_enum_framesizes - V4L2 sensor interface handler for + * VIDIOC_ENUM_FRAMESIZES ioctl + * @s: pointer to standard V4L2 device structure + * @fsize: standard V4L2 VIDIOC_ENUM_FRAMESIZES ioctl structure + * + * Return 0 if successful, otherwise -EINVAL. + */ +static int ioctl_enum_framesizes(struct v4l2_int_device *s, + struct v4l2_frmsizeenum *fsize) +{ + if (fsize->index > ov3640_mode_MAX) + return -EINVAL; + + fsize->pixel_format = ov3640_data.pix.pixelformat; + fsize->discrete.width = + max(ov3640_mode_info_data[0][fsize->index].width, + ov3640_mode_info_data[1][fsize->index].width); + fsize->discrete.height = + max(ov3640_mode_info_data[0][fsize->index].height, + ov3640_mode_info_data[1][fsize->index].height); + return 0; +} + +/*! + * ioctl_g_chip_ident - V4L2 sensor interface handler for + * VIDIOC_DBG_G_CHIP_IDENT ioctl + * @s: pointer to standard V4L2 device structure + * @id: pointer to int + * + * Return 0. + */ +static int ioctl_g_chip_ident(struct v4l2_int_device *s, int *id) +{ + ((struct v4l2_dbg_chip_ident *)id)->match.type = + V4L2_CHIP_MATCH_I2C_DRIVER; + strcpy(((struct v4l2_dbg_chip_ident *)id)->match.name, "ov3640_camera"); + + return 0; +} + +/*! * ioctl_init - V4L2 sensor interface handler for VIDIOC_INT_INIT * @s: pointer to standard V4L2 device structure */ @@ -1138,6 +1183,24 @@ static int ioctl_init(struct v4l2_int_device *s) } /*! + * ioctl_enum_fmt_cap - V4L2 sensor interface handler for VIDIOC_ENUM_FMT + * @s: pointer to standard V4L2 device structure + * @fmt: pointer to standard V4L2 fmt description structure + * + * Return 0. + */ +static int ioctl_enum_fmt_cap(struct v4l2_int_device *s, + struct v4l2_fmtdesc *fmt) +{ + if (fmt->index > ov3640_mode_MAX) + return -EINVAL; + + fmt->pixelformat = ov3640_data.pix.pixelformat; + + return 0; +} + +/*! * ioctl_dev_init - V4L2 sensor interface handler for vidioc_int_dev_init_num * @s: pointer to standard V4L2 device structure * @@ -1203,8 +1266,8 @@ static struct v4l2_int_ioctl_desc ov3640_ioctl_desc[] = { (v4l2_int_ioctl_func *)ioctl_g_needs_reset}, */ /* {vidioc_int_reset_num, (v4l2_int_ioctl_func *)ioctl_reset}, */ {vidioc_int_init_num, (v4l2_int_ioctl_func*)ioctl_init}, -/* {vidioc_int_enum_fmt_cap_num, - (v4l2_int_ioctl_func *)ioctl_enum_fmt_cap}, */ + {vidioc_int_enum_fmt_cap_num, + (v4l2_int_ioctl_func *)ioctl_enum_fmt_cap}, /* {vidioc_int_try_fmt_cap_num, (v4l2_int_ioctl_func *)ioctl_try_fmt_cap}, */ {vidioc_int_g_fmt_cap_num, (v4l2_int_ioctl_func*)ioctl_g_fmt_cap}, @@ -1214,6 +1277,10 @@ static struct v4l2_int_ioctl_desc ov3640_ioctl_desc[] = { /* {vidioc_int_queryctrl_num, (v4l2_int_ioctl_func *)ioctl_queryctrl}, */ {vidioc_int_g_ctrl_num, (v4l2_int_ioctl_func*)ioctl_g_ctrl}, {vidioc_int_s_ctrl_num, (v4l2_int_ioctl_func*)ioctl_s_ctrl}, + {vidioc_int_enum_framesizes_num, + (v4l2_int_ioctl_func *)ioctl_enum_framesizes}, + {vidioc_int_g_chip_ident_num, + (v4l2_int_ioctl_func *)ioctl_g_chip_ident}, }; static struct v4l2_int_slave ov3640_slave = { |