| 1195 | } |
| 1196 | |
| 1197 | static void panel_write_param(uint8_t value) { |
| 1198 | if (likely(panel.paramIter < panel.paramEnd)) { |
| 1199 | uint8_t index = panel.paramIter++; |
| 1200 | #if CEMU_BYTE_ORDER == CEMU_LITTLE_ENDIAN |
| 1201 | /* Swap endianness of word parameters */ |
| 1202 | index ^= (index < offsetof(panel_params_t, MADCTL)); |
| 1203 | #endif |
| 1204 | uint8_t oldValue = ((uint8_t*)&panel.params)[index]; |
| 1205 | ((uint8_t*)&panel.params)[index] = value; |
| 1206 | if (index >= offsetof(panel_params_t, CASET) && index < offsetof(panel_params_t, COLMOD)) { |
| 1207 | /* CASET, RASET, MADCTL */ |
| 1208 | panel_update_write_pixel_bounds(); |
| 1209 | } else if (index == offsetof(panel_params_t, COLMOD)) { |
| 1210 | panel_update_rgb_clock_method(); |
| 1211 | } else if (index == offsetof(panel_params_t, RAMCTRL)) { |
| 1212 | /* Handle display mode switch from RGB to MCU */ |
| 1213 | if (unlikely(panel_next_dm_is_mcu()) && |
| 1214 | panel.displayMode == PANEL_DM_RGB) { |
| 1215 | sched_set(SCHED_PANEL, panel_start_frame()); |
| 1216 | } |
| 1217 | if ((value ^ oldValue) & 1 << 4) { |
| 1218 | if (panel.params.RAMCTRL.RM) { |
| 1219 | /* Handle frame memory pointer reset when switching to RGB interface */ |
| 1220 | panel_reset_mem_ptr(&panel.rgbMemPtr);; |
| 1221 | panel.windowFullRgb = false; |
| 1222 | } |
| 1223 | panel_update_rgb_clock_method(); |
| 1224 | } |
| 1225 | } else if (index == offsetof(panel_params_t, RAMCTRL) + 1) { |
| 1226 | panel_update_rgb_clock_method(); |
| 1227 | } else if (index == offsetof(panel_params_t, RGBCTRL)) { |
| 1228 | if ((value ^ oldValue) & (1 << 7 | 1 << 5)) { |
| 1229 | /* Handle updates to WO and RCM */ |
| 1230 | panel_update_rgb_clock_method(); |
| 1231 | } |
| 1232 | } else if (index == offsetof(panel_params_t, FRCTRL1)) { |
| 1233 | if ((value ^ oldValue) & 3) { |
| 1234 | panel_update_clock_rate(); |
| 1235 | } |
| 1236 | } else if (index == offsetof(panel_params_t, LCMCTRL)) { |
| 1237 | if ((value ^ oldValue) & 1 << 4) { |
| 1238 | panel_spi_catchup(); |
| 1239 | panel_buffer_pixels(); |
| 1240 | panel_invert_luts(); |
| 1241 | } |
| 1242 | panel_update_write_pixel_bounds(); |
| 1243 | } else if (index >= offsetof(panel_params_t, GAMSET)) { |
| 1244 | if (unlikely(index == offsetof(panel_params_t, GAMSET))) { |
| 1245 | const panel_gamma_t *gamma_preset; |
| 1246 | switch (panel.params.GAMSET.GC) { |
| 1247 | case 8: |
| 1248 | gamma_preset = gamma_presets[3]; |
| 1249 | break; |
| 1250 | case 4: |
| 1251 | gamma_preset = gamma_presets[2]; |
| 1252 | break; |
| 1253 | case 2: |
| 1254 | gamma_preset = gamma_presets[1]; |
nothing calls this directly
no test coverage detected