Home | History | Annotate | Download | only in linux
      1 /*
      2  *  Copyright (c) 2007, 2008 HTC, Inc
      3  *   All rights reserved.
      4  *
      5  *   Redistribution and use in source and binary forms, with or without modification,
      6  *   are permitted provided that the following conditions are met:
      7  *
      8  *   Redistributions of source code must retain the above copyright notice, this list
      9  *   of conditions and the following disclaimer.
     10  *   Redistributions in binary form must reproduce the above copyright notice, this
     11  *   list of conditions and the following disclaimer in the documentation and/or other
     12  *   materials provided with the distribution.
     13  *   Neither the name of the HTC,Inc nor the names of its contributors may be used
     14  *   to endorse or promote products derived from this software without specific prior
     15  *   written permission.
     16  *
     17  *   THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
     18  *   "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
     19  *   TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
     20  *   PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
     21  *   CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
     22  *   EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
     23  *   PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;LOSS OF USE, DATA, OR
     24  *   PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
     25  *   OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,OR TORT
     26  *   (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
     27  *   OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH
     28  *   DAMAGE
     29  */
     30 
     31 #ifndef CAMERA_MT9T013_H
     32 #define CAMERA_MT9T013_H
     33 #include <linux/cdev.h>
     34 #include <linux/types.h>
     35 #include <linux/ioctl.h>
     36 #include <asm/sizes.h>
     37 
     38 /*************************************************************
     39 *	IOCTL define
     40 *************************************************************/
     41 
     42 #define MT9T013_I2C_IOCTL_MAGIC 'm'
     43 
     44 #define MT9T013_I2C_IOCTL_W \
     45 	        _IOW(MT9T013_I2C_IOCTL_MAGIC, 0, unsigned)
     46 
     47 #define MT9T013_I2C_IOCTL_R \
     48 	        _IOR(MT9T013_I2C_IOCTL_MAGIC, 1, unsigned)
     49 
     50 #define MT9T013_I2C_IOCTL_AF_W \
     51 	        _IOW(MT9T013_I2C_IOCTL_MAGIC, 2, unsigned)
     52 
     53 #define MT9T013_I2C_IOCTL_CAMIF_PAD_REG_RESET \
     54 	_IO(MT9T013_I2C_IOCTL_MAGIC, 3)
     55 
     56 #define MT9T013_I2C_IOCTL_CAMIF_PAD_REG_RESET_2 \
     57 	_IO(MT9T013_I2C_IOCTL_MAGIC, 4)
     58 
     59 #define CAMERA_CONFIGURE_GPIOS \
     60 	_IO(MT9T013_I2C_IOCTL_MAGIC, 7)
     61 
     62 #define CAMERA_UNCONFIGURE_GPIOS \
     63 	_IO(MT9T013_I2C_IOCTL_MAGIC, 8)
     64 
     65 #define CAMERA_LENS_POWER_ON \
     66 	_IO(MT9T013_I2C_IOCTL_MAGIC, 9)
     67 
     68 #define CAMERA_LENS_POWER_OFF \
     69 	_IO(MT9T013_I2C_IOCTL_MAGIC, 10)
     70 
     71 #define MT9T013_I2C_IOCTL_CAMIF_APPS_RESET \
     72 	_IO(MT9T013_I2C_IOCTL_MAGIC, 11)
     73 
     74 /* Replacement ioctls() for the clkrgm_sec RPCs. */
     75 
     76 #define CAMIO_VFE_MDC_CLK 1 /* enable, disable */
     77 #define CAMIO_MDC_CLK     2 /* enable, disable */
     78 #define CAMIO_VFE_CLK     3 /* clk_select, freq_prog */
     79 
     80 #define MT9T013_I2C_IOCTL_CLK_ENABLE \
     81 	_IOW(MT9T013_I2C_IOCTL_MAGIC, 12, unsigned)
     82 
     83 #define MT9T013_I2C_IOCTL_CLK_DISABLE \
     84 	_IOW(MT9T013_I2C_IOCTL_MAGIC, 13, unsigned)
     85 
     86 #define MT9T013_I2C_IOCTL_CLK_SELECT \
     87 	_IOW(MT9T013_I2C_IOCTL_MAGIC, 14, unsigned)
     88 
     89 #define MT9T013_I2C_IOCTL_CLK_FREQ_PROG \
     90 	_IOW(MT9T013_I2C_IOCTL_MAGIC, 15, unsigned)
     91 
     92 #define CAMSENSOR_REG_INIT		0<<0
     93 #define CAMSENSOR_REG_UPDATE_PERIODIC 	1<<0
     94 #define CAMSENSOR_TYPE_PREVIEW          0<<1
     95 #define CAMSENSOR_TYPE_SNAPSHOT		1<<1
     96 
     97 #define MT9T013_I2C_IOCTL_SENSOR_SETTING \
     98 	_IOW(MT9T013_I2C_IOCTL_MAGIC, 16, uint32_t)
     99 
    100 struct mt9t013_reg_struct
    101 {
    102 	uint16_t vt_pix_clk_div;            /* 0x0300 */
    103 	uint16_t vt_sys_clk_div;            /* 0x0302 */
    104 	uint16_t pre_pll_clk_div;           /* 0x0304 */
    105 	uint16_t pll_multiplier;            /* 0x0306 */
    106 	uint16_t op_pix_clk_div;            /* 0x0308 */
    107 	uint16_t op_sys_clk_div;            /* 0x030A */
    108 	uint16_t scale_m;                   /* 0x0404 */
    109 	uint16_t row_speed;                 /* 0x3016 */
    110 	uint16_t x_addr_start;              /* 0x3004 */
    111 	uint16_t x_addr_end;                /* 0x3008 */
    112 	uint16_t y_addr_start;              /* 0x3002 */
    113 	uint16_t y_addr_end;                /* 0x3006 */
    114 	uint16_t read_mode;                 /* 0x3040 */
    115 	uint16_t x_output_size ;            /* 0x034C */
    116 	uint16_t y_output_size;             /* 0x034E */
    117 	uint16_t line_length_pck;           /* 0x300C */
    118 	uint16_t frame_length_lines;        /* 0x300A */
    119 	uint16_t coarse_integration_time;   /* 0x3012 */
    120 	uint16_t fine_integration_time;     /* 0x3014 */
    121 };
    122 
    123 struct mt9t013_reg_pat {
    124 	struct mt9t013_reg_struct reg[2];
    125 };
    126 
    127 #define MT9T013_I2C_IOCTL_GET_REGISTERS \
    128 	_IOR(MT9T013_I2C_IOCTL_MAGIC, 17, struct mt9t013_reg_pat *)
    129 
    130 struct mt9t013_exposure_gain {
    131 	uint16_t gain;
    132 	uint16_t line;
    133         uint32_t mode;
    134 };
    135 
    136 #define MT9T013_I2C_IOCTL_EXPOSURE_GAIN \
    137 	_IOW(MT9T013_I2C_IOCTL_MAGIC, 18, struct exposure_gain *)
    138 
    139 #define MT9T013_I2C_IOCTL_MOVE_FOCUS \
    140 	_IOW(MT9T013_I2C_IOCTL_MAGIC, 19, uint32_t)
    141 
    142 #define MT9T013_I2C_IOCTL_SET_DEFAULT_FOCUS \
    143 	_IOW(MT9T013_I2C_IOCTL_MAGIC, 20, uint32_t)
    144 
    145 #define MT9T013_I2C_IOCTL_POWER_DOWN \
    146 	_IO(MT9T013_I2C_IOCTL_MAGIC, 21)
    147 
    148 struct mt9t013_init {
    149 	int preview; /* in: 1 for preview, 0 for capture */
    150 	uint16_t chipid; /* out: chip id */
    151 };
    152 
    153 #define MT9T013_I2C_IOCTL_INIT \
    154 	_IOWR(MT9T013_I2C_IOCTL_MAGIC, 22, struct mt9t013_init *)
    155 
    156 #endif
    157 
    158