[Samsung Epic 4G Touch] arpruss:
I spent some time last night and today trying to figure out how the /sys/etc/mdnie* files work. Most of my work was on the mdnie_tune_*_mode where * is movie, dynamic and standard. These, of course, correspond to the three modes in Settings | Display | Screen mode. The data below is from stock EL29. I don't know if other versions are the same (are they?).

What I wanted to do was to make a good red night mode. One can use ChainFire3D, but that works by just dropping the green and blue components, while what you really want to do is to convert rgb to luminance, and then use luminance to set the reg. This way, green and blue areas don't just go black, and things are much more legible.

Anyway, here are my partial findings (I am not the first to find them, since I came across an app to adjust the settings, but I couldn't find much of a write-up of how these things work--if you know a writeup, please tell me).

I suggest backing up all your /system/etc/mdnie* files before beginning.

To make the mdnie_tune_standard_mode and mdnie_tune_dynamic_mode files take effect, the corresponding mdnie_tune_ui_*_mode file must have the line 0x0001,0x0040 changed to read:

0x0001,0x0040,

The movie file already has that.

Then colors can be adjusted by editing the corresponding mdnie_tune_*_mode file. For the changes to take effect, just go to the settings and change profile to something else and back, or in a root shell do:

cat /sys/devices/virtual/mdnieset_ui/switch_mdnieset_ui/mdnieset_user_select_file_cmd > /sys/devices/virtual/mdnieset_ui/switch_mdnieset_ui/mdnieset_user_select_file_cmd

To edit colors, edit the second column of hex numbers in the mdnie_tune_*_mode file, in the lines numbered 0x00c8-0x00d3 (this is from the default mdnie_tune_standard_mode file):

0x00c8,0x0000,	//kb R	SCR
0x00c9,0x0000,	//gc R
0x00ca,0xffff,	//rm R
0x00cb,0xffff,	//yw R
0x00cc,0x0000,	//kb G
0x00cd,0xffff,	//gc G
0x00ce,0x0000,	//rm G
0x00cf,0xffff,	//yw G
0x00d0,0x00ff,	//kb B
0x00d1,0x00ff,	//gc B
0x00d2,0x00ff,	//rm B
0x00d3,0x00ff,	//yw B

The first number is a register number and the second is a register value. To understand these, note that the first four lines, marked with an "R", control how screen colors map to the red subpixels on the screen; the next four, marked with a "G", control how screen colors map to the green subpixels; the last four, marked with a "B", control how screen colors map to the blue subpixels.

Each line controls the output of two colors, using these codes: k = black (#000000), b = blue (#0000ff), g = green (#00ff00), c = cyan (#00ffff), r = red (#ff0000), m = magenta (#ff00ff), y = yellow (#ffff00), w = white (#ffffff).

E.g., the line

0x00d2,0x00ff,	//rm B

means that

r

ed gets a 0x00

B

lue subpixel, and

m

agenta gets a a 0xFF

B

lue subpixel.

For instance, a good way to turn the display black and white is:

0x00c8,0x001D,	//kb R	SCR
0x00c9,0x96B3,	//gc R
0x00ca,0x4C69,	//rm R
0x00cb,0xe2ff,	//yw R
0x00cc,0x001d,	//kb G
0x00cd,0x96b3,	//gc G
0x00ce,0x4c69,	//rm G
0x00cf,0xe2ff,	//yw G
0x00d0,0x001d,	//kb B
0x00d1,0x96b3,	//gc B
0x00d2,0x4c69,	//rm B
0x00d3,0xe2ff,	//yw B

This, e.g., sends red to 4c4c4c, green to 969696, blue to 1d1d1d, black to 000000, and white to ffffff, using the formula: luminance = .2989 R + .5870 G + .114 B

For a good red screen mode, one can use the same values, but set the G and B lines all to zero:

0x00c8,0x001D,	//kb R	SCR
0x00c9,0x96B3,	//gc R
0x00ca,0x4C69,	//rm R
0x00cb,0xe2ff,	//yw R
0x00cc,0x0000,	//kb G
0x00cd,0x0000,	//gc G
0x00ce,0x0000,	//rm G
0x00cf,0x0000,	//yw G
0x00d0,0x0000,	//kb B
0x00d1,0x0000,	//gc B
0x00d2,0x0000,	//rm B
0x00d3,0x0000,	//yw B

I wonder if it works exactly the same way on other Samsung mDNIe devices, like the Note, etc.