sed156x.c 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562
  1. /*
  2. * (C) Copyright 2003
  3. *
  4. * Pantelis Antoniou <panto@intracom.gr>
  5. * Intracom S.A.
  6. *
  7. * See file CREDITS for list of people who contributed to this
  8. * project.
  9. *
  10. * This program is free software; you can redistribute it and/or
  11. * modify it under the terms of the GNU General Public License as
  12. * published by the Free Software Foundation; either version 2 of
  13. * the License, or (at your option) any later version.
  14. *
  15. * This program is distributed in the hope that it will be useful,
  16. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  17. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  18. * GNU General Public License for more details.
  19. *
  20. * You should have received a copy of the GNU General Public License
  21. * along with this program; if not, write to the Free Software
  22. * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
  23. * MA 02111-1307 USA
  24. */
  25. #include <common.h>
  26. #include <watchdog.h>
  27. #include <sed156x.h>
  28. /* configure according to the selected display */
  29. #if defined(CONFIG_SED156X_PG12864Q)
  30. #define LCD_WIDTH 128
  31. #define LCD_HEIGHT 64
  32. #define LCD_LINES 64
  33. #define LCD_PAGES 9
  34. #define LCD_COLUMNS 132
  35. #else
  36. #error Unsupported SED156x configuration
  37. #endif
  38. /* include the font data */
  39. #include <video_font.h>
  40. #if VIDEO_FONT_WIDTH != 8 || VIDEO_FONT_HEIGHT != 16
  41. #error Expecting VIDEO_FONT_WIDTH == 8 && VIDEO_FONT_HEIGHT == 16
  42. #endif
  43. #define LCD_BYTE_WIDTH (LCD_WIDTH / 8)
  44. #define VIDEO_FONT_BYTE_WIDTH (VIDEO_FONT_WIDTH / 8)
  45. #define LCD_TEXT_WIDTH (LCD_WIDTH / VIDEO_FONT_WIDTH)
  46. #define LCD_TEXT_HEIGHT (LCD_HEIGHT / VIDEO_FONT_HEIGHT)
  47. #define LCD_BYTE_LINESZ (LCD_BYTE_WIDTH * VIDEO_FONT_HEIGHT)
  48. const int sed156x_text_width = LCD_TEXT_WIDTH;
  49. const int sed156x_text_height = LCD_TEXT_HEIGHT;
  50. /**************************************************************************************/
  51. #define SED156X_SPI_RXD() (SED156X_SPI_RXD_PORT & SED156X_SPI_RXD_MASK)
  52. #define SED156X_SPI_TXD(x) \
  53. do { \
  54. if (x) \
  55. SED156X_SPI_TXD_PORT |= SED156X_SPI_TXD_MASK; \
  56. else \
  57. SED156X_SPI_TXD_PORT &= ~SED156X_SPI_TXD_MASK; \
  58. } while(0)
  59. #define SED156X_SPI_CLK(x) \
  60. do { \
  61. if (x) \
  62. SED156X_SPI_CLK_PORT |= SED156X_SPI_CLK_MASK; \
  63. else \
  64. SED156X_SPI_CLK_PORT &= ~SED156X_SPI_CLK_MASK; \
  65. } while(0)
  66. #define SED156X_SPI_CLK_TOGGLE() (SED156X_SPI_CLK_PORT ^= SED156X_SPI_CLK_MASK)
  67. #define SED156X_SPI_BIT_DELAY() /* no delay */
  68. #define SED156X_CS(x) \
  69. do { \
  70. if (x) \
  71. SED156X_CS_PORT |= SED156X_CS_MASK; \
  72. else \
  73. SED156X_CS_PORT &= ~SED156X_CS_MASK; \
  74. } while(0)
  75. #define SED156X_A0(x) \
  76. do { \
  77. if (x) \
  78. SED156X_A0_PORT |= SED156X_A0_MASK; \
  79. else \
  80. SED156X_A0_PORT &= ~SED156X_A0_MASK; \
  81. } while(0)
  82. /**************************************************************************************/
  83. /*** LCD Commands ***/
  84. #define LCD_ON 0xAF /* Display ON */
  85. #define LCD_OFF 0xAE /* Display OFF */
  86. #define LCD_LADDR 0x40 /* Display start line set + (6-bit) address */
  87. #define LCD_PADDR 0xB0 /* Page address set + (4-bit) page */
  88. #define LCD_CADRH 0x10 /* Column address set upper + (4-bit) column hi */
  89. #define LCD_CADRL 0x00 /* Column address set lower + (4-bit) column lo */
  90. #define LCD_ADC_NRM 0xA0 /* ADC select Normal */
  91. #define LCD_ADC_REV 0xA1 /* ADC select Reverse */
  92. #define LCD_DSP_NRM 0xA6 /* LCD display Normal */
  93. #define LCD_DSP_REV 0xA7 /* LCD display Reverse */
  94. #define LCD_DPT_NRM 0xA4 /* Display all points Normal */
  95. #define LCD_DPT_ALL 0xA5 /* Display all points ON */
  96. #define LCD_BIAS9 0xA2 /* LCD bias set 1/9 */
  97. #define LCD_BIAS7 0xA3 /* LCD bias set 1/7 */
  98. #define LCD_CAINC 0xE0 /* Read/modify/write */
  99. #define LCD_CAEND 0xEE /* End */
  100. #define LCD_RESET 0xE2 /* Reset */
  101. #define LCD_C_NRM 0xC0 /* Common output mode select Normal direction */
  102. #define LCD_C_RVS 0xC8 /* Common output mode select Reverse direction */
  103. #define LCD_PWRMD 0x28 /* Power control set + (3-bit) mode */
  104. #define LCD_RESRT 0x20 /* V5 v. reg. int. resistor ratio set + (3-bit) ratio */
  105. #define LCD_EVSET 0x81 /* Electronic volume mode set + byte = (6-bit) volume */
  106. #define LCD_SIOFF 0xAC /* Static indicator OFF */
  107. #define LCD_SION 0xAD /* Static indicator ON + byte = (2-bit) mode */
  108. #define LCD_NOP 0xE3 /* NOP */
  109. #define LCD_TEST 0xF0 /* Test/Test mode reset (Note: *DO NOT USE*) */
  110. /*-------------------------------------------------------------------------------
  111. Compound commands
  112. -------------------------------------------------------------------------------
  113. Command Description Commands
  114. ---------- ------------------------ -------------------------------------
  115. POWS_ON POWER SAVER ON command LCD_OFF, LCD_D_ALL
  116. POWS_OFF POWER SAVER OFF command LCD_D_NRM
  117. SLEEPON SLEEP mode LCD_SIOFF, POWS_ON
  118. SLEEPOFF SLEEP mode cancel LCD_D_NRM, LCD_SION, LCD_SIS_???
  119. STDBYON STAND BY mode LCD_SION, POWS_ON
  120. STDBYOFF STAND BY mode cancel LCD_D_NRM
  121. -------------------------------------------------------------------------------*/
  122. /*** LCD various parameters ***/
  123. #define LCD_PPB 8 /* Pixels per byte (display is B/W, 1 bit per pixel) */
  124. /*** LCD Status byte masks ***/
  125. #define LCD_S_BUSY 0x80 /* Status Read - BUSY mask */
  126. #define LCD_S_ADC 0x40 /* Status Read - ADC mask */
  127. #define LCD_S_ONOFF 0x20 /* Status Read - ON/OFF mask */
  128. #define LCD_S_RESET 0x10 /* Status Read - RESET mask */
  129. /*** LCD commands parameter masks ***/
  130. #define LCD_M_LADDR 0x3F /* Display start line (6-bit) address mask */
  131. #define LCD_M_PADDR 0x0F /* Page address (4-bit) page mask */
  132. #define LCD_M_CADRH 0x0F /* Column address upper (4-bit) column hi mask */
  133. #define LCD_M_CADRL 0x0F /* Column address lower (4-bit) column lo mask */
  134. #define LCD_M_PWRMD 0x07 /* Power control (3-bit) mode mask */
  135. #define LCD_M_RESRT 0x07 /* V5 v. reg. int. resistor ratio (3-bit) ratio mask */
  136. #define LCD_M_EVSET 0x3F /* Electronic volume mode byte (6-bit) volume mask */
  137. #define LCD_M_SION 0x03 /* Static indicator ON (2-bit) mode mask */
  138. /*** LCD Power control cirquits control masks ***/
  139. #define LCD_PWRBSTR 0x04 /* Power control mode - Booster cirquit ON */
  140. #define LCD_PWRVREG 0x02 /* Power control mode - Voltage regulator cirquit ON */
  141. #define LCD_PWRVFOL 0x01 /* Power control mode - Voltage follower cirquit ON */
  142. /*** LCD Static indicator states ***/
  143. #define LCD_SIS_OFF 0x00 /* Static indicator register set - OFF state */
  144. #define LCD_SIS_BL 0x01 /* Static indicator register set - 1s blink state */
  145. #define LCD_SIS_RBL 0x02 /* Static indicator register set - .5s rapid blink state */
  146. #define LCD_SIS_ON 0x03 /* Static indicator register set - constantly on state */
  147. /*** LCD functions special parameters (commands) ***/
  148. #define LCD_PREVP 0x80 /* Page number for moving to previous */
  149. #define LCD_NEXTP 0x81 /* or next page */
  150. #define LCD_ERR_P 0xFF /* Error in page number */
  151. /*** LCD initialization settings ***/
  152. #define LCD_BIAS LCD_BIAS9 /* Bias: 1/9 */
  153. #define LCD_ADCMODE LCD_ADC_NRM /* ADC mode: normal */
  154. #define LCD_COMDIR LCD_C_NRM /* Common output mode: normal */
  155. #define LCD_RRATIO 0 /* Resistor ratio: 0 */
  156. #define LCD_CNTRST 0x1C /* electronic volume: 1Ch */
  157. #define LCD_POWERM (LCD_PWRBSTR | LCD_PWRVREG | LCD_PWRVFOL) /* Power mode: All on */
  158. /**************************************************************************************/
  159. static inline unsigned int sed156x_transfer(unsigned int val)
  160. {
  161. unsigned int rx;
  162. int b;
  163. rx = 0; b = 8;
  164. while (--b >= 0) {
  165. SED156X_SPI_TXD(val & 0x80);
  166. val <<= 1;
  167. SED156X_SPI_CLK_TOGGLE();
  168. SED156X_SPI_BIT_DELAY();
  169. rx <<= 1;
  170. if (SED156X_SPI_RXD())
  171. rx |= 1;
  172. SED156X_SPI_CLK_TOGGLE();
  173. SED156X_SPI_BIT_DELAY();
  174. }
  175. return rx;
  176. }
  177. unsigned int sed156x_data_transfer(unsigned int val)
  178. {
  179. unsigned int rx;
  180. SED156X_SPI_CLK(1);
  181. SED156X_CS(0);
  182. SED156X_A0(1);
  183. rx = sed156x_transfer(val);
  184. SED156X_CS(1);
  185. return rx;
  186. }
  187. void sed156x_data_block_transfer(const u8 *p, int size)
  188. {
  189. SED156X_SPI_CLK(1);
  190. SED156X_CS(0);
  191. SED156X_A0(1);
  192. while (--size >= 0)
  193. sed156x_transfer(*p++);
  194. SED156X_CS(1);
  195. }
  196. unsigned int sed156x_cmd_transfer(unsigned int val)
  197. {
  198. unsigned int rx;
  199. SED156X_SPI_CLK(1);
  200. SED156X_CS(0);
  201. SED156X_A0(0);
  202. rx = sed156x_transfer(val);
  203. SED156X_CS(1);
  204. SED156X_A0(1);
  205. return rx;
  206. }
  207. /******************************************************************************/
  208. static u8 hw_screen[LCD_PAGES][LCD_COLUMNS];
  209. static u8 last_hw_screen[LCD_PAGES][LCD_COLUMNS];
  210. static u8 sw_screen[LCD_BYTE_WIDTH * LCD_HEIGHT];
  211. void sed156x_sync(void)
  212. {
  213. int i, j, last_page;
  214. u8 *d;
  215. const u8 *s, *e, *b, *r;
  216. u8 v0, v1, v2, v3, v4, v5, v6, v7;
  217. /* copy and rotate sw_screen to hw_screen */
  218. for (i = 0; i < LCD_HEIGHT / 8; i++) {
  219. d = &hw_screen[i][0];
  220. s = &sw_screen[LCD_BYTE_WIDTH * 8 * i + LCD_BYTE_WIDTH - 1];
  221. for (j = 0; j < LCD_WIDTH / 8; j++) {
  222. v0 = s[0 * LCD_BYTE_WIDTH];
  223. v1 = s[1 * LCD_BYTE_WIDTH];
  224. v2 = s[2 * LCD_BYTE_WIDTH];
  225. v3 = s[3 * LCD_BYTE_WIDTH];
  226. v4 = s[4 * LCD_BYTE_WIDTH];
  227. v5 = s[5 * LCD_BYTE_WIDTH];
  228. v6 = s[6 * LCD_BYTE_WIDTH];
  229. v7 = s[7 * LCD_BYTE_WIDTH];
  230. d[0] = ((v7 & 0x01) << 7) |
  231. ((v6 & 0x01) << 6) |
  232. ((v5 & 0x01) << 5) |
  233. ((v4 & 0x01) << 4) |
  234. ((v3 & 0x01) << 3) |
  235. ((v2 & 0x01) << 2) |
  236. ((v1 & 0x01) << 1) |
  237. (v0 & 0x01) ;
  238. d[1] = ((v7 & 0x02) << 6) |
  239. ((v6 & 0x02) << 5) |
  240. ((v5 & 0x02) << 4) |
  241. ((v4 & 0x02) << 3) |
  242. ((v3 & 0x02) << 2) |
  243. ((v2 & 0x02) << 1) |
  244. ((v1 & 0x02) << 0) |
  245. ((v0 & 0x02) >> 1) ;
  246. d[2] = ((v7 & 0x04) << 5) |
  247. ((v6 & 0x04) << 4) |
  248. ((v5 & 0x04) << 3) |
  249. ((v4 & 0x04) << 2) |
  250. ((v3 & 0x04) << 1) |
  251. (v2 & 0x04) |
  252. ((v1 & 0x04) >> 1) |
  253. ((v0 & 0x04) >> 2) ;
  254. d[3] = ((v7 & 0x08) << 4) |
  255. ((v6 & 0x08) << 3) |
  256. ((v5 & 0x08) << 2) |
  257. ((v4 & 0x08) << 1) |
  258. (v3 & 0x08) |
  259. ((v2 & 0x08) >> 1) |
  260. ((v1 & 0x08) >> 2) |
  261. ((v0 & 0x08) >> 3) ;
  262. d[4] = ((v7 & 0x10) << 3) |
  263. ((v6 & 0x10) << 2) |
  264. ((v5 & 0x10) << 1) |
  265. (v4 & 0x10) |
  266. ((v3 & 0x10) >> 1) |
  267. ((v2 & 0x10) >> 2) |
  268. ((v1 & 0x10) >> 3) |
  269. ((v0 & 0x10) >> 4) ;
  270. d[5] = ((v7 & 0x20) << 2) |
  271. ((v6 & 0x20) << 1) |
  272. (v5 & 0x20) |
  273. ((v4 & 0x20) >> 1) |
  274. ((v3 & 0x20) >> 2) |
  275. ((v2 & 0x20) >> 3) |
  276. ((v1 & 0x20) >> 4) |
  277. ((v0 & 0x20) >> 5) ;
  278. d[6] = ((v7 & 0x40) << 1) |
  279. (v6 & 0x40) |
  280. ((v5 & 0x40) >> 1) |
  281. ((v4 & 0x40) >> 2) |
  282. ((v3 & 0x40) >> 3) |
  283. ((v2 & 0x40) >> 4) |
  284. ((v1 & 0x40) >> 5) |
  285. ((v0 & 0x40) >> 6) ;
  286. d[7] = (v7 & 0x80) |
  287. ((v6 & 0x80) >> 1) |
  288. ((v5 & 0x80) >> 2) |
  289. ((v4 & 0x80) >> 3) |
  290. ((v3 & 0x80) >> 4) |
  291. ((v2 & 0x80) >> 5) |
  292. ((v1 & 0x80) >> 6) |
  293. ((v0 & 0x80) >> 7) ;
  294. d += 8;
  295. s--;
  296. }
  297. }
  298. /* and now output only the differences */
  299. for (i = 0; i < LCD_PAGES; i++) {
  300. b = &hw_screen[i][0];
  301. e = &hw_screen[i][LCD_COLUMNS];
  302. d = &last_hw_screen[i][0];
  303. s = b;
  304. last_page = -1;
  305. /* update only the differences */
  306. do {
  307. while (s < e && *s == *d) {
  308. s++;
  309. d++;
  310. }
  311. if (s == e)
  312. break;
  313. r = s;
  314. while (s < e && *s != *d)
  315. *d++ = *s++;
  316. j = r - b;
  317. if (i != last_page) {
  318. sed156x_cmd_transfer(LCD_PADDR | i);
  319. last_page = i;
  320. }
  321. sed156x_cmd_transfer(LCD_CADRH | ((j >> 4) & 0x0F));
  322. sed156x_cmd_transfer(LCD_CADRL | (j & 0x0F));
  323. sed156x_data_block_transfer(r, s - r);
  324. } while (s < e);
  325. }
  326. /********
  327. for (i = 0; i < LCD_PAGES; i++) {
  328. sed156x_cmd_transfer(LCD_PADDR | i);
  329. sed156x_cmd_transfer(LCD_CADRH | 0);
  330. sed156x_cmd_transfer(LCD_CADRL | 0);
  331. sed156x_data_block_transfer(&hw_screen[i][0], LCD_COLUMNS);
  332. }
  333. memcpy(last_hw_screen, hw_screen, sizeof(last_hw_screen));
  334. ********/
  335. }
  336. void sed156x_clear(void)
  337. {
  338. memset(sw_screen, 0, sizeof(sw_screen));
  339. }
  340. void sed156x_output_at(int x, int y, const char *str, int size)
  341. {
  342. int i, j;
  343. u8 *p;
  344. const u8 *s;
  345. if ((unsigned int)y >= LCD_TEXT_HEIGHT || (unsigned int)x >= LCD_TEXT_WIDTH)
  346. return;
  347. p = &sw_screen[y * VIDEO_FONT_HEIGHT * LCD_BYTE_WIDTH + x * VIDEO_FONT_BYTE_WIDTH];
  348. while (--size >= 0) {
  349. s = &video_fontdata[((int)*str++ & 0xff) * VIDEO_FONT_BYTE_WIDTH * VIDEO_FONT_HEIGHT];
  350. for (i = 0; i < VIDEO_FONT_HEIGHT; i++) {
  351. for (j = 0; j < VIDEO_FONT_BYTE_WIDTH; j++)
  352. *p++ = *s++;
  353. p += LCD_BYTE_WIDTH - VIDEO_FONT_BYTE_WIDTH;
  354. }
  355. p -= (LCD_BYTE_LINESZ - VIDEO_FONT_BYTE_WIDTH);
  356. if (x >= LCD_TEXT_WIDTH)
  357. break;
  358. x++;
  359. }
  360. }
  361. void sed156x_reverse_at(int x, int y, int size)
  362. {
  363. int i, j;
  364. u8 *p;
  365. if ((unsigned int)y >= LCD_TEXT_HEIGHT || (unsigned int)x >= LCD_TEXT_WIDTH)
  366. return;
  367. p = &sw_screen[y * VIDEO_FONT_HEIGHT * LCD_BYTE_WIDTH + x * VIDEO_FONT_BYTE_WIDTH];
  368. while (--size >= 0) {
  369. for (i = 0; i < VIDEO_FONT_HEIGHT; i++) {
  370. for (j = 0; j < VIDEO_FONT_BYTE_WIDTH; j++, p++)
  371. *p = ~*p;
  372. p += LCD_BYTE_WIDTH - VIDEO_FONT_BYTE_WIDTH;
  373. }
  374. p -= (LCD_BYTE_LINESZ - VIDEO_FONT_BYTE_WIDTH);
  375. if (x >= LCD_TEXT_WIDTH)
  376. break;
  377. x++;
  378. }
  379. }
  380. void sed156x_scroll_line(void)
  381. {
  382. memmove(&sw_screen[0],
  383. &sw_screen[LCD_BYTE_LINESZ],
  384. LCD_BYTE_WIDTH * (LCD_HEIGHT - VIDEO_FONT_HEIGHT));
  385. }
  386. void sed156x_scroll(int dx, int dy)
  387. {
  388. u8 *p1 = NULL, *p2 = NULL, *p3 = NULL; /* pacify gcc */
  389. int adx, ady, i, sz;
  390. adx = dx > 0 ? dx : -dx;
  391. ady = dy > 0 ? dy : -dy;
  392. /* overscroll? erase everything */
  393. if (adx >= LCD_TEXT_WIDTH || ady >= LCD_TEXT_HEIGHT) {
  394. memset(sw_screen, 0, sizeof(sw_screen));
  395. return;
  396. }
  397. sz = LCD_BYTE_LINESZ * ady;
  398. if (dy > 0) {
  399. p1 = &sw_screen[0];
  400. p2 = &sw_screen[sz];
  401. p3 = &sw_screen[LCD_BYTE_WIDTH * LCD_HEIGHT - sz];
  402. } else if (dy < 0) {
  403. p1 = &sw_screen[sz];
  404. p2 = &sw_screen[0];
  405. p3 = &sw_screen[0];
  406. }
  407. if (ady > 0) {
  408. memmove(p1, p2, LCD_BYTE_WIDTH * LCD_HEIGHT - sz);
  409. memset(p3, 0, sz);
  410. }
  411. sz = VIDEO_FONT_BYTE_WIDTH * adx;
  412. if (dx > 0) {
  413. p1 = &sw_screen[0];
  414. p2 = &sw_screen[0] + sz;
  415. p3 = &sw_screen[0] + LCD_BYTE_WIDTH - sz;
  416. } else if (dx < 0) {
  417. p1 = &sw_screen[0] + sz;
  418. p2 = &sw_screen[0];
  419. p3 = &sw_screen[0];
  420. }
  421. /* xscroll */
  422. if (adx > 0) {
  423. for (i = 0; i < LCD_HEIGHT; i++) {
  424. memmove(p1, p2, LCD_BYTE_WIDTH - sz);
  425. memset(p3, 0, sz);
  426. p1 += LCD_BYTE_WIDTH;
  427. p2 += LCD_BYTE_WIDTH;
  428. p3 += LCD_BYTE_WIDTH;
  429. }
  430. }
  431. }
  432. void sed156x_init(void)
  433. {
  434. int i;
  435. SED156X_CS(1);
  436. SED156X_A0(1);
  437. /* Send initialization commands to the LCD */
  438. sed156x_cmd_transfer(LCD_OFF); /* Turn display OFF */
  439. sed156x_cmd_transfer(LCD_BIAS); /* set the LCD Bias, */
  440. sed156x_cmd_transfer(LCD_ADCMODE); /* ADC mode, */
  441. sed156x_cmd_transfer(LCD_COMDIR); /* common output mode, */
  442. sed156x_cmd_transfer(LCD_RESRT | LCD_RRATIO); /* resistor ratio, */
  443. sed156x_cmd_transfer(LCD_EVSET); /* electronic volume, */
  444. sed156x_cmd_transfer(LCD_CNTRST);
  445. sed156x_cmd_transfer(LCD_PWRMD | LCD_POWERM); /* and power mode */
  446. sed156x_cmd_transfer(LCD_PADDR | 0); /* cursor home */
  447. sed156x_cmd_transfer(LCD_CADRH | 0);
  448. sed156x_cmd_transfer(LCD_CADRL | 0);
  449. sed156x_cmd_transfer(LCD_LADDR | 0); /* and display start line */
  450. sed156x_cmd_transfer(LCD_DSP_NRM); /* LCD display Normal */
  451. /* clear everything */
  452. memset(sw_screen, 0, sizeof(sw_screen));
  453. memset(hw_screen, 0, sizeof(hw_screen));
  454. memset(last_hw_screen, 0, sizeof(last_hw_screen));
  455. for (i = 0; i < LCD_PAGES; i++) {
  456. sed156x_cmd_transfer(LCD_PADDR | i);
  457. sed156x_cmd_transfer(LCD_CADRH | 0);
  458. sed156x_cmd_transfer(LCD_CADRL | 0);
  459. sed156x_data_block_transfer(&hw_screen[i][0], LCD_COLUMNS);
  460. }
  461. sed156x_clear();
  462. sed156x_sync();
  463. sed156x_cmd_transfer(LCD_ON); /* Turn display ON */
  464. }