162306a36Sopenharmony_ci/* SPDX-License-Identifier: GPL-2.0-only */ 262306a36Sopenharmony_ci/* 362306a36Sopenharmony_ci * Driver for the mt9m111 sensor 462306a36Sopenharmony_ci * 562306a36Sopenharmony_ci * Copyright (C) 2008 Erik Andrén 662306a36Sopenharmony_ci * Copyright (C) 2007 Ilyes Gouta. Based on the m5603x Linux Driver Project. 762306a36Sopenharmony_ci * Copyright (C) 2005 m5603x Linux Driver Project <m5602@x3ng.com.br> 862306a36Sopenharmony_ci * 962306a36Sopenharmony_ci * Portions of code to USB interface and ALi driver software, 1062306a36Sopenharmony_ci * Copyright (c) 2006 Willem Duinker 1162306a36Sopenharmony_ci * v4l2 interface modeled after the V4L2 driver 1262306a36Sopenharmony_ci * for SN9C10x PC Camera Controllers 1362306a36Sopenharmony_ci * 1462306a36Sopenharmony_ci * Some defines taken from the mt9m111 sensor driver 1562306a36Sopenharmony_ci * Copyright (C) 2008, Robert Jarzmik <robert.jarzmik@free.fr> 1662306a36Sopenharmony_ci */ 1762306a36Sopenharmony_ci 1862306a36Sopenharmony_ci#ifndef M5602_MT9M111_H_ 1962306a36Sopenharmony_ci#define M5602_MT9M111_H_ 2062306a36Sopenharmony_ci 2162306a36Sopenharmony_ci#include "m5602_sensor.h" 2262306a36Sopenharmony_ci 2362306a36Sopenharmony_ci/*****************************************************************************/ 2462306a36Sopenharmony_ci 2562306a36Sopenharmony_ci#define MT9M111_SC_CHIPVER 0x00 2662306a36Sopenharmony_ci#define MT9M111_SC_ROWSTART 0x01 2762306a36Sopenharmony_ci#define MT9M111_SC_COLSTART 0x02 2862306a36Sopenharmony_ci#define MT9M111_SC_WINDOW_HEIGHT 0x03 2962306a36Sopenharmony_ci#define MT9M111_SC_WINDOW_WIDTH 0x04 3062306a36Sopenharmony_ci#define MT9M111_SC_HBLANK_CONTEXT_B 0x05 3162306a36Sopenharmony_ci#define MT9M111_SC_VBLANK_CONTEXT_B 0x06 3262306a36Sopenharmony_ci#define MT9M111_SC_HBLANK_CONTEXT_A 0x07 3362306a36Sopenharmony_ci#define MT9M111_SC_VBLANK_CONTEXT_A 0x08 3462306a36Sopenharmony_ci#define MT9M111_SC_SHUTTER_WIDTH 0x09 3562306a36Sopenharmony_ci#define MT9M111_SC_ROW_SPEED 0x0a 3662306a36Sopenharmony_ci#define MT9M111_SC_EXTRA_DELAY 0x0b 3762306a36Sopenharmony_ci#define MT9M111_SC_SHUTTER_DELAY 0x0c 3862306a36Sopenharmony_ci#define MT9M111_SC_RESET 0x0d 3962306a36Sopenharmony_ci#define MT9M111_SC_R_MODE_CONTEXT_B 0x20 4062306a36Sopenharmony_ci#define MT9M111_SC_R_MODE_CONTEXT_A 0x21 4162306a36Sopenharmony_ci#define MT9M111_SC_FLASH_CONTROL 0x23 4262306a36Sopenharmony_ci#define MT9M111_SC_GREEN_1_GAIN 0x2b 4362306a36Sopenharmony_ci#define MT9M111_SC_BLUE_GAIN 0x2c 4462306a36Sopenharmony_ci#define MT9M111_SC_RED_GAIN 0x2d 4562306a36Sopenharmony_ci#define MT9M111_SC_GREEN_2_GAIN 0x2e 4662306a36Sopenharmony_ci#define MT9M111_SC_GLOBAL_GAIN 0x2f 4762306a36Sopenharmony_ci 4862306a36Sopenharmony_ci#define MT9M111_CONTEXT_CONTROL 0xc8 4962306a36Sopenharmony_ci#define MT9M111_PAGE_MAP 0xf0 5062306a36Sopenharmony_ci#define MT9M111_BYTEWISE_ADDRESS 0xf1 5162306a36Sopenharmony_ci 5262306a36Sopenharmony_ci#define MT9M111_CP_OPERATING_MODE_CTL 0x06 5362306a36Sopenharmony_ci#define MT9M111_CP_LUMA_OFFSET 0x34 5462306a36Sopenharmony_ci#define MT9M111_CP_LUMA_CLIP 0x35 5562306a36Sopenharmony_ci#define MT9M111_CP_OUTPUT_FORMAT_CTL2_CONTEXT_A 0x3a 5662306a36Sopenharmony_ci#define MT9M111_CP_LENS_CORRECTION_1 0x3b 5762306a36Sopenharmony_ci#define MT9M111_CP_DEFECT_CORR_CONTEXT_A 0x4c 5862306a36Sopenharmony_ci#define MT9M111_CP_DEFECT_CORR_CONTEXT_B 0x4d 5962306a36Sopenharmony_ci#define MT9M111_CP_OUTPUT_FORMAT_CTL2_CONTEXT_B 0x9b 6062306a36Sopenharmony_ci#define MT9M111_CP_GLOBAL_CLK_CONTROL 0xb3 6162306a36Sopenharmony_ci 6262306a36Sopenharmony_ci#define MT9M111_CC_AUTO_EXPOSURE_PARAMETER_18 0x65 6362306a36Sopenharmony_ci#define MT9M111_CC_AWB_PARAMETER_7 0x28 6462306a36Sopenharmony_ci 6562306a36Sopenharmony_ci#define MT9M111_SENSOR_CORE 0x00 6662306a36Sopenharmony_ci#define MT9M111_COLORPIPE 0x01 6762306a36Sopenharmony_ci#define MT9M111_CAMERA_CONTROL 0x02 6862306a36Sopenharmony_ci 6962306a36Sopenharmony_ci#define MT9M111_RESET (1 << 0) 7062306a36Sopenharmony_ci#define MT9M111_RESTART (1 << 1) 7162306a36Sopenharmony_ci#define MT9M111_ANALOG_STANDBY (1 << 2) 7262306a36Sopenharmony_ci#define MT9M111_CHIP_ENABLE (1 << 3) 7362306a36Sopenharmony_ci#define MT9M111_CHIP_DISABLE (0 << 3) 7462306a36Sopenharmony_ci#define MT9M111_OUTPUT_DISABLE (1 << 4) 7562306a36Sopenharmony_ci#define MT9M111_SHOW_BAD_FRAMES (1 << 0) 7662306a36Sopenharmony_ci#define MT9M111_RESTART_BAD_FRAMES (1 << 1) 7762306a36Sopenharmony_ci#define MT9M111_SYNCHRONIZE_CHANGES (1 << 7) 7862306a36Sopenharmony_ci 7962306a36Sopenharmony_ci#define MT9M111_RMB_OVER_SIZED (1 << 0) 8062306a36Sopenharmony_ci#define MT9M111_RMB_MIRROR_ROWS (1 << 0) 8162306a36Sopenharmony_ci#define MT9M111_RMB_MIRROR_COLS (1 << 1) 8262306a36Sopenharmony_ci#define MT9M111_RMB_ROW_SKIP_2X (1 << 2) 8362306a36Sopenharmony_ci#define MT9M111_RMB_COLUMN_SKIP_2X (1 << 3) 8462306a36Sopenharmony_ci#define MT9M111_RMB_ROW_SKIP_4X (1 << 4) 8562306a36Sopenharmony_ci#define MT9M111_RMB_COLUMN_SKIP_4X (1 << 5) 8662306a36Sopenharmony_ci 8762306a36Sopenharmony_ci#define MT9M111_COLOR_MATRIX_BYPASS (1 << 4) 8862306a36Sopenharmony_ci#define MT9M111_SEL_CONTEXT_B (1 << 3) 8962306a36Sopenharmony_ci 9062306a36Sopenharmony_ci#define MT9M111_TRISTATE_PIN_IN_STANDBY (1 << 1) 9162306a36Sopenharmony_ci#define MT9M111_SOC_SOFT_STANDBY (1 << 0) 9262306a36Sopenharmony_ci 9362306a36Sopenharmony_ci#define MT9M111_2D_DEFECT_CORRECTION_ENABLE (1 << 0) 9462306a36Sopenharmony_ci 9562306a36Sopenharmony_ci#define INITIAL_MAX_GAIN 64 9662306a36Sopenharmony_ci#define MT9M111_DEFAULT_GAIN 283 9762306a36Sopenharmony_ci#define MT9M111_GREEN_GAIN_DEFAULT 0x20 9862306a36Sopenharmony_ci#define MT9M111_BLUE_GAIN_DEFAULT 0x20 9962306a36Sopenharmony_ci#define MT9M111_RED_GAIN_DEFAULT 0x20 10062306a36Sopenharmony_ci 10162306a36Sopenharmony_ci/*****************************************************************************/ 10262306a36Sopenharmony_ci 10362306a36Sopenharmony_ci/* Kernel module parameters */ 10462306a36Sopenharmony_ciextern int force_sensor; 10562306a36Sopenharmony_ciextern bool dump_sensor; 10662306a36Sopenharmony_ci 10762306a36Sopenharmony_ciint mt9m111_probe(struct sd *sd); 10862306a36Sopenharmony_ciint mt9m111_init(struct sd *sd); 10962306a36Sopenharmony_ciint mt9m111_init_controls(struct sd *sd); 11062306a36Sopenharmony_ciint mt9m111_start(struct sd *sd); 11162306a36Sopenharmony_civoid mt9m111_disconnect(struct sd *sd); 11262306a36Sopenharmony_ci 11362306a36Sopenharmony_cistatic const struct m5602_sensor mt9m111 = { 11462306a36Sopenharmony_ci .name = "MT9M111", 11562306a36Sopenharmony_ci 11662306a36Sopenharmony_ci .i2c_slave_id = 0xba, 11762306a36Sopenharmony_ci .i2c_regW = 2, 11862306a36Sopenharmony_ci 11962306a36Sopenharmony_ci .probe = mt9m111_probe, 12062306a36Sopenharmony_ci .init = mt9m111_init, 12162306a36Sopenharmony_ci .init_controls = mt9m111_init_controls, 12262306a36Sopenharmony_ci .disconnect = mt9m111_disconnect, 12362306a36Sopenharmony_ci .start = mt9m111_start, 12462306a36Sopenharmony_ci}; 12562306a36Sopenharmony_ci#endif 126