IMX071 (D5100/D7000) Sensor Protocol

All things embedded.
*NO FEATURE REQUESTS*

IMX071 (D5100/D7000) Sensor Protocol

Postby lain » Mon Mar 17, 2014 1:31 pm

astronomer and I have done some preliminary work to decode the SPI protocol used by the IMX071 image sensor in the D5100 and D7000. All work so far was done on a D5100, but it should be the same on D7000.

On the D5100 mainboard, the image sensor SPI signals can be found on test points near the IE-155 chip:
d5100_imx071_spi.png

The SPI bus runs at 4.17MHz. The TOUT (data out from the image sensor) pin is not connected.
Data is sent LSB first, sampled on the rising edge of the clock. Clock, data, and chip enable are normally high.
Communication looks like this:
imx071_spi_proto.png

Transmission is split into packets. XCE is asserted (low) for the duration of a packet.
Address is auto-incremented during a packet, so a packet may contain many bytes.
The first byte of a packet is the sensor address (0x02 in this case), and it is always the same.
The second byte is the starting offset / address, 0x3E in the example.
Then the data follows. In this example, 0x33 is written to offset 0x3E.
If another byte followed 0x33 before XCE was deasserted, it would be written to offset 0x3F, and so on.

So far we have confirmed the following:
  • Sensor settings are the same regardless of JPEG or RAW modes (expected).
  • High ISO Noise Reduction has no effect on settings (expected).
  • White balance has no effect on sensor settings, it is entirely digital.
  • Analog gain seems to be 8 bytes at offset 0x2C (see below).
  • Gain rises non-linearly up to ISO 1000. Above ISO 1000 gain remains the same.
More about analog gain: it looks like there are four 12-bit gain settings, packed as follows (binary):
Code: Select all
  1. 0000AAAA AAAAAAAA BBBBBBBB BBBB0000 CCCCCCCC CCCC0000 DDDDDDDD DDDD0000


Where A, B, C, and D values represent Gr, Gb, R, and B gain values. Not sure which is which though.

Here is a table of the 12bit analog gain values as they are written to the sensor.
Rows are ISO 100 to 1000 downward (1/3 stop increments), columns are address 0x2C to 0x33 from left to right.
Code: Select all
  1. ISO  100: 00000000 00100100 10101100 01000000 01101100 01000000 11101100 01000000

  2. ISO  125: 00000010 10001010 01110000 10100000 11110000 10100000 00001000 10100000

  3. ISO  160: 00001100 10101110 10001010 11100000 10001010 11100000 10001010 11100000

  4. ISO  200: 00000011 10001001 00111000 10010000 00111000 10010000 00111000 10010000

  5. ISO  250: 00001110 00010101 00010001 01010000 00010001 01010000 00010001 01010000

  6. ISO  320: 00001110 01011101 10010101 11010000 10010101 11010000 10010101 11010000

  7. ISO  400: 00000011 00010011 01110001 00110000 01110001 00110000 01110001 00110000

  8. ISO  500: 00001000 00101011 00100010 10110000 00100010 10110000 00100010 10110000

  9. ISO  640: 00000100 10111011 10101011 10110000 00101011 10110000 00101011 10110000

  10. ISO  800: 00000010 00100111 11100010 01110000 11100010 01110000 11100010 01110000

  11. ISO 1000: 00001100 10010111 11001001 01110000 11001001 01110000 11001001 01110000


:text-thankyoublue: Super thanks to astronomer for generating this table and figuring out what it all means!!

There is still much work to be done, but I think this is a good start for mapping out the registers in the image sensor!
I am setup to sniff sensor comms during any operation, so firmware folks please let me know if there is anything specific I should look at.
Last edited by lain on Mon Mar 17, 2014 7:30 pm, edited 1 time in total.
User avatar
lain
Developer
 
Posts: 189
Joined: Fri Mar 29, 2013 3:42 pm
Been thanked: 111 times

Re: IMX071 (D5100/D7000) Sensor Protocol

Postby Shadowww » Mon Mar 17, 2014 3:18 pm

Does the analog gain only being applied at ISO 100-800 means that anything above ISO 800 is essentially underexposed ISO 800 image with added exposure during raw development? Aka if shooting raw/M and correcting exposure in post process, there's no point using ISOs higher than 800?
Shadowww
 
Posts: 37
Joined: Sun Dec 29, 2013 10:12 am
Been thanked: 3 times

Re: IMX071 (D5100/D7000) Sensor Protocol

Postby Simeon » Mon Mar 17, 2014 3:25 pm

Are those "gain" value dynamic for the same ISO or static, as in a bright ISO 100 verse dark ISO 100 have the same values, of the change?

Guess I'm asking show we look for value tables, or formulas
Simeon
Core Developer
 
Posts: 2620
Joined: Wed Nov 30, 2011 6:12 am
Location: Christchurch, New Zealand
Been thanked: 618 times

Re: IMX071 (D5100/D7000) Sensor Protocol

Postby Simeon » Mon Mar 17, 2014 3:27 pm

Shadowww wrote:Does the analog gain only being applied at ISO 100-800 means that anything above ISO 800 is essentially underexposed ISO 800 image with added exposure during raw development? Aka if shooting raw/M and correcting exposure in post process, there's no point using ISOs higher than 800?


