Read about our upcoming Code of Conduct on this issue

Commit 3b3e7aa0 authored by alex@thinkpad's avatar alex@thinkpad
Browse files

QEMU: image sensor power emulation

(fixes FA_CaptureTestImage on 5D2; tested on all other models able to run the FRSP test)

--HG--
branch : qemu
parent 51ea8e0ba322
......@@ -2578,6 +2578,50 @@ static int eos_handle_serial_flash_cs( unsigned int parm, EOSState *s, unsigned
return ret;
}
static unsigned int eos_handle_imgpowdet( unsigned int parm, EOSState *s, unsigned int address, unsigned char type, unsigned int value )
{
const char * msg = 0;
unsigned int ret = 0;
static uint32_t imgpowcfg_written = 0;
static uint32_t imgpowdet_written = 0;
static uint32_t imgpowdet_enabled = 0;
if (address == s->model->imgpowdet_register)
{
msg = "ImgPowDet";
MMIO_VAR(imgpowdet_written);
if (!(type & MODE_WRITE))
{
ret = (imgpowdet_written & ~s->model->imgpowdet_register_bit) |
(imgpowdet_enabled & s->model->imgpowdet_register_bit) ;
}
}
if (address == s->model->imgpowcfg_register)
{
msg = "InitializePcfgPort";
MMIO_VAR(imgpowcfg_written);
if (type & MODE_WRITE)
{
/* to double-check: if you swap the values here,
* all the FRSP tests should print "Image Power Failure" */
imgpowdet_enabled = (value & s->model->imgpowcfg_register_bit)
? s->model->imgpowdet_register_bit : 0;
if (imgpowdet_enabled && s->model->imgpowdet_interrupt)
{
eos_trigger_int(s, s->model->imgpowdet_interrupt, 100);
}
}
}
io_log("IMGPOW", s, address, type, value, ret, msg, 0, 0);
return ret;
}
unsigned int eos_handle_gpio ( unsigned int parm, EOSState *s, unsigned int address, unsigned char type, unsigned int value )
{
unsigned int ret = 1;
......@@ -2610,6 +2654,13 @@ unsigned int eos_handle_gpio ( unsigned int parm, EOSState *s, unsigned int addr
return eos_handle_serial_flash_cs(parm, s, address, type, value);
}
/* 0xC0220008, 0xC022001C, 0xC0220124; 0xC0220118 */
if (address == s->model->imgpowdet_register ||
address == s->model->imgpowcfg_register)
{
return eos_handle_imgpowdet(parm, s, address, type, value);
}
switch (address & 0xFFFF)
{
case 0xCB6C: /* 5D3/6D expect this one to be 0x10 in bootloader (6D:FFFF0544) */
......@@ -2936,6 +2987,11 @@ unsigned int eos_handle_ram ( unsigned int parm, EOSState *s, unsigned int addre
unsigned int eos_handle_power_control ( unsigned int parm, EOSState *s, unsigned int address, unsigned char type, unsigned int value )
{
if (address == s->model->imgpowcfg_register)
{
return eos_handle_imgpowdet(parm, s, address, type, value);
}
unsigned int ret = 0;
static uint32_t data[0x100 >> 2];
uint32_t index = (address & 0xFF) >> 2;
......@@ -5310,6 +5366,13 @@ unsigned int eos_handle_digic6 ( unsigned int parm, EOSState *s, unsigned int ad
return eos_handle_serial_flash_cs(parm, s, address, type, value);
}
/* 0xD20B004C, 0xD20B2294, 0xD20B21DC */
if (address == s->model->imgpowdet_register ||
address == s->model->imgpowcfg_register)
{
return eos_handle_imgpowdet(parm, s, address, type, value);
}
switch (address)
{
case 0xD203046C:
......
......@@ -36,6 +36,11 @@ struct eos_model_desc eos_model_list[] = {
.uart_rx_interrupt = 0x2E,
.uart_tx_interrupt = 0x3A,
.rtc_cs_register = 0xC022005C,
.imgpowcfg_register = 0xC0220118, /* unsure, tested on 450D */
.imgpowcfg_register_bit = 0x00000002,
.imgpowdet_register = 0xC0220124, /* Image Power Failure */
.imgpowdet_register_bit = 0x00000001, /* register and bit checked to print that message */
.imgpowdet_interrupt = 0x56, /* only used on 1000D? */
},
{
.name = "5D",
......@@ -118,6 +123,11 @@ struct eos_model_desc eos_model_list[] = {
.uart_rx_interrupt = 0x2E,
.uart_tx_interrupt = 0x3A,
.rtc_cs_register = 0xC0220128,
.imgpowcfg_register = 0xC0F01010, /* InitializePcfgPort (register used to power on the sensor?) */
.imgpowcfg_register_bit = 0x00200000, /* bit enabled when powering on */
.imgpowdet_register = 0xC022001C, /* Image Power Failure */
.imgpowdet_register_bit = 0x00000001, /* register and bit checked to print that message */
.imgpowdet_interrupt = 0x52, /* interrupt registered when powering on the sensor */
},
{
.name = "50D",
......@@ -275,6 +285,11 @@ struct eos_model_desc eos_model_list[] = {
.serial_flash_interrupt = 0x17B, /* where .serial_flash_size is set */
.serial_flash_cs_register = 0xC022C0D4,
.serial_flash_cs_bitmask = 0x00100000, /* 0x83DC00 / 0x93D800 */
.imgpowcfg_register = 0xC0F01010, /* InitializePcfgPort (register used to power on the sensor?) */
.imgpowcfg_register_bit = 0x00200000, /* bit enabled when powering on */
.imgpowdet_register = 0xC02200F0, /* Image Power Failure */
.imgpowdet_register_bit = 0x00000001, /* register and bit checked to print that message */
.imgpowdet_interrupt = 0x52, /* interrupt registered when powering on the sensor */
},
{
.name = "5D3",
......@@ -288,6 +303,7 @@ struct eos_model_desc eos_model_list[] = {
.cf_dma_interrupt = 0xE3,
.rtc_time_correct = 0x9F,
.dedicated_movie_mode = 0,
.imgpowdet_register = 0xC0220008, /* Image Power Failure */
},
{
/* started on request on photo taking, raw develop and others;
......@@ -325,6 +341,7 @@ struct eos_model_desc eos_model_list[] = {
.rtc_cs_register = 0xC02201D4,
.rtc_time_correct = 0x9F,
.dedicated_movie_mode = 0,
.imgpowdet_register = 0xC0220008, /* Image Power Failure */
},
{
.name = "650D",
......@@ -394,6 +411,7 @@ struct eos_model_desc eos_model_list[] = {
.rtc_cs_register = 0xC02201D4,
.rtc_time_correct = 0xA0,
.dedicated_movie_mode = 0,
.imgpowdet_register = 0xC02201C4, /* Image Power Failure */
},
/*************************** DIGIC VI *********************************/
{
......@@ -432,6 +450,9 @@ struct eos_model_desc eos_model_list[] = {
.mpu_control_register = 0xD4013008, /* 0x1C written in MREQ_ISR */
.mpu_mreq_interrupt = 0x2A, /* MREQ_ISR in InitializeIntercom */
.mpu_sio3_interrupt = 0x147, /* SIO3_ISR */
.imgpowdet_register = 0xD20B004C, /* Image Power Failure */
.imgpowdet_register_bit = 0x00010000, /* register and bit checked to print that message */
.imgpowdet_interrupt = 0xDA, /* interrupt registered when powering on the sensor */
},
{
.name = "80D",
......@@ -490,6 +511,9 @@ struct eos_model_desc eos_model_list[] = {
.serial_flash_size = 0x1000000,
.serial_flash_sio_ch = 0,
.serial_flash_cs_register = 0xD20B037C,
.imgpowdet_register = 0xD20B2294, /* Image Power Failure */
.imgpowdet_register_bit = 0x00010000, /* register and bit checked to print that message */
.imgpowdet_interrupt = 0x10A, /* interrupt registered when powering on the sensor */
},
{
.name = "5D4AE",
......@@ -547,6 +571,9 @@ struct eos_model_desc eos_model_list[] = {
.mpu_control_register = 0xD4013008, /* 0x1C written in MREQ_ISR */
.mpu_mreq_interrupt = 0x2A, /* MREQ_ISR in InitializeIntercom */
.mpu_sio3_interrupt = 0x147, /* SIO3_ISR */
.imgpowdet_register = 0xD20821DC, /* Image Power Failure */
.imgpowdet_register_bit = 0x00010000, /* register and bit checked to print that message */
.imgpowdet_interrupt = 0xDA, /* interrupt registered when powering on the sensor */
},
{
.name = "200D",
......
......@@ -62,11 +62,16 @@ struct eos_model_desc {
uint32_t rtc_time_correct;
uint32_t rtc_control_reg_2;
uint32_t dedicated_movie_mode;
uint32_t imgpowcfg_register;
uint32_t imgpowcfg_register_bit;
uint32_t imgpowdet_register;
uint32_t imgpowdet_register_bit;
uint32_t imgpowdet_interrupt;
};
/* this must match the number of items in the above struct */
/* note: you get a compile-time error if params[] is smaller than the struct */
uint32_t params[46];
uint32_t params[51];
};
} __attribute__((packed));
......
b285b09475f1575f9257cd31cdaf0df9 frsp.ppm
......@@ -826,6 +826,10 @@ function test_frsp {
-serial file:tests/$CAM/$TEST-uart.log \
) &> tests/$CAM/$TEST.log
if grep -q "Image Power Failure\|Img Pwr Fail" tests/$CAM/$TEST-uart.log; then
echo -en "\e[33mImage Power Failure\e[0m "
fi
tests/check_grep.sh tests/$CAM/$TEST-uart.log \
-qm1 "FA_CreateTestImage Fin" || return
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment