max9286 get signal status

max9286

frame sync

帧同步模式分内同步、外同步两类;内同步又有手动、半自动、自动三种,半自动、自动时FSYNC PERDIV设置帧同步周期,每检测到多少个VSYNC后发送帧同步,半自动模式检测master那一路,自动模式时检测VSYNC最慢达到的那一路。

Internal Frame Sync (FSYNCMODE = 0X)

External Frame Sync (FSYNCMODE = 1X)

mode

FSYNCMODEdefault
00Internally generate frame sync, FSYNC/GPI is high impedance00
01Internally generate frame sync, FSYNC/GPI outputs frame sync
10Receive external frame sync from another MAX9286. FSYNC/
GPI is external frame sync input
11Receive external frame sync from ECU. FSYNC/GPI is a
general-purpose input

method 

FSYNCMETHwhen FSYNCMODE = 0Xdefault
00Internal frame sync uses manual mode
01Internal frames sync uses semi-automatic mode
1xInternal frame sync uses automatic mode10

log

grep "status change into" *.log
grep -E "CameraSourceProgress workingThread|CameraSourceProgress1Ch workingThread" *.log

 I2C

[    0.553150](2)[1:swapper/0][I2C]id: 0,freq:400000,div:5,ch_offset:0x0,offset_dma:0x0,offset_ccu:0x0
[    0.553776](2)[1:swapper/0][I2C]id: 1,freq:100000,div:5,ch_offset:0x0,offset_dma:0x0,offset_ccu:0x0
[    0.555925](2)[1:swapper/0][I2C]id: 2,freq:400000,div:5,ch_offset:0x100,offset_dma:0x0,offset_ccu:0x200
[    0.556971](2)[1:swapper/0][I2C]id: 3,freq:100000,div:5,ch_offset:0x100,offset_dma:0x0,offset_ccu:0x0
[    0.557453](2)[1:swapper/0][I2C]id: 4,freq:400000,div:5,ch_offset:0x100,offset_dma:0x0,offset_ccu:0x200
[    0.557740](2)[1:swapper/0][I2C]id: 5,freq:400000,div:5,ch_offset:0x0,offset_dma:0x0,offset_ccu:0x0
[    0.558477](2)[1:swapper/0][I2C]id: 6,freq:400000,div:5,ch_offset:0x100,offset_dma:0x0,offset_ccu:0x200

SIGNAL

kernel-4.9ICameraStream
0SIGNAL_IDLESIGNAL_STATUS_NONE0
1SIGNAL_LOSTMIPIVC_SIGNAL_LOSTSIGNAL_STATUS_LOST2
2SIGNAL_READYMIPIVC_SIGNAL_READYSIGNAL_STATUS_READY1

drivers/misc/mediatek/imgsensor/inc/kd_imgsensor_define.h

  85 typedef enum {
  86     SIGNAL_IDLE,
  87     SIGNAL_LOST,
  88     SIGNAL_READY,
  89     SIGNAL_STABLE,
  90     SIGNAL_MAX
  91 } SIGNAL_STATUS;

SIGNAL_STATUS

vendor/autochips/proprietary/hardware/videoin 

ICameraStream