It seems iso 1000 is the max point (vs 800), but yes. I assumed every body knew camera's had a native range, and a digital "magic" range.
Simeon
Core Developer
 
Posts: 2620
Joined: Wed Nov 30, 2011 6:12 am
Location: Christchurch, New Zealand
Been thanked: 618 times

Re: IMX071 (D5100/D7000) Sensor Protocol

Postby lain » Mon Mar 17, 2014 3:41 pm

Simeon wrote:Are those "gain" value dynamic for the same ISO or static, as in a bright ISO 100 verse dark ISO 100 have the same values, of the change?

Guess I'm asking show we look for value tables, or formulas

Understood, these tests were done with no lens attached, body cap on, manual mode, 1/4000th exposure.
Next time I'm at the camera I'll do some more tests:
- Lens attached, various apertures (expect aperture value to change gain)
- Bright light shining into camera vs. body/lens cap attached (with and without lens)

Any idea if D-Lighting might adjust gain, or would this be applied afterwards in EXPEED as well?
If we don't already know for sure, I'll add that to the next round of tests.
User avatar
lain
Developer
 
Posts: 189
Joined: Fri Mar 29, 2013 3:42 pm
Been thanked: 111 times

Re: IMX071 (D5100/D7000) Sensor Protocol

Postby AluK » Mon Mar 17, 2014 4:03 pm

lain wrote:Any idea if D-Lighting might adjust gain, or would this be applied afterwards in EXPEED as well?
If we don't already know for sure, I'll add that to the next round of tests.


Since RAW files of pictures taken with D-Lighting, when opened in a program other than Capture NX, just seem a tad underexposed, I'd hazard guess that it's purely a software thing.
AluK
 
Posts: 52
Joined: Thu Apr 12, 2012 3:49 am
Been thanked: 21 times

Re: IMX071 (D5100/D7000) Sensor Protocol

Postby coderat » Mon Mar 17, 2014 4:04 pm

lain wrote:Any idea if D-Lighting might adjust gain, or would this be applied afterwards in EXPEED as well?

The idea was D-Lighting is underexposure by some value (that is sure seen in RAW image with dcraw), another base curve in post (?) and then making shadows brighter in post (that seems to happend) on D5100/D7000. But may be more settings done on sensor ?

Good job, you keep me busy reading so I can't concentrate on my scripts ;)

Best regards,
coderat
coderat
Core Developer
 
Posts: 2283
Joined: Fri Apr 26, 2013 10:21 am
Been thanked: 450 times

Re: IMX071 (D5100/D7000) Sensor Protocol

Postby coderat » Mon Mar 17, 2014 4:29 pm

Shadowww wrote:Does the analog gain only being applied at ISO 100-800 means that anything above ISO 800 is essentially underexposed ISO 800 image with added exposure during raw development? Aka if shooting raw/M and correcting exposure in post process, there's no point using ISOs higher than 800?

Yes and no. But analog amplifier gain is set max at some ISO and it is somewhere between 800 and 1200, what was already pointed by this excellent review indirectly. But some tricks can be used in digital processing to gain more ISO. But anyway it is real ISO values - don't worry, they must comply international standards. Only modes Hi-x and Lo-x are not real ISOs. Of course if using ISO higher as max analog gain, you may loose parts of dynamic or color resolution - Nikon do not make promise on this. IMHO such tricks only work at the time point of making photo. So it still makes sense using ISOs >1000 when you need.

You can also translate in english this post about D4/D3s. Now you know why you pay more for those: D3s max analog gain seems being set high at 3200 ;) But D4 seems not having such high limit and there more things are done digitally.

Best regards,
coderat
coderat
Core Developer
 
Posts: 2283
Joined: Fri Apr 26, 2013 10:21 am
Been thanked: 450 times

Re: IMX071 (D5100/D7000) Sensor Protocol

Postby astronomer » Mon Mar 17, 2014 5:36 pm

Simeon wrote:Are those "gain" value dynamic for the same ISO or static, as in a bright ISO 100 verse dark ISO 100 have the same values, of the change?

Guess I'm asking show we look for value tables, or formulas


Yeah, this is a good question! We definitely need to test this later. As Wei-hao had encountered non-linearity issue before, the gain might be the culprit.
User avatar
astronomer
Developer
 
Posts: 722
Joined: Fri Apr 06, 2012 10:06 am
Location: US
Been thanked: 292 times

Re: IMX071 (D5100/D7000) Sensor Protocol

Postby astronomer » Mon Mar 17, 2014 5:38 pm

Simeon wrote:
Shadowww wrote:Does the analog gain only being applied at ISO 100-800 means that anything above ISO 800 is essentially underexposed ISO 800 image with added exposure during raw development? Aka if shooting raw/M and correcting exposure in post process, there's no point using ISOs higher than 800?


It seems iso 1000 is the max point (vs 800), but yes. I assumed every body knew camera's had a native range, and a digital "magic" range.


ISO1000 is the maximum analog gain, it has been proven by RAW histogram when anything beyond this point introduce gaps in green channel. I guess right now we definitely prove this.
User avatar
astronomer
Developer
 
Posts: 722
Joined: Fri Apr 06, 2012 10:06 am
Location: US
Been thanked: 292 times

Next

Return to Firmware

Who is online

Users browsing this forum: No registered users and 5 guests