14 #include <linux/i2c.h>
16 #include <linux/slab.h>
17 #include <linux/videodev2.h>
18 #include <linux/module.h>
26 #define MODE_SELECT 0x0100
27 #define IMAGE_ORIENTATION 0x0101
28 #define GROUPED_PARAMETER_HOLD 0x0104
31 #define COARSE_INTEGRATION_TIME_HI 0x0202
32 #define COARSE_INTEGRATION_TIME_LO 0x0203
34 #define ANALOGUE_GAIN_CODE_GLOBAL_HI 0x0204
35 #define ANALOGUE_GAIN_CODE_GLOBAL_LO 0x0205
38 #define PRE_PLL_CLK_DIV 0x0305
39 #define PLL_MULTIPLIER 0x0307
40 #define PLSTATIM 0x302b
41 #define VNDMY_ABLMGSHLMT 0x300a
42 #define Y_OPBADDR_START_DI 0x3014
44 #define FRAME_LENGTH_LINES_HI 0x0340
45 #define FRAME_LENGTH_LINES_LO 0x0341
46 #define LINE_LENGTH_PCK_HI 0x0342
47 #define LINE_LENGTH_PCK_LO 0x0343
48 #define YADDR_START 0x0347
49 #define YADDR_END 0x034b
50 #define X_OUTPUT_SIZE_MSB 0x034c
51 #define X_OUTPUT_SIZE_LSB 0x034d
52 #define Y_OUTPUT_SIZE_MSB 0x034e
53 #define Y_OUTPUT_SIZE_LSB 0x034f
54 #define X_EVEN_INC 0x0381
55 #define X_ODD_INC 0x0383
56 #define Y_EVEN_INC 0x0385
57 #define Y_ODD_INC 0x0387
59 #define HMODEADD 0x3001
60 #define VMODEADD 0x3016
61 #define VAPPLINE_START 0x3069
62 #define VAPPLINE_END 0x306b
63 #define SHUTTER 0x3086
64 #define HADDAVE 0x30e8
65 #define LANESEL 0x3301
68 #define IMX074_WIDTH 1052
69 #define IMX074_HEIGHT 780
96 for (i = 0; i <
ARRAY_SIZE(imx074_colour_fmts); i++)
97 if (imx074_colour_fmts[i].code == code)
98 return imx074_colour_fmts +
i;
123 return ret == 1 ? 0 : -
EIO;
128 u8 buf[2] = {addr >> 8, addr & 0xff};
137 .addr = client->
addr,
146 dev_warn(&client->
dev,
"Reading register %x from %x failed\n",
151 return buf[0] & 0xff;
155 struct v4l2_mbus_framefmt *mf)
162 mf->code = imx074_colour_fmts[0].
code;
163 mf->colorspace = imx074_colour_fmts[0].
colorspace;
174 struct v4l2_mbus_framefmt *mf)
176 struct i2c_client *client = v4l2_get_subdevdata(sd);
182 if (!imx074_find_datafmt(mf->code))
185 imx074_try_fmt(sd, mf);
187 priv->
fmt = imx074_find_datafmt(mf->code);
193 struct v4l2_mbus_framefmt *mf)
195 struct i2c_client *client = v4l2_get_subdevdata(sd);
196 struct imx074 *priv = to_imx074(client);
200 mf->code = fmt->
code;
239 if ((
unsigned int)index >=
ARRAY_SIZE(imx074_colour_fmts))
248 struct i2c_client *client = v4l2_get_subdevdata(sd);
254 static int imx074_g_chip_ident(
struct v4l2_subdev *sd,
257 struct i2c_client *client = v4l2_get_subdevdata(sd);
271 static int imx074_s_power(
struct v4l2_subdev *sd,
int on)
273 struct i2c_client *client = v4l2_get_subdevdata(sd);
276 return soc_camera_set_power(&client->
dev, icl, on);
279 static int imx074_g_mbus_config(
struct v4l2_subdev *sd,
291 .s_stream = imx074_s_stream,
292 .s_mbus_fmt = imx074_s_fmt,
293 .g_mbus_fmt = imx074_g_fmt,
294 .try_mbus_fmt = imx074_try_fmt,
295 .enum_mbus_fmt = imx074_enum_fmt,
296 .g_crop = imx074_g_crop,
297 .cropcap = imx074_cropcap,
298 .g_mbus_config = imx074_g_mbus_config,
302 .g_chip_ident = imx074_g_chip_ident,
303 .s_power = imx074_s_power,
307 .core = &imx074_subdev_core_ops,
308 .video = &imx074_subdev_video_ops,
311 static int imx074_video_probe(
struct i2c_client *client)
317 ret = imx074_s_power(subdev, 1);
334 dev_info(&client->
dev,
"Chip ID 0x%04x detected\n",
id);
424 imx074_s_power(subdev, 0);
428 static int imx074_probe(
struct i2c_client *client,
437 dev_err(&client->
dev,
"IMX074: missing platform data!\n");
443 "I2C-Adapter doesn't support I2C_FUNC_SMBUS_BYTE\n");
453 priv->
fmt = &imx074_colour_fmts[0];
455 ret = imx074_video_probe(client);
464 static int imx074_remove(
struct i2c_client *client)
466 struct imx074 *priv = to_imx074(client);
482 static struct i2c_driver imx074_i2c_driver = {
486 .probe = imx074_probe,
487 .remove = imx074_remove,
488 .id_table = imx074_id,