interface/camerasource/include/ICameraSource.h

 70 class ICameraStream
 71 {
 72 public:
 73     typedef enum
 74     {
 75         SIGNAL_STATUS_NONE = 0,
 76         SIGNAL_STATUS_READY,
 77         SIGNAL_STATUS_LOST,
 78         SIGNAL_STATUS_MAX,
 79     } SIGNAL_STATUS_ENUM;

MIPIVC_SIGNAL

libs/camerasource/inc/CameraSourceBase.h 

 52 #define MIPIVC_SIGNAL_LOST (1)
 53 #define MIPIVC_SIGNAL_READY (2)

onEvent

215         if(isFirstGetStatus || _info.signalStatus != signalStatus) {
216             switch(_info.signalStatus) {
217             case MIPIVC_SIGNAL_LOST:
218                 mCurStatus = ICameraStream::SIGNAL_STATUS_LOST;
219                 break;
220
221             case MIPIVC_SIGNAL_READY:
222                 mCurStatus = ICameraStream::SIGNAL_STATUS_READY;
223                 break;
224
225             default:
226                 mCurStatus = ICameraStream::SIGNAL_STATUS_NONE;
227                 _LOGW("mipivcInst->getSensorInfo get invalid signalStatus : %d", _info.signalStatus);
228                 break;
229             }
230
231             if(mCallback) {
232                 mCallback->onEvent(IEventCallback::CAM_SIGNAL_CHANGED, camCh, mCurStatus);
233             }
234
235             signalStatus = _info.signalStatus;
236             isFirstGetStatus = false;
237             _LOGI("camera ch(%d) status change into %d", camCh, mCurStatus);
238         }

max9286_yuv_sensor.c

drivers/misc/mediatek/imgsensor/src/common/v1/max9286_yuv/max9286_yuv_sensor.c

i2c_speed

71 static int max9286_i2c_speed = 400;

max9671_read

120 static kal_uint16 max96701_read(int index, kal_uint32 addr)
121 {
122     kal_uint16 get_byte = 0;
123
124     char pu_send_cmd[1] = { (char)(addr & 0xFF) };
125
126     iReadRegI2C(pu_send_cmd, 1, (u8 *) &get_byte, 1, max96701_i2c_write_id+(index<<1));
127
128     return get_byte;
129 }
130
131 static int max96701_write(int index, kal_uint32 addr, kal_uint32 para)
132 {
133     char pu_send_cmd[2] = { (char)(addr & 0xFF), (char)(para & 0xFF) };
134
135     return iWriteRegI2CTiming(
136         pu_send_cmd, 2, max96701_i2c_write_id+(index<<1), max9286_i2c_speed);
137 }

max9286_read

139 static kal_uint16 max9286_read(kal_uint32 addr)
140 {
141     kal_uint16 get_byte = 0;
142
143     char pu_send_cmd[1] = { (char)(addr & 0xFF) };
144
145     iReadRegI2C(pu_send_cmd, 1, (u8 *) &get_byte, 1, max9286_i2c_write_id);
146
147     return get_byte;
148 }
149
150 static int max9286_write(kal_uint32 addr, kal_uint32 para)
151 {
152     char pu_send_cmd[2] = { (char)(addr & 0xFF), (char)(para & 0xFF) };
153
154     return iWriteRegI2CTiming(
155         pu_send_cmd, 2, max9286_i2c_write_id, max9286_i2c_speed);
156 }

max9286_get_signalstatus

411 SIGNAL_STATUS max9286_get_signalstatus(int cha)
412 {
413     int value = 0xff;
414     SIGNAL_STATUS signal_status = SIGNAL_IDLE;
415
416     value = max9286_read(MAX9286_REG_VSYNCDET);
417     if (value & (1<<cha))
418     {
419         signal_status = SIGNAL_READY;
420     }
421     else
422     {
423         signal_lost_cnt++;
424         if (4 < signal_lost_cnt) {
425             signal_status = SIGNAL_LOST;
426         }
427     }
428
429     //LOG_INF("get signal status leave and current cha is %d,signal status is %d,value = 0x%x\n",cha,signal_status,value);
430
431     return signal_status;
432 }

n4_yuv_sensor.c

n4_get_signalstatus

3081 SIGNAL_STATUS n4_get_signalstatus(int ch)
3082 {
3083     int value = 0xff;
3084     SIGNAL_STATUS signal_status = SIGNAL_IDLE;
3085
3086     n4_write_cmos_sensor(0xff, 0x00);
3087     value = n4_read_cmos_sensor(0xa0);
3088     value = 0;
3089     if ((value & (0x01 << ch)) == 0x00 )
3090     {
3091         signal_status = SIGNAL_READY;
3092     }
3093     else
3094     {
3095         signal_lost_cnt++;
3096         if (4 < signal_lost_cnt) {
3097             signal_status = SIGNAL_LOST;
3098         }
3099     }
3100
3101     //LOG_INF("get signal status leave and current ch is %d,signal status is %d,value = 0x%x\n",ch,signal_status,value);
3102
3103     return signal_status;
3104
3105 }

imgsensor_legacy.c

drivers/misc/mediatek/imgsensor/src/common/v1/imgsensor_legacy.c

iReadRegI2C

 23 int iReadRegI2C(
 24     u8 *a_pSendData,
 25     u16 a_sizeSendData,
 26     u8 *a_pRecvData,
 27     u16 a_sizeRecvData,
 28     u16 i2cId)
 29 {
 30     return imgsensor_i2c_read(
 31         pgi2c_cfg_legacy,
 32         a_pSendData,
 33         a_sizeSendData,
 34         a_pRecvData,
 35         a_sizeRecvData,
 36         i2cId,
 37         IMGSENSOR_I2C_SPEED);
 38 }

iWriteRegI2CTiming

 69 int iWriteRegI2CTiming(
 70     u8 *a_pSendData,
 71     u16 a_sizeSendData,
 72     u16 i2cId,
 73     u16 timing)
 74 {
 75     return imgsensor_i2c_write(
 76         pgi2c_cfg_legacy,
 77         a_pSendData,
 78         a_sizeSendData,
 79         a_sizeSendData,
 80         i2cId,
 81         timing);
 82 }

imgsensor_i2c.c

drivers/misc/mediatek/imgsensor/src/common/v1/imgsensor_i2c.c

imgsensor_i2c_read

160 enum IMGSENSOR_RETURN imgsensor_i2c_read(
161     struct IMGSENSOR_I2C_CFG *pi2c_cfg,
162     u8 *pwrite_data,
163     u16 write_length,
164     u8 *pread_data,
165     u16 read_length,
166     u16 id,
167     int speed)
168 {
169     struct IMGSENSOR_I2C_INST *pinst = pi2c_cfg->pinst;
170     enum   IMGSENSOR_RETURN    ret   = IMGSENSOR_RETURN_SUCCESS;
171
172     mutex_lock(&pi2c_cfg->i2c_mutex);
173
174     pinst->msg[0].addr  = id >> 1;
175     pinst->msg[0].flags = 0;
176     pinst->msg[0].len   = write_length;
177     pinst->msg[0].buf   = pwrite_data;
178
179     pinst->msg[1].addr  = id >> 1;
180     pinst->msg[1].flags = I2C_M_RD;
181     pinst->msg[1].len   = read_length;
182     pinst->msg[1].buf   = pread_data;
183
184     if (mtk_i2c_transfer(
185         pinst->pi2c_client->adapter,
186         pinst->msg,
187         IMGSENSOR_I2C_MSG_SIZE_READ,
188         (pi2c_cfg->pinst->status.filter_msg) ? I2C_A_FILTER_MSG : 0,
189         ((speed > 0) && (speed <= 1000))
190           ? speed * 1000 : IMGSENSOR_I2C_SPEED * 1000)
191         != IMGSENSOR_I2C_MSG_SIZE_READ) {
192
193         static DEFINE_RATELIMIT_STATE(ratelimit, 1 * HZ, 30);
194
195         if (__ratelimit(&ratelimit))
196             pr_err(
197                 "I2C read failed (0x%x)! speed(0=%d) (0x%x)\n",
198                 ret,
199                 speed,
200                 *pwrite_data);
201
202         ret = IMGSENSOR_RETURN_ERROR;
203     }
204
205     mutex_unlock(&pi2c_cfg->i2c_mutex);
206
207     return ret;
208 }

 imgsensor_i2c_write

210 enum IMGSENSOR_RETURN imgsensor_i2c_write(
211     struct IMGSENSOR_I2C_CFG *pi2c_cfg,
212     u8 *pwrite_data,
213     u16 write_length,
214     u16 write_per_cycle,
215     u16 id,
216     int speed)
217 {
218     struct IMGSENSOR_I2C_INST *pinst = pi2c_cfg->pinst;
219     enum   IMGSENSOR_RETURN    ret   = IMGSENSOR_RETURN_SUCCESS;
220     struct i2c_msg     *pmsg  = pinst->msg;
221     u8                 *pdata = pwrite_data;
222     u8                 *pend  = pwrite_data + write_length;
223     int i   = 0;
224
225     mutex_lock(&pi2c_cfg->i2c_mutex);
226
227     while (pdata < pend && i < IMGSENSOR_I2C_CMD_LENGTH_MAX) {
228         pmsg->addr  = id >> 1;
229         pmsg->flags = 0;
230         pmsg->len   = write_per_cycle;
231         pmsg->buf   = pdata;
232
233         i++;
234         pmsg++;
235         pdata += write_per_cycle;
236     }
237
238     if (mtk_i2c_transfer(
239         pinst->pi2c_client->adapter,
240         pinst->msg,
241         i,
242         (pi2c_cfg->pinst->status.filter_msg) ? I2C_A_FILTER_MSG : 0,
243         ((speed > 0) && (speed <= 1000))
244           ? speed * 1000 : IMGSENSOR_I2C_SPEED * 1000)
245         != i) {
246
247         static DEFINE_RATELIMIT_STATE(ratelimit, 1 * HZ, 30);
248
249         if (__ratelimit(&ratelimit))
250             pr_err(
251                 "I2C write failed (0x%x)! speed(0=%d) (0x%x)\n",
252                 ret,
253                 speed,
254                 *pwrite_data);
255
256         ret = IMGSENSOR_RETURN_ERROR;
257     }
258
259     mutex_unlock(&pi2c_cfg->i2c_mutex);
260
261     return ret;
262 }

imgsensor_i2c_set_device 

269 #ifdef IMGSENSOR_LEGACY_COMPAT
270 struct IMGSENSOR_I2C_CFG *pgi2c_cfg_legacy;
271 void imgsensor_i2c_set_device(struct IMGSENSOR_I2C_CFG *pi2c_cfg)
272 {
273     pgi2c_cfg_legacy = pi2c_cfg;
274 }
275 #endif

i2c-mtk.c

drivers/i2c/busses/i2c-mtk.c

mtk_i2c_transfer

1459 int mtk_i2c_transfer(struct i2c_adapter *adap, struct i2c_msg *msgs, int num,
1460                     u32 ext_flag, u32 timing)
1461 {
1462     int ret;
1463     struct mt_i2c *i2c = i2c_get_adapdata(adap);
1464
1465     if (i2c->multiplexing) {
1466         /* Once AP use i2c to transfer, It means bus belongs AP.*/
1467         i2c->multiplexing = 0;
1468         mt_i2c_init_hw(i2c);
1469     }
1470
1471     ret = mt_i2c_clock_enable(i2c);
1472     if (ret)
1473         return -EBUSY;
1474
1475     mutex_lock(&i2c->i2c_mutex);
1476     i2c->ext_data.isEnable = true;
1477
1478     mt_i2c_parse_extension(&i2c->ext_data, ext_flag, timing);
1479     ret = __mt_i2c_transfer(i2c, msgs, num);
1480
1481     i2c->ext_data.isEnable = false;
1482     mutex_unlock(&i2c->i2c_mutex);
1483
1484     mt_i2c_clock_disable(i2c);
1485     return ret;
1486 }
1487 EXPORT_SYMBOL(mtk_i2c_transfer);

mt_i2c_parse_extension

1450 static void mt_i2c_parse_extension(struct mt_i2c_ext *pext, u32 ext_flag,
1451                             u32 timing)
1452 {
1453     if (ext_flag & I2C_A_FILTER_MSG)
1454         pext->isFilterMsg = true;
1455     if (timing)
1456         pext->timing = timing;
1457 }

mt_i2c_do_transfer

 854 static int mt_i2c_do_transfer(struct mt_i2c *i2c)
 855 {
 856     u16 addr_reg = 0;
 857     u16 control_reg = 0;
 858     u16 ioconfig_reg = 0;
 859     u16 start_reg = 0;
 860     u16 int_reg = 0;
 861     int tmo = i2c->adap.timeout;
 862     unsigned int speed_hz = 0;
 863     bool isDMA = false;
 864     int data_size = 0;
 865     u8 *ptr;
 866     int ret = 0;
 867     /* u16 ch_offset; */
 868
 869     i2c->trans_stop = false;
 870     i2c->irq_stat = 0;
 871     if (i2c->total_len > 8 || i2c->msg_aux_len > 8)
 872         isDMA = true;
 873     if (i2c->ext_data.isEnable && i2c->ext_data.timing)
 874         speed_hz = i2c->ext_data.timing;
 875     else
 876         speed_hz = i2c->speed_hz;
 877     if (i2c->ext_data.is_ch_offset) {
 878         i2c->ch_offset = i2c->ext_data.ch_offset;
 879         i2c->ch_offset_dma = i2c->ext_data.ch_offset_dma;
 880         if (i2c->ext_data.ch_offset == 0) {
 881             dev_info(i2c->dev, "Wrong channel offset for multi-channel\n");
 882             i2c->ch_offset = i2c->ccu_offset;
 883         }
 884     } else {
 885         i2c->ch_offset = i2c->ch_offset_default;
 886         i2c->ch_offset_dma = i2c->ch_offset_dma_default;
 887     }
 888
 889 #if !defined(CONFIG_MT_I2C_FPGA_ENABLE)
 890     ret = i2c_set_speed(i2c,
 891         clk_get_rate(i2c->clk_main) / i2c->clk_src_div);
 892 #else
 893     ret = i2c_set_speed(i2c, I2C_CLK_RATE);
 894 #endif
 895     if (ret) {
 896         dev_info(i2c->dev, "Failed to set the speed\n");
 897         return -EINVAL;
 898     }

imgsensor_i2c.h

drivers/misc/mediatek/imgsensor/src/common/v1/imgsensor_i2c.h

 31 #ifdef IMGSENSOR_I2C_1000K
 32 #define IMGSENSOR_I2C_SPEED              1000
 33 #else
 34 #define IMGSENSOR_I2C_SPEED              400
 35 #endif

imgsensor_common.h 

drivers/misc/mediatek/imgsensor/src/common/v1/imgsensor_common.h

 41 enum IMGSENSOR_RETURN {
 42     IMGSENSOR_RETURN_SUCCESS = 0,
 43     IMGSENSOR_RETURN_ERROR   = -1,
 44 };

imgsensor.c

imgsensor_mutex_lock

 139 static void imgsensor_mutex_lock(struct IMGSENSOR_SENSOR_INST *psensor_inst)
 140 {
 141 #ifdef IMGSENSOR_LEGACY_COMPAT
 142     if (psensor_inst->status.arch) {
 143         mutex_lock(&psensor_inst->sensor_mutex);
 144     } else {
 145         mutex_lock(&gimgsensor_mutex);
 146         imgsensor_i2c_set_device(&psensor_inst->i2c_cfg);
 147     }
 148 #else
 149     mutex_lock(&psensor_inst->sensor_mutex);
 150 #endif
 151 }

imgsensor_sensor_open

 165 MINT32
 166 imgsensor_sensor_open(struct IMGSENSOR_SENSOR *psensor)
 167 {
 168     MINT32 ret = ERROR_NONE;
 169     struct IMGSENSOR_SENSOR_INST *psensor_inst = &psensor->inst;
 170     struct SENSOR_FUNCTION_STRUCT *psensor_func =  psensor->pfunc;
 171
 172 #ifdef CONFIG_MTK_CCU
 173     struct ccu_sensor_info ccuSensorInfo;
 174     enum IMGSENSOR_SENSOR_IDX sensor_idx = psensor->inst.sensor_idx;
 175 #endif
 176
 177     IMGSENSOR_FUNCTION_ENTRY();
 178
 179     if (psensor_func &&
 180         psensor_func->SensorOpen &&
 181         psensor_inst) {
 182
 183         /* turn on power */
 184         IMGSENSOR_PROFILE_INIT(&psensor_inst->profile_time);
 185         if (pgimgsensor->imgsensor_oc_irq_enable != NULL)
 186             pgimgsensor->imgsensor_oc_irq_enable(
 187                     psensor->inst.sensor_idx, false);
 188
 189         ret = imgsensor_hw_power(&pgimgsensor->hw,
 190             psensor,
 191             psensor_inst->psensor_name,
 192             IMGSENSOR_HW_POWER_STATUS_ON);
 193
 194         if (ret != IMGSENSOR_RETURN_SUCCESS) {
 195             pr_err("[%s]", __func__);
 196             return -EIO;
 197         }
 198         /* wait for power stable */
 199         mDELAY(5);
 200
 201         IMGSENSOR_PROFILE(&psensor_inst->profile_time,
 202             "kdCISModulePowerOn");
 203
 204         imgsensor_mutex_lock(psensor_inst);
 205
 206         psensor_func->psensor_inst = psensor_inst;
 207         ret = psensor_func->SensorOpen();
 208         if (ret != ERROR_NONE) {
 209             imgsensor_hw_power(&pgimgsensor->hw,
 210                 psensor,
 211                 psensor_inst->psensor_name,
 212                 IMGSENSOR_HW_POWER_STATUS_OFF);
 213             pr_err("SensorOpen fail");
 214         } else {
 215             psensor_inst->state = IMGSENSOR_STATE_OPEN;
 216 #ifdef CONFIG_MTK_CCU
 217             ccuSensorInfo.slave_addr =
 218                 (psensor_inst->i2c_cfg.pinst->msg->addr << 1);
 219
 220             ccuSensorInfo.sensor_name_string =
 221                 (char *)(psensor_inst->psensor_name);
 222
 223             ccu_set_sensor_info(sensor_idx, &ccuSensorInfo);
 224 #endif
 225             if (pgimgsensor->imgsensor_oc_irq_enable != NULL)
 226                 pgimgsensor->imgsensor_oc_irq_enable(
 227                         psensor->inst.sensor_idx, true);
 228
 229         }
 230
 231         imgsensor_mutex_unlock(psensor_inst);
 232
 233         IMGSENSOR_PROFILE(&psensor_inst->profile_time, "SensorOpen");
 234     }
 235
 236     IMGSENSOR_FUNCTION_EXIT();
 237
 238     return ret ? -EIO : ret;
 239 }

imgsensor_hw_power

drivers/misc/mediatek/imgsensor/src/common/v1/imgsensor_hw.c

238     pr_info(
239         "sensor_idx %d, power %d curr_sensor_name %s\n",
240         sensor_idx,
241         pwr_status,
242         curr_sensor_name);
243
244     imgsensor_hw_power_sequence(
245         phw,
246         sensor_idx,
247         pwr_status,
248         platform_power_sequence,
249         imgsensor_sensor_idx_name[sensor_idx]);
250
251     imgsensor_hw_power_sequence(
252         phw,
253         sensor_idx,
254         pwr_status,
255         sensor_power_sequence,
256         curr_sensor_name);

imgsensor_hw_power_sequence

上电:设置管脚为ON状态,等待。下电:等待,设置管脚为OFF状态。

 84 static enum IMGSENSOR_RETURN imgsensor_hw_power_sequence(
 85     struct IMGSENSOR_HW             *phw,
 86     enum   IMGSENSOR_SENSOR_IDX      sensor_idx,
 87     enum   IMGSENSOR_HW_POWER_STATUS pwr_status,
 88     struct IMGSENSOR_HW_POWER_SEQ   *ppower_sequence,
 89     char *pcurr_idx)
 90 {
 91     struct IMGSENSOR_HW_SENSOR_POWER *psensor_pwr =
 92         &phw->sensor_pwr[sensor_idx];
 93
 94     struct IMGSENSOR_HW_POWER_SEQ    *ppwr_seq = ppower_sequence;
 95     struct IMGSENSOR_HW_POWER_INFO   *ppwr_info;
 96     struct IMGSENSOR_HW_DEVICE       *pdev;
 97     int                               pin_cnt = 0;
 98
 99     while (ppwr_seq->idx != NULL &&
100         ppwr_seq < ppower_sequence + IMGSENSOR_HW_SENSOR_MAX_NUM &&
101         strcmp(ppwr_seq->idx, pcurr_idx)) {
102         ppwr_seq++;
103     }
104
105     if (ppwr_seq->idx == NULL)
106         return IMGSENSOR_RETURN_ERROR;
107
108     ppwr_info = ppwr_seq->pwr_info;
109
110     while (ppwr_info->pin != IMGSENSOR_HW_PIN_NONE &&
111         ppwr_info < ppwr_seq->pwr_info + IMGSENSOR_HW_POWER_INFO_MAX) {
112
113         if (pwr_status == IMGSENSOR_HW_POWER_STATUS_ON &&
114            ppwr_info->pin != IMGSENSOR_HW_PIN_UNDEF) {
115             pdev = phw->pdev[psensor_pwr->id[ppwr_info->pin]];
116         /*pr_debug(
117          *  "sensor_idx = %d, pin=%d, pin_state_on=%d, hw_id =%d\n",
118          *  sensor_idx,
119          *  ppwr_info->pin,
120          *  ppwr_info->pin_state_on,
121          * psensor_pwr->id[ppwr_info->pin]);
122          */
123
124             if (pdev->set != NULL)
125                 pdev->set(
126                     pdev->pinstance,
127                     sensor_idx,
128                     ppwr_info->pin,
129                     ppwr_info->pin_state_on);
130
131             mdelay(ppwr_info->pin_on_delay);
132         }
133
134         ppwr_info++;
135         pin_cnt++;
136     }
137
138     if (pwr_status == IMGSENSOR_HW_POWER_STATUS_OFF) {
139         while (pin_cnt) {
140             ppwr_info--;
141             pin_cnt--;
142
143             if (ppwr_info->pin != IMGSENSOR_HW_PIN_UNDEF) {
144                 pdev =
145                     phw->pdev[psensor_pwr->id[ppwr_info->pin]];
146                 mdelay(ppwr_info->pin_on_delay);
147
148                 if (pdev->set != NULL)
149                     pdev->set(
150                         pdev->pinstance,
151                         sensor_idx,
152                         ppwr_info->pin,
153                         ppwr_info->pin_state_off);
154             }
155         }
156     }
157
158     /* wait for power stable */
159     if (pwr_status == IMGSENSOR_HW_POWER_STATUS_ON)
160         mdelay(5);
161     return IMGSENSOR_RETURN_SUCCESS;
162 }

sensor_power_sequence

上电:Power高,RST低,等50毫秒,RST高,等25毫秒。下电:25毫秒,RST低,等50毫秒,RST高,Power低。

drivers/misc/mediatek/imgsensor/src/ac8257/camera_hw/imgsensor_cfg_table.c

146 /* Legacy design */
147 struct IMGSENSOR_HW_POWER_SEQ sensor_power_sequence[] = {
148 #if defined(MAX9286_YUV)
149     {
150         SENSOR_DRVNAME_MAX9286_YUV,
151         {
152             {SensorMCLK, Vol_High, 1},
153             {PDN, Vol_High, 0},
154             {RST, Vol_Low, 50},
155             {RST, Vol_High, 25}
156         },
157     },
158 #endif

imgsensor_cfg_table.h

drivers/misc/mediatek/imgsensor/src/ac8257/camera_hw/imgsensor_cfg_table.h

 22 #define IMGSENSOR_SENSOR_IDX_NAME_MAIN  "0"
 23 #define IMGSENSOR_SENSOR_IDX_NAME_SUB   "1"
 24 #define IMGSENSOR_SENSOR_IDX_NAME_MAIN2 "2"
 25 #define IMGSENSOR_SENSOR_IDX_NAME_SUB2 "3"
 26 #define IMGSENSOR_SENSOR_IDX_NAME_MAIN3 "4"
 27
 28 #define IMGSENSOR_HW_POWER_INFO_MAX 12
 29 #define IMGSENSOR_HW_SENSOR_MAX_NUM 8
 30
 31 enum IMGSENSOR_HW_PIN {
 32     IMGSENSOR_HW_PIN_NONE = 0,
 33     IMGSENSOR_HW_PIN_PDN,
 34     IMGSENSOR_HW_PIN_RST,
 35     IMGSENSOR_HW_PIN_AVDD,
 36     IMGSENSOR_HW_PIN_DVDD,
 37     IMGSENSOR_HW_PIN_DOVDD,
 38     IMGSENSOR_HW_PIN_AFVDD,
 39 #ifdef MIPI_SWITCH
 40     IMGSENSOR_HW_PIN_MIPI_SWITCH_EN,
 41     IMGSENSOR_HW_PIN_MIPI_SWITCH_SEL,
 42 #endif
 43     IMGSENSOR_HW_PIN_MCLK,
 44     IMGSENSOR_HW_PIN_MAX_NUM,
 45     IMGSENSOR_HW_PIN_UNDEF = -1
 46 };
 47
 48 enum IMGSENSOR_HW_PIN_STATE {
 49     IMGSENSOR_HW_PIN_STATE_LEVEL_0,
 50     IMGSENSOR_HW_PIN_STATE_LEVEL_1000,
 51     IMGSENSOR_HW_PIN_STATE_LEVEL_1100,
 52     IMGSENSOR_HW_PIN_STATE_LEVEL_1200,
 53     IMGSENSOR_HW_PIN_STATE_LEVEL_1210,
 54     IMGSENSOR_HW_PIN_STATE_LEVEL_1220,
 55     IMGSENSOR_HW_PIN_STATE_LEVEL_1500,
 56     IMGSENSOR_HW_PIN_STATE_LEVEL_1800,
 57     IMGSENSOR_HW_PIN_STATE_LEVEL_2500,
 58     IMGSENSOR_HW_PIN_STATE_LEVEL_2800,
 59     IMGSENSOR_HW_PIN_STATE_LEVEL_2900,
 60     IMGSENSOR_HW_PIN_STATE_LEVEL_HIGH,
 61
 62     IMGSENSOR_HW_PIN_STATE_NONE = -1
 63 };
 64
 65 /*Legacy design*/
 66 #define PDN    IMGSENSOR_HW_PIN_PDN
 67 #define RST    IMGSENSOR_HW_PIN_RST
 68 #define AVDD   IMGSENSOR_HW_PIN_AVDD
 69 #define DVDD   IMGSENSOR_HW_PIN_DVDD
 70 #define DOVDD  IMGSENSOR_HW_PIN_DOVDD
 71 #define AFVDD  IMGSENSOR_HW_PIN_AFVDD
 72 #define VDD_None  IMGSENSOR_HW_PIN_NONE
 73
 74     /* For backward compatible */
 75 #define SensorMCLK  IMGSENSOR_HW_PIN_MCLK
 76
 77
 78 #define Vol_Low   IMGSENSOR_HW_PIN_STATE_LEVEL_0
 79 #define Vol_High  IMGSENSOR_HW_PIN_STATE_LEVEL_HIGH
 80 #define Vol_1000  IMGSENSOR_HW_PIN_STATE_LEVEL_1000
 81 #define Vol_1100  IMGSENSOR_HW_PIN_STATE_LEVEL_1100
 82 #define Vol_1200  IMGSENSOR_HW_PIN_STATE_LEVEL_1200
 83 #define Vol_1210  IMGSENSOR_HW_PIN_STATE_LEVEL_1210
 84 #define Vol_1220  IMGSENSOR_HW_PIN_STATE_LEVEL_1220
 85 #define Vol_1500  IMGSENSOR_HW_PIN_STATE_LEVEL_1500
 86 #define Vol_1800  IMGSENSOR_HW_PIN_STATE_LEVEL_1800
 87 #define Vol_2500  IMGSENSOR_HW_PIN_STATE_LEVEL_2500
 88 #define Vol_2800  IMGSENSOR_HW_PIN_STATE_LEVEL_2800
 89 #define Vol_2900  IMGSENSOR_HW_PIN_STATE_LEVEL_2900
 90
 91 enum IMGSENSOR_HW_ID {
 92     IMGSENSOR_HW_ID_REGULATOR,
 93     IMGSENSOR_HW_ID_GPIO,
 94     IMGSENSOR_HW_ID_MCLK,
 95
 96     IMGSENSOR_HW_ID_MAX_NUM,
 97     IMGSENSOR_HW_ID_NONE = -1
 98 };

log

[imgsensor][imgsensor_hw_power] sensor_idx 2, power 0 curr_sensor_name max9286_yuv

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值