diff options
| author | Kuninori Morimoto <morimoto.kuninori@renesas.com> | 2009-12-11 09:53:55 -0500 |
|---|---|---|
| committer | Mauro Carvalho Chehab <mchehab@redhat.com> | 2009-12-16 06:27:41 -0500 |
| commit | 858424b998ae112b2e04f4584bcdc6b0362a714a (patch) | |
| tree | cda123b6561a3b374ea474874ec3df33c88c55e7 | |
| parent | 70da92e5740a6ab8bfe0db826c345c85e795f109 (diff) | |
V4L/DVB (13670): soc-camera: Add mt9t112 camera driver
create mode 100644 drivers/media/video/mt9t112.c
create mode 100644 include/media/mt9t112.h
Signed-off-by: Kuninori Morimoto <morimoto.kuninori@renesas.com>
Signed-off-by: Guennadi Liakhovetski <g.liakhovetski@gmx.de>
Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
| -rw-r--r-- | drivers/media/video/Kconfig | 6 | ||||
| -rw-r--r-- | drivers/media/video/Makefile | 1 | ||||
| -rw-r--r-- | drivers/media/video/mt9t112.c | 1177 | ||||
| -rw-r--r-- | include/media/mt9t112.h | 30 | ||||
| -rw-r--r-- | include/media/v4l2-chip-ident.h | 2 |
5 files changed, 1216 insertions, 0 deletions
diff --git a/drivers/media/video/Kconfig b/drivers/media/video/Kconfig index f63909d9c70b..2f83be766d9f 100644 --- a/drivers/media/video/Kconfig +++ b/drivers/media/video/Kconfig | |||
| @@ -836,6 +836,12 @@ config SOC_CAMERA_MT9T031 | |||
| 836 | help | 836 | help |
| 837 | This driver supports MT9T031 cameras from Micron. | 837 | This driver supports MT9T031 cameras from Micron. |
| 838 | 838 | ||
| 839 | config SOC_CAMERA_MT9T112 | ||
| 840 | tristate "mt9t112 support" | ||
| 841 | depends on SOC_CAMERA && I2C | ||
| 842 | help | ||
| 843 | This driver supports MT9T112 cameras from Aptina. | ||
| 844 | |||
| 839 | config SOC_CAMERA_MT9V022 | 845 | config SOC_CAMERA_MT9V022 |
| 840 | tristate "mt9v022 support" | 846 | tristate "mt9v022 support" |
| 841 | depends on SOC_CAMERA && I2C | 847 | depends on SOC_CAMERA && I2C |
diff --git a/drivers/media/video/Makefile b/drivers/media/video/Makefile index e7bc8daae064..2af68ee84122 100644 --- a/drivers/media/video/Makefile +++ b/drivers/media/video/Makefile | |||
| @@ -75,6 +75,7 @@ obj-$(CONFIG_VIDEO_MT9V011) += mt9v011.o | |||
| 75 | obj-$(CONFIG_SOC_CAMERA_MT9M001) += mt9m001.o | 75 | obj-$(CONFIG_SOC_CAMERA_MT9M001) += mt9m001.o |
| 76 | obj-$(CONFIG_SOC_CAMERA_MT9M111) += mt9m111.o | 76 | obj-$(CONFIG_SOC_CAMERA_MT9M111) += mt9m111.o |
| 77 | obj-$(CONFIG_SOC_CAMERA_MT9T031) += mt9t031.o | 77 | obj-$(CONFIG_SOC_CAMERA_MT9T031) += mt9t031.o |
| 78 | obj-$(CONFIG_SOC_CAMERA_MT9T112) += mt9t112.o | ||
| 78 | obj-$(CONFIG_SOC_CAMERA_MT9V022) += mt9v022.o | 79 | obj-$(CONFIG_SOC_CAMERA_MT9V022) += mt9v022.o |
| 79 | obj-$(CONFIG_SOC_CAMERA_OV772X) += ov772x.o | 80 | obj-$(CONFIG_SOC_CAMERA_OV772X) += ov772x.o |
| 80 | obj-$(CONFIG_SOC_CAMERA_OV9640) += ov9640.o | 81 | obj-$(CONFIG_SOC_CAMERA_OV9640) += ov9640.o |
diff --git a/drivers/media/video/mt9t112.c b/drivers/media/video/mt9t112.c new file mode 100644 index 000000000000..fc4dd6045720 --- /dev/null +++ b/drivers/media/video/mt9t112.c | |||
| @@ -0,0 +1,1177 @@ | |||
| 1 | /* | ||
| 2 | * mt9t112 Camera Driver | ||
| 3 | * | ||
| 4 | * Copyright (C) 2009 Renesas Solutions Corp. | ||
| 5 | * Kuninori Morimoto <morimoto.kuninori@renesas.com> | ||
| 6 | * | ||
| 7 | * Based on ov772x driver, mt9m111 driver, | ||
| 8 | * | ||
| 9 | * Copyright (C) 2008 Kuninori Morimoto <morimoto.kuninori@renesas.com> | ||
| 10 | * Copyright (C) 2008, Robert Jarzmik <robert.jarzmik@free.fr> | ||
| 11 | * Copyright 2006-7 Jonathan Corbet <corbet@lwn.net> | ||
| 12 | * Copyright (C) 2008 Magnus Damm | ||
| 13 | * Copyright (C) 2008, Guennadi Liakhovetski <kernel@pengutronix.de> | ||
| 14 | * | ||
| 15 | * This program is free software; you can redistribute it and/or modify | ||
| 16 | * it under the terms of the GNU General Public License version 2 as | ||
| 17 | * published by the Free Software Foundation. | ||
| 18 | */ | ||
| 19 | |||
| 20 | #include <linux/delay.h> | ||
| 21 | #include <linux/i2c.h> | ||
| 22 | #include <linux/init.h> | ||
| 23 | #include <linux/module.h> | ||
| 24 | #include <linux/slab.h> | ||
| 25 | #include <linux/videodev2.h> | ||
| 26 | |||
| 27 | #include <media/mt9t112.h> | ||
| 28 | #include <media/soc_camera.h> | ||
| 29 | #include <media/soc_mediabus.h> | ||
| 30 | #include <media/v4l2-chip-ident.h> | ||
| 31 | #include <media/v4l2-common.h> | ||
| 32 | |||
| 33 | /* you can check PLL/clock info */ | ||
| 34 | /* #define EXT_CLOCK 24000000 */ | ||
| 35 | |||
| 36 | /************************************************************************ | ||
| 37 | |||
| 38 | |||
| 39 | macro | ||
| 40 | |||
| 41 | |||
| 42 | ************************************************************************/ | ||
| 43 | /* | ||
| 44 | * frame size | ||
| 45 | */ | ||
| 46 | #define MAX_WIDTH 2048 | ||
| 47 | #define MAX_HEIGHT 1536 | ||
| 48 | |||
| 49 | #define VGA_WIDTH 640 | ||
| 50 | #define VGA_HEIGHT 480 | ||
| 51 | |||
| 52 | /* | ||
| 53 | * macro of read/write | ||
| 54 | */ | ||
| 55 | #define ECHECKER(ret, x) \ | ||
| 56 | do { \ | ||
| 57 | (ret) = (x); \ | ||
| 58 | if ((ret) < 0) \ | ||
| 59 | return (ret); \ | ||
| 60 | } while (0) | ||
| 61 | |||
| 62 | #define mt9t112_reg_write(ret, client, a, b) \ | ||
| 63 | ECHECKER(ret, __mt9t112_reg_write(client, a, b)) | ||
| 64 | #define mt9t112_mcu_write(ret, client, a, b) \ | ||
| 65 | ECHECKER(ret, __mt9t112_mcu_write(client, a, b)) | ||
| 66 | |||
| 67 | #define mt9t112_reg_mask_set(ret, client, a, b, c) \ | ||
| 68 | ECHECKER(ret, __mt9t112_reg_mask_set(client, a, b, c)) | ||
| 69 | #define mt9t112_mcu_mask_set(ret, client, a, b, c) \ | ||
| 70 | ECHECKER(ret, __mt9t112_mcu_mask_set(client, a, b, c)) | ||
| 71 | |||
| 72 | #define mt9t112_reg_read(ret, client, a) \ | ||
| 73 | ECHECKER(ret, __mt9t112_reg_read(client, a)) | ||
| 74 | |||
| 75 | /* | ||
| 76 | * Logical address | ||
| 77 | */ | ||
| 78 | #define _VAR(id, offset, base) (base | (id & 0x1f) << 10 | (offset & 0x3ff)) | ||
| 79 | #define VAR(id, offset) _VAR(id, offset, 0x0000) | ||
| 80 | #define VAR8(id, offset) _VAR(id, offset, 0x8000) | ||
| 81 | |||
| 82 | /************************************************************************ | ||
| 83 | |||
| 84 | |||
| 85 | struct | ||
| 86 | |||
| 87 | |||
| 88 | ************************************************************************/ | ||
| 89 | struct mt9t112_frame_size { | ||
| 90 | u16 width; | ||
| 91 | u16 height; | ||
| 92 | }; | ||
| 93 | |||
| 94 | struct mt9t112_format { | ||
| 95 | enum v4l2_mbus_pixelcode code; | ||
| 96 | enum v4l2_colorspace colorspace; | ||
| 97 | u16 fmt; | ||
| 98 | u16 order; | ||
| 99 | }; | ||
| 100 | |||
| 101 | struct mt9t112_priv { | ||
| 102 | struct v4l2_subdev subdev; | ||
| 103 | struct mt9t112_camera_info *info; | ||
| 104 | struct i2c_client *client; | ||
| 105 | struct soc_camera_device icd; | ||
| 106 | struct mt9t112_frame_size frame; | ||
| 107 | const struct mt9t112_format *format; | ||
| 108 | int model; | ||
| 109 | u32 flags; | ||
| 110 | /* for flags */ | ||
| 111 | #define INIT_DONE (1<<0) | ||
| 112 | }; | ||
| 113 | |||
| 114 | /************************************************************************ | ||
| 115 | |||
| 116 | |||
| 117 | supported format | ||
| 118 | |||
| 119 | |||
| 120 | ************************************************************************/ | ||
| 121 | |||
| 122 | static const struct mt9t112_format mt9t112_cfmts[] = { | ||
| 123 | { | ||
| 124 | .code = V4L2_MBUS_FMT_YUYV8_2X8_BE, | ||
| 125 | .colorspace = V4L2_COLORSPACE_JPEG, | ||
| 126 | .fmt = 1, | ||
| 127 | .order = 0, | ||
| 128 | }, { | ||
| 129 | .code = V4L2_MBUS_FMT_YVYU8_2X8_BE, | ||
| 130 | .colorspace = V4L2_COLORSPACE_JPEG, | ||
| 131 | .fmt = 1, | ||
| 132 | .order = 1, | ||
| 133 | }, { | ||
| 134 | .code = V4L2_MBUS_FMT_YUYV8_2X8_LE, | ||
| 135 | .colorspace = V4L2_COLORSPACE_JPEG, | ||
| 136 | .fmt = 1, | ||
| 137 | .order = 2, | ||
| 138 | }, { | ||
| 139 | .code = V4L2_MBUS_FMT_YVYU8_2X8_LE, | ||
| 140 | .colorspace = V4L2_COLORSPACE_JPEG, | ||
| 141 | .fmt = 1, | ||
| 142 | .order = 3, | ||
| 143 | }, { | ||
| 144 | .code = V4L2_MBUS_FMT_RGB555_2X8_PADHI_LE, | ||
| 145 | .colorspace = V4L2_COLORSPACE_SRGB, | ||
| 146 | .fmt = 8, | ||
| 147 | .order = 2, | ||
| 148 | }, { | ||
| 149 | .code = V4L2_MBUS_FMT_RGB565_2X8_LE, | ||
| 150 | .colorspace = V4L2_COLORSPACE_SRGB, | ||
| 151 | .fmt = 4, | ||
| 152 | .order = 2, | ||
| 153 | }, | ||
| 154 | }; | ||
| 155 | |||
| 156 | /************************************************************************ | ||
| 157 | |||
| 158 | |||
| 159 | general function | ||
