#include <linux/i2c.h>
#include <linux/slab.h>
#include <linux/videodev2.h>
#include <linux/delay.h>
#include <linux/module.h>
#include <asm/div64.h>
#include <media/v4l2-device.h>
#include <media/v4l2-ctrls.h>
#include <media/i2c/mt9v011.h>
MODULE_DESCRIPTION(…) …;
MODULE_AUTHOR(…) …;
MODULE_LICENSE(…) …;
static int debug;
module_param(debug, int, 0);
MODULE_PARM_DESC(…) …;
#define R00_MT9V011_CHIP_VERSION …
#define R01_MT9V011_ROWSTART …
#define R02_MT9V011_COLSTART …
#define R03_MT9V011_HEIGHT …
#define R04_MT9V011_WIDTH …
#define R05_MT9V011_HBLANK …
#define R06_MT9V011_VBLANK …
#define R07_MT9V011_OUT_CTRL …
#define R09_MT9V011_SHUTTER_WIDTH …
#define R0A_MT9V011_CLK_SPEED …
#define R0B_MT9V011_RESTART …
#define R0C_MT9V011_SHUTTER_DELAY …
#define R0D_MT9V011_RESET …
#define R1E_MT9V011_DIGITAL_ZOOM …
#define R20_MT9V011_READ_MODE …
#define R2B_MT9V011_GREEN_1_GAIN …
#define R2C_MT9V011_BLUE_GAIN …
#define R2D_MT9V011_RED_GAIN …
#define R2E_MT9V011_GREEN_2_GAIN …
#define R35_MT9V011_GLOBAL_GAIN …
#define RF1_MT9V011_CHIP_ENABLE …
#define MT9V011_VERSION …
#define MT9V011_REV_B_VERSION …
struct mt9v011 { … };
static inline struct mt9v011 *to_mt9v011(struct v4l2_subdev *sd)
{ … }
static int mt9v011_read(struct v4l2_subdev *sd, unsigned char addr)
{ … }
static void mt9v011_write(struct v4l2_subdev *sd, unsigned char addr,
u16 value)
{ … }
struct i2c_reg_value { … };
static const struct i2c_reg_value mt9v011_init_default[] = …;
static u16 calc_mt9v011_gain(s16 lineargain)
{ … }
static void set_balance(struct v4l2_subdev *sd)
{ … }
static void calc_fps(struct v4l2_subdev *sd, u32 *numerator, u32 *denominator)
{ … }
static u16 calc_speed(struct v4l2_subdev *sd, u32 numerator, u32 denominator)
{ … }
static void set_res(struct v4l2_subdev *sd)
{
struct mt9v011 *core = to_mt9v011(sd);
unsigned vstart, hstart;
hstart = 20 + (640 - core->width) / 2;
mt9v011_write(sd, R02_MT9V011_COLSTART, hstart);
mt9v011_write(sd, R04_MT9V011_WIDTH, core->width);
mt9v011_write(sd, R05_MT9V011_HBLANK, 771 - core->width);
vstart = 8 + (480 - core->height) / 2;
mt9v011_write(sd, R01_MT9V011_ROWSTART, vstart);
mt9v011_write(sd, R03_MT9V011_HEIGHT, core->height);
mt9v011_write(sd, R06_MT9V011_VBLANK, 508 - core->height);
calc_fps(sd, NULL, NULL);
};
static void set_read_mode(struct v4l2_subdev *sd)
{ … }
static int mt9v011_reset(struct v4l2_subdev *sd, u32 val)
{ … }
static int mt9v011_enum_mbus_code(struct v4l2_subdev *sd,
struct v4l2_subdev_state *sd_state,
struct v4l2_subdev_mbus_code_enum *code)
{ … }
static int mt9v011_set_fmt(struct v4l2_subdev *sd,
struct v4l2_subdev_state *sd_state,
struct v4l2_subdev_format *format)
{ … }
static int mt9v011_get_frame_interval(struct v4l2_subdev *sd,
struct v4l2_subdev_state *sd_state,
struct v4l2_subdev_frame_interval *ival)
{ … }
static int mt9v011_set_frame_interval(struct v4l2_subdev *sd,
struct v4l2_subdev_state *sd_state,
struct v4l2_subdev_frame_interval *ival)
{ … }
#ifdef CONFIG_VIDEO_ADV_DEBUG
static int mt9v011_g_register(struct v4l2_subdev *sd,
struct v4l2_dbg_register *reg)
{ … }
static int mt9v011_s_register(struct v4l2_subdev *sd,
const struct v4l2_dbg_register *reg)
{ … }
#endif
static int mt9v011_s_ctrl(struct v4l2_ctrl *ctrl)
{ … }
static const struct v4l2_ctrl_ops mt9v011_ctrl_ops = …;
static const struct v4l2_subdev_core_ops mt9v011_core_ops = …;
static const struct v4l2_subdev_pad_ops mt9v011_pad_ops = …;
static const struct v4l2_subdev_ops mt9v011_ops = …;
static int mt9v011_probe(struct i2c_client *c)
{ … }
static void mt9v011_remove(struct i2c_client *c)
{ … }
static const struct i2c_device_id mt9v011_id[] = …;
MODULE_DEVICE_TABLE(i2c, mt9v011_id);
static struct i2c_driver mt9v011_driver = …;
module_i2c_driver(…) …;