diff options
Diffstat (limited to 'apps/plugins/lib/grey_core.c')
-rw-r--r-- | apps/plugins/lib/grey_core.c | 480 |
1 files changed, 276 insertions, 204 deletions
diff --git a/apps/plugins/lib/grey_core.c b/apps/plugins/lib/grey_core.c index 8a30faa5f8..6b196e1aaf 100644 --- a/apps/plugins/lib/grey_core.c +++ b/apps/plugins/lib/grey_core.c | |||
@@ -33,189 +33,200 @@ | |||
33 | 33 | ||
34 | #ifndef SIMULATOR | 34 | #ifndef SIMULATOR |
35 | 35 | ||
36 | #if CONFIG_LCD == LCD_SSD1815 || CONFIG_LCD == LCD_IFP7XX \ | 36 | #if defined ARCHOS_RECORDER /* verified */ \ |
37 | || CONFIG_LCD == LCD_MROBE100 | 37 | || defined ARCHOS_FMRECORDER /* should be identical */ \ |
38 | /* measured and interpolated curve */ | 38 | || defined ARCHOS_RECORDERV2 /* should be identical */ \ |
39 | /* TODO: check for iFP & m:robe 100 */ | 39 | || defined ARCHOS_ONDIOFM /* verified */ \ |
40 | || defined ARCHOS_ONDIOSP /* verified */ | ||
41 | /* Average measurements of a Recorder v1, an Ondio FM, a backlight-modded | ||
42 | * Ondio FM, and an Ondio SP. */ | ||
40 | static const unsigned char lcdlinear[256] = { | 43 | static const unsigned char lcdlinear[256] = { |
41 | 0, 3, 5, 8, 11, 13, 16, 18, | 44 | 5, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28, 29, 31, 33, 35, |
42 | 21, 23, 26, 28, 31, 33, 36, 38, | 45 | 37, 39, 40, 42, 43, 45, 46, 48, 49, 50, 51, 53, 54, 55, 57, 58, |
43 | 40, 42, 45, 47, 49, 51, 53, 55, | 46 | 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 68, 69, 70, 71, 71, 72, |
44 | 57, 59, 60, 62, 64, 66, 67, 69, | 47 | 73, 74, 74, 75, 76, 77, 77, 78, 79, 79, 80, 80, 81, 81, 82, 82, |
45 | 70, 72, 73, 74, 76, 77, 78, 79, | 48 | 83, 84, 84, 85, 86, 86, 87, 87, 88, 88, 89, 89, 90, 90, 91, 91, |
46 | 81, 82, 83, 84, 85, 86, 87, 88, | 49 | 92, 92, 93, 93, 94, 94, 95, 95, 96, 96, 97, 98, 98, 99, 100, 100, |
47 | 88, 89, 90, 91, 92, 92, 93, 94, | 50 | 101, 101, 102, 103, 103, 104, 105, 105, 106, 106, 107, 107, 108, 108, 109, 109, |
48 | 95, 95, 96, 97, 97, 98, 99, 99, | 51 | 110, 110, 111, 112, 112, 113, 114, 114, 115, 115, 116, 117, 117, 118, 119, 119, |
49 | 100, 101, 102, 102, 103, 104, 104, 105, | 52 | 120, 120, 121, 122, 123, 123, 124, 125, 126, 126, 127, 128, 129, 129, 130, 131, |
50 | 106, 106, 107, 107, 108, 109, 109, 110, | 53 | 132, 132, 133, 134, 135, 135, 136, 137, 138, 138, 139, 140, 140, 141, 141, 142, |
51 | 111, 111, 112, 113, 113, 114, 114, 115, | 54 | 143, 144, 145, 146, 147, 147, 148, 149, 150, 151, 152, 153, 154, 154, 155, 156, |
52 | 116, 116, 117, 117, 118, 119, 119, 120, | 55 | 157, 158, 159, 160, 161, 161, 162, 163, 164, 165, 166, 167, 168, 168, 169, 170, |
53 | 120, 121, 121, 122, 122, 123, 123, 124, | 56 | 171, 172, 173, 174, 175, 176, 177, 178, 179, 180, 181, 182, 184, 185, 186, 187, |
54 | 124, 125, 125, 126, 126, 127, 127, 128, | 57 | 188, 189, 191, 192, 194, 195, 197, 198, 199, 200, 202, 203, 204, 205, 207, 208, |
55 | 128, 128, 129, 129, 130, 130, 131, 131, | 58 | 209, 210, 212, 213, 215, 216, 218, 219, 220, 221, 222, 223, 225, 226, 227, 228, |
56 | 132, 132, 133, 133, 133, 134, 134, 135, | 59 | 229, 230, 232, 233, 234, 235, 237, 238, 239, 240, 242, 243, 244, 246, 247, 248 |
57 | 135, 136, 136, 137, 137, 138, 138, 138, | ||
58 | 139, 139, 140, 140, 141, 141, 142, 142, | ||
59 | 143, 143, 144, 144, 145, 145, 146, 146, | ||
60 | 147, 147, 148, 148, 148, 149, 149, 150, | ||
61 | 150, 151, 151, 152, 152, 153, 153, 153, | ||
62 | 154, 154, 155, 155, 156, 156, 157, 157, | ||
63 | 158, 158, 158, 159, 159, 160, 160, 161, | ||
64 | 161, 162, 162, 163, 163, 164, 164, 165, | ||
65 | 165, 166, 167, 167, 168, 168, 169, 169, | ||
66 | 170, 171, 171, 172, 173, 173, 174, 175, | ||
67 | 176, 176, 177, 178, 179, 180, 181, 181, | ||
68 | 182, 183, 184, 185, 186, 188, 189, 190, | ||
69 | 191, 192, 194, 195, 196, 198, 199, 201, | ||
70 | 202, 204, 205, 207, 209, 211, 213, 215, | ||
71 | 217, 219, 222, 224, 226, 229, 231, 234, | ||
72 | 236, 239, 242, 244, 247, 250, 252, 255 | ||
73 | }; | 60 | }; |
74 | #elif CONFIG_LCD == LCD_S1D15E06 | 61 | /* The actual LCD scanrate varies a lot with temperature on these targets */ |
75 | /* measured and interpolated curve */ | 62 | #define LCD_SCANRATE 67 /* Hz */ |
63 | |||
64 | #elif defined IAUDIO_M3 /* verified */ | ||
65 | /* Average measurements of 2 iAudio remotes connected to an M3. */ | ||
66 | static const unsigned char lcdlinear[256] = { | ||
67 | 5, 9, 13, 17, 21, 26, 30, 34, 38, 42, 46, 50, 54, 58, 62, 66, | ||
68 | 70, 73, 76, 78, 80, 82, 84, 86, 88, 90, 91, 92, 94, 95, 96, 97, | ||
69 | 98, 99, 99, 100, 101, 102, 102, 103, 104, 104, 105, 105, 106, 107, 107, 108, | ||
70 | 109, 109, 110, 110, 111, 111, 112, 112, 113, 113, 114, 114, 115, 115, 116, 116, | ||
71 | 117, 117, 118, 118, 119, 119, 120, 120, 121, 121, 121, 122, 122, 123, 123, 123, | ||
72 | 124, 124, 124, 125, 125, 126, 126, 126, 127, 127, 127, 128, 128, 129, 129, 129, | ||
73 | 130, 130, 131, 131, 132, 132, 133, 133, 134, 134, 134, 135, 135, 136, 136, 136, | ||
74 | 137, 137, 137, 138, 138, 139, 139, 139, 140, 140, 141, 141, 142, 142, 143, 143, | ||
75 | 144, 144, 145, 145, 146, 147, 147, 148, 149, 149, 150, 150, 151, 151, 152, 152, | ||
76 | 153, 153, 154, 154, 155, 155, 156, 156, 157, 157, 158, 158, 159, 160, 160, 161, | ||
77 | 162, 162, 163, 164, 164, 165, 166, 167, 168, 168, 169, 169, 170, 171, 171, 172, | ||
78 | 173, 173, 174, 175, 176, 176, 177, 178, 179, 179, 180, 181, 182, 182, 183, 184, | ||
79 | 185, 186, 187, 188, 189, 190, 191, 192, 193, 194, 195, 196, 198, 199, 200, 201, | ||
80 | 202, 203, 204, 205, 207, 208, 209, 210, 211, 212, 213, 214, 216, 217, 218, 219, | ||
81 | 220, 221, 222, 223, 225, 226, 227, 228, 229, 230, 231, 232, 234, 235, 236, 237, | ||
82 | 238, 239, 240, 241, 242, 243, 244, 245, 246, 247, 248, 249, 249, 250, 251, 252 | ||
83 | }; | ||
84 | /* The actual LCD scanrate is twice as high, but we cannot transfer fast enough | ||
85 | * for 150Hz. Even at 75Hz, greyscale display is very smooth. Average from | ||
86 | * 2 iAudio remotes. */ | ||
87 | #define LCD_SCANRATE 75 /* Hz */ | ||
88 | |||
89 | #elif defined IAUDIO_M5 /* verified */ | ||
90 | /* Measurement of one iAudio M5L */ | ||
91 | static const unsigned char lcdlinear[256] = { | ||
92 | 4, 6, 8, 10, 11, 13, 15, 17, 19, 21, 22, 24, 25, 27, 28, 30, | ||
93 | 32, 33, 35, 36, 37, 39, 40, 42, 43, 44, 45, 46, 48, 49, 50, 51, | ||
94 | 52, 52, 53, 54, 55, 55, 56, 57, 58, 58, 59, 60, 61, 61, 62, 63, | ||
95 | 64, 64, 65, 65, 66, 66, 67, 67, 68, 68, 69, 70, 70, 71, 72, 72, | ||
96 | 73, 73, 74, 75, 75, 76, 77, 77, 78, 78, 79, 79, 80, 80, 81, 81, | ||
97 | 82, 82, 83, 84, 84, 85, 86, 86, 87, 87, 88, 89, 89, 90, 91, 91, | ||
98 | 92, 92, 93, 93, 94, 94, 95, 95, 96, 96, 97, 98, 98, 99, 100, 100, | ||
99 | 101, 101, 102, 102, 103, 103, 104, 104, 105, 105, 106, 106, 107, 107, 108, 108, | ||
100 | 109, 109, 110, 110, 111, 111, 112, 112, 113, 113, 114, 114, 115, 115, 116, 116, | ||
101 | 117, 117, 118, 119, 119, 120, 121, 121, 122, 122, 123, 124, 124, 125, 126, 126, | ||
102 | 127, 127, 128, 129, 130, 130, 131, 132, 133, 133, 134, 135, 135, 136, 137, 137, | ||
103 | 138, 139, 140, 141, 142, 142, 143, 144, 145, 146, 147, 148, 149, 149, 150, 151, | ||
104 | 152, 153, 154, 155, 156, 157, 158, 159, 160, 161, 163, 164, 165, 167, 168, 169, | ||
105 | 170, 172, 173, 175, 177, 179, 180, 182, 184, 186, 188, 190, 192, 194, 196, 198, | ||
106 | 200, 202, 204, 205, 207, 209, 210, 212, 214, 216, 218, 219, 221, 223, 224, 226, | ||
107 | 228, 230, 231, 233, 235, 236, 237, 239, 241, 243, 244, 246, 248, 249, 250, 252 | ||
108 | }; | ||
109 | #define LCD_SCANRATE 73 /* Hz */ | ||
110 | |||
111 | #elif defined IPOD_1G2G /* verified */ | ||
112 | /* Average measurements of an iPod 1st Gen (0x00010001) and an iPod 2nd Gen | ||
113 | * (0x00020000), measured with both backlight off & backlight on (flipped | ||
114 | * curves) and medium load (white background when measuring with backlight on), | ||
115 | * as the curve is load dependent (the controller's step-up converter doesn't | ||
116 | * provide enough juice). Table is for backlight_off state. */ | ||
117 | static const unsigned char lcdlinear[256] = { | ||
118 | 4, 6, 8, 9, 11, 13, 14, 16, 17, 18, 20, 21, 23, 24, 26, 27, | ||
119 | 29, 30, 31, 32, 34, 35, 36, 37, 38, 39, 40, 41, 41, 42, 43, 44, | ||
120 | 45, 45, 46, 47, 47, 48, 49, 49, 50, 50, 51, 51, 52, 52, 53, 53, | ||
121 | 54, 54, 54, 55, 55, 56, 56, 56, 57, 57, 57, 58, 58, 59, 59, 59, | ||
122 | 60, 60, 60, 61, 61, 62, 62, 62, 63, 63, 63, 64, 64, 65, 65, 65, | ||
123 | 66, 66, 67, 67, 68, 68, 69, 69, 70, 70, 71, 71, 72, 72, 73, 73, | ||
124 | 74, 74, 74, 75, 75, 76, 76, 76, 77, 77, 78, 78, 79, 79, 80, 80, | ||
125 | 81, 81, 82, 82, 83, 83, 84, 84, 85, 85, 86, 86, 87, 87, 88, 88, | ||
126 | 89, 89, 90, 91, 92, 92, 93, 94, 95, 95, 96, 97, 97, 98, 99, 99, | ||
127 | 100, 100, 101, 102, 102, 103, 104, 104, 105, 105, 106, 107, 107, 108, 109, 109, | ||
128 | 110, 110, 111, 112, 113, 113, 114, 115, 116, 116, 117, 118, 119, 119, 120, 121, | ||
129 | 122, 122, 123, 124, 125, 125, 126, 127, 128, 129, 130, 131, 131, 132, 133, 134, | ||
130 | 135, 137, 138, 139, 141, 142, 144, 145, 146, 147, 149, 150, 151, 152, 154, 155, | ||
131 | 156, 158, 159, 161, 162, 164, 165, 167, 169, 171, 172, 174, 175, 177, 178, 180, | ||
132 | 182, 184, 186, 188, 189, 191, 193, 195, 197, 199, 201, 203, 206, 208, 210, 212, | ||
133 | 214, 217, 219, 221, 224, 226, 229, 231, 233, 236, 238, 240, 243, 245, 247, 250 | ||
134 | }; | ||
135 | /* Average from an iPod 1st Gen and an iPod 2nd Gen */ | ||
136 | #define LCD_SCANRATE 96 /* Hz */ | ||
137 | |||
138 | #elif defined IPOD_MINI2G /* verified */ \ | ||
139 | || defined IPOD_MINI /* should be identical */ \ | ||
140 | || defined IPOD_3G /* TODO: verify */ \ | ||
141 | || defined IPOD_4G /* TODO: verify */ | ||
142 | /* Measurement of one iPod Mini G2 */ | ||
76 | static const unsigned char lcdlinear[256] = { | 143 | static const unsigned char lcdlinear[256] = { |
77 | 0, 5, 11, 16, 21, 27, 32, 37, | 144 | 2, 5, 7, 10, 12, 15, 17, 20, 22, 24, 26, 28, 30, 32, 34, 36, |
78 | 42, 47, 51, 56, 60, 64, 68, 72, | 145 | 38, 40, 41, 42, 44, 45, 46, 47, 48, 49, 50, 50, 51, 52, 52, 53, |
79 | 75, 78, 81, 84, 87, 89, 91, 93, | 146 | 54, 54, 55, 55, 56, 56, 57, 57, 58, 58, 58, 59, 59, 60, 60, 60, |
80 | 95, 96, 98, 99, 101, 102, 103, 104, | 147 | 61, 61, 61, 62, 62, 63, 63, 63, 64, 64, 64, 64, 65, 65, 65, 65, |
81 | 105, 106, 107, 108, 109, 110, 111, 111, | 148 | 66, 66, 66, 66, 67, 67, 67, 67, 68, 68, 68, 68, 69, 69, 69, 69, |
82 | 112, 113, 113, 114, 115, 115, 116, 117, | 149 | 70, 70, 70, 70, 71, 71, 71, 71, 72, 72, 72, 73, 73, 74, 74, 74, |
83 | 117, 118, 118, 119, 119, 120, 120, 121, | 150 | 75, 75, 75, 75, 76, 76, 76, 76, 77, 77, 77, 78, 78, 79, 79, 79, |
84 | 121, 122, 122, 123, 123, 124, 124, 125, | 151 | 80, 80, 80, 81, 81, 82, 82, 82, 83, 83, 83, 84, 84, 85, 85, 85, |
85 | 125, 126, 126, 127, 127, 127, 128, 128, | 152 | 86, 86, 86, 87, 87, 88, 88, 88, 89, 89, 90, 90, 91, 91, 92, 92, |
86 | 129, 129, 130, 130, 131, 131, 132, 132, | 153 | 93, 93, 94, 94, 95, 95, 96, 96, 97, 97, 98, 99, 99, 100, 101, 101, |
87 | 133, 133, 134, 134, 135, 135, 136, 136, | 154 | 102, 102, 103, 104, 104, 105, 106, 106, 107, 108, 109, 110, 110, 111, 112, 113, |
88 | 137, 137, 138, 138, 138, 139, 139, 140, | 155 | 114, 115, 115, 116, 117, 118, 118, 119, 120, 121, 121, 122, 123, 124, 124, 125, |
89 | 140, 141, 141, 141, 142, 142, 143, 143, | 156 | 126, 127, 128, 129, 129, 130, 131, 132, 133, 134, 135, 136, 137, 138, 139, 140, |
90 | 143, 144, 144, 145, 145, 145, 146, 146, | 157 | 141, 142, 143, 144, 146, 147, 148, 149, 150, 151, 153, 154, 155, 156, 158, 159, |
91 | 146, 147, 147, 147, 148, 148, 149, 149, | 158 | 160, 162, 163, 165, 166, 168, 169, 171, 172, 175, 177, 180, 182, 185, 187, 190, |
92 | 149, 150, 150, 150, 151, 151, 151, 152, | 159 | 192, 196, 199, 203, 206, 210, 213, 217, 220, 223, 227, 230, 234, 238, 242, 246 |
93 | 152, 153, 153, 153, 154, 154, 155, 155, | ||
94 | 155, 156, 156, 157, 157, 157, 158, 158, | ||
95 | 159, 159, 159, 160, 160, 161, 161, 162, | ||
96 | 162, 162, 163, 163, 164, 164, 164, 165, | ||
97 | 165, 166, 166, 167, 167, 167, 168, 168, | ||
98 | 169, 169, 170, 170, 170, 171, 171, 172, | ||
99 | 172, 173, 173, 174, 174, 175, 175, 176, | ||
100 | 176, 177, 177, 178, 178, 179, 179, 180, | ||
101 | 180, 181, 182, 182, 183, 184, 184, 185, | ||
102 | 186, 186, 187, 188, 188, 189, 190, 191, | ||
103 | 191, 192, 193, 194, 195, 196, 196, 197, | ||
104 | 198, 199, 200, 201, 202, 203, 204, 205, | ||
105 | 206, 207, 208, 209, 210, 211, 213, 214, | ||
106 | 215, 216, 218, 219, 220, 222, 223, 225, | ||
107 | 227, 228, 230, 232, 233, 235, 237, 239, | ||
108 | 241, 243, 245, 247, 249, 251, 253, 255 | ||
109 | }; | 160 | }; |
110 | #elif (CONFIG_LCD == LCD_IPOD2BPP) || (CONFIG_LCD == LCD_IPODMINI) | 161 | /* Average of an iPod Mini G2 and 2 3rd Gen iPods. */ |
111 | /* measured and interpolated curve for mini LCD */ | 162 | #define LCD_SCANRATE 87 /* Hz */ |
112 | /* TODO: verify this curve on the fullsize greyscale LCD */ | 163 | |
164 | #elif defined IRIVER_H100_SERIES /* verified */ | ||
165 | /* Measurement of one Iriver H140 */ | ||
113 | static const unsigned char lcdlinear[256] = { | 166 | static const unsigned char lcdlinear[256] = { |
114 | 0, 3, 6, 8, 11, 14, 17, 19, | 167 | 5, 8, 12, 15, 18, 22, 25, 28, 31, 34, 36, 39, 42, 44, 47, 50, |
115 | 22, 24, 27, 29, 32, 34, 36, 38, | 168 | 53, 55, 57, 59, 62, 64, 66, 68, 70, 71, 72, 73, 75, 76, 77, 78, |
116 | 40, 42, 44, 45, 47, 48, 50, 51, | 169 | 79, 80, 80, 81, 82, 83, 83, 84, 85, 85, 86, 86, 87, 87, 88, 88, |
117 | 52, 54, 55, 56, 57, 58, 58, 59, | 170 | 89, 89, 90, 90, 91, 91, 92, 92, 93, 93, 93, 94, 94, 95, 95, 95, |
118 | 60, 61, 62, 62, 63, 64, 64, 65, | 171 | 96, 96, 96, 97, 97, 98, 98, 98, 99, 99, 99, 100, 100, 101, 101, 101, |
119 | 66, 66, 67, 67, 68, 68, 69, 69, | 172 | 102, 102, 102, 103, 103, 104, 104, 104, 105, 105, 106, 106, 107, 107, 108, 108, |
120 | 70, 70, 70, 71, 71, 71, 72, 72, | 173 | 109, 109, 109, 110, 110, 111, 111, 111, 112, 112, 113, 113, 114, 114, 115, 115, |
121 | 73, 73, 73, 74, 74, 74, 74, 75, | 174 | 116, 116, 117, 117, 118, 118, 119, 119, 120, 120, 121, 121, 122, 122, 123, 123, |
122 | 75, 75, 76, 76, 76, 77, 77, 77, | 175 | 124, 124, 125, 125, 126, 127, 127, 128, 129, 129, 130, 130, 131, 131, 132, 132, |
123 | 78, 78, 78, 79, 79, 79, 80, 80, | 176 | 133, 133, 134, 135, 135, 136, 137, 137, 138, 138, 139, 139, 140, 140, 141, 141, |
124 | 80, 80, 81, 81, 81, 82, 82, 82, | 177 | 142, 142, 143, 143, 144, 145, 145, 146, 147, 147, 148, 148, 149, 150, 150, 151, |
125 | 83, 83, 83, 84, 84, 84, 85, 85, | 178 | 152, 152, 153, 153, 154, 155, 155, 156, 157, 157, 158, 159, 160, 160, 161, 162, |
126 | 85, 85, 86, 86, 86, 87, 87, 87, | 179 | 163, 164, 165, 166, 166, 167, 168, 169, 170, 171, 172, 173, 174, 175, 176, 177, |
127 | 87, 88, 88, 88, 89, 89, 89, 89, | 180 | 178, 179, 181, 182, 183, 184, 186, 187, 188, 189, 191, 192, 193, 194, 196, 197, |
128 | 90, 90, 90, 91, 91, 91, 92, 92, | 181 | 198, 200, 202, 203, 205, 207, 208, 210, 212, 214, 215, 217, 218, 220, 221, 223, |
129 | 92, 93, 93, 93, 94, 94, 94, 95, | 182 | 224, 226, 228, 229, 231, 233, 235, 236, 238, 240, 241, 242, 244, 245, 246, 248 |
130 | 95, 96, 96, 96, 97, 97, 98, 98, | ||
131 | 99, 99, 99, 100, 100, 101, 101, 102, | ||
132 | 102, 103, 103, 104, 104, 105, 105, 106, | ||
133 | 106, 107, 107, 108, 108, 109, 109, 110, | ||
134 | 110, 111, 111, 112, 113, 113, 114, 114, | ||
135 | 115, 115, 116, 117, 117, 118, 118, 119, | ||
136 | 120, 120, 121, 122, 122, 123, 124, 124, | ||
137 | 125, 126, 126, 127, 128, 128, 129, 130, | ||
138 | 131, 131, 132, 133, 134, 134, 135, 136, | ||
139 | 137, 138, 139, 140, 141, 142, 143, 144, | ||
140 | 145, 146, 147, 148, 149, 150, 152, 153, | ||
141 | 154, 156, 157, 159, 160, 162, 163, 165, | ||
142 | 167, 168, 170, 172, 174, 176, 178, 180, | ||
143 | 182, 184, 187, 189, 192, 194, 197, 200, | ||
144 | 203, 206, 209, 212, 215, 219, 222, 226, | ||
145 | 229, 233, 236, 240, 244, 248, 251, 255 | ||
146 | }; | 183 | }; |
147 | #elif CONFIG_LCD == LCD_TL0350A | 184 | #define LCD_SCANRATE 70 /* Hz */ |
148 | /* measured and interpolated curve for iaudio remote */ | 185 | |
186 | #else /* not yet calibrated targets - generic linear mapping */ | ||
187 | /* TODO: calibrate iFP7xx | ||
188 | * TODO: Olympus m:robe 100 */ | ||
149 | static const unsigned char lcdlinear[256] = { | 189 | static const unsigned char lcdlinear[256] = { |
150 | 5, 9, 13, 17, 21, 25, 29, 33, | 190 | 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, |
151 | 36, 39, 42, 45, 48, 51, 54, 57, | 191 | 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, |
152 | 60, 62, 65, 67, 70, 72, 75, 77, | 192 | 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, |
153 | 80, 82, 84, 86, 87, 89, 91, 93, | 193 | 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, |
154 | 94, 95, 96, 97, 97, 98, 99, 99, | 194 | 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, |
155 | 100, 100, 101, 102, 103, 103, 104, 105, | 195 | 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, |
156 | 106, 106, 107, 108, 108, 109, 110, 111, | 196 | 96, 97, 98, 99, 100, 101, 102, 103, 104, 105, 106, 107, 108, 109, 110, 111, |
157 | 112, 112, 113, 113, 114, 114, 115, 115, | 197 | 112, 113, 114, 115, 116, 117, 118, 119, 120, 121, 122, 123, 124, 125, 126, 127, |
158 | 116, 116, 117, 117, 118, 118, 119, 119, | 198 | 128, 129, 130, 131, 132, 133, 134, 135, 136, 137, 138, 139, 140, 141, 142, 143, |
159 | 120, 120, 121, 121, 122, 122, 123, 123, | 199 | 144, 145, 146, 147, 148, 149, 150, 151, 152, 153, 154, 155, 156, 157, 158, 159, |
160 | 124, 124, 124, 125, 125, 126, 126, 126, | 200 | 160, 161, 162, 163, 164, 165, 166, 167, 168, 169, 170, 171, 172, 173, 174, 175, |
161 | 127, 127, 127, 128, 128, 129, 129, 129, | 201 | 176, 177, 178, 179, 180, 181, 182, 183, 184, 185, 186, 187, 188, 189, 190, 191, |
162 | 130, 130, 131, 131, 132, 132, 133, 133, | 202 | 192, 193, 194, 195, 196, 197, 198, 199, 200, 201, 202, 203, 204, 205, 206, 207, |
163 | 134, 134, 135, 135, 136, 136, 137, 137, | 203 | 208, 209, 210, 211, 212, 213, 214, 215, 216, 217, 218, 219, 220, 221, 222, 223, |
164 | 138, 138, 139, 139, 140, 140, 141, 141, | 204 | 224, 225, 226, 227, 228, 229, 230, 231, 232, 233, 234, 235, 236, 237, 238, 239, |
165 | 142, 142, 143, 143, 144, 144, 145, 145, | 205 | 240, 241, 242, 243, 244, 245, 246, 247, 248, 249, 250, 251, 252, 253, 254, 255 |
166 | 146, 146, 147, 147, 148, 149, 149, 150, | ||
167 | 151, 151, 152, 152, 153, 154, 154, 155, | ||
168 | 156, 156, 157, 157, 158, 159, 159, 160, | ||
169 | 161, 161, 162, 163, 164, 164, 165, 166, | ||
170 | 167, 167, 168, 169, 170, 170, 171, 172, | ||
171 | 173, 173, 174, 175, 176, 176, 177, 178, | ||
172 | 179, 179, 180, 181, 182, 182, 183, 184, | ||
173 | 185, 186, 187, 188, 188, 189, 191, 191, | ||
174 | 192, 193, 194, 195, 195, 196, 197, 198, | ||
175 | 199, 200, 201, 202, 203, 204, 205, 206, | ||
176 | 207, 208, 209, 210, 211, 212, 213, 214, | ||
177 | 215, 216, 217, 218, 219, 220, 222, 223, | ||
178 | 224, 225, 226, 227, 228, 229, 230, 231, | ||
179 | 232, 233, 234, 235, 236, 237, 238, 239, | ||
180 | 240, 240, 241, 242, 243, 243, 244, 245, | ||
181 | 246, 246, 247, 248, 249, 250, 251, 252 | ||
182 | }; | 206 | }; |
207 | /* generic default */ | ||
208 | #define LCD_SCANRATE 70 /* Hz */ | ||
209 | |||
183 | #endif | 210 | #endif |
184 | #else /* SIMULATOR */ | 211 | #else /* SIMULATOR */ |
185 | /* undo a (generic) PC display gamma of 2.0 to simulate target behaviour */ | 212 | /* undo a (generic) PC display gamma of 2.0 to simulate target behaviour */ |
186 | static const unsigned char lcdlinear[256] = { | 213 | static const unsigned char lcdlinear[256] = { |
187 | 0, 16, 23, 28, 32, 36, 39, 42, | 214 | 0, 16, 23, 28, 32, 36, 39, 42, 45, 48, 50, 53, 55, 58, 60, 62, |
188 | 45, 48, 50, 53, 55, 58, 60, 62, | 215 | 64, 66, 68, 70, 71, 73, 75, 77, 78, 80, 81, 83, 84, 86, 87, 89, |
189 | 64, 66, 68, 70, 71, 73, 75, 77, | 216 | 90, 92, 93, 94, 96, 97, 98, 100, 101, 102, 103, 105, 106, 107, 108, 109, |
190 | 78, 80, 81, 83, 84, 86, 87, 89, | 217 | 111, 112, 113, 114, 115, 116, 117, 118, 119, 121, 122, 123, 124, 125, 126, 127, |
191 | 90, 92, 93, 94, 96, 97, 98, 100, | 218 | 128, 129, 130, 131, 132, 133, 134, 135, 135, 136, 137, 138, 139, 140, 141, 142, |
192 | 101, 102, 103, 105, 106, 107, 108, 109, | 219 | 143, 144, 145, 145, 146, 147, 148, 149, 150, 151, 151, 152, 153, 154, 155, 156, |
193 | 111, 112, 113, 114, 115, 116, 117, 118, | 220 | 156, 157, 158, 159, 160, 160, 161, 162, 163, 164, 164, 165, 166, 167, 167, 168, |
194 | 119, 121, 122, 123, 124, 125, 126, 127, | 221 | 169, 170, 170, 171, 172, 173, 173, 174, 175, 176, 176, 177, 178, 179, 179, 180, |
195 | 128, 129, 130, 131, 132, 133, 134, 135, | 222 | 181, 181, 182, 183, 183, 184, 185, 186, 186, 187, 188, 188, 189, 190, 190, 191, |
196 | 135, 136, 137, 138, 139, 140, 141, 142, | 223 | 192, 192, 193, 194, 194, 195, 196, 196, 197, 198, 198, 199, 199, 200, 201, 201, |
197 | 143, 144, 145, 145, 146, 147, 148, 149, | 224 | 202, 203, 203, 204, 204, 205, 206, 206, 207, 208, 208, 209, 209, 210, 211, 211, |
198 | 150, 151, 151, 152, 153, 154, 155, 156, | 225 | 212, 212, 213, 214, 214, 215, 215, 216, 217, 217, 218, 218, 219, 220, 220, 221, |
199 | 156, 157, 158, 159, 160, 160, 161, 162, | 226 | 221, 222, 222, 223, 224, 224, 225, 225, 226, 226, 227, 228, 228, 229, 229, 230, |
200 | 163, 164, 164, 165, 166, 167, 167, 168, | 227 | 230, 231, 231, 232, 233, 233, 234, 234, 235, 235, 236, 236, 237, 237, 238, 238, |
201 | 169, 170, 170, 171, 172, 173, 173, 174, | 228 | 239, 240, 240, 241, 241, 242, 242, 243, 243, 244, 244, 245, 245, 246, 246, 247, |
202 | 175, 176, 176, 177, 178, 179, 179, 180, | 229 | 247, 248, 248, 249, 249, 250, 250, 251, 251, 252, 252, 253, 253, 254, 254, 255 |
203 | 181, 181, 182, 183, 183, 184, 185, 186, | ||
204 | 186, 187, 188, 188, 189, 190, 190, 191, | ||
205 | 192, 192, 193, 194, 194, 195, 196, 196, | ||
206 | 197, 198, 198, 199, 199, 200, 201, 201, | ||
207 | 202, 203, 203, 204, 204, 205, 206, 206, | ||
208 | 207, 208, 208, 209, 209, 210, 211, 211, | ||
209 | 212, 212, 213, 214, 214, 215, 215, 216, | ||
210 | 217, 217, 218, 218, 219, 220, 220, 221, | ||
211 | 221, 222, 222, 223, 224, 224, 225, 225, | ||
212 | 226, 226, 227, 228, 228, 229, 229, 230, | ||
213 | 230, 231, 231, 232, 233, 233, 234, 234, | ||
214 | 235, 235, 236, 236, 237, 237, 238, 238, | ||
215 | 239, 240, 240, 241, 241, 242, 242, 243, | ||
216 | 243, 244, 244, 245, 245, 246, 246, 247, | ||
217 | 247, 248, 248, 249, 249, 250, 250, 251, | ||
218 | 251, 252, 252, 253, 253, 254, 254, 255 | ||
219 | }; | 230 | }; |
220 | #endif /* SIMULATOR */ | 231 | #endif /* SIMULATOR */ |
221 | 232 | ||
@@ -224,12 +235,64 @@ static inline void _deferred_update(void) __attribute__ ((always_inline)); | |||
224 | static int exp_s16p16(int x); | 235 | static int exp_s16p16(int x); |
225 | static int log_s16p16(int x); | 236 | static int log_s16p16(int x); |
226 | static void grey_screendump_hook(int fd); | 237 | static void grey_screendump_hook(int fd); |
238 | static void fill_gvalues(void); | ||
227 | #ifdef SIMULATOR | 239 | #ifdef SIMULATOR |
228 | static unsigned long _grey_get_pixel(int x, int y); | 240 | static unsigned long _grey_get_pixel(int x, int y); |
229 | #else | 241 | #else |
230 | static void _timer_isr(void); | 242 | static void _timer_isr(void); |
231 | #endif | 243 | #endif |
232 | 244 | ||
245 | #if defined(HAVE_BACKLIGHT_INVERSION) && !defined(SIMULATOR) | ||
246 | static bool backlight_state; | ||
247 | |||
248 | |||
249 | static void invert_gvalues(void) | ||
250 | { | ||
251 | unsigned char *val, *end; | ||
252 | unsigned char rev_tab[256]; | ||
253 | unsigned i; | ||
254 | unsigned last_i = 0; | ||
255 | unsigned x = 0; | ||
256 | unsigned last_x; | ||
257 | |||
258 | if (_grey_info.flags & GREY_BUFFERED) | ||
259 | { | ||
260 | fill_gvalues(); | ||
261 | grey_update(); | ||
262 | } | ||
263 | else /* Unbuffered - need crude reconstruction */ | ||
264 | { | ||
265 | /* Step 1: Calculate a transposed table for undoing the old mapping */ | ||
266 | for (i = 0; i < 256; i++) | ||
267 | { | ||
268 | last_x = x; | ||
269 | x = _grey_info.gvalue[i]; | ||
270 | if (x > last_x) | ||
271 | { | ||
272 | rev_tab[last_x++] = (last_i + i) / 2; | ||
273 | while (x > last_x) | ||
274 | rev_tab[last_x++] = i; | ||
275 | last_i = i; | ||
276 | } | ||
277 | } | ||
278 | rev_tab[last_x++] = (last_i + 255) / 2; | ||
279 | while (256 > last_x) | ||
280 | rev_tab[last_x++] = 255; | ||
281 | |||
282 | /* Step 2: Calculate new mapping */ | ||
283 | fill_gvalues(); | ||
284 | |||
285 | /* Step 3: Transpose all pixel values */ | ||
286 | val = _grey_info.values; | ||
287 | end = val + _GREY_MULUQ(_grey_info.width, _grey_info.height); | ||
288 | |||
289 | do | ||
290 | *val = _grey_info.gvalue[rev_tab[*val]]; | ||
291 | while (++val < end); | ||
292 | } | ||
293 | } | ||
294 | #endif | ||
295 | |||
233 | /* Update LCD areas not covered by the greyscale overlay */ | 296 | /* Update LCD areas not covered by the greyscale overlay */ |
234 | static inline void _deferred_update(void) | 297 | static inline void _deferred_update(void) |
235 | { | 298 | { |
@@ -275,6 +338,16 @@ static unsigned long _grey_get_pixel(int x, int y) | |||
275 | /* Timer interrupt handler: display next frame */ | 338 | /* Timer interrupt handler: display next frame */ |
276 | static void _timer_isr(void) | 339 | static void _timer_isr(void) |
277 | { | 340 | { |
341 | #if defined(HAVE_BACKLIGHT_INVERSION) && !defined(SIMULATOR) | ||
342 | bool bls = _grey_info.rb->is_backlight_on(true); | ||
343 | |||
344 | if ((backlight_state != bls) && !(_grey_info.flags & GREY_RAWMAPPED)) | ||
345 | { | ||
346 | backlight_state = bls; | ||
347 | invert_gvalues(); | ||
348 | return; /* don't overload this timer slot */ | ||
349 | } | ||
350 | #endif | ||
278 | #if LCD_PIXELFORMAT == HORIZONTAL_PACKING | 351 | #if LCD_PIXELFORMAT == HORIZONTAL_PACKING |
279 | _grey_info.rb->lcd_blit_grey_phase(_grey_info.values, _grey_info.phases, | 352 | _grey_info.rb->lcd_blit_grey_phase(_grey_info.values, _grey_info.phases, |
280 | _grey_info.bx, _grey_info.y, | 353 | _grey_info.bx, _grey_info.y, |
@@ -343,6 +416,26 @@ static int log_s16p16(int x) | |||
343 | return y; | 416 | return y; |
344 | } | 417 | } |
345 | 418 | ||
419 | static void fill_gvalues(void) | ||
420 | { | ||
421 | int i; | ||
422 | unsigned data; | ||
423 | |||
424 | #if defined(HAVE_BACKLIGHT_INVERSION) && !defined(SIMULATOR) | ||
425 | unsigned imask = backlight_state ? 0xff : 0; | ||
426 | #else | ||
427 | const unsigned imask = 0; | ||
428 | #endif | ||
429 | for (i = 0; i < 256; i++) | ||
430 | { | ||
431 | data = exp_s16p16((_GREY_GAMMA * log_s16p16(i * 257 + 1)) >> 8) + 128; | ||
432 | data = (data - (data >> 8)) >> 8; /* approx. data /= 257 */ | ||
433 | data = ((lcdlinear[data ^ imask] ^ imask) << 7) + 127; | ||
434 | _grey_info.gvalue[i] = (data + (data >> 8)) >> 8; | ||
435 | /* approx. data / 255 */ | ||
436 | } | ||
437 | } | ||
438 | |||
346 | /* Initialise the framework and prepare the greyscale display buffer | 439 | /* Initialise the framework and prepare the greyscale display buffer |
347 | 440 | ||
348 | arguments: | 441 | arguments: |
@@ -449,7 +542,7 @@ bool grey_init(struct plugin_api* newrb, unsigned char *gbuf, long gbuf_size, | |||
449 | _grey_info.by = 0; | 542 | _grey_info.by = 0; |
450 | _grey_info.bheight = bdim; | 543 | _grey_info.bheight = bdim; |
451 | #endif | 544 | #endif |
452 | _grey_info.flags = 0; | 545 | _grey_info.flags = features & 0xff; |
453 | _grey_info.fg_brightness = 0; | 546 | _grey_info.fg_brightness = 0; |
454 | _grey_info.bg_brightness = 255; | 547 | _grey_info.bg_brightness = 255; |
455 | _grey_info.drawmode = DRMODE_SOLID; | 548 | _grey_info.drawmode = DRMODE_SOLID; |
@@ -458,21 +551,21 @@ bool grey_init(struct plugin_api* newrb, unsigned char *gbuf, long gbuf_size, | |||
458 | /* precalculate the value -> pattern index conversion table, taking | 551 | /* precalculate the value -> pattern index conversion table, taking |
459 | linearisation and gamma correction into account */ | 552 | linearisation and gamma correction into account */ |
460 | if (features & GREY_RAWMAPPED) | 553 | if (features & GREY_RAWMAPPED) |
554 | { | ||
461 | for (i = 0; i < 256; i++) | 555 | for (i = 0; i < 256; i++) |
462 | { | 556 | { |
463 | data = i << 7; | 557 | data = i << 7; |
464 | _grey_info.gvalue[i] = (data + (data >> 8)) >> 8; | 558 | _grey_info.gvalue[i] = (data + (data >> 8)) >> 8; |
465 | } | 559 | } |
560 | } | ||
466 | else | 561 | else |
467 | for (i = 0; i < 256; i++) | 562 | { |
468 | { | 563 | #if defined(HAVE_BACKLIGHT_INVERSION) && !defined(SIMULATOR) |
469 | data = exp_s16p16(((2<<8) * log_s16p16(i * 257 + 1)) >> 8) + 128; | 564 | backlight_state = _grey_info.rb->is_backlight_on(true); |
470 | data = (data - (data >> 8)) >> 8; /* approx. data /= 257 */ | 565 | #endif |
471 | data = (lcdlinear[data] << 7) + 127; | 566 | fill_gvalues(); |
472 | _grey_info.gvalue[i] = (data + (data >> 8)) >> 8; | 567 | } |
473 | /* approx. data / 255 */ | 568 | |
474 | } | ||
475 | |||
476 | if (buf_taken) /* caller requested info about space taken */ | 569 | if (buf_taken) /* caller requested info about space taken */ |
477 | *buf_taken = buftaken; | 570 | *buf_taken = buftaken; |
478 | 571 | ||
@@ -509,29 +602,8 @@ void grey_show(bool enable) | |||
509 | #ifdef NEED_BOOST | 602 | #ifdef NEED_BOOST |
510 | _grey_info.rb->cpu_boost(true); | 603 | _grey_info.rb->cpu_boost(true); |
511 | #endif | 604 | #endif |
512 | #if CONFIG_LCD == LCD_SSD1815 | 605 | _grey_info.rb->timer_register(1, NULL, TIMER_FREQ / LCD_SCANRATE, 1, |
513 | _grey_info.rb->timer_register(1, NULL, TIMER_FREQ / 67, 1, _timer_isr); | 606 | _timer_isr); |
514 | #elif CONFIG_LCD == LCD_S1D15E06 | ||
515 | _grey_info.rb->timer_register(1, NULL, TIMER_FREQ / 70, 1, _timer_isr); | ||
516 | #elif CONFIG_LCD == LCD_IPOD2BPP | ||
517 | #ifdef IPOD_1G2G | ||
518 | _grey_info.rb->timer_register(1, NULL, TIMER_FREQ / 96, 1, _timer_isr); /* verified */ | ||
519 | #elif defined IPOD_3G | ||
520 | _grey_info.rb->timer_register(1, NULL, TIMER_FREQ / 87, 1, _timer_isr); /* verified */ | ||
521 | #else | ||
522 | /* FIXME: verify value */ | ||
523 | _grey_info.rb->timer_register(1, NULL, TIMER_FREQ / 80, 1, _timer_isr); | ||
524 | #endif | ||
525 | #elif CONFIG_LCD == LCD_IPODMINI | ||
526 | _grey_info.rb->timer_register(1, NULL, TIMER_FREQ / 88, 1, _timer_isr); | ||
527 | #elif CONFIG_LCD == LCD_IFP7XX | ||
528 | _grey_info.rb->timer_register(1, NULL, TIMER_FREQ / 83, 1, _timer_isr); | ||
529 | #elif CONFIG_LCD == LCD_MROBE100 | ||
530 | _grey_info.rb->timer_register(1, NULL, TIMER_FREQ / 83, 1, _timer_isr); /* not calibrated/tested */ | ||
531 | #elif CONFIG_LCD == LCD_TL0350A | ||
532 | _grey_info.rb->timer_register(1, NULL, TIMER_FREQ / 75, 1, _timer_isr); /* verified */ | ||
533 | /* This is half of the actual frame frequency, but 150Hz is too much */ | ||
534 | #endif /* CONFIG_LCD */ | ||
535 | #endif /* !SIMULATOR */ | 607 | #endif /* !SIMULATOR */ |
536 | _grey_info.rb->screen_dump_set_hook(grey_screendump_hook); | 608 | _grey_info.rb->screen_dump_set_hook(grey_screendump_hook); |
537 | } | 609 | } |